opencode-gitlab-dap 1.5.1 → 1.6.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.cjs CHANGED
@@ -36,2591 +36,8 @@ module.exports = __toCommonJS(index_exports);
36
36
  var import_plugin = require("@opencode-ai/plugin");
37
37
  var import_gitlab_ai_provider = require("gitlab-ai-provider");
38
38
 
39
- // node_modules/js-yaml/dist/js-yaml.mjs
40
- function isNothing(subject) {
41
- return typeof subject === "undefined" || subject === null;
42
- }
43
- function isObject(subject) {
44
- return typeof subject === "object" && subject !== null;
45
- }
46
- function toArray(sequence) {
47
- if (Array.isArray(sequence)) return sequence;
48
- else if (isNothing(sequence)) return [];
49
- return [sequence];
50
- }
51
- function extend(target, source) {
52
- var index, length, key, sourceKeys;
53
- if (source) {
54
- sourceKeys = Object.keys(source);
55
- for (index = 0, length = sourceKeys.length; index < length; index += 1) {
56
- key = sourceKeys[index];
57
- target[key] = source[key];
58
- }
59
- }
60
- return target;
61
- }
62
- function repeat(string, count) {
63
- var result = "", cycle;
64
- for (cycle = 0; cycle < count; cycle += 1) {
65
- result += string;
66
- }
67
- return result;
68
- }
69
- function isNegativeZero(number) {
70
- return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
71
- }
72
- var isNothing_1 = isNothing;
73
- var isObject_1 = isObject;
74
- var toArray_1 = toArray;
75
- var repeat_1 = repeat;
76
- var isNegativeZero_1 = isNegativeZero;
77
- var extend_1 = extend;
78
- var common = {
79
- isNothing: isNothing_1,
80
- isObject: isObject_1,
81
- toArray: toArray_1,
82
- repeat: repeat_1,
83
- isNegativeZero: isNegativeZero_1,
84
- extend: extend_1
85
- };
86
- function formatError(exception2, compact) {
87
- var where = "", message = exception2.reason || "(unknown reason)";
88
- if (!exception2.mark) return message;
89
- if (exception2.mark.name) {
90
- where += 'in "' + exception2.mark.name + '" ';
91
- }
92
- where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
93
- if (!compact && exception2.mark.snippet) {
94
- where += "\n\n" + exception2.mark.snippet;
95
- }
96
- return message + " " + where;
97
- }
98
- function YAMLException$1(reason, mark) {
99
- Error.call(this);
100
- this.name = "YAMLException";
101
- this.reason = reason;
102
- this.mark = mark;
103
- this.message = formatError(this, false);
104
- if (Error.captureStackTrace) {
105
- Error.captureStackTrace(this, this.constructor);
106
- } else {
107
- this.stack = new Error().stack || "";
108
- }
109
- }
110
- YAMLException$1.prototype = Object.create(Error.prototype);
111
- YAMLException$1.prototype.constructor = YAMLException$1;
112
- YAMLException$1.prototype.toString = function toString(compact) {
113
- return this.name + ": " + formatError(this, compact);
114
- };
115
- var exception = YAMLException$1;
116
- function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
117
- var head = "";
118
- var tail = "";
119
- var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
120
- if (position - lineStart > maxHalfLength) {
121
- head = " ... ";
122
- lineStart = position - maxHalfLength + head.length;
123
- }
124
- if (lineEnd - position > maxHalfLength) {
125
- tail = " ...";
126
- lineEnd = position + maxHalfLength - tail.length;
127
- }
128
- return {
129
- str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
130
- pos: position - lineStart + head.length
131
- // relative position
132
- };
133
- }
134
- function padStart(string, max) {
135
- return common.repeat(" ", max - string.length) + string;
136
- }
137
- function makeSnippet(mark, options) {
138
- options = Object.create(options || null);
139
- if (!mark.buffer) return null;
140
- if (!options.maxLength) options.maxLength = 79;
141
- if (typeof options.indent !== "number") options.indent = 1;
142
- if (typeof options.linesBefore !== "number") options.linesBefore = 3;
143
- if (typeof options.linesAfter !== "number") options.linesAfter = 2;
144
- var re = /\r?\n|\r|\0/g;
145
- var lineStarts = [0];
146
- var lineEnds = [];
147
- var match;
148
- var foundLineNo = -1;
149
- while (match = re.exec(mark.buffer)) {
150
- lineEnds.push(match.index);
151
- lineStarts.push(match.index + match[0].length);
152
- if (mark.position <= match.index && foundLineNo < 0) {
153
- foundLineNo = lineStarts.length - 2;
154
- }
155
- }
156
- if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
157
- var result = "", i, line;
158
- var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
159
- var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
160
- for (i = 1; i <= options.linesBefore; i++) {
161
- if (foundLineNo - i < 0) break;
162
- line = getLine(
163
- mark.buffer,
164
- lineStarts[foundLineNo - i],
165
- lineEnds[foundLineNo - i],
166
- mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
167
- maxLineLength
168
- );
169
- result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
170
- }
171
- line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
172
- result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
173
- result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
174
- for (i = 1; i <= options.linesAfter; i++) {
175
- if (foundLineNo + i >= lineEnds.length) break;
176
- line = getLine(
177
- mark.buffer,
178
- lineStarts[foundLineNo + i],
179
- lineEnds[foundLineNo + i],
180
- mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
181
- maxLineLength
182
- );
183
- result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
184
- }
185
- return result.replace(/\n$/, "");
186
- }
187
- var snippet = makeSnippet;
188
- var TYPE_CONSTRUCTOR_OPTIONS = [
189
- "kind",
190
- "multi",
191
- "resolve",
192
- "construct",
193
- "instanceOf",
194
- "predicate",
195
- "represent",
196
- "representName",
197
- "defaultStyle",
198
- "styleAliases"
199
- ];
200
- var YAML_NODE_KINDS = [
201
- "scalar",
202
- "sequence",
203
- "mapping"
204
- ];
205
- function compileStyleAliases(map2) {
206
- var result = {};
207
- if (map2 !== null) {
208
- Object.keys(map2).forEach(function(style) {
209
- map2[style].forEach(function(alias) {
210
- result[String(alias)] = style;
211
- });
212
- });
213
- }
214
- return result;
215
- }
216
- function Type$1(tag, options) {
217
- options = options || {};
218
- Object.keys(options).forEach(function(name) {
219
- if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
220
- throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
221
- }
222
- });
223
- this.options = options;
224
- this.tag = tag;
225
- this.kind = options["kind"] || null;
226
- this.resolve = options["resolve"] || function() {
227
- return true;
228
- };
229
- this.construct = options["construct"] || function(data) {
230
- return data;
231
- };
232
- this.instanceOf = options["instanceOf"] || null;
233
- this.predicate = options["predicate"] || null;
234
- this.represent = options["represent"] || null;
235
- this.representName = options["representName"] || null;
236
- this.defaultStyle = options["defaultStyle"] || null;
237
- this.multi = options["multi"] || false;
238
- this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
239
- if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
240
- throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
241
- }
242
- }
243
- var type = Type$1;
244
- function compileList(schema2, name) {
245
- var result = [];
246
- schema2[name].forEach(function(currentType) {
247
- var newIndex = result.length;
248
- result.forEach(function(previousType, previousIndex) {
249
- if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
250
- newIndex = previousIndex;
251
- }
252
- });
253
- result[newIndex] = currentType;
254
- });
255
- return result;
256
- }
257
- function compileMap() {
258
- var result = {
259
- scalar: {},
260
- sequence: {},
261
- mapping: {},
262
- fallback: {},
263
- multi: {
264
- scalar: [],
265
- sequence: [],
266
- mapping: [],
267
- fallback: []
268
- }
269
- }, index, length;
270
- function collectType(type2) {
271
- if (type2.multi) {
272
- result.multi[type2.kind].push(type2);
273
- result.multi["fallback"].push(type2);
274
- } else {
275
- result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
276
- }
277
- }
278
- for (index = 0, length = arguments.length; index < length; index += 1) {
279
- arguments[index].forEach(collectType);
280
- }
281
- return result;
282
- }
283
- function Schema$1(definition) {
284
- return this.extend(definition);
285
- }
286
- Schema$1.prototype.extend = function extend2(definition) {
287
- var implicit = [];
288
- var explicit = [];
289
- if (definition instanceof type) {
290
- explicit.push(definition);
291
- } else if (Array.isArray(definition)) {
292
- explicit = explicit.concat(definition);
293
- } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
294
- if (definition.implicit) implicit = implicit.concat(definition.implicit);
295
- if (definition.explicit) explicit = explicit.concat(definition.explicit);
296
- } else {
297
- throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
298
- }
299
- implicit.forEach(function(type$1) {
300
- if (!(type$1 instanceof type)) {
301
- throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
302
- }
303
- if (type$1.loadKind && type$1.loadKind !== "scalar") {
304
- throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
305
- }
306
- if (type$1.multi) {
307
- throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
308
- }
309
- });
310
- explicit.forEach(function(type$1) {
311
- if (!(type$1 instanceof type)) {
312
- throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
313
- }
314
- });
315
- var result = Object.create(Schema$1.prototype);
316
- result.implicit = (this.implicit || []).concat(implicit);
317
- result.explicit = (this.explicit || []).concat(explicit);
318
- result.compiledImplicit = compileList(result, "implicit");
319
- result.compiledExplicit = compileList(result, "explicit");
320
- result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
321
- return result;
322
- };
323
- var schema = Schema$1;
324
- var str = new type("tag:yaml.org,2002:str", {
325
- kind: "scalar",
326
- construct: function(data) {
327
- return data !== null ? data : "";
328
- }
329
- });
330
- var seq = new type("tag:yaml.org,2002:seq", {
331
- kind: "sequence",
332
- construct: function(data) {
333
- return data !== null ? data : [];
334
- }
335
- });
336
- var map = new type("tag:yaml.org,2002:map", {
337
- kind: "mapping",
338
- construct: function(data) {
339
- return data !== null ? data : {};
340
- }
341
- });
342
- var failsafe = new schema({
343
- explicit: [
344
- str,
345
- seq,
346
- map
347
- ]
348
- });
349
- function resolveYamlNull(data) {
350
- if (data === null) return true;
351
- var max = data.length;
352
- return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
353
- }
354
- function constructYamlNull() {
355
- return null;
356
- }
357
- function isNull(object) {
358
- return object === null;
359
- }
360
- var _null = new type("tag:yaml.org,2002:null", {
361
- kind: "scalar",
362
- resolve: resolveYamlNull,
363
- construct: constructYamlNull,
364
- predicate: isNull,
365
- represent: {
366
- canonical: function() {
367
- return "~";
368
- },
369
- lowercase: function() {
370
- return "null";
371
- },
372
- uppercase: function() {
373
- return "NULL";
374
- },
375
- camelcase: function() {
376
- return "Null";
377
- },
378
- empty: function() {
379
- return "";
380
- }
381
- },
382
- defaultStyle: "lowercase"
383
- });
384
- function resolveYamlBoolean(data) {
385
- if (data === null) return false;
386
- var max = data.length;
387
- return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
388
- }
389
- function constructYamlBoolean(data) {
390
- return data === "true" || data === "True" || data === "TRUE";
391
- }
392
- function isBoolean(object) {
393
- return Object.prototype.toString.call(object) === "[object Boolean]";
394
- }
395
- var bool = new type("tag:yaml.org,2002:bool", {
396
- kind: "scalar",
397
- resolve: resolveYamlBoolean,
398
- construct: constructYamlBoolean,
399
- predicate: isBoolean,
400
- represent: {
401
- lowercase: function(object) {
402
- return object ? "true" : "false";
403
- },
404
- uppercase: function(object) {
405
- return object ? "TRUE" : "FALSE";
406
- },
407
- camelcase: function(object) {
408
- return object ? "True" : "False";
409
- }
410
- },
411
- defaultStyle: "lowercase"
412
- });
413
- function isHexCode(c) {
414
- return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
415
- }
416
- function isOctCode(c) {
417
- return 48 <= c && c <= 55;
418
- }
419
- function isDecCode(c) {
420
- return 48 <= c && c <= 57;
421
- }
422
- function resolveYamlInteger(data) {
423
- if (data === null) return false;
424
- var max = data.length, index = 0, hasDigits = false, ch;
425
- if (!max) return false;
426
- ch = data[index];
427
- if (ch === "-" || ch === "+") {
428
- ch = data[++index];
429
- }
430
- if (ch === "0") {
431
- if (index + 1 === max) return true;
432
- ch = data[++index];
433
- if (ch === "b") {
434
- index++;
435
- for (; index < max; index++) {
436
- ch = data[index];
437
- if (ch === "_") continue;
438
- if (ch !== "0" && ch !== "1") return false;
439
- hasDigits = true;
440
- }
441
- return hasDigits && ch !== "_";
442
- }
443
- if (ch === "x") {
444
- index++;
445
- for (; index < max; index++) {
446
- ch = data[index];
447
- if (ch === "_") continue;
448
- if (!isHexCode(data.charCodeAt(index))) return false;
449
- hasDigits = true;
450
- }
451
- return hasDigits && ch !== "_";
452
- }
453
- if (ch === "o") {
454
- index++;
455
- for (; index < max; index++) {
456
- ch = data[index];
457
- if (ch === "_") continue;
458
- if (!isOctCode(data.charCodeAt(index))) return false;
459
- hasDigits = true;
460
- }
461
- return hasDigits && ch !== "_";
462
- }
463
- }
464
- if (ch === "_") return false;
465
- for (; index < max; index++) {
466
- ch = data[index];
467
- if (ch === "_") continue;
468
- if (!isDecCode(data.charCodeAt(index))) {
469
- return false;
470
- }
471
- hasDigits = true;
472
- }
473
- if (!hasDigits || ch === "_") return false;
474
- return true;
475
- }
476
- function constructYamlInteger(data) {
477
- var value = data, sign = 1, ch;
478
- if (value.indexOf("_") !== -1) {
479
- value = value.replace(/_/g, "");
480
- }
481
- ch = value[0];
482
- if (ch === "-" || ch === "+") {
483
- if (ch === "-") sign = -1;
484
- value = value.slice(1);
485
- ch = value[0];
486
- }
487
- if (value === "0") return 0;
488
- if (ch === "0") {
489
- if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
490
- if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
491
- if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
492
- }
493
- return sign * parseInt(value, 10);
494
- }
495
- function isInteger(object) {
496
- return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
497
- }
498
- var int = new type("tag:yaml.org,2002:int", {
499
- kind: "scalar",
500
- resolve: resolveYamlInteger,
501
- construct: constructYamlInteger,
502
- predicate: isInteger,
503
- represent: {
504
- binary: function(obj) {
505
- return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
506
- },
507
- octal: function(obj) {
508
- return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
509
- },
510
- decimal: function(obj) {
511
- return obj.toString(10);
512
- },
513
- /* eslint-disable max-len */
514
- hexadecimal: function(obj) {
515
- return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
516
- }
517
- },
518
- defaultStyle: "decimal",
519
- styleAliases: {
520
- binary: [2, "bin"],
521
- octal: [8, "oct"],
522
- decimal: [10, "dec"],
523
- hexadecimal: [16, "hex"]
524
- }
525
- });
526
- var YAML_FLOAT_PATTERN = new RegExp(
527
- // 2.5e4, 2.5 and integers
528
- "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
529
- );
530
- function resolveYamlFloat(data) {
531
- if (data === null) return false;
532
- if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
533
- // Probably should update regexp & check speed
534
- data[data.length - 1] === "_") {
535
- return false;
536
- }
537
- return true;
538
- }
539
- function constructYamlFloat(data) {
540
- var value, sign;
541
- value = data.replace(/_/g, "").toLowerCase();
542
- sign = value[0] === "-" ? -1 : 1;
543
- if ("+-".indexOf(value[0]) >= 0) {
544
- value = value.slice(1);
545
- }
546
- if (value === ".inf") {
547
- return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
548
- } else if (value === ".nan") {
549
- return NaN;
550
- }
551
- return sign * parseFloat(value, 10);
552
- }
553
- var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
554
- function representYamlFloat(object, style) {
555
- var res;
556
- if (isNaN(object)) {
557
- switch (style) {
558
- case "lowercase":
559
- return ".nan";
560
- case "uppercase":
561
- return ".NAN";
562
- case "camelcase":
563
- return ".NaN";
564
- }
565
- } else if (Number.POSITIVE_INFINITY === object) {
566
- switch (style) {
567
- case "lowercase":
568
- return ".inf";
569
- case "uppercase":
570
- return ".INF";
571
- case "camelcase":
572
- return ".Inf";
573
- }
574
- } else if (Number.NEGATIVE_INFINITY === object) {
575
- switch (style) {
576
- case "lowercase":
577
- return "-.inf";
578
- case "uppercase":
579
- return "-.INF";
580
- case "camelcase":
581
- return "-.Inf";
582
- }
583
- } else if (common.isNegativeZero(object)) {
584
- return "-0.0";
585
- }
586
- res = object.toString(10);
587
- return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
588
- }
589
- function isFloat(object) {
590
- return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
591
- }
592
- var float = new type("tag:yaml.org,2002:float", {
593
- kind: "scalar",
594
- resolve: resolveYamlFloat,
595
- construct: constructYamlFloat,
596
- predicate: isFloat,
597
- represent: representYamlFloat,
598
- defaultStyle: "lowercase"
599
- });
600
- var json = failsafe.extend({
601
- implicit: [
602
- _null,
603
- bool,
604
- int,
605
- float
606
- ]
607
- });
608
- var core = json;
609
- var YAML_DATE_REGEXP = new RegExp(
610
- "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
611
- );
612
- var YAML_TIMESTAMP_REGEXP = new RegExp(
613
- "^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"
614
- );
615
- function resolveYamlTimestamp(data) {
616
- if (data === null) return false;
617
- if (YAML_DATE_REGEXP.exec(data) !== null) return true;
618
- if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
619
- return false;
620
- }
621
- function constructYamlTimestamp(data) {
622
- var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
623
- match = YAML_DATE_REGEXP.exec(data);
624
- if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
625
- if (match === null) throw new Error("Date resolve error");
626
- year = +match[1];
627
- month = +match[2] - 1;
628
- day = +match[3];
629
- if (!match[4]) {
630
- return new Date(Date.UTC(year, month, day));
631
- }
632
- hour = +match[4];
633
- minute = +match[5];
634
- second = +match[6];
635
- if (match[7]) {
636
- fraction = match[7].slice(0, 3);
637
- while (fraction.length < 3) {
638
- fraction += "0";
639
- }
640
- fraction = +fraction;
641
- }
642
- if (match[9]) {
643
- tz_hour = +match[10];
644
- tz_minute = +(match[11] || 0);
645
- delta = (tz_hour * 60 + tz_minute) * 6e4;
646
- if (match[9] === "-") delta = -delta;
647
- }
648
- date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
649
- if (delta) date.setTime(date.getTime() - delta);
650
- return date;
651
- }
652
- function representYamlTimestamp(object) {
653
- return object.toISOString();
654
- }
655
- var timestamp = new type("tag:yaml.org,2002:timestamp", {
656
- kind: "scalar",
657
- resolve: resolveYamlTimestamp,
658
- construct: constructYamlTimestamp,
659
- instanceOf: Date,
660
- represent: representYamlTimestamp
661
- });
662
- function resolveYamlMerge(data) {
663
- return data === "<<" || data === null;
664
- }
665
- var merge = new type("tag:yaml.org,2002:merge", {
666
- kind: "scalar",
667
- resolve: resolveYamlMerge
668
- });
669
- var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
670
- function resolveYamlBinary(data) {
671
- if (data === null) return false;
672
- var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
673
- for (idx = 0; idx < max; idx++) {
674
- code = map2.indexOf(data.charAt(idx));
675
- if (code > 64) continue;
676
- if (code < 0) return false;
677
- bitlen += 6;
678
- }
679
- return bitlen % 8 === 0;
680
- }
681
- function constructYamlBinary(data) {
682
- var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
683
- for (idx = 0; idx < max; idx++) {
684
- if (idx % 4 === 0 && idx) {
685
- result.push(bits >> 16 & 255);
686
- result.push(bits >> 8 & 255);
687
- result.push(bits & 255);
688
- }
689
- bits = bits << 6 | map2.indexOf(input.charAt(idx));
690
- }
691
- tailbits = max % 4 * 6;
692
- if (tailbits === 0) {
693
- result.push(bits >> 16 & 255);
694
- result.push(bits >> 8 & 255);
695
- result.push(bits & 255);
696
- } else if (tailbits === 18) {
697
- result.push(bits >> 10 & 255);
698
- result.push(bits >> 2 & 255);
699
- } else if (tailbits === 12) {
700
- result.push(bits >> 4 & 255);
701
- }
702
- return new Uint8Array(result);
703
- }
704
- function representYamlBinary(object) {
705
- var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
706
- for (idx = 0; idx < max; idx++) {
707
- if (idx % 3 === 0 && idx) {
708
- result += map2[bits >> 18 & 63];
709
- result += map2[bits >> 12 & 63];
710
- result += map2[bits >> 6 & 63];
711
- result += map2[bits & 63];
712
- }
713
- bits = (bits << 8) + object[idx];
714
- }
715
- tail = max % 3;
716
- if (tail === 0) {
717
- result += map2[bits >> 18 & 63];
718
- result += map2[bits >> 12 & 63];
719
- result += map2[bits >> 6 & 63];
720
- result += map2[bits & 63];
721
- } else if (tail === 2) {
722
- result += map2[bits >> 10 & 63];
723
- result += map2[bits >> 4 & 63];
724
- result += map2[bits << 2 & 63];
725
- result += map2[64];
726
- } else if (tail === 1) {
727
- result += map2[bits >> 2 & 63];
728
- result += map2[bits << 4 & 63];
729
- result += map2[64];
730
- result += map2[64];
731
- }
732
- return result;
733
- }
734
- function isBinary(obj) {
735
- return Object.prototype.toString.call(obj) === "[object Uint8Array]";
736
- }
737
- var binary = new type("tag:yaml.org,2002:binary", {
738
- kind: "scalar",
739
- resolve: resolveYamlBinary,
740
- construct: constructYamlBinary,
741
- predicate: isBinary,
742
- represent: representYamlBinary
743
- });
744
- var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
745
- var _toString$2 = Object.prototype.toString;
746
- function resolveYamlOmap(data) {
747
- if (data === null) return true;
748
- var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
749
- for (index = 0, length = object.length; index < length; index += 1) {
750
- pair = object[index];
751
- pairHasKey = false;
752
- if (_toString$2.call(pair) !== "[object Object]") return false;
753
- for (pairKey in pair) {
754
- if (_hasOwnProperty$3.call(pair, pairKey)) {
755
- if (!pairHasKey) pairHasKey = true;
756
- else return false;
757
- }
758
- }
759
- if (!pairHasKey) return false;
760
- if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
761
- else return false;
762
- }
763
- return true;
764
- }
765
- function constructYamlOmap(data) {
766
- return data !== null ? data : [];
767
- }
768
- var omap = new type("tag:yaml.org,2002:omap", {
769
- kind: "sequence",
770
- resolve: resolveYamlOmap,
771
- construct: constructYamlOmap
772
- });
773
- var _toString$1 = Object.prototype.toString;
774
- function resolveYamlPairs(data) {
775
- if (data === null) return true;
776
- var index, length, pair, keys, result, object = data;
777
- result = new Array(object.length);
778
- for (index = 0, length = object.length; index < length; index += 1) {
779
- pair = object[index];
780
- if (_toString$1.call(pair) !== "[object Object]") return false;
781
- keys = Object.keys(pair);
782
- if (keys.length !== 1) return false;
783
- result[index] = [keys[0], pair[keys[0]]];
784
- }
785
- return true;
786
- }
787
- function constructYamlPairs(data) {
788
- if (data === null) return [];
789
- var index, length, pair, keys, result, object = data;
790
- result = new Array(object.length);
791
- for (index = 0, length = object.length; index < length; index += 1) {
792
- pair = object[index];
793
- keys = Object.keys(pair);
794
- result[index] = [keys[0], pair[keys[0]]];
795
- }
796
- return result;
797
- }
798
- var pairs = new type("tag:yaml.org,2002:pairs", {
799
- kind: "sequence",
800
- resolve: resolveYamlPairs,
801
- construct: constructYamlPairs
802
- });
803
- var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
804
- function resolveYamlSet(data) {
805
- if (data === null) return true;
806
- var key, object = data;
807
- for (key in object) {
808
- if (_hasOwnProperty$2.call(object, key)) {
809
- if (object[key] !== null) return false;
810
- }
811
- }
812
- return true;
813
- }
814
- function constructYamlSet(data) {
815
- return data !== null ? data : {};
816
- }
817
- var set = new type("tag:yaml.org,2002:set", {
818
- kind: "mapping",
819
- resolve: resolveYamlSet,
820
- construct: constructYamlSet
821
- });
822
- var _default = core.extend({
823
- implicit: [
824
- timestamp,
825
- merge
826
- ],
827
- explicit: [
828
- binary,
829
- omap,
830
- pairs,
831
- set
832
- ]
833
- });
834
- var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
835
- var CONTEXT_FLOW_IN = 1;
836
- var CONTEXT_FLOW_OUT = 2;
837
- var CONTEXT_BLOCK_IN = 3;
838
- var CONTEXT_BLOCK_OUT = 4;
839
- var CHOMPING_CLIP = 1;
840
- var CHOMPING_STRIP = 2;
841
- var CHOMPING_KEEP = 3;
842
- var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
843
- var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
844
- var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
845
- var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
846
- var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
847
- function _class(obj) {
848
- return Object.prototype.toString.call(obj);
849
- }
850
- function is_EOL(c) {
851
- return c === 10 || c === 13;
852
- }
853
- function is_WHITE_SPACE(c) {
854
- return c === 9 || c === 32;
855
- }
856
- function is_WS_OR_EOL(c) {
857
- return c === 9 || c === 32 || c === 10 || c === 13;
858
- }
859
- function is_FLOW_INDICATOR(c) {
860
- return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
861
- }
862
- function fromHexCode(c) {
863
- var lc;
864
- if (48 <= c && c <= 57) {
865
- return c - 48;
866
- }
867
- lc = c | 32;
868
- if (97 <= lc && lc <= 102) {
869
- return lc - 97 + 10;
870
- }
871
- return -1;
872
- }
873
- function escapedHexLen(c) {
874
- if (c === 120) {
875
- return 2;
876
- }
877
- if (c === 117) {
878
- return 4;
879
- }
880
- if (c === 85) {
881
- return 8;
882
- }
883
- return 0;
884
- }
885
- function fromDecimalCode(c) {
886
- if (48 <= c && c <= 57) {
887
- return c - 48;
888
- }
889
- return -1;
890
- }
891
- function simpleEscapeSequence(c) {
892
- return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
893
- }
894
- function charFromCodepoint(c) {
895
- if (c <= 65535) {
896
- return String.fromCharCode(c);
897
- }
898
- return String.fromCharCode(
899
- (c - 65536 >> 10) + 55296,
900
- (c - 65536 & 1023) + 56320
901
- );
902
- }
903
- function setProperty(object, key, value) {
904
- if (key === "__proto__") {
905
- Object.defineProperty(object, key, {
906
- configurable: true,
907
- enumerable: true,
908
- writable: true,
909
- value
910
- });
911
- } else {
912
- object[key] = value;
913
- }
914
- }
915
- var simpleEscapeCheck = new Array(256);
916
- var simpleEscapeMap = new Array(256);
917
- for (i = 0; i < 256; i++) {
918
- simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
919
- simpleEscapeMap[i] = simpleEscapeSequence(i);
920
- }
921
- var i;
922
- function State$1(input, options) {
923
- this.input = input;
924
- this.filename = options["filename"] || null;
925
- this.schema = options["schema"] || _default;
926
- this.onWarning = options["onWarning"] || null;
927
- this.legacy = options["legacy"] || false;
928
- this.json = options["json"] || false;
929
- this.listener = options["listener"] || null;
930
- this.implicitTypes = this.schema.compiledImplicit;
931
- this.typeMap = this.schema.compiledTypeMap;
932
- this.length = input.length;
933
- this.position = 0;
934
- this.line = 0;
935
- this.lineStart = 0;
936
- this.lineIndent = 0;
937
- this.firstTabInLine = -1;
938
- this.documents = [];
939
- }
940
- function generateError(state, message) {
941
- var mark = {
942
- name: state.filename,
943
- buffer: state.input.slice(0, -1),
944
- // omit trailing \0
945
- position: state.position,
946
- line: state.line,
947
- column: state.position - state.lineStart
948
- };
949
- mark.snippet = snippet(mark);
950
- return new exception(message, mark);
951
- }
952
- function throwError(state, message) {
953
- throw generateError(state, message);
954
- }
955
- function throwWarning(state, message) {
956
- if (state.onWarning) {
957
- state.onWarning.call(null, generateError(state, message));
958
- }
959
- }
960
- var directiveHandlers = {
961
- YAML: function handleYamlDirective(state, name, args) {
962
- var match, major, minor;
963
- if (state.version !== null) {
964
- throwError(state, "duplication of %YAML directive");
965
- }
966
- if (args.length !== 1) {
967
- throwError(state, "YAML directive accepts exactly one argument");
968
- }
969
- match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
970
- if (match === null) {
971
- throwError(state, "ill-formed argument of the YAML directive");
972
- }
973
- major = parseInt(match[1], 10);
974
- minor = parseInt(match[2], 10);
975
- if (major !== 1) {
976
- throwError(state, "unacceptable YAML version of the document");
977
- }
978
- state.version = args[0];
979
- state.checkLineBreaks = minor < 2;
980
- if (minor !== 1 && minor !== 2) {
981
- throwWarning(state, "unsupported YAML version of the document");
982
- }
983
- },
984
- TAG: function handleTagDirective(state, name, args) {
985
- var handle, prefix;
986
- if (args.length !== 2) {
987
- throwError(state, "TAG directive accepts exactly two arguments");
988
- }
989
- handle = args[0];
990
- prefix = args[1];
991
- if (!PATTERN_TAG_HANDLE.test(handle)) {
992
- throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
993
- }
994
- if (_hasOwnProperty$1.call(state.tagMap, handle)) {
995
- throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
996
- }
997
- if (!PATTERN_TAG_URI.test(prefix)) {
998
- throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
999
- }
1000
- try {
1001
- prefix = decodeURIComponent(prefix);
1002
- } catch (err) {
1003
- throwError(state, "tag prefix is malformed: " + prefix);
1004
- }
1005
- state.tagMap[handle] = prefix;
1006
- }
1007
- };
1008
- function captureSegment(state, start, end, checkJson) {
1009
- var _position, _length, _character, _result;
1010
- if (start < end) {
1011
- _result = state.input.slice(start, end);
1012
- if (checkJson) {
1013
- for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
1014
- _character = _result.charCodeAt(_position);
1015
- if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
1016
- throwError(state, "expected valid JSON character");
1017
- }
1018
- }
1019
- } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1020
- throwError(state, "the stream contains non-printable characters");
1021
- }
1022
- state.result += _result;
1023
- }
1024
- }
1025
- function mergeMappings(state, destination, source, overridableKeys) {
1026
- var sourceKeys, key, index, quantity;
1027
- if (!common.isObject(source)) {
1028
- throwError(state, "cannot merge mappings; the provided source object is unacceptable");
1029
- }
1030
- sourceKeys = Object.keys(source);
1031
- for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1032
- key = sourceKeys[index];
1033
- if (!_hasOwnProperty$1.call(destination, key)) {
1034
- setProperty(destination, key, source[key]);
1035
- overridableKeys[key] = true;
1036
- }
1037
- }
1038
- }
1039
- function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
1040
- var index, quantity;
1041
- if (Array.isArray(keyNode)) {
1042
- keyNode = Array.prototype.slice.call(keyNode);
1043
- for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
1044
- if (Array.isArray(keyNode[index])) {
1045
- throwError(state, "nested arrays are not supported inside keys");
1046
- }
1047
- if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
1048
- keyNode[index] = "[object Object]";
1049
- }
1050
- }
1051
- }
1052
- if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
1053
- keyNode = "[object Object]";
1054
- }
1055
- keyNode = String(keyNode);
1056
- if (_result === null) {
1057
- _result = {};
1058
- }
1059
- if (keyTag === "tag:yaml.org,2002:merge") {
1060
- if (Array.isArray(valueNode)) {
1061
- for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1062
- mergeMappings(state, _result, valueNode[index], overridableKeys);
1063
- }
1064
- } else {
1065
- mergeMappings(state, _result, valueNode, overridableKeys);
1066
- }
1067
- } else {
1068
- if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
1069
- state.line = startLine || state.line;
1070
- state.lineStart = startLineStart || state.lineStart;
1071
- state.position = startPos || state.position;
1072
- throwError(state, "duplicated mapping key");
1073
- }
1074
- setProperty(_result, keyNode, valueNode);
1075
- delete overridableKeys[keyNode];
1076
- }
1077
- return _result;
1078
- }
1079
- function readLineBreak(state) {
1080
- var ch;
1081
- ch = state.input.charCodeAt(state.position);
1082
- if (ch === 10) {
1083
- state.position++;
1084
- } else if (ch === 13) {
1085
- state.position++;
1086
- if (state.input.charCodeAt(state.position) === 10) {
1087
- state.position++;
1088
- }
1089
- } else {
1090
- throwError(state, "a line break is expected");
1091
- }
1092
- state.line += 1;
1093
- state.lineStart = state.position;
1094
- state.firstTabInLine = -1;
1095
- }
1096
- function skipSeparationSpace(state, allowComments, checkIndent) {
1097
- var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
1098
- while (ch !== 0) {
1099
- while (is_WHITE_SPACE(ch)) {
1100
- if (ch === 9 && state.firstTabInLine === -1) {
1101
- state.firstTabInLine = state.position;
1102
- }
1103
- ch = state.input.charCodeAt(++state.position);
1104
- }
1105
- if (allowComments && ch === 35) {
1106
- do {
1107
- ch = state.input.charCodeAt(++state.position);
1108
- } while (ch !== 10 && ch !== 13 && ch !== 0);
1109
- }
1110
- if (is_EOL(ch)) {
1111
- readLineBreak(state);
1112
- ch = state.input.charCodeAt(state.position);
1113
- lineBreaks++;
1114
- state.lineIndent = 0;
1115
- while (ch === 32) {
1116
- state.lineIndent++;
1117
- ch = state.input.charCodeAt(++state.position);
1118
- }
1119
- } else {
1120
- break;
1121
- }
1122
- }
1123
- if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1124
- throwWarning(state, "deficient indentation");
1125
- }
1126
- return lineBreaks;
1127
- }
1128
- function testDocumentSeparator(state) {
1129
- var _position = state.position, ch;
1130
- ch = state.input.charCodeAt(_position);
1131
- if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
1132
- _position += 3;
1133
- ch = state.input.charCodeAt(_position);
1134
- if (ch === 0 || is_WS_OR_EOL(ch)) {
1135
- return true;
1136
- }
1137
- }
1138
- return false;
1139
- }
1140
- function writeFoldedLines(state, count) {
1141
- if (count === 1) {
1142
- state.result += " ";
1143
- } else if (count > 1) {
1144
- state.result += common.repeat("\n", count - 1);
1145
- }
1146
- }
1147
- function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1148
- var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
1149
- ch = state.input.charCodeAt(state.position);
1150
- if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
1151
- return false;
1152
- }
1153
- if (ch === 63 || ch === 45) {
1154
- following = state.input.charCodeAt(state.position + 1);
1155
- if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1156
- return false;
1157
- }
1158
- }
1159
- state.kind = "scalar";
1160
- state.result = "";
1161
- captureStart = captureEnd = state.position;
1162
- hasPendingContent = false;
1163
- while (ch !== 0) {
1164
- if (ch === 58) {
1165
- following = state.input.charCodeAt(state.position + 1);
1166
- if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1167
- break;
1168
- }
1169
- } else if (ch === 35) {
1170
- preceding = state.input.charCodeAt(state.position - 1);
1171
- if (is_WS_OR_EOL(preceding)) {
1172
- break;
1173
- }
1174
- } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1175
- break;
1176
- } else if (is_EOL(ch)) {
1177
- _line = state.line;
1178
- _lineStart = state.lineStart;
1179
- _lineIndent = state.lineIndent;
1180
- skipSeparationSpace(state, false, -1);
1181
- if (state.lineIndent >= nodeIndent) {
1182
- hasPendingContent = true;
1183
- ch = state.input.charCodeAt(state.position);
1184
- continue;
1185
- } else {
1186
- state.position = captureEnd;
1187
- state.line = _line;
1188
- state.lineStart = _lineStart;
1189
- state.lineIndent = _lineIndent;
1190
- break;
1191
- }
1192
- }
1193
- if (hasPendingContent) {
1194
- captureSegment(state, captureStart, captureEnd, false);
1195
- writeFoldedLines(state, state.line - _line);
1196
- captureStart = captureEnd = state.position;
1197
- hasPendingContent = false;
1198
- }
1199
- if (!is_WHITE_SPACE(ch)) {
1200
- captureEnd = state.position + 1;
1201
- }
1202
- ch = state.input.charCodeAt(++state.position);
1203
- }
1204
- captureSegment(state, captureStart, captureEnd, false);
1205
- if (state.result) {
1206
- return true;
1207
- }
1208
- state.kind = _kind;
1209
- state.result = _result;
1210
- return false;
1211
- }
1212
- function readSingleQuotedScalar(state, nodeIndent) {
1213
- var ch, captureStart, captureEnd;
1214
- ch = state.input.charCodeAt(state.position);
1215
- if (ch !== 39) {
1216
- return false;
1217
- }
1218
- state.kind = "scalar";
1219
- state.result = "";
1220
- state.position++;
1221
- captureStart = captureEnd = state.position;
1222
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1223
- if (ch === 39) {
1224
- captureSegment(state, captureStart, state.position, true);
1225
- ch = state.input.charCodeAt(++state.position);
1226
- if (ch === 39) {
1227
- captureStart = state.position;
1228
- state.position++;
1229
- captureEnd = state.position;
1230
- } else {
1231
- return true;
1232
- }
1233
- } else if (is_EOL(ch)) {
1234
- captureSegment(state, captureStart, captureEnd, true);
1235
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1236
- captureStart = captureEnd = state.position;
1237
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1238
- throwError(state, "unexpected end of the document within a single quoted scalar");
1239
- } else {
1240
- state.position++;
1241
- captureEnd = state.position;
1242
- }
1243
- }
1244
- throwError(state, "unexpected end of the stream within a single quoted scalar");
1245
- }
1246
- function readDoubleQuotedScalar(state, nodeIndent) {
1247
- var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
1248
- ch = state.input.charCodeAt(state.position);
1249
- if (ch !== 34) {
1250
- return false;
1251
- }
1252
- state.kind = "scalar";
1253
- state.result = "";
1254
- state.position++;
1255
- captureStart = captureEnd = state.position;
1256
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1257
- if (ch === 34) {
1258
- captureSegment(state, captureStart, state.position, true);
1259
- state.position++;
1260
- return true;
1261
- } else if (ch === 92) {
1262
- captureSegment(state, captureStart, state.position, true);
1263
- ch = state.input.charCodeAt(++state.position);
1264
- if (is_EOL(ch)) {
1265
- skipSeparationSpace(state, false, nodeIndent);
1266
- } else if (ch < 256 && simpleEscapeCheck[ch]) {
1267
- state.result += simpleEscapeMap[ch];
1268
- state.position++;
1269
- } else if ((tmp = escapedHexLen(ch)) > 0) {
1270
- hexLength = tmp;
1271
- hexResult = 0;
1272
- for (; hexLength > 0; hexLength--) {
1273
- ch = state.input.charCodeAt(++state.position);
1274
- if ((tmp = fromHexCode(ch)) >= 0) {
1275
- hexResult = (hexResult << 4) + tmp;
1276
- } else {
1277
- throwError(state, "expected hexadecimal character");
1278
- }
1279
- }
1280
- state.result += charFromCodepoint(hexResult);
1281
- state.position++;
1282
- } else {
1283
- throwError(state, "unknown escape sequence");
1284
- }
1285
- captureStart = captureEnd = state.position;
1286
- } else if (is_EOL(ch)) {
1287
- captureSegment(state, captureStart, captureEnd, true);
1288
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1289
- captureStart = captureEnd = state.position;
1290
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1291
- throwError(state, "unexpected end of the document within a double quoted scalar");
1292
- } else {
1293
- state.position++;
1294
- captureEnd = state.position;
1295
- }
1296
- }
1297
- throwError(state, "unexpected end of the stream within a double quoted scalar");
1298
- }
1299
- function readFlowCollection(state, nodeIndent) {
1300
- var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
1301
- ch = state.input.charCodeAt(state.position);
1302
- if (ch === 91) {
1303
- terminator = 93;
1304
- isMapping = false;
1305
- _result = [];
1306
- } else if (ch === 123) {
1307
- terminator = 125;
1308
- isMapping = true;
1309
- _result = {};
1310
- } else {
1311
- return false;
1312
- }
1313
- if (state.anchor !== null) {
1314
- state.anchorMap[state.anchor] = _result;
1315
- }
1316
- ch = state.input.charCodeAt(++state.position);
1317
- while (ch !== 0) {
1318
- skipSeparationSpace(state, true, nodeIndent);
1319
- ch = state.input.charCodeAt(state.position);
1320
- if (ch === terminator) {
1321
- state.position++;
1322
- state.tag = _tag;
1323
- state.anchor = _anchor;
1324
- state.kind = isMapping ? "mapping" : "sequence";
1325
- state.result = _result;
1326
- return true;
1327
- } else if (!readNext) {
1328
- throwError(state, "missed comma between flow collection entries");
1329
- } else if (ch === 44) {
1330
- throwError(state, "expected the node content, but found ','");
1331
- }
1332
- keyTag = keyNode = valueNode = null;
1333
- isPair = isExplicitPair = false;
1334
- if (ch === 63) {
1335
- following = state.input.charCodeAt(state.position + 1);
1336
- if (is_WS_OR_EOL(following)) {
1337
- isPair = isExplicitPair = true;
1338
- state.position++;
1339
- skipSeparationSpace(state, true, nodeIndent);
1340
- }
1341
- }
1342
- _line = state.line;
1343
- _lineStart = state.lineStart;
1344
- _pos = state.position;
1345
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1346
- keyTag = state.tag;
1347
- keyNode = state.result;
1348
- skipSeparationSpace(state, true, nodeIndent);
1349
- ch = state.input.charCodeAt(state.position);
1350
- if ((isExplicitPair || state.line === _line) && ch === 58) {
1351
- isPair = true;
1352
- ch = state.input.charCodeAt(++state.position);
1353
- skipSeparationSpace(state, true, nodeIndent);
1354
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1355
- valueNode = state.result;
1356
- }
1357
- if (isMapping) {
1358
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
1359
- } else if (isPair) {
1360
- _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
1361
- } else {
1362
- _result.push(keyNode);
1363
- }
1364
- skipSeparationSpace(state, true, nodeIndent);
1365
- ch = state.input.charCodeAt(state.position);
1366
- if (ch === 44) {
1367
- readNext = true;
1368
- ch = state.input.charCodeAt(++state.position);
1369
- } else {
1370
- readNext = false;
1371
- }
1372
- }
1373
- throwError(state, "unexpected end of the stream within a flow collection");
1374
- }
1375
- function readBlockScalar(state, nodeIndent) {
1376
- var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
1377
- ch = state.input.charCodeAt(state.position);
1378
- if (ch === 124) {
1379
- folding = false;
1380
- } else if (ch === 62) {
1381
- folding = true;
1382
- } else {
1383
- return false;
1384
- }
1385
- state.kind = "scalar";
1386
- state.result = "";
1387
- while (ch !== 0) {
1388
- ch = state.input.charCodeAt(++state.position);
1389
- if (ch === 43 || ch === 45) {
1390
- if (CHOMPING_CLIP === chomping) {
1391
- chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
1392
- } else {
1393
- throwError(state, "repeat of a chomping mode identifier");
1394
- }
1395
- } else if ((tmp = fromDecimalCode(ch)) >= 0) {
1396
- if (tmp === 0) {
1397
- throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
1398
- } else if (!detectedIndent) {
1399
- textIndent = nodeIndent + tmp - 1;
1400
- detectedIndent = true;
1401
- } else {
1402
- throwError(state, "repeat of an indentation width identifier");
1403
- }
1404
- } else {
1405
- break;
1406
- }
1407
- }
1408
- if (is_WHITE_SPACE(ch)) {
1409
- do {
1410
- ch = state.input.charCodeAt(++state.position);
1411
- } while (is_WHITE_SPACE(ch));
1412
- if (ch === 35) {
1413
- do {
1414
- ch = state.input.charCodeAt(++state.position);
1415
- } while (!is_EOL(ch) && ch !== 0);
1416
- }
1417
- }
1418
- while (ch !== 0) {
1419
- readLineBreak(state);
1420
- state.lineIndent = 0;
1421
- ch = state.input.charCodeAt(state.position);
1422
- while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
1423
- state.lineIndent++;
1424
- ch = state.input.charCodeAt(++state.position);
1425
- }
1426
- if (!detectedIndent && state.lineIndent > textIndent) {
1427
- textIndent = state.lineIndent;
1428
- }
1429
- if (is_EOL(ch)) {
1430
- emptyLines++;
1431
- continue;
1432
- }
1433
- if (state.lineIndent < textIndent) {
1434
- if (chomping === CHOMPING_KEEP) {
1435
- state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1436
- } else if (chomping === CHOMPING_CLIP) {
1437
- if (didReadContent) {
1438
- state.result += "\n";
1439
- }
1440
- }
1441
- break;
1442
- }
1443
- if (folding) {
1444
- if (is_WHITE_SPACE(ch)) {
1445
- atMoreIndented = true;
1446
- state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1447
- } else if (atMoreIndented) {
1448
- atMoreIndented = false;
1449
- state.result += common.repeat("\n", emptyLines + 1);
1450
- } else if (emptyLines === 0) {
1451
- if (didReadContent) {
1452
- state.result += " ";
1453
- }
1454
- } else {
1455
- state.result += common.repeat("\n", emptyLines);
1456
- }
1457
- } else {
1458
- state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1459
- }
1460
- didReadContent = true;
1461
- detectedIndent = true;
1462
- emptyLines = 0;
1463
- captureStart = state.position;
1464
- while (!is_EOL(ch) && ch !== 0) {
1465
- ch = state.input.charCodeAt(++state.position);
1466
- }
1467
- captureSegment(state, captureStart, state.position, false);
1468
- }
1469
- return true;
1470
- }
1471
- function readBlockSequence(state, nodeIndent) {
1472
- var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
1473
- if (state.firstTabInLine !== -1) return false;
1474
- if (state.anchor !== null) {
1475
- state.anchorMap[state.anchor] = _result;
1476
- }
1477
- ch = state.input.charCodeAt(state.position);
1478
- while (ch !== 0) {
1479
- if (state.firstTabInLine !== -1) {
1480
- state.position = state.firstTabInLine;
1481
- throwError(state, "tab characters must not be used in indentation");
1482
- }
1483
- if (ch !== 45) {
1484
- break;
1485
- }
1486
- following = state.input.charCodeAt(state.position + 1);
1487
- if (!is_WS_OR_EOL(following)) {
1488
- break;
1489
- }
1490
- detected = true;
1491
- state.position++;
1492
- if (skipSeparationSpace(state, true, -1)) {
1493
- if (state.lineIndent <= nodeIndent) {
1494
- _result.push(null);
1495
- ch = state.input.charCodeAt(state.position);
1496
- continue;
1497
- }
1498
- }
1499
- _line = state.line;
1500
- composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1501
- _result.push(state.result);
1502
- skipSeparationSpace(state, true, -1);
1503
- ch = state.input.charCodeAt(state.position);
1504
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1505
- throwError(state, "bad indentation of a sequence entry");
1506
- } else if (state.lineIndent < nodeIndent) {
1507
- break;
1508
- }
1509
- }
1510
- if (detected) {
1511
- state.tag = _tag;
1512
- state.anchor = _anchor;
1513
- state.kind = "sequence";
1514
- state.result = _result;
1515
- return true;
1516
- }
1517
- return false;
1518
- }
1519
- function readBlockMapping(state, nodeIndent, flowIndent) {
1520
- var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
1521
- if (state.firstTabInLine !== -1) return false;
1522
- if (state.anchor !== null) {
1523
- state.anchorMap[state.anchor] = _result;
1524
- }
1525
- ch = state.input.charCodeAt(state.position);
1526
- while (ch !== 0) {
1527
- if (!atExplicitKey && state.firstTabInLine !== -1) {
1528
- state.position = state.firstTabInLine;
1529
- throwError(state, "tab characters must not be used in indentation");
1530
- }
1531
- following = state.input.charCodeAt(state.position + 1);
1532
- _line = state.line;
1533
- if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
1534
- if (ch === 63) {
1535
- if (atExplicitKey) {
1536
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1537
- keyTag = keyNode = valueNode = null;
1538
- }
1539
- detected = true;
1540
- atExplicitKey = true;
1541
- allowCompact = true;
1542
- } else if (atExplicitKey) {
1543
- atExplicitKey = false;
1544
- allowCompact = true;
1545
- } else {
1546
- throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
1547
- }
1548
- state.position += 1;
1549
- ch = following;
1550
- } else {
1551
- _keyLine = state.line;
1552
- _keyLineStart = state.lineStart;
1553
- _keyPos = state.position;
1554
- if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1555
- break;
1556
- }
1557
- if (state.line === _line) {
1558
- ch = state.input.charCodeAt(state.position);
1559
- while (is_WHITE_SPACE(ch)) {
1560
- ch = state.input.charCodeAt(++state.position);
1561
- }
1562
- if (ch === 58) {
1563
- ch = state.input.charCodeAt(++state.position);
1564
- if (!is_WS_OR_EOL(ch)) {
1565
- throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
1566
- }
1567
- if (atExplicitKey) {
1568
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1569
- keyTag = keyNode = valueNode = null;
1570
- }
1571
- detected = true;
1572
- atExplicitKey = false;
1573
- allowCompact = false;
1574
- keyTag = state.tag;
1575
- keyNode = state.result;
1576
- } else if (detected) {
1577
- throwError(state, "can not read an implicit mapping pair; a colon is missed");
1578
- } else {
1579
- state.tag = _tag;
1580
- state.anchor = _anchor;
1581
- return true;
1582
- }
1583
- } else if (detected) {
1584
- throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
1585
- } else {
1586
- state.tag = _tag;
1587
- state.anchor = _anchor;
1588
- return true;
1589
- }
1590
- }
1591
- if (state.line === _line || state.lineIndent > nodeIndent) {
1592
- if (atExplicitKey) {
1593
- _keyLine = state.line;
1594
- _keyLineStart = state.lineStart;
1595
- _keyPos = state.position;
1596
- }
1597
- if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
1598
- if (atExplicitKey) {
1599
- keyNode = state.result;
1600
- } else {
1601
- valueNode = state.result;
1602
- }
1603
- }
1604
- if (!atExplicitKey) {
1605
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
1606
- keyTag = keyNode = valueNode = null;
1607
- }
1608
- skipSeparationSpace(state, true, -1);
1609
- ch = state.input.charCodeAt(state.position);
1610
- }
1611
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1612
- throwError(state, "bad indentation of a mapping entry");
1613
- } else if (state.lineIndent < nodeIndent) {
1614
- break;
1615
- }
1616
- }
1617
- if (atExplicitKey) {
1618
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1619
- }
1620
- if (detected) {
1621
- state.tag = _tag;
1622
- state.anchor = _anchor;
1623
- state.kind = "mapping";
1624
- state.result = _result;
1625
- }
1626
- return detected;
1627
- }
1628
- function readTagProperty(state) {
1629
- var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
1630
- ch = state.input.charCodeAt(state.position);
1631
- if (ch !== 33) return false;
1632
- if (state.tag !== null) {
1633
- throwError(state, "duplication of a tag property");
1634
- }
1635
- ch = state.input.charCodeAt(++state.position);
1636
- if (ch === 60) {
1637
- isVerbatim = true;
1638
- ch = state.input.charCodeAt(++state.position);
1639
- } else if (ch === 33) {
1640
- isNamed = true;
1641
- tagHandle = "!!";
1642
- ch = state.input.charCodeAt(++state.position);
1643
- } else {
1644
- tagHandle = "!";
1645
- }
1646
- _position = state.position;
1647
- if (isVerbatim) {
1648
- do {
1649
- ch = state.input.charCodeAt(++state.position);
1650
- } while (ch !== 0 && ch !== 62);
1651
- if (state.position < state.length) {
1652
- tagName = state.input.slice(_position, state.position);
1653
- ch = state.input.charCodeAt(++state.position);
1654
- } else {
1655
- throwError(state, "unexpected end of the stream within a verbatim tag");
1656
- }
1657
- } else {
1658
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1659
- if (ch === 33) {
1660
- if (!isNamed) {
1661
- tagHandle = state.input.slice(_position - 1, state.position + 1);
1662
- if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
1663
- throwError(state, "named tag handle cannot contain such characters");
1664
- }
1665
- isNamed = true;
1666
- _position = state.position + 1;
1667
- } else {
1668
- throwError(state, "tag suffix cannot contain exclamation marks");
1669
- }
1670
- }
1671
- ch = state.input.charCodeAt(++state.position);
1672
- }
1673
- tagName = state.input.slice(_position, state.position);
1674
- if (PATTERN_FLOW_INDICATORS.test(tagName)) {
1675
- throwError(state, "tag suffix cannot contain flow indicator characters");
1676
- }
1677
- }
1678
- if (tagName && !PATTERN_TAG_URI.test(tagName)) {
1679
- throwError(state, "tag name cannot contain such characters: " + tagName);
1680
- }
1681
- try {
1682
- tagName = decodeURIComponent(tagName);
1683
- } catch (err) {
1684
- throwError(state, "tag name is malformed: " + tagName);
1685
- }
1686
- if (isVerbatim) {
1687
- state.tag = tagName;
1688
- } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
1689
- state.tag = state.tagMap[tagHandle] + tagName;
1690
- } else if (tagHandle === "!") {
1691
- state.tag = "!" + tagName;
1692
- } else if (tagHandle === "!!") {
1693
- state.tag = "tag:yaml.org,2002:" + tagName;
1694
- } else {
1695
- throwError(state, 'undeclared tag handle "' + tagHandle + '"');
1696
- }
1697
- return true;
1698
- }
1699
- function readAnchorProperty(state) {
1700
- var _position, ch;
1701
- ch = state.input.charCodeAt(state.position);
1702
- if (ch !== 38) return false;
1703
- if (state.anchor !== null) {
1704
- throwError(state, "duplication of an anchor property");
1705
- }
1706
- ch = state.input.charCodeAt(++state.position);
1707
- _position = state.position;
1708
- while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1709
- ch = state.input.charCodeAt(++state.position);
1710
- }
1711
- if (state.position === _position) {
1712
- throwError(state, "name of an anchor node must contain at least one character");
1713
- }
1714
- state.anchor = state.input.slice(_position, state.position);
1715
- return true;
1716
- }
1717
- function readAlias(state) {
1718
- var _position, alias, ch;
1719
- ch = state.input.charCodeAt(state.position);
1720
- if (ch !== 42) return false;
1721
- ch = state.input.charCodeAt(++state.position);
1722
- _position = state.position;
1723
- while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1724
- ch = state.input.charCodeAt(++state.position);
1725
- }
1726
- if (state.position === _position) {
1727
- throwError(state, "name of an alias node must contain at least one character");
1728
- }
1729
- alias = state.input.slice(_position, state.position);
1730
- if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
1731
- throwError(state, 'unidentified alias "' + alias + '"');
1732
- }
1733
- state.result = state.anchorMap[alias];
1734
- skipSeparationSpace(state, true, -1);
1735
- return true;
1736
- }
1737
- function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
1738
- var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
1739
- if (state.listener !== null) {
1740
- state.listener("open", state);
1741
- }
1742
- state.tag = null;
1743
- state.anchor = null;
1744
- state.kind = null;
1745
- state.result = null;
1746
- allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
1747
- if (allowToSeek) {
1748
- if (skipSeparationSpace(state, true, -1)) {
1749
- atNewLine = true;
1750
- if (state.lineIndent > parentIndent) {
1751
- indentStatus = 1;
1752
- } else if (state.lineIndent === parentIndent) {
1753
- indentStatus = 0;
1754
- } else if (state.lineIndent < parentIndent) {
1755
- indentStatus = -1;
1756
- }
1757
- }
1758
- }
1759
- if (indentStatus === 1) {
1760
- while (readTagProperty(state) || readAnchorProperty(state)) {
1761
- if (skipSeparationSpace(state, true, -1)) {
1762
- atNewLine = true;
1763
- allowBlockCollections = allowBlockStyles;
1764
- if (state.lineIndent > parentIndent) {
1765
- indentStatus = 1;
1766
- } else if (state.lineIndent === parentIndent) {
1767
- indentStatus = 0;
1768
- } else if (state.lineIndent < parentIndent) {
1769
- indentStatus = -1;
1770
- }
1771
- } else {
1772
- allowBlockCollections = false;
1773
- }
1774
- }
1775
- }
1776
- if (allowBlockCollections) {
1777
- allowBlockCollections = atNewLine || allowCompact;
1778
- }
1779
- if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
1780
- if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
1781
- flowIndent = parentIndent;
1782
- } else {
1783
- flowIndent = parentIndent + 1;
1784
- }
1785
- blockIndent = state.position - state.lineStart;
1786
- if (indentStatus === 1) {
1787
- if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
1788
- hasContent = true;
1789
- } else {
1790
- if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
1791
- hasContent = true;
1792
- } else if (readAlias(state)) {
1793
- hasContent = true;
1794
- if (state.tag !== null || state.anchor !== null) {
1795
- throwError(state, "alias node should not have any properties");
1796
- }
1797
- } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
1798
- hasContent = true;
1799
- if (state.tag === null) {
1800
- state.tag = "?";
1801
- }
1802
- }
1803
- if (state.anchor !== null) {
1804
- state.anchorMap[state.anchor] = state.result;
1805
- }
1806
- }
1807
- } else if (indentStatus === 0) {
1808
- hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
1809
- }
1810
- }
1811
- if (state.tag === null) {
1812
- if (state.anchor !== null) {
1813
- state.anchorMap[state.anchor] = state.result;
1814
- }
1815
- } else if (state.tag === "?") {
1816
- if (state.result !== null && state.kind !== "scalar") {
1817
- throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
1818
- }
1819
- for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
1820
- type2 = state.implicitTypes[typeIndex];
1821
- if (type2.resolve(state.result)) {
1822
- state.result = type2.construct(state.result);
1823
- state.tag = type2.tag;
1824
- if (state.anchor !== null) {
1825
- state.anchorMap[state.anchor] = state.result;
1826
- }
1827
- break;
1828
- }
1829
- }
1830
- } else if (state.tag !== "!") {
1831
- if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
1832
- type2 = state.typeMap[state.kind || "fallback"][state.tag];
1833
- } else {
1834
- type2 = null;
1835
- typeList = state.typeMap.multi[state.kind || "fallback"];
1836
- for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
1837
- if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
1838
- type2 = typeList[typeIndex];
1839
- break;
1840
- }
1841
- }
1842
- }
1843
- if (!type2) {
1844
- throwError(state, "unknown tag !<" + state.tag + ">");
1845
- }
1846
- if (state.result !== null && type2.kind !== state.kind) {
1847
- throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
1848
- }
1849
- if (!type2.resolve(state.result, state.tag)) {
1850
- throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
1851
- } else {
1852
- state.result = type2.construct(state.result, state.tag);
1853
- if (state.anchor !== null) {
1854
- state.anchorMap[state.anchor] = state.result;
1855
- }
1856
- }
1857
- }
1858
- if (state.listener !== null) {
1859
- state.listener("close", state);
1860
- }
1861
- return state.tag !== null || state.anchor !== null || hasContent;
1862
- }
1863
- function readDocument(state) {
1864
- var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
1865
- state.version = null;
1866
- state.checkLineBreaks = state.legacy;
1867
- state.tagMap = /* @__PURE__ */ Object.create(null);
1868
- state.anchorMap = /* @__PURE__ */ Object.create(null);
1869
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1870
- skipSeparationSpace(state, true, -1);
1871
- ch = state.input.charCodeAt(state.position);
1872
- if (state.lineIndent > 0 || ch !== 37) {
1873
- break;
1874
- }
1875
- hasDirectives = true;
1876
- ch = state.input.charCodeAt(++state.position);
1877
- _position = state.position;
1878
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1879
- ch = state.input.charCodeAt(++state.position);
1880
- }
1881
- directiveName = state.input.slice(_position, state.position);
1882
- directiveArgs = [];
1883
- if (directiveName.length < 1) {
1884
- throwError(state, "directive name must not be less than one character in length");
1885
- }
1886
- while (ch !== 0) {
1887
- while (is_WHITE_SPACE(ch)) {
1888
- ch = state.input.charCodeAt(++state.position);
1889
- }
1890
- if (ch === 35) {
1891
- do {
1892
- ch = state.input.charCodeAt(++state.position);
1893
- } while (ch !== 0 && !is_EOL(ch));
1894
- break;
1895
- }
1896
- if (is_EOL(ch)) break;
1897
- _position = state.position;
1898
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1899
- ch = state.input.charCodeAt(++state.position);
1900
- }
1901
- directiveArgs.push(state.input.slice(_position, state.position));
1902
- }
1903
- if (ch !== 0) readLineBreak(state);
1904
- if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
1905
- directiveHandlers[directiveName](state, directiveName, directiveArgs);
1906
- } else {
1907
- throwWarning(state, 'unknown document directive "' + directiveName + '"');
1908
- }
1909
- }
1910
- skipSeparationSpace(state, true, -1);
1911
- if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
1912
- state.position += 3;
1913
- skipSeparationSpace(state, true, -1);
1914
- } else if (hasDirectives) {
1915
- throwError(state, "directives end mark is expected");
1916
- }
1917
- composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
1918
- skipSeparationSpace(state, true, -1);
1919
- if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
1920
- throwWarning(state, "non-ASCII line breaks are interpreted as content");
1921
- }
1922
- state.documents.push(state.result);
1923
- if (state.position === state.lineStart && testDocumentSeparator(state)) {
1924
- if (state.input.charCodeAt(state.position) === 46) {
1925
- state.position += 3;
1926
- skipSeparationSpace(state, true, -1);
1927
- }
1928
- return;
1929
- }
1930
- if (state.position < state.length - 1) {
1931
- throwError(state, "end of the stream or a document separator is expected");
1932
- } else {
1933
- return;
1934
- }
1935
- }
1936
- function loadDocuments(input, options) {
1937
- input = String(input);
1938
- options = options || {};
1939
- if (input.length !== 0) {
1940
- if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
1941
- input += "\n";
1942
- }
1943
- if (input.charCodeAt(0) === 65279) {
1944
- input = input.slice(1);
1945
- }
1946
- }
1947
- var state = new State$1(input, options);
1948
- var nullpos = input.indexOf("\0");
1949
- if (nullpos !== -1) {
1950
- state.position = nullpos;
1951
- throwError(state, "null byte is not allowed in input");
1952
- }
1953
- state.input += "\0";
1954
- while (state.input.charCodeAt(state.position) === 32) {
1955
- state.lineIndent += 1;
1956
- state.position += 1;
1957
- }
1958
- while (state.position < state.length - 1) {
1959
- readDocument(state);
1960
- }
1961
- return state.documents;
1962
- }
1963
- function loadAll$1(input, iterator, options) {
1964
- if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
1965
- options = iterator;
1966
- iterator = null;
1967
- }
1968
- var documents = loadDocuments(input, options);
1969
- if (typeof iterator !== "function") {
1970
- return documents;
1971
- }
1972
- for (var index = 0, length = documents.length; index < length; index += 1) {
1973
- iterator(documents[index]);
1974
- }
1975
- }
1976
- function load$1(input, options) {
1977
- var documents = loadDocuments(input, options);
1978
- if (documents.length === 0) {
1979
- return void 0;
1980
- } else if (documents.length === 1) {
1981
- return documents[0];
1982
- }
1983
- throw new exception("expected a single document in the stream, but found more");
1984
- }
1985
- var loadAll_1 = loadAll$1;
1986
- var load_1 = load$1;
1987
- var loader = {
1988
- loadAll: loadAll_1,
1989
- load: load_1
1990
- };
1991
- var _toString = Object.prototype.toString;
1992
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
1993
- var CHAR_BOM = 65279;
1994
- var CHAR_TAB = 9;
1995
- var CHAR_LINE_FEED = 10;
1996
- var CHAR_CARRIAGE_RETURN = 13;
1997
- var CHAR_SPACE = 32;
1998
- var CHAR_EXCLAMATION = 33;
1999
- var CHAR_DOUBLE_QUOTE = 34;
2000
- var CHAR_SHARP = 35;
2001
- var CHAR_PERCENT = 37;
2002
- var CHAR_AMPERSAND = 38;
2003
- var CHAR_SINGLE_QUOTE = 39;
2004
- var CHAR_ASTERISK = 42;
2005
- var CHAR_COMMA = 44;
2006
- var CHAR_MINUS = 45;
2007
- var CHAR_COLON = 58;
2008
- var CHAR_EQUALS = 61;
2009
- var CHAR_GREATER_THAN = 62;
2010
- var CHAR_QUESTION = 63;
2011
- var CHAR_COMMERCIAL_AT = 64;
2012
- var CHAR_LEFT_SQUARE_BRACKET = 91;
2013
- var CHAR_RIGHT_SQUARE_BRACKET = 93;
2014
- var CHAR_GRAVE_ACCENT = 96;
2015
- var CHAR_LEFT_CURLY_BRACKET = 123;
2016
- var CHAR_VERTICAL_LINE = 124;
2017
- var CHAR_RIGHT_CURLY_BRACKET = 125;
2018
- var ESCAPE_SEQUENCES = {};
2019
- ESCAPE_SEQUENCES[0] = "\\0";
2020
- ESCAPE_SEQUENCES[7] = "\\a";
2021
- ESCAPE_SEQUENCES[8] = "\\b";
2022
- ESCAPE_SEQUENCES[9] = "\\t";
2023
- ESCAPE_SEQUENCES[10] = "\\n";
2024
- ESCAPE_SEQUENCES[11] = "\\v";
2025
- ESCAPE_SEQUENCES[12] = "\\f";
2026
- ESCAPE_SEQUENCES[13] = "\\r";
2027
- ESCAPE_SEQUENCES[27] = "\\e";
2028
- ESCAPE_SEQUENCES[34] = '\\"';
2029
- ESCAPE_SEQUENCES[92] = "\\\\";
2030
- ESCAPE_SEQUENCES[133] = "\\N";
2031
- ESCAPE_SEQUENCES[160] = "\\_";
2032
- ESCAPE_SEQUENCES[8232] = "\\L";
2033
- ESCAPE_SEQUENCES[8233] = "\\P";
2034
- var DEPRECATED_BOOLEANS_SYNTAX = [
2035
- "y",
2036
- "Y",
2037
- "yes",
2038
- "Yes",
2039
- "YES",
2040
- "on",
2041
- "On",
2042
- "ON",
2043
- "n",
2044
- "N",
2045
- "no",
2046
- "No",
2047
- "NO",
2048
- "off",
2049
- "Off",
2050
- "OFF"
2051
- ];
2052
- var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
2053
- function compileStyleMap(schema2, map2) {
2054
- var result, keys, index, length, tag, style, type2;
2055
- if (map2 === null) return {};
2056
- result = {};
2057
- keys = Object.keys(map2);
2058
- for (index = 0, length = keys.length; index < length; index += 1) {
2059
- tag = keys[index];
2060
- style = String(map2[tag]);
2061
- if (tag.slice(0, 2) === "!!") {
2062
- tag = "tag:yaml.org,2002:" + tag.slice(2);
2063
- }
2064
- type2 = schema2.compiledTypeMap["fallback"][tag];
2065
- if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
2066
- style = type2.styleAliases[style];
2067
- }
2068
- result[tag] = style;
2069
- }
2070
- return result;
2071
- }
2072
- function encodeHex(character) {
2073
- var string, handle, length;
2074
- string = character.toString(16).toUpperCase();
2075
- if (character <= 255) {
2076
- handle = "x";
2077
- length = 2;
2078
- } else if (character <= 65535) {
2079
- handle = "u";
2080
- length = 4;
2081
- } else if (character <= 4294967295) {
2082
- handle = "U";
2083
- length = 8;
2084
- } else {
2085
- throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
2086
- }
2087
- return "\\" + handle + common.repeat("0", length - string.length) + string;
2088
- }
2089
- var QUOTING_TYPE_SINGLE = 1;
2090
- var QUOTING_TYPE_DOUBLE = 2;
2091
- function State(options) {
2092
- this.schema = options["schema"] || _default;
2093
- this.indent = Math.max(1, options["indent"] || 2);
2094
- this.noArrayIndent = options["noArrayIndent"] || false;
2095
- this.skipInvalid = options["skipInvalid"] || false;
2096
- this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
2097
- this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
2098
- this.sortKeys = options["sortKeys"] || false;
2099
- this.lineWidth = options["lineWidth"] || 80;
2100
- this.noRefs = options["noRefs"] || false;
2101
- this.noCompatMode = options["noCompatMode"] || false;
2102
- this.condenseFlow = options["condenseFlow"] || false;
2103
- this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
2104
- this.forceQuotes = options["forceQuotes"] || false;
2105
- this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
2106
- this.implicitTypes = this.schema.compiledImplicit;
2107
- this.explicitTypes = this.schema.compiledExplicit;
2108
- this.tag = null;
2109
- this.result = "";
2110
- this.duplicates = [];
2111
- this.usedDuplicates = null;
2112
- }
2113
- function indentString(string, spaces) {
2114
- var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
2115
- while (position < length) {
2116
- next = string.indexOf("\n", position);
2117
- if (next === -1) {
2118
- line = string.slice(position);
2119
- position = length;
2120
- } else {
2121
- line = string.slice(position, next + 1);
2122
- position = next + 1;
2123
- }
2124
- if (line.length && line !== "\n") result += ind;
2125
- result += line;
2126
- }
2127
- return result;
2128
- }
2129
- function generateNextLine(state, level) {
2130
- return "\n" + common.repeat(" ", state.indent * level);
2131
- }
2132
- function testImplicitResolving(state, str2) {
2133
- var index, length, type2;
2134
- for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
2135
- type2 = state.implicitTypes[index];
2136
- if (type2.resolve(str2)) {
2137
- return true;
2138
- }
2139
- }
2140
- return false;
2141
- }
2142
- function isWhitespace(c) {
2143
- return c === CHAR_SPACE || c === CHAR_TAB;
2144
- }
2145
- function isPrintable(c) {
2146
- return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
2147
- }
2148
- function isNsCharOrWhitespace(c) {
2149
- return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
2150
- }
2151
- function isPlainSafe(c, prev, inblock) {
2152
- var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
2153
- var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
2154
- return (
2155
- // ns-plain-safe
2156
- (inblock ? (
2157
- // c = flow-in
2158
- cIsNsCharOrWhitespace
2159
- ) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar
2160
- );
2161
- }
2162
- function isPlainSafeFirst(c) {
2163
- return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
2164
- }
2165
- function isPlainSafeLast(c) {
2166
- return !isWhitespace(c) && c !== CHAR_COLON;
2167
- }
2168
- function codePointAt(string, pos) {
2169
- var first = string.charCodeAt(pos), second;
2170
- if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
2171
- second = string.charCodeAt(pos + 1);
2172
- if (second >= 56320 && second <= 57343) {
2173
- return (first - 55296) * 1024 + second - 56320 + 65536;
2174
- }
2175
- }
2176
- return first;
2177
- }
2178
- function needIndentIndicator(string) {
2179
- var leadingSpaceRe = /^\n* /;
2180
- return leadingSpaceRe.test(string);
2181
- }
2182
- var STYLE_PLAIN = 1;
2183
- var STYLE_SINGLE = 2;
2184
- var STYLE_LITERAL = 3;
2185
- var STYLE_FOLDED = 4;
2186
- var STYLE_DOUBLE = 5;
2187
- function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
2188
- var i;
2189
- var char = 0;
2190
- var prevChar = null;
2191
- var hasLineBreak = false;
2192
- var hasFoldableLine = false;
2193
- var shouldTrackWidth = lineWidth !== -1;
2194
- var previousLineBreak = -1;
2195
- var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
2196
- if (singleLineOnly || forceQuotes) {
2197
- for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2198
- char = codePointAt(string, i);
2199
- if (!isPrintable(char)) {
2200
- return STYLE_DOUBLE;
2201
- }
2202
- plain = plain && isPlainSafe(char, prevChar, inblock);
2203
- prevChar = char;
2204
- }
2205
- } else {
2206
- for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2207
- char = codePointAt(string, i);
2208
- if (char === CHAR_LINE_FEED) {
2209
- hasLineBreak = true;
2210
- if (shouldTrackWidth) {
2211
- hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
2212
- i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
2213
- previousLineBreak = i;
2214
- }
2215
- } else if (!isPrintable(char)) {
2216
- return STYLE_DOUBLE;
2217
- }
2218
- plain = plain && isPlainSafe(char, prevChar, inblock);
2219
- prevChar = char;
2220
- }
2221
- hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
2222
- }
2223
- if (!hasLineBreak && !hasFoldableLine) {
2224
- if (plain && !forceQuotes && !testAmbiguousType(string)) {
2225
- return STYLE_PLAIN;
2226
- }
2227
- return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2228
- }
2229
- if (indentPerLevel > 9 && needIndentIndicator(string)) {
2230
- return STYLE_DOUBLE;
2231
- }
2232
- if (!forceQuotes) {
2233
- return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
2234
- }
2235
- return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2236
- }
2237
- function writeScalar(state, string, level, iskey, inblock) {
2238
- state.dump = (function() {
2239
- if (string.length === 0) {
2240
- return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
2241
- }
2242
- if (!state.noCompatMode) {
2243
- if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
2244
- return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
2245
- }
2246
- }
2247
- var indent = state.indent * Math.max(1, level);
2248
- var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
2249
- var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
2250
- function testAmbiguity(string2) {
2251
- return testImplicitResolving(state, string2);
2252
- }
2253
- switch (chooseScalarStyle(
2254
- string,
2255
- singleLineOnly,
2256
- state.indent,
2257
- lineWidth,
2258
- testAmbiguity,
2259
- state.quotingType,
2260
- state.forceQuotes && !iskey,
2261
- inblock
2262
- )) {
2263
- case STYLE_PLAIN:
2264
- return string;
2265
- case STYLE_SINGLE:
2266
- return "'" + string.replace(/'/g, "''") + "'";
2267
- case STYLE_LITERAL:
2268
- return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
2269
- case STYLE_FOLDED:
2270
- return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
2271
- case STYLE_DOUBLE:
2272
- return '"' + escapeString(string) + '"';
2273
- default:
2274
- throw new exception("impossible error: invalid scalar style");
2275
- }
2276
- })();
2277
- }
2278
- function blockHeader(string, indentPerLevel) {
2279
- var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
2280
- var clip = string[string.length - 1] === "\n";
2281
- var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
2282
- var chomp = keep ? "+" : clip ? "" : "-";
2283
- return indentIndicator + chomp + "\n";
2284
- }
2285
- function dropEndingNewline(string) {
2286
- return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
2287
- }
2288
- function foldString(string, width) {
2289
- var lineRe = /(\n+)([^\n]*)/g;
2290
- var result = (function() {
2291
- var nextLF = string.indexOf("\n");
2292
- nextLF = nextLF !== -1 ? nextLF : string.length;
2293
- lineRe.lastIndex = nextLF;
2294
- return foldLine(string.slice(0, nextLF), width);
2295
- })();
2296
- var prevMoreIndented = string[0] === "\n" || string[0] === " ";
2297
- var moreIndented;
2298
- var match;
2299
- while (match = lineRe.exec(string)) {
2300
- var prefix = match[1], line = match[2];
2301
- moreIndented = line[0] === " ";
2302
- result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
2303
- prevMoreIndented = moreIndented;
2304
- }
2305
- return result;
2306
- }
2307
- function foldLine(line, width) {
2308
- if (line === "" || line[0] === " ") return line;
2309
- var breakRe = / [^ ]/g;
2310
- var match;
2311
- var start = 0, end, curr = 0, next = 0;
2312
- var result = "";
2313
- while (match = breakRe.exec(line)) {
2314
- next = match.index;
2315
- if (next - start > width) {
2316
- end = curr > start ? curr : next;
2317
- result += "\n" + line.slice(start, end);
2318
- start = end + 1;
2319
- }
2320
- curr = next;
2321
- }
2322
- result += "\n";
2323
- if (line.length - start > width && curr > start) {
2324
- result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
2325
- } else {
2326
- result += line.slice(start);
2327
- }
2328
- return result.slice(1);
2329
- }
2330
- function escapeString(string) {
2331
- var result = "";
2332
- var char = 0;
2333
- var escapeSeq;
2334
- for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2335
- char = codePointAt(string, i);
2336
- escapeSeq = ESCAPE_SEQUENCES[char];
2337
- if (!escapeSeq && isPrintable(char)) {
2338
- result += string[i];
2339
- if (char >= 65536) result += string[i + 1];
2340
- } else {
2341
- result += escapeSeq || encodeHex(char);
2342
- }
2343
- }
2344
- return result;
2345
- }
2346
- function writeFlowSequence(state, level, object) {
2347
- var _result = "", _tag = state.tag, index, length, value;
2348
- for (index = 0, length = object.length; index < length; index += 1) {
2349
- value = object[index];
2350
- if (state.replacer) {
2351
- value = state.replacer.call(object, String(index), value);
2352
- }
2353
- if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
2354
- if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
2355
- _result += state.dump;
2356
- }
2357
- }
2358
- state.tag = _tag;
2359
- state.dump = "[" + _result + "]";
2360
- }
2361
- function writeBlockSequence(state, level, object, compact) {
2362
- var _result = "", _tag = state.tag, index, length, value;
2363
- for (index = 0, length = object.length; index < length; index += 1) {
2364
- value = object[index];
2365
- if (state.replacer) {
2366
- value = state.replacer.call(object, String(index), value);
2367
- }
2368
- if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
2369
- if (!compact || _result !== "") {
2370
- _result += generateNextLine(state, level);
2371
- }
2372
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2373
- _result += "-";
2374
- } else {
2375
- _result += "- ";
2376
- }
2377
- _result += state.dump;
2378
- }
2379
- }
2380
- state.tag = _tag;
2381
- state.dump = _result || "[]";
2382
- }
2383
- function writeFlowMapping(state, level, object) {
2384
- var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
2385
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2386
- pairBuffer = "";
2387
- if (_result !== "") pairBuffer += ", ";
2388
- if (state.condenseFlow) pairBuffer += '"';
2389
- objectKey = objectKeyList[index];
2390
- objectValue = object[objectKey];
2391
- if (state.replacer) {
2392
- objectValue = state.replacer.call(object, objectKey, objectValue);
2393
- }
2394
- if (!writeNode(state, level, objectKey, false, false)) {
2395
- continue;
2396
- }
2397
- if (state.dump.length > 1024) pairBuffer += "? ";
2398
- pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
2399
- if (!writeNode(state, level, objectValue, false, false)) {
2400
- continue;
2401
- }
2402
- pairBuffer += state.dump;
2403
- _result += pairBuffer;
2404
- }
2405
- state.tag = _tag;
2406
- state.dump = "{" + _result + "}";
2407
- }
2408
- function writeBlockMapping(state, level, object, compact) {
2409
- var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
2410
- if (state.sortKeys === true) {
2411
- objectKeyList.sort();
2412
- } else if (typeof state.sortKeys === "function") {
2413
- objectKeyList.sort(state.sortKeys);
2414
- } else if (state.sortKeys) {
2415
- throw new exception("sortKeys must be a boolean or a function");
2416
- }
2417
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2418
- pairBuffer = "";
2419
- if (!compact || _result !== "") {
2420
- pairBuffer += generateNextLine(state, level);
2421
- }
2422
- objectKey = objectKeyList[index];
2423
- objectValue = object[objectKey];
2424
- if (state.replacer) {
2425
- objectValue = state.replacer.call(object, objectKey, objectValue);
2426
- }
2427
- if (!writeNode(state, level + 1, objectKey, true, true, true)) {
2428
- continue;
2429
- }
2430
- explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
2431
- if (explicitPair) {
2432
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2433
- pairBuffer += "?";
2434
- } else {
2435
- pairBuffer += "? ";
2436
- }
2437
- }
2438
- pairBuffer += state.dump;
2439
- if (explicitPair) {
2440
- pairBuffer += generateNextLine(state, level);
2441
- }
2442
- if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
2443
- continue;
2444
- }
2445
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2446
- pairBuffer += ":";
2447
- } else {
2448
- pairBuffer += ": ";
2449
- }
2450
- pairBuffer += state.dump;
2451
- _result += pairBuffer;
2452
- }
2453
- state.tag = _tag;
2454
- state.dump = _result || "{}";
2455
- }
2456
- function detectType(state, object, explicit) {
2457
- var _result, typeList, index, length, type2, style;
2458
- typeList = explicit ? state.explicitTypes : state.implicitTypes;
2459
- for (index = 0, length = typeList.length; index < length; index += 1) {
2460
- type2 = typeList[index];
2461
- if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
2462
- if (explicit) {
2463
- if (type2.multi && type2.representName) {
2464
- state.tag = type2.representName(object);
2465
- } else {
2466
- state.tag = type2.tag;
2467
- }
2468
- } else {
2469
- state.tag = "?";
2470
- }
2471
- if (type2.represent) {
2472
- style = state.styleMap[type2.tag] || type2.defaultStyle;
2473
- if (_toString.call(type2.represent) === "[object Function]") {
2474
- _result = type2.represent(object, style);
2475
- } else if (_hasOwnProperty.call(type2.represent, style)) {
2476
- _result = type2.represent[style](object, style);
2477
- } else {
2478
- throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
2479
- }
2480
- state.dump = _result;
2481
- }
2482
- return true;
2483
- }
2484
- }
2485
- return false;
2486
- }
2487
- function writeNode(state, level, object, block, compact, iskey, isblockseq) {
2488
- state.tag = null;
2489
- state.dump = object;
2490
- if (!detectType(state, object, false)) {
2491
- detectType(state, object, true);
2492
- }
2493
- var type2 = _toString.call(state.dump);
2494
- var inblock = block;
2495
- var tagStr;
2496
- if (block) {
2497
- block = state.flowLevel < 0 || state.flowLevel > level;
2498
- }
2499
- var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
2500
- if (objectOrArray) {
2501
- duplicateIndex = state.duplicates.indexOf(object);
2502
- duplicate = duplicateIndex !== -1;
2503
- }
2504
- if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
2505
- compact = false;
2506
- }
2507
- if (duplicate && state.usedDuplicates[duplicateIndex]) {
2508
- state.dump = "*ref_" + duplicateIndex;
2509
- } else {
2510
- if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
2511
- state.usedDuplicates[duplicateIndex] = true;
2512
- }
2513
- if (type2 === "[object Object]") {
2514
- if (block && Object.keys(state.dump).length !== 0) {
2515
- writeBlockMapping(state, level, state.dump, compact);
2516
- if (duplicate) {
2517
- state.dump = "&ref_" + duplicateIndex + state.dump;
2518
- }
2519
- } else {
2520
- writeFlowMapping(state, level, state.dump);
2521
- if (duplicate) {
2522
- state.dump = "&ref_" + duplicateIndex + " " + state.dump;
2523
- }
2524
- }
2525
- } else if (type2 === "[object Array]") {
2526
- if (block && state.dump.length !== 0) {
2527
- if (state.noArrayIndent && !isblockseq && level > 0) {
2528
- writeBlockSequence(state, level - 1, state.dump, compact);
2529
- } else {
2530
- writeBlockSequence(state, level, state.dump, compact);
2531
- }
2532
- if (duplicate) {
2533
- state.dump = "&ref_" + duplicateIndex + state.dump;
2534
- }
2535
- } else {
2536
- writeFlowSequence(state, level, state.dump);
2537
- if (duplicate) {
2538
- state.dump = "&ref_" + duplicateIndex + " " + state.dump;
2539
- }
2540
- }
2541
- } else if (type2 === "[object String]") {
2542
- if (state.tag !== "?") {
2543
- writeScalar(state, state.dump, level, iskey, inblock);
2544
- }
2545
- } else if (type2 === "[object Undefined]") {
2546
- return false;
2547
- } else {
2548
- if (state.skipInvalid) return false;
2549
- throw new exception("unacceptable kind of an object to dump " + type2);
2550
- }
2551
- if (state.tag !== null && state.tag !== "?") {
2552
- tagStr = encodeURI(
2553
- state.tag[0] === "!" ? state.tag.slice(1) : state.tag
2554
- ).replace(/!/g, "%21");
2555
- if (state.tag[0] === "!") {
2556
- tagStr = "!" + tagStr;
2557
- } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
2558
- tagStr = "!!" + tagStr.slice(18);
2559
- } else {
2560
- tagStr = "!<" + tagStr + ">";
2561
- }
2562
- state.dump = tagStr + " " + state.dump;
2563
- }
2564
- }
2565
- return true;
2566
- }
2567
- function getDuplicateReferences(object, state) {
2568
- var objects = [], duplicatesIndexes = [], index, length;
2569
- inspectNode(object, objects, duplicatesIndexes);
2570
- for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
2571
- state.duplicates.push(objects[duplicatesIndexes[index]]);
2572
- }
2573
- state.usedDuplicates = new Array(length);
2574
- }
2575
- function inspectNode(object, objects, duplicatesIndexes) {
2576
- var objectKeyList, index, length;
2577
- if (object !== null && typeof object === "object") {
2578
- index = objects.indexOf(object);
2579
- if (index !== -1) {
2580
- if (duplicatesIndexes.indexOf(index) === -1) {
2581
- duplicatesIndexes.push(index);
2582
- }
2583
- } else {
2584
- objects.push(object);
2585
- if (Array.isArray(object)) {
2586
- for (index = 0, length = object.length; index < length; index += 1) {
2587
- inspectNode(object[index], objects, duplicatesIndexes);
2588
- }
2589
- } else {
2590
- objectKeyList = Object.keys(object);
2591
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2592
- inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
2593
- }
2594
- }
2595
- }
2596
- }
2597
- }
2598
- function dump$1(input, options) {
2599
- options = options || {};
2600
- var state = new State(options);
2601
- if (!state.noRefs) getDuplicateReferences(input, state);
2602
- var value = input;
2603
- if (state.replacer) {
2604
- value = state.replacer.call({ "": value }, "", value);
2605
- }
2606
- if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
2607
- return "";
2608
- }
2609
- var dump_1 = dump$1;
2610
- var dumper = {
2611
- dump: dump_1
2612
- };
2613
- function renamed(from, to) {
2614
- return function() {
2615
- throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
2616
- };
2617
- }
2618
- var load = loader.load;
2619
- var loadAll = loader.loadAll;
2620
- var dump = dumper.dump;
2621
- var safeLoad = renamed("safeLoad", "load");
2622
- var safeLoadAll = renamed("safeLoadAll", "loadAll");
2623
- var safeDump = renamed("safeDump", "dump");
39
+ // src/catalog.ts
40
+ var import_js_yaml = require("js-yaml");
2624
41
 
