@nexface/agent 0.1.1-alpha.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.
Files changed (56) hide show
  1. package/THIRD_PARTY_LICENSES.txt +245 -0
  2. package/dist/agent.d.ts +19 -0
  3. package/dist/agent.js +1509 -0
  4. package/dist/agent.js.map +1 -0
  5. package/dist/browser-prompt.d.ts +5 -0
  6. package/dist/browser-prompt.generated.d.ts +1 -0
  7. package/dist/browser-prompt.generated.js +50 -0
  8. package/dist/browser-prompt.generated.js.map +1 -0
  9. package/dist/browser-prompt.js +9 -0
  10. package/dist/browser-prompt.js.map +1 -0
  11. package/dist/errors.d.ts +21 -0
  12. package/dist/errors.js +55 -0
  13. package/dist/errors.js.map +1 -0
  14. package/dist/index.d.ts +6 -0
  15. package/dist/index.js +4 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/model/binding.d.ts +22 -0
  18. package/dist/model/binding.js +31 -0
  19. package/dist/model/binding.js.map +1 -0
  20. package/dist/model/error.d.ts +6 -0
  21. package/dist/model/error.js +10 -0
  22. package/dist/model/error.js.map +1 -0
  23. package/dist/model/internal-adapter.d.ts +8 -0
  24. package/dist/model/internal-adapter.js +13 -0
  25. package/dist/model/internal-adapter.js.map +1 -0
  26. package/dist/model/types.d.ts +9 -0
  27. package/dist/model/types.js +2 -0
  28. package/dist/model/types.js.map +1 -0
  29. package/dist/models/885.js +630 -0
  30. package/dist/models/956.js +5 -0
  31. package/dist/models/_chunks/35-e1813138.js +8304 -0
  32. package/dist/models/_chunks/879-7e580bb2.js +1189 -0
  33. package/dist/models/_chunks/958-bedced75.js +453 -0
  34. package/dist/models/_chunks/anthropic-messages~1-a4b25b48.js +8057 -0
  35. package/dist/models/_chunks/deferred-tools-90f3c977.js +37 -0
  36. package/dist/models/_chunks/error-body-8bee35c2.js +134 -0
  37. package/dist/models/_chunks/google-generative-ai~1-78bb2822.js +22104 -0
  38. package/dist/models/_chunks/openai-completions~1-7677fb83.js +1285 -0
  39. package/dist/models/_chunks/openai-responses~1-cc0a71cd.js +958 -0
  40. package/dist/models/anthropic-messages.d.ts +4 -0
  41. package/dist/models/anthropic-messages.js +32 -0
  42. package/dist/models/google-generative-ai.d.ts +4 -0
  43. package/dist/models/google-generative-ai.js +32 -0
  44. package/dist/models/openai-completions.d.ts +5 -0
  45. package/dist/models/openai-completions.js +16 -0
  46. package/dist/models/openai-responses.d.ts +5 -0
  47. package/dist/models/openai-responses.js +16 -0
  48. package/dist/models/rslib-runtime.js +59 -0
  49. package/dist/models/types.d.ts +26 -0
  50. package/dist/tool-bridge.d.ts +36 -0
  51. package/dist/tool-bridge.js +299 -0
  52. package/dist/tool-bridge.js.map +1 -0
  53. package/dist/types.d.ts +129 -0
  54. package/dist/types.js +2 -0
  55. package/dist/types.js.map +1 -0
  56. package/package.json +55 -0
