Upload 6 files
Browse files- src/message.js +54 -57
src/message.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
| 1 |
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
|
| 2 |
'use strict';
|
| 3 |
|
| 4 |
-
|
| 5 |
|
| 6 |
// Common aliases
|
| 7 |
-
|
| 8 |
$Writer = $protobuf.Writer,
|
| 9 |
$util = $protobuf.util;
|
| 10 |
|
| 11 |
// Exported root namespace
|
| 12 |
-
|
| 13 |
|
| 14 |
$root.ChatMessage = (function () {
|
| 15 |
/**
|
|
@@ -35,7 +35,7 @@ $root.ChatMessage = (function () {
|
|
| 35 |
*/
|
| 36 |
function ChatMessage(properties) {
|
| 37 |
this.messages = [];
|
| 38 |
-
if (properties)
|
| 39 |
}
|
| 40 |
|
| 41 |
/**
|
|
@@ -118,7 +118,7 @@ $root.ChatMessage = (function () {
|
|
| 118 |
ChatMessage.encode = function encode(message, writer) {
|
| 119 |
if (!writer) writer = $Writer.create();
|
| 120 |
if (message.messages != null && message.messages.length)
|
| 121 |
-
for (
|
| 122 |
if (message.instructions != null && Object.hasOwnProperty.call(message, 'instructions'))
|
| 123 |
$root.ChatMessage.Instructions.encode(message.instructions, writer.uint32(/* id 4, wireType 2 =*/ 34).fork()).ldelim();
|
| 124 |
if (message.projectPath != null && Object.hasOwnProperty.call(message, 'projectPath')) writer.uint32(/* id 5, wireType 2 =*/ 42).string(message.projectPath);
|
|
@@ -156,10 +156,10 @@ $root.ChatMessage = (function () {
|
|
| 156 |
*/
|
| 157 |
ChatMessage.decode = function decode(reader, length) {
|
| 158 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 159 |
-
|
| 160 |
message = new $root.ChatMessage();
|
| 161 |
while (reader.pos < end) {
|
| 162 |
-
|
| 163 |
switch (tag >>> 3) {
|
| 164 |
case 2: {
|
| 165 |
if (!(message.messages && message.messages.length)) message.messages = [];
|
|
@@ -222,22 +222,21 @@ $root.ChatMessage = (function () {
|
|
| 222 |
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
| 223 |
*/
|
| 224 |
ChatMessage.verify = function verify(message) {
|
| 225 |
-
let error;
|
| 226 |
if (typeof message !== 'object' || message === null) return 'object expected';
|
| 227 |
if (message.messages != null && message.hasOwnProperty('messages')) {
|
| 228 |
if (!Array.isArray(message.messages)) return 'messages: array expected';
|
| 229 |
-
for (
|
| 230 |
-
error = $root.ChatMessage.UserMessage.verify(message.messages[i]);
|
| 231 |
if (error) return 'messages.' + error;
|
| 232 |
}
|
| 233 |
}
|
| 234 |
if (message.instructions != null && message.hasOwnProperty('instructions')) {
|
| 235 |
-
error = $root.ChatMessage.Instructions.verify(message.instructions);
|
| 236 |
if (error) return 'instructions.' + error;
|
| 237 |
}
|
| 238 |
if (message.projectPath != null && message.hasOwnProperty('projectPath')) if (!$util.isString(message.projectPath)) return 'projectPath: string expected';
|
| 239 |
if (message.model != null && message.hasOwnProperty('model')) {
|
| 240 |
-
error = $root.ChatMessage.Model.verify(message.model);
|
| 241 |
if (error) return 'model.' + error;
|
| 242 |
}
|
| 243 |
if (message.requestId != null && message.hasOwnProperty('requestId')) if (!$util.isString(message.requestId)) return 'requestId: string expected';
|
|
@@ -256,11 +255,11 @@ $root.ChatMessage = (function () {
|
|
| 256 |
*/
|
| 257 |
ChatMessage.fromObject = function fromObject(object) {
|
| 258 |
if (object instanceof $root.ChatMessage) return object;
|
| 259 |
-
|
| 260 |
if (object.messages) {
|
| 261 |
if (!Array.isArray(object.messages)) throw TypeError('.ChatMessage.messages: array expected');
|
| 262 |
message.messages = [];
|
| 263 |
-
for (
|
| 264 |
if (typeof object.messages[i] !== 'object') throw TypeError('.ChatMessage.messages: object expected');
|
| 265 |
message.messages[i] = $root.ChatMessage.UserMessage.fromObject(object.messages[i]);
|
| 266 |
}
|
|
@@ -291,7 +290,7 @@ $root.ChatMessage = (function () {
|
|
| 291 |
*/
|
| 292 |
ChatMessage.toObject = function toObject(message, options) {
|
| 293 |
if (!options) options = {};
|
| 294 |
-
|
| 295 |
if (options.arrays || options.defaults) object.messages = [];
|
| 296 |
if (options.defaults) {
|
| 297 |
object.instructions = null;
|
|
@@ -303,7 +302,7 @@ $root.ChatMessage = (function () {
|
|
| 303 |
}
|
| 304 |
if (message.messages && message.messages.length) {
|
| 305 |
object.messages = [];
|
| 306 |
-
for (
|
| 307 |
}
|
| 308 |
if (message.instructions != null && message.hasOwnProperty('instructions')) object.instructions = $root.ChatMessage.Instructions.toObject(message.instructions, options);
|
| 309 |
if (message.projectPath != null && message.hasOwnProperty('projectPath')) object.projectPath = message.projectPath;
|
|
@@ -364,7 +363,7 @@ $root.ChatMessage = (function () {
|
|
| 364 |
* @param {ChatMessage.IFileContent=} [properties] Properties to set
|
| 365 |
*/
|
| 366 |
function FileContent(properties) {
|
| 367 |
-
if (properties)
|
| 368 |
}
|
| 369 |
|
| 370 |
/**
|
|
@@ -493,10 +492,10 @@ $root.ChatMessage = (function () {
|
|
| 493 |
*/
|
| 494 |
FileContent.decode = function decode(reader, length) {
|
| 495 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 496 |
-
|
| 497 |
message = new $root.ChatMessage.FileContent();
|
| 498 |
while (reader.pos < end) {
|
| 499 |
-
|
| 500 |
switch (tag >>> 3) {
|
| 501 |
case 1: {
|
| 502 |
message.filename = reader.string();
|
|
@@ -562,17 +561,16 @@ $root.ChatMessage = (function () {
|
|
| 562 |
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
| 563 |
*/
|
| 564 |
FileContent.verify = function verify(message) {
|
| 565 |
-
let error;
|
| 566 |
if (typeof message !== 'object' || message === null) return 'object expected';
|
| 567 |
if (message.filename != null && message.hasOwnProperty('filename')) if (!$util.isString(message.filename)) return 'filename: string expected';
|
| 568 |
if (message.content != null && message.hasOwnProperty('content')) if (!$util.isString(message.content)) return 'content: string expected';
|
| 569 |
if (message.position != null && message.hasOwnProperty('position')) {
|
| 570 |
-
error = $root.ChatMessage.FileContent.Position.verify(message.position);
|
| 571 |
if (error) return 'position.' + error;
|
| 572 |
}
|
| 573 |
if (message.language != null && message.hasOwnProperty('language')) if (!$util.isString(message.language)) return 'language: string expected';
|
| 574 |
if (message.range != null && message.hasOwnProperty('range')) {
|
| 575 |
-
error = $root.ChatMessage.FileContent.Range.verify(message.range);
|
| 576 |
if (error) return 'range.' + error;
|
| 577 |
}
|
| 578 |
if (message.length != null && message.hasOwnProperty('length')) if (!$util.isInteger(message.length)) return 'length: integer expected';
|
|
@@ -591,7 +589,7 @@ $root.ChatMessage = (function () {
|
|
| 591 |
*/
|
| 592 |
FileContent.fromObject = function fromObject(object) {
|
| 593 |
if (object instanceof $root.ChatMessage.FileContent) return object;
|
| 594 |
-
|
| 595 |
if (object.filename != null) message.filename = String(object.filename);
|
| 596 |
if (object.content != null) message.content = String(object.content);
|
| 597 |
if (object.position != null) {
|
|
@@ -620,7 +618,7 @@ $root.ChatMessage = (function () {
|
|
| 620 |
*/
|
| 621 |
FileContent.toObject = function toObject(message, options) {
|
| 622 |
if (!options) options = {};
|
| 623 |
-
|
| 624 |
if (options.defaults) {
|
| 625 |
object.filename = '';
|
| 626 |
object.content = '';
|
|
@@ -686,7 +684,7 @@ $root.ChatMessage = (function () {
|
|
| 686 |
* @param {ChatMessage.FileContent.IPosition=} [properties] Properties to set
|
| 687 |
*/
|
| 688 |
function Position(properties) {
|
| 689 |
-
if (properties)
|
| 690 |
}
|
| 691 |
|
| 692 |
/**
|
|
@@ -759,10 +757,10 @@ $root.ChatMessage = (function () {
|
|
| 759 |
*/
|
| 760 |
Position.decode = function decode(reader, length) {
|
| 761 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 762 |
-
|
| 763 |
message = new $root.ChatMessage.FileContent.Position();
|
| 764 |
while (reader.pos < end) {
|
| 765 |
-
|
| 766 |
switch (tag >>> 3) {
|
| 767 |
case 1: {
|
| 768 |
message.line = reader.int32();
|
|
@@ -820,7 +818,7 @@ $root.ChatMessage = (function () {
|
|
| 820 |
*/
|
| 821 |
Position.fromObject = function fromObject(object) {
|
| 822 |
if (object instanceof $root.ChatMessage.FileContent.Position) return object;
|
| 823 |
-
|
| 824 |
if (object.line != null) message.line = object.line | 0;
|
| 825 |
if (object.column != null) message.column = object.column | 0;
|
| 826 |
return message;
|
|
@@ -837,7 +835,7 @@ $root.ChatMessage = (function () {
|
|
| 837 |
*/
|
| 838 |
Position.toObject = function toObject(message, options) {
|
| 839 |
if (!options) options = {};
|
| 840 |
-
|
| 841 |
if (options.defaults) {
|
| 842 |
object.line = 0;
|
| 843 |
object.column = 0;
|
|
@@ -894,7 +892,7 @@ $root.ChatMessage = (function () {
|
|
| 894 |
* @param {ChatMessage.FileContent.IRange=} [properties] Properties to set
|
| 895 |
*/
|
| 896 |
function Range(properties) {
|
| 897 |
-
if (properties)
|
| 898 |
}
|
| 899 |
|
| 900 |
/**
|
|
@@ -969,10 +967,10 @@ $root.ChatMessage = (function () {
|
|
| 969 |
*/
|
| 970 |
Range.decode = function decode(reader, length) {
|
| 971 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 972 |
-
|
| 973 |
message = new $root.ChatMessage.FileContent.Range();
|
| 974 |
while (reader.pos < end) {
|
| 975 |
-
|
| 976 |
switch (tag >>> 3) {
|
| 977 |
case 1: {
|
| 978 |
message.start = $root.ChatMessage.FileContent.Position.decode(reader, reader.uint32());
|
|
@@ -1014,14 +1012,13 @@ $root.ChatMessage = (function () {
|
|
| 1014 |
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
| 1015 |
*/
|
| 1016 |
Range.verify = function verify(message) {
|
| 1017 |
-
let error;
|
| 1018 |
if (typeof message !== 'object' || message === null) return 'object expected';
|
| 1019 |
if (message.start != null && message.hasOwnProperty('start')) {
|
| 1020 |
-
error = $root.ChatMessage.FileContent.Position.verify(message.start);
|
| 1021 |
if (error) return 'start.' + error;
|
| 1022 |
}
|
| 1023 |
if (message.end != null && message.hasOwnProperty('end')) {
|
| 1024 |
-
error = $root.ChatMessage.FileContent.Position.verify(message.end);
|
| 1025 |
if (error) return 'end.' + error;
|
| 1026 |
}
|
| 1027 |
return null;
|
|
@@ -1037,7 +1034,7 @@ $root.ChatMessage = (function () {
|
|
| 1037 |
*/
|
| 1038 |
Range.fromObject = function fromObject(object) {
|
| 1039 |
if (object instanceof $root.ChatMessage.FileContent.Range) return object;
|
| 1040 |
-
|
| 1041 |
if (object.start != null) {
|
| 1042 |
if (typeof object.start !== 'object') throw TypeError('.ChatMessage.FileContent.Range.start: object expected');
|
| 1043 |
message.start = $root.ChatMessage.FileContent.Position.fromObject(object.start);
|
|
@@ -1060,7 +1057,7 @@ $root.ChatMessage = (function () {
|
|
| 1060 |
*/
|
| 1061 |
Range.toObject = function toObject(message, options) {
|
| 1062 |
if (!options) options = {};
|
| 1063 |
-
|
| 1064 |
if (options.defaults) {
|
| 1065 |
object.start = null;
|
| 1066 |
object.end = null;
|
|
@@ -1121,7 +1118,7 @@ $root.ChatMessage = (function () {
|
|
| 1121 |
* @param {ChatMessage.IUserMessage=} [properties] Properties to set
|
| 1122 |
*/
|
| 1123 |
function UserMessage(properties) {
|
| 1124 |
-
if (properties)
|
| 1125 |
}
|
| 1126 |
|
| 1127 |
/**
|
|
@@ -1203,10 +1200,10 @@ $root.ChatMessage = (function () {
|
|
| 1203 |
*/
|
| 1204 |
UserMessage.decode = function decode(reader, length) {
|
| 1205 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 1206 |
-
|
| 1207 |
message = new $root.ChatMessage.UserMessage();
|
| 1208 |
while (reader.pos < end) {
|
| 1209 |
-
|
| 1210 |
switch (tag >>> 3) {
|
| 1211 |
case 1: {
|
| 1212 |
message.content = reader.string();
|
|
@@ -1269,7 +1266,7 @@ $root.ChatMessage = (function () {
|
|
| 1269 |
*/
|
| 1270 |
UserMessage.fromObject = function fromObject(object) {
|
| 1271 |
if (object instanceof $root.ChatMessage.UserMessage) return object;
|
| 1272 |
-
|
| 1273 |
if (object.content != null) message.content = String(object.content);
|
| 1274 |
if (object.role != null) message.role = object.role | 0;
|
| 1275 |
if (object.messageId != null) message.messageId = String(object.messageId);
|
|
@@ -1287,7 +1284,7 @@ $root.ChatMessage = (function () {
|
|
| 1287 |
*/
|
| 1288 |
UserMessage.toObject = function toObject(message, options) {
|
| 1289 |
if (!options) options = {};
|
| 1290 |
-
|
| 1291 |
if (options.defaults) {
|
| 1292 |
object.content = '';
|
| 1293 |
object.role = 0;
|
|
@@ -1345,7 +1342,7 @@ $root.ChatMessage = (function () {
|
|
| 1345 |
* @param {ChatMessage.IInstructions=} [properties] Properties to set
|
| 1346 |
*/
|
| 1347 |
function Instructions(properties) {
|
| 1348 |
-
if (properties)
|
| 1349 |
}
|
| 1350 |
|
| 1351 |
/**
|
|
@@ -1409,10 +1406,10 @@ $root.ChatMessage = (function () {
|
|
| 1409 |
*/
|
| 1410 |
Instructions.decode = function decode(reader, length) {
|
| 1411 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 1412 |
-
|
| 1413 |
message = new $root.ChatMessage.Instructions();
|
| 1414 |
while (reader.pos < end) {
|
| 1415 |
-
|
| 1416 |
switch (tag >>> 3) {
|
| 1417 |
case 1: {
|
| 1418 |
message.instruction = reader.string();
|
|
@@ -1465,7 +1462,7 @@ $root.ChatMessage = (function () {
|
|
| 1465 |
*/
|
| 1466 |
Instructions.fromObject = function fromObject(object) {
|
| 1467 |
if (object instanceof $root.ChatMessage.Instructions) return object;
|
| 1468 |
-
|
| 1469 |
if (object.instruction != null) message.instruction = String(object.instruction);
|
| 1470 |
return message;
|
| 1471 |
};
|
|
@@ -1481,7 +1478,7 @@ $root.ChatMessage = (function () {
|
|
| 1481 |
*/
|
| 1482 |
Instructions.toObject = function toObject(message, options) {
|
| 1483 |
if (!options) options = {};
|
| 1484 |
-
|
| 1485 |
if (options.defaults) object.instruction = '';
|
| 1486 |
if (message.instruction != null && message.hasOwnProperty('instruction')) object.instruction = message.instruction;
|
| 1487 |
return object;
|
|
@@ -1534,7 +1531,7 @@ $root.ChatMessage = (function () {
|
|
| 1534 |
* @param {ChatMessage.IModel=} [properties] Properties to set
|
| 1535 |
*/
|
| 1536 |
function Model(properties) {
|
| 1537 |
-
if (properties)
|
| 1538 |
}
|
| 1539 |
|
| 1540 |
/**
|
|
@@ -1607,10 +1604,10 @@ $root.ChatMessage = (function () {
|
|
| 1607 |
*/
|
| 1608 |
Model.decode = function decode(reader, length) {
|
| 1609 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 1610 |
-
|
| 1611 |
message = new $root.ChatMessage.Model();
|
| 1612 |
while (reader.pos < end) {
|
| 1613 |
-
|
| 1614 |
switch (tag >>> 3) {
|
| 1615 |
case 1: {
|
| 1616 |
message.name = reader.string();
|
|
@@ -1668,7 +1665,7 @@ $root.ChatMessage = (function () {
|
|
| 1668 |
*/
|
| 1669 |
Model.fromObject = function fromObject(object) {
|
| 1670 |
if (object instanceof $root.ChatMessage.Model) return object;
|
| 1671 |
-
|
| 1672 |
if (object.name != null) message.name = String(object.name);
|
| 1673 |
if (object.empty != null) message.empty = String(object.empty);
|
| 1674 |
return message;
|
|
@@ -1685,7 +1682,7 @@ $root.ChatMessage = (function () {
|
|
| 1685 |
*/
|
| 1686 |
Model.toObject = function toObject(message, options) {
|
| 1687 |
if (!options) options = {};
|
| 1688 |
-
|
| 1689 |
if (options.defaults) {
|
| 1690 |
object.name = '';
|
| 1691 |
object.empty = '';
|
|
@@ -1744,7 +1741,7 @@ $root.ResMessage = (function () {
|
|
| 1744 |
* @param {IResMessage=} [properties] Properties to set
|
| 1745 |
*/
|
| 1746 |
function ResMessage(properties) {
|
| 1747 |
-
if (properties)
|
| 1748 |
}
|
| 1749 |
|
| 1750 |
/**
|
|
@@ -1808,10 +1805,10 @@ $root.ResMessage = (function () {
|
|
| 1808 |
*/
|
| 1809 |
ResMessage.decode = function decode(reader, length) {
|
| 1810 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 1811 |
-
|
| 1812 |
message = new $root.ResMessage();
|
| 1813 |
while (reader.pos < end) {
|
| 1814 |
-
|
| 1815 |
switch (tag >>> 3) {
|
| 1816 |
case 1: {
|
| 1817 |
message.msg = reader.string();
|
|
@@ -1864,7 +1861,7 @@ $root.ResMessage = (function () {
|
|
| 1864 |
*/
|
| 1865 |
ResMessage.fromObject = function fromObject(object) {
|
| 1866 |
if (object instanceof $root.ResMessage) return object;
|
| 1867 |
-
|
| 1868 |
if (object.msg != null) message.msg = String(object.msg);
|
| 1869 |
return message;
|
| 1870 |
};
|
|
@@ -1880,7 +1877,7 @@ $root.ResMessage = (function () {
|
|
| 1880 |
*/
|
| 1881 |
ResMessage.toObject = function toObject(message, options) {
|
| 1882 |
if (!options) options = {};
|
| 1883 |
-
|
| 1884 |
if (options.defaults) object.msg = '';
|
| 1885 |
if (message.msg != null && message.hasOwnProperty('msg')) object.msg = message.msg;
|
| 1886 |
return object;
|
|
|
|
| 1 |
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
|
| 2 |
'use strict';
|
| 3 |
|
| 4 |
+
var $protobuf = require('protobufjs/minimal');
|
| 5 |
|
| 6 |
// Common aliases
|
| 7 |
+
var $Reader = $protobuf.Reader,
|
| 8 |
$Writer = $protobuf.Writer,
|
| 9 |
$util = $protobuf.util;
|
| 10 |
|
| 11 |
// Exported root namespace
|
| 12 |
+
var $root = $protobuf.roots['default'] || ($protobuf.roots['default'] = {});
|
| 13 |
|
| 14 |
$root.ChatMessage = (function () {
|
| 15 |
/**
|
|
|
|
| 35 |
*/
|
| 36 |
function ChatMessage(properties) {
|
| 37 |
this.messages = [];
|
| 38 |
+
if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]];
|
| 39 |
}
|
| 40 |
|
| 41 |
/**
|
|
|
|
| 118 |
ChatMessage.encode = function encode(message, writer) {
|
| 119 |
if (!writer) writer = $Writer.create();
|
| 120 |
if (message.messages != null && message.messages.length)
|
| 121 |
+
for (var i = 0; i < message.messages.length; ++i) $root.ChatMessage.UserMessage.encode(message.messages[i], writer.uint32(/* id 2, wireType 2 =*/ 18).fork()).ldelim();
|
| 122 |
if (message.instructions != null && Object.hasOwnProperty.call(message, 'instructions'))
|
| 123 |
$root.ChatMessage.Instructions.encode(message.instructions, writer.uint32(/* id 4, wireType 2 =*/ 34).fork()).ldelim();
|
| 124 |
if (message.projectPath != null && Object.hasOwnProperty.call(message, 'projectPath')) writer.uint32(/* id 5, wireType 2 =*/ 42).string(message.projectPath);
|
|
|
|
| 156 |
*/
|
| 157 |
ChatMessage.decode = function decode(reader, length) {
|
| 158 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 159 |
+
var end = length === undefined ? reader.len : reader.pos + length,
|
| 160 |
message = new $root.ChatMessage();
|
| 161 |
while (reader.pos < end) {
|
| 162 |
+
var tag = reader.uint32();
|
| 163 |
switch (tag >>> 3) {
|
| 164 |
case 2: {
|
| 165 |
if (!(message.messages && message.messages.length)) message.messages = [];
|
|
|
|
| 222 |
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
| 223 |
*/
|
| 224 |
ChatMessage.verify = function verify(message) {
|
|
|
|
| 225 |
if (typeof message !== 'object' || message === null) return 'object expected';
|
| 226 |
if (message.messages != null && message.hasOwnProperty('messages')) {
|
| 227 |
if (!Array.isArray(message.messages)) return 'messages: array expected';
|
| 228 |
+
for (var i = 0; i < message.messages.length; ++i) {
|
| 229 |
+
var error = $root.ChatMessage.UserMessage.verify(message.messages[i]);
|
| 230 |
if (error) return 'messages.' + error;
|
| 231 |
}
|
| 232 |
}
|
| 233 |
if (message.instructions != null && message.hasOwnProperty('instructions')) {
|
| 234 |
+
var error = $root.ChatMessage.Instructions.verify(message.instructions);
|
| 235 |
if (error) return 'instructions.' + error;
|
| 236 |
}
|
| 237 |
if (message.projectPath != null && message.hasOwnProperty('projectPath')) if (!$util.isString(message.projectPath)) return 'projectPath: string expected';
|
| 238 |
if (message.model != null && message.hasOwnProperty('model')) {
|
| 239 |
+
var error = $root.ChatMessage.Model.verify(message.model);
|
| 240 |
if (error) return 'model.' + error;
|
| 241 |
}
|
| 242 |
if (message.requestId != null && message.hasOwnProperty('requestId')) if (!$util.isString(message.requestId)) return 'requestId: string expected';
|
|
|
|
| 255 |
*/
|
| 256 |
ChatMessage.fromObject = function fromObject(object) {
|
| 257 |
if (object instanceof $root.ChatMessage) return object;
|
| 258 |
+
var message = new $root.ChatMessage();
|
| 259 |
if (object.messages) {
|
| 260 |
if (!Array.isArray(object.messages)) throw TypeError('.ChatMessage.messages: array expected');
|
| 261 |
message.messages = [];
|
| 262 |
+
for (var i = 0; i < object.messages.length; ++i) {
|
| 263 |
if (typeof object.messages[i] !== 'object') throw TypeError('.ChatMessage.messages: object expected');
|
| 264 |
message.messages[i] = $root.ChatMessage.UserMessage.fromObject(object.messages[i]);
|
| 265 |
}
|
|
|
|
| 290 |
*/
|
| 291 |
ChatMessage.toObject = function toObject(message, options) {
|
| 292 |
if (!options) options = {};
|
| 293 |
+
var object = {};
|
| 294 |
if (options.arrays || options.defaults) object.messages = [];
|
| 295 |
if (options.defaults) {
|
| 296 |
object.instructions = null;
|
|
|
|
| 302 |
}
|
| 303 |
if (message.messages && message.messages.length) {
|
| 304 |
object.messages = [];
|
| 305 |
+
for (var j = 0; j < message.messages.length; ++j) object.messages[j] = $root.ChatMessage.UserMessage.toObject(message.messages[j], options);
|
| 306 |
}
|
| 307 |
if (message.instructions != null && message.hasOwnProperty('instructions')) object.instructions = $root.ChatMessage.Instructions.toObject(message.instructions, options);
|
| 308 |
if (message.projectPath != null && message.hasOwnProperty('projectPath')) object.projectPath = message.projectPath;
|
|
|
|
| 363 |
* @param {ChatMessage.IFileContent=} [properties] Properties to set
|
| 364 |
*/
|
| 365 |
function FileContent(properties) {
|
| 366 |
+
if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]];
|
| 367 |
}
|
| 368 |
|
| 369 |
/**
|
|
|
|
| 492 |
*/
|
| 493 |
FileContent.decode = function decode(reader, length) {
|
| 494 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 495 |
+
var end = length === undefined ? reader.len : reader.pos + length,
|
| 496 |
message = new $root.ChatMessage.FileContent();
|
| 497 |
while (reader.pos < end) {
|
| 498 |
+
var tag = reader.uint32();
|
| 499 |
switch (tag >>> 3) {
|
| 500 |
case 1: {
|
| 501 |
message.filename = reader.string();
|
|
|
|
| 561 |
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
| 562 |
*/
|
| 563 |
FileContent.verify = function verify(message) {
|
|
|
|
| 564 |
if (typeof message !== 'object' || message === null) return 'object expected';
|
| 565 |
if (message.filename != null && message.hasOwnProperty('filename')) if (!$util.isString(message.filename)) return 'filename: string expected';
|
| 566 |
if (message.content != null && message.hasOwnProperty('content')) if (!$util.isString(message.content)) return 'content: string expected';
|
| 567 |
if (message.position != null && message.hasOwnProperty('position')) {
|
| 568 |
+
var error = $root.ChatMessage.FileContent.Position.verify(message.position);
|
| 569 |
if (error) return 'position.' + error;
|
| 570 |
}
|
| 571 |
if (message.language != null && message.hasOwnProperty('language')) if (!$util.isString(message.language)) return 'language: string expected';
|
| 572 |
if (message.range != null && message.hasOwnProperty('range')) {
|
| 573 |
+
var error = $root.ChatMessage.FileContent.Range.verify(message.range);
|
| 574 |
if (error) return 'range.' + error;
|
| 575 |
}
|
| 576 |
if (message.length != null && message.hasOwnProperty('length')) if (!$util.isInteger(message.length)) return 'length: integer expected';
|
|
|
|
| 589 |
*/
|
| 590 |
FileContent.fromObject = function fromObject(object) {
|
| 591 |
if (object instanceof $root.ChatMessage.FileContent) return object;
|
| 592 |
+
var message = new $root.ChatMessage.FileContent();
|
| 593 |
if (object.filename != null) message.filename = String(object.filename);
|
| 594 |
if (object.content != null) message.content = String(object.content);
|
| 595 |
if (object.position != null) {
|
|
|
|
| 618 |
*/
|
| 619 |
FileContent.toObject = function toObject(message, options) {
|
| 620 |
if (!options) options = {};
|
| 621 |
+
var object = {};
|
| 622 |
if (options.defaults) {
|
| 623 |
object.filename = '';
|
| 624 |
object.content = '';
|
|
|
|
| 684 |
* @param {ChatMessage.FileContent.IPosition=} [properties] Properties to set
|
| 685 |
*/
|
| 686 |
function Position(properties) {
|
| 687 |
+
if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]];
|
| 688 |
}
|
| 689 |
|
| 690 |
/**
|
|
|
|
| 757 |
*/
|
| 758 |
Position.decode = function decode(reader, length) {
|
| 759 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 760 |
+
var end = length === undefined ? reader.len : reader.pos + length,
|
| 761 |
message = new $root.ChatMessage.FileContent.Position();
|
| 762 |
while (reader.pos < end) {
|
| 763 |
+
var tag = reader.uint32();
|
| 764 |
switch (tag >>> 3) {
|
| 765 |
case 1: {
|
| 766 |
message.line = reader.int32();
|
|
|
|
| 818 |
*/
|
| 819 |
Position.fromObject = function fromObject(object) {
|
| 820 |
if (object instanceof $root.ChatMessage.FileContent.Position) return object;
|
| 821 |
+
var message = new $root.ChatMessage.FileContent.Position();
|
| 822 |
if (object.line != null) message.line = object.line | 0;
|
| 823 |
if (object.column != null) message.column = object.column | 0;
|
| 824 |
return message;
|
|
|
|
| 835 |
*/
|
| 836 |
Position.toObject = function toObject(message, options) {
|
| 837 |
if (!options) options = {};
|
| 838 |
+
var object = {};
|
| 839 |
if (options.defaults) {
|
| 840 |
object.line = 0;
|
| 841 |
object.column = 0;
|
|
|
|
| 892 |
* @param {ChatMessage.FileContent.IRange=} [properties] Properties to set
|
| 893 |
*/
|
| 894 |
function Range(properties) {
|
| 895 |
+
if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]];
|
| 896 |
}
|
| 897 |
|
| 898 |
/**
|
|
|
|
| 967 |
*/
|
| 968 |
Range.decode = function decode(reader, length) {
|
| 969 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 970 |
+
var end = length === undefined ? reader.len : reader.pos + length,
|
| 971 |
message = new $root.ChatMessage.FileContent.Range();
|
| 972 |
while (reader.pos < end) {
|
| 973 |
+
var tag = reader.uint32();
|
| 974 |
switch (tag >>> 3) {
|
| 975 |
case 1: {
|
| 976 |
message.start = $root.ChatMessage.FileContent.Position.decode(reader, reader.uint32());
|
|
|
|
| 1012 |
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
| 1013 |
*/
|
| 1014 |
Range.verify = function verify(message) {
|
|
|
|
| 1015 |
if (typeof message !== 'object' || message === null) return 'object expected';
|
| 1016 |
if (message.start != null && message.hasOwnProperty('start')) {
|
| 1017 |
+
var error = $root.ChatMessage.FileContent.Position.verify(message.start);
|
| 1018 |
if (error) return 'start.' + error;
|
| 1019 |
}
|
| 1020 |
if (message.end != null && message.hasOwnProperty('end')) {
|
| 1021 |
+
var error = $root.ChatMessage.FileContent.Position.verify(message.end);
|
| 1022 |
if (error) return 'end.' + error;
|
| 1023 |
}
|
| 1024 |
return null;
|
|
|
|
| 1034 |
*/
|
| 1035 |
Range.fromObject = function fromObject(object) {
|
| 1036 |
if (object instanceof $root.ChatMessage.FileContent.Range) return object;
|
| 1037 |
+
var message = new $root.ChatMessage.FileContent.Range();
|
| 1038 |
if (object.start != null) {
|
| 1039 |
if (typeof object.start !== 'object') throw TypeError('.ChatMessage.FileContent.Range.start: object expected');
|
| 1040 |
message.start = $root.ChatMessage.FileContent.Position.fromObject(object.start);
|
|
|
|
| 1057 |
*/
|
| 1058 |
Range.toObject = function toObject(message, options) {
|
| 1059 |
if (!options) options = {};
|
| 1060 |
+
var object = {};
|
| 1061 |
if (options.defaults) {
|
| 1062 |
object.start = null;
|
| 1063 |
object.end = null;
|
|
|
|
| 1118 |
* @param {ChatMessage.IUserMessage=} [properties] Properties to set
|
| 1119 |
*/
|
| 1120 |
function UserMessage(properties) {
|
| 1121 |
+
if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]];
|
| 1122 |
}
|
| 1123 |
|
| 1124 |
/**
|
|
|
|
| 1200 |
*/
|
| 1201 |
UserMessage.decode = function decode(reader, length) {
|
| 1202 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 1203 |
+
var end = length === undefined ? reader.len : reader.pos + length,
|
| 1204 |
message = new $root.ChatMessage.UserMessage();
|
| 1205 |
while (reader.pos < end) {
|
| 1206 |
+
var tag = reader.uint32();
|
| 1207 |
switch (tag >>> 3) {
|
| 1208 |
case 1: {
|
| 1209 |
message.content = reader.string();
|
|
|
|
| 1266 |
*/
|
| 1267 |
UserMessage.fromObject = function fromObject(object) {
|
| 1268 |
if (object instanceof $root.ChatMessage.UserMessage) return object;
|
| 1269 |
+
var message = new $root.ChatMessage.UserMessage();
|
| 1270 |
if (object.content != null) message.content = String(object.content);
|
| 1271 |
if (object.role != null) message.role = object.role | 0;
|
| 1272 |
if (object.messageId != null) message.messageId = String(object.messageId);
|
|
|
|
| 1284 |
*/
|
| 1285 |
UserMessage.toObject = function toObject(message, options) {
|
| 1286 |
if (!options) options = {};
|
| 1287 |
+
var object = {};
|
| 1288 |
if (options.defaults) {
|
| 1289 |
object.content = '';
|
| 1290 |
object.role = 0;
|
|
|
|
| 1342 |
* @param {ChatMessage.IInstructions=} [properties] Properties to set
|
| 1343 |
*/
|
| 1344 |
function Instructions(properties) {
|
| 1345 |
+
if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]];
|
| 1346 |
}
|
| 1347 |
|
| 1348 |
/**
|
|
|
|
| 1406 |
*/
|
| 1407 |
Instructions.decode = function decode(reader, length) {
|
| 1408 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 1409 |
+
var end = length === undefined ? reader.len : reader.pos + length,
|
| 1410 |
message = new $root.ChatMessage.Instructions();
|
| 1411 |
while (reader.pos < end) {
|
| 1412 |
+
var tag = reader.uint32();
|
| 1413 |
switch (tag >>> 3) {
|
| 1414 |
case 1: {
|
| 1415 |
message.instruction = reader.string();
|
|
|
|
| 1462 |
*/
|
| 1463 |
Instructions.fromObject = function fromObject(object) {
|
| 1464 |
if (object instanceof $root.ChatMessage.Instructions) return object;
|
| 1465 |
+
var message = new $root.ChatMessage.Instructions();
|
| 1466 |
if (object.instruction != null) message.instruction = String(object.instruction);
|
| 1467 |
return message;
|
| 1468 |
};
|
|
|
|
| 1478 |
*/
|
| 1479 |
Instructions.toObject = function toObject(message, options) {
|
| 1480 |
if (!options) options = {};
|
| 1481 |
+
var object = {};
|
| 1482 |
if (options.defaults) object.instruction = '';
|
| 1483 |
if (message.instruction != null && message.hasOwnProperty('instruction')) object.instruction = message.instruction;
|
| 1484 |
return object;
|
|
|
|
| 1531 |
* @param {ChatMessage.IModel=} [properties] Properties to set
|
| 1532 |
*/
|
| 1533 |
function Model(properties) {
|
| 1534 |
+
if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]];
|
| 1535 |
}
|
| 1536 |
|
| 1537 |
/**
|
|
|
|
| 1604 |
*/
|
| 1605 |
Model.decode = function decode(reader, length) {
|
| 1606 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 1607 |
+
var end = length === undefined ? reader.len : reader.pos + length,
|
| 1608 |
message = new $root.ChatMessage.Model();
|
| 1609 |
while (reader.pos < end) {
|
| 1610 |
+
var tag = reader.uint32();
|
| 1611 |
switch (tag >>> 3) {
|
| 1612 |
case 1: {
|
| 1613 |
message.name = reader.string();
|
|
|
|
| 1665 |
*/
|
| 1666 |
Model.fromObject = function fromObject(object) {
|
| 1667 |
if (object instanceof $root.ChatMessage.Model) return object;
|
| 1668 |
+
var message = new $root.ChatMessage.Model();
|
| 1669 |
if (object.name != null) message.name = String(object.name);
|
| 1670 |
if (object.empty != null) message.empty = String(object.empty);
|
| 1671 |
return message;
|
|
|
|
| 1682 |
*/
|
| 1683 |
Model.toObject = function toObject(message, options) {
|
| 1684 |
if (!options) options = {};
|
| 1685 |
+
var object = {};
|
| 1686 |
if (options.defaults) {
|
| 1687 |
object.name = '';
|
| 1688 |
object.empty = '';
|
|
|
|
| 1741 |
* @param {IResMessage=} [properties] Properties to set
|
| 1742 |
*/
|
| 1743 |
function ResMessage(properties) {
|
| 1744 |
+
if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]];
|
| 1745 |
}
|
| 1746 |
|
| 1747 |
/**
|
|
|
|
| 1805 |
*/
|
| 1806 |
ResMessage.decode = function decode(reader, length) {
|
| 1807 |
if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
|
| 1808 |
+
var end = length === undefined ? reader.len : reader.pos + length,
|
| 1809 |
message = new $root.ResMessage();
|
| 1810 |
while (reader.pos < end) {
|
| 1811 |
+
var tag = reader.uint32();
|
| 1812 |
switch (tag >>> 3) {
|
| 1813 |
case 1: {
|
| 1814 |
message.msg = reader.string();
|
|
|
|
| 1861 |
*/
|
| 1862 |
ResMessage.fromObject = function fromObject(object) {
|
| 1863 |
if (object instanceof $root.ResMessage) return object;
|
| 1864 |
+
var message = new $root.ResMessage();
|
| 1865 |
if (object.msg != null) message.msg = String(object.msg);
|
| 1866 |
return message;
|
| 1867 |
};
|
|
|
|
| 1877 |
*/
|
| 1878 |
ResMessage.toObject = function toObject(message, options) {
|
| 1879 |
if (!options) options = {};
|
| 1880 |
+
var object = {};
|
| 1881 |
if (options.defaults) object.msg = '';
|
| 1882 |
if (message.msg != null && message.hasOwnProperty('msg')) object.msg = message.msg;
|
| 1883 |
return object;
|