2625
42
  // src/generated/foundational-flows.ts
2626
43
  var FOUNDATIONAL_FLOWS = {
@@ -3859,9 +1276,9 @@ async function gql(instanceUrl, token, query, variables) {
3859
1276
  headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
3860
1277
  body: JSON.stringify({ query, variables })
3861
1278
  });
3862
- const json2 = await res.json();
3863
- if (json2.errors?.length) throw new Error(json2.errors[0].message);
3864
- return json2.data;
1279
+ const json = await res.json();
1280
+ if (json.errors?.length) throw new Error(json.errors[0].message);
1281
+ return json.data;
3865
1282
  }
3866
1283
  async function fetchFoundationalChatAgents(instanceUrl, token, projectId) {
3867
1284
  const agents = [];
@@ -3915,7 +1332,7 @@ async function fetchCustomAgents(instanceUrl, token, projectId) {
3915
1332
  versionId: item.latestVersion.id
3916
1333
  });
3917
1334
  const yamlStr = cfgData?.aiCatalogAgentFlowConfig;
3918
- const parsed = yamlStr ? load(yamlStr) : void 0;
1335
+ const parsed = yamlStr ? (0, import_js_yaml.load)(yamlStr) : void 0;
3919
1336
  agents.push({
3920
1337
  identifier: item.id,
3921
1338
  name: item.name,
@@ -4344,8 +1761,48 @@ query AiCatalogBuiltInTools {
4344
1761
  nodes {
4345
1762
  id
4346
1763
  name
4347
- title
1764
+ title
1765
+ description
1766
+ }
1767
+ }
1768
+ }`;
1769
+ var CREATE_FLOW_MUTATION = `
1770
+ mutation AiCatalogFlowCreate($input: AiCatalogFlowCreateInput!) {
1771
+ aiCatalogFlowCreate(input: $input) {
1772
+ errors
1773
+ item {
1774
+ id
1775
+ name
1776
+ description
1777
+ itemType
1778
+ public
1779
+ project { id, nameWithNamespace, webUrl }
1780
+ latestVersion {
1781
+ id
1782
+ humanVersionName
1783
+ released
1784
+ ... on AiCatalogFlowVersion { definition }
1785
+ }
1786
+ }
1787
+ }
1788
+ }`;
1789
+ var UPDATE_FLOW_MUTATION = `
1790
+ mutation AiCatalogFlowUpdate($input: AiCatalogFlowUpdateInput!) {
1791
+ aiCatalogFlowUpdate(input: $input) {
1792
+ errors
1793
+ item {
1794
+ id
1795
+ name
4348
1796
  description
1797
+ itemType
1798
+ public
1799
+ project { id, nameWithNamespace, webUrl }
1800
+ latestVersion {
1801
+ id
1802
+ humanVersionName
1803
+ released
1804
+ ... on AiCatalogFlowVersion { definition }
1805
+ }
4349
1806
  }
4350
1807
  }
4351
1808
  }`;
@@ -4464,6 +1921,644 @@ async function listBuiltInTools(instanceUrl, token) {
4464
1921
  const result = await gql(instanceUrl, token, LIST_BUILTIN_TOOLS_QUERY, {});
4465
1922
  return result.aiCatalogBuiltInTools?.nodes ?? [];
4466
1923
  }
1924
+ async function createFlow(instanceUrl, token, projectPath, params) {
1925
+ const projectGid = await resolveProjectGid(instanceUrl, token, projectPath);
1926
+ const input = {
1927
+ projectId: projectGid,
1928
+ name: params.name,
1929
+ description: params.description,
1930
+ public: params.public,
1931
+ definition: params.definition
1932
+ };
1933
+ if (params.release !== void 0) input.release = params.release;
1934
+ const result = await gql(instanceUrl, token, CREATE_FLOW_MUTATION, { input });
1935
+ if (result.aiCatalogFlowCreate.errors.length > 0) {
1936
+ throw new Error(`Failed to create flow: ${result.aiCatalogFlowCreate.errors.join(", ")}`);
1937
+ }
1938
+ return result.aiCatalogFlowCreate.item;
1939
+ }
1940
+ async function updateFlow(instanceUrl, token, itemId, params) {
1941
+ const gid = normalizeItemGid(itemId);
1942
+ const input = { id: gid };
1943
+ if (params.name !== void 0) input.name = params.name;
1944
+ if (params.description !== void 0) input.description = params.description;
1945
+ if (params.public !== void 0) input.public = params.public;
1946
+ if (params.definition !== void 0) input.definition = params.definition;
1947
+ if (params.release !== void 0) input.release = params.release;
1948
+ if (params.versionBump) input.versionBump = params.versionBump;
1949
+ const result = await gql(instanceUrl, token, UPDATE_FLOW_MUTATION, { input });
1950
+ if (result.aiCatalogFlowUpdate.errors.length > 0) {
1951
+ throw new Error(`Failed to update flow: ${result.aiCatalogFlowUpdate.errors.join(", ")}`);
1952
+ }
1953
+ return result.aiCatalogFlowUpdate.item;
1954
+ }
1955
+
1956
+ // src/flow-validator.ts
1957
+ var import_ajv = __toESM(require("ajv"), 1);
1958
+ var import_js_yaml2 = __toESM(require("js-yaml"), 1);
1959
+
1960
+ // vendor/schemas/flow_v2.json
1961
+ var flow_v2_default = {
1962
+ $schema: "http://json-schema.org/draft-07/schema#",
1963
+ title: "Flow Registry v1 Configuration Schema",
1964
+ description: "JSON Schema for validating Flow Registry v1 YAML configuration files",
1965
+ type: "object",
1966
+ required: [
1967
+ "version",
1968
+ "environment",
1969
+ "components",
1970
+ "routers",
1971
+ "flow",
1972
+ "yaml_definition"
1973
+ ],
1974
+ additionalProperties: false,
1975
+ properties: {
1976
+ version: {
1977
+ type: "string",
1978
+ const: "v1",
1979
+ description: "Framework version - must be 'v1' for current stable version"
1980
+ },
1981
+ environment: {
1982
+ type: "string",
1983
+ enum: [
1984
+ "ambient"
1985
+ ],
1986
+ description: "Flow environment declaring expected level of interaction between human and AI agent"
1987
+ },
1988
+ components: {
1989
+ type: "array",
1990
+ minItems: 1,
1991
+ description: "List of components that make up the flow",
1992
+ items: {
1993
+ oneOf: [
1994
+ {
1995
+ $ref: "#/definitions/AgentComponent"
1996
+ },
1997
+ {
1998
+ $ref: "#/definitions/DeterministicStepComponent"
1999
+ },
2000
+ {
2001
+ $ref: "#/definitions/OneOffComponent"
2002
+ }
2003
+ ]
2004
+ }
2005
+ },
2006
+ routers: {
2007
+ type: "array",
2008
+ description: "Define how components connect to each other",
2009
+ items: {
2010
+ $ref: "#/definitions/Router"
2011
+ }
2012
+ },
2013
+ flow: {
2014
+ type: "object",
2015
+ description: "Specify the entry point component and other flow options",
2016
+ properties: {
2017
+ entry_point: {
2018
+ type: "string",
2019
+ description: "Name of first component to run. Examples: 'main_agent', 'initial_step'",
2020
+ pattern: "^[a-zA-Z0-9_]+$"
2021
+ },
2022
+ inputs: {
2023
+ type: "array",
2024
+ description: "Optional additional context schema definitions that can be passed to the flow (in addition to the 'goal')",
2025
+ items: {
2026
+ $ref: "#/definitions/FlowInputCategory"
2027
+ }
2028
+ }
2029
+ },
2030
+ additionalProperties: false
2031
+ },
2032
+ prompts: {
2033
+ type: "array",
2034
+ description: "List of inline prompt templates for flow components to use",
2035
+ items: {
2036
+ $ref: "#/definitions/LocalPrompt"
2037
+ }
2038
+ },
2039
+ yaml_definition: {
2040
+ type: "string"
2041
+ }
2042
+ },
2043
+ definitions: {
2044
+ ComponentName: {
2045
+ type: "string",
2046
+ pattern: "^[a-zA-Z0-9_]+$",
2047
+ description: "Component name must use alphanumeric characters or underscore. Must not include characters such as : and . Examples: 'my_agent', 'step1', 'dataProcessor'"
2048
+ },
2049
+ AgentComponent: {
2050
+ type: "object",
2051
+ required: [
2052
+ "name",
2053
+ "type",
2054
+ "prompt_id"
2055
+ ],
2056
+ additionalProperties: false,
2057
+ properties: {
2058
+ name: {
2059
+ $ref: "#/definitions/ComponentName"
2060
+ },
2061
+ type: {
2062
+ type: "string",
2063
+ const: "AgentComponent"
2064
+ },
2065
+ prompt_id: {
2066
+ type: "string",
2067
+ description: "ID of the prompt template from either the prompt registry or locally defined prompts"
2068
+ },
2069
+ prompt_version: {
2070
+ oneOf: [
2071
+ {
2072
+ type: "string",
2073
+ pattern: "^[~^]?\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$",
2074
+ description: "Semantic version constraint (e.g., '^1.0.0')"
2075
+ },
2076
+ {
2077
+ type: "null",
2078
+ description: "Use locally defined prompt from flow YAML"
2079
+ }
2080
+ ]
2081
+ },
2082
+ inputs: {
2083
+ type: "array",
2084
+ description: "List of input data sources",
2085
+ default: [
2086
+ "context:goal"
2087
+ ],
2088
+ items: {
2089
+ oneOf: [
2090
+ {
2091
+ type: "string",
2092
+ description: "Simple input reference"
2093
+ },
2094
+ {
2095
+ $ref: "#/definitions/InputMapping"
2096
+ }
2097
+ ]
2098
+ }
2099
+ },
2100
+ toolset: {
2101
+ type: "array",
2102
+ description: "List of tools available to the agent. Can be tool names or objects with tool options. Examples: ['read_file', {'create_merge_request_note': {'force_internal': true}}]",
2103
+ items: {
2104
+ oneOf: [
2105
+ {
2106
+ type: "string",
2107
+ description: "Tool name from tools registry"
2108
+ },
2109
+ {
2110
+ type: "object",
2111
+ description: "Tool with options. Key is tool name, value is options object",
2112
+ minProperties: 1,
2113
+ maxProperties: 1,
2114
+ additionalProperties: {
2115
+ type: "object",
2116
+ description: "Tool-specific options as key-value pairs",
2117
+ additionalProperties: {
2118
+ oneOf: [
2119
+ {
2120
+ type: "string"
2121
+ },
2122
+ {
2123
+ type: "number"
2124
+ },
2125
+ {
2126
+ type: "boolean"
2127
+ },
2128
+ {
2129
+ type: "null"
2130
+ },
2131
+ {
2132
+ type: "array",
2133
+ items: {
2134
+ oneOf: [
2135
+ {
2136
+ type: "string"
2137
+ },
2138
+ {
2139
+ type: "number"
2140
+ },
2141
+ {
2142
+ type: "boolean"
2143
+ },
2144
+ {
2145
+ type: "null"
2146
+ }
2147
+ ]
2148
+ }
2149
+ },
2150
+ {
2151
+ type: "object",
2152
+ additionalProperties: {
2153
+ oneOf: [
2154
+ {
2155
+ type: "string"
2156
+ },
2157
+ {
2158
+ type: "number"
2159
+ },
2160
+ {
2161
+ type: "boolean"
2162
+ },
2163
+ {
2164
+ type: "null"
2165
+ }
2166
+ ]
2167
+ }
2168
+ }
2169
+ ]
2170
+ }
2171
+ }
2172
+ }
2173
+ ]
2174
+ }
2175
+ },
2176
+ ui_log_events: {
2177
+ type: "array",
2178
+ description: "UI logging configuration",
2179
+ items: {
2180
+ type: "string",
2181
+ enum: [
2182
+ "on_agent_final_answer",
2183
+ "on_tool_execution_success",
2184
+ "on_tool_execution_failed"
2185
+ ]
2186
+ }
2187
+ },
2188
+ ui_role_as: {
2189
+ type: "string",
2190
+ enum: [
2191
+ "agent",
2192
+ "tool"
2193
+ ],
2194
+ description: "Display role in UI"
2195
+ }
2196
+ }
2197
+ },
2198
+ DeterministicStepComponent: {
2199
+ type: "object",
2200
+ required: [
2201
+ "name",
2202
+ "type",
2203
+ "tool_name"
2204
+ ],
2205
+ additionalProperties: false,
2206
+ properties: {
2207
+ name: {
2208
+ $ref: "#/definitions/ComponentName"
2209
+ },
2210
+ type: {
2211
+ type: "string",
2212
+ const: "DeterministicStepComponent"
2213
+ },
2214
+ tool_name: {
2215
+ type: "string",
2216
+ description: "Name of the single tool to execute"
2217
+ },
2218
+ toolset: {
2219
+ type: "array",
2220
+ description: "Toolset containing the tool to be executed",
2221
+ items: {
2222
+ type: "string"
2223
+ }
2224
+ },
2225
+ inputs: {
2226
+ type: "array",
2227
+ description: "List of input data sources to extract tool parameters",
2228
+ default: [],
2229
+ items: {
2230
+ oneOf: [
2231
+ {
2232
+ type: "string",
2233
+ description: "Simple input reference. Examples: 'context:goal'"
2234
+ },
2235
+ {
2236
+ $ref: "#/definitions/InputMapping"
2237
+ }
2238
+ ]
2239
+ }
2240
+ },
2241
+ ui_log_events: {
2242
+ type: "array",
2243
+ description: "UI logging configuration for displaying tool execution",
2244
+ items: {
2245
+ type: "string",
2246
+ enum: [
2247
+ "on_tool_execution_success",
2248
+ "on_tool_execution_failed"
2249
+ ]
2250
+ }
2251
+ },
2252
+ ui_role_as: {
2253
+ type: "string",
2254
+ enum: [
2255
+ "agent",
2256
+ "tool"
2257
+ ],
2258
+ default: "tool",
2259
+ description: "Display role in UI"
2260
+ }
2261
+ }
2262
+ },
2263
+ OneOffComponent: {
2264
+ type: "object",
2265
+ required: [
2266
+ "name",
2267
+ "type",
2268
+ "prompt_id",
2269
+ "toolset"
2270
+ ],
2271
+ additionalProperties: false,
2272
+ properties: {
2273
+ name: {
2274
+ $ref: "#/definitions/ComponentName"
2275
+ },
2276
+ type: {
2277
+ type: "string",
2278
+ const: "OneOffComponent"
2279
+ },
2280
+ prompt_id: {
2281
+ type: "string",
2282
+ description: "ID of the prompt template from either the prompt registry or locally defined prompts"
2283
+ },
2284
+ prompt_version: {
2285
+ oneOf: [
2286
+ {
2287
+ type: "string",
2288
+ pattern: "^[~^]?\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$",
2289
+ description: "Semantic version constraint. Examples: '1.0.0' (exact), '^1.2.3' (compatible)"
2290
+ },
2291
+ {
2292
+ type: "null",
2293
+ description: "Use locally defined prompt from flow YAML"
2294
+ }
2295
+ ]
2296
+ },
2297
+ toolset: {
2298
+ type: "array",
2299
+ minItems: 1,
2300
+ description: "List of tools available to the component. Examples: ['read_file', 'list_dir', 'edit_file']",
2301
+ items: {
2302
+ type: "string",
2303
+ description: "Tool name from tools registry"
2304
+ }
2305
+ },
2306
+ inputs: {
2307
+ type: "array",
2308
+ description: "List of input data sources",
2309
+ default: [
2310
+ "context:goal"
2311
+ ],
2312
+ items: {
2313
+ oneOf: [
2314
+ {
2315
+ type: "string",
2316
+ description: "Simple input reference. Examples: 'context:goal'"
2317
+ },
2318
+ {
2319
+ $ref: "#/definitions/InputMapping"
2320
+ }
2321
+ ]
2322
+ }
2323
+ },
2324
+ max_correction_attempts: {
2325
+ type: "integer",
2326
+ minimum: 0,
2327
+ default: 3,
2328
+ description: "Maximum number of retry attempts for failed tool executions"
2329
+ },
2330
+ ui_log_events: {
2331
+ type: "array",
2332
+ description: "UI logging configuration for displaying tool execution progress",
2333
+ items: {
2334
+ type: "string",
2335
+ enum: [
2336
+ "on_tool_call_input",
2337
+ "on_tool_execution_success",
2338
+ "on_tool_execution_failed"
2339
+ ]
2340
+ }
2341
+ }
2342
+ }
2343
+ },
2344
+ InputMapping: {
2345
+ type: "object",
2346
+ required: [
2347
+ "from",
2348
+ "as"
2349
+ ],
2350
+ additionalProperties: false,
2351
+ properties: {
2352
+ from: {
2353
+ type: "string",
2354
+ description: "Source of the input data. Examples: 'context:goal'"
2355
+ },
2356
+ as: {
2357
+ type: "string",
2358
+ description: "Variable name to use in prompt template. Examples: 'user_goal'"
2359
+ },
2360
+ literal: {
2361
+ type: "boolean",
2362
+ description: "Whether the 'from' value should be treated as a literal value"
2363
+ }
2364
+ }
2365
+ },
2366
+ Router: {
2367
+ type: "object",
2368
+ required: [
2369
+ "from"
2370
+ ],
2371
+ additionalProperties: false,
2372
+ properties: {
2373
+ from: {
2374
+ type: "string",
2375
+ description: "Source component name. Examples: 'main_agent', 'data_processor'"
2376
+ },
2377
+ to: {
2378
+ type: "string",
2379
+ description: "Target component name or 'end'. Examples: 'next_step', 'error_handler', 'end'"
2380
+ },
2381
+ condition: {
2382
+ $ref: "#/definitions/RouterCondition"
2383
+ }
2384
+ },
2385
+ oneOf: [
2386
+ {
2387
+ required: [
2388
+ "to"
2389
+ ]
2390
+ },
2391
+ {
2392
+ required: [
2393
+ "condition"
2394
+ ]
2395
+ }
2396
+ ]
2397
+ },
2398
+ RouterCondition: {
2399
+ type: "object",
2400
+ required: [
2401
+ "input",
2402
+ "routes"
2403
+ ],
2404
+ additionalProperties: false,
2405
+ properties: {
2406
+ input: {
2407
+ type: "string",
2408
+ description: "Input to evaluate for routing decision"
2409
+ },
2410
+ routes: {
2411
+ type: "object",
2412
+ description: "Mapping of condition values to target components",
2413
+ patternProperties: {
2414
+ ".*": {
2415
+ type: "string",
2416
+ description: "Target component name or 'end'"
2417
+ }
2418
+ }
2419
+ }
2420
+ }
2421
+ },
2422
+ LocalPrompt: {
2423
+ type: "object",
2424
+ required: [
2425
+ "prompt_id",
2426
+ "name",
2427
+ "prompt_template",
2428
+ "unit_primitives"
2429
+ ],
2430
+ additionalProperties: false,
2431
+ properties: {
2432
+ prompt_id: {
2433
+ type: "string",
2434
+ description: "Unique identifier for the local prompt"
2435
+ },
2436
+ name: {
2437
+ type: "string",
2438
+ description: "name for the local prompt"
2439
+ },
2440
+ prompt_template: {
2441
+ $ref: "#/definitions/PromptTemplate"
2442
+ },
2443
+ params: {
2444
+ type: "object",
2445
+ properties: {
2446
+ timeout: {
2447
+ type: "integer",
2448
+ minimum: 1,
2449
+ description: "Timeout in seconds for prompt execution"
2450
+ },
2451
+ vertex_location: {
2452
+ type: "string",
2453
+ description: "Vertex AI location for the flow"
2454
+ }
2455
+ },
2456
+ additionalProperties: false
2457
+ },
2458
+ unit_primitives: {
2459
+ type: "array",
2460
+ description: "Unit primitives configuration",
2461
+ items: {
2462
+ type: "string"
2463
+ }
2464
+ }
2465
+ }
2466
+ },
2467
+ PromptTemplate: {
2468
+ type: "object",
2469
+ additionalProperties: false,
2470
+ properties: {
2471
+ system: {
2472
+ type: "string",
2473
+ description: "System message template"
2474
+ },
2475
+ user: {
2476
+ type: "string",
2477
+ description: "User message template"
2478
+ },
2479
+ placeholder: {
2480
+ type: "string",
2481
+ enum: [
2482
+ "history"
2483
+ ],
2484
+ description: "Message placeholder for conversation history"
2485
+ }
2486
+ }
2487
+ },
2488
+ FlowInputCategory: {
2489
+ type: "object",
2490
+ required: [
2491
+ "category",
2492
+ "input_schema"
2493
+ ],
2494
+ additionalProperties: false,
2495
+ description: "Defines a category of additional context inputs that can be passed to the flow",
2496
+ properties: {
2497
+ category: {
2498
+ type: "string",
2499
+ description: "Category name for the additional context. Examples: 'merge_request_info', 'pipeline_info'"
2500
+ },
2501
+ input_schema: {
2502
+ type: "object",
2503
+ description: "Schema definition for the inputs in this category",
2504
+ patternProperties: {
2505
+ ".*": {
2506
+ $ref: "#/definitions/FlowInputField"
2507
+ }
2508
+ }
2509
+ }
2510
+ }
2511
+ },
2512
+ FlowInputField: {
2513
+ type: "object",
2514
+ required: [
2515
+ "type"
2516
+ ],
2517
+ additionalProperties: false,
2518
+ description: "Schema definition for a single input field",
2519
+ properties: {
2520
+ type: {
2521
+ type: "string",
2522
+ description: "JSON Schema type for the field. Examples: 'string'"
2523
+ },
2524
+ format: {
2525
+ type: "string",
2526
+ description: "Optional JSON Schema format specifier. Examples: 'uri', 'email', 'date-time'"
2527
+ },
2528
+ description: {
2529
+ type: "string",
2530
+ description: "Optional description of the field's purpose"
2531
+ }
2532
+ }
2533
+ }
2534
+ }
2535
+ };
2536
+
2537
+ // src/flow-validator.ts
2538
+ function validateFlowYaml(yamlString) {
2539
+ let parsed;
2540
+ try {
2541
+ parsed = import_js_yaml2.default.load(yamlString);
2542
+ } catch (e) {
2543
+ const msg = e instanceof Error ? e.message : String(e);
2544
+ return { valid: false, errors: [`Invalid YAML syntax: ${msg}`] };
2545
+ }
2546
+ if (!parsed || typeof parsed !== "object") {
2547
+ return { valid: false, errors: ["YAML must be an object"] };
2548
+ }
2549
+ parsed.yaml_definition = yamlString;
2550
+ const ajv = new import_ajv.default({ allErrors: true, strict: false });
2551
+ const validate = ajv.compile(flow_v2_default);
2552
+ const valid = validate(parsed);
2553
+ if (!valid && validate.errors) {
2554
+ const errors = validate.errors.map((e) => {
2555
+ const path = e.instancePath || "/";
2556
+ return `${path}: ${e.message}`;
2557
+ });
2558
+ return { valid: false, errors };
2559
+ }
2560
+ return { valid: true, errors: [] };
2561
+ }
4467
2562
 
4468
2563
  // src/agents.ts
4469
2564
  function resolveModelId(entry) {
@@ -4686,6 +2781,166 @@ Before calling gitlab_create_agent, you MUST:
4686
2781
  3. Show the generated system prompt and ask for confirmation.
4687
2782
  4. Only then call gitlab_create_agent. Use full tool GIDs like "gid://gitlab/Ai::Catalog::BuiltInTool/1".
4688
2783
  5. Ask if the user wants to enable it on the current project.`;
2784
+ var FLOW_SCHEMA_REFERENCE = `## Flow YAML Schema Reference
2785
+
2786
+ ### Top-level structure (all required unless noted):
2787
+ version: "v1" # Always "v1"
2788
+ environment: ambient # Always "ambient"
2789
+ components: [...] # Array of components (min 1)
2790
+ routers: [...] # Array of routers connecting components
2791
+ flow:
2792
+ entry_point: "component_name" # First component to run
2793
+ inputs: [...] # Optional: additional context inputs
2794
+ prompts: [...] # Optional: inline prompt definitions
2795
+
2796
+ ### Component types:
2797
+
2798
+ 1. DeterministicStepComponent \u2014 runs ONE tool, no LLM call:
2799
+ - name: "fetch_data" # alphanumeric + underscore only
2800
+ type: DeterministicStepComponent
2801
+ tool_name: "get_merge_request"
2802
+ inputs: # map tool parameters
2803
+ - { from: "context:goal", as: "merge_request_iid" }
2804
+ - { from: "context:project_id", as: "project_id" }
2805
+
2806
+ 2. OneOffComponent \u2014 single LLM call + tool execution:
2807
+ - name: "process_data"
2808
+ type: OneOffComponent
2809
+ prompt_id: "my_prompt" # references inline prompt
2810
+ prompt_version: null # null = use inline prompt from prompts section
2811
+ toolset: ["read_file", "edit_file"]
2812
+ inputs:
2813
+ - { from: "context:fetch_data.tool_responses", as: "data" }
2814
+ max_correction_attempts: 3 # retries on tool failure (default 3)
2815
+
2816
+ 3. AgentComponent \u2014 multi-turn LLM reasoning loop:
2817
+ - name: "analyze"
2818
+ type: AgentComponent
2819
+ prompt_id: "my_agent_prompt"
2820
+ prompt_version: null
2821
+ toolset: ["read_file", "grep"]
2822
+ inputs:
2823
+ - { from: "context:goal", as: "user_goal" }
2824
+ ui_log_events: ["on_agent_final_answer"]
2825
+
2826
+ ### IOKey syntax (inputs/from values):
2827
+ "context:goal" # The flow goal (user input)
2828
+ "context:project_id" # Project ID (auto-injected)
2829
+ "context:<component_name>.tool_responses" # Tool output from a component
2830
+ "context:<component_name>.final_answer" # Agent's final text answer
2831
+ "context:<component_name>.execution_result" # OneOff execution result
2832
+ { from: "context:x", as: "var_name" } # Rename for prompt template
2833
+ { from: "true", as: "flag", literal: true } # Literal value
2834
+
2835
+ ### Router patterns:
2836
+ Direct: { from: "step1", to: "step2" }
2837
+ To end: { from: "last_step", to: "end" }
2838
+ Conditional: { from: "step1", condition: { input: "context:step1.final_answer.decision", routes: { "yes": "step2", "no": "end" } } }
2839
+
2840
+ ### Inline prompts (in prompts section):
2841
+ - prompt_id: "my_prompt"
2842
+ name: "My Prompt"
2843
+ unit_primitives: ["duo_agent_platform"] # Always this value
2844
+ prompt_template:
2845
+ system: "You are a helpful assistant. {{var_name}} is available."
2846
+ user: "Process: {{data}}"
2847
+ placeholder: "history" # Optional, for AgentComponent conversation history
2848
+
2849
+ ### Tool names: use names from gitlab_list_builtin_tools (e.g., "read_file", "get_merge_request", "create_merge_request_note").`;
2850
+ var FLOW_EXAMPLE_LINEAR = `## Example: Simple linear flow (fetch MR \u2192 analyze \u2192 post comment)
2851
+ \`\`\`yaml
2852
+ version: "v1"
2853
+ environment: ambient
2854
+ components:
2855
+ - name: fetch_mr
2856
+ type: DeterministicStepComponent
2857
+ tool_name: build_review_merge_request_context
2858
+ inputs:
2859
+ - { from: "context:project_id", as: "project_id" }
2860
+ - { from: "context:goal", as: "merge_request_iid" }
2861
+ ui_log_events: ["on_tool_execution_success", "on_tool_execution_failed"]
2862
+ - name: analyze_and_comment
2863
+ type: OneOffComponent
2864
+ prompt_id: review_prompt
2865
+ prompt_version: null
2866
+ toolset: ["create_merge_request_note"]
2867
+ inputs:
2868
+ - { from: "context:fetch_mr.tool_responses", as: "mr_data" }
2869
+ - { from: "context:project_id", as: "project_id" }
2870
+ - { from: "context:goal", as: "merge_request_iid" }
2871
+ max_correction_attempts: 3
2872
+ ui_log_events: ["on_tool_execution_success"]
2873
+ routers:
2874
+ - { from: fetch_mr, to: analyze_and_comment }
2875
+ - { from: analyze_and_comment, to: end }
2876
+ flow:
2877
+ entry_point: fetch_mr
2878
+ prompts:
2879
+ - prompt_id: review_prompt
2880
+ name: MR Review Prompt
2881
+ unit_primitives: ["duo_agent_platform"]
2882
+ prompt_template:
2883
+ system: |
2884
+ You review merge requests. Analyze the MR data and post a concise review comment.
2885
+ Focus on code quality, potential bugs, and improvements.
2886
+ user: "Review MR !{{merge_request_iid}} in project {{project_id}}: {{mr_data}}"
2887
+ \`\`\``;
2888
+ var FLOW_EXAMPLE_CONDITIONAL = `## Example: Conditional flow (gather data \u2192 decide \u2192 branch)
2889
+ \`\`\`yaml
2890
+ version: "v1"
2891
+ environment: ambient
2892
+ components:
2893
+ - name: gather_context
2894
+ type: DeterministicStepComponent
2895
+ tool_name: get_vulnerability_details
2896
+ inputs:
2897
+ - { from: "context:goal", as: "vulnerability_id" }
2898
+ ui_log_events: ["on_tool_execution_success"]
2899
+ - name: evaluate
2900
+ type: AgentComponent
2901
+ prompt_id: eval_prompt
2902
+ prompt_version: null
2903
+ toolset: []
2904
+ inputs:
2905
+ - { from: "context:gather_context.tool_responses", as: "vuln_data" }
2906
+ ui_log_events: ["on_agent_final_answer"]
2907
+ - name: create_fix
2908
+ type: AgentComponent
2909
+ prompt_id: fix_prompt
2910
+ prompt_version: null
2911
+ toolset: ["read_file", "edit_file", "grep"]
2912
+ inputs:
2913
+ - { from: "context:gather_context.tool_responses", as: "vuln_data" }
2914
+ ui_log_events: ["on_agent_final_answer", "on_tool_execution_success"]
2915
+ routers:
2916
+ - { from: gather_context, to: evaluate }
2917
+ - from: evaluate
2918
+ condition:
2919
+ input: "context:evaluate.final_answer"
2920
+ routes:
2921
+ "fix_needed": create_fix
2922
+ "false_positive": end
2923
+ default_route: end
2924
+ - { from: create_fix, to: end }
2925
+ flow:
2926
+ entry_point: gather_context
2927
+ prompts:
2928
+ - prompt_id: eval_prompt
2929
+ name: Vulnerability Evaluator
2930
+ unit_primitives: ["duo_agent_platform"]
2931
+ prompt_template:
2932
+ system: |
2933
+ Evaluate if a vulnerability needs fixing. Respond with exactly "fix_needed" or "false_positive".
2934
+ user: "Evaluate: {{vuln_data}}"
2935
+ - prompt_id: fix_prompt
2936
+ name: Fix Generator
2937
+ unit_primitives: ["duo_agent_platform"]
2938
+ prompt_template:
2939
+ system: |
2940
+ You fix security vulnerabilities. Read the relevant code and apply the fix.
2941
+ user: "Fix this vulnerability: {{vuln_data}}"
2942
+ placeholder: history
2943
+ \`\`\``;
4689
2944
  var plugin = async (input) => {
4690
2945
  let authCache = null;
4691
2946
  let projectPath;
@@ -4695,7 +2950,7 @@ var plugin = async (input) => {
4695
2950
  let cachedAgents = [];
4696
2951
  let cfgRef = null;
4697
2952
  let baseModelIdRef;
4698
- async function load2() {
2953
+ async function load() {
4699
2954
  const auth = readAuth();
4700
2955
  if (!auth) return null;
4701
2956
  authCache = auth;
@@ -4717,7 +2972,7 @@ var plugin = async (input) => {
4717
2972
  if (!authCache || !cfgRef) return;
4718
2973
  const key = `${input.directory}\0${authCache.instanceUrl}`;
4719
2974
  memo.delete(key);
4720
- const result = await load2();
2975
+ const result = await load();
4721
2976
  if (!result) return;
4722
2977
  const previousNames = /* @__PURE__ */ new Set([
4723
2978
  ...flowAgents.keys(),
@@ -4770,7 +3025,7 @@ var plugin = async (input) => {
4770
3025
  }
4771
3026
  return {
4772
3027
  async config(cfg) {
4773
- const result = await load2();
3028
+ const result = await load();
4774
3029
  if (!result?.agents.length) return;
4775
3030
  cachedAgents = result.agents;
4776
3031
  const baseModelId = resolveModelId(result.entry);
@@ -5161,6 +3416,132 @@ User goal: "${rawText2}"`;
5161
3416
  return JSON.stringify(tools, null, 2);
5162
3417
  }
5163
3418
  }),
3419
+ gitlab_design_flow: (0, import_plugin.tool)({
3420
+ description: "Interactive flow design tool. Returns the flow YAML schema reference, examples, and instructions.\nUse this BEFORE gitlab_create_flow to design the flow definition interactively with the user.\nThe tool also validates generated YAML against the flow_v2 JSON schema.",
3421
+ args: {
3422
+ action: z.enum(["get_schema", "validate"]).describe(
3423
+ '"get_schema" returns the schema reference and examples. "validate" validates a YAML definition.'
3424
+ ),
3425
+ definition: z.string().optional().describe("YAML definition to validate (required when action=validate)")
3426
+ },
3427
+ execute: async (args) => {
3428
+ if (args.action === "validate") {
3429
+ if (!args.definition) return "Error: definition is required for validate action.";
3430
+ const result = validateFlowYaml(args.definition);
3431
+ if (result.valid) return "VALID: Flow definition passes schema validation.";
3432
+ return `INVALID: ${result.errors.length} error(s):
3433
+ ${result.errors.map((e, i) => ` ${i + 1}. ${e}`).join("\n")}`;
3434
+ }
3435
+ return [
3436
+ "Follow this multi-round workflow to design a flow:",
3437
+ "",
3438
+ "ROUND 1: Call gitlab_list_builtin_tools to discover available tool names for the flow.",
3439
+ " Then use the question tool to ask the user:",
3440
+ " - Flow name",
3441
+ " - Visibility: Public or Private",
3442
+ " - What the flow should do (step-by-step description)",
3443
+ " - What GitLab resource it operates on (MR, issue, pipeline, vulnerability, etc.)",
3444
+ "",
3445
+ "ROUND 2: Based on the user's answers, propose a component architecture in plain text:",
3446
+ " - List each step with its type (DeterministicStep, OneOff, or Agent)",
3447
+ " - Explain what each step does and what tools it uses",
3448
+ " - Show the routing (linear or conditional)",
3449
+ " Ask the user to confirm or adjust.",
3450
+ "",
3451
+ "ROUND 3: Generate the full YAML definition using the schema below.",
3452
+ " Call gitlab_design_flow with action='validate' to check it.",
3453
+ " Show the validated YAML to the user for final approval.",
3454
+ " Then call gitlab_create_flow with confirmed=true.",
3455
+ "",
3456
+ "=== FLOW YAML SCHEMA ===",
3457
+ FLOW_SCHEMA_REFERENCE,
3458
+ "",
3459
+ "=== EXAMPLE: Linear flow ===",
3460
+ FLOW_EXAMPLE_LINEAR,
3461
+ "",
3462
+ "=== EXAMPLE: Conditional flow ===",
3463
+ FLOW_EXAMPLE_CONDITIONAL
3464
+ ].join("\n");
3465
+ }
3466
+ }),
3467
+ gitlab_create_flow: (0, import_plugin.tool)({
3468
+ description: "Create a custom flow in the GitLab AI Catalog.\nFirst call: set confirmed=false (or omit). Returns instructions to use gitlab_design_flow first.\nSecond call: after the user confirms, set confirmed=true to create the flow.\nAfter creation, use gitlab_enable_project_flow to enable it on a project.",
3469
+ args: {
3470
+ project_id: z.string().describe('Project path (e.g., "gitlab-org/gitlab")'),
3471
+ name: z.string().describe("Display name for the flow"),
3472
+ description: z.string().describe("Description of what the flow does"),
3473
+ public: z.boolean().describe("Whether publicly visible in the AI Catalog"),
3474
+ definition: z.string().describe("Flow YAML definition (validated via gitlab_design_flow)"),
3475
+ release: z.boolean().optional().describe("Whether to release the version immediately"),
3476
+ confirmed: z.boolean().optional().describe("Set true only after user has reviewed the YAML")
3477
+ },
3478
+ execute: async (args) => {
3479
+ if (!args.confirmed) {
3480
+ return [
3481
+ "STOP: Do not create the flow yet.",
3482
+ "",
3483
+ "Call gitlab_design_flow with action='get_schema' first to get the interactive workflow.",
3484
+ "Follow the multi-round design process, then call this tool with confirmed=true."
3485
+ ].join("\n");
3486
+ }
3487
+ const validation = validateFlowYaml(args.definition);
3488
+ if (!validation.valid) {
3489
+ return `Flow YAML validation failed:
3490
+ ${validation.errors.map((e, i) => ` ${i + 1}. ${e}`).join("\n")}
3491
+
3492
+ Fix the errors and try again.`;
3493
+ }
3494
+ const auth = authCache ?? readAuth();
3495
+ if (!auth) throw new Error("Not authenticated");
3496
+ const result = await createFlow(auth.instanceUrl, auth.token, args.project_id, {
3497
+ name: args.name,
3498
+ description: args.description,
3499
+ public: args.public,
3500
+ definition: args.definition,
3501
+ release: args.release
3502
+ });
3503
+ await refreshAgents();
3504
+ const json = JSON.stringify(result, null, 2);
3505
+ return `${json}
3506
+
3507
+ Flow created successfully. Ask the user if they want to enable it on the current project using gitlab_enable_project_flow.`;
3508
+ }
3509
+ }),
3510
+ gitlab_update_flow: (0, import_plugin.tool)({
3511
+ description: "Update an existing custom flow in the GitLab AI Catalog.\nOnly provided fields are updated; omitted fields remain unchanged.\nUse gitlab_design_flow with action='validate' to check YAML before updating.",
3512
+ args: {
3513
+ id: z.string().describe("Flow ID (numeric or full GID)"),
3514
+ name: z.string().optional().describe("New display name"),
3515
+ description: z.string().optional().describe("New description"),
3516
+ public: z.boolean().optional().describe("Whether publicly visible"),
3517
+ definition: z.string().optional().describe("New flow YAML definition"),
3518
+ release: z.boolean().optional().describe("Whether to release the latest version"),
3519
+ version_bump: z.enum(["MAJOR", "MINOR", "PATCH"]).optional().describe("Version bump type")
3520
+ },
3521
+ execute: async (args) => {
3522
+ if (args.definition) {
3523
+ const validation = validateFlowYaml(args.definition);
3524
+ if (!validation.valid) {
3525
+ return `Flow YAML validation failed:
3526
+ ${validation.errors.map((e, i) => ` ${i + 1}. ${e}`).join("\n")}
3527
+
3528
+ Fix the errors and try again.`;
3529
+ }
3530
+ }
3531
+ const auth = authCache ?? readAuth();
3532
+ if (!auth) throw new Error("Not authenticated");
3533
+ const result = await updateFlow(auth.instanceUrl, auth.token, args.id, {
3534
+ name: args.name,
3535
+ description: args.description,
3536
+ public: args.public,
3537
+ definition: args.definition,
3538
+ release: args.release,
3539
+ versionBump: args.version_bump
3540
+ });
3541
+ await refreshAgents();
3542
+ return JSON.stringify(result, null, 2);
3543
+ }
3544
+ }),
5164
3545
  ...makeAgentFlowTools(
5165
3546
  z,
5166
3547
  () => authCache,
@@ -5174,9 +3555,4 @@ User goal: "${rawText2}"`;
5174
3555
  };
5175
3556
  };
5176
3557
  var index_default = plugin;
5177
- /*! Bundled license information:
5178
-
5179
- js-yaml/dist/js-yaml.mjs:
5180
- (*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
5181
- */
5182
3558
  //# sourceMappingURL=index.cjs.map