@agentclientprotocol/codex-acp 1.0.1 → 1.1.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/dist/index.js +1616 -501
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -45,35 +45,34 @@ var require_is = __commonJS({
|
|
|
45
45
|
"node_modules/vscode-jsonrpc/lib/common/is.js"(exports) {
|
|
46
46
|
"use strict";
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.
|
|
48
|
+
exports.boolean = boolean4;
|
|
49
|
+
exports.string = string4;
|
|
50
|
+
exports.number = number4;
|
|
51
|
+
exports.error = error51;
|
|
52
|
+
exports.func = func;
|
|
53
|
+
exports.array = array2;
|
|
54
|
+
exports.stringArray = stringArray;
|
|
49
55
|
function boolean4(value) {
|
|
50
56
|
return value === true || value === false;
|
|
51
57
|
}
|
|
52
|
-
exports.boolean = boolean4;
|
|
53
58
|
function string4(value) {
|
|
54
59
|
return typeof value === "string" || value instanceof String;
|
|
55
60
|
}
|
|
56
|
-
exports.string = string4;
|
|
57
61
|
function number4(value) {
|
|
58
62
|
return typeof value === "number" || value instanceof Number;
|
|
59
63
|
}
|
|
60
|
-
exports.number = number4;
|
|
61
64
|
function error51(value) {
|
|
62
65
|
return value instanceof Error;
|
|
63
66
|
}
|
|
64
|
-
exports.error = error51;
|
|
65
67
|
function func(value) {
|
|
66
68
|
return typeof value === "function";
|
|
67
69
|
}
|
|
68
|
-
exports.func = func;
|
|
69
70
|
function array2(value) {
|
|
70
71
|
return Array.isArray(value);
|
|
71
72
|
}
|
|
72
|
-
exports.array = array2;
|
|
73
73
|
function stringArray(value) {
|
|
74
74
|
return array2(value) && value.every((elem) => string4(elem));
|
|
75
75
|
}
|
|
76
|
-
exports.stringArray = stringArray;
|
|
77
76
|
}
|
|
78
77
|
});
|
|
79
78
|
|
|
@@ -81,9 +80,46 @@ var require_is = __commonJS({
|
|
|
81
80
|
var require_messages = __commonJS({
|
|
82
81
|
"node_modules/vscode-jsonrpc/lib/common/messages.js"(exports) {
|
|
83
82
|
"use strict";
|
|
83
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
84
|
+
if (k2 === void 0) k2 = k;
|
|
85
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
86
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
87
|
+
desc = { enumerable: true, get: function() {
|
|
88
|
+
return m[k];
|
|
89
|
+
} };
|
|
90
|
+
}
|
|
91
|
+
Object.defineProperty(o, k2, desc);
|
|
92
|
+
}) : (function(o, m, k, k2) {
|
|
93
|
+
if (k2 === void 0) k2 = k;
|
|
94
|
+
o[k2] = m[k];
|
|
95
|
+
}));
|
|
96
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
97
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
98
|
+
}) : function(o, v) {
|
|
99
|
+
o["default"] = v;
|
|
100
|
+
});
|
|
101
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
|
|
102
|
+
var ownKeys = function(o) {
|
|
103
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
104
|
+
var ar = [];
|
|
105
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
106
|
+
return ar;
|
|
107
|
+
};
|
|
108
|
+
return ownKeys(o);
|
|
109
|
+
};
|
|
110
|
+
return function(mod) {
|
|
111
|
+
if (mod && mod.__esModule) return mod;
|
|
112
|
+
var result = {};
|
|
113
|
+
if (mod != null) {
|
|
114
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
115
|
+
}
|
|
116
|
+
__setModuleDefault(result, mod);
|
|
117
|
+
return result;
|
|
118
|
+
};
|
|
119
|
+
})();
|
|
84
120
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
85
121
|
exports.Message = exports.NotificationType9 = exports.NotificationType8 = exports.NotificationType7 = exports.NotificationType6 = exports.NotificationType5 = exports.NotificationType4 = exports.NotificationType3 = exports.NotificationType2 = exports.NotificationType1 = exports.NotificationType0 = exports.NotificationType = exports.RequestType9 = exports.RequestType8 = exports.RequestType7 = exports.RequestType6 = exports.RequestType5 = exports.RequestType4 = exports.RequestType3 = exports.RequestType2 = exports.RequestType1 = exports.RequestType = exports.RequestType0 = exports.AbstractMessageSignature = exports.ParameterStructures = exports.ResponseError = exports.ErrorCodes = void 0;
|
|
86
|
-
var is = require_is();
|
|
122
|
+
var is = __importStar(require_is());
|
|
87
123
|
var ErrorCodes;
|
|
88
124
|
(function(ErrorCodes2) {
|
|
89
125
|
ErrorCodes2.ParseError = -32700;
|
|
@@ -103,6 +139,8 @@ var require_messages = __commonJS({
|
|
|
103
139
|
ErrorCodes2.serverErrorEnd = -32e3;
|
|
104
140
|
})(ErrorCodes || (exports.ErrorCodes = ErrorCodes = {}));
|
|
105
141
|
var ResponseError = class _ResponseError extends Error {
|
|
142
|
+
code;
|
|
143
|
+
data;
|
|
106
144
|
constructor(code, message, data) {
|
|
107
145
|
super(message);
|
|
108
146
|
this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
|
|
@@ -122,6 +160,23 @@ var require_messages = __commonJS({
|
|
|
122
160
|
};
|
|
123
161
|
exports.ResponseError = ResponseError;
|
|
124
162
|
var ParameterStructures = class _ParameterStructures {
|
|
163
|
+
kind;
|
|
164
|
+
/**
|
|
165
|
+
* The parameter structure is automatically inferred on the number of parameters
|
|
166
|
+
* and the parameter type in case of a single param.
|
|
167
|
+
*/
|
|
168
|
+
static auto = new _ParameterStructures("auto");
|
|
169
|
+
/**
|
|
170
|
+
* Forces `byPosition` parameter structure. This is useful if you have a single
|
|
171
|
+
* parameter which has a literal type.
|
|
172
|
+
*/
|
|
173
|
+
static byPosition = new _ParameterStructures("byPosition");
|
|
174
|
+
/**
|
|
175
|
+
* Forces `byName` parameter structure. This is only useful when having a single
|
|
176
|
+
* parameter. The library will report errors if used with a different number of
|
|
177
|
+
* parameters.
|
|
178
|
+
*/
|
|
179
|
+
static byName = new _ParameterStructures("byName");
|
|
125
180
|
constructor(kind) {
|
|
126
181
|
this.kind = kind;
|
|
127
182
|
}
|
|
@@ -133,10 +188,9 @@ var require_messages = __commonJS({
|
|
|
133
188
|
}
|
|
134
189
|
};
|
|
135
190
|
exports.ParameterStructures = ParameterStructures;
|
|
136
|
-
ParameterStructures.auto = new ParameterStructures("auto");
|
|
137
|
-
ParameterStructures.byPosition = new ParameterStructures("byPosition");
|
|
138
|
-
ParameterStructures.byName = new ParameterStructures("byName");
|
|
139
191
|
var AbstractMessageSignature = class {
|
|
192
|
+
method;
|
|
193
|
+
numberOfParams;
|
|
140
194
|
constructor(method, numberOfParams) {
|
|
141
195
|
this.method = method;
|
|
142
196
|
this.numberOfParams = numberOfParams;
|
|
@@ -147,12 +201,21 @@ var require_messages = __commonJS({
|
|
|
147
201
|
};
|
|
148
202
|
exports.AbstractMessageSignature = AbstractMessageSignature;
|
|
149
203
|
var RequestType0 = class extends AbstractMessageSignature {
|
|
204
|
+
/**
|
|
205
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
206
|
+
*/
|
|
207
|
+
_;
|
|
150
208
|
constructor(method) {
|
|
151
209
|
super(method, 0);
|
|
152
210
|
}
|
|
153
211
|
};
|
|
154
212
|
exports.RequestType0 = RequestType0;
|
|
155
213
|
var RequestType2 = class extends AbstractMessageSignature {
|
|
214
|
+
_parameterStructures;
|
|
215
|
+
/**
|
|
216
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
217
|
+
*/
|
|
218
|
+
_;
|
|
156
219
|
constructor(method, _parameterStructures = ParameterStructures.auto) {
|
|
157
220
|
super(method, 1);
|
|
158
221
|
this._parameterStructures = _parameterStructures;
|
|
@@ -163,6 +226,11 @@ var require_messages = __commonJS({
|
|
|
163
226
|
};
|
|
164
227
|
exports.RequestType = RequestType2;
|
|
165
228
|
var RequestType1 = class extends AbstractMessageSignature {
|
|
229
|
+
_parameterStructures;
|
|
230
|
+
/**
|
|
231
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
232
|
+
*/
|
|
233
|
+
_;
|
|
166
234
|
constructor(method, _parameterStructures = ParameterStructures.auto) {
|
|
167
235
|
super(method, 1);
|
|
168
236
|
this._parameterStructures = _parameterStructures;
|
|
@@ -173,54 +241,91 @@ var require_messages = __commonJS({
|
|
|
173
241
|
};
|
|
174
242
|
exports.RequestType1 = RequestType1;
|
|
175
243
|
var RequestType22 = class extends AbstractMessageSignature {
|
|
244
|
+
/**
|
|
245
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
246
|
+
*/
|
|
247
|
+
_;
|
|
176
248
|
constructor(method) {
|
|
177
249
|
super(method, 2);
|
|
178
250
|
}
|
|
179
251
|
};
|
|
180
252
|
exports.RequestType2 = RequestType22;
|
|
181
253
|
var RequestType3 = class extends AbstractMessageSignature {
|
|
254
|
+
/**
|
|
255
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
256
|
+
*/
|
|
257
|
+
_;
|
|
182
258
|
constructor(method) {
|
|
183
259
|
super(method, 3);
|
|
184
260
|
}
|
|
185
261
|
};
|
|
186
262
|
exports.RequestType3 = RequestType3;
|
|
187
263
|
var RequestType4 = class extends AbstractMessageSignature {
|
|
264
|
+
/**
|
|
265
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
266
|
+
*/
|
|
267
|
+
_;
|
|
188
268
|
constructor(method) {
|
|
189
269
|
super(method, 4);
|
|
190
270
|
}
|
|
191
271
|
};
|
|
192
272
|
exports.RequestType4 = RequestType4;
|
|
193
273
|
var RequestType5 = class extends AbstractMessageSignature {
|
|
274
|
+
/**
|
|
275
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
276
|
+
*/
|
|
277
|
+
_;
|
|
194
278
|
constructor(method) {
|
|
195
279
|
super(method, 5);
|
|
196
280
|
}
|
|
197
281
|
};
|
|
198
282
|
exports.RequestType5 = RequestType5;
|
|
199
283
|
var RequestType6 = class extends AbstractMessageSignature {
|
|
284
|
+
/**
|
|
285
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
286
|
+
*/
|
|
287
|
+
_;
|
|
200
288
|
constructor(method) {
|
|
201
289
|
super(method, 6);
|
|
202
290
|
}
|
|
203
291
|
};
|
|
204
292
|
exports.RequestType6 = RequestType6;
|
|
205
293
|
var RequestType7 = class extends AbstractMessageSignature {
|
|
294
|
+
/**
|
|
295
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
296
|
+
*/
|
|
297
|
+
_;
|
|
206
298
|
constructor(method) {
|
|
207
299
|
super(method, 7);
|
|
208
300
|
}
|
|
209
301
|
};
|
|
210
302
|
exports.RequestType7 = RequestType7;
|
|
211
303
|
var RequestType8 = class extends AbstractMessageSignature {
|
|
304
|
+
/**
|
|
305
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
306
|
+
*/
|
|
307
|
+
_;
|
|
212
308
|
constructor(method) {
|
|
213
309
|
super(method, 8);
|
|
214
310
|
}
|
|
215
311
|
};
|
|
216
312
|
exports.RequestType8 = RequestType8;
|
|
217
313
|
var RequestType9 = class extends AbstractMessageSignature {
|
|
314
|
+
/**
|
|
315
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
316
|
+
*/
|
|
317
|
+
_;
|
|
218
318
|
constructor(method) {
|
|
219
319
|
super(method, 9);
|
|
220
320
|
}
|
|
221
321
|
};
|
|
222
322
|
exports.RequestType9 = RequestType9;
|
|
223
323
|
var NotificationType = class extends AbstractMessageSignature {
|
|
324
|
+
_parameterStructures;
|
|
325
|
+
/**
|
|
326
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
327
|
+
*/
|
|
328
|
+
_;
|
|
224
329
|
constructor(method, _parameterStructures = ParameterStructures.auto) {
|
|
225
330
|
super(method, 1);
|
|
226
331
|
this._parameterStructures = _parameterStructures;
|
|
@@ -231,12 +336,21 @@ var require_messages = __commonJS({
|
|
|
231
336
|
};
|
|
232
337
|
exports.NotificationType = NotificationType;
|
|
233
338
|
var NotificationType0 = class extends AbstractMessageSignature {
|
|
339
|
+
/**
|
|
340
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
341
|
+
*/
|
|
342
|
+
_;
|
|
234
343
|
constructor(method) {
|
|
235
344
|
super(method, 0);
|
|
236
345
|
}
|
|
237
346
|
};
|
|
238
347
|
exports.NotificationType0 = NotificationType0;
|
|
239
348
|
var NotificationType1 = class extends AbstractMessageSignature {
|
|
349
|
+
_parameterStructures;
|
|
350
|
+
/**
|
|
351
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
352
|
+
*/
|
|
353
|
+
_;
|
|
240
354
|
constructor(method, _parameterStructures = ParameterStructures.auto) {
|
|
241
355
|
super(method, 1);
|
|
242
356
|
this._parameterStructures = _parameterStructures;
|
|
@@ -247,71 +361,103 @@ var require_messages = __commonJS({
|
|
|
247
361
|
};
|
|
248
362
|
exports.NotificationType1 = NotificationType1;
|
|
249
363
|
var NotificationType2 = class extends AbstractMessageSignature {
|
|
364
|
+
/**
|
|
365
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
366
|
+
*/
|
|
367
|
+
_;
|
|
250
368
|
constructor(method) {
|
|
251
369
|
super(method, 2);
|
|
252
370
|
}
|
|
253
371
|
};
|
|
254
372
|
exports.NotificationType2 = NotificationType2;
|
|
255
373
|
var NotificationType3 = class extends AbstractMessageSignature {
|
|
374
|
+
/**
|
|
375
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
376
|
+
*/
|
|
377
|
+
_;
|
|
256
378
|
constructor(method) {
|
|
257
379
|
super(method, 3);
|
|
258
380
|
}
|
|
259
381
|
};
|
|
260
382
|
exports.NotificationType3 = NotificationType3;
|
|
261
383
|
var NotificationType4 = class extends AbstractMessageSignature {
|
|
384
|
+
/**
|
|
385
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
386
|
+
*/
|
|
387
|
+
_;
|
|
262
388
|
constructor(method) {
|
|
263
389
|
super(method, 4);
|
|
264
390
|
}
|
|
265
391
|
};
|
|
266
392
|
exports.NotificationType4 = NotificationType4;
|
|
267
393
|
var NotificationType5 = class extends AbstractMessageSignature {
|
|
394
|
+
/**
|
|
395
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
396
|
+
*/
|
|
397
|
+
_;
|
|
268
398
|
constructor(method) {
|
|
269
399
|
super(method, 5);
|
|
270
400
|
}
|
|
271
401
|
};
|
|
272
402
|
exports.NotificationType5 = NotificationType5;
|
|
273
403
|
var NotificationType6 = class extends AbstractMessageSignature {
|
|
404
|
+
/**
|
|
405
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
406
|
+
*/
|
|
407
|
+
_;
|
|
274
408
|
constructor(method) {
|
|
275
409
|
super(method, 6);
|
|
276
410
|
}
|
|
277
411
|
};
|
|
278
412
|
exports.NotificationType6 = NotificationType6;
|
|
279
413
|
var NotificationType7 = class extends AbstractMessageSignature {
|
|
414
|
+
/**
|
|
415
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
416
|
+
*/
|
|
417
|
+
_;
|
|
280
418
|
constructor(method) {
|
|
281
419
|
super(method, 7);
|
|
282
420
|
}
|
|
283
421
|
};
|
|
284
422
|
exports.NotificationType7 = NotificationType7;
|
|
285
423
|
var NotificationType8 = class extends AbstractMessageSignature {
|
|
424
|
+
/**
|
|
425
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
426
|
+
*/
|
|
427
|
+
_;
|
|
286
428
|
constructor(method) {
|
|
287
429
|
super(method, 8);
|
|
288
430
|
}
|
|
289
431
|
};
|
|
290
432
|
exports.NotificationType8 = NotificationType8;
|
|
291
433
|
var NotificationType9 = class extends AbstractMessageSignature {
|
|
434
|
+
/**
|
|
435
|
+
* Clients must not use this property. It is here to ensure correct typing.
|
|
436
|
+
*/
|
|
437
|
+
_;
|
|
292
438
|
constructor(method) {
|
|
293
439
|
super(method, 9);
|
|
294
440
|
}
|
|
295
441
|
};
|
|
296
442
|
exports.NotificationType9 = NotificationType9;
|
|
297
|
-
var
|
|
298
|
-
(function(
|
|
443
|
+
var Message;
|
|
444
|
+
(function(Message2) {
|
|
299
445
|
function isRequest(message) {
|
|
300
446
|
const candidate = message;
|
|
301
447
|
return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
|
|
302
448
|
}
|
|
303
|
-
|
|
449
|
+
Message2.isRequest = isRequest;
|
|
304
450
|
function isNotification(message) {
|
|
305
451
|
const candidate = message;
|
|
306
452
|
return candidate && is.string(candidate.method) && message.id === void 0;
|
|
307
453
|
}
|
|
308
|
-
|
|
454
|
+
Message2.isNotification = isNotification;
|
|
309
455
|
function isResponse(message) {
|
|
310
456
|
const candidate = message;
|
|
311
457
|
return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
|
|
312
458
|
}
|
|
313
|
-
|
|
314
|
-
})(
|
|
459
|
+
Message2.isResponse = isResponse;
|
|
460
|
+
})(Message || (exports.Message = Message = {}));
|
|
315
461
|
}
|
|
316
462
|
});
|
|
317
463
|
|
|
@@ -319,7 +465,6 @@ var require_messages = __commonJS({
|
|
|
319
465
|
var require_linkedMap = __commonJS({
|
|
320
466
|
"node_modules/vscode-jsonrpc/lib/common/linkedMap.js"(exports) {
|
|
321
467
|
"use strict";
|
|
322
|
-
var _a3;
|
|
323
468
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
324
469
|
exports.LRUCache = exports.LinkedMap = exports.Touch = void 0;
|
|
325
470
|
var Touch;
|
|
@@ -331,8 +476,13 @@ var require_linkedMap = __commonJS({
|
|
|
331
476
|
Touch2.AsNew = Touch2.Last;
|
|
332
477
|
})(Touch || (exports.Touch = Touch = {}));
|
|
333
478
|
var LinkedMap = class {
|
|
479
|
+
[Symbol.toStringTag] = "LinkedMap";
|
|
480
|
+
_map;
|
|
481
|
+
_head;
|
|
482
|
+
_tail;
|
|
483
|
+
_size;
|
|
484
|
+
_state;
|
|
334
485
|
constructor() {
|
|
335
|
-
this[_a3] = "LinkedMap";
|
|
336
486
|
this._map = /* @__PURE__ */ new Map();
|
|
337
487
|
this._head = void 0;
|
|
338
488
|
this._tail = void 0;
|
|
@@ -358,6 +508,14 @@ var require_linkedMap = __commonJS({
|
|
|
358
508
|
get last() {
|
|
359
509
|
return this._tail?.value;
|
|
360
510
|
}
|
|
511
|
+
before(key) {
|
|
512
|
+
const item = this._map.get(key);
|
|
513
|
+
return item ? item.previous?.value : void 0;
|
|
514
|
+
}
|
|
515
|
+
after(key) {
|
|
516
|
+
const item = this._map.get(key);
|
|
517
|
+
return item ? item.next?.value : void 0;
|
|
518
|
+
}
|
|
361
519
|
has(key) {
|
|
362
520
|
return this._map.has(key);
|
|
363
521
|
}
|
|
@@ -506,7 +664,7 @@ var require_linkedMap = __commonJS({
|
|
|
506
664
|
};
|
|
507
665
|
return iterator;
|
|
508
666
|
}
|
|
509
|
-
[
|
|
667
|
+
[Symbol.iterator]() {
|
|
510
668
|
return this.entries();
|
|
511
669
|
}
|
|
512
670
|
trimOld(newSize) {
|
|
@@ -645,6 +803,8 @@ var require_linkedMap = __commonJS({
|
|
|
645
803
|
};
|
|
646
804
|
exports.LinkedMap = LinkedMap;
|
|
647
805
|
var LRUCache = class extends LinkedMap {
|
|
806
|
+
_limit;
|
|
807
|
+
_ratio;
|
|
648
808
|
constructor(limit, ratio = 1) {
|
|
649
809
|
super();
|
|
650
810
|
this._limit = limit;
|
|
@@ -691,15 +851,15 @@ var require_disposable = __commonJS({
|
|
|
691
851
|
"use strict";
|
|
692
852
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
693
853
|
exports.Disposable = void 0;
|
|
694
|
-
var
|
|
695
|
-
(function(
|
|
854
|
+
var Disposable;
|
|
855
|
+
(function(Disposable2) {
|
|
696
856
|
function create(func) {
|
|
697
857
|
return {
|
|
698
858
|
dispose: func
|
|
699
859
|
};
|
|
700
860
|
}
|
|
701
|
-
|
|
702
|
-
})(
|
|
861
|
+
Disposable2.create = create;
|
|
862
|
+
})(Disposable || (exports.Disposable = Disposable = {}));
|
|
703
863
|
}
|
|
704
864
|
});
|
|
705
865
|
|
|
@@ -732,9 +892,12 @@ var require_ral = __commonJS({
|
|
|
732
892
|
var require_events = __commonJS({
|
|
733
893
|
"node_modules/vscode-jsonrpc/lib/common/events.js"(exports) {
|
|
734
894
|
"use strict";
|
|
895
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
896
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
897
|
+
};
|
|
735
898
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
736
899
|
exports.Emitter = exports.Event = void 0;
|
|
737
|
-
var ral_1 = require_ral();
|
|
900
|
+
var ral_1 = __importDefault(require_ral());
|
|
738
901
|
var Event;
|
|
739
902
|
(function(Event2) {
|
|
740
903
|
const _disposable = { dispose() {
|
|
@@ -744,6 +907,8 @@ var require_events = __commonJS({
|
|
|
744
907
|
};
|
|
745
908
|
})(Event || (exports.Event = Event = {}));
|
|
746
909
|
var CallbackList = class {
|
|
910
|
+
_callbacks;
|
|
911
|
+
_contexts;
|
|
747
912
|
add(callback, context = null, bucket) {
|
|
748
913
|
if (!this._callbacks) {
|
|
749
914
|
this._callbacks = [];
|
|
@@ -798,6 +963,11 @@ var require_events = __commonJS({
|
|
|
798
963
|
}
|
|
799
964
|
};
|
|
800
965
|
var Emitter2 = class _Emitter {
|
|
966
|
+
_options;
|
|
967
|
+
static _noop = function() {
|
|
968
|
+
};
|
|
969
|
+
_event;
|
|
970
|
+
_callbacks;
|
|
801
971
|
constructor(_options) {
|
|
802
972
|
this._options = _options;
|
|
803
973
|
}
|
|
@@ -852,8 +1022,6 @@ var require_events = __commonJS({
|
|
|
852
1022
|
}
|
|
853
1023
|
};
|
|
854
1024
|
exports.Emitter = Emitter2;
|
|
855
|
-
Emitter2._noop = function() {
|
|
856
|
-
};
|
|
857
1025
|
}
|
|
858
1026
|
});
|
|
859
1027
|
|
|
@@ -861,10 +1029,50 @@ var require_events = __commonJS({
|
|
|
861
1029
|
var require_cancellation = __commonJS({
|
|
862
1030
|
"node_modules/vscode-jsonrpc/lib/common/cancellation.js"(exports) {
|
|
863
1031
|
"use strict";
|
|
1032
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
1033
|
+
if (k2 === void 0) k2 = k;
|
|
1034
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1035
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1036
|
+
desc = { enumerable: true, get: function() {
|
|
1037
|
+
return m[k];
|
|
1038
|
+
} };
|
|
1039
|
+
}
|
|
1040
|
+
Object.defineProperty(o, k2, desc);
|
|
1041
|
+
}) : (function(o, m, k, k2) {
|
|
1042
|
+
if (k2 === void 0) k2 = k;
|
|
1043
|
+
o[k2] = m[k];
|
|
1044
|
+
}));
|
|
1045
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
1046
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1047
|
+
}) : function(o, v) {
|
|
1048
|
+
o["default"] = v;
|
|
1049
|
+
});
|
|
1050
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
|
|
1051
|
+
var ownKeys = function(o) {
|
|
1052
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
1053
|
+
var ar = [];
|
|
1054
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
1055
|
+
return ar;
|
|
1056
|
+
};
|
|
1057
|
+
return ownKeys(o);
|
|
1058
|
+
};
|
|
1059
|
+
return function(mod) {
|
|
1060
|
+
if (mod && mod.__esModule) return mod;
|
|
1061
|
+
var result = {};
|
|
1062
|
+
if (mod != null) {
|
|
1063
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
1064
|
+
}
|
|
1065
|
+
__setModuleDefault(result, mod);
|
|
1066
|
+
return result;
|
|
1067
|
+
};
|
|
1068
|
+
})();
|
|
1069
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1070
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1071
|
+
};
|
|
864
1072
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
865
1073
|
exports.CancellationTokenSource = exports.CancellationToken = void 0;
|
|
866
|
-
var ral_1 = require_ral();
|
|
867
|
-
var Is = require_is();
|
|
1074
|
+
var ral_1 = __importDefault(require_ral());
|
|
1075
|
+
var Is = __importStar(require_is());
|
|
868
1076
|
var events_1 = require_events();
|
|
869
1077
|
var CancellationToken;
|
|
870
1078
|
(function(CancellationToken2) {
|
|
@@ -889,9 +1097,8 @@ var require_cancellation = __commonJS({
|
|
|
889
1097
|
} };
|
|
890
1098
|
});
|
|
891
1099
|
var MutableToken = class {
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
}
|
|
1100
|
+
_isCancelled = false;
|
|
1101
|
+
_emitter;
|
|
895
1102
|
cancel() {
|
|
896
1103
|
if (!this._isCancelled) {
|
|
897
1104
|
this._isCancelled = true;
|
|
@@ -921,6 +1128,7 @@ var require_cancellation = __commonJS({
|
|
|
921
1128
|
}
|
|
922
1129
|
};
|
|
923
1130
|
var CancellationTokenSource = class {
|
|
1131
|
+
_token;
|
|
924
1132
|
get token() {
|
|
925
1133
|
if (!this._token) {
|
|
926
1134
|
this._token = new MutableToken();
|
|
@@ -959,6 +1167,7 @@ var require_sharedArrayCancellation = __commonJS({
|
|
|
959
1167
|
CancellationState2.Cancelled = 1;
|
|
960
1168
|
})(CancellationState || (CancellationState = {}));
|
|
961
1169
|
var SharedArraySenderStrategy = class {
|
|
1170
|
+
buffers;
|
|
962
1171
|
constructor() {
|
|
963
1172
|
this.buffers = /* @__PURE__ */ new Map();
|
|
964
1173
|
}
|
|
@@ -989,6 +1198,7 @@ var require_sharedArrayCancellation = __commonJS({
|
|
|
989
1198
|
};
|
|
990
1199
|
exports.SharedArraySenderStrategy = SharedArraySenderStrategy;
|
|
991
1200
|
var SharedArrayBufferCancellationToken = class {
|
|
1201
|
+
data;
|
|
992
1202
|
constructor(buffer) {
|
|
993
1203
|
this.data = new Int32Array(buffer, 0, 1);
|
|
994
1204
|
}
|
|
@@ -1000,6 +1210,7 @@ var require_sharedArrayCancellation = __commonJS({
|
|
|
1000
1210
|
}
|
|
1001
1211
|
};
|
|
1002
1212
|
var SharedArrayBufferCancellationTokenSource = class {
|
|
1213
|
+
token;
|
|
1003
1214
|
constructor(buffer) {
|
|
1004
1215
|
this.token = new SharedArrayBufferCancellationToken(buffer);
|
|
1005
1216
|
}
|
|
@@ -1009,9 +1220,7 @@ var require_sharedArrayCancellation = __commonJS({
|
|
|
1009
1220
|
}
|
|
1010
1221
|
};
|
|
1011
1222
|
var SharedArrayReceiverStrategy = class {
|
|
1012
|
-
|
|
1013
|
-
this.kind = "request";
|
|
1014
|
-
}
|
|
1223
|
+
kind = "request";
|
|
1015
1224
|
createCancellationTokenSource(request) {
|
|
1016
1225
|
const buffer = request.$cancellationData;
|
|
1017
1226
|
if (buffer === void 0) {
|
|
@@ -1028,10 +1237,16 @@ var require_sharedArrayCancellation = __commonJS({
|
|
|
1028
1237
|
var require_semaphore = __commonJS({
|
|
1029
1238
|
"node_modules/vscode-jsonrpc/lib/common/semaphore.js"(exports) {
|
|
1030
1239
|
"use strict";
|
|
1240
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1241
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1242
|
+
};
|
|
1031
1243
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1032
1244
|
exports.Semaphore = void 0;
|
|
1033
|
-
var ral_1 = require_ral();
|
|
1245
|
+
var ral_1 = __importDefault(require_ral());
|
|
1034
1246
|
var Semaphore = class {
|
|
1247
|
+
_capacity;
|
|
1248
|
+
_active;
|
|
1249
|
+
_waiting;
|
|
1035
1250
|
constructor(capacity = 1) {
|
|
1036
1251
|
if (capacity <= 0) {
|
|
1037
1252
|
throw new Error("Capacity must be greater than 0");
|
|
@@ -1062,7 +1277,7 @@ var require_semaphore = __commonJS({
|
|
|
1062
1277
|
const next = this._waiting.shift();
|
|
1063
1278
|
this._active++;
|
|
1064
1279
|
if (this._active > this._capacity) {
|
|
1065
|
-
throw new Error(`
|
|
1280
|
+
throw new Error(`Too many thunks active`);
|
|
1066
1281
|
}
|
|
1067
1282
|
try {
|
|
1068
1283
|
const result = next.thunk();
|
|
@@ -1096,21 +1311,64 @@ var require_semaphore = __commonJS({
|
|
|
1096
1311
|
var require_messageReader = __commonJS({
|
|
1097
1312
|
"node_modules/vscode-jsonrpc/lib/common/messageReader.js"(exports) {
|
|
1098
1313
|
"use strict";
|
|
1314
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
1315
|
+
if (k2 === void 0) k2 = k;
|
|
1316
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1317
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1318
|
+
desc = { enumerable: true, get: function() {
|
|
1319
|
+
return m[k];
|
|
1320
|
+
} };
|
|
1321
|
+
}
|
|
1322
|
+
Object.defineProperty(o, k2, desc);
|
|
1323
|
+
}) : (function(o, m, k, k2) {
|
|
1324
|
+
if (k2 === void 0) k2 = k;
|
|
1325
|
+
o[k2] = m[k];
|
|
1326
|
+
}));
|
|
1327
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
1328
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1329
|
+
}) : function(o, v) {
|
|
1330
|
+
o["default"] = v;
|
|
1331
|
+
});
|
|
1332
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
|
|
1333
|
+
var ownKeys = function(o) {
|
|
1334
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
1335
|
+
var ar = [];
|
|
1336
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
1337
|
+
return ar;
|
|
1338
|
+
};
|
|
1339
|
+
return ownKeys(o);
|
|
1340
|
+
};
|
|
1341
|
+
return function(mod) {
|
|
1342
|
+
if (mod && mod.__esModule) return mod;
|
|
1343
|
+
var result = {};
|
|
1344
|
+
if (mod != null) {
|
|
1345
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
1346
|
+
}
|
|
1347
|
+
__setModuleDefault(result, mod);
|
|
1348
|
+
return result;
|
|
1349
|
+
};
|
|
1350
|
+
})();
|
|
1351
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1352
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1353
|
+
};
|
|
1099
1354
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1100
1355
|
exports.ReadableStreamMessageReader = exports.AbstractMessageReader = exports.MessageReader = void 0;
|
|
1101
|
-
var ral_1 = require_ral();
|
|
1102
|
-
var Is = require_is();
|
|
1356
|
+
var ral_1 = __importDefault(require_ral());
|
|
1357
|
+
var Is = __importStar(require_is());
|
|
1103
1358
|
var events_1 = require_events();
|
|
1104
1359
|
var semaphore_1 = require_semaphore();
|
|
1105
|
-
var
|
|
1106
|
-
(function(
|
|
1360
|
+
var MessageReader;
|
|
1361
|
+
(function(MessageReader2) {
|
|
1107
1362
|
function is(value) {
|
|
1108
|
-
|
|
1363
|
+
const candidate = value;
|
|
1109
1364
|
return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) && Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
|
|
1110
1365
|
}
|
|
1111
|
-
|
|
1112
|
-
})(
|
|
1366
|
+
MessageReader2.is = is;
|
|
1367
|
+
})(MessageReader || (exports.MessageReader = MessageReader = {}));
|
|
1113
1368
|
var AbstractMessageReader = class {
|
|
1369
|
+
errorEmitter;
|
|
1370
|
+
closeEmitter;
|
|
1371
|
+
partialMessageEmitter;
|
|
1114
1372
|
constructor() {
|
|
1115
1373
|
this.errorEmitter = new events_1.Emitter();
|
|
1116
1374
|
this.closeEmitter = new events_1.Emitter();
|
|
@@ -1119,6 +1377,7 @@ var require_messageReader = __commonJS({
|
|
|
1119
1377
|
dispose() {
|
|
1120
1378
|
this.errorEmitter.dispose();
|
|
1121
1379
|
this.closeEmitter.dispose();
|
|
1380
|
+
this.partialMessageEmitter.dispose();
|
|
1122
1381
|
}
|
|
1123
1382
|
get onError() {
|
|
1124
1383
|
return this.errorEmitter.event;
|
|
@@ -1188,6 +1447,15 @@ var require_messageReader = __commonJS({
|
|
|
1188
1447
|
ResolvedMessageReaderOptions2.fromOptions = fromOptions;
|
|
1189
1448
|
})(ResolvedMessageReaderOptions || (ResolvedMessageReaderOptions = {}));
|
|
1190
1449
|
var ReadableStreamMessageReader = class extends AbstractMessageReader {
|
|
1450
|
+
readable;
|
|
1451
|
+
options;
|
|
1452
|
+
callback;
|
|
1453
|
+
nextMessageLength;
|
|
1454
|
+
messageToken;
|
|
1455
|
+
buffer;
|
|
1456
|
+
partialMessageTimer;
|
|
1457
|
+
_partialMessageTimeout;
|
|
1458
|
+
readSemaphore;
|
|
1191
1459
|
constructor(readable, options) {
|
|
1192
1460
|
super();
|
|
1193
1461
|
this.readable = readable;
|
|
@@ -1285,23 +1553,65 @@ ${JSON.stringify(Object.fromEntries(headers))}`));
|
|
|
1285
1553
|
var require_messageWriter = __commonJS({
|
|
1286
1554
|
"node_modules/vscode-jsonrpc/lib/common/messageWriter.js"(exports) {
|
|
1287
1555
|
"use strict";
|
|
1556
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
1557
|
+
if (k2 === void 0) k2 = k;
|
|
1558
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1559
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1560
|
+
desc = { enumerable: true, get: function() {
|
|
1561
|
+
return m[k];
|
|
1562
|
+
} };
|
|
1563
|
+
}
|
|
1564
|
+
Object.defineProperty(o, k2, desc);
|
|
1565
|
+
}) : (function(o, m, k, k2) {
|
|
1566
|
+
if (k2 === void 0) k2 = k;
|
|
1567
|
+
o[k2] = m[k];
|
|
1568
|
+
}));
|
|
1569
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
1570
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1571
|
+
}) : function(o, v) {
|
|
1572
|
+
o["default"] = v;
|
|
1573
|
+
});
|
|
1574
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
|
|
1575
|
+
var ownKeys = function(o) {
|
|
1576
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
1577
|
+
var ar = [];
|
|
1578
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
1579
|
+
return ar;
|
|
1580
|
+
};
|
|
1581
|
+
return ownKeys(o);
|
|
1582
|
+
};
|
|
1583
|
+
return function(mod) {
|
|
1584
|
+
if (mod && mod.__esModule) return mod;
|
|
1585
|
+
var result = {};
|
|
1586
|
+
if (mod != null) {
|
|
1587
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
1588
|
+
}
|
|
1589
|
+
__setModuleDefault(result, mod);
|
|
1590
|
+
return result;
|
|
1591
|
+
};
|
|
1592
|
+
})();
|
|
1593
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1594
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1595
|
+
};
|
|
1288
1596
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1289
1597
|
exports.WriteableStreamMessageWriter = exports.AbstractMessageWriter = exports.MessageWriter = void 0;
|
|
1290
|
-
var ral_1 = require_ral();
|
|
1291
|
-
var Is = require_is();
|
|
1598
|
+
var ral_1 = __importDefault(require_ral());
|
|
1599
|
+
var Is = __importStar(require_is());
|
|
1292
1600
|
var semaphore_1 = require_semaphore();
|
|
1293
1601
|
var events_1 = require_events();
|
|
1294
1602
|
var ContentLength = "Content-Length: ";
|
|
1295
1603
|
var CRLF = "\r\n";
|
|
1296
|
-
var
|
|
1297
|
-
(function(
|
|
1604
|
+
var MessageWriter;
|
|
1605
|
+
(function(MessageWriter2) {
|
|
1298
1606
|
function is(value) {
|
|
1299
|
-
|
|
1607
|
+
const candidate = value;
|
|
1300
1608
|
return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) && Is.func(candidate.onError) && Is.func(candidate.write);
|
|
1301
1609
|
}
|
|
1302
|
-
|
|
1303
|
-
})(
|
|
1610
|
+
MessageWriter2.is = is;
|
|
1611
|
+
})(MessageWriter || (exports.MessageWriter = MessageWriter = {}));
|
|
1304
1612
|
var AbstractMessageWriter = class {
|
|
1613
|
+
errorEmitter;
|
|
1614
|
+
closeEmitter;
|
|
1305
1615
|
constructor() {
|
|
1306
1616
|
this.errorEmitter = new events_1.Emitter();
|
|
1307
1617
|
this.closeEmitter = new events_1.Emitter();
|
|
@@ -1343,6 +1653,10 @@ var require_messageWriter = __commonJS({
|
|
|
1343
1653
|
ResolvedMessageWriterOptions2.fromOptions = fromOptions;
|
|
1344
1654
|
})(ResolvedMessageWriterOptions || (ResolvedMessageWriterOptions = {}));
|
|
1345
1655
|
var WriteableStreamMessageWriter = class extends AbstractMessageWriter {
|
|
1656
|
+
writable;
|
|
1657
|
+
options;
|
|
1658
|
+
errorCount;
|
|
1659
|
+
writeSemaphore;
|
|
1346
1660
|
constructor(writable, options) {
|
|
1347
1661
|
super();
|
|
1348
1662
|
this.writable = writable;
|
|
@@ -1403,6 +1717,9 @@ var require_messageBuffer = __commonJS({
|
|
|
1403
1717
|
var LF = 10;
|
|
1404
1718
|
var CRLF = "\r\n";
|
|
1405
1719
|
var AbstractMessageBuffer = class {
|
|
1720
|
+
_encoding;
|
|
1721
|
+
_chunks;
|
|
1722
|
+
_totalLength;
|
|
1406
1723
|
constructor(encoding = "utf-8") {
|
|
1407
1724
|
this._encoding = encoding;
|
|
1408
1725
|
this._chunks = [];
|
|
@@ -1427,7 +1744,7 @@ var require_messageBuffer = __commonJS({
|
|
|
1427
1744
|
row: while (chunkIndex < this._chunks.length) {
|
|
1428
1745
|
const chunk = this._chunks[chunkIndex];
|
|
1429
1746
|
offset = 0;
|
|
1430
|
-
|
|
1747
|
+
while (offset < chunk.length) {
|
|
1431
1748
|
const value = chunk[offset];
|
|
1432
1749
|
switch (value) {
|
|
1433
1750
|
case CR:
|
|
@@ -1516,7 +1833,7 @@ ${header}`);
|
|
|
1516
1833
|
}
|
|
1517
1834
|
const result = this.allocNative(byteCount);
|
|
1518
1835
|
let resultOffset = 0;
|
|
1519
|
-
|
|
1836
|
+
const chunkIndex = 0;
|
|
1520
1837
|
while (byteCount > 0) {
|
|
1521
1838
|
const chunk = this._chunks[chunkIndex];
|
|
1522
1839
|
if (chunk.byteLength > byteCount) {
|
|
@@ -1545,10 +1862,51 @@ ${header}`);
|
|
|
1545
1862
|
var require_connection = __commonJS({
|
|
1546
1863
|
"node_modules/vscode-jsonrpc/lib/common/connection.js"(exports) {
|
|
1547
1864
|
"use strict";
|
|
1865
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
1866
|
+
if (k2 === void 0) k2 = k;
|
|
1867
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1868
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1869
|
+
desc = { enumerable: true, get: function() {
|
|
1870
|
+
return m[k];
|
|
1871
|
+
} };
|
|
1872
|
+
}
|
|
1873
|
+
Object.defineProperty(o, k2, desc);
|
|
1874
|
+
}) : (function(o, m, k, k2) {
|
|
1875
|
+
if (k2 === void 0) k2 = k;
|
|
1876
|
+
o[k2] = m[k];
|
|
1877
|
+
}));
|
|
1878
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
1879
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1880
|
+
}) : function(o, v) {
|
|
1881
|
+
o["default"] = v;
|
|
1882
|
+
});
|
|
1883
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
|
|
1884
|
+
var ownKeys = function(o) {
|
|
1885
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
1886
|
+
var ar = [];
|
|
1887
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
1888
|
+
return ar;
|
|
1889
|
+
};
|
|
1890
|
+
return ownKeys(o);
|
|
1891
|
+
};
|
|
1892
|
+
return function(mod) {
|
|
1893
|
+
if (mod && mod.__esModule) return mod;
|
|
1894
|
+
var result = {};
|
|
1895
|
+
if (mod != null) {
|
|
1896
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
1897
|
+
}
|
|
1898
|
+
__setModuleDefault(result, mod);
|
|
1899
|
+
return result;
|
|
1900
|
+
};
|
|
1901
|
+
})();
|
|
1902
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1903
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1904
|
+
};
|
|
1548
1905
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1549
|
-
exports.
|
|
1550
|
-
|
|
1551
|
-
var
|
|
1906
|
+
exports.ConnectionOptions = exports.MessageStrategy = exports.CancellationStrategy = exports.CancellationSenderStrategy = exports.CancellationReceiverStrategy = exports.RequestCancellationReceiverStrategy = exports.IdCancellationReceiverStrategy = exports.ConnectionStrategy = exports.ConnectionError = exports.ConnectionErrors = exports.LogTraceNotification = exports.SetTraceNotification = exports.TraceFormat = exports.TraceValues = exports.TraceValue = exports.Trace = exports.NullLogger = exports.ProgressType = exports.ProgressToken = void 0;
|
|
1907
|
+
exports.createMessageConnection = createMessageConnection2;
|
|
1908
|
+
var ral_1 = __importDefault(require_ral());
|
|
1909
|
+
var Is = __importStar(require_is());
|
|
1552
1910
|
var messages_1 = require_messages();
|
|
1553
1911
|
var linkedMap_1 = require_linkedMap();
|
|
1554
1912
|
var events_1 = require_events();
|
|
@@ -1569,6 +1927,12 @@ var require_connection = __commonJS({
|
|
|
1569
1927
|
ProgressNotification2.type = new messages_1.NotificationType("$/progress");
|
|
1570
1928
|
})(ProgressNotification || (ProgressNotification = {}));
|
|
1571
1929
|
var ProgressType = class {
|
|
1930
|
+
/**
|
|
1931
|
+
* Clients must not use these properties. They are here to ensure correct typing.
|
|
1932
|
+
* in TypeScript
|
|
1933
|
+
*/
|
|
1934
|
+
__;
|
|
1935
|
+
_pr;
|
|
1572
1936
|
constructor() {
|
|
1573
1937
|
}
|
|
1574
1938
|
};
|
|
@@ -1597,13 +1961,14 @@ var require_connection = __commonJS({
|
|
|
1597
1961
|
Trace2[Trace2["Compact"] = 2] = "Compact";
|
|
1598
1962
|
Trace2[Trace2["Verbose"] = 3] = "Verbose";
|
|
1599
1963
|
})(Trace || (exports.Trace = Trace = {}));
|
|
1600
|
-
var
|
|
1601
|
-
(function(
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
})(
|
|
1964
|
+
var TraceValue;
|
|
1965
|
+
(function(TraceValue2) {
|
|
1966
|
+
TraceValue2.Off = "off";
|
|
1967
|
+
TraceValue2.Messages = "messages";
|
|
1968
|
+
TraceValue2.Compact = "compact";
|
|
1969
|
+
TraceValue2.Verbose = "verbose";
|
|
1970
|
+
})(TraceValue || (exports.TraceValue = TraceValue = {}));
|
|
1971
|
+
exports.TraceValues = TraceValue;
|
|
1607
1972
|
(function(Trace2) {
|
|
1608
1973
|
function fromString(value) {
|
|
1609
1974
|
if (!Is.string(value)) {
|
|
@@ -1674,6 +2039,7 @@ var require_connection = __commonJS({
|
|
|
1674
2039
|
ConnectionErrors2[ConnectionErrors2["AlreadyListening"] = 3] = "AlreadyListening";
|
|
1675
2040
|
})(ConnectionErrors || (exports.ConnectionErrors = ConnectionErrors = {}));
|
|
1676
2041
|
var ConnectionError = class _ConnectionError extends Error {
|
|
2042
|
+
code;
|
|
1677
2043
|
constructor(code, message) {
|
|
1678
2044
|
super(message);
|
|
1679
2045
|
this.code = code;
|
|
@@ -1756,7 +2122,7 @@ var require_connection = __commonJS({
|
|
|
1756
2122
|
(function(ConnectionOptions2) {
|
|
1757
2123
|
function is(value) {
|
|
1758
2124
|
const candidate = value;
|
|
1759
|
-
return candidate && (CancellationStrategy.is(candidate.cancellationStrategy) || ConnectionStrategy.is(candidate.connectionStrategy) || MessageStrategy.is(candidate.messageStrategy));
|
|
2125
|
+
return candidate && (CancellationStrategy.is(candidate.cancellationStrategy) || ConnectionStrategy.is(candidate.connectionStrategy) || MessageStrategy.is(candidate.messageStrategy) || Is.number(candidate.maxParallelism));
|
|
1760
2126
|
}
|
|
1761
2127
|
ConnectionOptions2.is = is;
|
|
1762
2128
|
})(ConnectionOptions || (exports.ConnectionOptions = ConnectionOptions = {}));
|
|
@@ -1773,6 +2139,8 @@ var require_connection = __commonJS({
|
|
|
1773
2139
|
let notificationSequenceNumber = 0;
|
|
1774
2140
|
let unknownResponseSequenceNumber = 0;
|
|
1775
2141
|
const version2 = "2.0";
|
|
2142
|
+
const maxParallelism = options?.maxParallelism ?? -1;
|
|
2143
|
+
let inFlight = 0;
|
|
1776
2144
|
let starRequestHandler = void 0;
|
|
1777
2145
|
const requestHandlers = /* @__PURE__ */ new Map();
|
|
1778
2146
|
let starNotificationHandler = void 0;
|
|
@@ -1793,31 +2161,6 @@ var require_connection = __commonJS({
|
|
|
1793
2161
|
const unhandledProgressEmitter = new events_1.Emitter();
|
|
1794
2162
|
const disposeEmitter = new events_1.Emitter();
|
|
1795
2163
|
const cancellationStrategy = options && options.cancellationStrategy ? options.cancellationStrategy : CancellationStrategy.Message;
|
|
1796
|
-
function createRequestQueueKey(id) {
|
|
1797
|
-
if (id === null) {
|
|
1798
|
-
throw new Error(`Can't send requests with id null since the response can't be correlated.`);
|
|
1799
|
-
}
|
|
1800
|
-
return "req-" + id.toString();
|
|
1801
|
-
}
|
|
1802
|
-
function createResponseQueueKey(id) {
|
|
1803
|
-
if (id === null) {
|
|
1804
|
-
return "res-unknown-" + (++unknownResponseSequenceNumber).toString();
|
|
1805
|
-
} else {
|
|
1806
|
-
return "res-" + id.toString();
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
function createNotificationQueueKey() {
|
|
1810
|
-
return "not-" + (++notificationSequenceNumber).toString();
|
|
1811
|
-
}
|
|
1812
|
-
function addMessageToQueue(queue, message) {
|
|
1813
|
-
if (messages_1.Message.isRequest(message)) {
|
|
1814
|
-
queue.set(createRequestQueueKey(message.id), message);
|
|
1815
|
-
} else if (messages_1.Message.isResponse(message)) {
|
|
1816
|
-
queue.set(createResponseQueueKey(message.id), message);
|
|
1817
|
-
} else {
|
|
1818
|
-
queue.set(createNotificationQueueKey(), message);
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1821
2164
|
function cancelUndispatched(_message) {
|
|
1822
2165
|
return void 0;
|
|
1823
2166
|
}
|
|
@@ -1846,40 +2189,86 @@ var require_connection = __commonJS({
|
|
|
1846
2189
|
messageReader.onError(readErrorHandler);
|
|
1847
2190
|
messageWriter.onClose(closeHandler);
|
|
1848
2191
|
messageWriter.onError(writeErrorHandler);
|
|
2192
|
+
function createRequestQueueKey(id) {
|
|
2193
|
+
if (id === null) {
|
|
2194
|
+
throw new Error(`Can't send requests with id null since the response can't be correlated.`);
|
|
2195
|
+
}
|
|
2196
|
+
return "req-" + id.toString();
|
|
2197
|
+
}
|
|
2198
|
+
function createResponseQueueKey(id) {
|
|
2199
|
+
if (id === null) {
|
|
2200
|
+
return "res-unknown-" + (++unknownResponseSequenceNumber).toString();
|
|
2201
|
+
} else {
|
|
2202
|
+
return "res-" + id.toString();
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
function createNotificationQueueKey() {
|
|
2206
|
+
return "not-" + (++notificationSequenceNumber).toString();
|
|
2207
|
+
}
|
|
2208
|
+
function addMessageToQueue(queue, message) {
|
|
2209
|
+
if (messages_1.Message.isRequest(message)) {
|
|
2210
|
+
queue.set(createRequestQueueKey(message.id), message);
|
|
2211
|
+
} else if (messages_1.Message.isResponse(message)) {
|
|
2212
|
+
if (maxParallelism === -1) {
|
|
2213
|
+
queue.set(createResponseQueueKey(message.id), message);
|
|
2214
|
+
} else {
|
|
2215
|
+
handleResponse(message);
|
|
2216
|
+
}
|
|
2217
|
+
} else {
|
|
2218
|
+
queue.set(createNotificationQueueKey(), message);
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
1849
2221
|
function triggerMessageQueue() {
|
|
1850
2222
|
if (timer || messageQueue.size === 0) {
|
|
1851
2223
|
return;
|
|
1852
2224
|
}
|
|
1853
|
-
|
|
2225
|
+
if (maxParallelism !== -1 && inFlight >= maxParallelism) {
|
|
2226
|
+
return;
|
|
2227
|
+
}
|
|
2228
|
+
timer = (0, ral_1.default)().timer.setImmediate(async () => {
|
|
1854
2229
|
timer = void 0;
|
|
1855
|
-
|
|
2230
|
+
if (messageQueue.size === 0) {
|
|
2231
|
+
return;
|
|
2232
|
+
}
|
|
2233
|
+
if (maxParallelism !== -1 && inFlight >= maxParallelism) {
|
|
2234
|
+
return;
|
|
2235
|
+
}
|
|
2236
|
+
const message = messageQueue.shift();
|
|
2237
|
+
let result;
|
|
2238
|
+
try {
|
|
2239
|
+
inFlight++;
|
|
2240
|
+
const messageStrategy = options?.messageStrategy;
|
|
2241
|
+
if (MessageStrategy.is(messageStrategy)) {
|
|
2242
|
+
result = messageStrategy.handleMessage(message, handleMessage);
|
|
2243
|
+
} else {
|
|
2244
|
+
result = handleMessage(message);
|
|
2245
|
+
}
|
|
2246
|
+
} catch (error51) {
|
|
2247
|
+
logger2.error(`Processing message queue failed: ${error51.toString()}`);
|
|
2248
|
+
} finally {
|
|
2249
|
+
if (result instanceof Promise) {
|
|
2250
|
+
result.then(() => {
|
|
2251
|
+
inFlight--;
|
|
2252
|
+
triggerMessageQueue();
|
|
2253
|
+
}).catch((error51) => {
|
|
2254
|
+
logger2.error(`Processing message queue failed: ${error51.toString()}`);
|
|
2255
|
+
});
|
|
2256
|
+
} else {
|
|
2257
|
+
inFlight--;
|
|
2258
|
+
}
|
|
2259
|
+
triggerMessageQueue();
|
|
2260
|
+
}
|
|
1856
2261
|
});
|
|
1857
2262
|
}
|
|
1858
|
-
function handleMessage(message) {
|
|
2263
|
+
async function handleMessage(message) {
|
|
1859
2264
|
if (messages_1.Message.isRequest(message)) {
|
|
1860
|
-
handleRequest(message);
|
|
2265
|
+
return handleRequest(message);
|
|
1861
2266
|
} else if (messages_1.Message.isNotification(message)) {
|
|
1862
|
-
handleNotification(message);
|
|
2267
|
+
return handleNotification(message);
|
|
1863
2268
|
} else if (messages_1.Message.isResponse(message)) {
|
|
1864
|
-
handleResponse(message);
|
|
2269
|
+
return handleResponse(message);
|
|
1865
2270
|
} else {
|
|
1866
|
-
handleInvalidMessage(message);
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
function processMessageQueue() {
|
|
1870
|
-
if (messageQueue.size === 0) {
|
|
1871
|
-
return;
|
|
1872
|
-
}
|
|
1873
|
-
const message = messageQueue.shift();
|
|
1874
|
-
try {
|
|
1875
|
-
const messageStrategy = options?.messageStrategy;
|
|
1876
|
-
if (MessageStrategy.is(messageStrategy)) {
|
|
1877
|
-
messageStrategy.handleMessage(message, handleMessage);
|
|
1878
|
-
} else {
|
|
1879
|
-
handleMessage(message);
|
|
1880
|
-
}
|
|
1881
|
-
} finally {
|
|
1882
|
-
triggerMessageQueue();
|
|
2271
|
+
return handleInvalidMessage(message);
|
|
1883
2272
|
}
|
|
1884
2273
|
}
|
|
1885
2274
|
const callback = (message) => {
|
|
@@ -1914,9 +2303,9 @@ var require_connection = __commonJS({
|
|
|
1914
2303
|
triggerMessageQueue();
|
|
1915
2304
|
}
|
|
1916
2305
|
};
|
|
1917
|
-
function handleRequest(requestMessage) {
|
|
2306
|
+
async function handleRequest(requestMessage) {
|
|
1918
2307
|
if (isDisposed()) {
|
|
1919
|
-
return;
|
|
2308
|
+
return Promise.resolve();
|
|
1920
2309
|
}
|
|
1921
2310
|
function reply(resultOrError, method, startTime2) {
|
|
1922
2311
|
const message = {
|
|
@@ -1929,7 +2318,7 @@ var require_connection = __commonJS({
|
|
|
1929
2318
|
message.result = resultOrError === void 0 ? null : resultOrError;
|
|
1930
2319
|
}
|
|
1931
2320
|
traceSendingResponse(message, method, startTime2);
|
|
1932
|
-
messageWriter.write(message)
|
|
2321
|
+
return messageWriter.write(message);
|
|
1933
2322
|
}
|
|
1934
2323
|
function replyError(error51, method, startTime2) {
|
|
1935
2324
|
const message = {
|
|
@@ -1938,19 +2327,7 @@ var require_connection = __commonJS({
|
|
|
1938
2327
|
error: error51.toJson()
|
|
1939
2328
|
};
|
|
1940
2329
|
traceSendingResponse(message, method, startTime2);
|
|
1941
|
-
messageWriter.write(message)
|
|
1942
|
-
}
|
|
1943
|
-
function replySuccess(result, method, startTime2) {
|
|
1944
|
-
if (result === void 0) {
|
|
1945
|
-
result = null;
|
|
1946
|
-
}
|
|
1947
|
-
const message = {
|
|
1948
|
-
jsonrpc: version2,
|
|
1949
|
-
id: requestMessage.id,
|
|
1950
|
-
result
|
|
1951
|
-
};
|
|
1952
|
-
traceSendingResponse(message, method, startTime2);
|
|
1953
|
-
messageWriter.write(message).catch(() => logger2.error(`Sending response failed.`));
|
|
2330
|
+
return messageWriter.write(message);
|
|
1954
2331
|
}
|
|
1955
2332
|
traceReceivedRequest(requestMessage);
|
|
1956
2333
|
const element = requestHandlers.get(requestMessage.method);
|
|
@@ -1975,60 +2352,38 @@ var require_connection = __commonJS({
|
|
|
1975
2352
|
if (requestHandler) {
|
|
1976
2353
|
if (requestMessage.params === void 0) {
|
|
1977
2354
|
if (type !== void 0 && type.numberOfParams !== 0) {
|
|
1978
|
-
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines ${type.numberOfParams} params but received none.`), requestMessage.method, startTime);
|
|
1979
|
-
return;
|
|
2355
|
+
return replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines ${type.numberOfParams} params but received none.`), requestMessage.method, startTime);
|
|
1980
2356
|
}
|
|
1981
2357
|
handlerResult = requestHandler(cancellationSource.token);
|
|
1982
2358
|
} else if (Array.isArray(requestMessage.params)) {
|
|
1983
2359
|
if (type !== void 0 && type.parameterStructures === messages_1.ParameterStructures.byName) {
|
|
1984
|
-
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines parameters by name but received parameters by position`), requestMessage.method, startTime);
|
|
1985
|
-
return;
|
|
2360
|
+
return replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines parameters by name but received parameters by position`), requestMessage.method, startTime);
|
|
1986
2361
|
}
|
|
1987
2362
|
handlerResult = requestHandler(...requestMessage.params, cancellationSource.token);
|
|
1988
2363
|
} else {
|
|
1989
2364
|
if (type !== void 0 && type.parameterStructures === messages_1.ParameterStructures.byPosition) {
|
|
1990
|
-
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines parameters by position but received parameters by name`), requestMessage.method, startTime);
|
|
1991
|
-
return;
|
|
2365
|
+
return replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines parameters by position but received parameters by name`), requestMessage.method, startTime);
|
|
1992
2366
|
}
|
|
1993
2367
|
handlerResult = requestHandler(requestMessage.params, cancellationSource.token);
|
|
1994
2368
|
}
|
|
1995
2369
|
} else if (starRequestHandler) {
|
|
1996
2370
|
handlerResult = starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
|
|
1997
2371
|
}
|
|
1998
|
-
const
|
|
1999
|
-
|
|
2000
|
-
requestTokens.delete(tokenKey);
|
|
2001
|
-
replySuccess(handlerResult, requestMessage.method, startTime);
|
|
2002
|
-
} else if (promise2.then) {
|
|
2003
|
-
promise2.then((resultOrError) => {
|
|
2004
|
-
requestTokens.delete(tokenKey);
|
|
2005
|
-
reply(resultOrError, requestMessage.method, startTime);
|
|
2006
|
-
}, (error51) => {
|
|
2007
|
-
requestTokens.delete(tokenKey);
|
|
2008
|
-
if (error51 instanceof messages_1.ResponseError) {
|
|
2009
|
-
replyError(error51, requestMessage.method, startTime);
|
|
2010
|
-
} else if (error51 && Is.string(error51.message)) {
|
|
2011
|
-
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error51.message}`), requestMessage.method, startTime);
|
|
2012
|
-
} else {
|
|
2013
|
-
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
|
|
2014
|
-
}
|
|
2015
|
-
});
|
|
2016
|
-
} else {
|
|
2017
|
-
requestTokens.delete(tokenKey);
|
|
2018
|
-
reply(handlerResult, requestMessage.method, startTime);
|
|
2019
|
-
}
|
|
2372
|
+
const resultOrError = await handlerResult;
|
|
2373
|
+
await reply(resultOrError, requestMessage.method, startTime);
|
|
2020
2374
|
} catch (error51) {
|
|
2021
|
-
requestTokens.delete(tokenKey);
|
|
2022
2375
|
if (error51 instanceof messages_1.ResponseError) {
|
|
2023
|
-
reply(error51, requestMessage.method, startTime);
|
|
2376
|
+
await reply(error51, requestMessage.method, startTime);
|
|
2024
2377
|
} else if (error51 && Is.string(error51.message)) {
|
|
2025
|
-
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error51.message}`), requestMessage.method, startTime);
|
|
2378
|
+
await replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error51.message}`), requestMessage.method, startTime);
|
|
2026
2379
|
} else {
|
|
2027
|
-
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
|
|
2380
|
+
await replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
|
|
2028
2381
|
}
|
|
2382
|
+
} finally {
|
|
2383
|
+
requestTokens.delete(tokenKey);
|
|
2029
2384
|
}
|
|
2030
2385
|
} else {
|
|
2031
|
-
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
|
|
2386
|
+
await replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
|
|
2032
2387
|
}
|
|
2033
2388
|
}
|
|
2034
2389
|
function handleResponse(responseMessage) {
|
|
@@ -2067,7 +2422,7 @@ ${JSON.stringify(responseMessage.error, void 0, 4)}`);
|
|
|
2067
2422
|
}
|
|
2068
2423
|
}
|
|
2069
2424
|
}
|
|
2070
|
-
function handleNotification(message) {
|
|
2425
|
+
async function handleNotification(message) {
|
|
2071
2426
|
if (isDisposed()) {
|
|
2072
2427
|
return;
|
|
2073
2428
|
}
|
|
@@ -2095,11 +2450,11 @@ ${JSON.stringify(responseMessage.error, void 0, 4)}`);
|
|
|
2095
2450
|
logger2.error(`Notification ${message.method} defines ${type.numberOfParams} params but received none.`);
|
|
2096
2451
|
}
|
|
2097
2452
|
}
|
|
2098
|
-
notificationHandler();
|
|
2453
|
+
await notificationHandler();
|
|
2099
2454
|
} else if (Array.isArray(message.params)) {
|
|
2100
2455
|
const params = message.params;
|
|
2101
2456
|
if (message.method === ProgressNotification.type.method && params.length === 2 && ProgressToken.is(params[0])) {
|
|
2102
|
-
notificationHandler({ token: params[0], value: params[1] });
|
|
2457
|
+
await notificationHandler({ token: params[0], value: params[1] });
|
|
2103
2458
|
} else {
|
|
2104
2459
|
if (type !== void 0) {
|
|
2105
2460
|
if (type.parameterStructures === messages_1.ParameterStructures.byName) {
|
|
@@ -2109,16 +2464,16 @@ ${JSON.stringify(responseMessage.error, void 0, 4)}`);
|
|
|
2109
2464
|
logger2.error(`Notification ${message.method} defines ${type.numberOfParams} params but received ${params.length} arguments`);
|
|
2110
2465
|
}
|
|
2111
2466
|
}
|
|
2112
|
-
notificationHandler(...params);
|
|
2467
|
+
await notificationHandler(...params);
|
|
2113
2468
|
}
|
|
2114
2469
|
} else {
|
|
2115
2470
|
if (type !== void 0 && type.parameterStructures === messages_1.ParameterStructures.byPosition) {
|
|
2116
2471
|
logger2.error(`Notification ${message.method} defines parameters by position but received parameters by name`);
|
|
2117
2472
|
}
|
|
2118
|
-
notificationHandler(message.params);
|
|
2473
|
+
await notificationHandler(message.params);
|
|
2119
2474
|
}
|
|
2120
2475
|
} else if (starNotificationHandler) {
|
|
2121
|
-
starNotificationHandler(message.method, message.params);
|
|
2476
|
+
await starNotificationHandler(message.method, message.params);
|
|
2122
2477
|
}
|
|
2123
2478
|
} catch (error51) {
|
|
2124
2479
|
if (error51.message) {
|
|
@@ -2167,9 +2522,7 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2167
2522
|
if (traceFormat === TraceFormat.Text) {
|
|
2168
2523
|
let data = void 0;
|
|
2169
2524
|
if ((trace === Trace.Verbose || trace === Trace.Compact) && message.params) {
|
|
2170
|
-
data = `Params: ${stringifyTrace(message.params)}
|
|
2171
|
-
|
|
2172
|
-
`;
|
|
2525
|
+
data = `Params: ${stringifyTrace(message.params)}`;
|
|
2173
2526
|
}
|
|
2174
2527
|
tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
|
|
2175
2528
|
} else {
|
|
@@ -2184,11 +2537,9 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2184
2537
|
let data = void 0;
|
|
2185
2538
|
if (trace === Trace.Verbose || trace === Trace.Compact) {
|
|
2186
2539
|
if (message.params) {
|
|
2187
|
-
data = `Params: ${stringifyTrace(message.params)}
|
|
2188
|
-
|
|
2189
|
-
`;
|
|
2540
|
+
data = `Params: ${stringifyTrace(message.params)}`;
|
|
2190
2541
|
} else {
|
|
2191
|
-
data = "No parameters provided
|
|
2542
|
+
data = "No parameters provided.";
|
|
2192
2543
|
}
|
|
2193
2544
|
}
|
|
2194
2545
|
tracer.log(`Sending notification '${message.method}'.`, data);
|
|
@@ -2204,16 +2555,12 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2204
2555
|
let data = void 0;
|
|
2205
2556
|
if (trace === Trace.Verbose || trace === Trace.Compact) {
|
|
2206
2557
|
if (message.error && message.error.data) {
|
|
2207
|
-
data = `Error data: ${stringifyTrace(message.error.data)}
|
|
2208
|
-
|
|
2209
|
-
`;
|
|
2558
|
+
data = `Error data: ${stringifyTrace(message.error.data)}`;
|
|
2210
2559
|
} else {
|
|
2211
2560
|
if (message.result) {
|
|
2212
|
-
data = `Result: ${stringifyTrace(message.result)}
|
|
2213
|
-
|
|
2214
|
-
`;
|
|
2561
|
+
data = `Result: ${stringifyTrace(message.result)}`;
|
|
2215
2562
|
} else if (message.error === void 0) {
|
|
2216
|
-
data = "No result returned
|
|
2563
|
+
data = "No result returned.";
|
|
2217
2564
|
}
|
|
2218
2565
|
}
|
|
2219
2566
|
}
|
|
@@ -2229,9 +2576,7 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2229
2576
|
if (traceFormat === TraceFormat.Text) {
|
|
2230
2577
|
let data = void 0;
|
|
2231
2578
|
if ((trace === Trace.Verbose || trace === Trace.Compact) && message.params) {
|
|
2232
|
-
data = `Params: ${stringifyTrace(message.params)}
|
|
2233
|
-
|
|
2234
|
-
`;
|
|
2579
|
+
data = `Params: ${stringifyTrace(message.params)}`;
|
|
2235
2580
|
}
|
|
2236
2581
|
tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
|
|
2237
2582
|
} else {
|
|
@@ -2246,11 +2591,9 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2246
2591
|
let data = void 0;
|
|
2247
2592
|
if (trace === Trace.Verbose || trace === Trace.Compact) {
|
|
2248
2593
|
if (message.params) {
|
|
2249
|
-
data = `Params: ${stringifyTrace(message.params)}
|
|
2250
|
-
|
|
2251
|
-
`;
|
|
2594
|
+
data = `Params: ${stringifyTrace(message.params)}`;
|
|
2252
2595
|
} else {
|
|
2253
|
-
data = "No parameters provided
|
|
2596
|
+
data = "No parameters provided.";
|
|
2254
2597
|
}
|
|
2255
2598
|
}
|
|
2256
2599
|
tracer.log(`Received notification '${message.method}'.`, data);
|
|
@@ -2266,16 +2609,12 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2266
2609
|
let data = void 0;
|
|
2267
2610
|
if (trace === Trace.Verbose || trace === Trace.Compact) {
|
|
2268
2611
|
if (message.error && message.error.data) {
|
|
2269
|
-
data = `Error data: ${stringifyTrace(message.error.data)}
|
|
2270
|
-
|
|
2271
|
-
`;
|
|
2612
|
+
data = `Error data: ${stringifyTrace(message.error.data)}`;
|
|
2272
2613
|
} else {
|
|
2273
2614
|
if (message.result) {
|
|
2274
|
-
data = `Result: ${stringifyTrace(message.result)}
|
|
2275
|
-
|
|
2276
|
-
`;
|
|
2615
|
+
data = `Result: ${stringifyTrace(message.result)}`;
|
|
2277
2616
|
} else if (message.error === void 0) {
|
|
2278
|
-
data = "No result returned
|
|
2617
|
+
data = "No result returned.";
|
|
2279
2618
|
}
|
|
2280
2619
|
}
|
|
2281
2620
|
}
|
|
@@ -2393,7 +2732,7 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2393
2732
|
paramStart = 1;
|
|
2394
2733
|
parameterStructures = first;
|
|
2395
2734
|
}
|
|
2396
|
-
|
|
2735
|
+
const paramEnd = args.length;
|
|
2397
2736
|
const numberOfParams = paramEnd - paramStart;
|
|
2398
2737
|
switch (numberOfParams) {
|
|
2399
2738
|
case 0:
|
|
@@ -2442,8 +2781,10 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2442
2781
|
return {
|
|
2443
2782
|
dispose: () => {
|
|
2444
2783
|
if (method !== void 0) {
|
|
2445
|
-
notificationHandlers.
|
|
2446
|
-
|
|
2784
|
+
if (notificationHandlers.get(method)?.handler === handler) {
|
|
2785
|
+
notificationHandlers.delete(method);
|
|
2786
|
+
}
|
|
2787
|
+
} else if (starNotificationHandler === type) {
|
|
2447
2788
|
starNotificationHandler = void 0;
|
|
2448
2789
|
}
|
|
2449
2790
|
}
|
|
@@ -2456,7 +2797,9 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2456
2797
|
progressHandlers.set(token, handler);
|
|
2457
2798
|
return {
|
|
2458
2799
|
dispose: () => {
|
|
2459
|
-
progressHandlers.
|
|
2800
|
+
if (progressHandlers.get(token) === handler) {
|
|
2801
|
+
progressHandlers.delete(token);
|
|
2802
|
+
}
|
|
2460
2803
|
}
|
|
2461
2804
|
};
|
|
2462
2805
|
},
|
|
@@ -2467,6 +2810,16 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2467
2810
|
sendRequest: (type, ...args) => {
|
|
2468
2811
|
throwIfClosedOrDisposed();
|
|
2469
2812
|
throwIfNotListening();
|
|
2813
|
+
function sendCancellation(connection2, id2) {
|
|
2814
|
+
const p = cancellationStrategy.sender.sendCancellation(connection2, id2);
|
|
2815
|
+
if (p === void 0) {
|
|
2816
|
+
logger2.log(`Received no promise from cancellation strategy when cancelling id ${id2}`);
|
|
2817
|
+
} else {
|
|
2818
|
+
p.catch(() => {
|
|
2819
|
+
logger2.log(`Sending cancellation messages for id ${id2} failed.`);
|
|
2820
|
+
});
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2470
2823
|
let method;
|
|
2471
2824
|
let messageParams;
|
|
2472
2825
|
let token = void 0;
|
|
@@ -2509,18 +2862,15 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2509
2862
|
}
|
|
2510
2863
|
const id = sequenceNumber++;
|
|
2511
2864
|
let disposable;
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
});
|
|
2522
|
-
}
|
|
2523
|
-
});
|
|
2865
|
+
let tokenWasCancelled = false;
|
|
2866
|
+
if (token !== void 0) {
|
|
2867
|
+
if (token.isCancellationRequested) {
|
|
2868
|
+
tokenWasCancelled = true;
|
|
2869
|
+
} else {
|
|
2870
|
+
disposable = token.onCancellationRequested(() => {
|
|
2871
|
+
sendCancellation(connection, id);
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2524
2874
|
}
|
|
2525
2875
|
const requestMessage = {
|
|
2526
2876
|
jsonrpc: version2,
|
|
@@ -2547,6 +2897,9 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2547
2897
|
try {
|
|
2548
2898
|
responsePromises.set(id, responsePromise);
|
|
2549
2899
|
await messageWriter.write(requestMessage);
|
|
2900
|
+
if (tokenWasCancelled) {
|
|
2901
|
+
sendCancellation(connection, id);
|
|
2902
|
+
}
|
|
2550
2903
|
} catch (error51) {
|
|
2551
2904
|
responsePromises.delete(id);
|
|
2552
2905
|
responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, error51.message ? error51.message : "Unknown reason"));
|
|
@@ -2579,8 +2932,10 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2579
2932
|
return;
|
|
2580
2933
|
}
|
|
2581
2934
|
if (method !== void 0) {
|
|
2582
|
-
requestHandlers.
|
|
2583
|
-
|
|
2935
|
+
if (requestHandlers.get(method)?.handler === handler) {
|
|
2936
|
+
requestHandlers.delete(method);
|
|
2937
|
+
}
|
|
2938
|
+
} else if (starRequestHandler === type) {
|
|
2584
2939
|
starRequestHandler = void 0;
|
|
2585
2940
|
}
|
|
2586
2941
|
}
|
|
@@ -2656,17 +3011,16 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2656
3011
|
const verbose = trace === Trace.Verbose || trace === Trace.Compact;
|
|
2657
3012
|
tracer.log(params.message, verbose ? params.verbose : void 0);
|
|
2658
3013
|
});
|
|
2659
|
-
connection.onNotification(ProgressNotification.type, (params) => {
|
|
3014
|
+
connection.onNotification(ProgressNotification.type, async (params) => {
|
|
2660
3015
|
const handler = progressHandlers.get(params.token);
|
|
2661
3016
|
if (handler) {
|
|
2662
|
-
handler(params.value);
|
|
3017
|
+
await handler(params.value);
|
|
2663
3018
|
} else {
|
|
2664
3019
|
unhandledProgressEmitter.fire(params);
|
|
2665
3020
|
}
|
|
2666
3021
|
});
|
|
2667
3022
|
return connection;
|
|
2668
3023
|
}
|
|
2669
|
-
exports.createMessageConnection = createMessageConnection2;
|
|
2670
3024
|
}
|
|
2671
3025
|
});
|
|
2672
3026
|
|
|
@@ -2674,9 +3028,12 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2674
3028
|
var require_api = __commonJS({
|
|
2675
3029
|
"node_modules/vscode-jsonrpc/lib/common/api.js"(exports) {
|
|
2676
3030
|
"use strict";
|
|
3031
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
3032
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
3033
|
+
};
|
|
2677
3034
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2678
3035
|
exports.ProgressType = exports.ProgressToken = exports.createMessageConnection = exports.NullLogger = exports.ConnectionOptions = exports.ConnectionStrategy = exports.AbstractMessageBuffer = exports.WriteableStreamMessageWriter = exports.AbstractMessageWriter = exports.MessageWriter = exports.ReadableStreamMessageReader = exports.AbstractMessageReader = exports.MessageReader = exports.SharedArrayReceiverStrategy = exports.SharedArraySenderStrategy = exports.CancellationToken = exports.CancellationTokenSource = exports.Emitter = exports.Event = exports.Disposable = exports.LRUCache = exports.Touch = exports.LinkedMap = exports.ParameterStructures = exports.NotificationType9 = exports.NotificationType8 = exports.NotificationType7 = exports.NotificationType6 = exports.NotificationType5 = exports.NotificationType4 = exports.NotificationType3 = exports.NotificationType2 = exports.NotificationType1 = exports.NotificationType0 = exports.NotificationType = exports.ErrorCodes = exports.ResponseError = exports.RequestType9 = exports.RequestType8 = exports.RequestType7 = exports.RequestType6 = exports.RequestType5 = exports.RequestType4 = exports.RequestType3 = exports.RequestType2 = exports.RequestType1 = exports.RequestType0 = exports.RequestType = exports.Message = exports.RAL = void 0;
|
|
2679
|
-
exports.MessageStrategy = exports.CancellationStrategy = exports.CancellationSenderStrategy = exports.CancellationReceiverStrategy = exports.ConnectionError = exports.ConnectionErrors = exports.LogTraceNotification = exports.SetTraceNotification = exports.TraceFormat = exports.TraceValues = exports.Trace = void 0;
|
|
3036
|
+
exports.MessageStrategy = exports.CancellationStrategy = exports.CancellationSenderStrategy = exports.RequestCancellationReceiverStrategy = exports.IdCancellationReceiverStrategy = exports.CancellationReceiverStrategy = exports.ConnectionError = exports.ConnectionErrors = exports.LogTraceNotification = exports.SetTraceNotification = exports.TraceFormat = exports.TraceValues = exports.TraceValue = exports.Trace = void 0;
|
|
2680
3037
|
var messages_1 = require_messages();
|
|
2681
3038
|
Object.defineProperty(exports, "Message", { enumerable: true, get: function() {
|
|
2682
3039
|
return messages_1.Message;
|
|
@@ -2837,8 +3194,8 @@ var require_api = __commonJS({
|
|
|
2837
3194
|
Object.defineProperty(exports, "Trace", { enumerable: true, get: function() {
|
|
2838
3195
|
return connection_1.Trace;
|
|
2839
3196
|
} });
|
|
2840
|
-
Object.defineProperty(exports, "
|
|
2841
|
-
return connection_1.
|
|
3197
|
+
Object.defineProperty(exports, "TraceValue", { enumerable: true, get: function() {
|
|
3198
|
+
return connection_1.TraceValue;
|
|
2842
3199
|
} });
|
|
2843
3200
|
Object.defineProperty(exports, "TraceFormat", { enumerable: true, get: function() {
|
|
2844
3201
|
return connection_1.TraceFormat;
|
|
@@ -2858,6 +3215,12 @@ var require_api = __commonJS({
|
|
|
2858
3215
|
Object.defineProperty(exports, "CancellationReceiverStrategy", { enumerable: true, get: function() {
|
|
2859
3216
|
return connection_1.CancellationReceiverStrategy;
|
|
2860
3217
|
} });
|
|
3218
|
+
Object.defineProperty(exports, "IdCancellationReceiverStrategy", { enumerable: true, get: function() {
|
|
3219
|
+
return connection_1.IdCancellationReceiverStrategy;
|
|
3220
|
+
} });
|
|
3221
|
+
Object.defineProperty(exports, "RequestCancellationReceiverStrategy", { enumerable: true, get: function() {
|
|
3222
|
+
return connection_1.RequestCancellationReceiverStrategy;
|
|
3223
|
+
} });
|
|
2861
3224
|
Object.defineProperty(exports, "CancellationSenderStrategy", { enumerable: true, get: function() {
|
|
2862
3225
|
return connection_1.CancellationSenderStrategy;
|
|
2863
3226
|
} });
|
|
@@ -2867,7 +3230,10 @@ var require_api = __commonJS({
|
|
|
2867
3230
|
Object.defineProperty(exports, "MessageStrategy", { enumerable: true, get: function() {
|
|
2868
3231
|
return connection_1.MessageStrategy;
|
|
2869
3232
|
} });
|
|
2870
|
-
|
|
3233
|
+
Object.defineProperty(exports, "TraceValues", { enumerable: true, get: function() {
|
|
3234
|
+
return connection_1.TraceValues;
|
|
3235
|
+
} });
|
|
3236
|
+
var ral_1 = __importDefault(require_ral());
|
|
2871
3237
|
exports.RAL = ral_1.default;
|
|
2872
3238
|
}
|
|
2873
3239
|
});
|
|
@@ -2880,6 +3246,7 @@ var require_ril = __commonJS({
|
|
|
2880
3246
|
var util_1 = __require("util");
|
|
2881
3247
|
var api_1 = require_api();
|
|
2882
3248
|
var MessageBuffer = class _MessageBuffer extends api_1.AbstractMessageBuffer {
|
|
3249
|
+
static emptyBuffer = Buffer.allocUnsafe(0);
|
|
2883
3250
|
constructor(encoding = "utf-8") {
|
|
2884
3251
|
super(encoding);
|
|
2885
3252
|
}
|
|
@@ -2907,8 +3274,8 @@ var require_ril = __commonJS({
|
|
|
2907
3274
|
return Buffer.allocUnsafe(length);
|
|
2908
3275
|
}
|
|
2909
3276
|
};
|
|
2910
|
-
MessageBuffer.emptyBuffer = Buffer.allocUnsafe(0);
|
|
2911
3277
|
var ReadableStreamWrapper = class {
|
|
3278
|
+
stream;
|
|
2912
3279
|
constructor(stream) {
|
|
2913
3280
|
this.stream = stream;
|
|
2914
3281
|
}
|
|
@@ -2930,6 +3297,7 @@ var require_ril = __commonJS({
|
|
|
2930
3297
|
}
|
|
2931
3298
|
};
|
|
2932
3299
|
var WritableStreamWrapper = class {
|
|
3300
|
+
stream;
|
|
2933
3301
|
constructor(stream) {
|
|
2934
3302
|
this.stream = stream;
|
|
2935
3303
|
}
|
|
@@ -3045,24 +3413,59 @@ var require_main = __commonJS({
|
|
|
3045
3413
|
if (k2 === void 0) k2 = k;
|
|
3046
3414
|
o[k2] = m[k];
|
|
3047
3415
|
}));
|
|
3416
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
3417
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
3418
|
+
}) : function(o, v) {
|
|
3419
|
+
o["default"] = v;
|
|
3420
|
+
});
|
|
3421
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
|
|
3422
|
+
var ownKeys = function(o) {
|
|
3423
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
3424
|
+
var ar = [];
|
|
3425
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
3426
|
+
return ar;
|
|
3427
|
+
};
|
|
3428
|
+
return ownKeys(o);
|
|
3429
|
+
};
|
|
3430
|
+
return function(mod) {
|
|
3431
|
+
if (mod && mod.__esModule) return mod;
|
|
3432
|
+
var result = {};
|
|
3433
|
+
if (mod != null) {
|
|
3434
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
3435
|
+
}
|
|
3436
|
+
__setModuleDefault(result, mod);
|
|
3437
|
+
return result;
|
|
3438
|
+
};
|
|
3439
|
+
})();
|
|
3048
3440
|
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
3049
3441
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
3050
3442
|
};
|
|
3443
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
3444
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
3445
|
+
};
|
|
3051
3446
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3052
|
-
exports.
|
|
3053
|
-
|
|
3447
|
+
exports.StreamMessageWriter = exports.StreamMessageReader = exports.SocketMessageWriter = exports.SocketMessageReader = exports.PortMessageWriter = exports.PortMessageReader = exports.IPCMessageWriter = exports.IPCMessageReader = void 0;
|
|
3448
|
+
exports.generateRandomPipeName = generateRandomPipeName;
|
|
3449
|
+
exports.createClientPipeTransport = createClientPipeTransport;
|
|
3450
|
+
exports.createServerPipeTransport = createServerPipeTransport;
|
|
3451
|
+
exports.createClientSocketTransport = createClientSocketTransport;
|
|
3452
|
+
exports.createServerSocketTransport = createServerSocketTransport;
|
|
3453
|
+
exports.createMessageConnection = createMessageConnection2;
|
|
3454
|
+
var ril_1 = __importDefault(require_ril());
|
|
3054
3455
|
ril_1.default.install();
|
|
3055
|
-
var path6 = __require("path");
|
|
3056
|
-
var os2 = __require("os");
|
|
3456
|
+
var path6 = __importStar(__require("path"));
|
|
3457
|
+
var os2 = __importStar(__require("os"));
|
|
3458
|
+
var fs7 = __importStar(__require("fs"));
|
|
3057
3459
|
var crypto_1 = __require("crypto");
|
|
3058
3460
|
var net_1 = __require("net");
|
|
3059
3461
|
var api_1 = require_api();
|
|
3060
3462
|
__exportStar(require_api(), exports);
|
|
3061
3463
|
var IPCMessageReader = class extends api_1.AbstractMessageReader {
|
|
3464
|
+
process;
|
|
3062
3465
|
constructor(process10) {
|
|
3063
3466
|
super();
|
|
3064
3467
|
this.process = process10;
|
|
3065
|
-
|
|
3468
|
+
const eventEmitter = this.process;
|
|
3066
3469
|
eventEmitter.on("error", (error51) => this.fireError(error51));
|
|
3067
3470
|
eventEmitter.on("close", () => this.fireClose());
|
|
3068
3471
|
}
|
|
@@ -3073,6 +3476,8 @@ var require_main = __commonJS({
|
|
|
3073
3476
|
};
|
|
3074
3477
|
exports.IPCMessageReader = IPCMessageReader;
|
|
3075
3478
|
var IPCMessageWriter = class extends api_1.AbstractMessageWriter {
|
|
3479
|
+
process;
|
|
3480
|
+
errorCount;
|
|
3076
3481
|
constructor(process10) {
|
|
3077
3482
|
super();
|
|
3078
3483
|
this.process = process10;
|
|
@@ -3108,6 +3513,7 @@ var require_main = __commonJS({
|
|
|
3108
3513
|
};
|
|
3109
3514
|
exports.IPCMessageWriter = IPCMessageWriter;
|
|
3110
3515
|
var PortMessageReader = class extends api_1.AbstractMessageReader {
|
|
3516
|
+
onData;
|
|
3111
3517
|
constructor(port) {
|
|
3112
3518
|
super();
|
|
3113
3519
|
this.onData = new api_1.Emitter();
|
|
@@ -3123,6 +3529,8 @@ var require_main = __commonJS({
|
|
|
3123
3529
|
};
|
|
3124
3530
|
exports.PortMessageReader = PortMessageReader;
|
|
3125
3531
|
var PortMessageWriter = class extends api_1.AbstractMessageWriter {
|
|
3532
|
+
port;
|
|
3533
|
+
errorCount;
|
|
3126
3534
|
constructor(port) {
|
|
3127
3535
|
super();
|
|
3128
3536
|
this.port = port;
|
|
@@ -3154,6 +3562,7 @@ var require_main = __commonJS({
|
|
|
3154
3562
|
};
|
|
3155
3563
|
exports.SocketMessageReader = SocketMessageReader;
|
|
3156
3564
|
var SocketMessageWriter = class extends api_1.WriteableStreamMessageWriter {
|
|
3565
|
+
socket;
|
|
3157
3566
|
constructor(socket, options) {
|
|
3158
3567
|
super((0, ril_1.default)().stream.asWritableStream(socket), options);
|
|
3159
3568
|
this.socket = socket;
|
|
@@ -3179,33 +3588,32 @@ var require_main = __commonJS({
|
|
|
3179
3588
|
var XDG_RUNTIME_DIR = process.env["XDG_RUNTIME_DIR"];
|
|
3180
3589
|
var safeIpcPathLengths = /* @__PURE__ */ new Map([
|
|
3181
3590
|
["linux", 107],
|
|
3182
|
-
["darwin",
|
|
3591
|
+
["darwin", 102]
|
|
3183
3592
|
]);
|
|
3184
3593
|
function generateRandomPipeName() {
|
|
3185
|
-
const randomSuffix = (0, crypto_1.randomBytes)(21).toString("hex");
|
|
3186
3594
|
if (process.platform === "win32") {
|
|
3187
|
-
return `\\\\.\\pipe\\
|
|
3188
|
-
}
|
|
3189
|
-
let result;
|
|
3190
|
-
if (XDG_RUNTIME_DIR) {
|
|
3191
|
-
result = path6.join(XDG_RUNTIME_DIR, `vscode-ipc-${randomSuffix}.sock`);
|
|
3192
|
-
} else {
|
|
3193
|
-
result = path6.join(os2.tmpdir(), `vscode-${randomSuffix}.sock`);
|
|
3595
|
+
return `\\\\.\\pipe\\lsp-${(0, crypto_1.randomBytes)(16).toString("hex")}-sock`;
|
|
3194
3596
|
}
|
|
3597
|
+
let randomLength = 32;
|
|
3598
|
+
const fixedLength = "/lsp-.sock".length;
|
|
3599
|
+
const tmpDir = fs7.realpathSync(XDG_RUNTIME_DIR ?? os2.tmpdir());
|
|
3195
3600
|
const limit = safeIpcPathLengths.get(process.platform);
|
|
3196
|
-
if (limit !== void 0
|
|
3197
|
-
|
|
3601
|
+
if (limit !== void 0) {
|
|
3602
|
+
randomLength = Math.min(limit - tmpDir.length - fixedLength, randomLength);
|
|
3198
3603
|
}
|
|
3199
|
-
|
|
3604
|
+
if (randomLength < 16) {
|
|
3605
|
+
throw new Error(`Unable to generate a random pipe name with ${randomLength} characters.`);
|
|
3606
|
+
}
|
|
3607
|
+
const randomSuffix = (0, crypto_1.randomBytes)(Math.floor(randomLength / 2)).toString("hex");
|
|
3608
|
+
return path6.join(tmpDir, `lsp-${randomSuffix}.sock`);
|
|
3200
3609
|
}
|
|
3201
|
-
exports.generateRandomPipeName = generateRandomPipeName;
|
|
3202
3610
|
function createClientPipeTransport(pipeName, encoding = "utf-8") {
|
|
3203
3611
|
let connectResolve;
|
|
3204
3612
|
const connected = new Promise((resolve, _reject) => {
|
|
3205
3613
|
connectResolve = resolve;
|
|
3206
3614
|
});
|
|
3207
3615
|
return new Promise((resolve, reject) => {
|
|
3208
|
-
|
|
3616
|
+
const server = (0, net_1.createServer)((socket) => {
|
|
3209
3617
|
server.close();
|
|
3210
3618
|
connectResolve([
|
|
3211
3619
|
new SocketMessageReader(socket, encoding),
|
|
@@ -3223,7 +3631,6 @@ var require_main = __commonJS({
|
|
|
3223
3631
|
});
|
|
3224
3632
|
});
|
|
3225
3633
|
}
|
|
3226
|
-
exports.createClientPipeTransport = createClientPipeTransport;
|
|
3227
3634
|
function createServerPipeTransport(pipeName, encoding = "utf-8") {
|
|
3228
3635
|
const socket = (0, net_1.createConnection)(pipeName);
|
|
3229
3636
|
return [
|
|
@@ -3231,7 +3638,6 @@ var require_main = __commonJS({
|
|
|
3231
3638
|
new SocketMessageWriter(socket, encoding)
|
|
3232
3639
|
];
|
|
3233
3640
|
}
|
|
3234
|
-
exports.createServerPipeTransport = createServerPipeTransport;
|
|
3235
3641
|
function createClientSocketTransport(port, encoding = "utf-8") {
|
|
3236
3642
|
let connectResolve;
|
|
3237
3643
|
const connected = new Promise((resolve, _reject) => {
|
|
@@ -3256,7 +3662,6 @@ var require_main = __commonJS({
|
|
|
3256
3662
|
});
|
|
3257
3663
|
});
|
|
3258
3664
|
}
|
|
3259
|
-
exports.createClientSocketTransport = createClientSocketTransport;
|
|
3260
3665
|
function createServerSocketTransport(port, encoding = "utf-8") {
|
|
3261
3666
|
const socket = (0, net_1.createConnection)(port, "127.0.0.1");
|
|
3262
3667
|
return [
|
|
@@ -3264,7 +3669,6 @@ var require_main = __commonJS({
|
|
|
3264
3669
|
new SocketMessageWriter(socket, encoding)
|
|
3265
3670
|
];
|
|
3266
3671
|
}
|
|
3267
|
-
exports.createServerSocketTransport = createServerSocketTransport;
|
|
3268
3672
|
function isReadableStream(value) {
|
|
3269
3673
|
const candidate = value;
|
|
3270
3674
|
return candidate.read !== void 0 && candidate.addListener !== void 0;
|
|
@@ -3284,15 +3688,6 @@ var require_main = __commonJS({
|
|
|
3284
3688
|
}
|
|
3285
3689
|
return (0, api_1.createMessageConnection)(reader, writer, logger2, options);
|
|
3286
3690
|
}
|
|
3287
|
-
exports.createMessageConnection = createMessageConnection2;
|
|
3288
|
-
}
|
|
3289
|
-
});
|
|
3290
|
-
|
|
3291
|
-
// node_modules/vscode-jsonrpc/node.js
|
|
3292
|
-
var require_node = __commonJS({
|
|
3293
|
-
"node_modules/vscode-jsonrpc/node.js"(exports, module) {
|
|
3294
|
-
"use strict";
|
|
3295
|
-
module.exports = require_main();
|
|
3296
3691
|
}
|
|
3297
3692
|
});
|
|
3298
3693
|
|
|
@@ -20352,9 +20747,20 @@ var methods = {
|
|
|
20352
20747
|
var startActiveSession = /* @__PURE__ */ Symbol("startActiveSession");
|
|
20353
20748
|
var AcpContext = class {
|
|
20354
20749
|
cx;
|
|
20750
|
+
currentRequestId;
|
|
20355
20751
|
/** @internal */
|
|
20356
|
-
constructor(cx) {
|
|
20752
|
+
constructor(cx, currentRequestId) {
|
|
20357
20753
|
this.cx = cx;
|
|
20754
|
+
this.currentRequestId = currentRequestId;
|
|
20755
|
+
}
|
|
20756
|
+
/**
|
|
20757
|
+
* JSON-RPC id of the request currently being handled.
|
|
20758
|
+
*
|
|
20759
|
+
* This is `undefined` for notification handlers and for contexts created
|
|
20760
|
+
* outside an inbound request, such as `connect(...)` and `connectWith(...)`.
|
|
20761
|
+
*/
|
|
20762
|
+
get requestId() {
|
|
20763
|
+
return this.currentRequestId;
|
|
20358
20764
|
}
|
|
20359
20765
|
/** @internal */
|
|
20360
20766
|
get connectionContext() {
|
|
@@ -20374,12 +20780,12 @@ var AcpContext = class {
|
|
|
20374
20780
|
}
|
|
20375
20781
|
};
|
|
20376
20782
|
var AgentContext = class _AgentContext extends AcpContext {
|
|
20377
|
-
constructor(cx) {
|
|
20378
|
-
super(cx);
|
|
20783
|
+
constructor(cx, requestId) {
|
|
20784
|
+
super(cx, requestId);
|
|
20379
20785
|
}
|
|
20380
20786
|
/** @internal */
|
|
20381
|
-
static create(cx) {
|
|
20382
|
-
return new _AgentContext(cx);
|
|
20787
|
+
static create(cx, requestId) {
|
|
20788
|
+
return new _AgentContext(cx, requestId);
|
|
20383
20789
|
}
|
|
20384
20790
|
request(method, params, options) {
|
|
20385
20791
|
const spec = clientRequestSpecsByMethod[method];
|
|
@@ -20390,12 +20796,12 @@ var AgentContext = class _AgentContext extends AcpContext {
|
|
|
20390
20796
|
}
|
|
20391
20797
|
};
|
|
20392
20798
|
var ClientContext = class _ClientContext extends AcpContext {
|
|
20393
|
-
constructor(cx) {
|
|
20394
|
-
super(cx);
|
|
20799
|
+
constructor(cx, requestId) {
|
|
20800
|
+
super(cx, requestId);
|
|
20395
20801
|
}
|
|
20396
20802
|
/** @internal */
|
|
20397
|
-
static create(cx) {
|
|
20398
|
-
return new _ClientContext(cx);
|
|
20803
|
+
static create(cx, requestId) {
|
|
20804
|
+
return new _ClientContext(cx, requestId);
|
|
20399
20805
|
}
|
|
20400
20806
|
/** @internal */
|
|
20401
20807
|
[startActiveSession](params, options) {
|
|
@@ -20764,7 +21170,7 @@ function notificationSpec(method, params) {
|
|
|
20764
21170
|
}
|
|
20765
21171
|
function registerAppRequest(builder, spec, context, handler) {
|
|
20766
21172
|
builder.onReceiveRequest(spec.method, (params) => parseParams(spec.params, params), async (params, responder, cx) => {
|
|
20767
|
-
const response = await handler(context(params, cx, responder.signal));
|
|
21173
|
+
const response = await handler(context(params, cx, responder.signal, responder.id));
|
|
20768
21174
|
await responder.respond(spec.mapResponse ? spec.mapResponse(response) : response);
|
|
20769
21175
|
});
|
|
20770
21176
|
}
|
|
@@ -20828,14 +21234,30 @@ var agentRequestSpecsByMethod = specsByMethod(agentRequestSpecs);
|
|
|
20828
21234
|
var agentNotificationSpecsByMethod = specsByMethod(agentNotificationSpecs);
|
|
20829
21235
|
var clientRequestSpecsByMethod = specsByMethod(clientRequestSpecs);
|
|
20830
21236
|
var clientNotificationSpecsByMethod = specsByMethod(clientNotificationSpecs);
|
|
20831
|
-
function
|
|
21237
|
+
function agentRequestContext(params, client, signal, requestId) {
|
|
21238
|
+
return {
|
|
21239
|
+
params,
|
|
21240
|
+
requestId,
|
|
21241
|
+
signal,
|
|
21242
|
+
client
|
|
21243
|
+
};
|
|
21244
|
+
}
|
|
21245
|
+
function agentNotificationContext(params, client, signal) {
|
|
20832
21246
|
return {
|
|
20833
21247
|
params,
|
|
20834
21248
|
signal,
|
|
20835
21249
|
client
|
|
20836
21250
|
};
|
|
20837
21251
|
}
|
|
20838
|
-
function
|
|
21252
|
+
function clientRequestContext(params, agent2, signal, requestId) {
|
|
21253
|
+
return {
|
|
21254
|
+
params,
|
|
21255
|
+
requestId,
|
|
21256
|
+
signal,
|
|
21257
|
+
agent: agent2
|
|
21258
|
+
};
|
|
21259
|
+
}
|
|
21260
|
+
function clientNotificationContext(params, agent2, signal) {
|
|
20839
21261
|
return {
|
|
20840
21262
|
params,
|
|
20841
21263
|
signal,
|
|
@@ -20957,11 +21379,11 @@ var AgentApp = class {
|
|
|
20957
21379
|
return this.notification(spec, handlerOrParams);
|
|
20958
21380
|
}
|
|
20959
21381
|
request(spec, handler) {
|
|
20960
|
-
registerAppRequest(this.builder, spec, (params, cx, signal) =>
|
|
21382
|
+
registerAppRequest(this.builder, spec, (params, cx, signal, requestId) => agentRequestContext(params, AgentContext.create(cx, requestId), signal, requestId), handler);
|
|
20961
21383
|
return this;
|
|
20962
21384
|
}
|
|
20963
21385
|
notification(spec, handler) {
|
|
20964
|
-
registerAppNotification(this.builder, spec, (params, cx, signal) =>
|
|
21386
|
+
registerAppNotification(this.builder, spec, (params, cx, signal) => agentNotificationContext(params, AgentContext.create(cx), signal), handler);
|
|
20965
21387
|
return this;
|
|
20966
21388
|
}
|
|
20967
21389
|
connectConnection(target, options = {}) {
|
|
@@ -21054,11 +21476,11 @@ var ClientApp = class {
|
|
|
21054
21476
|
return this.notification(spec, handlerOrParams);
|
|
21055
21477
|
}
|
|
21056
21478
|
request(spec, handler) {
|
|
21057
|
-
registerAppRequest(this.builder, spec, (params, cx, signal) =>
|
|
21479
|
+
registerAppRequest(this.builder, spec, (params, cx, signal, requestId) => clientRequestContext(params, ClientContext.create(cx, requestId), signal, requestId), handler);
|
|
21058
21480
|
return this;
|
|
21059
21481
|
}
|
|
21060
21482
|
notification(spec, handler) {
|
|
21061
|
-
registerAppNotification(this.builder, spec, (params, cx, signal) =>
|
|
21483
|
+
registerAppNotification(this.builder, spec, (params, cx, signal) => clientNotificationContext(params, ClientContext.create(cx), signal), handler);
|
|
21062
21484
|
return this;
|
|
21063
21485
|
}
|
|
21064
21486
|
connectConnection(target) {
|
|
@@ -21139,13 +21561,12 @@ var legacyClientNotificationMethods = /* @__PURE__ */ new Set([
|
|
|
21139
21561
|
]);
|
|
21140
21562
|
|
|
21141
21563
|
// src/CodexJsonRpcConnection.ts
|
|
21142
|
-
var rpc = __toESM(
|
|
21564
|
+
var rpc = __toESM(require_main(), 1);
|
|
21143
21565
|
import { spawn } from "node:child_process";
|
|
21144
21566
|
import { createRequire } from "node:module";
|
|
21145
21567
|
|
|
21146
21568
|
// src/StdUtils.ts
|
|
21147
|
-
var
|
|
21148
|
-
var import_node = __toESM(require_node(), 1);
|
|
21569
|
+
var import_node = __toESM(require_main(), 1);
|
|
21149
21570
|
import { Readable, Writable } from "node:stream";
|
|
21150
21571
|
function createJSONRPCWriter(writable) {
|
|
21151
21572
|
return {
|
|
@@ -21391,43 +21812,271 @@ function isWin(patch) {
|
|
|
21391
21812
|
function parsePatch(uniDiff) {
|
|
21392
21813
|
const diffstr = uniDiff.split(/\n/), list = [];
|
|
21393
21814
|
let i = 0;
|
|
21815
|
+
function isGitDiffHeader(line) {
|
|
21816
|
+
return /^diff --git /.test(line);
|
|
21817
|
+
}
|
|
21818
|
+
function isDiffHeader(line) {
|
|
21819
|
+
return isGitDiffHeader(line) || /^Index:\s/.test(line) || /^diff(?: -r \w+)+\s/.test(line);
|
|
21820
|
+
}
|
|
21821
|
+
function isFileHeader(line) {
|
|
21822
|
+
return /^(---|\+\+\+)\s/.test(line);
|
|
21823
|
+
}
|
|
21824
|
+
function isHunkHeader(line) {
|
|
21825
|
+
return /^@@\s/.test(line);
|
|
21826
|
+
}
|
|
21394
21827
|
function parseIndex() {
|
|
21828
|
+
var _a3;
|
|
21395
21829
|
const index = {};
|
|
21830
|
+
index.hunks = [];
|
|
21396
21831
|
list.push(index);
|
|
21832
|
+
let seenDiffHeader = false;
|
|
21397
21833
|
while (i < diffstr.length) {
|
|
21398
21834
|
const line = diffstr[i];
|
|
21399
|
-
if (
|
|
21835
|
+
if (isFileHeader(line) || isHunkHeader(line)) {
|
|
21400
21836
|
break;
|
|
21401
21837
|
}
|
|
21402
|
-
|
|
21403
|
-
|
|
21404
|
-
|
|
21838
|
+
if (isGitDiffHeader(line)) {
|
|
21839
|
+
if (seenDiffHeader) {
|
|
21840
|
+
return;
|
|
21841
|
+
}
|
|
21842
|
+
seenDiffHeader = true;
|
|
21843
|
+
index.isGit = true;
|
|
21844
|
+
const paths = parseGitDiffHeader(line);
|
|
21845
|
+
if (paths) {
|
|
21846
|
+
index.oldFileName = paths.oldFileName;
|
|
21847
|
+
index.newFileName = paths.newFileName;
|
|
21848
|
+
}
|
|
21849
|
+
i++;
|
|
21850
|
+
while (i < diffstr.length) {
|
|
21851
|
+
const extLine = diffstr[i];
|
|
21852
|
+
if (isFileHeader(extLine) || isHunkHeader(extLine) || isDiffHeader(extLine)) {
|
|
21853
|
+
break;
|
|
21854
|
+
}
|
|
21855
|
+
const renameFromMatch = /^rename from (.*)/.exec(extLine);
|
|
21856
|
+
if (renameFromMatch) {
|
|
21857
|
+
index.oldFileName = "a/" + unquoteIfQuoted(renameFromMatch[1]);
|
|
21858
|
+
index.isRename = true;
|
|
21859
|
+
}
|
|
21860
|
+
const renameToMatch = /^rename to (.*)/.exec(extLine);
|
|
21861
|
+
if (renameToMatch) {
|
|
21862
|
+
index.newFileName = "b/" + unquoteIfQuoted(renameToMatch[1]);
|
|
21863
|
+
index.isRename = true;
|
|
21864
|
+
}
|
|
21865
|
+
const copyFromMatch = /^copy from (.*)/.exec(extLine);
|
|
21866
|
+
if (copyFromMatch) {
|
|
21867
|
+
index.oldFileName = "a/" + unquoteIfQuoted(copyFromMatch[1]);
|
|
21868
|
+
index.isCopy = true;
|
|
21869
|
+
}
|
|
21870
|
+
const copyToMatch = /^copy to (.*)/.exec(extLine);
|
|
21871
|
+
if (copyToMatch) {
|
|
21872
|
+
index.newFileName = "b/" + unquoteIfQuoted(copyToMatch[1]);
|
|
21873
|
+
index.isCopy = true;
|
|
21874
|
+
}
|
|
21875
|
+
const newFileModeMatch = /^new file mode (\d+)/.exec(extLine);
|
|
21876
|
+
if (newFileModeMatch) {
|
|
21877
|
+
index.isCreate = true;
|
|
21878
|
+
index.newMode = newFileModeMatch[1];
|
|
21879
|
+
}
|
|
21880
|
+
const deletedFileModeMatch = /^deleted file mode (\d+)/.exec(extLine);
|
|
21881
|
+
if (deletedFileModeMatch) {
|
|
21882
|
+
index.isDelete = true;
|
|
21883
|
+
index.oldMode = deletedFileModeMatch[1];
|
|
21884
|
+
}
|
|
21885
|
+
const oldModeMatch = /^old mode (\d+)/.exec(extLine);
|
|
21886
|
+
if (oldModeMatch) {
|
|
21887
|
+
index.oldMode = oldModeMatch[1];
|
|
21888
|
+
}
|
|
21889
|
+
const newModeMatch = /^new mode (\d+)/.exec(extLine);
|
|
21890
|
+
if (newModeMatch) {
|
|
21891
|
+
index.newMode = newModeMatch[1];
|
|
21892
|
+
}
|
|
21893
|
+
if (/^Binary files /.test(extLine)) {
|
|
21894
|
+
index.isBinary = true;
|
|
21895
|
+
}
|
|
21896
|
+
i++;
|
|
21897
|
+
}
|
|
21898
|
+
continue;
|
|
21899
|
+
} else if (isDiffHeader(line)) {
|
|
21900
|
+
if (seenDiffHeader) {
|
|
21901
|
+
return;
|
|
21902
|
+
}
|
|
21903
|
+
seenDiffHeader = true;
|
|
21904
|
+
const headerMatch = /^(?:Index:|diff(?: -r \w+)+)\s+/.exec(line);
|
|
21905
|
+
if (headerMatch) {
|
|
21906
|
+
index.index = line.substring(headerMatch[0].length).trim();
|
|
21907
|
+
}
|
|
21405
21908
|
}
|
|
21406
21909
|
i++;
|
|
21407
21910
|
}
|
|
21408
21911
|
parseFileHeader(index);
|
|
21409
21912
|
parseFileHeader(index);
|
|
21410
|
-
index.
|
|
21913
|
+
if (index.oldFileName === void 0 !== (index.newFileName === void 0)) {
|
|
21914
|
+
throw new Error("Missing " + (index.oldFileName !== void 0 ? '"+++ ..."' : '"--- ..."') + " file header for " + ((_a3 = index.oldFileName) !== null && _a3 !== void 0 ? _a3 : index.newFileName));
|
|
21915
|
+
}
|
|
21411
21916
|
while (i < diffstr.length) {
|
|
21412
21917
|
const line = diffstr[i];
|
|
21413
|
-
if (
|
|
21918
|
+
if (isDiffHeader(line) || isFileHeader(line) || /^===================================================================/.test(line)) {
|
|
21414
21919
|
break;
|
|
21415
|
-
} else if (
|
|
21920
|
+
} else if (isHunkHeader(line)) {
|
|
21416
21921
|
index.hunks.push(parseHunk());
|
|
21417
|
-
} else if (line) {
|
|
21418
|
-
throw new Error("Unknown line " + (i + 1) + " " + JSON.stringify(line));
|
|
21419
21922
|
} else {
|
|
21420
21923
|
i++;
|
|
21421
21924
|
}
|
|
21422
21925
|
}
|
|
21423
21926
|
}
|
|
21927
|
+
function parseGitDiffHeader(line) {
|
|
21928
|
+
const rest = line.substring("diff --git ".length);
|
|
21929
|
+
if (rest.startsWith('"')) {
|
|
21930
|
+
const oldPath = parseQuotedFileName(rest);
|
|
21931
|
+
if (oldPath === null) {
|
|
21932
|
+
return null;
|
|
21933
|
+
}
|
|
21934
|
+
const afterOld = rest.substring(oldPath.rawLength + 1);
|
|
21935
|
+
let newFileName;
|
|
21936
|
+
if (afterOld.startsWith('"')) {
|
|
21937
|
+
const newPath = parseQuotedFileName(afterOld);
|
|
21938
|
+
if (newPath === null) {
|
|
21939
|
+
return null;
|
|
21940
|
+
}
|
|
21941
|
+
newFileName = newPath.fileName;
|
|
21942
|
+
} else {
|
|
21943
|
+
newFileName = afterOld;
|
|
21944
|
+
}
|
|
21945
|
+
return {
|
|
21946
|
+
oldFileName: oldPath.fileName,
|
|
21947
|
+
newFileName
|
|
21948
|
+
};
|
|
21949
|
+
}
|
|
21950
|
+
const quoteIdx = rest.indexOf('"');
|
|
21951
|
+
if (quoteIdx > 0) {
|
|
21952
|
+
const oldFileName = rest.substring(0, quoteIdx - 1);
|
|
21953
|
+
const newPath = parseQuotedFileName(rest.substring(quoteIdx));
|
|
21954
|
+
if (newPath === null) {
|
|
21955
|
+
return null;
|
|
21956
|
+
}
|
|
21957
|
+
return {
|
|
21958
|
+
oldFileName,
|
|
21959
|
+
newFileName: newPath.fileName
|
|
21960
|
+
};
|
|
21961
|
+
}
|
|
21962
|
+
if (rest.startsWith("a/")) {
|
|
21963
|
+
const splits = [];
|
|
21964
|
+
let idx = 0;
|
|
21965
|
+
while (true) {
|
|
21966
|
+
idx = rest.indexOf(" b/", idx + 1);
|
|
21967
|
+
if (idx === -1) {
|
|
21968
|
+
break;
|
|
21969
|
+
}
|
|
21970
|
+
splits.push(idx);
|
|
21971
|
+
}
|
|
21972
|
+
if (splits.length > 0) {
|
|
21973
|
+
const mid = splits[Math.floor(splits.length / 2)];
|
|
21974
|
+
return {
|
|
21975
|
+
oldFileName: rest.substring(0, mid),
|
|
21976
|
+
newFileName: rest.substring(mid + 1)
|
|
21977
|
+
};
|
|
21978
|
+
}
|
|
21979
|
+
}
|
|
21980
|
+
return null;
|
|
21981
|
+
}
|
|
21982
|
+
function unquoteIfQuoted(s) {
|
|
21983
|
+
if (s.startsWith('"')) {
|
|
21984
|
+
const parsed = parseQuotedFileName(s);
|
|
21985
|
+
if (parsed) {
|
|
21986
|
+
return parsed.fileName;
|
|
21987
|
+
}
|
|
21988
|
+
}
|
|
21989
|
+
return s;
|
|
21990
|
+
}
|
|
21991
|
+
function parseQuotedFileName(s) {
|
|
21992
|
+
if (!s.startsWith('"')) {
|
|
21993
|
+
return null;
|
|
21994
|
+
}
|
|
21995
|
+
let result = "";
|
|
21996
|
+
let j = 1;
|
|
21997
|
+
while (j < s.length) {
|
|
21998
|
+
if (s[j] === '"') {
|
|
21999
|
+
return { fileName: result, rawLength: j + 1 };
|
|
22000
|
+
}
|
|
22001
|
+
if (s[j] === "\\" && j + 1 < s.length) {
|
|
22002
|
+
j++;
|
|
22003
|
+
switch (s[j]) {
|
|
22004
|
+
case "a":
|
|
22005
|
+
result += "\x07";
|
|
22006
|
+
break;
|
|
22007
|
+
case "b":
|
|
22008
|
+
result += "\b";
|
|
22009
|
+
break;
|
|
22010
|
+
case "f":
|
|
22011
|
+
result += "\f";
|
|
22012
|
+
break;
|
|
22013
|
+
case "n":
|
|
22014
|
+
result += "\n";
|
|
22015
|
+
break;
|
|
22016
|
+
case "r":
|
|
22017
|
+
result += "\r";
|
|
22018
|
+
break;
|
|
22019
|
+
case "t":
|
|
22020
|
+
result += " ";
|
|
22021
|
+
break;
|
|
22022
|
+
case "v":
|
|
22023
|
+
result += "\v";
|
|
22024
|
+
break;
|
|
22025
|
+
case "\\":
|
|
22026
|
+
result += "\\";
|
|
22027
|
+
break;
|
|
22028
|
+
case '"':
|
|
22029
|
+
result += '"';
|
|
22030
|
+
break;
|
|
22031
|
+
case "0":
|
|
22032
|
+
case "1":
|
|
22033
|
+
case "2":
|
|
22034
|
+
case "3":
|
|
22035
|
+
case "4":
|
|
22036
|
+
case "5":
|
|
22037
|
+
case "6":
|
|
22038
|
+
case "7": {
|
|
22039
|
+
if (j + 2 >= s.length || s[j + 1] < "0" || s[j + 1] > "7" || s[j + 2] < "0" || s[j + 2] > "7") {
|
|
22040
|
+
return null;
|
|
22041
|
+
}
|
|
22042
|
+
const bytes = [parseInt(s.substring(j, j + 3), 8)];
|
|
22043
|
+
j += 3;
|
|
22044
|
+
while (s[j] === "\\" && s[j + 1] >= "0" && s[j + 1] <= "7") {
|
|
22045
|
+
if (j + 3 >= s.length || s[j + 2] < "0" || s[j + 2] > "7" || s[j + 3] < "0" || s[j + 3] > "7") {
|
|
22046
|
+
return null;
|
|
22047
|
+
}
|
|
22048
|
+
bytes.push(parseInt(s.substring(j + 1, j + 4), 8));
|
|
22049
|
+
j += 4;
|
|
22050
|
+
}
|
|
22051
|
+
result += new TextDecoder("utf-8").decode(new Uint8Array(bytes));
|
|
22052
|
+
continue;
|
|
22053
|
+
}
|
|
22054
|
+
// Note that in C, there are also three kinds of hex escape sequences:
|
|
22055
|
+
// - \xhh
|
|
22056
|
+
// - \uhhhh
|
|
22057
|
+
// - \Uhhhhhhhh
|
|
22058
|
+
// We do not bother to parse them here because, so far as we know,
|
|
22059
|
+
// they are never emitted by any tools that generate unified diff
|
|
22060
|
+
// format diffs, and so for now jsdiff does not consider them legal.
|
|
22061
|
+
default:
|
|
22062
|
+
return null;
|
|
22063
|
+
}
|
|
22064
|
+
} else {
|
|
22065
|
+
result += s[j];
|
|
22066
|
+
}
|
|
22067
|
+
j++;
|
|
22068
|
+
}
|
|
22069
|
+
return null;
|
|
22070
|
+
}
|
|
21424
22071
|
function parseFileHeader(index) {
|
|
21425
22072
|
const fileHeaderMatch = /^(---|\+\+\+)\s+/.exec(diffstr[i]);
|
|
21426
22073
|
if (fileHeaderMatch) {
|
|
21427
22074
|
const prefix = fileHeaderMatch[1], data = diffstr[i].substring(3).trim().split(" ", 2), header = (data[1] || "").trim();
|
|
21428
|
-
let fileName = data[0]
|
|
21429
|
-
if (fileName.startsWith('"')
|
|
21430
|
-
fileName =
|
|
22075
|
+
let fileName = data[0];
|
|
22076
|
+
if (fileName.startsWith('"')) {
|
|
22077
|
+
fileName = unquoteIfQuoted(fileName);
|
|
22078
|
+
} else {
|
|
22079
|
+
fileName = fileName.replace(/\\\\/g, "\\");
|
|
21431
22080
|
}
|
|
21432
22081
|
if (prefix === "---") {
|
|
21433
22082
|
index.oldFileName = fileName;
|
|
@@ -21484,6 +22133,9 @@ function parsePatch(uniDiff) {
|
|
|
21484
22133
|
if (removeCount !== hunk.oldLines) {
|
|
21485
22134
|
throw new Error("Removed line count did not match for hunk at line " + (chunkHeaderIndex + 1));
|
|
21486
22135
|
}
|
|
22136
|
+
if (i < diffstr.length && diffstr[i] && /^[+ -]/.test(diffstr[i]) && !isFileHeader(diffstr[i])) {
|
|
22137
|
+
throw new Error("Hunk at line " + (chunkHeaderIndex + 1) + " has more lines than expected (expected " + hunk.oldLines + " old lines and " + hunk.newLines + " new lines)");
|
|
22138
|
+
}
|
|
21487
22139
|
return hunk;
|
|
21488
22140
|
}
|
|
21489
22141
|
while (i < diffstr.length) {
|
|
@@ -21671,11 +22323,23 @@ function applyStructuredPatch(source, patch, options = {}) {
|
|
|
21671
22323
|
}
|
|
21672
22324
|
|
|
21673
22325
|
// node_modules/diff/libesm/patch/reverse.js
|
|
22326
|
+
function swapPrefix(fileName) {
|
|
22327
|
+
if (fileName === void 0 || fileName === "/dev/null") {
|
|
22328
|
+
return fileName;
|
|
22329
|
+
}
|
|
22330
|
+
if (fileName.startsWith("a/")) {
|
|
22331
|
+
return "b/" + fileName.slice(2);
|
|
22332
|
+
}
|
|
22333
|
+
if (fileName.startsWith("b/")) {
|
|
22334
|
+
return "a/" + fileName.slice(2);
|
|
22335
|
+
}
|
|
22336
|
+
return fileName;
|
|
22337
|
+
}
|
|
21674
22338
|
function reversePatch(structuredPatch) {
|
|
21675
22339
|
if (Array.isArray(structuredPatch)) {
|
|
21676
22340
|
return structuredPatch.map((patch) => reversePatch(patch)).reverse();
|
|
21677
22341
|
}
|
|
21678
|
-
|
|
22342
|
+
const reversed = Object.assign(Object.assign({}, structuredPatch), { oldFileName: structuredPatch.isGit ? swapPrefix(structuredPatch.newFileName) : structuredPatch.newFileName, oldHeader: structuredPatch.newHeader, newFileName: structuredPatch.isGit ? swapPrefix(structuredPatch.oldFileName) : structuredPatch.oldFileName, newHeader: structuredPatch.oldHeader, oldMode: structuredPatch.newMode, newMode: structuredPatch.oldMode, isCreate: structuredPatch.isDelete, isDelete: structuredPatch.isCreate, hunks: structuredPatch.hunks.map((hunk) => {
|
|
21679
22343
|
return {
|
|
21680
22344
|
oldLines: hunk.newLines,
|
|
21681
22345
|
oldStart: hunk.newStart,
|
|
@@ -21692,6 +22356,16 @@ function reversePatch(structuredPatch) {
|
|
|
21692
22356
|
})
|
|
21693
22357
|
};
|
|
21694
22358
|
}) });
|
|
22359
|
+
if (structuredPatch.isCopy) {
|
|
22360
|
+
reversed.newFileName = "/dev/null";
|
|
22361
|
+
reversed.newHeader = void 0;
|
|
22362
|
+
reversed.isDelete = true;
|
|
22363
|
+
delete reversed.isCreate;
|
|
22364
|
+
delete reversed.isCopy;
|
|
22365
|
+
delete reversed.isRename;
|
|
22366
|
+
reversed.hunks = [];
|
|
22367
|
+
}
|
|
22368
|
+
return reversed;
|
|
21695
22369
|
}
|
|
21696
22370
|
|
|
21697
22371
|
// src/CodexToolCallMapper.ts
|
|
@@ -21861,18 +22535,18 @@ function createImageGenerationCompleteUpdate(item) {
|
|
|
21861
22535
|
return {
|
|
21862
22536
|
sessionUpdate: "tool_call_update",
|
|
21863
22537
|
toolCallId: item.id,
|
|
21864
|
-
status:
|
|
22538
|
+
status: imageGenerationTerminalStatus(item.status),
|
|
21865
22539
|
content: imageGenerationContent(item),
|
|
21866
22540
|
rawOutput: imageGenerationRawOutput(item)
|
|
21867
22541
|
};
|
|
21868
22542
|
}
|
|
21869
|
-
function createImageGenerationUpdate(item) {
|
|
22543
|
+
function createImageGenerationUpdate(item, options) {
|
|
21870
22544
|
return {
|
|
21871
22545
|
sessionUpdate: "tool_call",
|
|
21872
22546
|
toolCallId: item.id,
|
|
21873
22547
|
kind: "other",
|
|
21874
22548
|
title: "Image generation",
|
|
21875
|
-
status: imageGenerationToolStatus(item.status),
|
|
22549
|
+
status: options?.terminalStatus ? imageGenerationTerminalStatus(item.status) : imageGenerationToolStatus(item.status),
|
|
21876
22550
|
content: imageGenerationContent(item),
|
|
21877
22551
|
rawOutput: imageGenerationRawOutput(item)
|
|
21878
22552
|
};
|
|
@@ -22214,6 +22888,19 @@ function imageGenerationToolStatus(status) {
|
|
|
22214
22888
|
return "completed";
|
|
22215
22889
|
}
|
|
22216
22890
|
}
|
|
22891
|
+
function imageGenerationTerminalStatus(status) {
|
|
22892
|
+
switch (status) {
|
|
22893
|
+
case "failed":
|
|
22894
|
+
return "failed";
|
|
22895
|
+
case "completed":
|
|
22896
|
+
case "generating":
|
|
22897
|
+
case "in_progress":
|
|
22898
|
+
case "inProgress":
|
|
22899
|
+
case "incomplete":
|
|
22900
|
+
default:
|
|
22901
|
+
return "completed";
|
|
22902
|
+
}
|
|
22903
|
+
}
|
|
22217
22904
|
function imageGenerationContent(item) {
|
|
22218
22905
|
const content = [];
|
|
22219
22906
|
if (item.revisedPrompt && item.revisedPrompt.trim() !== "") {
|
|
@@ -22344,6 +23031,53 @@ function recoverCorruptedDiff(diff) {
|
|
|
22344
23031
|
return diff.replace(/\n\nMoved to: .*$/, "");
|
|
22345
23032
|
}
|
|
22346
23033
|
|
|
23034
|
+
// src/ContentChunks.ts
|
|
23035
|
+
function createUserMessageChunk(content, messageId) {
|
|
23036
|
+
if (messageId) {
|
|
23037
|
+
return {
|
|
23038
|
+
sessionUpdate: "user_message_chunk",
|
|
23039
|
+
messageId,
|
|
23040
|
+
content
|
|
23041
|
+
};
|
|
23042
|
+
}
|
|
23043
|
+
return {
|
|
23044
|
+
sessionUpdate: "user_message_chunk",
|
|
23045
|
+
content
|
|
23046
|
+
};
|
|
23047
|
+
}
|
|
23048
|
+
function createAgentMessageChunk(content, messageId) {
|
|
23049
|
+
if (messageId) {
|
|
23050
|
+
return {
|
|
23051
|
+
sessionUpdate: "agent_message_chunk",
|
|
23052
|
+
messageId,
|
|
23053
|
+
content
|
|
23054
|
+
};
|
|
23055
|
+
}
|
|
23056
|
+
return {
|
|
23057
|
+
sessionUpdate: "agent_message_chunk",
|
|
23058
|
+
content
|
|
23059
|
+
};
|
|
23060
|
+
}
|
|
23061
|
+
function createAgentThoughtChunk(content, messageId) {
|
|
23062
|
+
if (messageId) {
|
|
23063
|
+
return {
|
|
23064
|
+
sessionUpdate: "agent_thought_chunk",
|
|
23065
|
+
messageId,
|
|
23066
|
+
content
|
|
23067
|
+
};
|
|
23068
|
+
}
|
|
23069
|
+
return {
|
|
23070
|
+
sessionUpdate: "agent_thought_chunk",
|
|
23071
|
+
content
|
|
23072
|
+
};
|
|
23073
|
+
}
|
|
23074
|
+
function createAgentTextMessageChunk(text, messageId) {
|
|
23075
|
+
return createAgentMessageChunk({ type: "text", text }, messageId);
|
|
23076
|
+
}
|
|
23077
|
+
function createAgentTextThoughtChunk(text, messageId) {
|
|
23078
|
+
return createAgentThoughtChunk({ type: "text", text }, messageId);
|
|
23079
|
+
}
|
|
23080
|
+
|
|
22347
23081
|
// src/CodexEventHandler.ts
|
|
22348
23082
|
var CodexEventHandler = class {
|
|
22349
23083
|
connection;
|
|
@@ -22499,104 +23233,65 @@ var CodexEventHandler = class {
|
|
|
22499
23233
|
};
|
|
22500
23234
|
}
|
|
22501
23235
|
async createTextEvent(event) {
|
|
22502
|
-
return
|
|
22503
|
-
sessionUpdate: "agent_message_chunk",
|
|
22504
|
-
content: {
|
|
22505
|
-
type: "text",
|
|
22506
|
-
text: event.delta
|
|
22507
|
-
}
|
|
22508
|
-
};
|
|
23236
|
+
return createAgentTextMessageChunk(event.delta, event.itemId);
|
|
22509
23237
|
}
|
|
22510
23238
|
async createConfigWarningEvent(event) {
|
|
22511
23239
|
const detailsText = event.details ? `
|
|
22512
23240
|
|
|
22513
23241
|
${event.details}` : "";
|
|
22514
|
-
return {
|
|
22515
|
-
sessionUpdate: "agent_message_chunk",
|
|
22516
|
-
content: {
|
|
22517
|
-
type: "text",
|
|
22518
|
-
text: `Config warning: ${event.summary}${detailsText}
|
|
23242
|
+
return createAgentTextMessageChunk(`Config warning: ${event.summary}${detailsText}
|
|
22519
23243
|
|
|
22520
|
-
`
|
|
22521
|
-
}
|
|
22522
|
-
};
|
|
23244
|
+
`);
|
|
22523
23245
|
}
|
|
22524
23246
|
createWarningEvent(event) {
|
|
22525
|
-
return {
|
|
22526
|
-
sessionUpdate: "agent_message_chunk",
|
|
22527
|
-
content: {
|
|
22528
|
-
type: "text",
|
|
22529
|
-
text: `Warning: ${event.message}
|
|
23247
|
+
return createAgentTextMessageChunk(`Warning: ${event.message}
|
|
22530
23248
|
|
|
22531
|
-
`
|
|
22532
|
-
}
|
|
22533
|
-
};
|
|
23249
|
+
`);
|
|
22534
23250
|
}
|
|
22535
23251
|
createModelReroutedEvent(event) {
|
|
22536
|
-
return {
|
|
22537
|
-
sessionUpdate: "agent_thought_chunk",
|
|
22538
|
-
content: {
|
|
22539
|
-
type: "text",
|
|
22540
|
-
text: `Model rerouted from ${event.fromModel} to ${event.toModel} (${event.reason}).
|
|
23252
|
+
return createAgentTextThoughtChunk(`Model rerouted from ${event.fromModel} to ${event.toModel} (${event.reason}).
|
|
22541
23253
|
|
|
22542
|
-
`
|
|
22543
|
-
}
|
|
22544
|
-
};
|
|
23254
|
+
`);
|
|
22545
23255
|
}
|
|
22546
23256
|
createThreadGoalUpdatedEvent(event) {
|
|
22547
|
-
const
|
|
22548
|
-
|
|
22549
|
-
|
|
22550
|
-
${objective}` : `Goal updated (${status}): ${objective}`;
|
|
22551
|
-
return {
|
|
22552
|
-
sessionUpdate: "agent_message_chunk",
|
|
22553
|
-
content: {
|
|
22554
|
-
type: "text",
|
|
22555
|
-
text
|
|
22556
|
-
}
|
|
22557
|
-
};
|
|
22558
|
-
}
|
|
22559
|
-
formatThreadGoalStatus(status) {
|
|
22560
|
-
switch (status) {
|
|
22561
|
-
case "active":
|
|
22562
|
-
return "active";
|
|
22563
|
-
case "paused":
|
|
22564
|
-
return "paused";
|
|
22565
|
-
case "budgetLimited":
|
|
22566
|
-
return "budget limited";
|
|
22567
|
-
case "blocked":
|
|
22568
|
-
return "blocked";
|
|
22569
|
-
case "usageLimited":
|
|
22570
|
-
return "usage limited";
|
|
22571
|
-
case "complete":
|
|
22572
|
-
return "complete";
|
|
23257
|
+
const goalSnapshot = this.createThreadGoalSnapshot(event);
|
|
23258
|
+
if (this.sameThreadGoalSnapshot(this.sessionState.currentGoal, goalSnapshot)) {
|
|
23259
|
+
return null;
|
|
22573
23260
|
}
|
|
23261
|
+
this.sessionState.currentGoal = goalSnapshot;
|
|
23262
|
+
return this.createCodexSessionInfoUpdate({
|
|
23263
|
+
goal: goalSnapshot
|
|
23264
|
+
});
|
|
22574
23265
|
}
|
|
22575
23266
|
createThreadGoalClearedEvent(_event) {
|
|
23267
|
+
if (this.sessionState.currentGoal === null) {
|
|
23268
|
+
return null;
|
|
23269
|
+
}
|
|
23270
|
+
this.sessionState.currentGoal = null;
|
|
23271
|
+
return this.createCodexSessionInfoUpdate({
|
|
23272
|
+
goal: null
|
|
23273
|
+
});
|
|
23274
|
+
}
|
|
23275
|
+
createThreadGoalSnapshot(event) {
|
|
22576
23276
|
return {
|
|
22577
|
-
|
|
22578
|
-
|
|
22579
|
-
|
|
22580
|
-
text: "Goal cleared."
|
|
22581
|
-
}
|
|
23277
|
+
objective: event.goal.objective.trim(),
|
|
23278
|
+
status: event.goal.status,
|
|
23279
|
+
tokenBudget: event.goal.tokenBudget
|
|
22582
23280
|
};
|
|
22583
23281
|
}
|
|
23282
|
+
sameThreadGoalSnapshot(left, right) {
|
|
23283
|
+
return left !== null && left !== void 0 && left.objective === right.objective && left.status === right.status && left.tokenBudget === right.tokenBudget;
|
|
23284
|
+
}
|
|
22584
23285
|
createReasoningDeltaEvent(event) {
|
|
22585
23286
|
this.seenReasoningDeltaItemIds.add(event.itemId);
|
|
22586
|
-
return this.createAgentThoughtEvent(event.delta);
|
|
23287
|
+
return this.createAgentThoughtEvent(event.delta, event.itemId);
|
|
22587
23288
|
}
|
|
22588
23289
|
createReasoningSectionBreakEvent(event) {
|
|
22589
23290
|
this.seenReasoningDeltaItemIds.add(event.itemId);
|
|
22590
|
-
return this.createAgentThoughtEvent("\n\n");
|
|
23291
|
+
return this.createAgentThoughtEvent("\n\n", event.itemId);
|
|
22591
23292
|
}
|
|
22592
|
-
createAgentThoughtEvent(text) {
|
|
22593
|
-
return
|
|
22594
|
-
sessionUpdate: "agent_thought_chunk",
|
|
22595
|
-
content: {
|
|
22596
|
-
type: "text",
|
|
22597
|
-
text
|
|
22598
|
-
}
|
|
22599
|
-
};
|
|
23293
|
+
createAgentThoughtEvent(text, messageId) {
|
|
23294
|
+
return createAgentTextThoughtChunk(text, messageId);
|
|
22600
23295
|
}
|
|
22601
23296
|
async createItemEvent(event) {
|
|
22602
23297
|
switch (event.item.type) {
|
|
@@ -22666,7 +23361,7 @@ ${objective}` : `Goal updated (${status}): ${objective}`;
|
|
|
22666
23361
|
if (this.activeImageGenerationItems.delete(event.item.id)) {
|
|
22667
23362
|
return createImageGenerationCompleteUpdate(event.item);
|
|
22668
23363
|
}
|
|
22669
|
-
return createImageGenerationUpdate(event.item);
|
|
23364
|
+
return createImageGenerationUpdate(event.item, { terminalStatus: true });
|
|
22670
23365
|
case "reasoning":
|
|
22671
23366
|
if (this.seenReasoningDeltaItemIds.delete(event.item.id)) {
|
|
22672
23367
|
return null;
|
|
@@ -22697,29 +23392,17 @@ ${objective}` : `Goal updated (${status}): ${objective}`;
|
|
|
22697
23392
|
if (text.length === 0) {
|
|
22698
23393
|
return null;
|
|
22699
23394
|
}
|
|
22700
|
-
return this.createAgentThoughtEvent(text);
|
|
23395
|
+
return this.createAgentThoughtEvent(text, item.id);
|
|
22701
23396
|
}
|
|
22702
23397
|
createExitedReviewModeEvent(item) {
|
|
22703
23398
|
const text = item.review.trim();
|
|
22704
23399
|
if (text.length === 0) {
|
|
22705
23400
|
return null;
|
|
22706
23401
|
}
|
|
22707
|
-
return
|
|
22708
|
-
sessionUpdate: "agent_message_chunk",
|
|
22709
|
-
content: {
|
|
22710
|
-
type: "text",
|
|
22711
|
-
text
|
|
22712
|
-
}
|
|
22713
|
-
};
|
|
23402
|
+
return createAgentTextMessageChunk(text);
|
|
22714
23403
|
}
|
|
22715
23404
|
createContextCompactedEvent() {
|
|
22716
|
-
return
|
|
22717
|
-
sessionUpdate: "agent_message_chunk",
|
|
22718
|
-
content: {
|
|
22719
|
-
type: "text",
|
|
22720
|
-
text: "*Context compacted to fit the model's context window.*\n\n"
|
|
22721
|
-
}
|
|
22722
|
-
};
|
|
23405
|
+
return createAgentTextMessageChunk("*Context compacted to fit the model's context window.*\n\n");
|
|
22723
23406
|
}
|
|
22724
23407
|
createCommandOutputDeltaEvent(event) {
|
|
22725
23408
|
if (this.terminalCommandIds.has(event.itemId) && event.delta.length > 0) {
|
|
@@ -22846,15 +23529,9 @@ ${event.stdin}
|
|
|
22846
23529
|
} else if (this.isAuthenticationRequiredError(error51)) {
|
|
22847
23530
|
this.failure = this.sessionState.authConfigured ? RequestError.internalError(this.createTurnErrorData(params.error)) : RequestError.authRequired(this.createTurnErrorData(params.error), params.error.message);
|
|
22848
23531
|
}
|
|
22849
|
-
return {
|
|
22850
|
-
sessionUpdate: "agent_message_chunk",
|
|
22851
|
-
content: {
|
|
22852
|
-
type: "text",
|
|
22853
|
-
text: `${params.error.message}
|
|
23532
|
+
return createAgentTextMessageChunk(`${params.error.message}
|
|
22854
23533
|
|
|
22855
|
-
`
|
|
22856
|
-
}
|
|
22857
|
-
};
|
|
23534
|
+
`);
|
|
22858
23535
|
}
|
|
22859
23536
|
isAuthenticationRequiredError(error51) {
|
|
22860
23537
|
return error51 === "unauthorized" || this.getHttpStatusCode(error51) === 401;
|
|
@@ -23592,10 +24269,15 @@ var isWsl = () => {
|
|
|
23592
24269
|
return true;
|
|
23593
24270
|
}
|
|
23594
24271
|
try {
|
|
23595
|
-
|
|
24272
|
+
if (fs4.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
24273
|
+
return !isInsideContainer();
|
|
24274
|
+
}
|
|
23596
24275
|
} catch {
|
|
23597
|
-
return false;
|
|
23598
24276
|
}
|
|
24277
|
+
if (fs4.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs4.existsSync("/run/WSL")) {
|
|
24278
|
+
return !isInsideContainer();
|
|
24279
|
+
}
|
|
24280
|
+
return false;
|
|
23599
24281
|
};
|
|
23600
24282
|
var is_wsl_default = process3.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
23601
24283
|
|
|
@@ -23634,6 +24316,20 @@ executePowerShell.argumentsPrefix = [
|
|
|
23634
24316
|
executePowerShell.encodeCommand = (command) => Buffer2.from(command, "utf16le").toString("base64");
|
|
23635
24317
|
executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
23636
24318
|
|
|
24319
|
+
// node_modules/wsl-utils/utilities.js
|
|
24320
|
+
function parseMountPointFromConfig(content) {
|
|
24321
|
+
for (const line of content.split("\n")) {
|
|
24322
|
+
if (/^\s*#/.test(line)) {
|
|
24323
|
+
continue;
|
|
24324
|
+
}
|
|
24325
|
+
const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
24326
|
+
if (!match) {
|
|
24327
|
+
continue;
|
|
24328
|
+
}
|
|
24329
|
+
return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
|
|
24330
|
+
}
|
|
24331
|
+
}
|
|
24332
|
+
|
|
23637
24333
|
// node_modules/wsl-utils/index.js
|
|
23638
24334
|
var execFile2 = promisify2(childProcess2.execFile);
|
|
23639
24335
|
var wslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
@@ -23654,11 +24350,11 @@ var wslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
|
23654
24350
|
return defaultMountPoint;
|
|
23655
24351
|
}
|
|
23656
24352
|
const configContent = await fs5.readFile(configFilePath, { encoding: "utf8" });
|
|
23657
|
-
const
|
|
23658
|
-
if (
|
|
24353
|
+
const parsedMountPoint = parseMountPointFromConfig(configContent);
|
|
24354
|
+
if (parsedMountPoint === void 0) {
|
|
23659
24355
|
return defaultMountPoint;
|
|
23660
24356
|
}
|
|
23661
|
-
mountPoint =
|
|
24357
|
+
mountPoint = parsedMountPoint;
|
|
23662
24358
|
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
23663
24359
|
return mountPoint;
|
|
23664
24360
|
};
|
|
@@ -23802,11 +24498,11 @@ async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
|
23802
24498
|
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
23803
24499
|
}
|
|
23804
24500
|
const { id } = match.groups;
|
|
23805
|
-
const
|
|
23806
|
-
|
|
23807
|
-
|
|
23808
|
-
|
|
23809
|
-
return
|
|
24501
|
+
const dotIndex = id.lastIndexOf(".");
|
|
24502
|
+
const hyphenIndex = id.lastIndexOf("-");
|
|
24503
|
+
const baseIdByDot = dotIndex === -1 ? void 0 : id.slice(0, dotIndex);
|
|
24504
|
+
const baseIdByHyphen = hyphenIndex === -1 ? void 0 : id.slice(0, hyphenIndex);
|
|
24505
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
23810
24506
|
}
|
|
23811
24507
|
|
|
23812
24508
|
// node_modules/default-browser/index.js
|
|
@@ -24259,7 +24955,7 @@ var package_default = {
|
|
|
24259
24955
|
publishConfig: {
|
|
24260
24956
|
access: "public"
|
|
24261
24957
|
},
|
|
24262
|
-
version: "1.0
|
|
24958
|
+
version: "1.1.0",
|
|
24263
24959
|
description: "",
|
|
24264
24960
|
main: "dist/index.js",
|
|
24265
24961
|
bin: {
|
|
@@ -24309,19 +25005,19 @@ var package_default = {
|
|
|
24309
25005
|
license: "Apache-2.0",
|
|
24310
25006
|
type: "module",
|
|
24311
25007
|
devDependencies: {
|
|
24312
|
-
"@types/node": "^
|
|
25008
|
+
"@types/node": "^26.0.1",
|
|
24313
25009
|
esbuild: "^0.28.1",
|
|
24314
25010
|
"mcp-hello-world": "^1.1.2",
|
|
24315
25011
|
tsx: "^4.20.6",
|
|
24316
|
-
typescript: "^
|
|
24317
|
-
vitest: "^4.
|
|
25012
|
+
typescript: "^6.0.3",
|
|
25013
|
+
vitest: "^4.1.9"
|
|
24318
25014
|
},
|
|
24319
25015
|
dependencies: {
|
|
24320
|
-
"@agentclientprotocol/sdk": "^1.
|
|
24321
|
-
"@openai/codex": "^0.142.
|
|
24322
|
-
diff: "^
|
|
25016
|
+
"@agentclientprotocol/sdk": "^1.1.0",
|
|
25017
|
+
"@openai/codex": "^0.142.5",
|
|
25018
|
+
diff: "^9.0.0",
|
|
24323
25019
|
open: "^11.0.0",
|
|
24324
|
-
"vscode-jsonrpc": "^
|
|
25020
|
+
"vscode-jsonrpc": "^9.0.1",
|
|
24325
25021
|
zod: "^4.0.0"
|
|
24326
25022
|
}
|
|
24327
25023
|
};
|
|
@@ -24563,15 +25259,37 @@ var CodexAcpClient = class {
|
|
|
24563
25259
|
async deleteSession(sessionId) {
|
|
24564
25260
|
await this.codexClient.threadArchive({ threadId: sessionId });
|
|
24565
25261
|
}
|
|
24566
|
-
async runReview(sessionId, target, onTurnStarted) {
|
|
24567
|
-
return await this.codexClient.runReview({
|
|
25262
|
+
async runReview(sessionId, target, onTurnStarted) {
|
|
25263
|
+
return await this.codexClient.runReview({
|
|
25264
|
+
threadId: sessionId,
|
|
25265
|
+
target,
|
|
25266
|
+
delivery: "inline"
|
|
25267
|
+
}, onTurnStarted);
|
|
25268
|
+
}
|
|
25269
|
+
async runCompact(sessionId) {
|
|
25270
|
+
await this.codexClient.runCompact({ threadId: sessionId });
|
|
25271
|
+
}
|
|
25272
|
+
async setGoal(sessionId, objective, onTurnStarted) {
|
|
25273
|
+
return await this.codexClient.runGoalSet({
|
|
25274
|
+
threadId: sessionId,
|
|
25275
|
+
objective,
|
|
25276
|
+
status: "active"
|
|
25277
|
+
}, onTurnStarted);
|
|
25278
|
+
}
|
|
25279
|
+
async setGoalStatus(sessionId, status) {
|
|
25280
|
+
await this.codexClient.runGoalSet({
|
|
25281
|
+
threadId: sessionId,
|
|
25282
|
+
status
|
|
25283
|
+
});
|
|
25284
|
+
}
|
|
25285
|
+
async resumeGoal(sessionId, onTurnStarted) {
|
|
25286
|
+
return await this.codexClient.runGoalSet({
|
|
24568
25287
|
threadId: sessionId,
|
|
24569
|
-
|
|
24570
|
-
delivery: "inline"
|
|
25288
|
+
status: "active"
|
|
24571
25289
|
}, onTurnStarted);
|
|
24572
25290
|
}
|
|
24573
|
-
async
|
|
24574
|
-
await this.codexClient.
|
|
25291
|
+
async clearGoal(sessionId) {
|
|
25292
|
+
await this.codexClient.runGoalClear({ threadId: sessionId });
|
|
24575
25293
|
}
|
|
24576
25294
|
async awaitMcpServerStartup(serverNames, afterVersion) {
|
|
24577
25295
|
return await this.codexClient.awaitMcpServerStartup(serverNames, afterVersion);
|
|
@@ -25088,22 +25806,27 @@ var CodexCommands = class {
|
|
|
25088
25806
|
this.runWithProcessCheck = runWithProcessCheck;
|
|
25089
25807
|
this.onLogout = onLogout;
|
|
25090
25808
|
}
|
|
25091
|
-
async publish(
|
|
25809
|
+
async publish(sessionState) {
|
|
25092
25810
|
try {
|
|
25093
|
-
const skillsResponse = await this.runWithProcessCheck(() => this.codexAcpClient.listSkills());
|
|
25811
|
+
const skillsResponse = await this.runWithProcessCheck(() => this.codexAcpClient.listSkills(this.createSkillsListParams(sessionState)));
|
|
25094
25812
|
const availableCommands = this.buildAvailableCommands(skillsResponse?.data ?? []);
|
|
25095
25813
|
if (availableCommands.length === 0) {
|
|
25096
25814
|
return;
|
|
25097
25815
|
}
|
|
25098
|
-
const session = new ACPSessionConnection(this.connection, sessionId);
|
|
25816
|
+
const session = new ACPSessionConnection(this.connection, sessionState.sessionId);
|
|
25099
25817
|
await session.update({
|
|
25100
25818
|
sessionUpdate: "available_commands_update",
|
|
25101
25819
|
availableCommands
|
|
25102
25820
|
});
|
|
25103
25821
|
} catch (err) {
|
|
25104
|
-
logger.error(`Failed to publish available commands for session ${sessionId}`, err);
|
|
25822
|
+
logger.error(`Failed to publish available commands for session ${sessionState.sessionId}`, err);
|
|
25105
25823
|
}
|
|
25106
25824
|
}
|
|
25825
|
+
createSkillsListParams(sessionState) {
|
|
25826
|
+
return {
|
|
25827
|
+
cwds: [sessionState.cwd, ...sessionState.additionalDirectories]
|
|
25828
|
+
};
|
|
25829
|
+
}
|
|
25107
25830
|
buildAvailableCommands(skillsEntries) {
|
|
25108
25831
|
const commands = /* @__PURE__ */ new Map();
|
|
25109
25832
|
for (const builtin of this.getBuiltinCommands()) {
|
|
@@ -25163,6 +25886,11 @@ var CodexCommands = class {
|
|
|
25163
25886
|
description: "Summarize conversation to avoid hitting the context limit.",
|
|
25164
25887
|
input: null
|
|
25165
25888
|
},
|
|
25889
|
+
{
|
|
25890
|
+
name: "goal",
|
|
25891
|
+
description: "Set, pause, resume, or clear a task goal.",
|
|
25892
|
+
input: { hint: "[<objective>|clear|pause|resume]" }
|
|
25893
|
+
},
|
|
25166
25894
|
{
|
|
25167
25895
|
name: "logout",
|
|
25168
25896
|
description: "Sign out of Codex. This option is available when you are logged in via ChatGPT.",
|
|
@@ -25195,6 +25923,9 @@ var CodexCommands = class {
|
|
|
25195
25923
|
await this.runWithProcessCheck(() => this.codexAcpClient.runCompact(sessionId));
|
|
25196
25924
|
return { handled: true };
|
|
25197
25925
|
}
|
|
25926
|
+
case "goal": {
|
|
25927
|
+
return await this.runGoalCommand(sessionState, command.rest, options);
|
|
25928
|
+
}
|
|
25198
25929
|
case "review": {
|
|
25199
25930
|
const target = this.buildReviewTarget(command.rest);
|
|
25200
25931
|
const turnCompleted = await this.runReviewCommand(sessionState, target, options);
|
|
@@ -25226,24 +25957,18 @@ var CodexCommands = class {
|
|
|
25226
25957
|
case "status": {
|
|
25227
25958
|
const session = new ACPSessionConnection(this.connection, sessionId);
|
|
25228
25959
|
const message = this.buildStatusMessage(sessionState);
|
|
25229
|
-
await session.update(
|
|
25230
|
-
sessionUpdate: "agent_message_chunk",
|
|
25231
|
-
content: { type: "text", text: message }
|
|
25232
|
-
});
|
|
25960
|
+
await session.update(createAgentTextMessageChunk(message));
|
|
25233
25961
|
return { handled: true };
|
|
25234
25962
|
}
|
|
25235
25963
|
case "logout": {
|
|
25236
25964
|
await this.runWithProcessCheck(() => this.codexAcpClient.logout());
|
|
25237
25965
|
await this.onLogout();
|
|
25238
25966
|
const session = new ACPSessionConnection(this.connection, sessionId);
|
|
25239
|
-
await session.update(
|
|
25240
|
-
sessionUpdate: "agent_message_chunk",
|
|
25241
|
-
content: { type: "text", text: "Logged out from Codex account." }
|
|
25242
|
-
});
|
|
25967
|
+
await session.update(createAgentTextMessageChunk("Logged out from Codex account."));
|
|
25243
25968
|
return { handled: true };
|
|
25244
25969
|
}
|
|
25245
25970
|
case "skills": {
|
|
25246
|
-
const response = await this.runWithProcessCheck(() => this.codexAcpClient.listSkills());
|
|
25971
|
+
const response = await this.runWithProcessCheck(() => this.codexAcpClient.listSkills(this.createSkillsListParams(sessionState)));
|
|
25247
25972
|
const skills = (response?.data ?? []).flatMap((entry) => entry.skills);
|
|
25248
25973
|
const lines = skills.map((skill) => {
|
|
25249
25974
|
const description = skill.shortDescription ?? skill.description ?? "";
|
|
@@ -25251,10 +25976,7 @@ var CodexCommands = class {
|
|
|
25251
25976
|
});
|
|
25252
25977
|
const text = lines.length > 0 ? ["Available skills:", ...lines].join("\n") : "No skills configured.";
|
|
25253
25978
|
const session = new ACPSessionConnection(this.connection, sessionId);
|
|
25254
|
-
await session.update(
|
|
25255
|
-
sessionUpdate: "agent_message_chunk",
|
|
25256
|
-
content: { type: "text", text }
|
|
25257
|
-
});
|
|
25979
|
+
await session.update(createAgentTextMessageChunk(text));
|
|
25258
25980
|
return { handled: true };
|
|
25259
25981
|
}
|
|
25260
25982
|
case "mcp": {
|
|
@@ -25268,10 +25990,7 @@ var CodexCommands = class {
|
|
|
25268
25990
|
const lines = [...configuredServers, ...sessionServers];
|
|
25269
25991
|
const text = lines.length > 0 ? ["Configured MCP servers:", ...lines].join("\n") : "No MCP servers configured.";
|
|
25270
25992
|
const session = new ACPSessionConnection(this.connection, sessionId);
|
|
25271
|
-
await session.update(
|
|
25272
|
-
sessionUpdate: "agent_message_chunk",
|
|
25273
|
-
content: { type: "text", text }
|
|
25274
|
-
});
|
|
25993
|
+
await session.update(createAgentTextMessageChunk(text));
|
|
25275
25994
|
return { handled: true };
|
|
25276
25995
|
}
|
|
25277
25996
|
default:
|
|
@@ -25280,18 +25999,68 @@ var CodexCommands = class {
|
|
|
25280
25999
|
}
|
|
25281
26000
|
}
|
|
25282
26001
|
async runReviewCommand(sessionState, target, options) {
|
|
26002
|
+
options.onTurnStartPending?.();
|
|
25283
26003
|
return await this.runWithProcessCheck(() => this.codexAcpClient.runReview(
|
|
25284
26004
|
sessionState.sessionId,
|
|
25285
26005
|
target,
|
|
25286
26006
|
(turnId, threadId) => {
|
|
25287
|
-
|
|
25288
|
-
options.onTurnStarted(turnId, threadId);
|
|
25289
|
-
} else {
|
|
25290
|
-
sessionState.currentTurnId = turnId;
|
|
25291
|
-
}
|
|
26007
|
+
this.handleCommandTurnStarted(sessionState, options, turnId, threadId);
|
|
25292
26008
|
}
|
|
25293
26009
|
));
|
|
25294
26010
|
}
|
|
26011
|
+
async runGoalCommand(sessionState, rest, options) {
|
|
26012
|
+
const sessionId = sessionState.sessionId;
|
|
26013
|
+
const argument = rest.trim();
|
|
26014
|
+
if (argument.length === 0) {
|
|
26015
|
+
await this.sendCommandUsageMessage("goal", "[<objective>|clear|pause|resume]", sessionId);
|
|
26016
|
+
return { handled: true };
|
|
26017
|
+
}
|
|
26018
|
+
switch (argument.toLowerCase()) {
|
|
26019
|
+
case "pause":
|
|
26020
|
+
await this.runWithProcessCheck(() => this.codexAcpClient.setGoalStatus(sessionId, "paused"));
|
|
26021
|
+
return { handled: true };
|
|
26022
|
+
case "resume":
|
|
26023
|
+
options.onTurnStartPending?.();
|
|
26024
|
+
return this.createGoalCommandResult(await this.runWithProcessCheck(() => this.codexAcpClient.resumeGoal(
|
|
26025
|
+
sessionId,
|
|
26026
|
+
(turnId) => {
|
|
26027
|
+
this.handleCommandTurnStarted(sessionState, options, turnId, sessionId);
|
|
26028
|
+
}
|
|
26029
|
+
)));
|
|
26030
|
+
case "clear":
|
|
26031
|
+
await this.runWithProcessCheck(() => this.codexAcpClient.clearGoal(sessionId));
|
|
26032
|
+
return { handled: true };
|
|
26033
|
+
}
|
|
26034
|
+
if (argument.length > 4e3) {
|
|
26035
|
+
const session = new ACPSessionConnection(this.connection, sessionId);
|
|
26036
|
+
await session.update(createAgentTextMessageChunk('Command "/goal" requires goal text of at most 4000 characters.'));
|
|
26037
|
+
return { handled: true };
|
|
26038
|
+
}
|
|
26039
|
+
options.onTurnStartPending?.();
|
|
26040
|
+
return this.createGoalCommandResult(await this.runWithProcessCheck(() => this.codexAcpClient.setGoal(
|
|
26041
|
+
sessionId,
|
|
26042
|
+
argument,
|
|
26043
|
+
(turnId) => {
|
|
26044
|
+
this.handleCommandTurnStarted(sessionState, options, turnId, sessionId);
|
|
26045
|
+
}
|
|
26046
|
+
)));
|
|
26047
|
+
}
|
|
26048
|
+
handleCommandTurnStarted(sessionState, options, turnId, threadId) {
|
|
26049
|
+
if (options.onTurnStarted) {
|
|
26050
|
+
options.onTurnStarted(turnId, threadId);
|
|
26051
|
+
} else {
|
|
26052
|
+
sessionState.currentTurnId = turnId;
|
|
26053
|
+
}
|
|
26054
|
+
}
|
|
26055
|
+
createGoalCommandResult(turnCompleted) {
|
|
26056
|
+
if (turnCompleted === null) {
|
|
26057
|
+
return { handled: true };
|
|
26058
|
+
}
|
|
26059
|
+
return {
|
|
26060
|
+
handled: true,
|
|
26061
|
+
turnCompleted
|
|
26062
|
+
};
|
|
26063
|
+
}
|
|
25295
26064
|
buildReviewTarget(instructions) {
|
|
25296
26065
|
if (instructions.length === 0) {
|
|
25297
26066
|
return { type: "uncommittedChanges" };
|
|
@@ -25303,13 +26072,7 @@ var CodexCommands = class {
|
|
|
25303
26072
|
}
|
|
25304
26073
|
async sendCommandUsageMessage(name, inputHint, sessionId) {
|
|
25305
26074
|
const session = new ACPSessionConnection(this.connection, sessionId);
|
|
25306
|
-
await session.update({
|
|
25307
|
-
sessionUpdate: "agent_message_chunk",
|
|
25308
|
-
content: {
|
|
25309
|
-
type: "text",
|
|
25310
|
-
text: `Command "/${name}" requires ${inputHint}.`
|
|
25311
|
-
}
|
|
25312
|
-
});
|
|
26075
|
+
await session.update(createAgentTextMessageChunk(`Command "/${name}" requires ${inputHint}.`));
|
|
25313
26076
|
}
|
|
25314
26077
|
async sendUnknownCommandMessage(name, sessionId) {
|
|
25315
26078
|
const lines = this.getBuiltinCommands().map((command) => `- /${command.name}: ${command.description}`);
|
|
@@ -25321,10 +26084,7 @@ var CodexCommands = class {
|
|
|
25321
26084
|
text.push(...lines);
|
|
25322
26085
|
}
|
|
25323
26086
|
const session = new ACPSessionConnection(this.connection, sessionId);
|
|
25324
|
-
await session.update(
|
|
25325
|
-
sessionUpdate: "agent_message_chunk",
|
|
25326
|
-
content: { type: "text", text: text.join("\n") }
|
|
25327
|
-
});
|
|
26087
|
+
await session.update(createAgentTextMessageChunk(text.join("\n")));
|
|
25328
26088
|
}
|
|
25329
26089
|
buildStatusMessage(sessionState) {
|
|
25330
26090
|
const agentMode = sessionState.agentMode;
|
|
@@ -25467,7 +26227,7 @@ function historyFallbackUpdateKey(update) {
|
|
|
25467
26227
|
case "user_message_chunk":
|
|
25468
26228
|
case "agent_message_chunk":
|
|
25469
26229
|
case "agent_thought_chunk":
|
|
25470
|
-
return `${update.sessionUpdate}:${JSON.stringify(update.content)}`;
|
|
26230
|
+
return `${update.sessionUpdate}:${update.messageId ?? ""}:${JSON.stringify(update.content)}`;
|
|
25471
26231
|
case "tool_call":
|
|
25472
26232
|
return `tool_call:${update.toolCallId}:start`;
|
|
25473
26233
|
case "tool_call_update":
|
|
@@ -26431,6 +27191,7 @@ function isExtMethodRequest(request) {
|
|
|
26431
27191
|
|
|
26432
27192
|
// src/FastModeConfig.ts
|
|
26433
27193
|
var FAST_MODE_CONFIG_ID = "fast-mode";
|
|
27194
|
+
var FAST_MODE_CATEGORY = "model_config";
|
|
26434
27195
|
var FAST_MODE_ON = "on";
|
|
26435
27196
|
var FAST_MODE_OFF = "off";
|
|
26436
27197
|
var FAST_MODE_DESCRIPTION = "1.5x speed, increased usage";
|
|
@@ -26440,12 +27201,25 @@ function modelSupportsFast(model) {
|
|
|
26440
27201
|
function resolveFastServiceTier(fastModeEnabled, currentModelSupportsFast) {
|
|
26441
27202
|
return fastModeEnabled && currentModelSupportsFast ? "fast" : null;
|
|
26442
27203
|
}
|
|
26443
|
-
function
|
|
27204
|
+
function clientSupportsBooleanConfigOptions(clientCapabilities) {
|
|
27205
|
+
return clientCapabilities?.session?.configOptions?.boolean != null;
|
|
27206
|
+
}
|
|
27207
|
+
function createFastModeConfigOption(fastModeEnabled, useBooleanConfigOption = false) {
|
|
27208
|
+
if (useBooleanConfigOption) {
|
|
27209
|
+
return {
|
|
27210
|
+
id: FAST_MODE_CONFIG_ID,
|
|
27211
|
+
name: "Fast mode",
|
|
27212
|
+
description: FAST_MODE_DESCRIPTION,
|
|
27213
|
+
category: FAST_MODE_CATEGORY,
|
|
27214
|
+
type: "boolean",
|
|
27215
|
+
currentValue: fastModeEnabled
|
|
27216
|
+
};
|
|
27217
|
+
}
|
|
26444
27218
|
return {
|
|
26445
27219
|
id: FAST_MODE_CONFIG_ID,
|
|
26446
27220
|
name: "Fast mode",
|
|
26447
27221
|
description: FAST_MODE_DESCRIPTION,
|
|
26448
|
-
category:
|
|
27222
|
+
category: FAST_MODE_CATEGORY,
|
|
26449
27223
|
type: "select",
|
|
26450
27224
|
currentValue: fastModeEnabled ? FAST_MODE_ON : FAST_MODE_OFF,
|
|
26451
27225
|
options: [
|
|
@@ -26489,6 +27263,7 @@ var CodexAcpServer = class _CodexAcpServer {
|
|
|
26489
27263
|
availableCommands;
|
|
26490
27264
|
clientInfo;
|
|
26491
27265
|
terminalOutputMode;
|
|
27266
|
+
booleanConfigOptionsSupported;
|
|
26492
27267
|
sessions;
|
|
26493
27268
|
pendingMcpStartupSessions;
|
|
26494
27269
|
pendingTurnStarts;
|
|
@@ -26511,6 +27286,7 @@ var CodexAcpServer = class _CodexAcpServer {
|
|
|
26511
27286
|
this.getRecentStderr = getRecentStderr ?? (() => "");
|
|
26512
27287
|
this.clientInfo = null;
|
|
26513
27288
|
this.terminalOutputMode = "terminal_output_delta";
|
|
27289
|
+
this.booleanConfigOptionsSupported = false;
|
|
26514
27290
|
this.availableCommands = new CodexCommands(
|
|
26515
27291
|
connection,
|
|
26516
27292
|
codexAcpClient,
|
|
@@ -26522,6 +27298,7 @@ var CodexAcpServer = class _CodexAcpServer {
|
|
|
26522
27298
|
logger.log("Initialize request received");
|
|
26523
27299
|
this.clientInfo = _params.clientInfo ?? null;
|
|
26524
27300
|
this.terminalOutputMode = resolveTerminalOutputMode(_params.clientCapabilities);
|
|
27301
|
+
this.booleanConfigOptionsSupported = clientSupportsBooleanConfigOptions(_params.clientCapabilities);
|
|
26525
27302
|
await this.runWithProcessCheck(() => this.codexAcpClient.initialize(_params));
|
|
26526
27303
|
return {
|
|
26527
27304
|
protocolVersion: PROTOCOL_VERSION,
|
|
@@ -26734,7 +27511,7 @@ You have been logged out. Please try again.`);
|
|
|
26734
27511
|
});
|
|
26735
27512
|
this.publishMcpStartupStatusAsync(sessionId);
|
|
26736
27513
|
}
|
|
26737
|
-
this.publishAvailableCommandsAsync(
|
|
27514
|
+
this.publishAvailableCommandsAsync(sessionState);
|
|
26738
27515
|
const sessionModelState = this.createModelState(models, currentModelId);
|
|
26739
27516
|
const sessionModeState = sessionState.agentMode.toSessionModeState();
|
|
26740
27517
|
return [sessionId, sessionModelState, sessionModeState];
|
|
@@ -26931,22 +27708,18 @@ You have been logged out. Please try again.`);
|
|
|
26931
27708
|
});
|
|
26932
27709
|
const sessionState = this.sessions.get(params.sessionId);
|
|
26933
27710
|
if (!sessionState) throw new Error(`Session ${params.sessionId} not found`);
|
|
26934
|
-
if (typeof params.value !== "string") {
|
|
26935
|
-
throw RequestError.invalidParams();
|
|
26936
|
-
}
|
|
26937
|
-
const value = params.value;
|
|
26938
27711
|
switch (params.configId) {
|
|
26939
27712
|
case FAST_MODE_CONFIG_ID:
|
|
26940
|
-
this.applyFastModeChange(sessionState,
|
|
27713
|
+
this.applyFastModeChange(sessionState, params);
|
|
26941
27714
|
break;
|
|
26942
27715
|
case MODE_CONFIG_ID:
|
|
26943
|
-
this.applyModeChange(sessionState,
|
|
27716
|
+
this.applyModeChange(sessionState, this.stringConfigValue(params));
|
|
26944
27717
|
break;
|
|
26945
27718
|
case MODEL_CONFIG_ID:
|
|
26946
|
-
this.applyModelChange(sessionState,
|
|
27719
|
+
this.applyModelChange(sessionState, this.stringConfigValue(params));
|
|
26947
27720
|
break;
|
|
26948
27721
|
case REASONING_EFFORT_CONFIG_ID:
|
|
26949
|
-
this.applyReasoningEffortChange(sessionState,
|
|
27722
|
+
this.applyReasoningEffortChange(sessionState, this.stringConfigValue(params));
|
|
26950
27723
|
break;
|
|
26951
27724
|
default:
|
|
26952
27725
|
throw RequestError.invalidParams();
|
|
@@ -26955,12 +27728,23 @@ You have been logged out. Please try again.`);
|
|
|
26955
27728
|
configOptions: this.createSessionConfigOptions(sessionState)
|
|
26956
27729
|
};
|
|
26957
27730
|
}
|
|
26958
|
-
applyFastModeChange(sessionState,
|
|
27731
|
+
applyFastModeChange(sessionState, params) {
|
|
27732
|
+
const value = params.value;
|
|
27733
|
+
if (typeof value === "boolean") {
|
|
27734
|
+
sessionState.fastModeEnabled = value;
|
|
27735
|
+
return;
|
|
27736
|
+
}
|
|
26959
27737
|
if (value !== FAST_MODE_ON && value !== FAST_MODE_OFF) {
|
|
26960
27738
|
throw RequestError.invalidParams();
|
|
26961
27739
|
}
|
|
26962
27740
|
sessionState.fastModeEnabled = value === FAST_MODE_ON;
|
|
26963
27741
|
}
|
|
27742
|
+
stringConfigValue(params) {
|
|
27743
|
+
if (typeof params.value !== "string") {
|
|
27744
|
+
throw RequestError.invalidParams();
|
|
27745
|
+
}
|
|
27746
|
+
return params.value;
|
|
27747
|
+
}
|
|
26964
27748
|
applyModeChange(sessionState, value) {
|
|
26965
27749
|
const newMode = AgentMode.find(value);
|
|
26966
27750
|
if (!newMode) {
|
|
@@ -27042,7 +27826,12 @@ You have been logged out. Please try again.`);
|
|
|
27042
27826
|
createReasoningEffortConfigOption(sessionState.supportedReasoningEfforts, currentModelId.effort)
|
|
27043
27827
|
);
|
|
27044
27828
|
}
|
|
27045
|
-
|
|
27829
|
+
if (sessionState.currentModelSupportsFast) {
|
|
27830
|
+
configOptions.push(createFastModeConfigOption(
|
|
27831
|
+
sessionState.fastModeEnabled,
|
|
27832
|
+
this.booleanConfigOptionsSupported
|
|
27833
|
+
));
|
|
27834
|
+
}
|
|
27046
27835
|
return configOptions;
|
|
27047
27836
|
}
|
|
27048
27837
|
createSessionConfigOptionsResponse(sessionState) {
|
|
@@ -27056,8 +27845,8 @@ You have been logged out. Please try again.`);
|
|
|
27056
27845
|
isSessionConfigEnabled() {
|
|
27057
27846
|
return !isJetBrains2026_1Client(this.clientInfo);
|
|
27058
27847
|
}
|
|
27059
|
-
publishAvailableCommandsAsync(
|
|
27060
|
-
void this.availableCommands.publish(
|
|
27848
|
+
publishAvailableCommandsAsync(sessionState) {
|
|
27849
|
+
void this.availableCommands.publish(sessionState);
|
|
27061
27850
|
}
|
|
27062
27851
|
findCurrentModel(models, currentModelId) {
|
|
27063
27852
|
const modelId = ModelId.fromString(currentModelId);
|
|
@@ -27148,7 +27937,7 @@ You have been logged out. Please try again.`);
|
|
|
27148
27937
|
});
|
|
27149
27938
|
this.publishMcpStartupStatusAsync(sessionId);
|
|
27150
27939
|
}
|
|
27151
|
-
await this.availableCommands.publish(
|
|
27940
|
+
await this.availableCommands.publish(sessionState);
|
|
27152
27941
|
const sessionModelState = this.createModelState(models, currentModelId);
|
|
27153
27942
|
const sessionModeState = sessionState.agentMode.toSessionModeState();
|
|
27154
27943
|
return {
|
|
@@ -27188,6 +27977,7 @@ You have been logged out. Please try again.`);
|
|
|
27188
27977
|
case "agentMessage":
|
|
27189
27978
|
return [{
|
|
27190
27979
|
sessionUpdate: "agent_message_chunk",
|
|
27980
|
+
messageId: item.id,
|
|
27191
27981
|
content: { type: "text", text: item.text }
|
|
27192
27982
|
}];
|
|
27193
27983
|
case "reasoning":
|
|
@@ -27226,23 +28016,19 @@ You have been logged out. Please try again.`);
|
|
|
27226
28016
|
}
|
|
27227
28017
|
createUserMessageUpdates(item) {
|
|
27228
28018
|
const updates = [];
|
|
28019
|
+
const messageId = item.id;
|
|
27229
28020
|
for (const input of item.content) {
|
|
27230
28021
|
const blocks = this.userInputToContentBlocks(input);
|
|
27231
28022
|
for (const block of blocks) {
|
|
27232
|
-
updates.push(
|
|
27233
|
-
sessionUpdate: "user_message_chunk",
|
|
27234
|
-
content: block
|
|
27235
|
-
});
|
|
28023
|
+
updates.push(createUserMessageChunk(block, messageId));
|
|
27236
28024
|
}
|
|
27237
28025
|
}
|
|
27238
28026
|
return updates;
|
|
27239
28027
|
}
|
|
27240
28028
|
createReasoningUpdates(item) {
|
|
27241
28029
|
const parts = item.summary.length > 0 ? item.summary : item.content;
|
|
27242
|
-
|
|
27243
|
-
|
|
27244
|
-
content: { type: "text", text }
|
|
27245
|
-
}));
|
|
28030
|
+
const messageId = item.id;
|
|
28031
|
+
return parts.map((text) => createAgentTextThoughtChunk(text, messageId));
|
|
27246
28032
|
}
|
|
27247
28033
|
createWebSearchUpdate(item) {
|
|
27248
28034
|
return {
|
|
@@ -27563,6 +28349,13 @@ ${item.text}`
|
|
|
27563
28349
|
sessionState.lastTokenUsage = null;
|
|
27564
28350
|
const activePrompt = this.trackActivePrompt(params.sessionId);
|
|
27565
28351
|
let pendingTurnStart = null;
|
|
28352
|
+
const ensurePendingTurnStart = () => {
|
|
28353
|
+
if (pendingTurnStart === null) {
|
|
28354
|
+
pendingTurnStart = this.createPendingTurnStart();
|
|
28355
|
+
this.pendingTurnStarts.set(params.sessionId, pendingTurnStart);
|
|
28356
|
+
}
|
|
28357
|
+
return pendingTurnStart;
|
|
28358
|
+
};
|
|
27566
28359
|
const disposePromptRequestCancellation = this.observePromptRequestCancellation(signal, sessionState, activePrompt);
|
|
27567
28360
|
try {
|
|
27568
28361
|
const eventHandler = new CodexEventHandler(this.connection, sessionState);
|
|
@@ -27581,6 +28374,9 @@ ${item.text}`
|
|
|
27581
28374
|
return this.cancelledPromptResponse(sessionState);
|
|
27582
28375
|
}
|
|
27583
28376
|
const commandPromise = this.availableCommands.tryHandleCommand(params.prompt, sessionState, {
|
|
28377
|
+
onTurnStartPending: () => {
|
|
28378
|
+
ensurePendingTurnStart();
|
|
28379
|
+
},
|
|
27584
28380
|
onTurnStarted: (turnId, threadId) => {
|
|
27585
28381
|
const turn = { threadId, turnId };
|
|
27586
28382
|
activePrompt.currentTurn = turn;
|
|
@@ -27589,6 +28385,7 @@ ${item.text}`
|
|
|
27589
28385
|
return;
|
|
27590
28386
|
}
|
|
27591
28387
|
sessionState.currentTurnId = turnId;
|
|
28388
|
+
pendingTurnStart?.resolve(turnId);
|
|
27592
28389
|
}
|
|
27593
28390
|
});
|
|
27594
28391
|
void commandPromise.catch((err) => {
|
|
@@ -27641,8 +28438,7 @@ ${item.text}`
|
|
|
27641
28438
|
sessionState.fastModeEnabled,
|
|
27642
28439
|
sessionState.currentModelSupportsFast
|
|
27643
28440
|
);
|
|
27644
|
-
|
|
27645
|
-
this.pendingTurnStarts.set(params.sessionId, pendingTurnStart);
|
|
28441
|
+
ensurePendingTurnStart();
|
|
27646
28442
|
const sendPromptPromise = this.runWithProcessCheck(
|
|
27647
28443
|
() => this.codexAcpClient.sendPrompt(
|
|
27648
28444
|
params,
|
|
@@ -27699,10 +28495,11 @@ ${item.text}`
|
|
|
27699
28495
|
logger.log("Prompt completed", { sessionId: params.sessionId });
|
|
27700
28496
|
disposePromptRequestCancellation();
|
|
27701
28497
|
sessionState.currentTurnId = null;
|
|
27702
|
-
|
|
28498
|
+
const registeredPendingTurnStart = this.pendingTurnStarts.get(params.sessionId);
|
|
28499
|
+
if (registeredPendingTurnStart !== void 0) {
|
|
27703
28500
|
this.pendingTurnStarts.delete(params.sessionId);
|
|
28501
|
+
registeredPendingTurnStart.resolve(null);
|
|
27704
28502
|
}
|
|
27705
|
-
pendingTurnStart?.resolve(null);
|
|
27706
28503
|
activePrompt.complete();
|
|
27707
28504
|
}
|
|
27708
28505
|
}
|
|
@@ -27719,13 +28516,7 @@ ${item.text}`
|
|
|
27719
28516
|
}
|
|
27720
28517
|
await this.connection.notify(methods.client.session.update, {
|
|
27721
28518
|
sessionId,
|
|
27722
|
-
update:
|
|
27723
|
-
sessionUpdate: "agent_message_chunk",
|
|
27724
|
-
content: {
|
|
27725
|
-
type: "text",
|
|
27726
|
-
text: "*Conversation interrupted*"
|
|
27727
|
-
}
|
|
27728
|
-
}
|
|
28519
|
+
update: createAgentTextMessageChunk("*Conversation interrupted*")
|
|
27729
28520
|
});
|
|
27730
28521
|
}
|
|
27731
28522
|
buildQuotaMeta(sessionState) {
|
|
@@ -27786,22 +28577,24 @@ function mergeHistoryUpdates(responseItemFallbackUpdates, threadUpdates) {
|
|
|
27786
28577
|
}
|
|
27787
28578
|
merged.push(update);
|
|
27788
28579
|
};
|
|
27789
|
-
const
|
|
27790
|
-
const
|
|
28580
|
+
const flushFallbackBeforeMatchingDuplicate = (targetUpdate) => {
|
|
28581
|
+
const targetKey = historyUpdateKey(targetUpdate);
|
|
28582
|
+
const targetContentKey = historyUpdateContentKey(targetUpdate);
|
|
28583
|
+
if (!targetKey && !targetContentKey) {
|
|
28584
|
+
return;
|
|
28585
|
+
}
|
|
28586
|
+
const matchIndex = responseItemFallbackUpdates.findIndex((update, index) => index >= fallbackIndex && (targetKey !== null && historyUpdateKey(update) === targetKey || targetContentKey !== null && historyUpdateContentKey(update) === targetContentKey));
|
|
27791
28587
|
if (matchIndex === -1) {
|
|
27792
|
-
return
|
|
28588
|
+
return;
|
|
27793
28589
|
}
|
|
27794
|
-
while (fallbackIndex
|
|
28590
|
+
while (fallbackIndex < matchIndex) {
|
|
27795
28591
|
pushUpdate(responseItemFallbackUpdates[fallbackIndex]);
|
|
27796
28592
|
fallbackIndex += 1;
|
|
27797
28593
|
}
|
|
27798
|
-
|
|
28594
|
+
fallbackIndex += 1;
|
|
27799
28595
|
};
|
|
27800
28596
|
for (const update of threadUpdates) {
|
|
27801
|
-
|
|
27802
|
-
if (key && flushFallbackThrough(key)) {
|
|
27803
|
-
continue;
|
|
27804
|
-
}
|
|
28597
|
+
flushFallbackBeforeMatchingDuplicate(update);
|
|
27805
28598
|
pushUpdate(update);
|
|
27806
28599
|
}
|
|
27807
28600
|
while (fallbackIndex < responseItemFallbackUpdates.length) {
|
|
@@ -27815,7 +28608,7 @@ function historyUpdateKey(update) {
|
|
|
27815
28608
|
case "user_message_chunk":
|
|
27816
28609
|
case "agent_message_chunk":
|
|
27817
28610
|
case "agent_thought_chunk":
|
|
27818
|
-
return `${update.sessionUpdate}:${JSON.stringify(update.content)}`;
|
|
28611
|
+
return `${update.sessionUpdate}:${update.messageId ?? ""}:${JSON.stringify(update.content)}`;
|
|
27819
28612
|
case "tool_call":
|
|
27820
28613
|
return `tool_call:${update.toolCallId}:start`;
|
|
27821
28614
|
case "tool_call_update":
|
|
@@ -27824,16 +28617,27 @@ function historyUpdateKey(update) {
|
|
|
27824
28617
|
return null;
|
|
27825
28618
|
}
|
|
27826
28619
|
}
|
|
28620
|
+
function historyUpdateContentKey(update) {
|
|
28621
|
+
switch (update.sessionUpdate) {
|
|
28622
|
+
case "user_message_chunk":
|
|
28623
|
+
case "agent_message_chunk":
|
|
28624
|
+
case "agent_thought_chunk":
|
|
28625
|
+
return `${update.sessionUpdate}:${JSON.stringify(update.content)}`;
|
|
28626
|
+
default:
|
|
28627
|
+
return historyUpdateKey(update);
|
|
28628
|
+
}
|
|
28629
|
+
}
|
|
27827
28630
|
function getRequestedMcpServerNames(mcpServers) {
|
|
27828
28631
|
return Array.from(new Set(mcpServers.map((server) => sanitizeMcpServerName(server.name))));
|
|
27829
28632
|
}
|
|
27830
28633
|
|
|
27831
28634
|
// src/CodexAppServerClient.ts
|
|
27832
|
-
var import_node2 = __toESM(
|
|
28635
|
+
var import_node2 = __toESM(require_main(), 1);
|
|
27833
28636
|
var CommandExecutionApprovalRequest = new import_node2.RequestType("item/commandExecution/requestApproval");
|
|
27834
28637
|
var FileChangeApprovalRequest = new import_node2.RequestType("item/fileChange/requestApproval");
|
|
27835
28638
|
var PermissionsApprovalRequest = new import_node2.RequestType("item/permissions/requestApproval");
|
|
27836
28639
|
var McpServerElicitationRequest = new import_node2.RequestType("mcpServer/elicitation/request");
|
|
28640
|
+
var GOAL_RUNTIME_EFFECTS_GRACE_MS = 1e3;
|
|
27837
28641
|
var CodexAppServerClient = class {
|
|
27838
28642
|
connection;
|
|
27839
28643
|
approvalHandlers = /* @__PURE__ */ new Map();
|
|
@@ -27844,6 +28648,10 @@ var CodexAppServerClient = class {
|
|
|
27844
28648
|
pendingTurnCompletionResolvers = /* @__PURE__ */ new Map();
|
|
27845
28649
|
pendingCompactionCompletionResolvers = /* @__PURE__ */ new Map();
|
|
27846
28650
|
turnCompletionCaptures = /* @__PURE__ */ new Map();
|
|
28651
|
+
turnRoutingCaptures = /* @__PURE__ */ new Map();
|
|
28652
|
+
threadStatusCaptures = /* @__PURE__ */ new Map();
|
|
28653
|
+
threadGoalUpdateCaptures = /* @__PURE__ */ new Map();
|
|
28654
|
+
threadGoalClearedCaptures = /* @__PURE__ */ new Map();
|
|
27847
28655
|
staleTurnIds = /* @__PURE__ */ new Map();
|
|
27848
28656
|
constructor(connection) {
|
|
27849
28657
|
this.connection = connection;
|
|
@@ -27864,15 +28672,21 @@ var CodexAppServerClient = class {
|
|
|
27864
28672
|
if (isCompactionCompletedNotification(serverNotification)) {
|
|
27865
28673
|
this.recordCompactionCompleted(serverNotification);
|
|
27866
28674
|
}
|
|
28675
|
+
if (isThreadStatusChangedNotification(serverNotification)) {
|
|
28676
|
+
this.recordThreadStatusChanged(serverNotification.params);
|
|
28677
|
+
}
|
|
28678
|
+
if (isThreadGoalUpdatedNotification(serverNotification)) {
|
|
28679
|
+
this.recordThreadGoalUpdated(serverNotification.params);
|
|
28680
|
+
}
|
|
28681
|
+
if (isThreadGoalClearedNotification(serverNotification)) {
|
|
28682
|
+
this.recordThreadGoalCleared(serverNotification.params);
|
|
28683
|
+
}
|
|
27867
28684
|
const routing = extractTurnRouting(serverNotification);
|
|
27868
|
-
|
|
27869
|
-
|
|
27870
|
-
|
|
27871
|
-
|
|
27872
|
-
|
|
27873
|
-
for (const callback of this.codexEventHandlers) {
|
|
27874
|
-
callback({ eventType: "notification", ...serverNotification });
|
|
27875
|
-
}
|
|
28685
|
+
if (this.handleStaleTurnNotification(serverNotification, routing)) {
|
|
28686
|
+
return;
|
|
28687
|
+
}
|
|
28688
|
+
this.recordTurnRouting(routing);
|
|
28689
|
+
if (this.handleStaleTurnNotification(serverNotification, routing)) {
|
|
27876
28690
|
return;
|
|
27877
28691
|
}
|
|
27878
28692
|
this.notify(serverNotification);
|
|
@@ -27974,6 +28788,174 @@ var CodexAppServerClient = class {
|
|
|
27974
28788
|
releaseCapture();
|
|
27975
28789
|
}
|
|
27976
28790
|
}
|
|
28791
|
+
async runGoalSet(params, onTurnStarted, runtimeEffectsGraceMs = GOAL_RUNTIME_EFFECTS_GRACE_MS) {
|
|
28792
|
+
let goalTurnId = null;
|
|
28793
|
+
const capturedCompletions = [];
|
|
28794
|
+
let resolveGoalTurnCompleted = () => {
|
|
28795
|
+
};
|
|
28796
|
+
const goalTurnCompleted = new Promise((resolve) => {
|
|
28797
|
+
resolveGoalTurnCompleted = resolve;
|
|
28798
|
+
});
|
|
28799
|
+
const releaseCompletionCapture = this.captureTurnCompletions(params.threadId, (event) => {
|
|
28800
|
+
capturedCompletions.push(event);
|
|
28801
|
+
if (goalTurnId === event.turn.id) {
|
|
28802
|
+
resolveGoalTurnCompleted(event);
|
|
28803
|
+
}
|
|
28804
|
+
});
|
|
28805
|
+
let resolveGoalTurnStarted = () => {
|
|
28806
|
+
};
|
|
28807
|
+
const goalTurnStarted = new Promise((resolve) => {
|
|
28808
|
+
resolveGoalTurnStarted = resolve;
|
|
28809
|
+
});
|
|
28810
|
+
let resolveGoalUpdateHandled = () => {
|
|
28811
|
+
};
|
|
28812
|
+
const matchingGoalUpdateHandled = new Promise((resolve) => {
|
|
28813
|
+
resolveGoalUpdateHandled = () => resolve(null);
|
|
28814
|
+
});
|
|
28815
|
+
let goalUpdateHandled = false;
|
|
28816
|
+
let expectedGoal = null;
|
|
28817
|
+
const noGoalTurnStarted = this.createNoGoalTurnStartedPromise(runtimeEffectsGraceMs);
|
|
28818
|
+
const capturedGoalUpdates = [];
|
|
28819
|
+
const releaseRoutingCapture = this.captureTurnRoutings(params.threadId, (turnId) => {
|
|
28820
|
+
if (!goalUpdateHandled || goalTurnId !== null) {
|
|
28821
|
+
return;
|
|
28822
|
+
}
|
|
28823
|
+
goalTurnId = turnId;
|
|
28824
|
+
onTurnStarted?.(turnId);
|
|
28825
|
+
resolveGoalTurnStarted(turnId);
|
|
28826
|
+
});
|
|
28827
|
+
const releaseGoalUpdateCapture = this.captureThreadGoalUpdates(params.threadId, (event) => {
|
|
28828
|
+
capturedGoalUpdates.push(event);
|
|
28829
|
+
if (expectedGoal !== null && goalsMatch(event.goal, expectedGoal)) {
|
|
28830
|
+
goalUpdateHandled = true;
|
|
28831
|
+
resolveGoalUpdateHandled();
|
|
28832
|
+
noGoalTurnStarted.goalUpdated();
|
|
28833
|
+
}
|
|
28834
|
+
});
|
|
28835
|
+
const releaseStatusCapture = this.captureThreadStatuses(params.threadId, (status) => {
|
|
28836
|
+
if (!goalUpdateHandled || goalTurnId !== null) {
|
|
28837
|
+
return;
|
|
28838
|
+
}
|
|
28839
|
+
noGoalTurnStarted.threadStatusChanged(status);
|
|
28840
|
+
});
|
|
28841
|
+
try {
|
|
28842
|
+
const goalSetResponse = await this.threadGoalSet(params);
|
|
28843
|
+
expectedGoal = goalSetResponse.goal;
|
|
28844
|
+
if (capturedGoalUpdates.some((event) => goalsMatch(event.goal, expectedGoal))) {
|
|
28845
|
+
goalUpdateHandled = true;
|
|
28846
|
+
resolveGoalUpdateHandled();
|
|
28847
|
+
noGoalTurnStarted.goalUpdated();
|
|
28848
|
+
}
|
|
28849
|
+
if (expectedGoal.status !== "active") {
|
|
28850
|
+
await matchingGoalUpdateHandled;
|
|
28851
|
+
return null;
|
|
28852
|
+
}
|
|
28853
|
+
const turnId = goalTurnId ?? await Promise.race([goalTurnStarted, noGoalTurnStarted.promise]);
|
|
28854
|
+
noGoalTurnStarted.release();
|
|
28855
|
+
releaseRoutingCapture();
|
|
28856
|
+
releaseStatusCapture();
|
|
28857
|
+
releaseGoalUpdateCapture();
|
|
28858
|
+
if (turnId === null) {
|
|
28859
|
+
return null;
|
|
28860
|
+
}
|
|
28861
|
+
const earlyCompletion = capturedCompletions.find((event) => event.turn.id === turnId);
|
|
28862
|
+
if (earlyCompletion) {
|
|
28863
|
+
return earlyCompletion;
|
|
28864
|
+
}
|
|
28865
|
+
return await goalTurnCompleted;
|
|
28866
|
+
} finally {
|
|
28867
|
+
noGoalTurnStarted.release();
|
|
28868
|
+
releaseCompletionCapture();
|
|
28869
|
+
releaseRoutingCapture();
|
|
28870
|
+
releaseStatusCapture();
|
|
28871
|
+
releaseGoalUpdateCapture();
|
|
28872
|
+
}
|
|
28873
|
+
}
|
|
28874
|
+
async runGoalClear(params) {
|
|
28875
|
+
let goalClearedHandled = false;
|
|
28876
|
+
let resolveGoalClearedHandled = () => {
|
|
28877
|
+
};
|
|
28878
|
+
const matchingGoalClearedHandled = new Promise((resolve) => {
|
|
28879
|
+
resolveGoalClearedHandled = () => resolve();
|
|
28880
|
+
});
|
|
28881
|
+
const releaseGoalClearedCapture = this.captureThreadGoalClears(params.threadId, () => {
|
|
28882
|
+
goalClearedHandled = true;
|
|
28883
|
+
resolveGoalClearedHandled();
|
|
28884
|
+
});
|
|
28885
|
+
try {
|
|
28886
|
+
const response = await this.threadGoalClear(params);
|
|
28887
|
+
if (!response.cleared || goalClearedHandled) {
|
|
28888
|
+
return;
|
|
28889
|
+
}
|
|
28890
|
+
await matchingGoalClearedHandled;
|
|
28891
|
+
} finally {
|
|
28892
|
+
releaseGoalClearedCapture();
|
|
28893
|
+
}
|
|
28894
|
+
}
|
|
28895
|
+
createNoGoalTurnStartedPromise(runtimeEffectsGraceMs) {
|
|
28896
|
+
let released = false;
|
|
28897
|
+
let resolved = false;
|
|
28898
|
+
let goalUpdated = false;
|
|
28899
|
+
let activeAfterGoalUpdate = false;
|
|
28900
|
+
let timeout = null;
|
|
28901
|
+
let resolveNoGoalTurnStarted = () => {
|
|
28902
|
+
};
|
|
28903
|
+
const clearTimer = () => {
|
|
28904
|
+
if (timeout !== null) {
|
|
28905
|
+
clearTimeout(timeout);
|
|
28906
|
+
timeout = null;
|
|
28907
|
+
}
|
|
28908
|
+
};
|
|
28909
|
+
const resolveNoTurn = () => {
|
|
28910
|
+
if (released || resolved) {
|
|
28911
|
+
return;
|
|
28912
|
+
}
|
|
28913
|
+
resolved = true;
|
|
28914
|
+
clearTimer();
|
|
28915
|
+
resolveNoGoalTurnStarted();
|
|
28916
|
+
};
|
|
28917
|
+
const scheduleNoTurnTimer = () => {
|
|
28918
|
+
if (released || resolved || !goalUpdated || activeAfterGoalUpdate || timeout !== null) {
|
|
28919
|
+
return;
|
|
28920
|
+
}
|
|
28921
|
+
timeout = setTimeout(resolveNoTurn, runtimeEffectsGraceMs);
|
|
28922
|
+
};
|
|
28923
|
+
const release = () => {
|
|
28924
|
+
if (released) {
|
|
28925
|
+
return;
|
|
28926
|
+
}
|
|
28927
|
+
released = true;
|
|
28928
|
+
clearTimer();
|
|
28929
|
+
};
|
|
28930
|
+
const promise2 = new Promise((resolve) => {
|
|
28931
|
+
resolveNoGoalTurnStarted = () => {
|
|
28932
|
+
resolve(null);
|
|
28933
|
+
};
|
|
28934
|
+
});
|
|
28935
|
+
const handleGoalUpdated = () => {
|
|
28936
|
+
goalUpdated = true;
|
|
28937
|
+
scheduleNoTurnTimer();
|
|
28938
|
+
};
|
|
28939
|
+
const handleThreadStatusChanged = (status) => {
|
|
28940
|
+
if (!goalUpdated || released || resolved) {
|
|
28941
|
+
return;
|
|
28942
|
+
}
|
|
28943
|
+
if (status.type === "active") {
|
|
28944
|
+
activeAfterGoalUpdate = true;
|
|
28945
|
+
clearTimer();
|
|
28946
|
+
return;
|
|
28947
|
+
}
|
|
28948
|
+
if (activeAfterGoalUpdate) {
|
|
28949
|
+
resolveNoTurn();
|
|
28950
|
+
}
|
|
28951
|
+
};
|
|
28952
|
+
return {
|
|
28953
|
+
promise: promise2,
|
|
28954
|
+
release,
|
|
28955
|
+
goalUpdated: handleGoalUpdated,
|
|
28956
|
+
threadStatusChanged: handleThreadStatusChanged
|
|
28957
|
+
};
|
|
28958
|
+
}
|
|
27977
28959
|
async runCompact(params) {
|
|
27978
28960
|
const compactionCompleted = this.awaitCompactionCompleted(params.threadId);
|
|
27979
28961
|
await this.threadCompactStart(params);
|
|
@@ -28014,6 +28996,12 @@ var CodexAppServerClient = class {
|
|
|
28014
28996
|
async threadCompactStart(params) {
|
|
28015
28997
|
return await this.sendRequest({ method: "thread/compact/start", params });
|
|
28016
28998
|
}
|
|
28999
|
+
async threadGoalSet(params) {
|
|
29000
|
+
return await this.sendRequest({ method: "thread/goal/set", params });
|
|
29001
|
+
}
|
|
29002
|
+
async threadGoalClear(params) {
|
|
29003
|
+
return await this.sendRequest({ method: "thread/goal/clear", params });
|
|
29004
|
+
}
|
|
28017
29005
|
async listMcpServerStatus(params) {
|
|
28018
29006
|
return await this.sendRequest({ method: "mcpServerStatus/list", params });
|
|
28019
29007
|
}
|
|
@@ -28145,6 +29133,57 @@ var CodexAppServerClient = class {
|
|
|
28145
29133
|
resolve(event);
|
|
28146
29134
|
}
|
|
28147
29135
|
}
|
|
29136
|
+
recordThreadStatusChanged(event) {
|
|
29137
|
+
const captures = this.threadStatusCaptures.get(event.threadId);
|
|
29138
|
+
if (!captures) {
|
|
29139
|
+
return;
|
|
29140
|
+
}
|
|
29141
|
+
for (const capture of captures) {
|
|
29142
|
+
capture(event.status);
|
|
29143
|
+
}
|
|
29144
|
+
}
|
|
29145
|
+
recordThreadGoalUpdated(event) {
|
|
29146
|
+
const captures = this.threadGoalUpdateCaptures.get(event.threadId);
|
|
29147
|
+
if (!captures) {
|
|
29148
|
+
return;
|
|
29149
|
+
}
|
|
29150
|
+
for (const capture of captures) {
|
|
29151
|
+
capture(event);
|
|
29152
|
+
}
|
|
29153
|
+
}
|
|
29154
|
+
recordThreadGoalCleared(event) {
|
|
29155
|
+
const captures = this.threadGoalClearedCaptures.get(event.threadId);
|
|
29156
|
+
if (!captures) {
|
|
29157
|
+
return;
|
|
29158
|
+
}
|
|
29159
|
+
for (const capture of captures) {
|
|
29160
|
+
capture();
|
|
29161
|
+
}
|
|
29162
|
+
}
|
|
29163
|
+
recordTurnRouting(routing) {
|
|
29164
|
+
if (routing.threadId === null || routing.turnId === null) {
|
|
29165
|
+
return;
|
|
29166
|
+
}
|
|
29167
|
+
const captures = this.turnRoutingCaptures.get(routing.threadId);
|
|
29168
|
+
if (!captures) {
|
|
29169
|
+
return;
|
|
29170
|
+
}
|
|
29171
|
+
for (const capture of captures) {
|
|
29172
|
+
capture(routing.turnId);
|
|
29173
|
+
}
|
|
29174
|
+
}
|
|
29175
|
+
handleStaleTurnNotification(notification, routing) {
|
|
29176
|
+
if (!this.isStaleTurn(routing.threadId, routing.turnId)) {
|
|
29177
|
+
return false;
|
|
29178
|
+
}
|
|
29179
|
+
if (isTurnCompletedNotification(notification) && routing.threadId !== null && routing.turnId !== null) {
|
|
29180
|
+
this.clearStaleTurn(routing.threadId, routing.turnId);
|
|
29181
|
+
}
|
|
29182
|
+
for (const callback of this.codexEventHandlers) {
|
|
29183
|
+
callback({ eventType: "notification", ...notification });
|
|
29184
|
+
}
|
|
29185
|
+
return true;
|
|
29186
|
+
}
|
|
28148
29187
|
isStaleTurn(threadId, turnId) {
|
|
28149
29188
|
if (threadId === null || turnId === null) {
|
|
28150
29189
|
return false;
|
|
@@ -28186,6 +29225,70 @@ var CodexAppServerClient = class {
|
|
|
28186
29225
|
}
|
|
28187
29226
|
};
|
|
28188
29227
|
}
|
|
29228
|
+
captureTurnRoutings(threadId, capture) {
|
|
29229
|
+
const captures = this.turnRoutingCaptures.get(threadId) ?? /* @__PURE__ */ new Set();
|
|
29230
|
+
captures.add(capture);
|
|
29231
|
+
this.turnRoutingCaptures.set(threadId, captures);
|
|
29232
|
+
let released = false;
|
|
29233
|
+
return () => {
|
|
29234
|
+
if (released) {
|
|
29235
|
+
return;
|
|
29236
|
+
}
|
|
29237
|
+
released = true;
|
|
29238
|
+
captures.delete(capture);
|
|
29239
|
+
if (captures.size === 0) {
|
|
29240
|
+
this.turnRoutingCaptures.delete(threadId);
|
|
29241
|
+
}
|
|
29242
|
+
};
|
|
29243
|
+
}
|
|
29244
|
+
captureThreadStatuses(threadId, capture) {
|
|
29245
|
+
const captures = this.threadStatusCaptures.get(threadId) ?? /* @__PURE__ */ new Set();
|
|
29246
|
+
captures.add(capture);
|
|
29247
|
+
this.threadStatusCaptures.set(threadId, captures);
|
|
29248
|
+
let released = false;
|
|
29249
|
+
return () => {
|
|
29250
|
+
if (released) {
|
|
29251
|
+
return;
|
|
29252
|
+
}
|
|
29253
|
+
released = true;
|
|
29254
|
+
captures.delete(capture);
|
|
29255
|
+
if (captures.size === 0) {
|
|
29256
|
+
this.threadStatusCaptures.delete(threadId);
|
|
29257
|
+
}
|
|
29258
|
+
};
|
|
29259
|
+
}
|
|
29260
|
+
captureThreadGoalUpdates(threadId, capture) {
|
|
29261
|
+
const captures = this.threadGoalUpdateCaptures.get(threadId) ?? /* @__PURE__ */ new Set();
|
|
29262
|
+
captures.add(capture);
|
|
29263
|
+
this.threadGoalUpdateCaptures.set(threadId, captures);
|
|
29264
|
+
let released = false;
|
|
29265
|
+
return () => {
|
|
29266
|
+
if (released) {
|
|
29267
|
+
return;
|
|
29268
|
+
}
|
|
29269
|
+
released = true;
|
|
29270
|
+
captures.delete(capture);
|
|
29271
|
+
if (captures.size === 0) {
|
|
29272
|
+
this.threadGoalUpdateCaptures.delete(threadId);
|
|
29273
|
+
}
|
|
29274
|
+
};
|
|
29275
|
+
}
|
|
29276
|
+
captureThreadGoalClears(threadId, capture) {
|
|
29277
|
+
const captures = this.threadGoalClearedCaptures.get(threadId) ?? /* @__PURE__ */ new Set();
|
|
29278
|
+
captures.add(capture);
|
|
29279
|
+
this.threadGoalClearedCaptures.set(threadId, captures);
|
|
29280
|
+
let released = false;
|
|
29281
|
+
return () => {
|
|
29282
|
+
if (released) {
|
|
29283
|
+
return;
|
|
29284
|
+
}
|
|
29285
|
+
released = true;
|
|
29286
|
+
captures.delete(capture);
|
|
29287
|
+
if (captures.size === 0) {
|
|
29288
|
+
this.threadGoalClearedCaptures.delete(threadId);
|
|
29289
|
+
}
|
|
29290
|
+
};
|
|
29291
|
+
}
|
|
28189
29292
|
resolveMcpServerStartupResolvers() {
|
|
28190
29293
|
const pendingResolvers = [];
|
|
28191
29294
|
for (const resolver of this.mcpServerStartupResolvers) {
|
|
@@ -28248,12 +29351,24 @@ function isMcpServerStatusUpdatedNotification(notification) {
|
|
|
28248
29351
|
function isTurnCompletedNotification(notification) {
|
|
28249
29352
|
return notification.method === "turn/completed";
|
|
28250
29353
|
}
|
|
29354
|
+
function isThreadStatusChangedNotification(notification) {
|
|
29355
|
+
return notification.method === "thread/status/changed";
|
|
29356
|
+
}
|
|
29357
|
+
function isThreadGoalUpdatedNotification(notification) {
|
|
29358
|
+
return notification.method === "thread/goal/updated";
|
|
29359
|
+
}
|
|
29360
|
+
function isThreadGoalClearedNotification(notification) {
|
|
29361
|
+
return notification.method === "thread/goal/cleared";
|
|
29362
|
+
}
|
|
28251
29363
|
function isCompactionCompletedNotification(notification) {
|
|
28252
29364
|
if (notification.method === "thread/compacted") {
|
|
28253
29365
|
return true;
|
|
28254
29366
|
}
|
|
28255
29367
|
return notification.method === "item/completed" && notification.params.item.type === "contextCompaction";
|
|
28256
29368
|
}
|
|
29369
|
+
function goalsMatch(left, right) {
|
|
29370
|
+
return left.threadId === right.threadId && left.objective === right.objective && left.status === right.status && left.tokenBudget === right.tokenBudget && left.updatedAt === right.updatedAt;
|
|
29371
|
+
}
|
|
28257
29372
|
function extractThreadId(notification) {
|
|
28258
29373
|
const params = notification.params;
|
|
28259
29374
|
if (params && typeof params.threadId === "string") {
|