@@ -0,0 +1,453 @@
1
+ import { __webpack_require__ } from "../rslib-runtime.js";
2
+
3
+ __webpack_require__.add({
4
+ 2319(__unused_rspack_module, exports, __webpack_require__) {
5
+
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
+ };
20
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
21
+ exports.Allow = exports.MalformedJSON = exports.PartialJSON = exports.parseJSON = exports.parse = void 0;
22
+ const options_1 = __webpack_require__(290);
23
+ Object.defineProperty(exports, "Allow", ({ enumerable: true, get: function () { return options_1.Allow; } }));
24
+ __exportStar(__webpack_require__(290), exports);
25
+ class PartialJSON extends Error {
26
+ }
27
+ exports.PartialJSON = PartialJSON;
28
+ class MalformedJSON extends Error {
29
+ }
30
+ exports.MalformedJSON = MalformedJSON;
31
+ /**
32
+ * Parse incomplete JSON
33
+ * @param {string} jsonString Partial JSON to be parsed
34
+ * @param {number} allowPartial Specify what types are allowed to be partial, see {@link Allow} for details
35
+ * @returns The parsed JSON
36
+ * @throws {PartialJSON} If the JSON is incomplete (related to the `allow` parameter)
37
+ * @throws {MalformedJSON} If the JSON is malformed
38
+ */
39
+ function parseJSON(jsonString, allowPartial = options_1.Allow.ALL) {
40
+ if (typeof jsonString !== "string") {
41
+ throw new TypeError(`expecting str, got ${typeof jsonString}`);
42
+ }
43
+ if (!jsonString.trim()) {
44
+ throw new Error(`${jsonString} is empty`);
45
+ }
46
+ return _parseJSON(jsonString.trim(), allowPartial);
47
+ }
48
+ exports.parseJSON = parseJSON;
49
+ ;
50
+ const _parseJSON = (jsonString, allow) => {
51
+ const length = jsonString.length;
52
+ let index = 0;
53
+ const markPartialJSON = (msg) => {
54
+ throw new PartialJSON(`${msg} at position ${index}`);
55
+ };
56
+ const throwMalformedError = (msg) => {
57
+ throw new MalformedJSON(`${msg} at position ${index}`);
58
+ };
59
+ const parseAny = () => {
60
+ skipBlank();
61
+ if (index >= length)
62
+ markPartialJSON("Unexpected end of input");
63
+ if (jsonString[index] === '"')
64
+ return parseStr();
65
+ if (jsonString[index] === "{")
66
+ return parseObj();
67
+ if (jsonString[index] === "[")
68
+ return parseArr();
69
+ if (jsonString.substring(index, index + 4) === "null" || (options_1.Allow.NULL & allow && length - index < 4 && "null".startsWith(jsonString.substring(index)))) {
70
+ index += 4;
71
+ return null;
72
+ }
73
+ if (jsonString.substring(index, index + 4) === "true" || (options_1.Allow.BOOL & allow && length - index < 4 && "true".startsWith(jsonString.substring(index)))) {
74
+ index += 4;
75
+ return true;
76
+ }
77
+ if (jsonString.substring(index, index + 5) === "false" || (options_1.Allow.BOOL & allow && length - index < 5 && "false".startsWith(jsonString.substring(index)))) {
78
+ index += 5;
79
+ return false;
80
+ }
81
+ if (jsonString.substring(index, index + 8) === "Infinity" || (options_1.Allow.INFINITY & allow && length - index < 8 && "Infinity".startsWith(jsonString.substring(index)))) {
82
+ index += 8;
83
+ return Infinity;
84
+ }
85
+ if (jsonString.substring(index, index + 9) === "-Infinity" || (options_1.Allow._INFINITY & allow && 1 < length - index && length - index < 9 && "-Infinity".startsWith(jsonString.substring(index)))) {
86
+ index += 9;
87
+ return -Infinity;
88
+ }
89
+ if (jsonString.substring(index, index + 3) === "NaN" || (options_1.Allow.NAN & allow && length - index < 3 && "NaN".startsWith(jsonString.substring(index)))) {
90
+ index += 3;
91
+ return NaN;
92
+ }
93
+ return parseNum();
94
+ };
95
+ const parseStr = () => {
96
+ const start = index;
97
+ let escape = false;
98
+ index++; // skip initial quote
99
+ while (index < length && (jsonString[index] !== '"' || (escape && jsonString[index - 1] === "\\"))) {
100
+ escape = jsonString[index] === "\\" ? !escape : false;
101
+ index++;
102
+ }
103
+ if (jsonString.charAt(index) == '"') {
104
+ try {
105
+ return JSON.parse(jsonString.substring(start, ++index - Number(escape)));
106
+ }
107
+ catch (e) {
108
+ throwMalformedError(String(e));
109
+ }
110
+ }
111
+ else if (options_1.Allow.STR & allow) {
112
+ try {
113
+ return JSON.parse(jsonString.substring(start, index - Number(escape)) + '"');
114
+ }
115
+ catch (e) {
116
+ // SyntaxError: Invalid escape sequence
117
+ return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf("\\")) + '"');
118
+ }
119
+ }
120
+ markPartialJSON("Unterminated string literal");
121
+ };
122
+ const parseObj = () => {
123
+ index++; // skip initial brace
124
+ skipBlank();
125
+ const obj = {};
126
+ try {
127
+ while (jsonString[index] !== "}") {
128
+ skipBlank();
129
+ if (index >= length && options_1.Allow.OBJ & allow)
130
+ return obj;
131
+ const key = parseStr();
132
+ skipBlank();
133
+ index++; // skip colon
134
+ try {
135
+ const value = parseAny();
136
+ obj[key] = value;
137
+ }
138
+ catch (e) {
139
+ if (options_1.Allow.OBJ & allow)
140
+ return obj;
141
+ else
142
+ throw e;
143
+ }
144
+ skipBlank();
145
+ if (jsonString[index] === ",")
146
+ index++; // skip comma
147
+ }
148
+ }
149
+ catch (e) {
150
+ if (options_1.Allow.OBJ & allow)
151
+ return obj;
152
+ else
153
+ markPartialJSON("Expected '}' at end of object");
154
+ }
155
+ index++; // skip final brace
156
+ return obj;
157
+ };
158
+ const parseArr = () => {
159
+ index++; // skip initial bracket
160
+ const arr = [];
161
+ try {
162
+ while (jsonString[index] !== "]") {
163
+ arr.push(parseAny());
164
+ skipBlank();
165
+ if (jsonString[index] === ",") {
166
+ index++; // skip comma
167
+ }
168
+ }
169
+ }
170
+ catch (e) {
171
+ if (options_1.Allow.ARR & allow) {
172
+ return arr;
173
+ }
174
+ markPartialJSON("Expected ']' at end of array");
175
+ }
176
+ index++; // skip final bracket
177
+ return arr;
178
+ };
179
+ const parseNum = () => {
180
+ if (index === 0) {
181
+ if (jsonString === "-")
182
+ throwMalformedError("Not sure what '-' is");
183
+ try {
184
+ return JSON.parse(jsonString);
185
+ }
186
+ catch (e) {
187
+ if (options_1.Allow.NUM & allow)
188
+ try {
189
+ return JSON.parse(jsonString.substring(0, jsonString.lastIndexOf("e")));
190
+ }
191
+ catch (e) { }
192
+ throwMalformedError(String(e));
193
+ }
194
+ }
195
+ const start = index;
196
+ if (jsonString[index] === "-")
197
+ index++;
198
+ while (jsonString[index] && ",]}".indexOf(jsonString[index]) === -1)
199
+ index++;
200
+ if (index == length && !(options_1.Allow.NUM & allow))
201
+ markPartialJSON("Unterminated number literal");
202
+ try {
203
+ return JSON.parse(jsonString.substring(start, index));
204
+ }
205
+ catch (e) {
206
+ if (jsonString.substring(start, index) === "-")
207
+ markPartialJSON("Not sure what '-' is");
208
+ try {
209
+ return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf("e")));
210
+ }
211
+ catch (e) {
212
+ throwMalformedError(String(e));
213
+ }
214
+ }
215
+ };
216
+ const skipBlank = () => {
217
+ while (index < length && " \n\r\t".includes(jsonString[index])) {
218
+ index++;
219
+ }
220
+ };
221
+ return parseAny();
222
+ };
223
+ const parse = parseJSON;
224
+ exports.parse = parse;
225
+
226
+
227
+ },
228
+ 290(__unused_rspack_module, exports) {
229
+
230
+ /**
231
+ * Sometimes you don't allow every type to be partially parsed.
232
+ * For example, you may not want a partial number because it may increase its size gradually before it's complete.
233
+ * In this case, you can use the `Allow` object to control what types you allow to be partially parsed.
234
+ * @module
235
+ */
236
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
237
+ exports.Allow = exports.ALL = exports.COLLECTION = exports.ATOM = exports.SPECIAL = exports.INF = exports._INFINITY = exports.INFINITY = exports.NAN = exports.BOOL = exports.NULL = exports.OBJ = exports.ARR = exports.NUM = exports.STR = void 0;
238
+ /**
239
+ * allow partial strings like `"hello \u12` to be parsed as `"hello "`
240
+ */
241
+ exports.STR = 0b000000001;
242
+ /**
243
+ * allow partial numbers like `123.` to be parsed as `123`
244
+ */
245
+ exports.NUM = 0b000000010;
246
+ /**
247
+ * allow partial arrays like `[1, 2,` to be parsed as `[1, 2]`
248
+ */
249
+ exports.ARR = 0b000000100;
250
+ /**
251
+ * allow partial objects like `{"a": 1, "b":` to be parsed as `{"a": 1}`
252
+ */
253
+ exports.OBJ = 0b000001000;
254
+ /**
255
+ * allow `nu` to be parsed as `null`
256
+ */
257
+ exports.NULL = 0b000010000;
258
+ /**
259
+ * allow `tr` to be parsed as `true`, and `fa` to be parsed as `false`
260
+ */
261
+ exports.BOOL = 0b000100000;
262
+ /**
263
+ * allow `Na` to be parsed as `NaN`
264
+ */
265
+ exports.NAN = 0b001000000;
266
+ /**
267
+ * allow `Inf` to be parsed as `Infinity`
268
+ */
269
+ exports.INFINITY = 0b010000000;
270
+ /**
271
+ * allow `-Inf` to be parsed as `-Infinity`
272
+ */
273
+ exports._INFINITY = 0b100000000;
274
+ exports.INF = exports.INFINITY | exports._INFINITY;
275
+ exports.SPECIAL = exports.NULL | exports.BOOL | exports.INF | exports.NAN;
276
+ exports.ATOM = exports.STR | exports.NUM | exports.SPECIAL;
277
+ exports.COLLECTION = exports.ARR | exports.OBJ;
278
+ exports.ALL = exports.ATOM | exports.COLLECTION;
279
+ /**
280
+ * Control what types you allow to be partially parsed.
281
+ * The default is to allow all types to be partially parsed, which in most casees is the best option.
282
+ * @example
283
+ * If you don't want to allow partial objects, you can use the following code:
284
+ * ```ts
285
+ * import { Allow, parse } from "partial-json";
286
+ * parse(`[{"a": 1, "b": 2}, {"a": 3,`, Allow.ARR); // [ { a: 1, b: 2 } ]
287
+ * ```
288
+ * Or you can use `~` to disallow a type:
289
+ * ```ts
290
+ * parse(`[{"a": 1, "b": 2}, {"a": 3,`, ~Allow.OBJ); // [ { a: 1, b: 2 } ]
291
+ * ```
292
+ * @example
293
+ * If you don't want to allow partial strings, you can use the following code:
294
+ * ```ts
295
+ * import { Allow, parse } from "partial-json";
296
+ * parse(`["complete string", "incompl`, ~Allow.STR); // [ 'complete string' ]
297
+ * ```
298
+ */
299
+ exports.Allow = { STR: exports.STR, NUM: exports.NUM, ARR: exports.ARR, OBJ: exports.OBJ, NULL: exports.NULL, BOOL: exports.BOOL, NAN: exports.NAN, INFINITY: exports.INFINITY, _INFINITY: exports._INFINITY, INF: exports.INF, SPECIAL: exports.SPECIAL, ATOM: exports.ATOM, COLLECTION: exports.COLLECTION, ALL: exports.ALL };
300
+ exports["default"] = exports.Allow;
301
+
302
+
303
+ },
304
+ });
305
+ const dist = __webpack_require__("2319");
306
+
307
+ const VALID_JSON_ESCAPES = new Set(['"', "\\", "/", "b", "f", "n", "r", "t", "u"]);
308
+ function isControlCharacter(char) {
309
+ const codePoint = char.codePointAt(0);
310
+ return codePoint !== undefined && codePoint >= 0x00 && codePoint <= 0x1f;
311
+ }
312
+ function escapeControlCharacter(char) {
313
+ switch (char) {
314
+ case "\b":
315
+ return "\\b";
316
+ case "\f":
317
+ return "\\f";
318
+ case "\n":
319
+ return "\\n";
320
+ case "\r":
321
+ return "\\r";
322
+ case "\t":
323
+ return "\\t";
324
+ default:
325
+ return `\\u${char.codePointAt(0)?.toString(16).padStart(4, "0") ?? "0000"}`;
326
+ }
327
+ }
328
+ /**
329
+ * Repairs malformed JSON string literals by:
330
+ * - escaping raw control characters inside strings
331
+ * - doubling backslashes before invalid escape characters
332
+ */
333
+ function repairJson(json) {
334
+ let repaired = "";
335
+ let inString = false;
336
+ for (let index = 0; index < json.length; index++) {
337
+ const char = json[index];
338
+ if (!inString) {
339
+ repaired += char;
340
+ if (char === '"') {
341
+ inString = true;
342
+ }
343
+ continue;
344
+ }
345
+ if (char === '"') {
346
+ repaired += char;
347
+ inString = false;
348
+ continue;
349
+ }
350
+ if (char === "\\") {
351
+ const nextChar = json[index + 1];
352
+ if (nextChar === undefined) {
353
+ repaired += "\\\\";
354
+ continue;
355
+ }
356
+ if (nextChar === "u") {
357
+ const unicodeDigits = json.slice(index + 2, index + 6);
358
+ if (/^[0-9a-fA-F]{4}$/.test(unicodeDigits)) {
359
+ repaired += `\\u${unicodeDigits}`;
360
+ index += 5;
361
+ continue;
362
+ }
363
+ }
364
+ if (VALID_JSON_ESCAPES.has(nextChar)) {
365
+ repaired += `\\${nextChar}`;
366
+ index += 1;
367
+ continue;
368
+ }
369
+ repaired += "\\\\";
370
+ continue;
371
+ }
372
+ repaired += isControlCharacter(char) ? escapeControlCharacter(char) : char;
373
+ }
374
+ return repaired;
375
+ }
376
+ function parseJsonWithRepair(json) {
377
+ try {
378
+ return JSON.parse(json);
379
+ }
380
+ catch (error) {
381
+ const repairedJson = repairJson(json);
382
+ if (repairedJson !== json) {
383
+ return JSON.parse(repairedJson);
384
+ }
385
+ throw error;
386
+ }
387
+ }
388
+ /**
389
+ * Attempts to parse potentially incomplete JSON during streaming.
390
+ * Always returns a valid object, even if the JSON is incomplete.
391
+ *
392
+ * @param partialJson The partial JSON string from streaming
393
+ * @returns Parsed object or empty object if parsing fails
394
+ */
395
+ function parseStreamingJson(partialJson) {
396
+ if (!partialJson || partialJson.trim() === "") {
397
+ return {};
398
+ }
399
+ try {
400
+ return parseJsonWithRepair(partialJson);
401
+ }
402
+ catch {
403
+ try {
404
+ const result = (0,dist.parse)(partialJson);
405
+ return (result ?? {});
406
+ }
407
+ catch {
408
+ try {
409
+ const result = (0,dist.parse)(repairJson(partialJson));
410
+ return (result ?? {});
411
+ }
412
+ catch {
413
+ return {};
414
+ }
415
+ }
416
+ }
417
+ }
418
+ //# sourceMappingURL=json-parse.js.map
419
+ function getProviderEnvValue(name, env) {
420
+ const value = env?.[name];
421
+ return typeof value === "string" && value.trim() ? value : undefined;
422
+ }
423
+
424
+ // Copilot expects X-Initiator to indicate whether the request is user-initiated
425
+ // or agent-initiated (e.g. follow-up after assistant/tool messages).
426
+ function inferCopilotInitiator(messages) {
427
+ const last = messages[messages.length - 1];
428
+ return last && last.role !== "user" ? "agent" : "user";
429
+ }
430
+ // Copilot requires Copilot-Vision-Request header when sending images
431
+ function hasCopilotVisionInput(messages) {
432
+ return messages.some((msg) => {
433
+ if (msg.role === "user" && Array.isArray(msg.content)) {
434
+ return msg.content.some((c) => c.type === "image");
435
+ }
436
+ if (msg.role === "toolResult" && Array.isArray(msg.content)) {
437
+ return msg.content.some((c) => c.type === "image");
438
+ }
439
+ return false;
440
+ });
441
+ }
442
+ function buildCopilotDynamicHeaders(params) {
443
+ const headers = {
444
+ "X-Initiator": inferCopilotInitiator(params.messages),
445
+ "Openai-Intent": "conversation-edits",
446
+ };
447
+ if (params.hasImages) {
448
+ headers["Copilot-Vision-Request"] = "true";
449
+ }
450
+ return headers;
451
+ }
452
+ //# sourceMappingURL=github-copilot-headers.js.map
453
+ export { buildCopilotDynamicHeaders, getProviderEnvValue, hasCopilotVisionInput, parseJsonWithRepair, parseStreamingJson };