@fdcn/sourcefed 0.3.7 → 0.3.8
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/README.md +1 -1
- package/dist/{chunk-E6J3BAXP.js → chunk-5JL3UV72.js} +990 -99
- package/dist/cli.js +8716 -6926
- package/dist/daemon.js +994 -101
- package/dist/data/core/SKILL.md +9 -4
- package/dist/data/core/references/commands.md +6 -1
- package/dist/data/sourcefed/SKILL.md +3 -2
- package/dist/guidance.md +6 -2
- package/dist/mcp.js +6 -2
- package/dist/opencode.js +6 -2
- package/dist/pi.js +161 -39
- package/dist/tui-compiled.mjs +306 -166
- package/dist.dts/adapters/opencode/tools/monitor_create.d.ts +16 -0
- package/dist.dts/adapters/pi/src/dialog.d.ts +1 -2
- package/dist.dts/adapters/pi/src/monitors-dialog.d.ts +32 -0
- package/dist.dts/adapters/pi/src/monitors-dialog.test.d.ts +1 -0
- package/dist.dts/packages/core/src/types/monitor-create-input.d.ts +4 -0
- package/dist.dts/packages/daemon/src/registry.d.ts +2 -0
- package/dist.dts/packages/daemon/src/types/daemon.d.ts +4 -0
- package/dist.dts/providers/yab/src/index.d.ts +2 -0
- package/dist.dts/providers/yab/src/monitor.d.ts +14 -0
- package/dist.dts/providers/yab/src/poll/index.d.ts +2 -0
- package/dist.dts/providers/yab/src/poll/monitor.d.ts +3 -0
- package/dist.dts/providers/yab/src/poll/utils/feed-events.d.ts +5 -0
- package/dist.dts/providers/yab/src/poll/utils/index.d.ts +4 -0
- package/dist.dts/providers/yab/src/poll/utils/parse-feed.d.ts +3 -0
- package/dist.dts/providers/yab/src/poll/utils/poll-yab.d.ts +7 -0
- package/dist.dts/providers/yab/src/poll/utils/yab-mcp.d.ts +10 -0
- package/dist.dts/providers/yab/src/schema.d.ts +12 -0
- package/dist.dts/providers/yab/src/types/cursor.d.ts +4 -0
- package/dist.dts/providers/yab/src/types/event.d.ts +8 -0
- package/dist.dts/providers/yab/src/types/feed-entry.d.ts +8 -0
- package/dist.dts/providers/yab/src/types/index.d.ts +5 -0
- package/dist.dts/providers/yab/src/types/page.d.ts +6 -0
- package/dist.dts/providers/yab/src/types/source-record.d.ts +7 -0
- package/dist.dts/providers/yab/src/yab.test.d.ts +1 -0
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -374,8 +374,8 @@ var require_node = __commonJS({
|
|
|
374
374
|
var _this = this;
|
|
375
375
|
if (this.parentNode) {
|
|
376
376
|
var children = this.parentNode.childNodes;
|
|
377
|
-
this.parentNode.childNodes = children.filter(function(
|
|
378
|
-
return _this !==
|
|
377
|
+
this.parentNode.childNodes = children.filter(function(child2) {
|
|
378
|
+
return _this !== child2;
|
|
379
379
|
});
|
|
380
380
|
this.parentNode = null;
|
|
381
381
|
}
|
|
@@ -888,8 +888,8 @@ var require_node2 = __commonJS({
|
|
|
888
888
|
} else if (isTag(node)) {
|
|
889
889
|
var children = recursive ? cloneChildren(node.children) : [];
|
|
890
890
|
var clone_1 = new Element(node.name, __assign({}, node.attribs), children);
|
|
891
|
-
children.forEach(function(
|
|
892
|
-
return
|
|
891
|
+
children.forEach(function(child2) {
|
|
892
|
+
return child2.parent = clone_1;
|
|
893
893
|
});
|
|
894
894
|
if (node.namespace != null) {
|
|
895
895
|
clone_1.namespace = node.namespace;
|
|
@@ -904,15 +904,15 @@ var require_node2 = __commonJS({
|
|
|
904
904
|
} else if (isCDATA(node)) {
|
|
905
905
|
var children = recursive ? cloneChildren(node.children) : [];
|
|
906
906
|
var clone_2 = new CDATA(children);
|
|
907
|
-
children.forEach(function(
|
|
908
|
-
return
|
|
907
|
+
children.forEach(function(child2) {
|
|
908
|
+
return child2.parent = clone_2;
|
|
909
909
|
});
|
|
910
910
|
result = clone_2;
|
|
911
911
|
} else if (isDocument(node)) {
|
|
912
912
|
var children = recursive ? cloneChildren(node.children) : [];
|
|
913
913
|
var clone_3 = new Document(children);
|
|
914
|
-
children.forEach(function(
|
|
915
|
-
return
|
|
914
|
+
children.forEach(function(child2) {
|
|
915
|
+
return child2.parent = clone_3;
|
|
916
916
|
});
|
|
917
917
|
if (node["x-mode"]) {
|
|
918
918
|
clone_3["x-mode"] = node["x-mode"];
|
|
@@ -938,8 +938,8 @@ var require_node2 = __commonJS({
|
|
|
938
938
|
}
|
|
939
939
|
exports.cloneNode = cloneNode;
|
|
940
940
|
function cloneChildren(childs) {
|
|
941
|
-
var children = childs.map(function(
|
|
942
|
-
return cloneNode(
|
|
941
|
+
var children = childs.map(function(child2) {
|
|
942
|
+
return cloneNode(child2, true);
|
|
943
943
|
});
|
|
944
944
|
for (var i = 1; i < children.length; i++) {
|
|
945
945
|
children[i].prev = children[i - 1];
|
|
@@ -2283,16 +2283,16 @@ var require_manipulation = __commonJS({
|
|
|
2283
2283
|
elem.parent = null;
|
|
2284
2284
|
}
|
|
2285
2285
|
}
|
|
2286
|
-
function appendChild(parent,
|
|
2287
|
-
removeElement(
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
if (parent.children.push(
|
|
2286
|
+
function appendChild(parent, child2) {
|
|
2287
|
+
removeElement(child2);
|
|
2288
|
+
child2.next = null;
|
|
2289
|
+
child2.parent = parent;
|
|
2290
|
+
if (parent.children.push(child2) > 1) {
|
|
2291
2291
|
var sibling = parent.children[parent.children.length - 2];
|
|
2292
|
-
sibling.next =
|
|
2293
|
-
|
|
2292
|
+
sibling.next = child2;
|
|
2293
|
+
child2.prev = sibling;
|
|
2294
2294
|
} else {
|
|
2295
|
-
|
|
2295
|
+
child2.prev = null;
|
|
2296
2296
|
}
|
|
2297
2297
|
}
|
|
2298
2298
|
function append(elem, next) {
|
|
@@ -2313,16 +2313,16 @@ var require_manipulation = __commonJS({
|
|
|
2313
2313
|
parent.children.push(next);
|
|
2314
2314
|
}
|
|
2315
2315
|
}
|
|
2316
|
-
function prependChild(parent,
|
|
2317
|
-
removeElement(
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
if (parent.children.unshift(
|
|
2316
|
+
function prependChild(parent, child2) {
|
|
2317
|
+
removeElement(child2);
|
|
2318
|
+
child2.parent = parent;
|
|
2319
|
+
child2.prev = null;
|
|
2320
|
+
if (parent.children.unshift(child2) !== 1) {
|
|
2321
2321
|
var sibling = parent.children[1];
|
|
2322
|
-
sibling.prev =
|
|
2323
|
-
|
|
2322
|
+
sibling.prev = child2;
|
|
2323
|
+
child2.next = sibling;
|
|
2324
2324
|
} else {
|
|
2325
|
-
|
|
2325
|
+
child2.next = null;
|
|
2326
2326
|
}
|
|
2327
2327
|
}
|
|
2328
2328
|
function prepend(elem, prev) {
|
|
@@ -4342,7 +4342,7 @@ var require_general = __commonJS({
|
|
|
4342
4342
|
};
|
|
4343
4343
|
}
|
|
4344
4344
|
case css_what_1.SelectorType.Child: {
|
|
4345
|
-
return function
|
|
4345
|
+
return function child2(elem) {
|
|
4346
4346
|
var parent = adapter.getParent(elem);
|
|
4347
4347
|
return parent != null && adapter.isTag(parent) && next(parent);
|
|
4348
4348
|
};
|
|
@@ -4586,12 +4586,12 @@ var require_lib7 = __commonJS({
|
|
|
4586
4586
|
exports._compileUnsafe = wrapCompile(compile_js_1.compileUnsafe);
|
|
4587
4587
|
exports._compileToken = wrapCompile(compile_js_1.compileToken);
|
|
4588
4588
|
function getSelectorFunc(searchFunc) {
|
|
4589
|
-
return function select(query,
|
|
4589
|
+
return function select(query, elements2, options) {
|
|
4590
4590
|
var opts = convertOptionFormats(options);
|
|
4591
4591
|
if (typeof query !== "function") {
|
|
4592
|
-
query = (0, compile_js_1.compileUnsafe)(query, opts,
|
|
4592
|
+
query = (0, compile_js_1.compileUnsafe)(query, opts, elements2);
|
|
4593
4593
|
}
|
|
4594
|
-
var filteredElements = prepareContext(
|
|
4594
|
+
var filteredElements = prepareContext(elements2, opts.adapter, query.shouldTestNextSiblings);
|
|
4595
4595
|
return searchFunc(query, filteredElements, opts);
|
|
4596
4596
|
};
|
|
4597
4597
|
}
|
|
@@ -5143,18 +5143,18 @@ var require_html = __commonJS({
|
|
|
5143
5143
|
return JSON.stringify(attr.replace(/"/g, """)).replace(/\\t/g, " ").replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\\/g, "");
|
|
5144
5144
|
};
|
|
5145
5145
|
HTMLElement2.prototype.removeChild = function(node) {
|
|
5146
|
-
this.childNodes = this.childNodes.filter(function(
|
|
5147
|
-
return
|
|
5146
|
+
this.childNodes = this.childNodes.filter(function(child2) {
|
|
5147
|
+
return child2 !== node;
|
|
5148
5148
|
});
|
|
5149
5149
|
return this;
|
|
5150
5150
|
};
|
|
5151
5151
|
HTMLElement2.prototype.exchangeChild = function(oldNode, newNode) {
|
|
5152
5152
|
var children = this.childNodes;
|
|
5153
|
-
this.childNodes = children.map(function(
|
|
5154
|
-
if (
|
|
5153
|
+
this.childNodes = children.map(function(child2) {
|
|
5154
|
+
if (child2 === oldNode) {
|
|
5155
5155
|
return newNode;
|
|
5156
5156
|
}
|
|
5157
|
-
return
|
|
5157
|
+
return child2;
|
|
5158
5158
|
});
|
|
5159
5159
|
return this;
|
|
5160
5160
|
};
|
|
@@ -5272,8 +5272,8 @@ var require_html = __commonJS({
|
|
|
5272
5272
|
};
|
|
5273
5273
|
Object.defineProperty(HTMLElement2.prototype, "innerHTML", {
|
|
5274
5274
|
get: function() {
|
|
5275
|
-
return this.childNodes.map(function(
|
|
5276
|
-
return
|
|
5275
|
+
return this.childNodes.map(function(child2) {
|
|
5276
|
+
return child2.toString();
|
|
5277
5277
|
}).join("");
|
|
5278
5278
|
},
|
|
5279
5279
|
set: function(content) {
|
|
@@ -5318,8 +5318,8 @@ var require_html = __commonJS({
|
|
|
5318
5318
|
}
|
|
5319
5319
|
return [];
|
|
5320
5320
|
}).flat();
|
|
5321
|
-
var idx = parent.childNodes.findIndex(function(
|
|
5322
|
-
return
|
|
5321
|
+
var idx = parent.childNodes.findIndex(function(child2) {
|
|
5322
|
+
return child2 === _this;
|
|
5323
5323
|
});
|
|
5324
5324
|
resetParent([this], null);
|
|
5325
5325
|
parent.childNodes = __spreadArray(__spreadArray(__spreadArray([], parent.childNodes.slice(0, idx), true), resetParent(content, parent), true), parent.childNodes.slice(idx + 1), true);
|
|
@@ -5416,21 +5416,21 @@ var require_html = __commonJS({
|
|
|
5416
5416
|
var currentNodeReference = this;
|
|
5417
5417
|
var index = 0;
|
|
5418
5418
|
while (index !== void 0) {
|
|
5419
|
-
var
|
|
5419
|
+
var child2 = void 0;
|
|
5420
5420
|
do {
|
|
5421
|
-
|
|
5422
|
-
} while (index < currentNodeReference.childNodes.length &&
|
|
5423
|
-
if (
|
|
5421
|
+
child2 = currentNodeReference.childNodes[index++];
|
|
5422
|
+
} while (index < currentNodeReference.childNodes.length && child2 === void 0);
|
|
5423
|
+
if (child2 === void 0) {
|
|
5424
5424
|
currentNodeReference = currentNodeReference.parentNode;
|
|
5425
5425
|
index = stack.pop();
|
|
5426
5426
|
continue;
|
|
5427
5427
|
}
|
|
5428
|
-
if (
|
|
5429
|
-
if (tagName === "*" ||
|
|
5430
|
-
re.push(
|
|
5431
|
-
if (
|
|
5428
|
+
if (child2.nodeType === type_1.default.ELEMENT_NODE) {
|
|
5429
|
+
if (tagName === "*" || child2.tagName === upperCasedTagName)
|
|
5430
|
+
re.push(child2);
|
|
5431
|
+
if (child2.childNodes.length > 0) {
|
|
5432
5432
|
stack.push(index);
|
|
5433
|
-
currentNodeReference =
|
|
5433
|
+
currentNodeReference = child2;
|
|
5434
5434
|
index = 0;
|
|
5435
5435
|
}
|
|
5436
5436
|
}
|
|
@@ -5442,23 +5442,23 @@ var require_html = __commonJS({
|
|
|
5442
5442
|
var currentNodeReference = this;
|
|
5443
5443
|
var index = 0;
|
|
5444
5444
|
while (index !== void 0) {
|
|
5445
|
-
var
|
|
5445
|
+
var child2 = void 0;
|
|
5446
5446
|
do {
|
|
5447
|
-
|
|
5448
|
-
} while (index < currentNodeReference.childNodes.length &&
|
|
5449
|
-
if (
|
|
5447
|
+
child2 = currentNodeReference.childNodes[index++];
|
|
5448
|
+
} while (index < currentNodeReference.childNodes.length && child2 === void 0);
|
|
5449
|
+
if (child2 === void 0) {
|
|
5450
5450
|
currentNodeReference = currentNodeReference.parentNode;
|
|
5451
5451
|
index = stack.pop();
|
|
5452
5452
|
continue;
|
|
5453
5453
|
}
|
|
5454
|
-
if (
|
|
5455
|
-
if (
|
|
5456
|
-
return
|
|
5454
|
+
if (child2.nodeType === type_1.default.ELEMENT_NODE) {
|
|
5455
|
+
if (child2.id === id) {
|
|
5456
|
+
return child2;
|
|
5457
5457
|
}
|
|
5458
5458
|
;
|
|
5459
|
-
if (
|
|
5459
|
+
if (child2.childNodes.length > 0) {
|
|
5460
5460
|
stack.push(index);
|
|
5461
|
-
currentNodeReference =
|
|
5461
|
+
currentNodeReference = child2;
|
|
5462
5462
|
index = 0;
|
|
5463
5463
|
}
|
|
5464
5464
|
}
|
|
@@ -5476,9 +5476,9 @@ var require_html = __commonJS({
|
|
|
5476
5476
|
if (test(el_1)) {
|
|
5477
5477
|
elem = el_1;
|
|
5478
5478
|
} else {
|
|
5479
|
-
var
|
|
5480
|
-
if (
|
|
5481
|
-
elem = findOne(test, [
|
|
5479
|
+
var child2 = mapChild.get(el_1);
|
|
5480
|
+
if (child2) {
|
|
5481
|
+
elem = findOne(test, [child2]);
|
|
5482
5482
|
}
|
|
5483
5483
|
}
|
|
5484
5484
|
}
|
|
@@ -5494,8 +5494,8 @@ var require_html = __commonJS({
|
|
|
5494
5494
|
var e = (0, css_select_1.selectOne)(selector, el, {
|
|
5495
5495
|
xmlMode: true,
|
|
5496
5496
|
adapter: __assign(__assign({}, matcher_1.default), { getChildren: function(node) {
|
|
5497
|
-
var
|
|
5498
|
-
return
|
|
5497
|
+
var child2 = mapChild.get(node);
|
|
5498
|
+
return child2 && [child2];
|
|
5499
5499
|
}, getSiblings: function(node) {
|
|
5500
5500
|
return [node];
|
|
5501
5501
|
}, findOne, findAll: function() {
|
|
@@ -5674,8 +5674,8 @@ var require_html = __commonJS({
|
|
|
5674
5674
|
}
|
|
5675
5675
|
var p = parse(html, this._parseOptions);
|
|
5676
5676
|
if (where === "afterend") {
|
|
5677
|
-
var idx = this.parentNode.childNodes.findIndex(function(
|
|
5678
|
-
return
|
|
5677
|
+
var idx = this.parentNode.childNodes.findIndex(function(child2) {
|
|
5678
|
+
return child2 === _this;
|
|
5679
5679
|
});
|
|
5680
5680
|
resetParent(p.childNodes, this.parentNode);
|
|
5681
5681
|
(_a = this.parentNode.childNodes).splice.apply(_a, __spreadArray([idx + 1, 0], p.childNodes, false));
|
|
@@ -5687,8 +5687,8 @@ var require_html = __commonJS({
|
|
|
5687
5687
|
_this.appendChild(n);
|
|
5688
5688
|
});
|
|
5689
5689
|
} else if (where === "beforebegin") {
|
|
5690
|
-
var idx = this.parentNode.childNodes.findIndex(function(
|
|
5691
|
-
return
|
|
5690
|
+
var idx = this.parentNode.childNodes.findIndex(function(child2) {
|
|
5691
|
+
return child2 === _this;
|
|
5692
5692
|
});
|
|
5693
5693
|
resetParent(p.childNodes, this.parentNode);
|
|
5694
5694
|
(_c = this.parentNode.childNodes).splice.apply(_c, __spreadArray([idx, 0], p.childNodes, false));
|
|
@@ -5703,8 +5703,8 @@ var require_html = __commonJS({
|
|
|
5703
5703
|
var children = this.parentNode.childNodes;
|
|
5704
5704
|
var i = 0;
|
|
5705
5705
|
while (i < children.length) {
|
|
5706
|
-
var
|
|
5707
|
-
if (this ===
|
|
5706
|
+
var child2 = children[i++];
|
|
5707
|
+
if (this === child2)
|
|
5708
5708
|
return children[i] || null;
|
|
5709
5709
|
}
|
|
5710
5710
|
return null;
|
|
@@ -5720,12 +5720,12 @@ var require_html = __commonJS({
|
|
|
5720
5720
|
var i = 0;
|
|
5721
5721
|
var find = false;
|
|
5722
5722
|
while (i < children.length) {
|
|
5723
|
-
var
|
|
5723
|
+
var child2 = children[i++];
|
|
5724
5724
|
if (find) {
|
|
5725
|
-
if (
|
|
5726
|
-
return
|
|
5725
|
+
if (child2 instanceof HTMLElement2) {
|
|
5726
|
+
return child2 || null;
|
|
5727
5727
|
}
|
|
5728
|
-
} else if (this ===
|
|
5728
|
+
} else if (this === child2) {
|
|
5729
5729
|
find = true;
|
|
5730
5730
|
}
|
|
5731
5731
|
}
|
|
@@ -5741,8 +5741,8 @@ var require_html = __commonJS({
|
|
|
5741
5741
|
var children = this.parentNode.childNodes;
|
|
5742
5742
|
var i = children.length;
|
|
5743
5743
|
while (i > 0) {
|
|
5744
|
-
var
|
|
5745
|
-
if (this ===
|
|
5744
|
+
var child2 = children[--i];
|
|
5745
|
+
if (this === child2)
|
|
5746
5746
|
return children[i - 1] || null;
|
|
5747
5747
|
}
|
|
5748
5748
|
return null;
|
|
@@ -5758,12 +5758,12 @@ var require_html = __commonJS({
|
|
|
5758
5758
|
var i = children.length;
|
|
5759
5759
|
var find = false;
|
|
5760
5760
|
while (i > 0) {
|
|
5761
|
-
var
|
|
5761
|
+
var child2 = children[--i];
|
|
5762
5762
|
if (find) {
|
|
5763
|
-
if (
|
|
5764
|
-
return
|
|
5763
|
+
if (child2 instanceof HTMLElement2) {
|
|
5764
|
+
return child2 || null;
|
|
5765
5765
|
}
|
|
5766
|
-
} else if (this ===
|
|
5766
|
+
} else if (this === child2) {
|
|
5767
5767
|
find = true;
|
|
5768
5768
|
}
|
|
5769
5769
|
}
|
|
@@ -5836,18 +5836,18 @@ var require_html = __commonJS({
|
|
|
5836
5836
|
options = {};
|
|
5837
5837
|
}
|
|
5838
5838
|
var voidTag = new void_tag_1.default((_a = options === null || options === void 0 ? void 0 : options.voidTag) === null || _a === void 0 ? void 0 : _a.closingSlash, (_b = options === null || options === void 0 ? void 0 : options.voidTag) === null || _b === void 0 ? void 0 : _b.tags);
|
|
5839
|
-
var
|
|
5839
|
+
var elements2 = options.blockTextElements || {
|
|
5840
5840
|
script: true,
|
|
5841
5841
|
noscript: true,
|
|
5842
5842
|
style: true,
|
|
5843
5843
|
pre: true
|
|
5844
5844
|
};
|
|
5845
|
-
var element_names = Object.keys(
|
|
5845
|
+
var element_names = Object.keys(elements2);
|
|
5846
5846
|
var kBlockTextElements = element_names.map(function(it) {
|
|
5847
5847
|
return new RegExp("^".concat(it, "$"), "i");
|
|
5848
5848
|
});
|
|
5849
5849
|
var kIgnoreElements = element_names.filter(function(it) {
|
|
5850
|
-
return Boolean(
|
|
5850
|
+
return Boolean(elements2[it]);
|
|
5851
5851
|
}).map(function(it) {
|
|
5852
5852
|
return new RegExp("^".concat(it, "$"), "i");
|
|
5853
5853
|
});
|
|
@@ -5982,16 +5982,16 @@ var require_html = __commonJS({
|
|
|
5982
5982
|
if (last.parentNode === oneBefore && last.tagName === oneBefore.tagName) {
|
|
5983
5983
|
if (options.parseNoneClosedTags !== true) {
|
|
5984
5984
|
oneBefore.removeChild(last);
|
|
5985
|
-
last.childNodes.forEach(function(
|
|
5986
|
-
oneBefore.parentNode.appendChild(
|
|
5985
|
+
last.childNodes.forEach(function(child2) {
|
|
5986
|
+
oneBefore.parentNode.appendChild(child2);
|
|
5987
5987
|
});
|
|
5988
5988
|
stack.pop();
|
|
5989
5989
|
}
|
|
5990
5990
|
} else {
|
|
5991
5991
|
if (options.parseNoneClosedTags !== true) {
|
|
5992
5992
|
oneBefore.removeChild(last);
|
|
5993
|
-
last.childNodes.forEach(function(
|
|
5994
|
-
oneBefore.appendChild(
|
|
5993
|
+
last.childNodes.forEach(function(child2) {
|
|
5994
|
+
oneBefore.appendChild(child2);
|
|
5995
5995
|
});
|
|
5996
5996
|
}
|
|
5997
5997
|
}
|
|
@@ -6684,11 +6684,11 @@ var require_visitor = __commonJS({
|
|
|
6684
6684
|
if ((translator === null || translator === void 0 ? void 0 : translator.preserveIfEmpty) || typeof translator === "function")
|
|
6685
6685
|
res = true;
|
|
6686
6686
|
} else
|
|
6687
|
-
for (const
|
|
6687
|
+
for (const child2 of childNodes) {
|
|
6688
6688
|
if (!res)
|
|
6689
|
-
res = visit(
|
|
6689
|
+
res = visit(child2);
|
|
6690
6690
|
else
|
|
6691
|
-
visit(
|
|
6691
|
+
visit(child2);
|
|
6692
6692
|
}
|
|
6693
6693
|
}
|
|
6694
6694
|
return node2.preserve = res;
|
|
@@ -6747,8 +6747,8 @@ var require_visitor = __commonJS({
|
|
|
6747
6747
|
if (metadata)
|
|
6748
6748
|
this.nodeMetadata.set(node, metadata);
|
|
6749
6749
|
if (!translatorCfgOrFactory) {
|
|
6750
|
-
for (const
|
|
6751
|
-
this.visitNode(
|
|
6750
|
+
for (const child2 of (0, utilities_1.getChildNodes)(node))
|
|
6751
|
+
this.visitNode(child2, textOnly, metadata);
|
|
6752
6752
|
return;
|
|
6753
6753
|
}
|
|
6754
6754
|
let cfg;
|
|
@@ -6777,8 +6777,8 @@ var require_visitor = __commonJS({
|
|
|
6777
6777
|
this.appendResult(cfg.content, void 0, cfg.spaceIfRepeatingChar);
|
|
6778
6778
|
else {
|
|
6779
6779
|
const startPos = result.text.length;
|
|
6780
|
-
for (const
|
|
6781
|
-
this.visitNode(
|
|
6780
|
+
for (const child2 of (0, utilities_1.getChildNodes)(node))
|
|
6781
|
+
this.visitNode(child2, cfg.recurse === false, metadata);
|
|
6782
6782
|
if (cfg.postprocess) {
|
|
6783
6783
|
const postRes = cfg.postprocess(Object.assign(Object.assign({}, ctx || (0, translator_1.createTranslatorContext)(this, node, metadata)), { content: result.text.substr(startPos) }));
|
|
6784
6784
|
if (postRes === translator_1.PostProcessResult.RemoveNode) {
|
|
@@ -10306,11 +10306,904 @@ var SlackMonitor = class extends Monitor3 {
|
|
|
10306
10306
|
}
|
|
10307
10307
|
};
|
|
10308
10308
|
|
|
10309
|
+
// providers/yab/dist/index.js
|
|
10310
|
+
import { link as link4, mkdir as mkdir4, open as open4, readFile as readFile4, rename as rename4, rm as rm4, writeFile as writeFile4 } from "node:fs/promises";
|
|
10311
|
+
import os4 from "node:os";
|
|
10312
|
+
import path4 from "node:path";
|
|
10313
|
+
import { spawn } from "node:child_process";
|
|
10314
|
+
var store$45;
|
|
10315
|
+
var DEFAULT_CONFIG5 = {
|
|
10316
|
+
lang: void 0,
|
|
10317
|
+
message: void 0,
|
|
10318
|
+
abortEarly: void 0,
|
|
10319
|
+
abortPipeEarly: void 0
|
|
10320
|
+
};
|
|
10321
|
+
// @__NO_SIDE_EFFECTS__
|
|
10322
|
+
function getGlobalConfig5(config$1) {
|
|
10323
|
+
if (!config$1 && !store$45) return DEFAULT_CONFIG5;
|
|
10324
|
+
return {
|
|
10325
|
+
lang: config$1?.lang ?? store$45?.lang,
|
|
10326
|
+
message: config$1?.message,
|
|
10327
|
+
abortEarly: config$1?.abortEarly ?? store$45?.abortEarly,
|
|
10328
|
+
abortPipeEarly: config$1?.abortPipeEarly ?? store$45?.abortPipeEarly
|
|
10329
|
+
};
|
|
10330
|
+
}
|
|
10331
|
+
var store$35;
|
|
10332
|
+
// @__NO_SIDE_EFFECTS__
|
|
10333
|
+
function getGlobalMessage5(lang) {
|
|
10334
|
+
return store$35?.get(lang);
|
|
10335
|
+
}
|
|
10336
|
+
var store$25;
|
|
10337
|
+
// @__NO_SIDE_EFFECTS__
|
|
10338
|
+
function getSchemaMessage5(lang) {
|
|
10339
|
+
return store$25?.get(lang);
|
|
10340
|
+
}
|
|
10341
|
+
var store$15;
|
|
10342
|
+
// @__NO_SIDE_EFFECTS__
|
|
10343
|
+
function getSpecificMessage5(reference, lang) {
|
|
10344
|
+
return store$15?.get(reference)?.get(lang);
|
|
10345
|
+
}
|
|
10346
|
+
// @__NO_SIDE_EFFECTS__
|
|
10347
|
+
function _stringify5(input) {
|
|
10348
|
+
const type = typeof input;
|
|
10349
|
+
if (type === "string") return `"${input}"`;
|
|
10350
|
+
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
10351
|
+
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
10352
|
+
return type;
|
|
10353
|
+
}
|
|
10354
|
+
function _addIssue5(context, label, dataset, config$1, other) {
|
|
10355
|
+
const input = other && "input" in other ? other.input : dataset.value;
|
|
10356
|
+
const expected = other?.expected ?? context.expects ?? null;
|
|
10357
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify5(input);
|
|
10358
|
+
const issue = {
|
|
10359
|
+
kind: context.kind,
|
|
10360
|
+
type: context.type,
|
|
10361
|
+
input,
|
|
10362
|
+
expected,
|
|
10363
|
+
received,
|
|
10364
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
10365
|
+
requirement: context.requirement,
|
|
10366
|
+
path: other?.path,
|
|
10367
|
+
issues: other?.issues,
|
|
10368
|
+
lang: config$1.lang,
|
|
10369
|
+
abortEarly: config$1.abortEarly,
|
|
10370
|
+
abortPipeEarly: config$1.abortPipeEarly
|
|
10371
|
+
};
|
|
10372
|
+
const isSchema = context.kind === "schema";
|
|
10373
|
+
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage5(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage5(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage5(issue.lang);
|
|
10374
|
+
if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
|
|
10375
|
+
if (isSchema) dataset.typed = false;
|
|
10376
|
+
if (dataset.issues) dataset.issues.push(issue);
|
|
10377
|
+
else dataset.issues = [issue];
|
|
10378
|
+
}
|
|
10379
|
+
var _standardCache5 = /* @__PURE__ */ new WeakMap();
|
|
10380
|
+
// @__NO_SIDE_EFFECTS__
|
|
10381
|
+
function _getStandardProps5(context) {
|
|
10382
|
+
let cached = _standardCache5.get(context);
|
|
10383
|
+
if (!cached) {
|
|
10384
|
+
cached = {
|
|
10385
|
+
version: 1,
|
|
10386
|
+
vendor: "valibot",
|
|
10387
|
+
validate(value$1) {
|
|
10388
|
+
return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig5());
|
|
10389
|
+
}
|
|
10390
|
+
};
|
|
10391
|
+
_standardCache5.set(context, cached);
|
|
10392
|
+
}
|
|
10393
|
+
return cached;
|
|
10394
|
+
}
|
|
10395
|
+
var EMOJI_REGEX5 = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
|
|
10396
|
+
// @__NO_SIDE_EFFECTS__
|
|
10397
|
+
function array5(item, message$1) {
|
|
10398
|
+
return {
|
|
10399
|
+
kind: "schema",
|
|
10400
|
+
type: "array",
|
|
10401
|
+
reference: array5,
|
|
10402
|
+
expects: "Array",
|
|
10403
|
+
async: false,
|
|
10404
|
+
item,
|
|
10405
|
+
message: message$1,
|
|
10406
|
+
get "~standard"() {
|
|
10407
|
+
return /* @__PURE__ */ _getStandardProps5(this);
|
|
10408
|
+
},
|
|
10409
|
+
"~run"(dataset, config$1) {
|
|
10410
|
+
const input = dataset.value;
|
|
10411
|
+
if (Array.isArray(input)) {
|
|
10412
|
+
dataset.typed = true;
|
|
10413
|
+
dataset.value = [];
|
|
10414
|
+
for (let key = 0; key < input.length; key++) {
|
|
10415
|
+
const value$1 = input[key];
|
|
10416
|
+
const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
|
|
10417
|
+
if (itemDataset.issues) {
|
|
10418
|
+
const pathItem = {
|
|
10419
|
+
type: "array",
|
|
10420
|
+
origin: "value",
|
|
10421
|
+
input,
|
|
10422
|
+
key,
|
|
10423
|
+
value: value$1
|
|
10424
|
+
};
|
|
10425
|
+
for (const issue of itemDataset.issues) {
|
|
10426
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
10427
|
+
else issue.path = [pathItem];
|
|
10428
|
+
dataset.issues?.push(issue);
|
|
10429
|
+
}
|
|
10430
|
+
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
10431
|
+
if (config$1.abortEarly) {
|
|
10432
|
+
dataset.typed = false;
|
|
10433
|
+
break;
|
|
10434
|
+
}
|
|
10435
|
+
}
|
|
10436
|
+
if (!itemDataset.typed) dataset.typed = false;
|
|
10437
|
+
dataset.value.push(itemDataset.value);
|
|
10438
|
+
}
|
|
10439
|
+
} else _addIssue5(this, "type", dataset, config$1);
|
|
10440
|
+
return dataset;
|
|
10441
|
+
}
|
|
10442
|
+
};
|
|
10443
|
+
}
|
|
10444
|
+
// @__NO_SIDE_EFFECTS__
|
|
10445
|
+
function string5(message$1) {
|
|
10446
|
+
return {
|
|
10447
|
+
kind: "schema",
|
|
10448
|
+
type: "string",
|
|
10449
|
+
reference: string5,
|
|
10450
|
+
expects: "string",
|
|
10451
|
+
async: false,
|
|
10452
|
+
message: message$1,
|
|
10453
|
+
get "~standard"() {
|
|
10454
|
+
return /* @__PURE__ */ _getStandardProps5(this);
|
|
10455
|
+
},
|
|
10456
|
+
"~run"(dataset, config$1) {
|
|
10457
|
+
if (typeof dataset.value === "string") dataset.typed = true;
|
|
10458
|
+
else _addIssue5(this, "type", dataset, config$1);
|
|
10459
|
+
return dataset;
|
|
10460
|
+
}
|
|
10461
|
+
};
|
|
10462
|
+
}
|
|
10463
|
+
// @__NO_SIDE_EFFECTS__
|
|
10464
|
+
function safeParse5(schema, input, config$1) {
|
|
10465
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig5(config$1));
|
|
10466
|
+
return {
|
|
10467
|
+
typed: dataset.typed,
|
|
10468
|
+
success: !dataset.issues,
|
|
10469
|
+
output: dataset.value,
|
|
10470
|
+
issues: dataset.issues
|
|
10471
|
+
};
|
|
10472
|
+
}
|
|
10473
|
+
var Monitor4 = class {
|
|
10474
|
+
type;
|
|
10475
|
+
schema;
|
|
10476
|
+
poll;
|
|
10477
|
+
webhook;
|
|
10478
|
+
constructor(options) {
|
|
10479
|
+
this.type = options.type;
|
|
10480
|
+
this.schema = options.schema;
|
|
10481
|
+
}
|
|
10482
|
+
validateSource(source) {
|
|
10483
|
+
const result = /* @__PURE__ */ safeParse5(this.schema, source);
|
|
10484
|
+
if (result.success) return result.output;
|
|
10485
|
+
throw new Error(`invalid ${this.type} monitor source`);
|
|
10486
|
+
}
|
|
10487
|
+
initialDelivery(source) {
|
|
10488
|
+
this.validateSource(source);
|
|
10489
|
+
if (this.webhook && this.webhook.preferred && this.webhook.configured()) return "webhook";
|
|
10490
|
+
if (this.poll) return "poll";
|
|
10491
|
+
if (this.webhook) return "webhook";
|
|
10492
|
+
throw new Error(`source ${this.type} has no configured transport`);
|
|
10493
|
+
}
|
|
10494
|
+
resolveDelivery(monitor) {
|
|
10495
|
+
let webhookHealthy = false;
|
|
10496
|
+
if (this.webhook) webhookHealthy = this.webhook.isHealthy(monitor);
|
|
10497
|
+
if (monitor.delivery === "webhook") {
|
|
10498
|
+
if (this.webhook && webhookHealthy) return "webhook";
|
|
10499
|
+
if (this.poll) return "poll";
|
|
10500
|
+
if (this.webhook) return "webhook";
|
|
10501
|
+
return void 0;
|
|
10502
|
+
}
|
|
10503
|
+
if (this.webhook && webhookHealthy) return "webhook";
|
|
10504
|
+
if (this.poll) return "poll";
|
|
10505
|
+
if (this.webhook) return "webhook";
|
|
10506
|
+
return void 0;
|
|
10507
|
+
}
|
|
10508
|
+
async tick(context, record2) {
|
|
10509
|
+
const fresh = await context.service.get(record2.id);
|
|
10510
|
+
if (!fresh || !fresh.enabled) return 0;
|
|
10511
|
+
if (this.webhook) await this.webhook.retryPending(context, this, fresh);
|
|
10512
|
+
const current = await context.service.get(record2.id);
|
|
10513
|
+
if (!current || !current.enabled) return 0;
|
|
10514
|
+
const nextDelivery = this.resolveDelivery(current);
|
|
10515
|
+
if (!nextDelivery) return 0;
|
|
10516
|
+
if (nextDelivery !== current.delivery) {
|
|
10517
|
+
await context.service.setDelivery(current.id, nextDelivery);
|
|
10518
|
+
current.delivery = nextDelivery;
|
|
10519
|
+
}
|
|
10520
|
+
if (current.delivery !== "poll" || !this.poll) return 0;
|
|
10521
|
+
const lastAttemptAt = Number(current.cursors.__lastAttemptAt ?? current.cursors.__lastPolledAt ?? 0);
|
|
10522
|
+
const pollIntervalSec = current.pollIntervalSec || 60;
|
|
10523
|
+
if (lastAttemptAt && Date.now() - lastAttemptAt < pollIntervalSec * 1e3) return 0;
|
|
10524
|
+
return this.poll.run(context, this, current);
|
|
10525
|
+
}
|
|
10526
|
+
async deliver(context, record2, event, deliveryId) {
|
|
10527
|
+
if (!this.webhook) return 0;
|
|
10528
|
+
return this.webhook.deliver(context, this, record2, event, deliveryId);
|
|
10529
|
+
}
|
|
10530
|
+
unresponsive(record2, now = Date.now()) {
|
|
10531
|
+
if (!record2.enabled) return false;
|
|
10532
|
+
if (record2.delivery === "poll") {
|
|
10533
|
+
if (!this.poll) return true;
|
|
10534
|
+
return this.poll.isUnresponsive(record2, now);
|
|
10535
|
+
}
|
|
10536
|
+
if (!this.webhook) return true;
|
|
10537
|
+
return this.webhook.isUnresponsive(record2, now);
|
|
10538
|
+
}
|
|
10539
|
+
};
|
|
10540
|
+
var RoutedEventCursorSchema4 = /* @__PURE__ */ array5(/* @__PURE__ */ string5());
|
|
10541
|
+
function eventDeliveryId4(event) {
|
|
10542
|
+
if (event.id) return event.id;
|
|
10543
|
+
return `${event.kind}:${event.at}:${event.summary}`;
|
|
10544
|
+
}
|
|
10545
|
+
var activePolls4 = /* @__PURE__ */ new Set();
|
|
10546
|
+
var PollMonitor4 = class {
|
|
10547
|
+
constructor(options) {
|
|
10548
|
+
this.options = options;
|
|
10549
|
+
}
|
|
10550
|
+
async run(context, source, record2) {
|
|
10551
|
+
if (activePolls4.has(record2.id)) return 0;
|
|
10552
|
+
activePolls4.add(record2.id);
|
|
10553
|
+
try {
|
|
10554
|
+
const fresh = await context.service.get(record2.id);
|
|
10555
|
+
if (!fresh) return 0;
|
|
10556
|
+
const sourceRecord = source.validateSource(fresh.source);
|
|
10557
|
+
const cursorKey = source.key(sourceRecord);
|
|
10558
|
+
const result = await this.options.run(sourceRecord, fresh.cursors[cursorKey]);
|
|
10559
|
+
const current = await context.service.get(record2.id);
|
|
10560
|
+
if (!current || !current.enabled) return 0;
|
|
10561
|
+
const parsedRoutedIds = /* @__PURE__ */ safeParse5(RoutedEventCursorSchema4, fresh.cursors.__routedEventIds);
|
|
10562
|
+
let routedIds = [];
|
|
10563
|
+
if (parsedRoutedIds.success) routedIds = parsedRoutedIds.output;
|
|
10564
|
+
let routeFailed = false;
|
|
10565
|
+
for (const event of result.events) {
|
|
10566
|
+
const eventId = eventDeliveryId4(event);
|
|
10567
|
+
if (routedIds.includes(eventId)) continue;
|
|
10568
|
+
const routed = await context.sink.deliver({ monitor: fresh, event });
|
|
10569
|
+
if (!routed.ok) {
|
|
10570
|
+
routeFailed = true;
|
|
10571
|
+
console.error(`[sourcefed] route failed for ${fresh.id}: ${routed.error}`);
|
|
10572
|
+
continue;
|
|
10573
|
+
}
|
|
10574
|
+
if (!routedIds.includes(eventId)) routedIds.push(eventId);
|
|
10575
|
+
}
|
|
10576
|
+
if (routeFailed) {
|
|
10577
|
+
await context.service.updateCursor(fresh, "__routedEventIds", routedIds);
|
|
10578
|
+
return 0;
|
|
10579
|
+
}
|
|
10580
|
+
await context.service.updateCursorValue(fresh, cursorKey, (current2) => {
|
|
10581
|
+
if (this.options.mergeCursor) return this.options.mergeCursor(current2, result.cursor);
|
|
10582
|
+
return result.cursor;
|
|
10583
|
+
});
|
|
10584
|
+
await context.service.updateCursor(fresh, "__routedEventIds", []);
|
|
10585
|
+
if (result.terminal) await context.service.remove(fresh.id);
|
|
10586
|
+
await context.service.updateCursor(fresh, "__lastPolledAt", Date.now());
|
|
10587
|
+
return result.events.length;
|
|
10588
|
+
} finally {
|
|
10589
|
+
activePolls4.delete(record2.id);
|
|
10590
|
+
}
|
|
10591
|
+
}
|
|
10592
|
+
isUnresponsive(record2, now) {
|
|
10593
|
+
const intervalMs = Math.max((record2.pollIntervalSec || 60) * 3e3, 12e4);
|
|
10594
|
+
const lastPolledAt = Number(record2.cursors.__lastPolledAt ?? 0);
|
|
10595
|
+
if (lastPolledAt > 0) return now - lastPolledAt > intervalMs;
|
|
10596
|
+
return now - Date.parse(record2.createdAt) > intervalMs;
|
|
10597
|
+
}
|
|
10598
|
+
};
|
|
10599
|
+
var MAX_WEBHOOK_BODY_BYTES4 = 1024 * 1024;
|
|
10600
|
+
function toMonitorEvent4(event, source) {
|
|
10601
|
+
return {
|
|
10602
|
+
source,
|
|
10603
|
+
kind: event.kind,
|
|
10604
|
+
id: event.id,
|
|
10605
|
+
at: event.at,
|
|
10606
|
+
summary: event.summary,
|
|
10607
|
+
body: event.body,
|
|
10608
|
+
actionable: event.actionable,
|
|
10609
|
+
terminal: event.terminal
|
|
10610
|
+
};
|
|
10611
|
+
}
|
|
10612
|
+
var store$424;
|
|
10613
|
+
var DEFAULT_CONFIG24 = {
|
|
10614
|
+
lang: void 0,
|
|
10615
|
+
message: void 0,
|
|
10616
|
+
abortEarly: void 0,
|
|
10617
|
+
abortPipeEarly: void 0
|
|
10618
|
+
};
|
|
10619
|
+
// @__NO_SIDE_EFFECTS__
|
|
10620
|
+
function getGlobalConfig24(config$1) {
|
|
10621
|
+
if (!config$1 && !store$424) return DEFAULT_CONFIG24;
|
|
10622
|
+
return {
|
|
10623
|
+
lang: config$1?.lang ?? store$424?.lang,
|
|
10624
|
+
message: config$1?.message,
|
|
10625
|
+
abortEarly: config$1?.abortEarly ?? store$424?.abortEarly,
|
|
10626
|
+
abortPipeEarly: config$1?.abortPipeEarly ?? store$424?.abortPipeEarly
|
|
10627
|
+
};
|
|
10628
|
+
}
|
|
10629
|
+
var store$324;
|
|
10630
|
+
// @__NO_SIDE_EFFECTS__
|
|
10631
|
+
function getGlobalMessage24(lang) {
|
|
10632
|
+
return store$324?.get(lang);
|
|
10633
|
+
}
|
|
10634
|
+
var store$224;
|
|
10635
|
+
// @__NO_SIDE_EFFECTS__
|
|
10636
|
+
function getSchemaMessage24(lang) {
|
|
10637
|
+
return store$224?.get(lang);
|
|
10638
|
+
}
|
|
10639
|
+
var store$124;
|
|
10640
|
+
// @__NO_SIDE_EFFECTS__
|
|
10641
|
+
function getSpecificMessage24(reference, lang) {
|
|
10642
|
+
return store$124?.get(reference)?.get(lang);
|
|
10643
|
+
}
|
|
10644
|
+
// @__NO_SIDE_EFFECTS__
|
|
10645
|
+
function _stringify24(input) {
|
|
10646
|
+
const type = typeof input;
|
|
10647
|
+
if (type === "string") return `"${input}"`;
|
|
10648
|
+
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
10649
|
+
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
10650
|
+
return type;
|
|
10651
|
+
}
|
|
10652
|
+
function _addIssue24(context, label, dataset, config$1, other) {
|
|
10653
|
+
const input = other && "input" in other ? other.input : dataset.value;
|
|
10654
|
+
const expected = other?.expected ?? context.expects ?? null;
|
|
10655
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify24(input);
|
|
10656
|
+
const issue = {
|
|
10657
|
+
kind: context.kind,
|
|
10658
|
+
type: context.type,
|
|
10659
|
+
input,
|
|
10660
|
+
expected,
|
|
10661
|
+
received,
|
|
10662
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
10663
|
+
requirement: context.requirement,
|
|
10664
|
+
path: other?.path,
|
|
10665
|
+
issues: other?.issues,
|
|
10666
|
+
lang: config$1.lang,
|
|
10667
|
+
abortEarly: config$1.abortEarly,
|
|
10668
|
+
abortPipeEarly: config$1.abortPipeEarly
|
|
10669
|
+
};
|
|
10670
|
+
const isSchema = context.kind === "schema";
|
|
10671
|
+
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage24(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage24(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage24(issue.lang);
|
|
10672
|
+
if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
|
|
10673
|
+
if (isSchema) dataset.typed = false;
|
|
10674
|
+
if (dataset.issues) dataset.issues.push(issue);
|
|
10675
|
+
else dataset.issues = [issue];
|
|
10676
|
+
}
|
|
10677
|
+
var _standardCache24 = /* @__PURE__ */ new WeakMap();
|
|
10678
|
+
// @__NO_SIDE_EFFECTS__
|
|
10679
|
+
function _getStandardProps24(context) {
|
|
10680
|
+
let cached = _standardCache24.get(context);
|
|
10681
|
+
if (!cached) {
|
|
10682
|
+
cached = {
|
|
10683
|
+
version: 1,
|
|
10684
|
+
vendor: "valibot",
|
|
10685
|
+
validate(value$1) {
|
|
10686
|
+
return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig24());
|
|
10687
|
+
}
|
|
10688
|
+
};
|
|
10689
|
+
_standardCache24.set(context, cached);
|
|
10690
|
+
}
|
|
10691
|
+
return cached;
|
|
10692
|
+
}
|
|
10693
|
+
var EMOJI_REGEX24 = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
|
|
10694
|
+
// @__NO_SIDE_EFFECTS__
|
|
10695
|
+
function getFallback5(schema, dataset, config$1) {
|
|
10696
|
+
return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
|
|
10697
|
+
}
|
|
10698
|
+
// @__NO_SIDE_EFFECTS__
|
|
10699
|
+
function getDefault5(schema, dataset, config$1) {
|
|
10700
|
+
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
|
|
10701
|
+
}
|
|
10702
|
+
// @__NO_SIDE_EFFECTS__
|
|
10703
|
+
function array24(item, message$1) {
|
|
10704
|
+
return {
|
|
10705
|
+
kind: "schema",
|
|
10706
|
+
type: "array",
|
|
10707
|
+
reference: array24,
|
|
10708
|
+
expects: "Array",
|
|
10709
|
+
async: false,
|
|
10710
|
+
item,
|
|
10711
|
+
message: message$1,
|
|
10712
|
+
get "~standard"() {
|
|
10713
|
+
return /* @__PURE__ */ _getStandardProps24(this);
|
|
10714
|
+
},
|
|
10715
|
+
"~run"(dataset, config$1) {
|
|
10716
|
+
const input = dataset.value;
|
|
10717
|
+
if (Array.isArray(input)) {
|
|
10718
|
+
dataset.typed = true;
|
|
10719
|
+
dataset.value = [];
|
|
10720
|
+
for (let key = 0; key < input.length; key++) {
|
|
10721
|
+
const value$1 = input[key];
|
|
10722
|
+
const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
|
|
10723
|
+
if (itemDataset.issues) {
|
|
10724
|
+
const pathItem = {
|
|
10725
|
+
type: "array",
|
|
10726
|
+
origin: "value",
|
|
10727
|
+
input,
|
|
10728
|
+
key,
|
|
10729
|
+
value: value$1
|
|
10730
|
+
};
|
|
10731
|
+
for (const issue of itemDataset.issues) {
|
|
10732
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
10733
|
+
else issue.path = [pathItem];
|
|
10734
|
+
dataset.issues?.push(issue);
|
|
10735
|
+
}
|
|
10736
|
+
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
10737
|
+
if (config$1.abortEarly) {
|
|
10738
|
+
dataset.typed = false;
|
|
10739
|
+
break;
|
|
10740
|
+
}
|
|
10741
|
+
}
|
|
10742
|
+
if (!itemDataset.typed) dataset.typed = false;
|
|
10743
|
+
dataset.value.push(itemDataset.value);
|
|
10744
|
+
}
|
|
10745
|
+
} else _addIssue24(this, "type", dataset, config$1);
|
|
10746
|
+
return dataset;
|
|
10747
|
+
}
|
|
10748
|
+
};
|
|
10749
|
+
}
|
|
10750
|
+
// @__NO_SIDE_EFFECTS__
|
|
10751
|
+
function boolean4(message$1) {
|
|
10752
|
+
return {
|
|
10753
|
+
kind: "schema",
|
|
10754
|
+
type: "boolean",
|
|
10755
|
+
reference: boolean4,
|
|
10756
|
+
expects: "boolean",
|
|
10757
|
+
async: false,
|
|
10758
|
+
message: message$1,
|
|
10759
|
+
get "~standard"() {
|
|
10760
|
+
return /* @__PURE__ */ _getStandardProps24(this);
|
|
10761
|
+
},
|
|
10762
|
+
"~run"(dataset, config$1) {
|
|
10763
|
+
if (typeof dataset.value === "boolean") dataset.typed = true;
|
|
10764
|
+
else _addIssue24(this, "type", dataset, config$1);
|
|
10765
|
+
return dataset;
|
|
10766
|
+
}
|
|
10767
|
+
};
|
|
10768
|
+
}
|
|
10769
|
+
// @__NO_SIDE_EFFECTS__
|
|
10770
|
+
function literal4(literal_, message$1) {
|
|
10771
|
+
return {
|
|
10772
|
+
kind: "schema",
|
|
10773
|
+
type: "literal",
|
|
10774
|
+
reference: literal4,
|
|
10775
|
+
expects: /* @__PURE__ */ _stringify24(literal_),
|
|
10776
|
+
async: false,
|
|
10777
|
+
literal: literal_,
|
|
10778
|
+
message: message$1,
|
|
10779
|
+
get "~standard"() {
|
|
10780
|
+
return /* @__PURE__ */ _getStandardProps24(this);
|
|
10781
|
+
},
|
|
10782
|
+
"~run"(dataset, config$1) {
|
|
10783
|
+
if (dataset.value === this.literal) dataset.typed = true;
|
|
10784
|
+
else _addIssue24(this, "type", dataset, config$1);
|
|
10785
|
+
return dataset;
|
|
10786
|
+
}
|
|
10787
|
+
};
|
|
10788
|
+
}
|
|
10789
|
+
// @__NO_SIDE_EFFECTS__
|
|
10790
|
+
function object5(entries$1, message$1) {
|
|
10791
|
+
return {
|
|
10792
|
+
kind: "schema",
|
|
10793
|
+
type: "object",
|
|
10794
|
+
reference: object5,
|
|
10795
|
+
expects: "Object",
|
|
10796
|
+
async: false,
|
|
10797
|
+
entries: entries$1,
|
|
10798
|
+
message: message$1,
|
|
10799
|
+
get "~standard"() {
|
|
10800
|
+
return /* @__PURE__ */ _getStandardProps24(this);
|
|
10801
|
+
},
|
|
10802
|
+
"~run"(dataset, config$1) {
|
|
10803
|
+
const input = dataset.value;
|
|
10804
|
+
if (input && typeof input === "object") {
|
|
10805
|
+
dataset.typed = true;
|
|
10806
|
+
dataset.value = {};
|
|
10807
|
+
for (const key in this.entries) {
|
|
10808
|
+
const valueSchema = this.entries[key];
|
|
10809
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
10810
|
+
const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault5(valueSchema);
|
|
10811
|
+
const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
10812
|
+
if (valueDataset.issues) {
|
|
10813
|
+
const pathItem = {
|
|
10814
|
+
type: "object",
|
|
10815
|
+
origin: "value",
|
|
10816
|
+
input,
|
|
10817
|
+
key,
|
|
10818
|
+
value: value$1
|
|
10819
|
+
};
|
|
10820
|
+
for (const issue of valueDataset.issues) {
|
|
10821
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
10822
|
+
else issue.path = [pathItem];
|
|
10823
|
+
dataset.issues?.push(issue);
|
|
10824
|
+
}
|
|
10825
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
10826
|
+
if (config$1.abortEarly) {
|
|
10827
|
+
dataset.typed = false;
|
|
10828
|
+
break;
|
|
10829
|
+
}
|
|
10830
|
+
}
|
|
10831
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
10832
|
+
dataset.value[key] = valueDataset.value;
|
|
10833
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback5(valueSchema);
|
|
10834
|
+
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
10835
|
+
_addIssue24(this, "key", dataset, config$1, {
|
|
10836
|
+
input: void 0,
|
|
10837
|
+
expected: `"${key}"`,
|
|
10838
|
+
path: [{
|
|
10839
|
+
type: "object",
|
|
10840
|
+
origin: "key",
|
|
10841
|
+
input,
|
|
10842
|
+
key,
|
|
10843
|
+
value: input[key]
|
|
10844
|
+
}]
|
|
10845
|
+
});
|
|
10846
|
+
if (config$1.abortEarly) break;
|
|
10847
|
+
}
|
|
10848
|
+
}
|
|
10849
|
+
} else _addIssue24(this, "type", dataset, config$1);
|
|
10850
|
+
return dataset;
|
|
10851
|
+
}
|
|
10852
|
+
};
|
|
10853
|
+
}
|
|
10854
|
+
// @__NO_SIDE_EFFECTS__
|
|
10855
|
+
function optional5(wrapped, default_) {
|
|
10856
|
+
return {
|
|
10857
|
+
kind: "schema",
|
|
10858
|
+
type: "optional",
|
|
10859
|
+
reference: optional5,
|
|
10860
|
+
expects: `(${wrapped.expects} | undefined)`,
|
|
10861
|
+
async: false,
|
|
10862
|
+
wrapped,
|
|
10863
|
+
default: default_,
|
|
10864
|
+
get "~standard"() {
|
|
10865
|
+
return /* @__PURE__ */ _getStandardProps24(this);
|
|
10866
|
+
},
|
|
10867
|
+
"~run"(dataset, config$1) {
|
|
10868
|
+
if (dataset.value === void 0) {
|
|
10869
|
+
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault5(this, dataset, config$1);
|
|
10870
|
+
if (dataset.value === void 0) {
|
|
10871
|
+
dataset.typed = true;
|
|
10872
|
+
return dataset;
|
|
10873
|
+
}
|
|
10874
|
+
}
|
|
10875
|
+
return this.wrapped["~run"](dataset, config$1);
|
|
10876
|
+
}
|
|
10877
|
+
};
|
|
10878
|
+
}
|
|
10879
|
+
// @__NO_SIDE_EFFECTS__
|
|
10880
|
+
function string24(message$1) {
|
|
10881
|
+
return {
|
|
10882
|
+
kind: "schema",
|
|
10883
|
+
type: "string",
|
|
10884
|
+
reference: string24,
|
|
10885
|
+
expects: "string",
|
|
10886
|
+
async: false,
|
|
10887
|
+
message: message$1,
|
|
10888
|
+
get "~standard"() {
|
|
10889
|
+
return /* @__PURE__ */ _getStandardProps24(this);
|
|
10890
|
+
},
|
|
10891
|
+
"~run"(dataset, config$1) {
|
|
10892
|
+
if (typeof dataset.value === "string") dataset.typed = true;
|
|
10893
|
+
else _addIssue24(this, "type", dataset, config$1);
|
|
10894
|
+
return dataset;
|
|
10895
|
+
}
|
|
10896
|
+
};
|
|
10897
|
+
}
|
|
10898
|
+
// @__NO_SIDE_EFFECTS__
|
|
10899
|
+
function safeParse24(schema, input, config$1) {
|
|
10900
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig24(config$1));
|
|
10901
|
+
return {
|
|
10902
|
+
typed: dataset.typed,
|
|
10903
|
+
success: !dataset.issues,
|
|
10904
|
+
output: dataset.value,
|
|
10905
|
+
issues: dataset.issues
|
|
10906
|
+
};
|
|
10907
|
+
}
|
|
10908
|
+
var YabSourceSchema = /* @__PURE__ */ object5({
|
|
10909
|
+
type: /* @__PURE__ */ literal4("yab"),
|
|
10910
|
+
url: /* @__PURE__ */ string24(),
|
|
10911
|
+
space: /* @__PURE__ */ optional5(/* @__PURE__ */ string24()),
|
|
10912
|
+
match: /* @__PURE__ */ optional5(/* @__PURE__ */ string24()),
|
|
10913
|
+
exclude: /* @__PURE__ */ optional5(/* @__PURE__ */ string24())
|
|
10914
|
+
});
|
|
10915
|
+
var YabCursorSchema = /* @__PURE__ */ object5({
|
|
10916
|
+
primed: /* @__PURE__ */ boolean4(),
|
|
10917
|
+
seenIds: /* @__PURE__ */ array24(/* @__PURE__ */ string24())
|
|
10918
|
+
});
|
|
10919
|
+
var SEEN_LIMIT = 1e3;
|
|
10920
|
+
function feedEvents(source, entries, cursorRaw) {
|
|
10921
|
+
const parsedCursor = /* @__PURE__ */ safeParse24(YabCursorSchema, cursorRaw);
|
|
10922
|
+
let previous = {};
|
|
10923
|
+
if (parsedCursor.success) previous = parsedCursor.output;
|
|
10924
|
+
const cursor = { primed: previous.primed ?? false, seenIds: previous.seenIds ?? [] };
|
|
10925
|
+
let events = [];
|
|
10926
|
+
if (cursor.primed) {
|
|
10927
|
+
const seen = new Set(cursor.seenIds);
|
|
10928
|
+
const match = source.match ? new RegExp(source.match, "i") : void 0;
|
|
10929
|
+
const exclude = source.exclude ? new RegExp(source.exclude, "i") : void 0;
|
|
10930
|
+
events = entries.filter((entry) => !seen.has(entry.id)).filter((entry) => {
|
|
10931
|
+
const text = [entry.title, entry.summary, entry.author].filter(Boolean).join("\n");
|
|
10932
|
+
if (match && !match.test(text)) return false;
|
|
10933
|
+
if (exclude && exclude.test(text)) return false;
|
|
10934
|
+
return true;
|
|
10935
|
+
}).sort((left, right) => left.at && right.at ? left.at.localeCompare(right.at) : 0).map(entryEvent);
|
|
10936
|
+
}
|
|
10937
|
+
cursor.primed = true;
|
|
10938
|
+
cursor.seenIds = [.../* @__PURE__ */ new Set([...cursor.seenIds, ...entries.map((entry) => entry.id)])].slice(-SEEN_LIMIT);
|
|
10939
|
+
return { events, cursor };
|
|
10940
|
+
}
|
|
10941
|
+
function entryEvent(entry) {
|
|
10942
|
+
const title = entry.title || "(untitled)";
|
|
10943
|
+
return {
|
|
10944
|
+
kind: "entry",
|
|
10945
|
+
id: `entry:${entry.id}`,
|
|
10946
|
+
at: entry.at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
10947
|
+
summary: entry.author ? `Yab feed entry from ${entry.author}: ${title}` : `Yab feed entry: ${title}`,
|
|
10948
|
+
body: [entry.summary, entry.link].filter(Boolean).join("\n\n") || void 0,
|
|
10949
|
+
actionable: true
|
|
10950
|
+
};
|
|
10951
|
+
}
|
|
10952
|
+
var INVISIBLE = /[\u00AD\u034F\u061C\u115F\u1160\u17B4\u17B5\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u3164\uFEFF]/g;
|
|
10953
|
+
var ENTITIES = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: " " };
|
|
10954
|
+
function parseFeed(body, type = "") {
|
|
10955
|
+
const text = body.trim();
|
|
10956
|
+
if (/json/i.test(type) || text.startsWith("{") || text.startsWith("[")) return parseJsonFeed(text);
|
|
10957
|
+
if (!/<(feed|rss|rdf:RDF)[\s>]/i.test(text)) throw new Error("the page is not an Atom, RSS or JSON feed");
|
|
10958
|
+
const entries = elements(text, "entry");
|
|
10959
|
+
const blocks = entries.length > 0 ? entries : elements(text, "item");
|
|
10960
|
+
return blocks.map(xmlEntry).filter((entry) => entry !== void 0);
|
|
10961
|
+
}
|
|
10962
|
+
function xmlEntry(block) {
|
|
10963
|
+
const title = clean(child(block, "title")) ?? "";
|
|
10964
|
+
const summary = clean(child(block, "summary") ?? child(block, "description") ?? child(block, "content") ?? child(block, "content:encoded"));
|
|
10965
|
+
const link22 = atomLink(block) ?? clean(child(block, "link"));
|
|
10966
|
+
const at = firstDate([child(block, "updated"), child(block, "modified"), child(block, "issued"), child(block, "published"), child(block, "pubDate"), child(block, "dc:date")]);
|
|
10967
|
+
const id = clean(child(block, "id")) ?? clean(child(block, "guid")) ?? link22 ?? (title && at ? `${title}@${at}` : title);
|
|
10968
|
+
if (!id) return void 0;
|
|
10969
|
+
return compact({ id, title, summary, author: xmlAuthor(block), link: link22, at });
|
|
10970
|
+
}
|
|
10971
|
+
function xmlAuthor(block) {
|
|
10972
|
+
const author = child(block, "author");
|
|
10973
|
+
if (author && /<(name|email)[\s>]/i.test(author)) {
|
|
10974
|
+
const name = clean(child(author, "name"));
|
|
10975
|
+
const email = clean(child(author, "email"));
|
|
10976
|
+
if (name && email) return `${name} <${email}>`;
|
|
10977
|
+
return name ?? email;
|
|
10978
|
+
}
|
|
10979
|
+
return clean(author) ?? clean(child(block, "dc:creator"));
|
|
10980
|
+
}
|
|
10981
|
+
function atomLink(block) {
|
|
10982
|
+
let fallback;
|
|
10983
|
+
for (const match of block.matchAll(/<link\b([^>]*?)\/?>/gi)) {
|
|
10984
|
+
const attributes = match[1] ?? "";
|
|
10985
|
+
const href = attributes.match(/\bhref\s*=\s*["']([^"']*)["']/i)?.[1];
|
|
10986
|
+
if (!href) continue;
|
|
10987
|
+
const rel = attributes.match(/\brel\s*=\s*["']([^"']*)["']/i)?.[1];
|
|
10988
|
+
if (!rel || rel === "alternate") return decodeEntities(href);
|
|
10989
|
+
fallback ??= decodeEntities(href);
|
|
10990
|
+
}
|
|
10991
|
+
return fallback;
|
|
10992
|
+
}
|
|
10993
|
+
function parseJsonFeed(text) {
|
|
10994
|
+
const data = JSON.parse(text);
|
|
10995
|
+
let items;
|
|
10996
|
+
if (Array.isArray(data)) items = data;
|
|
10997
|
+
else if (Array.isArray(data?.items)) items = data.items;
|
|
10998
|
+
else if (Array.isArray(data?.entries)) items = data.entries;
|
|
10999
|
+
if (!items) throw new Error("the JSON has no items or entries list");
|
|
11000
|
+
const entries = [];
|
|
11001
|
+
for (const item of items) {
|
|
11002
|
+
if (!item || typeof item !== "object") continue;
|
|
11003
|
+
const link22 = text_(item.url ?? item.link ?? item.html_url);
|
|
11004
|
+
const title = clean(text_(item.title ?? item.subject ?? item.name)) ?? "";
|
|
11005
|
+
const at = firstDate([item.date_published, item.date_modified, item.updated, item.published, item.date, item.created_at]);
|
|
11006
|
+
const id = text_(item.id ?? item.guid) ?? link22 ?? (title && at ? `${title}@${at}` : title);
|
|
11007
|
+
if (!id) continue;
|
|
11008
|
+
const summary = clean(text_(item.summary ?? item.content_text ?? item.description ?? item.content_html ?? item.body ?? item.text));
|
|
11009
|
+
const author = clean(text_(item.author?.name ?? item.authors?.[0]?.name ?? item.author ?? item.from));
|
|
11010
|
+
entries.push(compact({ id, title, summary, author, link: link22, at }));
|
|
11011
|
+
}
|
|
11012
|
+
return entries;
|
|
11013
|
+
}
|
|
11014
|
+
function elements(xml, tag) {
|
|
11015
|
+
const pattern = new RegExp(`<${tag}(?:\\s[^>]*)?>([\\s\\S]*?)</${tag}>`, "gi");
|
|
11016
|
+
return [...xml.matchAll(pattern)].map((match) => match[1] ?? "");
|
|
11017
|
+
}
|
|
11018
|
+
function child(xml, tag) {
|
|
11019
|
+
return elements(xml, tag)[0];
|
|
11020
|
+
}
|
|
11021
|
+
function clean(value) {
|
|
11022
|
+
if (value === void 0) return void 0;
|
|
11023
|
+
const unwrapped = value.replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, "$1");
|
|
11024
|
+
const decoded = decodeEntities(stripTags(unwrapped));
|
|
11025
|
+
const text = stripTags(decoded).replace(INVISIBLE, "").replace(/\s+/g, " ").trim();
|
|
11026
|
+
return text || void 0;
|
|
11027
|
+
}
|
|
11028
|
+
function stripTags(value) {
|
|
11029
|
+
return value.replace(/<[^>]*>/g, " ");
|
|
11030
|
+
}
|
|
11031
|
+
function decodeEntities(value) {
|
|
11032
|
+
return value.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (entity, name) => {
|
|
11033
|
+
if (name[0] === "#") {
|
|
11034
|
+
const code = name[1]?.toLowerCase() === "x" ? Number.parseInt(name.slice(2), 16) : Number.parseInt(name.slice(1), 10);
|
|
11035
|
+
return Number.isFinite(code) && code <= 1114111 ? String.fromCodePoint(code) : entity;
|
|
11036
|
+
}
|
|
11037
|
+
return ENTITIES[name.toLowerCase()] ?? entity;
|
|
11038
|
+
});
|
|
11039
|
+
}
|
|
11040
|
+
function firstDate(values) {
|
|
11041
|
+
for (const value of values) {
|
|
11042
|
+
const raw = typeof value === "string" ? clean(value) : void 0;
|
|
11043
|
+
if (!raw) continue;
|
|
11044
|
+
const time = Date.parse(raw);
|
|
11045
|
+
if (!Number.isNaN(time)) return new Date(time).toISOString();
|
|
11046
|
+
}
|
|
11047
|
+
return void 0;
|
|
11048
|
+
}
|
|
11049
|
+
function text_(value) {
|
|
11050
|
+
if (typeof value === "string" && value.trim()) return value.trim();
|
|
11051
|
+
if (typeof value === "number") return String(value);
|
|
11052
|
+
return void 0;
|
|
11053
|
+
}
|
|
11054
|
+
function compact(entry) {
|
|
11055
|
+
const result = { id: entry.id, title: entry.title };
|
|
11056
|
+
if (entry.summary) result.summary = entry.summary;
|
|
11057
|
+
if (entry.author) result.author = entry.author;
|
|
11058
|
+
if (entry.link) result.link = entry.link;
|
|
11059
|
+
if (entry.at) result.at = entry.at;
|
|
11060
|
+
return result;
|
|
11061
|
+
}
|
|
11062
|
+
var DEFAULT_YAB_COMMAND = "/Applications/yab.app/Contents/MacOS/yab";
|
|
11063
|
+
var TIMEOUT_MS = 45e3;
|
|
11064
|
+
async function fetchThroughYab(url, space) {
|
|
11065
|
+
const args = { url, html: true };
|
|
11066
|
+
if (space) args.space = space;
|
|
11067
|
+
return parseYabFetch(await callYabTool("fetch", args));
|
|
11068
|
+
}
|
|
11069
|
+
function parseYabFetch(text) {
|
|
11070
|
+
const split = text.indexOf("\n\n");
|
|
11071
|
+
const head = split >= 0 ? text.slice(0, split) : text;
|
|
11072
|
+
const body = split >= 0 ? text.slice(split + 2) : "";
|
|
11073
|
+
const [status = "", type = "", ...rest] = head.split(" \xB7 ");
|
|
11074
|
+
const code = Number(status.trim());
|
|
11075
|
+
if (!Number.isInteger(code) || code <= 0) throw new Error(`yab fetch gave an unexpected answer: ${head.slice(0, 200)}`);
|
|
11076
|
+
return { status: code, type: type.trim(), url: rest.join(" \xB7 ").trim(), body };
|
|
11077
|
+
}
|
|
11078
|
+
function callYabTool(name, args) {
|
|
11079
|
+
const command = process.env.SOURCEFED_YAB_COMMAND || DEFAULT_YAB_COMMAND;
|
|
11080
|
+
return new Promise((resolve, reject) => {
|
|
11081
|
+
const child2 = spawn(command, ["mcp"], { stdio: ["pipe", "pipe", "pipe"] });
|
|
11082
|
+
let buffer = "";
|
|
11083
|
+
let stderr = "";
|
|
11084
|
+
let settled = false;
|
|
11085
|
+
const finish = (error, value = "") => {
|
|
11086
|
+
if (settled) return;
|
|
11087
|
+
settled = true;
|
|
11088
|
+
clearTimeout(timer);
|
|
11089
|
+
child2.kill();
|
|
11090
|
+
if (error) reject(error);
|
|
11091
|
+
else resolve(value);
|
|
11092
|
+
};
|
|
11093
|
+
const send = (message) => {
|
|
11094
|
+
child2.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", ...message })}
|
|
11095
|
+
`);
|
|
11096
|
+
};
|
|
11097
|
+
const timer = setTimeout(() => finish(new Error(`yab ${name} timed out after ${TIMEOUT_MS / 1e3}s`)), TIMEOUT_MS);
|
|
11098
|
+
child2.on("error", (error) => finish(new Error(`yab mcp could not start (${command}): ${error.message}`)));
|
|
11099
|
+
child2.on("exit", (code) => {
|
|
11100
|
+
const detail = stderr.trim() ? `: ${stderr.trim().slice(0, 300)}` : "";
|
|
11101
|
+
finish(new Error(`yab mcp exited (${code ?? "signal"}) before answering${detail}`));
|
|
11102
|
+
});
|
|
11103
|
+
child2.stdin.on("error", () => {
|
|
11104
|
+
});
|
|
11105
|
+
child2.stderr.setEncoding("utf8");
|
|
11106
|
+
child2.stderr.on("data", (chunk) => {
|
|
11107
|
+
stderr += chunk;
|
|
11108
|
+
});
|
|
11109
|
+
child2.stdout.setEncoding("utf8");
|
|
11110
|
+
child2.stdout.on("data", (chunk) => {
|
|
11111
|
+
buffer += chunk;
|
|
11112
|
+
let newline = buffer.indexOf("\n");
|
|
11113
|
+
while (newline >= 0) {
|
|
11114
|
+
const line = buffer.slice(0, newline).trim();
|
|
11115
|
+
buffer = buffer.slice(newline + 1);
|
|
11116
|
+
newline = buffer.indexOf("\n");
|
|
11117
|
+
if (!line) continue;
|
|
11118
|
+
let message;
|
|
11119
|
+
try {
|
|
11120
|
+
message = JSON.parse(line);
|
|
11121
|
+
} catch {
|
|
11122
|
+
continue;
|
|
11123
|
+
}
|
|
11124
|
+
if (message.id === 1) {
|
|
11125
|
+
if (message.error) return finish(new Error(`yab mcp initialize failed: ${message.error.message}`));
|
|
11126
|
+
send({ method: "notifications/initialized" });
|
|
11127
|
+
send({ id: 2, method: "tools/call", params: { name, arguments: args } });
|
|
11128
|
+
} else if (message.id === 2) {
|
|
11129
|
+
if (message.error) return finish(new Error(`yab ${name} failed: ${message.error.message}`));
|
|
11130
|
+
const content = Array.isArray(message.result?.content) ? message.result.content : [];
|
|
11131
|
+
const text = content.filter((part) => part?.type === "text").map((part) => String(part.text)).join("\n");
|
|
11132
|
+
if (message.result?.isError) return finish(new Error(`yab ${name} failed: ${text.slice(0, 300)}`));
|
|
11133
|
+
return finish(void 0, text);
|
|
11134
|
+
}
|
|
11135
|
+
}
|
|
11136
|
+
});
|
|
11137
|
+
send({
|
|
11138
|
+
id: 1,
|
|
11139
|
+
method: "initialize",
|
|
11140
|
+
params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "sourcefed", version: "0.3" } }
|
|
11141
|
+
});
|
|
11142
|
+
});
|
|
11143
|
+
}
|
|
11144
|
+
async function pollYab(source, cursorRaw, fetchPage = fetchThroughYab) {
|
|
11145
|
+
const page = await fetchPage(source.url, source.space);
|
|
11146
|
+
if (page.status >= 400) {
|
|
11147
|
+
const hint = page.status === 401 || page.status === 403 ? "; sign in to the site in Yab" : "";
|
|
11148
|
+
throw new Error(`yab fetch of ${source.url} answered ${page.status}${hint}`);
|
|
11149
|
+
}
|
|
11150
|
+
return { ...feedEvents(source, parseFeed(page.body, page.type), cursorRaw), terminal: false };
|
|
11151
|
+
}
|
|
11152
|
+
var yabPollMonitor = new PollMonitor4({
|
|
11153
|
+
run: async (source, cursor) => {
|
|
11154
|
+
const result = await pollYab(source, cursor);
|
|
11155
|
+
return {
|
|
11156
|
+
cursor: result.cursor,
|
|
11157
|
+
events: result.events.map((event) => toMonitorEvent4(event, source)),
|
|
11158
|
+
terminal: result.terminal
|
|
11159
|
+
};
|
|
11160
|
+
}
|
|
11161
|
+
});
|
|
11162
|
+
var YabMonitor = class extends Monitor4 {
|
|
11163
|
+
poll = yabPollMonitor;
|
|
11164
|
+
constructor() {
|
|
11165
|
+
super({ type: "yab", schema: YabSourceSchema });
|
|
11166
|
+
}
|
|
11167
|
+
key = (source) => `yab:${source.space ?? ""}:${source.url}`;
|
|
11168
|
+
icon = "\u{F059F}";
|
|
11169
|
+
label = (source) => new URL(source.url).hostname;
|
|
11170
|
+
detail = (source) => ` ${shortUrl(source.url)}${source.match || source.exclude ? " \xB7 filtered" : ""}`;
|
|
11171
|
+
describe = (source) => `Yab feed ${shortUrl(source.url)}${source.space ? ` (${source.space})` : ""}`;
|
|
11172
|
+
build(input) {
|
|
11173
|
+
if (!input.url) return { error: "url is required for a yab monitor" };
|
|
11174
|
+
let url;
|
|
11175
|
+
try {
|
|
11176
|
+
url = new URL(input.url);
|
|
11177
|
+
} catch {
|
|
11178
|
+
return { error: "url must be a valid http(s) URL" };
|
|
11179
|
+
}
|
|
11180
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") return { error: "url must be a valid http(s) URL" };
|
|
11181
|
+
for (const [key, pattern] of [["match", input.match], ["exclude", input.exclude]]) {
|
|
11182
|
+
if (!pattern) continue;
|
|
11183
|
+
try {
|
|
11184
|
+
new RegExp(pattern, "i");
|
|
11185
|
+
} catch {
|
|
11186
|
+
return { error: `${key} must be a valid regular expression` };
|
|
11187
|
+
}
|
|
11188
|
+
}
|
|
11189
|
+
const source = { type: "yab", url: url.href };
|
|
11190
|
+
if (input.space) source.space = input.space;
|
|
11191
|
+
if (input.match) source.match = input.match;
|
|
11192
|
+
if (input.exclude) source.exclude = input.exclude;
|
|
11193
|
+
return source;
|
|
11194
|
+
}
|
|
11195
|
+
};
|
|
11196
|
+
function shortUrl(href) {
|
|
11197
|
+
const url = new URL(href);
|
|
11198
|
+
return `${url.hostname}${url.pathname === "/" ? "" : url.pathname}`;
|
|
11199
|
+
}
|
|
11200
|
+
|
|
10309
11201
|
// packages/daemon/src/registry.ts
|
|
10310
11202
|
var SOURCE_MAP = {
|
|
10311
11203
|
jira: new JiraMonitor(),
|
|
10312
11204
|
github: new GithubMonitor(),
|
|
10313
|
-
slack: new SlackMonitor()
|
|
11205
|
+
slack: new SlackMonitor(),
|
|
11206
|
+
yab: new YabMonitor()
|
|
10314
11207
|
};
|
|
10315
11208
|
var SOURCE_TYPES = Object.keys(SOURCE_MAP);
|
|
10316
11209
|
function sourceDefinition(source) {
|
|
@@ -10332,8 +11225,8 @@ function sourceForWebhookPath(pathname) {
|
|
|
10332
11225
|
}
|
|
10333
11226
|
|
|
10334
11227
|
// packages/daemon/src/utils/env.ts
|
|
10335
|
-
import
|
|
10336
|
-
import
|
|
11228
|
+
import os5 from "node:os";
|
|
11229
|
+
import path5 from "node:path";
|
|
10337
11230
|
var DAEMON_ENVIRONMENT = [
|
|
10338
11231
|
"PATH",
|
|
10339
11232
|
"HOME",
|
|
@@ -10361,7 +11254,7 @@ function daemonEnvironment(host) {
|
|
|
10361
11254
|
const environment = Object.fromEntries(
|
|
10362
11255
|
DAEMON_ENVIRONMENT.flatMap((name) => process.env[name] === void 0 ? [] : [[name, process.env[name]]])
|
|
10363
11256
|
);
|
|
10364
|
-
if (host) environment.SOURCEFED_STATE_DIR ??=
|
|
11257
|
+
if (host) environment.SOURCEFED_STATE_DIR ??= path5.join(process.env.XDG_STATE_HOME ?? path5.join(os5.homedir(), ".local", "state"), "sourcefed", host);
|
|
10365
11258
|
return environment;
|
|
10366
11259
|
}
|
|
10367
11260
|
|
|
@@ -10461,8 +11354,8 @@ async function writeResponse(outgoing, response) {
|
|
|
10461
11354
|
}
|
|
10462
11355
|
|
|
10463
11356
|
// packages/daemon/src/utils/spawn.ts
|
|
10464
|
-
import { spawn } from "node:child_process";
|
|
10465
|
-
import
|
|
11357
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
11358
|
+
import path6 from "node:path";
|
|
10466
11359
|
var DEFAULT_DAEMON_URL = "http://127.0.0.1:18787";
|
|
10467
11360
|
function defaultDaemonUrl() {
|
|
10468
11361
|
const port = process.env.SOURCEFED_DAEMON_PORT ?? 18787;
|
|
@@ -10475,7 +11368,7 @@ function daemonCommand(cliEntryPath) {
|
|
|
10475
11368
|
};
|
|
10476
11369
|
}
|
|
10477
11370
|
function nodeExecutable() {
|
|
10478
|
-
const base =
|
|
11371
|
+
const base = path6.basename(process.execPath);
|
|
10479
11372
|
if (base.includes("node") || base.includes("bun")) return process.execPath;
|
|
10480
11373
|
return "node";
|
|
10481
11374
|
}
|
|
@@ -10484,7 +11377,7 @@ async function spawnLocalDaemon(options) {
|
|
|
10484
11377
|
const url = `http://127.0.0.1:${port}`;
|
|
10485
11378
|
const token = options.env?.SOURCEFED_DAEMON_TOKEN ?? process.env.SOURCEFED_DAEMON_TOKEN;
|
|
10486
11379
|
if (await daemonReachable(url, 750, token)) return { url };
|
|
10487
|
-
const proc =
|
|
11380
|
+
const proc = spawn2(options.command, [...options.args, "--port", String(port)], {
|
|
10488
11381
|
stdio: ["ignore", "ignore", "ignore"],
|
|
10489
11382
|
detached: true,
|
|
10490
11383
|
env: { ...process.env, ...options.env }
|
|
@@ -11134,7 +12027,7 @@ function createCreateInput(params) {
|
|
|
11134
12027
|
name: params.name,
|
|
11135
12028
|
sourceType: params.sourceType
|
|
11136
12029
|
};
|
|
11137
|
-
for (const key of ["issueKey", "repo", "channelId", "threadTs", "threadUrl"]) {
|
|
12030
|
+
for (const key of ["issueKey", "repo", "channelId", "threadTs", "threadUrl", "url", "space", "match", "exclude"]) {
|
|
11138
12031
|
if (typeof params[key] === "string") input[key] = params[key];
|
|
11139
12032
|
}
|
|
11140
12033
|
if (typeof params.prNumber === "number") input.prNumber = params.prNumber;
|