neuralos 3.8.0 → 3.8.1
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/bin/gybackend.cjs +1531 -462
- package/package.json +1 -1
package/bin/gybackend.cjs
CHANGED
|
@@ -11,10 +11,10 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
11
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
12
|
var __getProtoOf = Object.getPrototypeOf;
|
|
13
13
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __glob = (map3) => (
|
|
15
|
-
var fn = map3[
|
|
14
|
+
var __glob = (map3) => (path34) => {
|
|
15
|
+
var fn = map3[path34];
|
|
16
16
|
if (fn) return fn();
|
|
17
|
-
throw new Error("Module not found in bundle: " +
|
|
17
|
+
throw new Error("Module not found in bundle: " + path34);
|
|
18
18
|
};
|
|
19
19
|
var __esm = (fn, res) => function __init() {
|
|
20
20
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
@@ -9040,7 +9040,7 @@ var require_eventemitter3 = __commonJS({
|
|
|
9040
9040
|
if (listeners.fn) return 1;
|
|
9041
9041
|
return listeners.length;
|
|
9042
9042
|
};
|
|
9043
|
-
EventEmitter4.prototype.emit = function
|
|
9043
|
+
EventEmitter4.prototype.emit = function emit12(event, a1, a2, a3, a4, a5) {
|
|
9044
9044
|
var evt = prefix ? prefix + event : event;
|
|
9045
9045
|
if (!this._events[evt]) return false;
|
|
9046
9046
|
var listeners = this._events[evt], len = arguments.length, args, i;
|
|
@@ -12024,8 +12024,8 @@ var init_parseUtil = __esm({
|
|
|
12024
12024
|
init_errors();
|
|
12025
12025
|
init_en();
|
|
12026
12026
|
makeIssue = (params) => {
|
|
12027
|
-
const { data, path:
|
|
12028
|
-
const fullPath = [...
|
|
12027
|
+
const { data, path: path34, errorMaps, issueData } = params;
|
|
12028
|
+
const fullPath = [...path34, ...issueData.path || []];
|
|
12029
12029
|
const fullIssue = {
|
|
12030
12030
|
...issueData,
|
|
12031
12031
|
path: fullPath
|
|
@@ -12333,11 +12333,11 @@ var init_types = __esm({
|
|
|
12333
12333
|
init_parseUtil();
|
|
12334
12334
|
init_util();
|
|
12335
12335
|
ParseInputLazyPath = class {
|
|
12336
|
-
constructor(parent, value,
|
|
12336
|
+
constructor(parent, value, path34, key) {
|
|
12337
12337
|
this._cachedPath = [];
|
|
12338
12338
|
this.parent = parent;
|
|
12339
12339
|
this.data = value;
|
|
12340
|
-
this._path =
|
|
12340
|
+
this._path = path34;
|
|
12341
12341
|
this._key = key;
|
|
12342
12342
|
}
|
|
12343
12343
|
get path() {
|
|
@@ -27268,11 +27268,11 @@ var require_pdf_worker = __commonJS({
|
|
|
27268
27268
|
var nameTree = new NameTree(nameTreeRef, xref);
|
|
27269
27269
|
var names = nameTree.getAll();
|
|
27270
27270
|
for (var name in names) {
|
|
27271
|
-
var
|
|
27271
|
+
var fs25 = new FileSpec(names[name], xref);
|
|
27272
27272
|
if (!attachments) {
|
|
27273
27273
|
attachments = /* @__PURE__ */ Object.create(null);
|
|
27274
27274
|
}
|
|
27275
|
-
attachments[(0, _util.stringToPDFString)(name)] =
|
|
27275
|
+
attachments[(0, _util.stringToPDFString)(name)] = fs25.serializable;
|
|
27276
27276
|
}
|
|
27277
27277
|
}
|
|
27278
27278
|
return (0, _util.shadow)(this, "attachments", attachments);
|
|
@@ -32572,8 +32572,8 @@ var require_pdf_worker = __commonJS({
|
|
|
32572
32572
|
if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
|
|
32573
32573
|
var buildPath = function buildPath2(fontChar) {
|
|
32574
32574
|
if (!font.renderer.hasBuiltPath(fontChar)) {
|
|
32575
|
-
var
|
|
32576
|
-
_this5.handler.send("commonobj", [font.loadedName + "_path_" + fontChar, "FontPath",
|
|
32575
|
+
var path34 = font.renderer.getPathJs(fontChar);
|
|
32576
|
+
_this5.handler.send("commonobj", [font.loadedName + "_path_" + fontChar, "FontPath", path34]);
|
|
32577
32577
|
}
|
|
32578
32578
|
};
|
|
32579
32579
|
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
|
@@ -75261,10 +75261,10 @@ var require_pdf = __commonJS({
|
|
|
75261
75261
|
ctx.save();
|
|
75262
75262
|
ctx.beginPath();
|
|
75263
75263
|
for (var i = 0; i < paths.length; i++) {
|
|
75264
|
-
var
|
|
75265
|
-
ctx.setTransform.apply(ctx,
|
|
75266
|
-
ctx.translate(
|
|
75267
|
-
|
|
75264
|
+
var path34 = paths[i];
|
|
75265
|
+
ctx.setTransform.apply(ctx, path34.transform);
|
|
75266
|
+
ctx.translate(path34.x, path34.y);
|
|
75267
|
+
path34.addToPath(ctx, path34.fontSize);
|
|
75268
75268
|
}
|
|
75269
75269
|
ctx.restore();
|
|
75270
75270
|
ctx.clip();
|
|
@@ -77124,7 +77124,7 @@ var require_pdf = __commonJS({
|
|
|
77124
77124
|
throw new TypeError("Cannot call a class as a function");
|
|
77125
77125
|
}
|
|
77126
77126
|
}
|
|
77127
|
-
var
|
|
77127
|
+
var fs25 = require("fs");
|
|
77128
77128
|
var http2 = require("http");
|
|
77129
77129
|
var https2 = require("https");
|
|
77130
77130
|
var url2 = require("url");
|
|
@@ -77457,8 +77457,8 @@ var require_pdf = __commonJS({
|
|
|
77457
77457
|
function PDFNodeStreamFsFullReader2(stream) {
|
|
77458
77458
|
_classCallCheck(this, PDFNodeStreamFsFullReader2);
|
|
77459
77459
|
var _this7 = _possibleConstructorReturn(this, (PDFNodeStreamFsFullReader2.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsFullReader2)).call(this, stream));
|
|
77460
|
-
var
|
|
77461
|
-
|
|
77460
|
+
var path34 = decodeURI(_this7._url.path);
|
|
77461
|
+
fs25.lstat(path34, function(error40, stat) {
|
|
77462
77462
|
if (error40) {
|
|
77463
77463
|
_this7._errored = true;
|
|
77464
77464
|
_this7._reason = error40;
|
|
@@ -77466,7 +77466,7 @@ var require_pdf = __commonJS({
|
|
|
77466
77466
|
return;
|
|
77467
77467
|
}
|
|
77468
77468
|
_this7._contentLength = stat.size;
|
|
77469
|
-
_this7._setReadableStream(
|
|
77469
|
+
_this7._setReadableStream(fs25.createReadStream(path34));
|
|
77470
77470
|
_this7._headersCapability.resolve();
|
|
77471
77471
|
});
|
|
77472
77472
|
return _this7;
|
|
@@ -77478,7 +77478,7 @@ var require_pdf = __commonJS({
|
|
|
77478
77478
|
function PDFNodeStreamFsRangeReader2(stream, start, end) {
|
|
77479
77479
|
_classCallCheck(this, PDFNodeStreamFsRangeReader2);
|
|
77480
77480
|
var _this8 = _possibleConstructorReturn(this, (PDFNodeStreamFsRangeReader2.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsRangeReader2)).call(this, stream));
|
|
77481
|
-
_this8._setReadableStream(
|
|
77481
|
+
_this8._setReadableStream(fs25.createReadStream(decodeURI(_this8._url.path), {
|
|
77482
77482
|
start,
|
|
77483
77483
|
end: end - 1
|
|
77484
77484
|
}));
|
|
@@ -89472,11 +89472,11 @@ var require_pdf_worker2 = __commonJS({
|
|
|
89472
89472
|
var nameTree = new NameTree(nameTreeRef, xref);
|
|
89473
89473
|
var names = nameTree.getAll();
|
|
89474
89474
|
for (var name in names) {
|
|
89475
|
-
var
|
|
89475
|
+
var fs25 = new FileSpec(names[name], xref);
|
|
89476
89476
|
if (!attachments) {
|
|
89477
89477
|
attachments = /* @__PURE__ */ Object.create(null);
|
|
89478
89478
|
}
|
|
89479
|
-
attachments[(0, _util.stringToPDFString)(name)] =
|
|
89479
|
+
attachments[(0, _util.stringToPDFString)(name)] = fs25.serializable;
|
|
89480
89480
|
}
|
|
89481
89481
|
}
|
|
89482
89482
|
return (0, _util.shadow)(this, "attachments", attachments);
|
|
@@ -94776,8 +94776,8 @@ var require_pdf_worker2 = __commonJS({
|
|
|
94776
94776
|
if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
|
|
94777
94777
|
var buildPath = function buildPath2(fontChar) {
|
|
94778
94778
|
if (!font.renderer.hasBuiltPath(fontChar)) {
|
|
94779
|
-
var
|
|
94780
|
-
_this5.handler.send("commonobj", [font.loadedName + "_path_" + fontChar, "FontPath",
|
|
94779
|
+
var path34 = font.renderer.getPathJs(fontChar);
|
|
94780
|
+
_this5.handler.send("commonobj", [font.loadedName + "_path_" + fontChar, "FontPath", path34]);
|
|
94781
94781
|
}
|
|
94782
94782
|
};
|
|
94783
94783
|
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
|
@@ -137573,10 +137573,10 @@ var require_pdf2 = __commonJS({
|
|
|
137573
137573
|
ctx.save();
|
|
137574
137574
|
ctx.beginPath();
|
|
137575
137575
|
for (var i = 0; i < paths.length; i++) {
|
|
137576
|
-
var
|
|
137577
|
-
ctx.setTransform.apply(ctx,
|
|
137578
|
-
ctx.translate(
|
|
137579
|
-
|
|
137576
|
+
var path34 = paths[i];
|
|
137577
|
+
ctx.setTransform.apply(ctx, path34.transform);
|
|
137578
|
+
ctx.translate(path34.x, path34.y);
|
|
137579
|
+
path34.addToPath(ctx, path34.fontSize);
|
|
137580
137580
|
}
|
|
137581
137581
|
ctx.restore();
|
|
137582
137582
|
ctx.clip();
|
|
@@ -138960,7 +138960,7 @@ var require_pdf2 = __commonJS({
|
|
|
138960
138960
|
throw new TypeError("Cannot call a class as a function");
|
|
138961
138961
|
}
|
|
138962
138962
|
}
|
|
138963
|
-
var
|
|
138963
|
+
var fs25 = require("fs");
|
|
138964
138964
|
var http2 = require("http");
|
|
138965
138965
|
var https2 = require("https");
|
|
138966
138966
|
var url2 = require("url");
|
|
@@ -139293,8 +139293,8 @@ var require_pdf2 = __commonJS({
|
|
|
139293
139293
|
function PDFNodeStreamFsFullReader2(stream) {
|
|
139294
139294
|
_classCallCheck(this, PDFNodeStreamFsFullReader2);
|
|
139295
139295
|
var _this7 = _possibleConstructorReturn(this, (PDFNodeStreamFsFullReader2.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsFullReader2)).call(this, stream));
|
|
139296
|
-
var
|
|
139297
|
-
|
|
139296
|
+
var path34 = decodeURI(_this7._url.path);
|
|
139297
|
+
fs25.lstat(path34, function(error40, stat) {
|
|
139298
139298
|
if (error40) {
|
|
139299
139299
|
_this7._errored = true;
|
|
139300
139300
|
_this7._reason = error40;
|
|
@@ -139302,7 +139302,7 @@ var require_pdf2 = __commonJS({
|
|
|
139302
139302
|
return;
|
|
139303
139303
|
}
|
|
139304
139304
|
_this7._contentLength = stat.size;
|
|
139305
|
-
_this7._setReadableStream(
|
|
139305
|
+
_this7._setReadableStream(fs25.createReadStream(path34));
|
|
139306
139306
|
_this7._headersCapability.resolve();
|
|
139307
139307
|
});
|
|
139308
139308
|
return _this7;
|
|
@@ -139314,7 +139314,7 @@ var require_pdf2 = __commonJS({
|
|
|
139314
139314
|
function PDFNodeStreamFsRangeReader2(stream, start, end) {
|
|
139315
139315
|
_classCallCheck(this, PDFNodeStreamFsRangeReader2);
|
|
139316
139316
|
var _this8 = _possibleConstructorReturn(this, (PDFNodeStreamFsRangeReader2.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsRangeReader2)).call(this, stream));
|
|
139317
|
-
_this8._setReadableStream(
|
|
139317
|
+
_this8._setReadableStream(fs25.createReadStream(decodeURI(_this8._url.path), {
|
|
139318
139318
|
start,
|
|
139319
139319
|
end: end - 1
|
|
139320
139320
|
}));
|
|
@@ -156879,8 +156879,8 @@ var require_pdf_worker3 = __commonJS({
|
|
|
156879
156879
|
if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
|
|
156880
156880
|
var buildPath = function buildPath2(fontChar) {
|
|
156881
156881
|
if (!font.renderer.hasBuiltPath(fontChar)) {
|
|
156882
|
-
var
|
|
156883
|
-
_this5.handler.send("commonobj", [font.loadedName + "_path_" + fontChar, "FontPath",
|
|
156882
|
+
var path34 = font.renderer.getPathJs(fontChar);
|
|
156883
|
+
_this5.handler.send("commonobj", [font.loadedName + "_path_" + fontChar, "FontPath", path34]);
|
|
156884
156884
|
}
|
|
156885
156885
|
};
|
|
156886
156886
|
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
|
@@ -161698,11 +161698,11 @@ var require_pdf_worker3 = __commonJS({
|
|
|
161698
161698
|
var nameTree = new NameTree(nameTreeRef, xref);
|
|
161699
161699
|
var names = nameTree.getAll();
|
|
161700
161700
|
for (var name in names) {
|
|
161701
|
-
var
|
|
161701
|
+
var fs25 = new FileSpec(names[name], xref);
|
|
161702
161702
|
if (!attachments) {
|
|
161703
161703
|
attachments = /* @__PURE__ */ Object.create(null);
|
|
161704
161704
|
}
|
|
161705
|
-
attachments[(0, _util.stringToPDFString)(name)] =
|
|
161705
|
+
attachments[(0, _util.stringToPDFString)(name)] = fs25.serializable;
|
|
161706
161706
|
}
|
|
161707
161707
|
}
|
|
161708
161708
|
return (0, _util.shadow)(this, "attachments", attachments);
|
|
@@ -191335,10 +191335,10 @@ var require_pdf3 = __commonJS({
|
|
|
191335
191335
|
ctx.save();
|
|
191336
191336
|
ctx.beginPath();
|
|
191337
191337
|
for (var i = 0; i < paths.length; i++) {
|
|
191338
|
-
var
|
|
191339
|
-
ctx.setTransform.apply(ctx,
|
|
191340
|
-
ctx.translate(
|
|
191341
|
-
|
|
191338
|
+
var path34 = paths[i];
|
|
191339
|
+
ctx.setTransform.apply(ctx, path34.transform);
|
|
191340
|
+
ctx.translate(path34.x, path34.y);
|
|
191341
|
+
path34.addToPath(ctx, path34.fontSize);
|
|
191342
191342
|
}
|
|
191343
191343
|
ctx.restore();
|
|
191344
191344
|
ctx.clip();
|
|
@@ -203583,11 +203583,11 @@ var require_pdf_worker4 = __commonJS({
|
|
|
203583
203583
|
var nameTree = new NameTree(nameTreeRef, xref);
|
|
203584
203584
|
var names = nameTree.getAll();
|
|
203585
203585
|
for (var name in names) {
|
|
203586
|
-
var
|
|
203586
|
+
var fs25 = new FileSpec(names[name], xref);
|
|
203587
203587
|
if (!attachments) {
|
|
203588
203588
|
attachments = /* @__PURE__ */ Object.create(null);
|
|
203589
203589
|
}
|
|
203590
|
-
attachments[(0, _util.stringToPDFString)(name)] =
|
|
203590
|
+
attachments[(0, _util.stringToPDFString)(name)] = fs25.serializable;
|
|
203591
203591
|
}
|
|
203592
203592
|
}
|
|
203593
203593
|
return (0, _util.shadow)(this, "attachments", attachments);
|
|
@@ -216733,8 +216733,8 @@ var require_pdf_worker4 = __commonJS({
|
|
|
216733
216733
|
if (font.data && (isAddToPathSet || this.options.disableFontFace || state.fillColorSpace.name === "Pattern")) {
|
|
216734
216734
|
var buildPath = function buildPath2(fontChar) {
|
|
216735
216735
|
if (!font.renderer.hasBuiltPath(fontChar)) {
|
|
216736
|
-
var
|
|
216737
|
-
_this5.handler.send("commonobj", [font.loadedName + "_path_" + fontChar, "FontPath",
|
|
216736
|
+
var path34 = font.renderer.getPathJs(fontChar);
|
|
216737
|
+
_this5.handler.send("commonobj", [font.loadedName + "_path_" + fontChar, "FontPath", path34]);
|
|
216738
216738
|
}
|
|
216739
216739
|
};
|
|
216740
216740
|
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
|
@@ -248698,10 +248698,10 @@ var require_pdf4 = __commonJS({
|
|
|
248698
248698
|
ctx.save();
|
|
248699
248699
|
ctx.beginPath();
|
|
248700
248700
|
for (var i = 0; i < paths.length; i++) {
|
|
248701
|
-
var
|
|
248702
|
-
ctx.setTransform.apply(ctx,
|
|
248703
|
-
ctx.translate(
|
|
248704
|
-
|
|
248701
|
+
var path34 = paths[i];
|
|
248702
|
+
ctx.setTransform.apply(ctx, path34.transform);
|
|
248703
|
+
ctx.translate(path34.x, path34.y);
|
|
248704
|
+
path34.addToPath(ctx, path34.fontSize);
|
|
248705
248705
|
}
|
|
248706
248706
|
ctx.restore();
|
|
248707
248707
|
ctx.clip();
|
|
@@ -253970,7 +253970,7 @@ var require_pdf4 = __commonJS({
|
|
|
253970
253970
|
throw new TypeError("Cannot call a class as a function");
|
|
253971
253971
|
}
|
|
253972
253972
|
}
|
|
253973
|
-
var
|
|
253973
|
+
var fs25 = require("fs");
|
|
253974
253974
|
var http2 = require("http");
|
|
253975
253975
|
var https2 = require("https");
|
|
253976
253976
|
var url2 = require("url");
|
|
@@ -254324,11 +254324,11 @@ var require_pdf4 = __commonJS({
|
|
|
254324
254324
|
function PDFNodeStreamFsFullReader2(stream) {
|
|
254325
254325
|
_classCallCheck(this, PDFNodeStreamFsFullReader2);
|
|
254326
254326
|
var _this7 = _possibleConstructorReturn(this, (PDFNodeStreamFsFullReader2.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsFullReader2)).call(this, stream));
|
|
254327
|
-
var
|
|
254327
|
+
var path34 = decodeURIComponent(_this7._url.path);
|
|
254328
254328
|
if (fileUriRegex.test(_this7._url.href)) {
|
|
254329
|
-
|
|
254329
|
+
path34 = path34.replace(/^\//, "");
|
|
254330
254330
|
}
|
|
254331
|
-
|
|
254331
|
+
fs25.lstat(path34, function(error40, stat) {
|
|
254332
254332
|
if (error40) {
|
|
254333
254333
|
_this7._errored = true;
|
|
254334
254334
|
_this7._reason = error40;
|
|
@@ -254336,7 +254336,7 @@ var require_pdf4 = __commonJS({
|
|
|
254336
254336
|
return;
|
|
254337
254337
|
}
|
|
254338
254338
|
_this7._contentLength = stat.size;
|
|
254339
|
-
_this7._setReadableStream(
|
|
254339
|
+
_this7._setReadableStream(fs25.createReadStream(path34));
|
|
254340
254340
|
_this7._headersCapability.resolve();
|
|
254341
254341
|
});
|
|
254342
254342
|
return _this7;
|
|
@@ -254348,11 +254348,11 @@ var require_pdf4 = __commonJS({
|
|
|
254348
254348
|
function PDFNodeStreamFsRangeReader2(stream, start, end) {
|
|
254349
254349
|
_classCallCheck(this, PDFNodeStreamFsRangeReader2);
|
|
254350
254350
|
var _this8 = _possibleConstructorReturn(this, (PDFNodeStreamFsRangeReader2.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsRangeReader2)).call(this, stream));
|
|
254351
|
-
var
|
|
254351
|
+
var path34 = decodeURIComponent(_this8._url.path);
|
|
254352
254352
|
if (fileUriRegex.test(_this8._url.href)) {
|
|
254353
|
-
|
|
254353
|
+
path34 = path34.replace(/^\//, "");
|
|
254354
254354
|
}
|
|
254355
|
-
_this8._setReadableStream(
|
|
254355
|
+
_this8._setReadableStream(fs25.createReadStream(path34, {
|
|
254356
254356
|
start,
|
|
254357
254357
|
end: end - 1
|
|
254358
254358
|
}));
|
|
@@ -257634,7 +257634,7 @@ function playbookNeedsOrchestration(playbook) {
|
|
|
257634
257634
|
(s) => s.dependsOn !== void 0 || s.desiredState || s.captureVar
|
|
257635
257635
|
);
|
|
257636
257636
|
}
|
|
257637
|
-
function
|
|
257637
|
+
function emit8(context2, toolName, input, output) {
|
|
257638
257638
|
context2.sendEvent(context2.sessionId, {
|
|
257639
257639
|
messageId: context2.messageId,
|
|
257640
257640
|
type: "tool_call",
|
|
@@ -257650,7 +257650,7 @@ async function managePlaybook(args, context2) {
|
|
|
257650
257650
|
const m2 = context2.automationManager;
|
|
257651
257651
|
if (!m2) {
|
|
257652
257652
|
const msg2 = noStore2();
|
|
257653
|
-
|
|
257653
|
+
emit8(context2, "manage_playbook", args, msg2);
|
|
257654
257654
|
return msg2;
|
|
257655
257655
|
}
|
|
257656
257656
|
const { action } = args;
|
|
@@ -257658,7 +257658,7 @@ async function managePlaybook(args, context2) {
|
|
|
257658
257658
|
const all = m2.listPlaybooks();
|
|
257659
257659
|
if (!all.length) {
|
|
257660
257660
|
const msg3 = "No playbooks. Create one with manage_playbook action=create.";
|
|
257661
|
-
|
|
257661
|
+
emit8(context2, "manage_playbook", args, msg3);
|
|
257662
257662
|
return msg3;
|
|
257663
257663
|
}
|
|
257664
257664
|
const body = all.map((p) => {
|
|
@@ -257667,20 +257667,20 @@ async function managePlaybook(args, context2) {
|
|
|
257667
257667
|
}).join("\n");
|
|
257668
257668
|
const msg2 = `Playbooks (${all.length}):
|
|
257669
257669
|
${body}`;
|
|
257670
|
-
|
|
257670
|
+
emit8(context2, "manage_playbook", args, msg2);
|
|
257671
257671
|
return msg2;
|
|
257672
257672
|
}
|
|
257673
257673
|
if (action === "get") {
|
|
257674
257674
|
const key = args.id ?? args.name;
|
|
257675
257675
|
if (!key) {
|
|
257676
257676
|
const msg3 = "get requires id or name.";
|
|
257677
|
-
|
|
257677
|
+
emit8(context2, "manage_playbook", args, msg3);
|
|
257678
257678
|
return msg3;
|
|
257679
257679
|
}
|
|
257680
257680
|
const p = m2.getPlaybook(key);
|
|
257681
257681
|
if (!p) {
|
|
257682
257682
|
const msg3 = `No playbook "${key}".`;
|
|
257683
|
-
|
|
257683
|
+
emit8(context2, "manage_playbook", args, msg3);
|
|
257684
257684
|
return msg3;
|
|
257685
257685
|
}
|
|
257686
257686
|
const steps = p.steps.map((s, i) => {
|
|
@@ -257694,13 +257694,13 @@ Scope: ${scope}
|
|
|
257694
257694
|
Default onError: ${p.onError ?? "stop"}${p.requireApproval ? "\nMOP mode: requires an approved change record (manage_change) to run" : ""}
|
|
257695
257695
|
Steps:
|
|
257696
257696
|
${steps}`;
|
|
257697
|
-
|
|
257697
|
+
emit8(context2, "manage_playbook", args, msg2);
|
|
257698
257698
|
return msg2;
|
|
257699
257699
|
}
|
|
257700
257700
|
if (action === "create") {
|
|
257701
257701
|
if (!args.name || !args.steps?.length) {
|
|
257702
257702
|
const msg2 = "create requires name + at least one step.";
|
|
257703
|
-
|
|
257703
|
+
emit8(context2, "manage_playbook", args, msg2);
|
|
257704
257704
|
return msg2;
|
|
257705
257705
|
}
|
|
257706
257706
|
try {
|
|
@@ -257715,18 +257715,18 @@ ${steps}`;
|
|
|
257715
257715
|
requireApproval: args.requireApproval
|
|
257716
257716
|
});
|
|
257717
257717
|
const msg2 = `Created playbook "${p.name}" (id=${p.id}, ${p.steps.length} step(s)). ${p.requireApproval ? "MOP mode: run it via manage_change (plan \u2192 approve \u2192 run)." : "Run it with run_playbook."}`;
|
|
257718
|
-
|
|
257718
|
+
emit8(context2, "manage_playbook", args, msg2);
|
|
257719
257719
|
return msg2;
|
|
257720
257720
|
} catch (error40) {
|
|
257721
257721
|
const msg2 = `Could not create playbook: ${error40 instanceof Error ? error40.message : error40}`;
|
|
257722
|
-
|
|
257722
|
+
emit8(context2, "manage_playbook", args, msg2);
|
|
257723
257723
|
return msg2;
|
|
257724
257724
|
}
|
|
257725
257725
|
}
|
|
257726
257726
|
if (action === "update") {
|
|
257727
257727
|
if (!args.id) {
|
|
257728
257728
|
const msg2 = "update requires id.";
|
|
257729
|
-
|
|
257729
|
+
emit8(context2, "manage_playbook", args, msg2);
|
|
257730
257730
|
return msg2;
|
|
257731
257731
|
}
|
|
257732
257732
|
try {
|
|
@@ -257742,51 +257742,51 @@ ${steps}`;
|
|
|
257742
257742
|
...args.requireApproval !== void 0 ? { requireApproval: args.requireApproval } : {}
|
|
257743
257743
|
});
|
|
257744
257744
|
const msg2 = `Updated playbook "${p.name}" (${p.steps.length} step(s)).`;
|
|
257745
|
-
|
|
257745
|
+
emit8(context2, "manage_playbook", args, msg2);
|
|
257746
257746
|
return msg2;
|
|
257747
257747
|
} catch (error40) {
|
|
257748
257748
|
const msg2 = `Could not update playbook: ${error40 instanceof Error ? error40.message : error40}`;
|
|
257749
|
-
|
|
257749
|
+
emit8(context2, "manage_playbook", args, msg2);
|
|
257750
257750
|
return msg2;
|
|
257751
257751
|
}
|
|
257752
257752
|
}
|
|
257753
257753
|
if (action === "delete") {
|
|
257754
257754
|
if (!args.id) {
|
|
257755
257755
|
const msg3 = "delete requires id.";
|
|
257756
|
-
|
|
257756
|
+
emit8(context2, "manage_playbook", args, msg3);
|
|
257757
257757
|
return msg3;
|
|
257758
257758
|
}
|
|
257759
257759
|
const removed = m2.deletePlaybook(args.id);
|
|
257760
257760
|
const msg2 = removed ? `Deleted playbook ${args.id}.` : `No playbook ${args.id}.`;
|
|
257761
|
-
|
|
257761
|
+
emit8(context2, "manage_playbook", args, msg2);
|
|
257762
257762
|
return msg2;
|
|
257763
257763
|
}
|
|
257764
257764
|
const msg = `Unknown action "${action}".`;
|
|
257765
|
-
|
|
257765
|
+
emit8(context2, "manage_playbook", args, msg);
|
|
257766
257766
|
return msg;
|
|
257767
257767
|
}
|
|
257768
257768
|
async function runPlaybook(args, context2) {
|
|
257769
257769
|
const m2 = context2.automationManager;
|
|
257770
257770
|
if (!m2) {
|
|
257771
257771
|
const msg2 = noStore2();
|
|
257772
|
-
|
|
257772
|
+
emit8(context2, "run_playbook", args, msg2);
|
|
257773
257773
|
return msg2;
|
|
257774
257774
|
}
|
|
257775
257775
|
const key = args.id ?? args.name;
|
|
257776
257776
|
if (!key) {
|
|
257777
257777
|
const msg2 = "run_playbook requires id or name.";
|
|
257778
|
-
|
|
257778
|
+
emit8(context2, "run_playbook", args, msg2);
|
|
257779
257779
|
return msg2;
|
|
257780
257780
|
}
|
|
257781
257781
|
const playbook = m2.getPlaybook(key);
|
|
257782
257782
|
if (!playbook) {
|
|
257783
257783
|
const msg2 = `No playbook "${key}". Use manage_playbook action=list to see valid playbooks.`;
|
|
257784
|
-
|
|
257784
|
+
emit8(context2, "run_playbook", args, msg2);
|
|
257785
257785
|
return msg2;
|
|
257786
257786
|
}
|
|
257787
257787
|
if (playbook.requireApproval) {
|
|
257788
257788
|
const msg2 = `Playbook "${playbook.name}" is in MOP mode (requireApproval). Run it through a change record: manage_change action=plan name="${playbook.name}" \u2192 approve \u2192 run.`;
|
|
257789
|
-
|
|
257789
|
+
emit8(context2, "run_playbook", args, msg2);
|
|
257790
257790
|
return msg2;
|
|
257791
257791
|
}
|
|
257792
257792
|
if (args.dryRun) {
|
|
@@ -257814,7 +257814,7 @@ Targets (${plan.targets.length}): ${targetList}
|
|
|
257814
257814
|
|
|
257815
257815
|
Steps (${plan.steps.length}):
|
|
257816
257816
|
${stepList}${notes}`;
|
|
257817
|
-
|
|
257817
|
+
emit8(context2, "run_playbook", args, msg2);
|
|
257818
257818
|
return msg2;
|
|
257819
257819
|
}
|
|
257820
257820
|
const settings = {
|
|
@@ -257854,7 +257854,7 @@ ${stepList}${notes}`;
|
|
|
257854
257854
|
}
|
|
257855
257855
|
} catch (error40) {
|
|
257856
257856
|
const msg2 = `Playbook "${playbook.name}" could not run: ${error40 instanceof Error ? error40.message : error40}`;
|
|
257857
|
-
|
|
257857
|
+
emit8(context2, "run_playbook", args, msg2);
|
|
257858
257858
|
return msg2;
|
|
257859
257859
|
}
|
|
257860
257860
|
const lines = [];
|
|
@@ -257869,7 +257869,7 @@ ${stepList}${notes}`;
|
|
|
257869
257869
|
const okTargets = record2.targets.filter((t) => t.ok).length;
|
|
257870
257870
|
const msg = `Playbook "${record2.playbookName}" ${record2.ok ? "completed OK" : "FAILED"} (runId=${record2.runId}, ${okTargets}/${record2.targets.length} target(s) ok):
|
|
257871
257871
|
${lines.join("\n")}`;
|
|
257872
|
-
|
|
257872
|
+
emit8(context2, "run_playbook", args, msg);
|
|
257873
257873
|
return msg;
|
|
257874
257874
|
}
|
|
257875
257875
|
var stepSchema, managePlaybookSchema, runPlaybookSchema;
|
|
@@ -258310,8 +258310,8 @@ function extractFields(message) {
|
|
|
258310
258310
|
if (ip) fields.ip = ip[1];
|
|
258311
258311
|
const port = message.match(/[Pp]ort[:\s]+(\d{1,5})/);
|
|
258312
258312
|
if (port) fields.port = port[1];
|
|
258313
|
-
const
|
|
258314
|
-
if (
|
|
258313
|
+
const path34 = message.match(/([A-Za-z]:\\[^\s"',;]+)/);
|
|
258314
|
+
if (path34) fields.path = path34[1];
|
|
258315
258315
|
const key = message.match(/(HKLM|HKCU|HKCR|HKU)\\[^\s"',;]+/i);
|
|
258316
258316
|
if (key) fields.key = key[0];
|
|
258317
258317
|
const proc = message.match(/[Pp]rocess(?:Name)?[:\s]+([A-Za-z0-9_.-]+\.exe)/);
|
|
@@ -265869,8 +265869,8 @@ var require_utils2 = __commonJS({
|
|
|
265869
265869
|
}
|
|
265870
265870
|
return ind;
|
|
265871
265871
|
}
|
|
265872
|
-
function removeDotSegments(
|
|
265873
|
-
let input =
|
|
265872
|
+
function removeDotSegments(path34) {
|
|
265873
|
+
let input = path34;
|
|
265874
265874
|
const output = [];
|
|
265875
265875
|
let nextSlash = -1;
|
|
265876
265876
|
let len = 0;
|
|
@@ -266069,8 +266069,8 @@ var require_schemes = __commonJS({
|
|
|
266069
266069
|
wsComponent.secure = void 0;
|
|
266070
266070
|
}
|
|
266071
266071
|
if (wsComponent.resourceName) {
|
|
266072
|
-
const [
|
|
266073
|
-
wsComponent.path =
|
|
266072
|
+
const [path34, query] = wsComponent.resourceName.split("?");
|
|
266073
|
+
wsComponent.path = path34 && path34 !== "/" ? path34 : void 0;
|
|
266074
266074
|
wsComponent.query = query;
|
|
266075
266075
|
wsComponent.resourceName = void 0;
|
|
266076
266076
|
}
|
|
@@ -275109,12 +275109,12 @@ var require_dist2 = __commonJS({
|
|
|
275109
275109
|
throw new Error(`Unknown format "${name}"`);
|
|
275110
275110
|
return f;
|
|
275111
275111
|
};
|
|
275112
|
-
function addFormats(ajv, list,
|
|
275112
|
+
function addFormats(ajv, list, fs25, exportName) {
|
|
275113
275113
|
var _a3;
|
|
275114
275114
|
var _b;
|
|
275115
275115
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
275116
275116
|
for (const f of list)
|
|
275117
|
-
ajv.addFormat(f,
|
|
275117
|
+
ajv.addFormat(f, fs25[f]);
|
|
275118
275118
|
}
|
|
275119
275119
|
module2.exports = exports2 = formatsPlugin;
|
|
275120
275120
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -275127,8 +275127,8 @@ var require_windows = __commonJS({
|
|
|
275127
275127
|
"../../node_modules/isexe/windows.js"(exports2, module2) {
|
|
275128
275128
|
module2.exports = isexe;
|
|
275129
275129
|
isexe.sync = sync;
|
|
275130
|
-
var
|
|
275131
|
-
function checkPathExt(
|
|
275130
|
+
var fs25 = require("fs");
|
|
275131
|
+
function checkPathExt(path34, options) {
|
|
275132
275132
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
275133
275133
|
if (!pathext) {
|
|
275134
275134
|
return true;
|
|
@@ -275139,25 +275139,25 @@ var require_windows = __commonJS({
|
|
|
275139
275139
|
}
|
|
275140
275140
|
for (var i = 0; i < pathext.length; i++) {
|
|
275141
275141
|
var p = pathext[i].toLowerCase();
|
|
275142
|
-
if (p &&
|
|
275142
|
+
if (p && path34.substr(-p.length).toLowerCase() === p) {
|
|
275143
275143
|
return true;
|
|
275144
275144
|
}
|
|
275145
275145
|
}
|
|
275146
275146
|
return false;
|
|
275147
275147
|
}
|
|
275148
|
-
function checkStat(stat,
|
|
275148
|
+
function checkStat(stat, path34, options) {
|
|
275149
275149
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
275150
275150
|
return false;
|
|
275151
275151
|
}
|
|
275152
|
-
return checkPathExt(
|
|
275152
|
+
return checkPathExt(path34, options);
|
|
275153
275153
|
}
|
|
275154
|
-
function isexe(
|
|
275155
|
-
|
|
275156
|
-
cb(er, er ? false : checkStat(stat,
|
|
275154
|
+
function isexe(path34, options, cb) {
|
|
275155
|
+
fs25.stat(path34, function(er, stat) {
|
|
275156
|
+
cb(er, er ? false : checkStat(stat, path34, options));
|
|
275157
275157
|
});
|
|
275158
275158
|
}
|
|
275159
|
-
function sync(
|
|
275160
|
-
return checkStat(
|
|
275159
|
+
function sync(path34, options) {
|
|
275160
|
+
return checkStat(fs25.statSync(path34), path34, options);
|
|
275161
275161
|
}
|
|
275162
275162
|
}
|
|
275163
275163
|
});
|
|
@@ -275167,14 +275167,14 @@ var require_mode = __commonJS({
|
|
|
275167
275167
|
"../../node_modules/isexe/mode.js"(exports2, module2) {
|
|
275168
275168
|
module2.exports = isexe;
|
|
275169
275169
|
isexe.sync = sync;
|
|
275170
|
-
var
|
|
275171
|
-
function isexe(
|
|
275172
|
-
|
|
275170
|
+
var fs25 = require("fs");
|
|
275171
|
+
function isexe(path34, options, cb) {
|
|
275172
|
+
fs25.stat(path34, function(er, stat) {
|
|
275173
275173
|
cb(er, er ? false : checkStat(stat, options));
|
|
275174
275174
|
});
|
|
275175
275175
|
}
|
|
275176
|
-
function sync(
|
|
275177
|
-
return checkStat(
|
|
275176
|
+
function sync(path34, options) {
|
|
275177
|
+
return checkStat(fs25.statSync(path34), options);
|
|
275178
275178
|
}
|
|
275179
275179
|
function checkStat(stat, options) {
|
|
275180
275180
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -275198,7 +275198,7 @@ var require_mode = __commonJS({
|
|
|
275198
275198
|
// ../../node_modules/isexe/index.js
|
|
275199
275199
|
var require_isexe = __commonJS({
|
|
275200
275200
|
"../../node_modules/isexe/index.js"(exports2, module2) {
|
|
275201
|
-
var
|
|
275201
|
+
var fs25 = require("fs");
|
|
275202
275202
|
var core2;
|
|
275203
275203
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
275204
275204
|
core2 = require_windows();
|
|
@@ -275207,7 +275207,7 @@ var require_isexe = __commonJS({
|
|
|
275207
275207
|
}
|
|
275208
275208
|
module2.exports = isexe;
|
|
275209
275209
|
isexe.sync = sync;
|
|
275210
|
-
function isexe(
|
|
275210
|
+
function isexe(path34, options, cb) {
|
|
275211
275211
|
if (typeof options === "function") {
|
|
275212
275212
|
cb = options;
|
|
275213
275213
|
options = {};
|
|
@@ -275217,7 +275217,7 @@ var require_isexe = __commonJS({
|
|
|
275217
275217
|
throw new TypeError("callback not provided");
|
|
275218
275218
|
}
|
|
275219
275219
|
return new Promise(function(resolve2, reject) {
|
|
275220
|
-
isexe(
|
|
275220
|
+
isexe(path34, options || {}, function(er, is) {
|
|
275221
275221
|
if (er) {
|
|
275222
275222
|
reject(er);
|
|
275223
275223
|
} else {
|
|
@@ -275226,7 +275226,7 @@ var require_isexe = __commonJS({
|
|
|
275226
275226
|
});
|
|
275227
275227
|
});
|
|
275228
275228
|
}
|
|
275229
|
-
core2(
|
|
275229
|
+
core2(path34, options || {}, function(er, is) {
|
|
275230
275230
|
if (er) {
|
|
275231
275231
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
275232
275232
|
er = null;
|
|
@@ -275236,9 +275236,9 @@ var require_isexe = __commonJS({
|
|
|
275236
275236
|
cb(er, is);
|
|
275237
275237
|
});
|
|
275238
275238
|
}
|
|
275239
|
-
function sync(
|
|
275239
|
+
function sync(path34, options) {
|
|
275240
275240
|
try {
|
|
275241
|
-
return core2.sync(
|
|
275241
|
+
return core2.sync(path34, options || {});
|
|
275242
275242
|
} catch (er) {
|
|
275243
275243
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
275244
275244
|
return false;
|
|
@@ -275254,7 +275254,7 @@ var require_isexe = __commonJS({
|
|
|
275254
275254
|
var require_which = __commonJS({
|
|
275255
275255
|
"../../node_modules/which/which.js"(exports2, module2) {
|
|
275256
275256
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
275257
|
-
var
|
|
275257
|
+
var path34 = require("path");
|
|
275258
275258
|
var COLON = isWindows ? ";" : ":";
|
|
275259
275259
|
var isexe = require_isexe();
|
|
275260
275260
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -275292,7 +275292,7 @@ var require_which = __commonJS({
|
|
|
275292
275292
|
return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
|
|
275293
275293
|
const ppRaw = pathEnv[i];
|
|
275294
275294
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
275295
|
-
const pCmd =
|
|
275295
|
+
const pCmd = path34.join(pathPart, cmd);
|
|
275296
275296
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
275297
275297
|
resolve2(subStep(p, i, 0));
|
|
275298
275298
|
});
|
|
@@ -275319,7 +275319,7 @@ var require_which = __commonJS({
|
|
|
275319
275319
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
275320
275320
|
const ppRaw = pathEnv[i];
|
|
275321
275321
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
275322
|
-
const pCmd =
|
|
275322
|
+
const pCmd = path34.join(pathPart, cmd);
|
|
275323
275323
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
275324
275324
|
for (let j = 0; j < pathExt.length; j++) {
|
|
275325
275325
|
const cur = p + pathExt[j];
|
|
@@ -275367,7 +275367,7 @@ var require_path_key = __commonJS({
|
|
|
275367
275367
|
var require_resolveCommand = __commonJS({
|
|
275368
275368
|
"../../node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2, module2) {
|
|
275369
275369
|
"use strict";
|
|
275370
|
-
var
|
|
275370
|
+
var path34 = require("path");
|
|
275371
275371
|
var which = require_which();
|
|
275372
275372
|
var getPathKey = require_path_key();
|
|
275373
275373
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -275385,7 +275385,7 @@ var require_resolveCommand = __commonJS({
|
|
|
275385
275385
|
try {
|
|
275386
275386
|
resolved = which.sync(parsed.command, {
|
|
275387
275387
|
path: env[getPathKey({ env })],
|
|
275388
|
-
pathExt: withoutPathExt ?
|
|
275388
|
+
pathExt: withoutPathExt ? path34.delimiter : void 0
|
|
275389
275389
|
});
|
|
275390
275390
|
} catch (e) {
|
|
275391
275391
|
} finally {
|
|
@@ -275394,7 +275394,7 @@ var require_resolveCommand = __commonJS({
|
|
|
275394
275394
|
}
|
|
275395
275395
|
}
|
|
275396
275396
|
if (resolved) {
|
|
275397
|
-
resolved =
|
|
275397
|
+
resolved = path34.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
275398
275398
|
}
|
|
275399
275399
|
return resolved;
|
|
275400
275400
|
}
|
|
@@ -275448,8 +275448,8 @@ var require_shebang_command = __commonJS({
|
|
|
275448
275448
|
if (!match) {
|
|
275449
275449
|
return null;
|
|
275450
275450
|
}
|
|
275451
|
-
const [
|
|
275452
|
-
const binary2 =
|
|
275451
|
+
const [path34, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
275452
|
+
const binary2 = path34.split("/").pop();
|
|
275453
275453
|
if (binary2 === "env") {
|
|
275454
275454
|
return argument;
|
|
275455
275455
|
}
|
|
@@ -275462,16 +275462,16 @@ var require_shebang_command = __commonJS({
|
|
|
275462
275462
|
var require_readShebang = __commonJS({
|
|
275463
275463
|
"../../node_modules/cross-spawn/lib/util/readShebang.js"(exports2, module2) {
|
|
275464
275464
|
"use strict";
|
|
275465
|
-
var
|
|
275465
|
+
var fs25 = require("fs");
|
|
275466
275466
|
var shebangCommand = require_shebang_command();
|
|
275467
275467
|
function readShebang(command) {
|
|
275468
275468
|
const size = 150;
|
|
275469
275469
|
const buffer = Buffer.alloc(size);
|
|
275470
275470
|
let fd;
|
|
275471
275471
|
try {
|
|
275472
|
-
fd =
|
|
275473
|
-
|
|
275474
|
-
|
|
275472
|
+
fd = fs25.openSync(command, "r");
|
|
275473
|
+
fs25.readSync(fd, buffer, 0, size, 0);
|
|
275474
|
+
fs25.closeSync(fd);
|
|
275475
275475
|
} catch (e) {
|
|
275476
275476
|
}
|
|
275477
275477
|
return shebangCommand(buffer.toString());
|
|
@@ -275484,7 +275484,7 @@ var require_readShebang = __commonJS({
|
|
|
275484
275484
|
var require_parse2 = __commonJS({
|
|
275485
275485
|
"../../node_modules/cross-spawn/lib/parse.js"(exports2, module2) {
|
|
275486
275486
|
"use strict";
|
|
275487
|
-
var
|
|
275487
|
+
var path34 = require("path");
|
|
275488
275488
|
var resolveCommand = require_resolveCommand();
|
|
275489
275489
|
var escape2 = require_escape();
|
|
275490
275490
|
var readShebang = require_readShebang();
|
|
@@ -275509,7 +275509,7 @@ var require_parse2 = __commonJS({
|
|
|
275509
275509
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
275510
275510
|
if (parsed.options.forceShell || needsShell) {
|
|
275511
275511
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
275512
|
-
parsed.command =
|
|
275512
|
+
parsed.command = path34.normalize(parsed.command);
|
|
275513
275513
|
parsed.command = escape2.command(parsed.command);
|
|
275514
275514
|
parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
|
|
275515
275515
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -276684,6 +276684,514 @@ var init_compoundingStore = __esm({
|
|
|
276684
276684
|
}
|
|
276685
276685
|
});
|
|
276686
276686
|
|
|
276687
|
+
// ../../packages/backend/src/services/ops/collabSession.ts
|
|
276688
|
+
function joinSession(sessionId, operator) {
|
|
276689
|
+
const r = rooms.get(sessionId) ?? { sessionId, operators: [], holder: null };
|
|
276690
|
+
if (!r.operators.includes(operator)) r.operators.push(operator);
|
|
276691
|
+
if (!r.holder) r.holder = operator;
|
|
276692
|
+
rooms.set(sessionId, r);
|
|
276693
|
+
return r;
|
|
276694
|
+
}
|
|
276695
|
+
function takeConn(sessionId, operator) {
|
|
276696
|
+
const r = rooms.get(sessionId);
|
|
276697
|
+
if (!r) throw new Error("no session");
|
|
276698
|
+
if (!r.operators.includes(operator)) r.operators.push(operator);
|
|
276699
|
+
r.holder = operator;
|
|
276700
|
+
return r;
|
|
276701
|
+
}
|
|
276702
|
+
function whoHasConn(sessionId) {
|
|
276703
|
+
return rooms.get(sessionId)?.holder ?? null;
|
|
276704
|
+
}
|
|
276705
|
+
var rooms;
|
|
276706
|
+
var init_collabSession = __esm({
|
|
276707
|
+
"../../packages/backend/src/services/ops/collabSession.ts"() {
|
|
276708
|
+
"use strict";
|
|
276709
|
+
rooms = /* @__PURE__ */ new Map();
|
|
276710
|
+
}
|
|
276711
|
+
});
|
|
276712
|
+
|
|
276713
|
+
// ../../packages/backend/src/services/ops/agentReplay.ts
|
|
276714
|
+
function replayWithStubs(runId, steps) {
|
|
276715
|
+
return {
|
|
276716
|
+
runId,
|
|
276717
|
+
steps: steps.map((s) => ({
|
|
276718
|
+
tool: s.tool,
|
|
276719
|
+
usedStub: true,
|
|
276720
|
+
output: s.stub
|
|
276721
|
+
})),
|
|
276722
|
+
wouldHaveCalled: steps.map((s) => s.tool)
|
|
276723
|
+
};
|
|
276724
|
+
}
|
|
276725
|
+
function breakpointBefore(tool2, nextTool) {
|
|
276726
|
+
return tool2 === nextTool;
|
|
276727
|
+
}
|
|
276728
|
+
var init_agentReplay = __esm({
|
|
276729
|
+
"../../packages/backend/src/services/ops/agentReplay.ts"() {
|
|
276730
|
+
"use strict";
|
|
276731
|
+
}
|
|
276732
|
+
});
|
|
276733
|
+
|
|
276734
|
+
// ../../packages/backend/src/services/ops/djoinPlaybook.ts
|
|
276735
|
+
function planOfflineJoin2(opts) {
|
|
276736
|
+
const domain2 = String(opts.domain || "").trim();
|
|
276737
|
+
const machine = String(opts.machine || "").trim();
|
|
276738
|
+
if (!domain2 || !machine) throw new Error("domain and machine required");
|
|
276739
|
+
return {
|
|
276740
|
+
domain: domain2,
|
|
276741
|
+
machine,
|
|
276742
|
+
provisionOn: opts.dcConnection,
|
|
276743
|
+
applyOn: opts.memberConnection,
|
|
276744
|
+
steps: [
|
|
276745
|
+
`On ${opts.dcConnection}: djoin /provision /domain ${domain2} /machine ${machine} /savefile C:\\temp\\${machine}.odj`,
|
|
276746
|
+
`Copy blob to ${opts.memberConnection} (no SMB \u2014 PSRP/WinRM file or pypsrp)`,
|
|
276747
|
+
`On ${opts.memberConnection}: djoin /requestODJ /loadfile C:\\temp\\${machine}.odj /localos /windowspath C:\\Windows`,
|
|
276748
|
+
`Restart ${opts.memberConnection}`,
|
|
276749
|
+
`Verify PartOfDomain and Get-ADComputer ${machine}`
|
|
276750
|
+
]
|
|
276751
|
+
};
|
|
276752
|
+
}
|
|
276753
|
+
function djoinProvisionCommand(domain2, machine, savefile = "C:\\temp\\odj.blob") {
|
|
276754
|
+
return `djoin /provision /domain ${domain2} /machine ${machine} /savefile ${savefile}`;
|
|
276755
|
+
}
|
|
276756
|
+
function djoinRequestCommand(loadfile = "C:\\temp\\odj.blob") {
|
|
276757
|
+
return `djoin /requestODJ /loadfile ${loadfile} /localos /windowspath C:\\Windows`;
|
|
276758
|
+
}
|
|
276759
|
+
var init_djoinPlaybook = __esm({
|
|
276760
|
+
"../../packages/backend/src/services/ops/djoinPlaybook.ts"() {
|
|
276761
|
+
"use strict";
|
|
276762
|
+
}
|
|
276763
|
+
});
|
|
276764
|
+
|
|
276765
|
+
// ../../packages/backend/src/services/ops/netDevice.ts
|
|
276766
|
+
function parseCdpNeighbors(showCdp) {
|
|
276767
|
+
const out = [];
|
|
276768
|
+
const blocks2 = showCdp.split(/Device ID:/i);
|
|
276769
|
+
for (const b of blocks2.slice(1)) {
|
|
276770
|
+
const device = (b.split("\n")[0] || "").trim();
|
|
276771
|
+
const local = /Interface:\s*(\S+)/i.exec(b)?.[1] ?? "";
|
|
276772
|
+
const remote = /Port ID[^:]*:\s*(\S+)/i.exec(b)?.[1] ?? "";
|
|
276773
|
+
if (device) out.push({ device, localIntf: local, remoteIntf: remote });
|
|
276774
|
+
}
|
|
276775
|
+
return out;
|
|
276776
|
+
}
|
|
276777
|
+
function configDiff(running, startup) {
|
|
276778
|
+
const a = running.replace(/\r/g, "").trimEnd();
|
|
276779
|
+
const b = startup.replace(/\r/g, "").trimEnd();
|
|
276780
|
+
if (a === b) return { changed: false, unified: "" };
|
|
276781
|
+
return { changed: true, unified: `--- startup
|
|
276782
|
+
+++ running
|
|
276783
|
+
-${b.slice(0, 200)}
|
|
276784
|
+
+${a.slice(0, 200)}` };
|
|
276785
|
+
}
|
|
276786
|
+
function inConfigMode(prompt) {
|
|
276787
|
+
return /\(config[^)]*\)#\s*$/.test(prompt);
|
|
276788
|
+
}
|
|
276789
|
+
var init_netDevice = __esm({
|
|
276790
|
+
"../../packages/backend/src/services/ops/netDevice.ts"() {
|
|
276791
|
+
"use strict";
|
|
276792
|
+
}
|
|
276793
|
+
});
|
|
276794
|
+
|
|
276795
|
+
// ../../packages/backend/src/services/ops/opsStore.ts
|
|
276796
|
+
function mapIncident(r) {
|
|
276797
|
+
let tabIds = [];
|
|
276798
|
+
try {
|
|
276799
|
+
const parsed = JSON.parse(String(r.tab_ids ?? "[]"));
|
|
276800
|
+
if (Array.isArray(parsed)) tabIds = parsed.map(String);
|
|
276801
|
+
} catch {
|
|
276802
|
+
tabIds = [];
|
|
276803
|
+
}
|
|
276804
|
+
return {
|
|
276805
|
+
id: String(r.id),
|
|
276806
|
+
title: String(r.title),
|
|
276807
|
+
status: r.status === "closed" ? "closed" : "open",
|
|
276808
|
+
sessionId: r.session_id ? String(r.session_id) : void 0,
|
|
276809
|
+
tabIds,
|
|
276810
|
+
recordingId: r.recording_id ? String(r.recording_id) : void 0,
|
|
276811
|
+
runId: r.run_id ? String(r.run_id) : void 0,
|
|
276812
|
+
notes: r.notes ? String(r.notes) : void 0,
|
|
276813
|
+
openedAt: Number(r.opened_at ?? 0),
|
|
276814
|
+
closedAt: r.closed_at ? Number(r.closed_at) : void 0
|
|
276815
|
+
};
|
|
276816
|
+
}
|
|
276817
|
+
function mapJumpPath(r) {
|
|
276818
|
+
let hops = [];
|
|
276819
|
+
try {
|
|
276820
|
+
const parsed = JSON.parse(String(r.hops ?? "[]"));
|
|
276821
|
+
if (Array.isArray(parsed)) hops = parsed;
|
|
276822
|
+
} catch {
|
|
276823
|
+
hops = [];
|
|
276824
|
+
}
|
|
276825
|
+
return {
|
|
276826
|
+
name: String(r.name),
|
|
276827
|
+
hops,
|
|
276828
|
+
breakGlassUntil: r.break_glass_until ? Number(r.break_glass_until) : void 0,
|
|
276829
|
+
createdAt: Number(r.created_at ?? 0)
|
|
276830
|
+
};
|
|
276831
|
+
}
|
|
276832
|
+
function mapSnapshot(r) {
|
|
276833
|
+
return {
|
|
276834
|
+
connection: String(r.connection),
|
|
276835
|
+
command: String(r.command),
|
|
276836
|
+
output: String(r.output ?? ""),
|
|
276837
|
+
at: Number(r.at ?? 0)
|
|
276838
|
+
};
|
|
276839
|
+
}
|
|
276840
|
+
function mapApproval(r) {
|
|
276841
|
+
return {
|
|
276842
|
+
id: String(r.id),
|
|
276843
|
+
command: String(r.command),
|
|
276844
|
+
state: String(r.state) ?? "pending",
|
|
276845
|
+
twoPerson: Number(r.two_person ?? 0) === 1,
|
|
276846
|
+
requestedAt: Number(r.requested_at ?? 0),
|
|
276847
|
+
expiresAt: Number(r.expires_at ?? 0),
|
|
276848
|
+
decidedBy: r.decided_by ? String(r.decided_by) : void 0,
|
|
276849
|
+
decidedAt: r.decided_at ? Number(r.decided_at) : void 0
|
|
276850
|
+
};
|
|
276851
|
+
}
|
|
276852
|
+
var import_node_fs13, import_node_path29, OPS_DB_FILE, OpsStore;
|
|
276853
|
+
var init_opsStore = __esm({
|
|
276854
|
+
"../../packages/backend/src/services/ops/opsStore.ts"() {
|
|
276855
|
+
"use strict";
|
|
276856
|
+
import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
276857
|
+
import_node_path29 = __toESM(require("node:path"), 1);
|
|
276858
|
+
init_betterSqlite3Runtime();
|
|
276859
|
+
init_historyStoragePaths();
|
|
276860
|
+
OPS_DB_FILE = "gyshell-ops.sqlite";
|
|
276861
|
+
OpsStore = class {
|
|
276862
|
+
db;
|
|
276863
|
+
constructor(options) {
|
|
276864
|
+
const filePath = options?.filePath || import_node_path29.default.join(resolveHistoryStorageDir(), OPS_DB_FILE);
|
|
276865
|
+
import_node_fs13.default.mkdirSync(import_node_path29.default.dirname(filePath), { recursive: true });
|
|
276866
|
+
this.db = openBetterSqlite3Database(filePath);
|
|
276867
|
+
this.db.pragma("journal_mode = WAL");
|
|
276868
|
+
this.db.exec(`
|
|
276869
|
+
CREATE TABLE IF NOT EXISTS incidents (
|
|
276870
|
+
id TEXT PRIMARY KEY,
|
|
276871
|
+
title TEXT NOT NULL,
|
|
276872
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
276873
|
+
session_id TEXT,
|
|
276874
|
+
tab_ids TEXT NOT NULL DEFAULT '[]',
|
|
276875
|
+
recording_id TEXT,
|
|
276876
|
+
run_id TEXT,
|
|
276877
|
+
notes TEXT,
|
|
276878
|
+
opened_at INTEGER NOT NULL,
|
|
276879
|
+
closed_at INTEGER
|
|
276880
|
+
);
|
|
276881
|
+
CREATE TABLE IF NOT EXISTS jump_paths (
|
|
276882
|
+
name TEXT PRIMARY KEY,
|
|
276883
|
+
hops TEXT NOT NULL DEFAULT '[]',
|
|
276884
|
+
break_glass_until INTEGER,
|
|
276885
|
+
created_at INTEGER NOT NULL
|
|
276886
|
+
);
|
|
276887
|
+
CREATE TABLE IF NOT EXISTS snapshots (
|
|
276888
|
+
connection TEXT NOT NULL,
|
|
276889
|
+
command TEXT NOT NULL,
|
|
276890
|
+
output TEXT NOT NULL,
|
|
276891
|
+
at INTEGER NOT NULL,
|
|
276892
|
+
PRIMARY KEY (connection, command)
|
|
276893
|
+
);
|
|
276894
|
+
CREATE TABLE IF NOT EXISTS approvals (
|
|
276895
|
+
id TEXT PRIMARY KEY,
|
|
276896
|
+
command TEXT NOT NULL,
|
|
276897
|
+
state TEXT NOT NULL DEFAULT 'pending',
|
|
276898
|
+
two_person INTEGER NOT NULL DEFAULT 0,
|
|
276899
|
+
requested_at INTEGER NOT NULL,
|
|
276900
|
+
expires_at INTEGER NOT NULL,
|
|
276901
|
+
decided_by TEXT,
|
|
276902
|
+
decided_at INTEGER,
|
|
276903
|
+
approvals TEXT NOT NULL DEFAULT '[]'
|
|
276904
|
+
);
|
|
276905
|
+
`);
|
|
276906
|
+
}
|
|
276907
|
+
// ── incidents ────────────────────────────────────────────────────────────
|
|
276908
|
+
openIncident(title, parts = {}) {
|
|
276909
|
+
const row = {
|
|
276910
|
+
id: `inc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`,
|
|
276911
|
+
title,
|
|
276912
|
+
status: "open",
|
|
276913
|
+
tabIds: parts.tabIds ?? [],
|
|
276914
|
+
sessionId: parts.sessionId,
|
|
276915
|
+
recordingId: parts.recordingId,
|
|
276916
|
+
runId: parts.runId,
|
|
276917
|
+
notes: parts.notes,
|
|
276918
|
+
openedAt: Date.now()
|
|
276919
|
+
};
|
|
276920
|
+
this.db.prepare(
|
|
276921
|
+
`INSERT INTO incidents (id, title, status, session_id, tab_ids, recording_id, run_id, notes, opened_at)
|
|
276922
|
+
VALUES (@id, @title, @status, @sessionId, @tabIds, @recordingId, @runId, @notes, @openedAt)`
|
|
276923
|
+
).run({ ...row, tabIds: JSON.stringify(row.tabIds) });
|
|
276924
|
+
return row;
|
|
276925
|
+
}
|
|
276926
|
+
getIncident(id) {
|
|
276927
|
+
const r = this.db.prepare(`SELECT * FROM incidents WHERE id = ?`).get(id);
|
|
276928
|
+
return r ? mapIncident(r) : void 0;
|
|
276929
|
+
}
|
|
276930
|
+
listIncidents(status) {
|
|
276931
|
+
const rows = status ? this.db.prepare(`SELECT * FROM incidents WHERE status = ? ORDER BY opened_at DESC`).all(status) : this.db.prepare(`SELECT * FROM incidents ORDER BY opened_at DESC`).all();
|
|
276932
|
+
return rows.map(mapIncident);
|
|
276933
|
+
}
|
|
276934
|
+
closeIncident(id, notes) {
|
|
276935
|
+
this.db.prepare(`UPDATE incidents SET status = 'closed', closed_at = ?, notes = COALESCE(?, notes) WHERE id = ?`).run(Date.now(), notes ?? null, id);
|
|
276936
|
+
return this.getIncident(id);
|
|
276937
|
+
}
|
|
276938
|
+
// ── jump paths / break-glass ─────────────────────────────────────────────
|
|
276939
|
+
defineJumpPath(name, hops) {
|
|
276940
|
+
const row = { name, hops, createdAt: Date.now() };
|
|
276941
|
+
this.db.prepare(
|
|
276942
|
+
`INSERT INTO jump_paths (name, hops, break_glass_until, created_at) VALUES (?, ?, NULL, ?)
|
|
276943
|
+
ON CONFLICT(name) DO UPDATE SET hops = excluded.hops`
|
|
276944
|
+
).run(name, JSON.stringify(hops), row.createdAt);
|
|
276945
|
+
return row;
|
|
276946
|
+
}
|
|
276947
|
+
listJumpPaths() {
|
|
276948
|
+
return this.db.prepare(`SELECT * FROM jump_paths ORDER BY name`).all().map(
|
|
276949
|
+
mapJumpPath
|
|
276950
|
+
);
|
|
276951
|
+
}
|
|
276952
|
+
/** Grant time-boxed break-glass on a path. */
|
|
276953
|
+
grantBreakGlass(name, ttlMs) {
|
|
276954
|
+
const until = Date.now() + Math.max(0, ttlMs);
|
|
276955
|
+
this.db.prepare(`UPDATE jump_paths SET break_glass_until = ? WHERE name = ?`).run(until, name);
|
|
276956
|
+
return this.listJumpPaths().find((p) => p.name === name);
|
|
276957
|
+
}
|
|
276958
|
+
/** allowed = no break-glass needed, or break-glass still valid. */
|
|
276959
|
+
pathAllowed(name, now = Date.now()) {
|
|
276960
|
+
const p = this.listJumpPaths().find((x) => x.name === name);
|
|
276961
|
+
if (!p) return { allowed: false };
|
|
276962
|
+
if (!p.breakGlassUntil) return { allowed: false };
|
|
276963
|
+
const allowed = p.breakGlassUntil > now;
|
|
276964
|
+
return { allowed, breakGlassUntil: p.breakGlassUntil, expired: !allowed };
|
|
276965
|
+
}
|
|
276966
|
+
// ── output snapshots ─────────────────────────────────────────────────────
|
|
276967
|
+
rememberOutput(connection, command, output, at = Date.now()) {
|
|
276968
|
+
const row = { connection, command, output, at };
|
|
276969
|
+
this.db.prepare(
|
|
276970
|
+
`INSERT INTO snapshots (connection, command, output, at) VALUES (@connection, @command, @output, @at)
|
|
276971
|
+
ON CONFLICT(connection, command) DO UPDATE SET output = excluded.output, at = excluded.at`
|
|
276972
|
+
).run(row);
|
|
276973
|
+
return row;
|
|
276974
|
+
}
|
|
276975
|
+
lastSnapshot(connection, command) {
|
|
276976
|
+
const r = this.db.prepare(`SELECT * FROM snapshots WHERE connection = ? AND command = ?`).get(connection, command);
|
|
276977
|
+
return r ? mapSnapshot(r) : void 0;
|
|
276978
|
+
}
|
|
276979
|
+
listSnapshots(connection) {
|
|
276980
|
+
const rows = connection ? this.db.prepare(`SELECT * FROM snapshots WHERE connection = ? ORDER BY at DESC`).all(connection) : this.db.prepare(`SELECT * FROM snapshots ORDER BY at DESC`);
|
|
276981
|
+
return rows.map(mapSnapshot);
|
|
276982
|
+
}
|
|
276983
|
+
/**
|
|
276984
|
+
* Diff the stored output for (connection, command) against nextOutput and
|
|
276985
|
+
* remember nextOutput as the new baseline (so the next call diffs again).
|
|
276986
|
+
*/
|
|
276987
|
+
diffAndRemember(connection, command, nextOutput) {
|
|
276988
|
+
const prev = this.lastSnapshot(connection, command);
|
|
276989
|
+
const changed = prev ? prev.output !== nextOutput : false;
|
|
276990
|
+
this.rememberOutput(connection, command, nextOutput);
|
|
276991
|
+
return { previous: prev ? prev.output : null, current: nextOutput, changed };
|
|
276992
|
+
}
|
|
276993
|
+
// ── approvals (two-person + TTL) ─────────────────────────────────────────
|
|
276994
|
+
requestApproval(command, ttlMs, twoPerson = false, now = Date.now()) {
|
|
276995
|
+
const row = {
|
|
276996
|
+
id: `ap-${now.toString(36)}-${Math.random().toString(36).slice(2, 6)}`,
|
|
276997
|
+
command,
|
|
276998
|
+
state: "pending",
|
|
276999
|
+
twoPerson,
|
|
277000
|
+
requestedAt: now,
|
|
277001
|
+
expiresAt: now + Math.max(0, ttlMs)
|
|
277002
|
+
};
|
|
277003
|
+
this.db.prepare(
|
|
277004
|
+
`INSERT INTO approvals (id, command, state, two_person, requested_at, expires_at, approvals)
|
|
277005
|
+
VALUES (@id, @command, @state, @twoPerson, @requestedAt, @expiresAt, '[]')`
|
|
277006
|
+
).run({ ...row, twoPerson: row.twoPerson ? 1 : 0 });
|
|
277007
|
+
return row;
|
|
277008
|
+
}
|
|
277009
|
+
getApproval(id) {
|
|
277010
|
+
const r = this.db.prepare(`SELECT * FROM approvals WHERE id = ?`).get(id);
|
|
277011
|
+
return r ? mapApproval(r) : void 0;
|
|
277012
|
+
}
|
|
277013
|
+
listApprovals(state) {
|
|
277014
|
+
const rows = state ? this.db.prepare(`SELECT * FROM approvals WHERE state = ? ORDER BY requested_at DESC`).all(state) : this.db.prepare(`SELECT * FROM approvals ORDER BY requested_at DESC`);
|
|
277015
|
+
return rows.map(mapApproval);
|
|
277016
|
+
}
|
|
277017
|
+
approvers(id) {
|
|
277018
|
+
const r = this.db.prepare(`SELECT approvals FROM approvals WHERE id = ?`).get(id);
|
|
277019
|
+
try {
|
|
277020
|
+
const parsed = JSON.parse(r?.approvals ?? "[]");
|
|
277021
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
277022
|
+
} catch {
|
|
277023
|
+
return [];
|
|
277024
|
+
}
|
|
277025
|
+
}
|
|
277026
|
+
/** Sweep pending approvals whose TTL has passed into 'expired'. Returns count. */
|
|
277027
|
+
sweepExpired(now = Date.now()) {
|
|
277028
|
+
const r = this.db.prepare(`UPDATE approvals SET state = 'expired' WHERE state = 'pending' AND expires_at <= ?`).run(now);
|
|
277029
|
+
return Number(r.changes ?? 0);
|
|
277030
|
+
}
|
|
277031
|
+
/**
|
|
277032
|
+
* Record a decision. A two-person approval needs TWO DISTINCT approvers before
|
|
277033
|
+
* it flips to approved; a denial takes effect immediately. Expired approvals
|
|
277034
|
+
* cannot be decided.
|
|
277035
|
+
*/
|
|
277036
|
+
decide(id, who, approve, now = Date.now()) {
|
|
277037
|
+
const a = this.getApproval(id);
|
|
277038
|
+
if (!a) throw new Error(`unknown approval ${id}`);
|
|
277039
|
+
this.sweepExpired(now);
|
|
277040
|
+
const fresh = this.getApproval(id);
|
|
277041
|
+
if (fresh.state === "expired") return { ok: false, approval: fresh, reason: "expired" };
|
|
277042
|
+
if (fresh.state !== "pending") return { ok: false, approval: fresh, reason: `already ${fresh.state}` };
|
|
277043
|
+
if (!approve) {
|
|
277044
|
+
this.db.prepare(`UPDATE approvals SET state = 'denied', decided_by = ?, decided_at = ? WHERE id = ?`).run(who, now, id);
|
|
277045
|
+
return { ok: false, approval: this.getApproval(id), reason: "denied" };
|
|
277046
|
+
}
|
|
277047
|
+
const prior = this.approvers(id);
|
|
277048
|
+
if (prior.includes(who)) {
|
|
277049
|
+
return { ok: false, approval: fresh, reason: `approver "${who}" already approved \u2014 a second person is required` };
|
|
277050
|
+
}
|
|
277051
|
+
const next = [...prior, who];
|
|
277052
|
+
const needed = fresh.twoPerson ? 2 : 1;
|
|
277053
|
+
const approved = next.length >= needed;
|
|
277054
|
+
this.db.prepare(
|
|
277055
|
+
`UPDATE approvals SET approvals = ?, state = ?, decided_by = ?, decided_at = ? WHERE id = ?`
|
|
277056
|
+
).run(JSON.stringify(next), approved ? "approved" : "pending", who, now, id);
|
|
277057
|
+
return {
|
|
277058
|
+
ok: approved,
|
|
277059
|
+
approval: this.getApproval(id),
|
|
277060
|
+
reason: approved ? void 0 : `need ${needed - next.length} more approver(s)`
|
|
277061
|
+
};
|
|
277062
|
+
}
|
|
277063
|
+
};
|
|
277064
|
+
}
|
|
277065
|
+
});
|
|
277066
|
+
|
|
277067
|
+
// ../../packages/backend/src/services/ops/opsService.ts
|
|
277068
|
+
var opsService_exports = {};
|
|
277069
|
+
__export(opsService_exports, {
|
|
277070
|
+
OpsService: () => OpsService
|
|
277071
|
+
});
|
|
277072
|
+
var OpsService;
|
|
277073
|
+
var init_opsService = __esm({
|
|
277074
|
+
"../../packages/backend/src/services/ops/opsService.ts"() {
|
|
277075
|
+
"use strict";
|
|
277076
|
+
init_collabSession();
|
|
277077
|
+
init_agentReplay();
|
|
277078
|
+
init_djoinPlaybook();
|
|
277079
|
+
init_netDevice();
|
|
277080
|
+
init_opsStore();
|
|
277081
|
+
OpsService = class {
|
|
277082
|
+
store;
|
|
277083
|
+
/** sessionId → operators, for the presence listing. */
|
|
277084
|
+
rooms = /* @__PURE__ */ new Map();
|
|
277085
|
+
constructor(deps = {}) {
|
|
277086
|
+
this.store = new OpsStore({ filePath: deps.filePath });
|
|
277087
|
+
}
|
|
277088
|
+
// ── collaborate (two operators, one session) ─────────────────────────────
|
|
277089
|
+
joinCollab(sessionId, operator) {
|
|
277090
|
+
const p = joinSession(sessionId, operator);
|
|
277091
|
+
this.rooms.set(sessionId, p);
|
|
277092
|
+
return p;
|
|
277093
|
+
}
|
|
277094
|
+
takeConn(sessionId, operator) {
|
|
277095
|
+
const p = takeConn(sessionId, operator);
|
|
277096
|
+
this.rooms.set(sessionId, p);
|
|
277097
|
+
return p;
|
|
277098
|
+
}
|
|
277099
|
+
whoHasConn(sessionId) {
|
|
277100
|
+
const p = this.rooms.get(sessionId) ?? joinSession(sessionId, "system");
|
|
277101
|
+
this.rooms.set(sessionId, p);
|
|
277102
|
+
return { sessionId, holder: whoHasConn(sessionId), operators: p.operators };
|
|
277103
|
+
}
|
|
277104
|
+
listCollabSessions() {
|
|
277105
|
+
return [...this.rooms.values()];
|
|
277106
|
+
}
|
|
277107
|
+
// ── incidents ────────────────────────────────────────────────────────────
|
|
277108
|
+
openIncident(title, parts) {
|
|
277109
|
+
return this.store.openIncident(title, parts);
|
|
277110
|
+
}
|
|
277111
|
+
getIncident(id) {
|
|
277112
|
+
return this.store.getIncident(id);
|
|
277113
|
+
}
|
|
277114
|
+
listIncidents(status) {
|
|
277115
|
+
return this.store.listIncidents(status);
|
|
277116
|
+
}
|
|
277117
|
+
closeIncident(id, notes) {
|
|
277118
|
+
return this.store.closeIncident(id, notes);
|
|
277119
|
+
}
|
|
277120
|
+
// ── jump paths + break-glass ─────────────────────────────────────────────
|
|
277121
|
+
defineJumpPath(name, hops) {
|
|
277122
|
+
return this.store.defineJumpPath(name, hops);
|
|
277123
|
+
}
|
|
277124
|
+
listJumpPaths() {
|
|
277125
|
+
return this.store.listJumpPaths();
|
|
277126
|
+
}
|
|
277127
|
+
grantBreakGlass(name, ttlMs) {
|
|
277128
|
+
if (!this.store.listJumpPaths().some((p) => p.name === name)) {
|
|
277129
|
+
throw new Error(`unknown jump path "${name}" \u2014 define it first`);
|
|
277130
|
+
}
|
|
277131
|
+
return this.store.grantBreakGlass(name, ttlMs);
|
|
277132
|
+
}
|
|
277133
|
+
pathAllowed(name) {
|
|
277134
|
+
return this.store.pathAllowed(name);
|
|
277135
|
+
}
|
|
277136
|
+
// ── output snapshots + drift ─────────────────────────────────────────────
|
|
277137
|
+
rememberOutput(connection, command, output) {
|
|
277138
|
+
return this.store.rememberOutput(connection, command, output);
|
|
277139
|
+
}
|
|
277140
|
+
listSnapshots(connection) {
|
|
277141
|
+
return this.store.listSnapshots(connection);
|
|
277142
|
+
}
|
|
277143
|
+
diffOutput(connection, command, nextOutput) {
|
|
277144
|
+
return this.store.diffAndRemember(connection, command, nextOutput);
|
|
277145
|
+
}
|
|
277146
|
+
// ── approvals (TTL + two-person) ─────────────────────────────────────────
|
|
277147
|
+
requestApproval(command, ttlMs, twoPerson = false) {
|
|
277148
|
+
return this.store.requestApproval(command, ttlMs, twoPerson);
|
|
277149
|
+
}
|
|
277150
|
+
listApprovals(state) {
|
|
277151
|
+
this.store.sweepExpired();
|
|
277152
|
+
return this.store.listApprovals(state);
|
|
277153
|
+
}
|
|
277154
|
+
getApproval(id) {
|
|
277155
|
+
this.store.sweepExpired();
|
|
277156
|
+
return this.store.getApproval(id);
|
|
277157
|
+
}
|
|
277158
|
+
decideApproval(id, who, approve) {
|
|
277159
|
+
return this.store.decide(id, who, approve);
|
|
277160
|
+
}
|
|
277161
|
+
sweepExpiredApprovals() {
|
|
277162
|
+
return this.store.sweepExpired();
|
|
277163
|
+
}
|
|
277164
|
+
// ── agent replay (debug without touching live hosts) ─────────────────────
|
|
277165
|
+
replay(runId, steps) {
|
|
277166
|
+
return replayWithStubs(runId, steps);
|
|
277167
|
+
}
|
|
277168
|
+
shouldBreakpointBefore(tool2, nextTool) {
|
|
277169
|
+
return breakpointBefore(tool2, nextTool);
|
|
277170
|
+
}
|
|
277171
|
+
// ── offline domain join ──────────────────────────────────────────────────
|
|
277172
|
+
planOfflineJoin(opts) {
|
|
277173
|
+
return planOfflineJoin2(opts);
|
|
277174
|
+
}
|
|
277175
|
+
djoinProvision(domain2, machine, savefile) {
|
|
277176
|
+
return djoinProvisionCommand(domain2, machine, savefile);
|
|
277177
|
+
}
|
|
277178
|
+
djoinRequest(loadfile) {
|
|
277179
|
+
return djoinRequestCommand(loadfile);
|
|
277180
|
+
}
|
|
277181
|
+
// ── network device helpers ───────────────────────────────────────────────
|
|
277182
|
+
parseCdp(showCdp) {
|
|
277183
|
+
return parseCdpNeighbors(showCdp);
|
|
277184
|
+
}
|
|
277185
|
+
configDiff(running, startup) {
|
|
277186
|
+
return configDiff(running, startup);
|
|
277187
|
+
}
|
|
277188
|
+
inConfigMode(prompt) {
|
|
277189
|
+
return inConfigMode(prompt);
|
|
277190
|
+
}
|
|
277191
|
+
};
|
|
277192
|
+
}
|
|
277193
|
+
});
|
|
277194
|
+
|
|
276687
277195
|
// ../../node_modules/@nats-io/nats-core/lib/encoders.js
|
|
276688
277196
|
var require_encoders = __commonJS({
|
|
276689
277197
|
"../../node_modules/@nats-io/nats-core/lib/encoders.js"(exports2) {
|
|
@@ -285435,7 +285943,7 @@ var require_ws_transport = __commonJS({
|
|
|
285435
285943
|
let protocol;
|
|
285436
285944
|
let port;
|
|
285437
285945
|
const host = url2.hostname;
|
|
285438
|
-
const
|
|
285946
|
+
const path34 = url2.pathname;
|
|
285439
285947
|
const search = url2.search || "";
|
|
285440
285948
|
switch (srcProto) {
|
|
285441
285949
|
case "http:":
|
|
@@ -285455,7 +285963,7 @@ var require_ws_transport = __commonJS({
|
|
|
285455
285963
|
protocol = encrypted === true ? "wss:" : "ws:";
|
|
285456
285964
|
break;
|
|
285457
285965
|
}
|
|
285458
|
-
return `${protocol}//${host}:${port}${
|
|
285966
|
+
return `${protocol}//${host}:${port}${path34}${search}`;
|
|
285459
285967
|
}
|
|
285460
285968
|
function wsconnect(opts = {}) {
|
|
285461
285969
|
(0, transport_1.setTransportFactory)({
|
|
@@ -287300,11 +287808,11 @@ var require_jsmconsumer_api = __commonJS({
|
|
|
287300
287808
|
consumerName = cfg.name ?? cfg.durable_name ?? "";
|
|
287301
287809
|
}
|
|
287302
287810
|
if (consumerName !== "") {
|
|
287303
|
-
let
|
|
287304
|
-
if (
|
|
287305
|
-
|
|
287811
|
+
let fs25 = cfg.filter_subject ?? void 0;
|
|
287812
|
+
if (fs25 === ">") {
|
|
287813
|
+
fs25 = void 0;
|
|
287306
287814
|
}
|
|
287307
|
-
subj =
|
|
287815
|
+
subj = fs25 !== void 0 ? `${this.prefix}.CONSUMER.CREATE.${stream}.${consumerName}.${fs25}` : `${this.prefix}.CONSUMER.CREATE.${stream}.${consumerName}`;
|
|
287308
287816
|
} else {
|
|
287309
287817
|
subj = cfg.durable_name ? `${this.prefix}.CONSUMER.DURABLE.CREATE.${stream}.${cfg.durable_name}` : `${this.prefix}.CONSUMER.CREATE.${stream}`;
|
|
287310
287818
|
}
|
|
@@ -291854,8 +292362,8 @@ var init_natsEventBus = __esm({
|
|
|
291854
292362
|
});
|
|
291855
292363
|
|
|
291856
292364
|
// ../../packages/backend/src/runtimes/gybackend/startGyBackend.ts
|
|
291857
|
-
var
|
|
291858
|
-
var
|
|
292365
|
+
var import_node_path30 = __toESM(require("node:path"), 1);
|
|
292366
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
291859
292367
|
var import_node_process2 = __toESM(require("node:process"), 1);
|
|
291860
292368
|
|
|
291861
292369
|
// ../../packages/backend/src/services/TerminalService.ts
|
|
@@ -293888,18 +294396,18 @@ var SSHBackend = class _SSHBackend {
|
|
|
293888
294396
|
});
|
|
293889
294397
|
return info.socket;
|
|
293890
294398
|
}
|
|
293891
|
-
async buildConnectSocketIfNeeded(sshConfig,
|
|
294399
|
+
async buildConnectSocketIfNeeded(sshConfig, emit12) {
|
|
293892
294400
|
if (sshConfig.jumpHost) {
|
|
293893
294401
|
const jumpId = `[Jump:${sshConfig.jumpHost.host}]`;
|
|
293894
294402
|
console.log(`${jumpId} Starting jump host connection flow...`);
|
|
293895
|
-
|
|
294403
|
+
emit12(
|
|
293896
294404
|
`\x1B[36m\u25B9 ${jumpId} Establishing tunnel via jump host ${sshConfig.jumpHost.host}...\x1B[0m\r
|
|
293897
294405
|
`
|
|
293898
294406
|
);
|
|
293899
294407
|
const jumpClient = new (loadSsh2()).Client();
|
|
293900
294408
|
const jumpSock = await this.buildConnectSocketIfNeeded(
|
|
293901
294409
|
sshConfig.jumpHost,
|
|
293902
|
-
|
|
294410
|
+
emit12
|
|
293903
294411
|
);
|
|
293904
294412
|
if (jumpSock) {
|
|
293905
294413
|
console.log(
|
|
@@ -293943,7 +294451,7 @@ var SSHBackend = class _SSHBackend {
|
|
|
293943
294451
|
});
|
|
293944
294452
|
jumpClient.connect(jumpConnectConfig);
|
|
293945
294453
|
});
|
|
293946
|
-
|
|
294454
|
+
emit12(
|
|
293947
294455
|
`\x1B[32m\u2714 ${jumpId} Jump host ready. Requesting forward to target ${sshConfig.host}:${sshConfig.port}...\x1B[0m\r
|
|
293948
294456
|
`
|
|
293949
294457
|
);
|
|
@@ -294259,25 +294767,25 @@ var SSHBackend = class _SSHBackend {
|
|
|
294259
294767
|
};
|
|
294260
294768
|
this.sessions.set(config2.id, instance);
|
|
294261
294769
|
(async () => {
|
|
294262
|
-
const
|
|
294770
|
+
const emit12 = (data) => {
|
|
294263
294771
|
instance.dataCallbacks.forEach((cb) => cb(data));
|
|
294264
294772
|
};
|
|
294265
294773
|
const emitExit = (code) => {
|
|
294266
294774
|
this.emitExitOnce(config2.id, instance, code);
|
|
294267
294775
|
};
|
|
294268
294776
|
client2.on("ready", async () => {
|
|
294269
|
-
|
|
294777
|
+
emit12("\x1B[2J\x1B[H\x1B[32m\u2714 Connection established.\x1B[0m\r\n");
|
|
294270
294778
|
console.log(
|
|
294271
294779
|
`[SSH] Connection ready for ${sshConfig.host}:${sshConfig.port}`
|
|
294272
294780
|
);
|
|
294273
294781
|
const rawShell = isRawShellPreset(sshConfig.algorithmsPreset);
|
|
294274
294782
|
try {
|
|
294275
|
-
|
|
294783
|
+
emit12("\x1B[36m\u25B9 Setting up port forwards...\x1B[0m\r\n");
|
|
294276
294784
|
console.log(`[SSH] Setting up port forwards...`);
|
|
294277
294785
|
await this.setupPortForwards(instance, sshConfig);
|
|
294278
294786
|
} catch (e) {
|
|
294279
294787
|
console.error(`[SSH] Port forward setup failed:`, e);
|
|
294280
|
-
|
|
294788
|
+
emit12(`\x1B[31m\u2718 Port forward failed: ${e.message}\x1B[0m\r
|
|
294281
294789
|
`);
|
|
294282
294790
|
}
|
|
294283
294791
|
if (rawShell) {
|
|
@@ -294287,7 +294795,7 @@ var SSHBackend = class _SSHBackend {
|
|
|
294287
294795
|
);
|
|
294288
294796
|
} else {
|
|
294289
294797
|
try {
|
|
294290
|
-
|
|
294798
|
+
emit12("\x1B[36m\u25B9 Detecting remote OS...\x1B[0m\r\n");
|
|
294291
294799
|
console.log(`[SSH] Detecting remote OS...`);
|
|
294292
294800
|
const uname = await this.execCollect(client2, "uname -s");
|
|
294293
294801
|
const u = (uname.stdout || uname.stderr || "").toLowerCase();
|
|
@@ -294307,13 +294815,13 @@ var SSHBackend = class _SSHBackend {
|
|
|
294307
294815
|
if (!instance.remoteOs) instance.remoteOs = "unix";
|
|
294308
294816
|
console.log(`[SSH] Remote OS detected: ${instance.remoteOs}`);
|
|
294309
294817
|
try {
|
|
294310
|
-
|
|
294818
|
+
emit12("\x1B[36m\u25B9 Initializing SFTP channel...\x1B[0m\r\n");
|
|
294311
294819
|
await this.initializeSftp(instance);
|
|
294312
|
-
|
|
294820
|
+
emit12("\x1B[32m\u2714 SFTP channel ready.\x1B[0m\r\n");
|
|
294313
294821
|
} catch (error40) {
|
|
294314
294822
|
const message = error40 instanceof Error ? error40.message : String(error40);
|
|
294315
294823
|
instance.sftpInitError = message;
|
|
294316
|
-
|
|
294824
|
+
emit12(
|
|
294317
294825
|
`\x1B[33m\u26A0 SFTP unavailable: ${message}. File panel features may be limited.\x1B[0m\r
|
|
294318
294826
|
`
|
|
294319
294827
|
);
|
|
@@ -294326,7 +294834,7 @@ var SSHBackend = class _SSHBackend {
|
|
|
294326
294834
|
}
|
|
294327
294835
|
}
|
|
294328
294836
|
}
|
|
294329
|
-
|
|
294837
|
+
emit12("\x1B[36m\u25B9 Opening interactive shell...\x1B[0m\r\n");
|
|
294330
294838
|
console.log(`[SSH] Opening interactive shell...`);
|
|
294331
294839
|
const initialWindowSize = this.resolveRequestedWindowSize(instance, {
|
|
294332
294840
|
cols: config2.cols,
|
|
@@ -294356,7 +294864,7 @@ var SSHBackend = class _SSHBackend {
|
|
|
294356
294864
|
console.error(`[SSH] Failed to open shell:`, err);
|
|
294357
294865
|
instance.initializationState = "failed";
|
|
294358
294866
|
instance.isInitializing = false;
|
|
294359
|
-
|
|
294867
|
+
emit12(`\x1B[31m\u2718 Failed to open shell: ${err.message}\x1B[0m\r
|
|
294360
294868
|
`);
|
|
294361
294869
|
emitExit(-1);
|
|
294362
294870
|
return;
|
|
@@ -294366,7 +294874,7 @@ var SSHBackend = class _SSHBackend {
|
|
|
294366
294874
|
if (rawShell) {
|
|
294367
294875
|
instance.initializationState = "ready";
|
|
294368
294876
|
instance.isInitializing = false;
|
|
294369
|
-
|
|
294877
|
+
emit12("\x1B[32m\u2714 Shell ready.\x1B[0m\r\n");
|
|
294370
294878
|
console.log(
|
|
294371
294879
|
`[SSH] Raw-shell mode: shell ready immediately (preset=${sshConfig.algorithmsPreset}).`
|
|
294372
294880
|
);
|
|
@@ -294374,14 +294882,14 @@ var SSHBackend = class _SSHBackend {
|
|
|
294374
294882
|
const chunk2 = data.toString();
|
|
294375
294883
|
const sanitizedChunk = this.stripReadyMarker(chunk2);
|
|
294376
294884
|
this.consumeOscMarkers(instance, sanitizedChunk);
|
|
294377
|
-
if (sanitizedChunk)
|
|
294885
|
+
if (sanitizedChunk) emit12(sanitizedChunk);
|
|
294378
294886
|
});
|
|
294379
294887
|
stream.on("close", async (code) => {
|
|
294380
294888
|
emitExit(typeof code === "number" ? code : 0);
|
|
294381
294889
|
});
|
|
294382
294890
|
return;
|
|
294383
294891
|
}
|
|
294384
|
-
|
|
294892
|
+
emit12("\x1B[36m\u25B9 Initializing shell integration...\x1B[0m\r\n");
|
|
294385
294893
|
console.log(
|
|
294386
294894
|
`[SSH] Shell stream opened. Starting robust initialization...`
|
|
294387
294895
|
);
|
|
@@ -294427,7 +294935,7 @@ var SSHBackend = class _SSHBackend {
|
|
|
294427
294935
|
if (retryCount >= maxRetries) {
|
|
294428
294936
|
instance.initializationState = "failed";
|
|
294429
294937
|
instance.isInitializing = false;
|
|
294430
|
-
|
|
294938
|
+
emit12(
|
|
294431
294939
|
"\x1B[31m\u2718 Initialization failed. Entering fallback mode.\x1B[0m\r\n"
|
|
294432
294940
|
);
|
|
294433
294941
|
console.error(
|
|
@@ -294436,7 +294944,7 @@ var SSHBackend = class _SSHBackend {
|
|
|
294436
294944
|
clearInterval(watchdogInterval);
|
|
294437
294945
|
return;
|
|
294438
294946
|
}
|
|
294439
|
-
|
|
294947
|
+
emit12(
|
|
294440
294948
|
`\x1B[33m\u26A0 Initialization timeout, retrying (${retryCount}/${maxRetries})...\x1B[0m\r
|
|
294441
294949
|
`
|
|
294442
294950
|
);
|
|
@@ -294450,7 +294958,7 @@ var SSHBackend = class _SSHBackend {
|
|
|
294450
294958
|
if (instance.isInitializing) {
|
|
294451
294959
|
instance.buffer += chunk2;
|
|
294452
294960
|
if (instance.buffer.includes(GYSHELL_READY_MARKER2)) {
|
|
294453
|
-
|
|
294961
|
+
emit12("\x1B[2J\x1B[H");
|
|
294454
294962
|
isReadySent = true;
|
|
294455
294963
|
clearInterval(watchdogInterval);
|
|
294456
294964
|
const sawContinuation = /(?:\r?\n)>>\s*\r?\n/.test(instance.buffer) || instance.buffer.trimEnd().endsWith("\n>>") || instance.buffer.trimEnd().endsWith("\r\n>>");
|
|
@@ -294461,7 +294969,7 @@ var SSHBackend = class _SSHBackend {
|
|
|
294461
294969
|
const realContent = this.stripReadyMarker(
|
|
294462
294970
|
parts.slice(1).join(GYSHELL_READY_MARKER2)
|
|
294463
294971
|
).trimStart();
|
|
294464
|
-
if (realContent)
|
|
294972
|
+
if (realContent) emit12(realContent);
|
|
294465
294973
|
}
|
|
294466
294974
|
instance.buffer = "";
|
|
294467
294975
|
if (sawContinuation && instance.remoteOs === "windows" && instance.stream) {
|
|
@@ -294477,7 +294985,7 @@ var SSHBackend = class _SSHBackend {
|
|
|
294477
294985
|
const sanitizedChunk = this.stripReadyMarker(chunk2);
|
|
294478
294986
|
this.consumeOscMarkers(instance, sanitizedChunk);
|
|
294479
294987
|
if (sanitizedChunk) {
|
|
294480
|
-
|
|
294988
|
+
emit12(sanitizedChunk);
|
|
294481
294989
|
}
|
|
294482
294990
|
}
|
|
294483
294991
|
});
|
|
@@ -294491,7 +294999,7 @@ var SSHBackend = class _SSHBackend {
|
|
|
294491
294999
|
console.error(`[SSH] Client error:`, err);
|
|
294492
295000
|
instance.initializationState = "failed";
|
|
294493
295001
|
instance.isInitializing = false;
|
|
294494
|
-
|
|
295002
|
+
emit12(`\x1B[31m\u2718 SSH Error: ${err.message}\x1B[0m\r
|
|
294495
295003
|
`);
|
|
294496
295004
|
emitExit(-1);
|
|
294497
295005
|
});
|
|
@@ -294514,7 +295022,7 @@ var SSHBackend = class _SSHBackend {
|
|
|
294514
295022
|
sshConfig.privateKeyPath
|
|
294515
295023
|
);
|
|
294516
295024
|
} catch (e) {
|
|
294517
|
-
|
|
295025
|
+
emit12(
|
|
294518
295026
|
`\x1B[31m\u2718 Failed to read private key: ${e.message}\x1B[0m\r
|
|
294519
295027
|
`
|
|
294520
295028
|
);
|
|
@@ -294526,19 +295034,19 @@ var SSHBackend = class _SSHBackend {
|
|
|
294526
295034
|
}
|
|
294527
295035
|
try {
|
|
294528
295036
|
await new Promise((r) => setTimeout(r, 50));
|
|
294529
|
-
|
|
295037
|
+
emit12(
|
|
294530
295038
|
`\x1B[36m\u25B9 Connecting to ${sshConfig.host}:${sshConfig.port}...\x1B[0m\r
|
|
294531
295039
|
`
|
|
294532
295040
|
);
|
|
294533
295041
|
console.log(
|
|
294534
295042
|
`[SSH] Attempting to connect to ${sshConfig.host}:${sshConfig.port}...`
|
|
294535
295043
|
);
|
|
294536
|
-
const sock = await this.buildConnectSocketIfNeeded(sshConfig,
|
|
295044
|
+
const sock = await this.buildConnectSocketIfNeeded(sshConfig, emit12);
|
|
294537
295045
|
if (sock) {
|
|
294538
295046
|
console.log(
|
|
294539
295047
|
`[SSH] SUCCESS: Connection to ${sshConfig.host} will be tunneled through sock (Jump Host/Proxy).`
|
|
294540
295048
|
);
|
|
294541
|
-
|
|
295049
|
+
emit12(
|
|
294542
295050
|
"\x1B[36m\u25B9 [Final] Using tunnel socket for target connection...\x1B[0m\r\n"
|
|
294543
295051
|
);
|
|
294544
295052
|
connectConfig.sock = sock;
|
|
@@ -294552,7 +295060,7 @@ var SSHBackend = class _SSHBackend {
|
|
|
294552
295060
|
const errMsg = e instanceof Error ? e.message : String(e);
|
|
294553
295061
|
instance.initializationState = "failed";
|
|
294554
295062
|
instance.isInitializing = false;
|
|
294555
|
-
|
|
295063
|
+
emit12(`\x1B[31m\u2718 Connection failed: ${errMsg}\x1B[0m\r
|
|
294556
295064
|
`);
|
|
294557
295065
|
emitExit(-1);
|
|
294558
295066
|
}
|
|
@@ -297073,11 +297581,11 @@ Run commands with exec_command / run_fleet_command. Interactive TUI apps are not
|
|
|
297073
297581
|
var import_node_crypto5 = require("node:crypto");
|
|
297074
297582
|
var injectedSerial = null;
|
|
297075
297583
|
var lazySerial;
|
|
297076
|
-
function constructPort(Ctor,
|
|
297584
|
+
function constructPort(Ctor, path34, opts) {
|
|
297077
297585
|
try {
|
|
297078
|
-
return new Ctor(
|
|
297586
|
+
return new Ctor(path34, opts);
|
|
297079
297587
|
} catch (e) {
|
|
297080
|
-
if (e instanceof TypeError) return new Ctor({ path:
|
|
297588
|
+
if (e instanceof TypeError) return new Ctor({ path: path34, ...opts });
|
|
297081
297589
|
throw e;
|
|
297082
297590
|
}
|
|
297083
297591
|
}
|
|
@@ -297095,7 +297603,7 @@ var SerialBackend = class {
|
|
|
297095
297603
|
try {
|
|
297096
297604
|
const mod = require("serialport");
|
|
297097
297605
|
const Ctor = typeof mod?.SerialPort === "function" ? mod.SerialPort : mod;
|
|
297098
|
-
lazySerial = ((
|
|
297606
|
+
lazySerial = ((path34, opts) => constructPort(Ctor, path34, opts));
|
|
297099
297607
|
} catch {
|
|
297100
297608
|
lazySerial = null;
|
|
297101
297609
|
}
|
|
@@ -301549,8 +302057,8 @@ function shallowCopy(obj) {
|
|
|
301549
302057
|
}
|
|
301550
302058
|
function replaceSecrets(root, secretsMap) {
|
|
301551
302059
|
const result = shallowCopy(root);
|
|
301552
|
-
for (const [
|
|
301553
|
-
const [last, ...partsReverse] =
|
|
302060
|
+
for (const [path34, secretId] of Object.entries(secretsMap)) {
|
|
302061
|
+
const [last, ...partsReverse] = path34.split(".").reverse();
|
|
301554
302062
|
let current = result;
|
|
301555
302063
|
for (const part of partsReverse.reverse()) {
|
|
301556
302064
|
if (current[part] === void 0) break;
|
|
@@ -306614,9 +307122,9 @@ var Client = class _Client {
|
|
|
306614
307122
|
}
|
|
306615
307123
|
return headers;
|
|
306616
307124
|
}
|
|
306617
|
-
_getPlatformEndpointPath(
|
|
307125
|
+
_getPlatformEndpointPath(path34) {
|
|
306618
307126
|
const needsV1Prefix = this.apiUrl.slice(-3) !== "/v1" && this.apiUrl.slice(-4) !== "/v1/";
|
|
306619
|
-
return needsV1Prefix ? `/v1/platform/${
|
|
307127
|
+
return needsV1Prefix ? `/v1/platform/${path34}` : `/platform/${path34}`;
|
|
306620
307128
|
}
|
|
306621
307129
|
async processInputs(inputs) {
|
|
306622
307130
|
if (this.hideInputs === false) {
|
|
@@ -306652,9 +307160,9 @@ var Client = class _Client {
|
|
|
306652
307160
|
}
|
|
306653
307161
|
return runParams;
|
|
306654
307162
|
}
|
|
306655
|
-
async _getResponse(
|
|
307163
|
+
async _getResponse(path34, queryParams) {
|
|
306656
307164
|
const paramsString = queryParams?.toString() ?? "";
|
|
306657
|
-
const url2 = `${this.apiUrl}${
|
|
307165
|
+
const url2 = `${this.apiUrl}${path34}?${paramsString}`;
|
|
306658
307166
|
const response = await this.caller.call(async () => {
|
|
306659
307167
|
const res = await this._fetch(url2, {
|
|
306660
307168
|
method: "GET",
|
|
@@ -306662,22 +307170,22 @@ var Client = class _Client {
|
|
|
306662
307170
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
306663
307171
|
...this.fetchOptions
|
|
306664
307172
|
});
|
|
306665
|
-
await raiseForStatus(res, `fetch ${
|
|
307173
|
+
await raiseForStatus(res, `fetch ${path34}`);
|
|
306666
307174
|
return res;
|
|
306667
307175
|
});
|
|
306668
307176
|
return response;
|
|
306669
307177
|
}
|
|
306670
|
-
async _get(
|
|
306671
|
-
const response = await this._getResponse(
|
|
307178
|
+
async _get(path34, queryParams) {
|
|
307179
|
+
const response = await this._getResponse(path34, queryParams);
|
|
306672
307180
|
return response.json();
|
|
306673
307181
|
}
|
|
306674
|
-
async *_getPaginated(
|
|
307182
|
+
async *_getPaginated(path34, queryParams = new URLSearchParams(), transform2) {
|
|
306675
307183
|
let offset = Number(queryParams.get("offset")) || 0;
|
|
306676
307184
|
const limit2 = Number(queryParams.get("limit")) || 100;
|
|
306677
307185
|
while (true) {
|
|
306678
307186
|
queryParams.set("offset", String(offset));
|
|
306679
307187
|
queryParams.set("limit", String(limit2));
|
|
306680
|
-
const url2 = `${this.apiUrl}${
|
|
307188
|
+
const url2 = `${this.apiUrl}${path34}?${queryParams}`;
|
|
306681
307189
|
const response = await this.caller.call(async () => {
|
|
306682
307190
|
const res = await this._fetch(url2, {
|
|
306683
307191
|
method: "GET",
|
|
@@ -306685,7 +307193,7 @@ var Client = class _Client {
|
|
|
306685
307193
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
306686
307194
|
...this.fetchOptions
|
|
306687
307195
|
});
|
|
306688
|
-
await raiseForStatus(res, `fetch ${
|
|
307196
|
+
await raiseForStatus(res, `fetch ${path34}`);
|
|
306689
307197
|
return res;
|
|
306690
307198
|
});
|
|
306691
307199
|
const items = transform2 ? transform2(await response.json()) : await response.json();
|
|
@@ -306699,19 +307207,19 @@ var Client = class _Client {
|
|
|
306699
307207
|
offset += items.length;
|
|
306700
307208
|
}
|
|
306701
307209
|
}
|
|
306702
|
-
async *_getCursorPaginatedList(
|
|
307210
|
+
async *_getCursorPaginatedList(path34, body = null, requestMethod = "POST", dataKey = "runs") {
|
|
306703
307211
|
const bodyParams = body ? { ...body } : {};
|
|
306704
307212
|
while (true) {
|
|
306705
307213
|
const body2 = JSON.stringify(bodyParams);
|
|
306706
307214
|
const response = await this.caller.call(async () => {
|
|
306707
|
-
const res = await this._fetch(`${this.apiUrl}${
|
|
307215
|
+
const res = await this._fetch(`${this.apiUrl}${path34}`, {
|
|
306708
307216
|
method: requestMethod,
|
|
306709
307217
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
306710
307218
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
306711
307219
|
...this.fetchOptions,
|
|
306712
307220
|
body: body2
|
|
306713
307221
|
});
|
|
306714
|
-
await raiseForStatus(res, `fetch ${
|
|
307222
|
+
await raiseForStatus(res, `fetch ${path34}`);
|
|
306715
307223
|
return res;
|
|
306716
307224
|
});
|
|
306717
307225
|
const responseBody = await response.json();
|
|
@@ -307640,8 +308148,8 @@ Context: ${context2}`);
|
|
|
307640
308148
|
limit: Number(limit2) || 100
|
|
307641
308149
|
};
|
|
307642
308150
|
let currentOffset = Number(offset) || 0;
|
|
307643
|
-
const
|
|
307644
|
-
const url2 = `${this.apiUrl}${
|
|
308151
|
+
const path34 = "/runs/group";
|
|
308152
|
+
const url2 = `${this.apiUrl}${path34}`;
|
|
307645
308153
|
while (true) {
|
|
307646
308154
|
const currentBody = {
|
|
307647
308155
|
...baseBody,
|
|
@@ -307657,7 +308165,7 @@ Context: ${context2}`);
|
|
|
307657
308165
|
...this.fetchOptions,
|
|
307658
308166
|
body
|
|
307659
308167
|
});
|
|
307660
|
-
await raiseForStatus(res, `Failed to fetch ${
|
|
308168
|
+
await raiseForStatus(res, `Failed to fetch ${path34}`);
|
|
307661
308169
|
return res;
|
|
307662
308170
|
});
|
|
307663
308171
|
const items = await response.json();
|
|
@@ -307974,20 +308482,20 @@ Message: ${Array.isArray(result.detail) ? result.detail.join("\n") : "Unspecifie
|
|
|
307974
308482
|
return result;
|
|
307975
308483
|
}
|
|
307976
308484
|
async hasProject({ projectId, projectName }) {
|
|
307977
|
-
let
|
|
308485
|
+
let path34 = "/sessions";
|
|
307978
308486
|
const params = new URLSearchParams();
|
|
307979
308487
|
if (projectId !== void 0 && projectName !== void 0) {
|
|
307980
308488
|
throw new Error("Must provide either projectName or projectId, not both");
|
|
307981
308489
|
} else if (projectId !== void 0) {
|
|
307982
308490
|
assertUuid(projectId);
|
|
307983
|
-
|
|
308491
|
+
path34 += `/${projectId}`;
|
|
307984
308492
|
} else if (projectName !== void 0) {
|
|
307985
308493
|
params.append("name", projectName);
|
|
307986
308494
|
} else {
|
|
307987
308495
|
throw new Error("Must provide projectName or projectId");
|
|
307988
308496
|
}
|
|
307989
308497
|
const response = await this.caller.call(async () => {
|
|
307990
|
-
const res = await this._fetch(`${this.apiUrl}${
|
|
308498
|
+
const res = await this._fetch(`${this.apiUrl}${path34}?${params}`, {
|
|
307991
308499
|
method: "GET",
|
|
307992
308500
|
headers: this.headers,
|
|
307993
308501
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
@@ -308010,13 +308518,13 @@ Message: ${Array.isArray(result.detail) ? result.detail.join("\n") : "Unspecifie
|
|
|
308010
308518
|
}
|
|
308011
308519
|
}
|
|
308012
308520
|
async readProject({ projectId, projectName, includeStats }) {
|
|
308013
|
-
let
|
|
308521
|
+
let path34 = "/sessions";
|
|
308014
308522
|
const params = new URLSearchParams();
|
|
308015
308523
|
if (projectId !== void 0 && projectName !== void 0) {
|
|
308016
308524
|
throw new Error("Must provide either projectName or projectId, not both");
|
|
308017
308525
|
} else if (projectId !== void 0) {
|
|
308018
308526
|
assertUuid(projectId);
|
|
308019
|
-
|
|
308527
|
+
path34 += `/${projectId}`;
|
|
308020
308528
|
} else if (projectName !== void 0) {
|
|
308021
308529
|
params.append("name", projectName);
|
|
308022
308530
|
} else {
|
|
@@ -308025,7 +308533,7 @@ Message: ${Array.isArray(result.detail) ? result.detail.join("\n") : "Unspecifie
|
|
|
308025
308533
|
if (includeStats !== void 0) {
|
|
308026
308534
|
params.append("include_stats", includeStats.toString());
|
|
308027
308535
|
}
|
|
308028
|
-
const response = await this._get(
|
|
308536
|
+
const response = await this._get(path34, params);
|
|
308029
308537
|
let result;
|
|
308030
308538
|
if (Array.isArray(response)) {
|
|
308031
308539
|
if (response.length === 0) {
|
|
@@ -308188,19 +308696,19 @@ Message: ${Array.isArray(result.detail) ? result.detail.join("\n") : "Unspecifie
|
|
|
308188
308696
|
return result;
|
|
308189
308697
|
}
|
|
308190
308698
|
async readDataset({ datasetId, datasetName }) {
|
|
308191
|
-
let
|
|
308699
|
+
let path34 = "/datasets";
|
|
308192
308700
|
const params = new URLSearchParams({ limit: "1" });
|
|
308193
308701
|
if (datasetId && datasetName) {
|
|
308194
308702
|
throw new Error("Must provide either datasetName or datasetId, not both");
|
|
308195
308703
|
} else if (datasetId) {
|
|
308196
308704
|
assertUuid(datasetId);
|
|
308197
|
-
|
|
308705
|
+
path34 += `/${datasetId}`;
|
|
308198
308706
|
} else if (datasetName) {
|
|
308199
308707
|
params.append("name", datasetName);
|
|
308200
308708
|
} else {
|
|
308201
308709
|
throw new Error("Must provide datasetName or datasetId");
|
|
308202
308710
|
}
|
|
308203
|
-
const response = await this._get(
|
|
308711
|
+
const response = await this._get(path34, params);
|
|
308204
308712
|
let result;
|
|
308205
308713
|
if (Array.isArray(response)) {
|
|
308206
308714
|
if (response.length === 0) {
|
|
@@ -308244,20 +308752,20 @@ Message: ${Array.isArray(result.detail) ? result.detail.join("\n") : "Unspecifie
|
|
|
308244
308752
|
return response;
|
|
308245
308753
|
}
|
|
308246
308754
|
async readDatasetOpenaiFinetuning({ datasetId, datasetName }) {
|
|
308247
|
-
const
|
|
308755
|
+
const path34 = "/datasets";
|
|
308248
308756
|
if (datasetId !== void 0) {
|
|
308249
308757
|
} else if (datasetName !== void 0) {
|
|
308250
308758
|
datasetId = (await this.readDataset({ datasetName })).id;
|
|
308251
308759
|
} else {
|
|
308252
308760
|
throw new Error("Must provide either datasetName or datasetId");
|
|
308253
308761
|
}
|
|
308254
|
-
const response = await this._getResponse(`${
|
|
308762
|
+
const response = await this._getResponse(`${path34}/${datasetId}/openai_ft`);
|
|
308255
308763
|
const datasetText = await response.text();
|
|
308256
308764
|
const dataset = datasetText.trim().split("\n").map((line) => JSON.parse(line));
|
|
308257
308765
|
return dataset;
|
|
308258
308766
|
}
|
|
308259
308767
|
async *listDatasets({ limit: limit2 = 100, offset = 0, datasetIds, datasetName, datasetNameContains, metadata } = {}) {
|
|
308260
|
-
const
|
|
308768
|
+
const path34 = "/datasets";
|
|
308261
308769
|
const params = new URLSearchParams({
|
|
308262
308770
|
limit: limit2.toString(),
|
|
308263
308771
|
offset: offset.toString()
|
|
@@ -308276,7 +308784,7 @@ Message: ${Array.isArray(result.detail) ? result.detail.join("\n") : "Unspecifie
|
|
|
308276
308784
|
if (metadata !== void 0) {
|
|
308277
308785
|
params.append("metadata", JSON.stringify(metadata));
|
|
308278
308786
|
}
|
|
308279
|
-
for await (const datasets of this._getPaginated(
|
|
308787
|
+
for await (const datasets of this._getPaginated(path34, params)) {
|
|
308280
308788
|
yield* datasets;
|
|
308281
308789
|
}
|
|
308282
308790
|
}
|
|
@@ -308345,7 +308853,7 @@ Message: ${Array.isArray(result.detail) ? result.detail.join("\n") : "Unspecifie
|
|
|
308345
308853
|
});
|
|
308346
308854
|
}
|
|
308347
308855
|
async deleteDataset({ datasetId, datasetName }) {
|
|
308348
|
-
let
|
|
308856
|
+
let path34 = "/datasets";
|
|
308349
308857
|
let datasetId_ = datasetId;
|
|
308350
308858
|
if (datasetId !== void 0 && datasetName !== void 0) {
|
|
308351
308859
|
throw new Error("Must provide either datasetName or datasetId, not both");
|
|
@@ -308355,18 +308863,18 @@ Message: ${Array.isArray(result.detail) ? result.detail.join("\n") : "Unspecifie
|
|
|
308355
308863
|
}
|
|
308356
308864
|
if (datasetId_ !== void 0) {
|
|
308357
308865
|
assertUuid(datasetId_);
|
|
308358
|
-
|
|
308866
|
+
path34 += `/${datasetId_}`;
|
|
308359
308867
|
} else {
|
|
308360
308868
|
throw new Error("Must provide datasetName or datasetId");
|
|
308361
308869
|
}
|
|
308362
308870
|
await this.caller.call(async () => {
|
|
308363
|
-
const res = await this._fetch(this.apiUrl +
|
|
308871
|
+
const res = await this._fetch(this.apiUrl + path34, {
|
|
308364
308872
|
method: "DELETE",
|
|
308365
308873
|
headers: this.headers,
|
|
308366
308874
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
308367
308875
|
...this.fetchOptions
|
|
308368
308876
|
});
|
|
308369
|
-
await raiseForStatus(res, `delete ${
|
|
308877
|
+
await raiseForStatus(res, `delete ${path34}`, true);
|
|
308370
308878
|
return res;
|
|
308371
308879
|
});
|
|
308372
308880
|
}
|
|
@@ -308557,8 +309065,8 @@ Message: ${Array.isArray(result.detail) ? result.detail.join("\n") : "Unspecifie
|
|
|
308557
309065
|
}
|
|
308558
309066
|
async readExample(exampleId) {
|
|
308559
309067
|
assertUuid(exampleId);
|
|
308560
|
-
const
|
|
308561
|
-
const rawExample = await this._get(
|
|
309068
|
+
const path34 = `/examples/${exampleId}`;
|
|
309069
|
+
const rawExample = await this._get(path34);
|
|
308562
309070
|
const { attachment_urls, ...rest } = rawExample;
|
|
308563
309071
|
const example = rest;
|
|
308564
309072
|
if (attachment_urls) {
|
|
@@ -308641,15 +309149,15 @@ Message: ${Array.isArray(result.detail) ? result.detail.join("\n") : "Unspecifie
|
|
|
308641
309149
|
}
|
|
308642
309150
|
async deleteExample(exampleId) {
|
|
308643
309151
|
assertUuid(exampleId);
|
|
308644
|
-
const
|
|
309152
|
+
const path34 = `/examples/${exampleId}`;
|
|
308645
309153
|
await this.caller.call(async () => {
|
|
308646
|
-
const res = await this._fetch(this.apiUrl +
|
|
309154
|
+
const res = await this._fetch(this.apiUrl + path34, {
|
|
308647
309155
|
method: "DELETE",
|
|
308648
309156
|
headers: this.headers,
|
|
308649
309157
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
308650
309158
|
...this.fetchOptions
|
|
308651
309159
|
});
|
|
308652
|
-
await raiseForStatus(res, `delete ${
|
|
309160
|
+
await raiseForStatus(res, `delete ${path34}`, true);
|
|
308653
309161
|
return res;
|
|
308654
309162
|
});
|
|
308655
309163
|
}
|
|
@@ -308662,9 +309170,9 @@ Message: ${Array.isArray(result.detail) ? result.detail.join("\n") : "Unspecifie
|
|
|
308662
309170
|
async deleteExamples(exampleIds, options) {
|
|
308663
309171
|
exampleIds.forEach((id) => assertUuid(id));
|
|
308664
309172
|
if (options?.hardDelete) {
|
|
308665
|
-
const
|
|
309173
|
+
const path34 = this._getPlatformEndpointPath("datasets/examples/delete");
|
|
308666
309174
|
await this.caller.call(async () => {
|
|
308667
|
-
const res = await this._fetch(`${this.apiUrl}${
|
|
309175
|
+
const res = await this._fetch(`${this.apiUrl}${path34}`, {
|
|
308668
309176
|
method: "POST",
|
|
308669
309177
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
308670
309178
|
body: JSON.stringify({
|
|
@@ -308898,21 +309406,21 @@ Message: ${Array.isArray(result.detail) ? result.detail.join("\n") : "Unspecifie
|
|
|
308898
309406
|
}
|
|
308899
309407
|
async readFeedback(feedbackId) {
|
|
308900
309408
|
assertUuid(feedbackId);
|
|
308901
|
-
const
|
|
308902
|
-
const response = await this._get(
|
|
309409
|
+
const path34 = `/feedback/${feedbackId}`;
|
|
309410
|
+
const response = await this._get(path34);
|
|
308903
309411
|
return response;
|
|
308904
309412
|
}
|
|
308905
309413
|
async deleteFeedback(feedbackId) {
|
|
308906
309414
|
assertUuid(feedbackId);
|
|
308907
|
-
const
|
|
309415
|
+
const path34 = `/feedback/${feedbackId}`;
|
|
308908
309416
|
await this.caller.call(async () => {
|
|
308909
|
-
const res = await this._fetch(this.apiUrl +
|
|
309417
|
+
const res = await this._fetch(this.apiUrl + path34, {
|
|
308910
309418
|
method: "DELETE",
|
|
308911
309419
|
headers: this.headers,
|
|
308912
309420
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
308913
309421
|
...this.fetchOptions
|
|
308914
309422
|
});
|
|
308915
|
-
await raiseForStatus(res, `delete ${
|
|
309423
|
+
await raiseForStatus(res, `delete ${path34}`, true);
|
|
308916
309424
|
return res;
|
|
308917
309425
|
});
|
|
308918
309426
|
}
|
|
@@ -312508,12 +313016,12 @@ function isInteger(str3) {
|
|
|
312508
313016
|
}
|
|
312509
313017
|
return true;
|
|
312510
313018
|
}
|
|
312511
|
-
function escapePathComponent(
|
|
312512
|
-
if (
|
|
312513
|
-
return
|
|
313019
|
+
function escapePathComponent(path34) {
|
|
313020
|
+
if (path34.indexOf("/") === -1 && path34.indexOf("~") === -1) return path34;
|
|
313021
|
+
return path34.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
312514
313022
|
}
|
|
312515
|
-
function unescapePathComponent(
|
|
312516
|
-
return
|
|
313023
|
+
function unescapePathComponent(path34) {
|
|
313024
|
+
return path34.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
312517
313025
|
}
|
|
312518
313026
|
function hasUndefined(obj) {
|
|
312519
313027
|
if (obj === void 0) return true;
|
|
@@ -312707,8 +313215,8 @@ function applyOperation(document2, operation, validateOperation = false, mutateD
|
|
|
312707
313215
|
else return returnValue;
|
|
312708
313216
|
} else {
|
|
312709
313217
|
if (!mutateDocument) document2 = _deepClone(document2);
|
|
312710
|
-
const
|
|
312711
|
-
const keys =
|
|
313218
|
+
const path34 = operation.path || "";
|
|
313219
|
+
const keys = path34.split("/");
|
|
312712
313220
|
let obj = document2;
|
|
312713
313221
|
let t = 1;
|
|
312714
313222
|
let len = keys.length;
|
|
@@ -312831,7 +313339,7 @@ function _areEquals(a, b) {
|
|
|
312831
313339
|
}
|
|
312832
313340
|
|
|
312833
313341
|
// ../../node_modules/@langchain/core/dist/utils/fast-json-patch/src/duplex.js
|
|
312834
|
-
function _generate(mirror, obj, patches,
|
|
313342
|
+
function _generate(mirror, obj, patches, path34, invertible) {
|
|
312835
313343
|
if (obj === mirror) return;
|
|
312836
313344
|
if (typeof obj.toJSON === "function") obj = obj.toJSON();
|
|
312837
313345
|
var newKeys = _objectKeys(obj);
|
|
@@ -312843,40 +313351,40 @@ function _generate(mirror, obj, patches, path33, invertible) {
|
|
|
312843
313351
|
var oldVal = mirror[key];
|
|
312844
313352
|
if (hasOwnProperty(obj, key) && !(obj[key] === void 0 && oldVal !== void 0 && Array.isArray(obj) === false)) {
|
|
312845
313353
|
var newVal = obj[key];
|
|
312846
|
-
if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null && Array.isArray(oldVal) === Array.isArray(newVal)) _generate(oldVal, newVal, patches,
|
|
313354
|
+
if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null && Array.isArray(oldVal) === Array.isArray(newVal)) _generate(oldVal, newVal, patches, path34 + "/" + escapePathComponent(key), invertible);
|
|
312847
313355
|
else if (oldVal !== newVal) {
|
|
312848
313356
|
changed = true;
|
|
312849
313357
|
if (invertible) patches.push({
|
|
312850
313358
|
op: "test",
|
|
312851
|
-
path:
|
|
313359
|
+
path: path34 + "/" + escapePathComponent(key),
|
|
312852
313360
|
value: _deepClone(oldVal)
|
|
312853
313361
|
});
|
|
312854
313362
|
patches.push({
|
|
312855
313363
|
op: "replace",
|
|
312856
|
-
path:
|
|
313364
|
+
path: path34 + "/" + escapePathComponent(key),
|
|
312857
313365
|
value: _deepClone(newVal)
|
|
312858
313366
|
});
|
|
312859
313367
|
}
|
|
312860
313368
|
} else if (Array.isArray(mirror) === Array.isArray(obj)) {
|
|
312861
313369
|
if (invertible) patches.push({
|
|
312862
313370
|
op: "test",
|
|
312863
|
-
path:
|
|
313371
|
+
path: path34 + "/" + escapePathComponent(key),
|
|
312864
313372
|
value: _deepClone(oldVal)
|
|
312865
313373
|
});
|
|
312866
313374
|
patches.push({
|
|
312867
313375
|
op: "remove",
|
|
312868
|
-
path:
|
|
313376
|
+
path: path34 + "/" + escapePathComponent(key)
|
|
312869
313377
|
});
|
|
312870
313378
|
deleted = true;
|
|
312871
313379
|
} else {
|
|
312872
313380
|
if (invertible) patches.push({
|
|
312873
313381
|
op: "test",
|
|
312874
|
-
path:
|
|
313382
|
+
path: path34,
|
|
312875
313383
|
value: mirror
|
|
312876
313384
|
});
|
|
312877
313385
|
patches.push({
|
|
312878
313386
|
op: "replace",
|
|
312879
|
-
path:
|
|
313387
|
+
path: path34,
|
|
312880
313388
|
value: obj
|
|
312881
313389
|
});
|
|
312882
313390
|
changed = true;
|
|
@@ -312887,7 +313395,7 @@ function _generate(mirror, obj, patches, path33, invertible) {
|
|
|
312887
313395
|
var key = newKeys[t];
|
|
312888
313396
|
if (!hasOwnProperty(mirror, key) && obj[key] !== void 0) patches.push({
|
|
312889
313397
|
op: "add",
|
|
312890
|
-
path:
|
|
313398
|
+
path: path34 + "/" + escapePathComponent(key),
|
|
312891
313399
|
value: _deepClone(obj[key])
|
|
312892
313400
|
});
|
|
312893
313401
|
}
|
|
@@ -314273,10 +314781,10 @@ function assignProp(target, prop, value) {
|
|
|
314273
314781
|
configurable: true
|
|
314274
314782
|
});
|
|
314275
314783
|
}
|
|
314276
|
-
function getElementAtPath(obj,
|
|
314277
|
-
if (!
|
|
314784
|
+
function getElementAtPath(obj, path34) {
|
|
314785
|
+
if (!path34)
|
|
314278
314786
|
return obj;
|
|
314279
|
-
return
|
|
314787
|
+
return path34.reduce((acc, key) => acc?.[key], obj);
|
|
314280
314788
|
}
|
|
314281
314789
|
function promiseAllObject(promisesObj) {
|
|
314282
314790
|
const keys = Object.keys(promisesObj);
|
|
@@ -314596,11 +315104,11 @@ function aborted(x, startIndex = 0) {
|
|
|
314596
315104
|
}
|
|
314597
315105
|
return false;
|
|
314598
315106
|
}
|
|
314599
|
-
function prefixIssues(
|
|
315107
|
+
function prefixIssues(path34, issues) {
|
|
314600
315108
|
return issues.map((iss) => {
|
|
314601
315109
|
var _a3;
|
|
314602
315110
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
314603
|
-
iss.path.unshift(
|
|
315111
|
+
iss.path.unshift(path34);
|
|
314604
315112
|
return iss;
|
|
314605
315113
|
});
|
|
314606
315114
|
}
|
|
@@ -314737,7 +315245,7 @@ function treeifyError(error40, _mapper) {
|
|
|
314737
315245
|
return issue2.message;
|
|
314738
315246
|
};
|
|
314739
315247
|
const result = { errors: [] };
|
|
314740
|
-
const processError = (error41,
|
|
315248
|
+
const processError = (error41, path34 = []) => {
|
|
314741
315249
|
var _a3, _b;
|
|
314742
315250
|
for (const issue2 of error41.issues) {
|
|
314743
315251
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -314747,7 +315255,7 @@ function treeifyError(error40, _mapper) {
|
|
|
314747
315255
|
} else if (issue2.code === "invalid_element") {
|
|
314748
315256
|
processError({ issues: issue2.issues }, issue2.path);
|
|
314749
315257
|
} else {
|
|
314750
|
-
const fullpath = [...
|
|
315258
|
+
const fullpath = [...path34, ...issue2.path];
|
|
314751
315259
|
if (fullpath.length === 0) {
|
|
314752
315260
|
result.errors.push(mapper(issue2));
|
|
314753
315261
|
continue;
|
|
@@ -314777,9 +315285,9 @@ function treeifyError(error40, _mapper) {
|
|
|
314777
315285
|
processError(error40);
|
|
314778
315286
|
return result;
|
|
314779
315287
|
}
|
|
314780
|
-
function toDotPath(
|
|
315288
|
+
function toDotPath(path34) {
|
|
314781
315289
|
const segs = [];
|
|
314782
|
-
for (const seg of
|
|
315290
|
+
for (const seg of path34) {
|
|
314783
315291
|
if (typeof seg === "number")
|
|
314784
315292
|
segs.push(`[${seg}]`);
|
|
314785
315293
|
else if (typeof seg === "symbol")
|
|
@@ -327027,10 +327535,10 @@ var Runnable = class extends Serializable {
|
|
|
327027
327535
|
}
|
|
327028
327536
|
const paths = log.ops.filter((op) => op.path.startsWith("/logs/")).map((op) => op.path.split("/")[2]);
|
|
327029
327537
|
const dedupedPaths = [...new Set(paths)];
|
|
327030
|
-
for (const
|
|
327538
|
+
for (const path34 of dedupedPaths) {
|
|
327031
327539
|
let eventType;
|
|
327032
327540
|
let data = {};
|
|
327033
|
-
const logEntry = runLog.state.logs[
|
|
327541
|
+
const logEntry = runLog.state.logs[path34];
|
|
327034
327542
|
if (logEntry.end_time === void 0) if (logEntry.streamed_output.length > 0) eventType = "stream";
|
|
327035
327543
|
else eventType = "start";
|
|
327036
327544
|
else eventType = "end";
|
|
@@ -332723,7 +333231,7 @@ var initializeSax = function() {
|
|
|
332723
333231
|
if (parser.opt.xmlns) parser.ns = Object.create(rootNS);
|
|
332724
333232
|
parser.trackPosition = parser.opt.position !== false;
|
|
332725
333233
|
if (parser.trackPosition) parser.position = parser.line = parser.column = 0;
|
|
332726
|
-
|
|
333234
|
+
emit12(parser, "onready");
|
|
332727
333235
|
}
|
|
332728
333236
|
if (!Object.create) Object.create = function(o) {
|
|
332729
333237
|
function F2() {
|
|
@@ -333189,16 +333697,16 @@ var initializeSax = function() {
|
|
|
333189
333697
|
});
|
|
333190
333698
|
for (var s in sax$1.STATE) sax$1.STATE[sax$1.STATE[s]] = s;
|
|
333191
333699
|
S2 = sax$1.STATE;
|
|
333192
|
-
function
|
|
333700
|
+
function emit12(parser, event, data) {
|
|
333193
333701
|
parser[event] && parser[event](data);
|
|
333194
333702
|
}
|
|
333195
333703
|
function emitNode(parser, nodeType, data) {
|
|
333196
333704
|
if (parser.textNode) closeText(parser);
|
|
333197
|
-
|
|
333705
|
+
emit12(parser, nodeType, data);
|
|
333198
333706
|
}
|
|
333199
333707
|
function closeText(parser) {
|
|
333200
333708
|
parser.textNode = textopts(parser.opt, parser.textNode);
|
|
333201
|
-
if (parser.textNode)
|
|
333709
|
+
if (parser.textNode) emit12(parser, "ontext", parser.textNode);
|
|
333202
333710
|
parser.textNode = "";
|
|
333203
333711
|
}
|
|
333204
333712
|
function textopts(opt, text) {
|
|
@@ -333211,7 +333719,7 @@ var initializeSax = function() {
|
|
|
333211
333719
|
if (parser.trackPosition) er += "\nLine: " + parser.line + "\nColumn: " + parser.column + "\nChar: " + parser.c;
|
|
333212
333720
|
er = new Error(er);
|
|
333213
333721
|
parser.error = er;
|
|
333214
|
-
|
|
333722
|
+
emit12(parser, "onerror", er);
|
|
333215
333723
|
return parser;
|
|
333216
333724
|
}
|
|
333217
333725
|
function end(parser) {
|
|
@@ -333220,7 +333728,7 @@ var initializeSax = function() {
|
|
|
333220
333728
|
closeText(parser);
|
|
333221
333729
|
parser.c = "";
|
|
333222
333730
|
parser.closed = true;
|
|
333223
|
-
|
|
333731
|
+
emit12(parser, "onend");
|
|
333224
333732
|
SAXParser.call(parser, parser.strict, parser.opt);
|
|
333225
333733
|
return parser;
|
|
333226
333734
|
}
|
|
@@ -339095,13 +339603,13 @@ function combineAliasesAndInvert(constructor) {
|
|
|
339095
339603
|
}, {});
|
|
339096
339604
|
}
|
|
339097
339605
|
async function reviver(value) {
|
|
339098
|
-
const { optionalImportsMap, optionalImportEntrypoints: optionalImportEntrypoints$1, importMap, secretsMap, secretsFromEnv, path:
|
|
339099
|
-
const pathStr =
|
|
339606
|
+
const { optionalImportsMap, optionalImportEntrypoints: optionalImportEntrypoints$1, importMap, secretsMap, secretsFromEnv, path: path34, depth, maxDepth } = this;
|
|
339607
|
+
const pathStr = path34.join(".");
|
|
339100
339608
|
if (depth > maxDepth) throw new Error(`Maximum recursion depth (${maxDepth}) exceeded during deserialization. This may indicate a malicious payload or you may need to increase maxDepth.`);
|
|
339101
339609
|
if (typeof value !== "object" || value == null) return value;
|
|
339102
339610
|
if (Array.isArray(value)) return Promise.all(value.map((v, i) => reviver.call({
|
|
339103
339611
|
...this,
|
|
339104
|
-
path: [...
|
|
339612
|
+
path: [...path34, `${i}`],
|
|
339105
339613
|
depth: depth + 1
|
|
339106
339614
|
}, v)));
|
|
339107
339615
|
const record2 = value;
|
|
@@ -339156,7 +339664,7 @@ async function reviver(value) {
|
|
|
339156
339664
|
if (typeof builder !== "function") throw new Error(`Invalid identifer: ${pathStr} -> ${str3}`);
|
|
339157
339665
|
const kwargs = await reviver.call({
|
|
339158
339666
|
...this,
|
|
339159
|
-
path: [...
|
|
339667
|
+
path: [...path34, "kwargs"],
|
|
339160
339668
|
depth: depth + 1
|
|
339161
339669
|
}, serialized.kwargs);
|
|
339162
339670
|
const instance = new builder(mapKeys(kwargs, keyFromJson, combineAliasesAndInvert(builder)));
|
|
@@ -339166,7 +339674,7 @@ async function reviver(value) {
|
|
|
339166
339674
|
const result = {};
|
|
339167
339675
|
for (const [key, val] of Object.entries(record2)) result[key] = await reviver.call({
|
|
339168
339676
|
...this,
|
|
339169
|
-
path: [...
|
|
339677
|
+
path: [...path34, key],
|
|
339170
339678
|
depth: depth + 1
|
|
339171
339679
|
}, val);
|
|
339172
339680
|
return result;
|
|
@@ -344294,10 +344802,10 @@ var Graph$1 = class {
|
|
|
344294
344802
|
this.edges.add([startKey, endKey]);
|
|
344295
344803
|
return this;
|
|
344296
344804
|
}
|
|
344297
|
-
addConditionalEdges(source,
|
|
344805
|
+
addConditionalEdges(source, path34, pathMap) {
|
|
344298
344806
|
const options = typeof source === "object" ? source : {
|
|
344299
344807
|
source,
|
|
344300
|
-
path:
|
|
344808
|
+
path: path34,
|
|
344301
344809
|
pathMap
|
|
344302
344810
|
};
|
|
344303
344811
|
this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.");
|
|
@@ -345851,16 +346359,16 @@ var Diff = class {
|
|
|
345851
346359
|
}
|
|
345852
346360
|
}
|
|
345853
346361
|
}
|
|
345854
|
-
addToPath(
|
|
345855
|
-
const last =
|
|
346362
|
+
addToPath(path34, added, removed, oldPosInc, options) {
|
|
346363
|
+
const last = path34.lastComponent;
|
|
345856
346364
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
345857
346365
|
return {
|
|
345858
|
-
oldPos:
|
|
346366
|
+
oldPos: path34.oldPos + oldPosInc,
|
|
345859
346367
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
345860
346368
|
};
|
|
345861
346369
|
} else {
|
|
345862
346370
|
return {
|
|
345863
|
-
oldPos:
|
|
346371
|
+
oldPos: path34.oldPos + oldPosInc,
|
|
345864
346372
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
345865
346373
|
};
|
|
345866
346374
|
}
|
|
@@ -350577,6 +351085,265 @@ ${usage}`;
|
|
|
350577
351085
|
return msg;
|
|
350578
351086
|
}
|
|
350579
351087
|
|
|
351088
|
+
// ../../packages/backend/src/services/AgentHelper/tools/ops_tools.ts
|
|
351089
|
+
init_zod();
|
|
351090
|
+
function emit6(context2, toolName, input, output) {
|
|
351091
|
+
context2.sendEvent(context2.sessionId, {
|
|
351092
|
+
messageId: context2.messageId,
|
|
351093
|
+
type: "tool_call",
|
|
351094
|
+
toolName,
|
|
351095
|
+
input: typeof input === "string" ? input : JSON.stringify(input),
|
|
351096
|
+
output
|
|
351097
|
+
});
|
|
351098
|
+
}
|
|
351099
|
+
function noService(context2, tool2, args) {
|
|
351100
|
+
const msg = "Ops service is not wired in this runtime.";
|
|
351101
|
+
emit6(context2, tool2, args, msg);
|
|
351102
|
+
return msg;
|
|
351103
|
+
}
|
|
351104
|
+
var manageIncidentSchema = external_exports.object({
|
|
351105
|
+
action: external_exports.enum(["open", "get", "list", "close"]).describe("open a bundle, get one, list, or close it."),
|
|
351106
|
+
id: external_exports.string().optional().describe("Incident id (get/close)."),
|
|
351107
|
+
title: external_exports.string().optional().describe("Incident title (open)."),
|
|
351108
|
+
notes: external_exports.string().optional().describe("Free-form notes (open/close)."),
|
|
351109
|
+
chatId: external_exports.string().optional().describe("Session id to attach (open)."),
|
|
351110
|
+
terminals: external_exports.array(external_exports.string()).optional().describe("Terminal ids to attach (open)."),
|
|
351111
|
+
recordingId: external_exports.string().optional().describe("Recording id to attach (open)."),
|
|
351112
|
+
runId: external_exports.string().optional().describe("Agent run id to attach (open)."),
|
|
351113
|
+
status: external_exports.enum(["open", "closed"]).optional().describe("Filter for list.")
|
|
351114
|
+
});
|
|
351115
|
+
var manageCollabSchema = external_exports.object({
|
|
351116
|
+
action: external_exports.enum(["join", "takeConn", "whoHasConn", "list"]).describe("Session presence for two operators."),
|
|
351117
|
+
sessionId: external_exports.string().optional().describe("Session id (join/takeConn/whoHasConn)."),
|
|
351118
|
+
operator: external_exports.string().optional().describe("Operator name (join/takeConn).")
|
|
351119
|
+
});
|
|
351120
|
+
var manageJumpPathSchema = external_exports.object({
|
|
351121
|
+
action: external_exports.enum(["define", "list", "breakGlass", "allowed"]).describe("Named jump paths + time-boxed break-glass."),
|
|
351122
|
+
name: external_exports.string().optional().describe("Path name (define/breakGlass/allowed)."),
|
|
351123
|
+
hops: external_exports.array(external_exports.object({ host: external_exports.string(), user: external_exports.string().optional(), port: external_exports.number().optional() })).optional().describe('Ordered hops for define \u2014 e.g. [{host:"jump"}, {host:"target",user:"admin"}].'),
|
|
351124
|
+
ttlSeconds: external_exports.number().optional().describe("Break-glass TTL in seconds (breakGlass). Default 3600.")
|
|
351125
|
+
});
|
|
351126
|
+
var manageApprovalSchema = external_exports.object({
|
|
351127
|
+
action: external_exports.enum(["request", "list", "get", "decide", "sweep"]).describe("Time-boxed approvals; twoPerson needs two distinct approvers."),
|
|
351128
|
+
id: external_exports.string().optional().describe("Approval id (get/decide)."),
|
|
351129
|
+
command: external_exports.string().optional().describe("The command awaiting approval (request)."),
|
|
351130
|
+
ttlSeconds: external_exports.number().optional().describe("TTL in seconds (request). Default 900."),
|
|
351131
|
+
twoPerson: external_exports.boolean().optional().describe("Require two distinct approvers (request)."),
|
|
351132
|
+
who: external_exports.string().optional().describe("Approver name (decide)."),
|
|
351133
|
+
approve: external_exports.boolean().optional().describe("true = approve, false = deny (decide)."),
|
|
351134
|
+
state: external_exports.enum(["pending", "approved", "denied", "expired"]).optional().describe("Filter for list.")
|
|
351135
|
+
});
|
|
351136
|
+
var snapshotOutputSchema = external_exports.object({
|
|
351137
|
+
action: external_exports.enum(["remember", "list", "diff"]).describe("Baseline command output and diff against it later (config drift)."),
|
|
351138
|
+
connection: external_exports.string().describe("Connection/tab name, e.g. CORP-WS2 or cisco-xe-1."),
|
|
351139
|
+
command: external_exports.string().optional().describe("The command whose output is being baselined (remember/diff)."),
|
|
351140
|
+
output: external_exports.string().optional().describe("The output text (remember/diff).")
|
|
351141
|
+
});
|
|
351142
|
+
var replayAgentRunSchema = external_exports.object({
|
|
351143
|
+
runId: external_exports.string().describe("Run id from the run ledger to replay."),
|
|
351144
|
+
steps: external_exports.array(
|
|
351145
|
+
external_exports.object({
|
|
351146
|
+
tool: external_exports.string(),
|
|
351147
|
+
args: external_exports.unknown().optional(),
|
|
351148
|
+
output: external_exports.string().optional().describe("Stubbed output \u2014 the real tool is NOT called.")
|
|
351149
|
+
})
|
|
351150
|
+
).describe("Steps with stubbed outputs so a replay never touches live hosts.")
|
|
351151
|
+
});
|
|
351152
|
+
var planOfflineJoinSchema = external_exports.object({
|
|
351153
|
+
domain: external_exports.string().describe("Target AD domain, e.g. corp.local."),
|
|
351154
|
+
machine: external_exports.string().describe("Machine name to join, e.g. EC2AMAZ-C69VULQ."),
|
|
351155
|
+
dcConnection: external_exports.string().describe("Saved connection name for the DC, e.g. CORP-DC1."),
|
|
351156
|
+
memberConnection: external_exports.string().describe("Saved connection name for the member, e.g. CORP-WS2.")
|
|
351157
|
+
});
|
|
351158
|
+
var netDeviceSchema = external_exports.object({
|
|
351159
|
+
action: external_exports.enum(["parseCdp", "configDiff", "inConfigMode"]).describe("Network-device helpers."),
|
|
351160
|
+
output: external_exports.string().optional().describe("Text to parse (parseCdp) or the prompt to test (inConfigMode)."),
|
|
351161
|
+
running: external_exports.string().optional().describe("running-config text (configDiff)."),
|
|
351162
|
+
startup: external_exports.string().optional().describe("startup-config text (configDiff).")
|
|
351163
|
+
});
|
|
351164
|
+
async function manageIncident(args, context2) {
|
|
351165
|
+
const svc = context2.opsService;
|
|
351166
|
+
if (!svc) return noService(context2, "manage_incident", args);
|
|
351167
|
+
let msg;
|
|
351168
|
+
if (args.action === "open") {
|
|
351169
|
+
if (!args.title) {
|
|
351170
|
+
msg = "open requires a title";
|
|
351171
|
+
} else {
|
|
351172
|
+
const inc = svc.openIncident(args.title, {
|
|
351173
|
+
sessionId: args.chatId,
|
|
351174
|
+
tabIds: args.terminals,
|
|
351175
|
+
recordingId: args.recordingId,
|
|
351176
|
+
runId: args.runId,
|
|
351177
|
+
notes: args.notes
|
|
351178
|
+
});
|
|
351179
|
+
msg = `Opened incident ${inc.id} "${inc.title}"${inc.tabIds.length ? ` with ${inc.tabIds.length} terminal(s)` : ""}.`;
|
|
351180
|
+
}
|
|
351181
|
+
} else if (args.action === "get") {
|
|
351182
|
+
const inc = args.id ? svc.getIncident(args.id) : void 0;
|
|
351183
|
+
msg = inc ? JSON.stringify(inc) : `No incident ${args.id ?? "(missing id)"}`;
|
|
351184
|
+
} else if (args.action === "close") {
|
|
351185
|
+
const inc = args.id ? svc.closeIncident(args.id, args.notes) : void 0;
|
|
351186
|
+
msg = inc ? `Closed incident ${inc.id}.` : `No incident ${args.id ?? "(missing id)"}`;
|
|
351187
|
+
} else {
|
|
351188
|
+
const list = svc.listIncidents(args.status);
|
|
351189
|
+
msg = list.length ? list.map((i) => `- ${i.id} [${i.status}] ${i.title}${i.tabIds.length ? ` tabs=${i.tabIds.join(",")}` : ""}`).join("\n") : "No incidents.";
|
|
351190
|
+
}
|
|
351191
|
+
emit6(context2, "manage_incident", args, msg);
|
|
351192
|
+
return msg;
|
|
351193
|
+
}
|
|
351194
|
+
async function manageCollab(args, context2) {
|
|
351195
|
+
const svc = context2.opsService;
|
|
351196
|
+
if (!svc) return noService(context2, "manage_collab", args);
|
|
351197
|
+
const sessionId = args.sessionId || context2.sessionId;
|
|
351198
|
+
let msg;
|
|
351199
|
+
if (args.action === "list") {
|
|
351200
|
+
const rooms2 = svc.listCollabSessions();
|
|
351201
|
+
msg = rooms2.length ? rooms2.map((r) => `- ${r.sessionId} holder=${r.holder ?? "none"} operators=${r.operators.join(",") || "none"}`).join("\n") : "No shared sessions yet.";
|
|
351202
|
+
} else if (args.action === "whoHasConn") {
|
|
351203
|
+
const p = svc.whoHasConn(sessionId);
|
|
351204
|
+
msg = `Session ${p.sessionId}: holder=${p.holder ?? "none"} operators=${p.operators.join(",") || "none"}`;
|
|
351205
|
+
} else {
|
|
351206
|
+
const operator = args.operator || "agent";
|
|
351207
|
+
const p = args.action === "join" ? svc.joinCollab(sessionId, operator) : svc.takeConn(sessionId, operator);
|
|
351208
|
+
msg = `${operator} ${args.action === "join" ? "joined" : "has the conn"} for ${p.sessionId}; operators=${p.operators.join(",")} holder=${p.holder ?? "none"}`;
|
|
351209
|
+
}
|
|
351210
|
+
emit6(context2, "manage_collab", args, msg);
|
|
351211
|
+
return msg;
|
|
351212
|
+
}
|
|
351213
|
+
async function manageJumpPath(args, context2) {
|
|
351214
|
+
const svc = context2.opsService;
|
|
351215
|
+
if (!svc) return noService(context2, "manage_jump_path", args);
|
|
351216
|
+
let msg;
|
|
351217
|
+
if (args.action === "list") {
|
|
351218
|
+
const paths = svc.listJumpPaths();
|
|
351219
|
+
msg = paths.length ? paths.map((p) => {
|
|
351220
|
+
const bg = p.breakGlassUntil ? new Date(p.breakGlassUntil).toISOString() : "none";
|
|
351221
|
+
return `- ${p.name} hops=${p.hops.map((h) => h.host).join("->")} breakGlassUntil=${bg}`;
|
|
351222
|
+
}).join("\n") : "No jump paths defined.";
|
|
351223
|
+
} else if (args.action === "allowed") {
|
|
351224
|
+
if (!args.name) msg = "allowed requires name";
|
|
351225
|
+
else {
|
|
351226
|
+
const r = svc.pathAllowed(args.name);
|
|
351227
|
+
msg = `${args.name}: allowed=${r.allowed}${r.expired ? " (break-glass expired)" : ""}${r.breakGlassUntil ? ` until ${new Date(r.breakGlassUntil).toISOString()}` : ""}`;
|
|
351228
|
+
}
|
|
351229
|
+
} else if (args.action === "breakGlass") {
|
|
351230
|
+
if (!args.name) msg = "breakGlass requires name";
|
|
351231
|
+
else {
|
|
351232
|
+
const p = svc.grantBreakGlass(args.name, (args.ttlSeconds ?? 3600) * 1e3);
|
|
351233
|
+
msg = p ? `Break-glass granted on ${p.name} until ${new Date(p.breakGlassUntil ?? 0).toISOString()}` : `No jump path "${args.name}"`;
|
|
351234
|
+
}
|
|
351235
|
+
} else {
|
|
351236
|
+
if (!args.name || !args.hops?.length) msg = "define requires name and hops";
|
|
351237
|
+
else {
|
|
351238
|
+
const p = svc.defineJumpPath(args.name, args.hops);
|
|
351239
|
+
msg = `Defined jump path ${p.name} with ${p.hops.length} hop(s): ${p.hops.map((h) => h.host).join(" -> ")}`;
|
|
351240
|
+
}
|
|
351241
|
+
}
|
|
351242
|
+
emit6(context2, "manage_jump_path", args, msg);
|
|
351243
|
+
return msg;
|
|
351244
|
+
}
|
|
351245
|
+
async function manageApproval(args, context2) {
|
|
351246
|
+
const svc = context2.opsService;
|
|
351247
|
+
if (!svc) return noService(context2, "manage_approval", args);
|
|
351248
|
+
let msg;
|
|
351249
|
+
if (args.action === "request") {
|
|
351250
|
+
if (!args.command) msg = "request requires command";
|
|
351251
|
+
else {
|
|
351252
|
+
const a = svc.requestApproval(args.command, (args.ttlSeconds ?? 900) * 1e3, args.twoPerson === true);
|
|
351253
|
+
msg = `Approval ${a.id} requested for: ${a.command}
|
|
351254
|
+
twoPerson=${a.twoPerson} expires=${new Date(a.expiresAt).toISOString()}
|
|
351255
|
+
` + (a.twoPerson ? "Two DISTINCT approvers are required before this may run." : "One approver suffices.");
|
|
351256
|
+
}
|
|
351257
|
+
} else if (args.action === "get") {
|
|
351258
|
+
const a = args.id ? svc.getApproval(args.id) : void 0;
|
|
351259
|
+
msg = a ? JSON.stringify(a) : `No approval ${args.id ?? "(missing id)"}`;
|
|
351260
|
+
} else if (args.action === "sweep") {
|
|
351261
|
+
msg = `Expired ${svc.sweepExpiredApprovals()} approval(s).`;
|
|
351262
|
+
} else if (args.action === "decide") {
|
|
351263
|
+
if (!args.id || !args.who || typeof args.approve !== "boolean") msg = "decide requires id, who and approve";
|
|
351264
|
+
else {
|
|
351265
|
+
const r = svc.decideApproval(args.id, args.who, args.approve);
|
|
351266
|
+
msg = `approval ${r.approval.id}: state=${r.approval.state}${r.reason ? ` (${r.reason})` : ""}`;
|
|
351267
|
+
}
|
|
351268
|
+
} else {
|
|
351269
|
+
const list = svc.listApprovals(args.state);
|
|
351270
|
+
msg = list.length ? list.map((a) => `- ${a.id} [${a.state}]${a.twoPerson ? " (2-person)" : ""} ${a.command} expires=${new Date(a.expiresAt).toISOString()}`).join("\n") : "No approvals.";
|
|
351271
|
+
}
|
|
351272
|
+
emit6(context2, "manage_approval", args, msg);
|
|
351273
|
+
return msg;
|
|
351274
|
+
}
|
|
351275
|
+
async function snapshotOutput(args, context2) {
|
|
351276
|
+
const svc = context2.opsService;
|
|
351277
|
+
if (!svc) return noService(context2, "snapshot_output", args);
|
|
351278
|
+
let msg;
|
|
351279
|
+
if (args.action === "list") {
|
|
351280
|
+
const snaps = svc.listSnapshots(args.connection);
|
|
351281
|
+
msg = snaps.length ? snaps.map((s) => `- ${s.connection} :: ${s.command} (${s.output.length} chars @ ${new Date(s.at).toISOString()})`).join("\n") : `No snapshots for ${args.connection}.`;
|
|
351282
|
+
} else if (args.action === "remember") {
|
|
351283
|
+
if (!args.command || args.output === void 0) msg = "remember requires command and output";
|
|
351284
|
+
else {
|
|
351285
|
+
svc.rememberOutput(args.connection, args.command, args.output);
|
|
351286
|
+
msg = `Baseline stored for ${args.connection} :: ${args.command} (${args.output.length} chars).`;
|
|
351287
|
+
}
|
|
351288
|
+
} else {
|
|
351289
|
+
if (!args.command || args.output === void 0) msg = "diff requires command and output";
|
|
351290
|
+
else {
|
|
351291
|
+
const d = svc.diffOutput(args.connection, args.command, args.output);
|
|
351292
|
+
msg = d.previous === null ? `No baseline existed \u2014 stored this output (${args.output.length} chars) as the baseline for ${args.connection} :: ${args.command}.` : `changed=${d.changed} for ${args.connection} :: ${args.command}`;
|
|
351293
|
+
}
|
|
351294
|
+
}
|
|
351295
|
+
emit6(context2, "snapshot_output", args, msg);
|
|
351296
|
+
return msg;
|
|
351297
|
+
}
|
|
351298
|
+
async function replayAgentRun(args, context2) {
|
|
351299
|
+
const svc = context2.opsService;
|
|
351300
|
+
if (!svc) return noService(context2, "replay_agent_run", args);
|
|
351301
|
+
const r = svc.replay(
|
|
351302
|
+
args.runId,
|
|
351303
|
+
args.steps.map((s) => ({
|
|
351304
|
+
tool: s.tool,
|
|
351305
|
+
args: s.args && typeof s.args === "object" && !Array.isArray(s.args) ? s.args : {},
|
|
351306
|
+
stub: s.output ?? ""
|
|
351307
|
+
}))
|
|
351308
|
+
);
|
|
351309
|
+
const msg = `Replay ${args.runId}: ${r.steps.length} step(s) completed. Tools that would have been called: ${r.wouldHaveCalled.join(", ") || "(none)"}. No live tool was called.`;
|
|
351310
|
+
emit6(context2, "replay_agent_run", args, msg);
|
|
351311
|
+
return msg;
|
|
351312
|
+
}
|
|
351313
|
+
async function planOfflineJoin(args, context2) {
|
|
351314
|
+
const svc = context2.opsService;
|
|
351315
|
+
if (!svc) return noService(context2, "plan_offline_join", args);
|
|
351316
|
+
svc.planOfflineJoin(args);
|
|
351317
|
+
const lines = [
|
|
351318
|
+
`Offline join plan for ${args.machine} into ${args.domain}:`,
|
|
351319
|
+
`1. on ${args.dcConnection}: ${svc.djoinProvision(args.domain, args.machine)}`,
|
|
351320
|
+
`2. copy the blob to ${args.memberConnection} (no SMB required)`,
|
|
351321
|
+
`3. on ${args.memberConnection}: ${svc.djoinRequest()}`,
|
|
351322
|
+
`4. reboot ${args.memberConnection}, then verify with estate_facts / collect_facts`,
|
|
351323
|
+
`Use this INSTEAD of Add-Computer when NetUseAdd \\\\DC\\IPC$ fails with 64 (network name no longer available).`
|
|
351324
|
+
];
|
|
351325
|
+
const msg = lines.join("\n");
|
|
351326
|
+
emit6(context2, "plan_offline_join", args, msg);
|
|
351327
|
+
return msg;
|
|
351328
|
+
}
|
|
351329
|
+
async function netDevice(args, context2) {
|
|
351330
|
+
const svc = context2.opsService;
|
|
351331
|
+
if (!svc) return noService(context2, "net_device", args);
|
|
351332
|
+
let msg;
|
|
351333
|
+
if (args.action === "parseCdp") {
|
|
351334
|
+
const neighbors = svc.parseCdp(args.output ?? "");
|
|
351335
|
+
msg = neighbors.length ? neighbors.map((n2) => `- ${n2.device} local=${n2.localIntf} remote=${n2.remoteIntf}`).join("\n") : "No CDP neighbors parsed (empty or unrecognised output).";
|
|
351336
|
+
} else if (args.action === "inConfigMode") {
|
|
351337
|
+
msg = svc.inConfigMode(args.output ?? "") ? "Device prompt looks like CONFIG mode." : "Not in config mode.";
|
|
351338
|
+
} else {
|
|
351339
|
+
const d = svc.configDiff(args.running ?? "", args.startup ?? "");
|
|
351340
|
+
msg = d.changed ? `running-config DIFFERS from startup-config:
|
|
351341
|
+
${d.unified.slice(0, 4e3)}` : "running-config matches startup-config.";
|
|
351342
|
+
}
|
|
351343
|
+
emit6(context2, "net_device", args, msg);
|
|
351344
|
+
return msg;
|
|
351345
|
+
}
|
|
351346
|
+
|
|
350580
351347
|
// ../../packages/backend/src/services/AgentHelper/tools/fleet_tools.ts
|
|
350581
351348
|
init_zod();
|
|
350582
351349
|
|
|
@@ -351425,7 +352192,7 @@ function importPuttyReg(content, opts) {
|
|
|
351425
352192
|
}
|
|
351426
352193
|
|
|
351427
352194
|
// ../../packages/backend/src/services/AgentHelper/tools/automation_tools.ts
|
|
351428
|
-
function
|
|
352195
|
+
function emit7(context2, _toolName, input, output) {
|
|
351429
352196
|
context2.sendEvent(context2.sessionId, {
|
|
351430
352197
|
messageId: context2.messageId,
|
|
351431
352198
|
type: "tool_call",
|
|
@@ -351452,7 +352219,7 @@ async function manageDeviceMemory(args, context2) {
|
|
|
351452
352219
|
const m2 = context2.automationManager;
|
|
351453
352220
|
if (!m2) {
|
|
351454
352221
|
const msg2 = noStore();
|
|
351455
|
-
|
|
352222
|
+
emit7(context2, "manage_device_memory", args, msg2);
|
|
351456
352223
|
return msg2;
|
|
351457
352224
|
}
|
|
351458
352225
|
const { action } = args;
|
|
@@ -351460,25 +352227,25 @@ async function manageDeviceMemory(args, context2) {
|
|
|
351460
352227
|
const all = m2.listDeviceMemory();
|
|
351461
352228
|
if (!all.length) {
|
|
351462
352229
|
const msg3 = "No device memory entries.";
|
|
351463
|
-
|
|
352230
|
+
emit7(context2, "manage_device_memory", args, msg3);
|
|
351464
352231
|
return msg3;
|
|
351465
352232
|
}
|
|
351466
352233
|
const body = all.map((e) => `${e.host} (role=${e.role || "unspecified"}, ${e.incidents.length} incident(s))`).join("\n");
|
|
351467
352234
|
const msg2 = `Device memory (${all.length}):
|
|
351468
352235
|
${body}`;
|
|
351469
|
-
|
|
352236
|
+
emit7(context2, "manage_device_memory", args, msg2);
|
|
351470
352237
|
return msg2;
|
|
351471
352238
|
}
|
|
351472
352239
|
if (!args.host) {
|
|
351473
352240
|
const msg2 = `action="${action}" requires a host.`;
|
|
351474
|
-
|
|
352241
|
+
emit7(context2, "manage_device_memory", args, msg2);
|
|
351475
352242
|
return msg2;
|
|
351476
352243
|
}
|
|
351477
352244
|
if (action === "get") {
|
|
351478
352245
|
const mem = m2.getDeviceMemory(args.host);
|
|
351479
352246
|
if (!mem) {
|
|
351480
352247
|
const msg3 = `No device memory for host "${args.host}".`;
|
|
351481
|
-
|
|
352248
|
+
emit7(context2, "manage_device_memory", args, msg3);
|
|
351482
352249
|
return msg3;
|
|
351483
352250
|
}
|
|
351484
352251
|
const msg2 = `Device memory for ${args.host}:
|
|
@@ -351486,18 +352253,18 @@ role: ${mem.role || "unspecified"}
|
|
|
351486
352253
|
standing instructions: ${mem.standingInstructions || "(none)"}
|
|
351487
352254
|
incidents (${mem.incidents.length}):
|
|
351488
352255
|
${mem.incidents.map((i) => `- [${i.at}] ${i.summary}${i.ticketId ? ` (ticket: ${i.ticketId})` : ""}${i.resolution ? ` \u2014 ${i.resolution}` : ""}`).join("\n")}`;
|
|
351489
|
-
|
|
352256
|
+
emit7(context2, "manage_device_memory", args, msg2);
|
|
351490
352257
|
return msg2;
|
|
351491
352258
|
}
|
|
351492
352259
|
if (action === "add_incident") {
|
|
351493
352260
|
if (!args.incident) {
|
|
351494
352261
|
const msg3 = "add_incident requires an `incident` object.";
|
|
351495
|
-
|
|
352262
|
+
emit7(context2, "manage_device_memory", args, msg3);
|
|
351496
352263
|
return msg3;
|
|
351497
352264
|
}
|
|
351498
352265
|
const inc = m2.addIncident(args.host, args.incident);
|
|
351499
352266
|
const msg2 = `Recorded incident for ${args.host} at ${inc.at}: ${inc.summary}.`;
|
|
351500
|
-
|
|
352267
|
+
emit7(context2, "manage_device_memory", args, msg2);
|
|
351501
352268
|
return msg2;
|
|
351502
352269
|
}
|
|
351503
352270
|
if (action === "upsert") {
|
|
@@ -351508,17 +352275,17 @@ ${mem.incidents.map((i) => `- [${i.at}] ${i.summary}${i.ticketId ? ` (ticket: ${
|
|
|
351508
352275
|
incidents: []
|
|
351509
352276
|
});
|
|
351510
352277
|
const msg2 = `Saved device memory for ${mem.host} (role=${mem.role || "unspecified"}).`;
|
|
351511
|
-
|
|
352278
|
+
emit7(context2, "manage_device_memory", args, msg2);
|
|
351512
352279
|
return msg2;
|
|
351513
352280
|
}
|
|
351514
352281
|
if (action === "delete") {
|
|
351515
352282
|
const removed = m2.deleteDeviceMemory(args.host);
|
|
351516
352283
|
const msg2 = removed ? `Deleted device memory for ${args.host}.` : `No device memory for ${args.host}.`;
|
|
351517
|
-
|
|
352284
|
+
emit7(context2, "manage_device_memory", args, msg2);
|
|
351518
352285
|
return msg2;
|
|
351519
352286
|
}
|
|
351520
352287
|
const msg = `Unknown action "${action}".`;
|
|
351521
|
-
|
|
352288
|
+
emit7(context2, "manage_device_memory", args, msg);
|
|
351522
352289
|
return msg;
|
|
351523
352290
|
}
|
|
351524
352291
|
var manageScriptSchema = external_exports.object({
|
|
@@ -351534,7 +352301,7 @@ async function manageScript(args, context2) {
|
|
|
351534
352301
|
const m2 = context2.automationManager;
|
|
351535
352302
|
if (!m2) {
|
|
351536
352303
|
const msg2 = noStore();
|
|
351537
|
-
|
|
352304
|
+
emit7(context2, "manage_script", args, msg2);
|
|
351538
352305
|
return msg2;
|
|
351539
352306
|
}
|
|
351540
352307
|
const { action } = args;
|
|
@@ -351542,56 +352309,56 @@ async function manageScript(args, context2) {
|
|
|
351542
352309
|
const all = m2.listScripts();
|
|
351543
352310
|
if (!all.length) {
|
|
351544
352311
|
const msg3 = "No saved scripts.";
|
|
351545
|
-
|
|
352312
|
+
emit7(context2, "manage_script", args, msg3);
|
|
351546
352313
|
return msg3;
|
|
351547
352314
|
}
|
|
351548
352315
|
const body = all.map((s) => `- ${s.name} (id=${s.id}): ${s.command.split("\n")[0].slice(0, 60)}${s.command.length > 60 ? "\u2026" : ""}`).join("\n");
|
|
351549
352316
|
const msg2 = `Saved scripts (${all.length}):
|
|
351550
352317
|
${body}`;
|
|
351551
|
-
|
|
352318
|
+
emit7(context2, "manage_script", args, msg2);
|
|
351552
352319
|
return msg2;
|
|
351553
352320
|
}
|
|
351554
352321
|
if (action === "create") {
|
|
351555
352322
|
if (!args.name || !args.command) {
|
|
351556
352323
|
const msg3 = "create requires name + command.";
|
|
351557
|
-
|
|
352324
|
+
emit7(context2, "manage_script", args, msg3);
|
|
351558
352325
|
return msg3;
|
|
351559
352326
|
}
|
|
351560
352327
|
const s = m2.createScript({ name: args.name, command: args.command, description: args.description, targets: args.targets, tags: args.tags });
|
|
351561
352328
|
const msg2 = `Created script "${s.name}" (id=${s.id}). Run it on open tabs with run_fleet_command or exec_command using its command body.`;
|
|
351562
|
-
|
|
352329
|
+
emit7(context2, "manage_script", args, msg2);
|
|
351563
352330
|
return msg2;
|
|
351564
352331
|
}
|
|
351565
352332
|
if (action === "update") {
|
|
351566
352333
|
if (!args.id) {
|
|
351567
352334
|
const msg3 = "update requires id.";
|
|
351568
|
-
|
|
352335
|
+
emit7(context2, "manage_script", args, msg3);
|
|
351569
352336
|
return msg3;
|
|
351570
352337
|
}
|
|
351571
352338
|
const existing = m2.listScripts().find((s2) => s2.id === args.id);
|
|
351572
352339
|
if (!existing) {
|
|
351573
352340
|
const msg3 = `No script with id="${args.id}".`;
|
|
351574
|
-
|
|
352341
|
+
emit7(context2, "manage_script", args, msg3);
|
|
351575
352342
|
return msg3;
|
|
351576
352343
|
}
|
|
351577
352344
|
const s = m2.updateScript({ ...existing, name: args.name ?? existing.name, command: args.command ?? existing.command, description: args.description ?? existing.description, targets: args.targets ?? existing.targets, tags: args.tags ?? existing.tags });
|
|
351578
352345
|
const msg2 = `Updated script "${s.name}".`;
|
|
351579
|
-
|
|
352346
|
+
emit7(context2, "manage_script", args, msg2);
|
|
351580
352347
|
return msg2;
|
|
351581
352348
|
}
|
|
351582
352349
|
if (action === "delete") {
|
|
351583
352350
|
if (!args.id) {
|
|
351584
352351
|
const msg3 = "delete requires id.";
|
|
351585
|
-
|
|
352352
|
+
emit7(context2, "manage_script", args, msg3);
|
|
351586
352353
|
return msg3;
|
|
351587
352354
|
}
|
|
351588
352355
|
const removed = m2.deleteScript(args.id);
|
|
351589
352356
|
const msg2 = removed ? `Deleted script ${args.id}.` : `No script ${args.id}.`;
|
|
351590
|
-
|
|
352357
|
+
emit7(context2, "manage_script", args, msg2);
|
|
351591
352358
|
return msg2;
|
|
351592
352359
|
}
|
|
351593
352360
|
const msg = `Unknown action "${action}".`;
|
|
351594
|
-
|
|
352361
|
+
emit7(context2, "manage_script", args, msg);
|
|
351595
352362
|
return msg;
|
|
351596
352363
|
}
|
|
351597
352364
|
var manageGroupSchema = external_exports.object({
|
|
@@ -351604,7 +352371,7 @@ async function manageGroup(args, context2) {
|
|
|
351604
352371
|
const m2 = context2.automationManager;
|
|
351605
352372
|
if (!m2) {
|
|
351606
352373
|
const msg2 = noStore();
|
|
351607
|
-
|
|
352374
|
+
emit7(context2, "manage_group", args, msg2);
|
|
351608
352375
|
return msg2;
|
|
351609
352376
|
}
|
|
351610
352377
|
const { action } = args;
|
|
@@ -351612,49 +352379,49 @@ async function manageGroup(args, context2) {
|
|
|
351612
352379
|
const all = m2.listGroups();
|
|
351613
352380
|
if (!all.length) {
|
|
351614
352381
|
const msg3 = "No groups.";
|
|
351615
|
-
|
|
352382
|
+
emit7(context2, "manage_group", args, msg3);
|
|
351616
352383
|
return msg3;
|
|
351617
352384
|
}
|
|
351618
352385
|
const msg2 = `Groups (${all.length}):
|
|
351619
352386
|
${all.map((g) => `- ${g.name} (id=${g.id}${g.parentId ? `, parent=${g.parentId}` : ""})`).join("\n")}`;
|
|
351620
|
-
|
|
352387
|
+
emit7(context2, "manage_group", args, msg2);
|
|
351621
352388
|
return msg2;
|
|
351622
352389
|
}
|
|
351623
352390
|
if (action === "create") {
|
|
351624
352391
|
if (!args.name) {
|
|
351625
352392
|
const msg3 = "create requires name.";
|
|
351626
|
-
|
|
352393
|
+
emit7(context2, "manage_group", args, msg3);
|
|
351627
352394
|
return msg3;
|
|
351628
352395
|
}
|
|
351629
352396
|
const g = m2.createGroup(args.name, args.parentId ?? null);
|
|
351630
352397
|
const msg2 = `Created group "${g.name}" (id=${g.id}). Assign a connection by setting its groupId via manage_ssh_connection.update or the Connections panel.`;
|
|
351631
|
-
|
|
352398
|
+
emit7(context2, "manage_group", args, msg2);
|
|
351632
352399
|
return msg2;
|
|
351633
352400
|
}
|
|
351634
352401
|
if (action === "update") {
|
|
351635
352402
|
if (!args.id) {
|
|
351636
352403
|
const msg3 = "update requires id.";
|
|
351637
|
-
|
|
352404
|
+
emit7(context2, "manage_group", args, msg3);
|
|
351638
352405
|
return msg3;
|
|
351639
352406
|
}
|
|
351640
352407
|
const g = m2.updateGroup({ id: args.id, name: args.name ?? "", parentId: args.parentId });
|
|
351641
352408
|
const msg2 = `Updated group "${g.name}".`;
|
|
351642
|
-
|
|
352409
|
+
emit7(context2, "manage_group", args, msg2);
|
|
351643
352410
|
return msg2;
|
|
351644
352411
|
}
|
|
351645
352412
|
if (action === "delete") {
|
|
351646
352413
|
if (!args.id) {
|
|
351647
352414
|
const msg3 = "delete requires id.";
|
|
351648
|
-
|
|
352415
|
+
emit7(context2, "manage_group", args, msg3);
|
|
351649
352416
|
return msg3;
|
|
351650
352417
|
}
|
|
351651
352418
|
const removed = m2.deleteGroup(args.id);
|
|
351652
352419
|
const msg2 = removed ? `Deleted group ${args.id} (children reparented to root).` : `No group ${args.id}.`;
|
|
351653
|
-
|
|
352420
|
+
emit7(context2, "manage_group", args, msg2);
|
|
351654
352421
|
return msg2;
|
|
351655
352422
|
}
|
|
351656
352423
|
const msg = `Unknown action "${action}".`;
|
|
351657
|
-
|
|
352424
|
+
emit7(context2, "manage_group", args, msg);
|
|
351658
352425
|
return msg;
|
|
351659
352426
|
}
|
|
351660
352427
|
var manageScheduledTaskSchema = external_exports.object({
|
|
@@ -351684,7 +352451,7 @@ async function manageScheduledTask(args, context2) {
|
|
|
351684
352451
|
const m2 = context2.automationManager;
|
|
351685
352452
|
if (!m2) {
|
|
351686
352453
|
const msg2 = noStore();
|
|
351687
|
-
|
|
352454
|
+
emit7(context2, "manage_scheduled_task", args, msg2);
|
|
351688
352455
|
return msg2;
|
|
351689
352456
|
}
|
|
351690
352457
|
const { action } = args;
|
|
@@ -351692,30 +352459,30 @@ async function manageScheduledTask(args, context2) {
|
|
|
351692
352459
|
const all = m2.listScheduledTasks();
|
|
351693
352460
|
if (!all.length) {
|
|
351694
352461
|
const msg3 = "No scheduled tasks.";
|
|
351695
|
-
|
|
352462
|
+
emit7(context2, "manage_scheduled_task", args, msg3);
|
|
351696
352463
|
return msg3;
|
|
351697
352464
|
}
|
|
351698
352465
|
const msg2 = `Scheduled tasks (${all.length}):
|
|
351699
352466
|
${all.map((t) => `- ${t.name} (id=${t.id}, cron="${t.cron}", enabled=${t.enabled}${t.lastRunAt ? `, lastRun=${t.lastRunAt}` : ""})`).join("\n")}`;
|
|
351700
|
-
|
|
352467
|
+
emit7(context2, "manage_scheduled_task", args, msg2);
|
|
351701
352468
|
return msg2;
|
|
351702
352469
|
}
|
|
351703
352470
|
if (action === "create") {
|
|
351704
352471
|
if (!args.name || !args.cron) {
|
|
351705
352472
|
const msg3 = "create requires name + cron.";
|
|
351706
|
-
|
|
352473
|
+
emit7(context2, "manage_scheduled_task", args, msg3);
|
|
351707
352474
|
return msg3;
|
|
351708
352475
|
}
|
|
351709
352476
|
if (!args.scriptId && !args.command && !args.playbookId) {
|
|
351710
352477
|
const msg3 = "create requires scriptId, command, or playbookId.";
|
|
351711
|
-
|
|
352478
|
+
emit7(context2, "manage_scheduled_task", args, msg3);
|
|
351712
352479
|
return msg3;
|
|
351713
352480
|
}
|
|
351714
352481
|
const { validateCron: validateCron2 } = await Promise.resolve().then(() => (init_schedulerService(), schedulerService_exports));
|
|
351715
352482
|
const v = validateCron2(args.cron);
|
|
351716
352483
|
if (!v.ok) {
|
|
351717
352484
|
const msg3 = `Invalid cron "${args.cron}": ${v.reason}`;
|
|
351718
|
-
|
|
352485
|
+
emit7(context2, "manage_scheduled_task", args, msg3);
|
|
351719
352486
|
return msg3;
|
|
351720
352487
|
}
|
|
351721
352488
|
const t = m2.createScheduledTask({
|
|
@@ -351739,47 +352506,47 @@ ${all.map((t) => `- ${t.name} (id=${t.id}, cron="${t.cron}", enabled=${t.enabled
|
|
|
351739
352506
|
alertAfterFailures: args.alertAfterFailures
|
|
351740
352507
|
});
|
|
351741
352508
|
const msg2 = `Created scheduled task "${t.name}" (id=${t.id}, cron="${t.cron}"${args.timezone ? ` @ ${args.timezone}` : ""}). It will be evaluated by the local scheduler.`;
|
|
351742
|
-
|
|
352509
|
+
emit7(context2, "manage_scheduled_task", args, msg2);
|
|
351743
352510
|
return msg2;
|
|
351744
352511
|
}
|
|
351745
352512
|
if (action === "update") {
|
|
351746
352513
|
if (!args.id) {
|
|
351747
352514
|
const msg3 = "update requires id.";
|
|
351748
|
-
|
|
352515
|
+
emit7(context2, "manage_scheduled_task", args, msg3);
|
|
351749
352516
|
return msg3;
|
|
351750
352517
|
}
|
|
351751
352518
|
const existing = m2.listScheduledTasks().find((t2) => t2.id === args.id);
|
|
351752
352519
|
if (!existing) {
|
|
351753
352520
|
const msg3 = `No task ${args.id}.`;
|
|
351754
|
-
|
|
352521
|
+
emit7(context2, "manage_scheduled_task", args, msg3);
|
|
351755
352522
|
return msg3;
|
|
351756
352523
|
}
|
|
351757
352524
|
const t = m2.updateScheduledTask({ ...existing, name: args.name ?? existing.name, cron: args.cron ?? existing.cron, scriptId: args.scriptId ?? existing.scriptId, command: args.command ?? existing.command, enabled: args.enabled ?? existing.enabled, groupId: args.groupId, tags: args.tags, targets: args.targets });
|
|
351758
352525
|
const msg2 = `Updated task "${t.name}".`;
|
|
351759
|
-
|
|
352526
|
+
emit7(context2, "manage_scheduled_task", args, msg2);
|
|
351760
352527
|
return msg2;
|
|
351761
352528
|
}
|
|
351762
352529
|
if (action === "delete") {
|
|
351763
352530
|
if (!args.id) {
|
|
351764
352531
|
const msg3 = "delete requires id.";
|
|
351765
|
-
|
|
352532
|
+
emit7(context2, "manage_scheduled_task", args, msg3);
|
|
351766
352533
|
return msg3;
|
|
351767
352534
|
}
|
|
351768
352535
|
const removed = m2.deleteScheduledTask(args.id);
|
|
351769
352536
|
const msg2 = removed ? `Deleted task ${args.id}.` : `No task ${args.id}.`;
|
|
351770
|
-
|
|
352537
|
+
emit7(context2, "manage_scheduled_task", args, msg2);
|
|
351771
352538
|
return msg2;
|
|
351772
352539
|
}
|
|
351773
352540
|
if (action === "validate") {
|
|
351774
352541
|
if (!args.cron) {
|
|
351775
352542
|
const msg3 = "validate requires cron.";
|
|
351776
|
-
|
|
352543
|
+
emit7(context2, "manage_scheduled_task", args, msg3);
|
|
351777
352544
|
return msg3;
|
|
351778
352545
|
}
|
|
351779
352546
|
const { validateCron: validateCron2 } = await Promise.resolve().then(() => (init_schedulerService(), schedulerService_exports));
|
|
351780
352547
|
const v = validateCron2(args.cron);
|
|
351781
352548
|
const msg2 = v.ok ? `Cron "${args.cron}" is valid.` : `Invalid cron "${args.cron}": ${v.reason}`;
|
|
351782
|
-
|
|
352549
|
+
emit7(context2, "manage_scheduled_task", args, msg2);
|
|
351783
352550
|
return msg2;
|
|
351784
352551
|
}
|
|
351785
352552
|
if (action === "drift") {
|
|
@@ -351788,20 +352555,20 @@ ${all.map((t) => `- ${t.name} (id=${t.id}, cron="${t.cron}", enabled=${t.enabled
|
|
|
351788
352555
|
const flagged = drift.filter((d) => d.drifted);
|
|
351789
352556
|
const msg2 = flagged.length === 0 ? `No drift detected across ${drift.length} enabled task(s).` : `Drifted task(s) (${flagged.length}):
|
|
351790
352557
|
${flagged.map((d) => `- ${d.taskName} (id=${d.taskId}): ${Number.isFinite(d.minutesSinceLastRun) ? `${Math.round(d.minutesSinceLastRun)} min since last run` : "never ran"} vs expected \u2264${d.expectedIntervalMinutes} min`).join("\n")}`;
|
|
351791
|
-
|
|
352558
|
+
emit7(context2, "manage_scheduled_task", args, msg2);
|
|
351792
352559
|
return msg2;
|
|
351793
352560
|
}
|
|
351794
352561
|
if (action === "history") {
|
|
351795
352562
|
const sched = context2.scheduledTaskHistory;
|
|
351796
352563
|
if (!sched) {
|
|
351797
352564
|
const msg3 = "Run history is not available in this runtime (headless daemon exposes it via the gateway).";
|
|
351798
|
-
|
|
352565
|
+
emit7(context2, "manage_scheduled_task", args, msg3);
|
|
351799
352566
|
return msg3;
|
|
351800
352567
|
}
|
|
351801
352568
|
const tasks = args.id ? m2.listScheduledTasks().filter((t) => t.id === args.id) : m2.listScheduledTasks();
|
|
351802
352569
|
if (tasks.length === 0) {
|
|
351803
352570
|
const msg3 = args.id ? `No task ${args.id}.` : "No scheduled tasks.";
|
|
351804
|
-
|
|
352571
|
+
emit7(context2, "manage_scheduled_task", args, msg3);
|
|
351805
352572
|
return msg3;
|
|
351806
352573
|
}
|
|
351807
352574
|
const lines = tasks.map((t) => {
|
|
@@ -351814,34 +352581,34 @@ ${flagged.map((d) => `- ${d.taskName} (id=${d.taskId}): ${Number.isFinite(d.minu
|
|
|
351814
352581
|
});
|
|
351815
352582
|
const msg2 = `Scheduled task history:
|
|
351816
352583
|
${lines.join("\n")}`;
|
|
351817
|
-
|
|
352584
|
+
emit7(context2, "manage_scheduled_task", args, msg2);
|
|
351818
352585
|
return msg2;
|
|
351819
352586
|
}
|
|
351820
352587
|
if (action === "runNow") {
|
|
351821
352588
|
if (!args.id) {
|
|
351822
352589
|
const msg3 = "runNow requires id.";
|
|
351823
|
-
|
|
352590
|
+
emit7(context2, "manage_scheduled_task", args, msg3);
|
|
351824
352591
|
return msg3;
|
|
351825
352592
|
}
|
|
351826
352593
|
const task2 = m2.listScheduledTasks().find((t) => t.id === args.id);
|
|
351827
352594
|
if (!task2) {
|
|
351828
352595
|
const msg3 = `No task ${args.id}.`;
|
|
351829
|
-
|
|
352596
|
+
emit7(context2, "manage_scheduled_task", args, msg3);
|
|
351830
352597
|
return msg3;
|
|
351831
352598
|
}
|
|
351832
352599
|
const sched = context2.scheduledTaskRunner;
|
|
351833
352600
|
if (!sched) {
|
|
351834
352601
|
const msg3 = "Run-now is not available in this runtime.";
|
|
351835
|
-
|
|
352602
|
+
emit7(context2, "manage_scheduled_task", args, msg3);
|
|
351836
352603
|
return msg3;
|
|
351837
352604
|
}
|
|
351838
352605
|
const r = await sched(task2);
|
|
351839
352606
|
const msg2 = r.ran ? `Task "${task2.name}" executed now.` : `Task "${task2.name}" not run: ${r.reason}.`;
|
|
351840
|
-
|
|
352607
|
+
emit7(context2, "manage_scheduled_task", args, msg2);
|
|
351841
352608
|
return msg2;
|
|
351842
352609
|
}
|
|
351843
352610
|
const msg = `Unknown action "${action}".`;
|
|
351844
|
-
|
|
352611
|
+
emit7(context2, "manage_scheduled_task", args, msg);
|
|
351845
352612
|
return msg;
|
|
351846
352613
|
}
|
|
351847
352614
|
var manageTemplateSchema = external_exports.object({
|
|
@@ -351857,7 +352624,7 @@ async function manageTemplate(args, context2) {
|
|
|
351857
352624
|
const m2 = context2.automationManager;
|
|
351858
352625
|
if (!m2) {
|
|
351859
352626
|
const msg2 = noStore();
|
|
351860
|
-
|
|
352627
|
+
emit7(context2, "manage_template", args, msg2);
|
|
351861
352628
|
return msg2;
|
|
351862
352629
|
}
|
|
351863
352630
|
const { action } = args;
|
|
@@ -351865,57 +352632,57 @@ async function manageTemplate(args, context2) {
|
|
|
351865
352632
|
const all = m2.listTemplates();
|
|
351866
352633
|
if (!all.length) {
|
|
351867
352634
|
const msg3 = "No templates.";
|
|
351868
|
-
|
|
352635
|
+
emit7(context2, "manage_template", args, msg3);
|
|
351869
352636
|
return msg3;
|
|
351870
352637
|
}
|
|
351871
352638
|
const msg2 = `Templates (${all.length}):
|
|
351872
352639
|
${all.map((t) => `- ${t.name} (id=${t.id}, ${t.versions.length} version(s))`).join("\n")}`;
|
|
351873
|
-
|
|
352640
|
+
emit7(context2, "manage_template", args, msg2);
|
|
351874
352641
|
return msg2;
|
|
351875
352642
|
}
|
|
351876
352643
|
if (action === "create") {
|
|
351877
352644
|
if (!args.name || !args.body) {
|
|
351878
352645
|
const msg3 = "create requires name + body.";
|
|
351879
|
-
|
|
352646
|
+
emit7(context2, "manage_template", args, msg3);
|
|
351880
352647
|
return msg3;
|
|
351881
352648
|
}
|
|
351882
352649
|
const t = m2.createTemplate({ name: args.name, body: args.body, variables: args.variables ?? [] });
|
|
351883
352650
|
const msg2 = `Created template "${t.name}" (id=${t.id}). Use action="render" to preview, action="version" to save a rendered version.`;
|
|
351884
|
-
|
|
352651
|
+
emit7(context2, "manage_template", args, msg2);
|
|
351885
352652
|
return msg2;
|
|
351886
352653
|
}
|
|
351887
352654
|
if (action === "update") {
|
|
351888
352655
|
if (!args.id) {
|
|
351889
352656
|
const msg3 = "update requires id.";
|
|
351890
|
-
|
|
352657
|
+
emit7(context2, "manage_template", args, msg3);
|
|
351891
352658
|
return msg3;
|
|
351892
352659
|
}
|
|
351893
352660
|
const t = m2.updateTemplate({ id: args.id, name: args.name, body: args.body, variables: args.variables });
|
|
351894
352661
|
const msg2 = `Updated template "${t.name}".`;
|
|
351895
|
-
|
|
352662
|
+
emit7(context2, "manage_template", args, msg2);
|
|
351896
352663
|
return msg2;
|
|
351897
352664
|
}
|
|
351898
352665
|
if (action === "delete") {
|
|
351899
352666
|
if (!args.id) {
|
|
351900
352667
|
const msg3 = "delete requires id.";
|
|
351901
|
-
|
|
352668
|
+
emit7(context2, "manage_template", args, msg3);
|
|
351902
352669
|
return msg3;
|
|
351903
352670
|
}
|
|
351904
352671
|
const removed = m2.deleteTemplate(args.id);
|
|
351905
352672
|
const msg2 = removed ? `Deleted template ${args.id}.` : `No template ${args.id}.`;
|
|
351906
|
-
|
|
352673
|
+
emit7(context2, "manage_template", args, msg2);
|
|
351907
352674
|
return msg2;
|
|
351908
352675
|
}
|
|
351909
352676
|
if (action === "render") {
|
|
351910
352677
|
if (!args.id) {
|
|
351911
352678
|
const msg3 = "render requires id.";
|
|
351912
|
-
|
|
352679
|
+
emit7(context2, "manage_template", args, msg3);
|
|
351913
352680
|
return msg3;
|
|
351914
352681
|
}
|
|
351915
352682
|
const t = m2.listTemplates().find((x) => x.id === args.id);
|
|
351916
352683
|
if (!t) {
|
|
351917
352684
|
const msg3 = `No template ${args.id}.`;
|
|
351918
|
-
|
|
352685
|
+
emit7(context2, "manage_template", args, msg3);
|
|
351919
352686
|
return msg3;
|
|
351920
352687
|
}
|
|
351921
352688
|
const defaults2 = {};
|
|
@@ -351926,19 +352693,19 @@ ${all.map((t) => `- ${t.name} (id=${t.id}, ${t.versions.length} version(s))`).jo
|
|
|
351926
352693
|
<rendered>
|
|
351927
352694
|
${rendered}
|
|
351928
352695
|
</rendered>`;
|
|
351929
|
-
|
|
352696
|
+
emit7(context2, "manage_template", args, msg2);
|
|
351930
352697
|
return msg2;
|
|
351931
352698
|
}
|
|
351932
352699
|
if (action === "version") {
|
|
351933
352700
|
if (!args.id) {
|
|
351934
352701
|
const msg3 = "version requires id.";
|
|
351935
|
-
|
|
352702
|
+
emit7(context2, "manage_template", args, msg3);
|
|
351936
352703
|
return msg3;
|
|
351937
352704
|
}
|
|
351938
352705
|
const t = m2.listTemplates().find((x) => x.id === args.id);
|
|
351939
352706
|
if (!t) {
|
|
351940
352707
|
const msg3 = `No template ${args.id}.`;
|
|
351941
|
-
|
|
352708
|
+
emit7(context2, "manage_template", args, msg3);
|
|
351942
352709
|
return msg3;
|
|
351943
352710
|
}
|
|
351944
352711
|
const defaults2 = {};
|
|
@@ -351952,11 +352719,11 @@ ${rendered}
|
|
|
351952
352719
|
Diff vs previous version:
|
|
351953
352720
|
${diffStrings(prev.rendered, rendered)}` : "\n\n(first version)";
|
|
351954
352721
|
const msg2 = `Saved version ${t.versions.length + 1} of "${t.name}" at ${v.at}.${diff}`;
|
|
351955
|
-
|
|
352722
|
+
emit7(context2, "manage_template", args, msg2);
|
|
351956
352723
|
return msg2;
|
|
351957
352724
|
}
|
|
351958
352725
|
const msg = `Unknown action "${action}".`;
|
|
351959
|
-
|
|
352726
|
+
emit7(context2, "manage_template", args, msg);
|
|
351960
352727
|
return msg;
|
|
351961
352728
|
}
|
|
351962
352729
|
var importPuttySchema = external_exports.object({
|
|
@@ -351966,13 +352733,13 @@ async function importPutty(args, context2) {
|
|
|
351966
352733
|
const cm = context2.connectionManager;
|
|
351967
352734
|
if (!cm) {
|
|
351968
352735
|
const msg2 = "Connection management is not available in this runtime.";
|
|
351969
|
-
|
|
352736
|
+
emit7(context2, "import_putty", args, msg2);
|
|
351970
352737
|
return msg2;
|
|
351971
352738
|
}
|
|
351972
352739
|
const entries = importPuttyReg(args.regContent);
|
|
351973
352740
|
if (!entries.length) {
|
|
351974
352741
|
const msg2 = "No SSH sessions found in the provided PuTTY export (only ssh-protocol sessions with a HostName are imported).";
|
|
351975
|
-
|
|
352742
|
+
emit7(context2, "import_putty", args, msg2);
|
|
351976
352743
|
return msg2;
|
|
351977
352744
|
}
|
|
351978
352745
|
let created = 0;
|
|
@@ -351983,7 +352750,7 @@ async function importPutty(args, context2) {
|
|
|
351983
352750
|
created++;
|
|
351984
352751
|
}
|
|
351985
352752
|
const msg = `Imported ${created} SSH connection(s) from PuTTY${entries.length !== created ? ` (${entries.length - created} skipped as duplicates or non-ssh)` : ""}. Imported: ${entries.map((e) => e.name).join(", ")}. Open them with open_terminal_tab by Name.`;
|
|
351986
|
-
|
|
352753
|
+
emit7(context2, "import_putty", args, msg);
|
|
351987
352754
|
return msg;
|
|
351988
352755
|
}
|
|
351989
352756
|
|
|
@@ -351994,7 +352761,7 @@ init_playbook_tools();
|
|
|
351994
352761
|
init_zod();
|
|
351995
352762
|
init_playbookRunner();
|
|
351996
352763
|
init_scheduledTaskRunner();
|
|
351997
|
-
function
|
|
352764
|
+
function emit9(context2, toolName, input, output) {
|
|
351998
352765
|
context2.sendEvent(context2.sessionId, {
|
|
351999
352766
|
messageId: context2.messageId,
|
|
352000
352767
|
type: "tool_call",
|
|
@@ -352034,12 +352801,12 @@ async function manageChange(args, context2) {
|
|
|
352034
352801
|
const ledger = context2.changeLedger;
|
|
352035
352802
|
if (!m2) {
|
|
352036
352803
|
const msg2 = "Automation store is not available in this runtime.";
|
|
352037
|
-
|
|
352804
|
+
emit9(context2, "manage_change", args, msg2);
|
|
352038
352805
|
return msg2;
|
|
352039
352806
|
}
|
|
352040
352807
|
if (!ledger) {
|
|
352041
352808
|
const msg2 = "Change ledger is not available in this runtime.";
|
|
352042
|
-
|
|
352809
|
+
emit9(context2, "manage_change", args, msg2);
|
|
352043
352810
|
return msg2;
|
|
352044
352811
|
}
|
|
352045
352812
|
const { action } = args;
|
|
@@ -352047,13 +352814,13 @@ async function manageChange(args, context2) {
|
|
|
352047
352814
|
const key = args.playbookId ?? args.name;
|
|
352048
352815
|
if (!key) {
|
|
352049
352816
|
const msg3 = "plan requires playbookId or name.";
|
|
352050
|
-
|
|
352817
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352051
352818
|
return msg3;
|
|
352052
352819
|
}
|
|
352053
352820
|
const playbook = m2.getPlaybook(key);
|
|
352054
352821
|
if (!playbook) {
|
|
352055
352822
|
const msg3 = `No playbook "${key}".`;
|
|
352056
|
-
|
|
352823
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352057
352824
|
return msg3;
|
|
352058
352825
|
}
|
|
352059
352826
|
const settings = settingsFromContext(context2);
|
|
@@ -352073,58 +352840,58 @@ Targets (${targets.length || 1}): ${targets.length ? targets.map((t) => t.name).
|
|
|
352073
352840
|
Steps:
|
|
352074
352841
|
${steps}
|
|
352075
352842
|
Next: manage_change action=approve changeId=${changeId}, then action=run.`;
|
|
352076
|
-
|
|
352843
|
+
emit9(context2, "manage_change", args, msg2);
|
|
352077
352844
|
return msg2;
|
|
352078
352845
|
}
|
|
352079
352846
|
if (action === "approve") {
|
|
352080
352847
|
if (!args.changeId) {
|
|
352081
352848
|
const msg3 = "approve requires changeId.";
|
|
352082
|
-
|
|
352849
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352083
352850
|
return msg3;
|
|
352084
352851
|
}
|
|
352085
352852
|
const existing = ledger.getChange(args.changeId);
|
|
352086
352853
|
if (!existing) {
|
|
352087
352854
|
const msg3 = `No change "${args.changeId}".`;
|
|
352088
|
-
|
|
352855
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352089
352856
|
return msg3;
|
|
352090
352857
|
}
|
|
352091
352858
|
if (existing.change.status !== "planned") {
|
|
352092
352859
|
const msg3 = `Change ${args.changeId} is ${existing.change.status} \u2014 only planned changes can be approved.`;
|
|
352093
|
-
|
|
352860
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352094
352861
|
return msg3;
|
|
352095
352862
|
}
|
|
352096
352863
|
ledger.approveChange(args.changeId, args.approvedBy);
|
|
352097
352864
|
const msg2 = `Change ${args.changeId} approved${args.approvedBy ? ` by ${args.approvedBy}` : ""}. Execute with manage_change action=run changeId=${args.changeId}.`;
|
|
352098
|
-
|
|
352865
|
+
emit9(context2, "manage_change", args, msg2);
|
|
352099
352866
|
return msg2;
|
|
352100
352867
|
}
|
|
352101
352868
|
if (action === "run") {
|
|
352102
352869
|
if (!args.changeId) {
|
|
352103
352870
|
const msg3 = "run requires changeId.";
|
|
352104
|
-
|
|
352871
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352105
352872
|
return msg3;
|
|
352106
352873
|
}
|
|
352107
352874
|
const existing = ledger.getChange(args.changeId);
|
|
352108
352875
|
if (!existing) {
|
|
352109
352876
|
const msg3 = `No change "${args.changeId}". Plan one first with manage_change action=plan.`;
|
|
352110
|
-
|
|
352877
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352111
352878
|
return msg3;
|
|
352112
352879
|
}
|
|
352113
352880
|
if (existing.change.status !== "approved") {
|
|
352114
352881
|
const msg3 = `Change ${args.changeId} is ${existing.change.status} \u2014 it must be approved before execution (manage_change action=approve).`;
|
|
352115
|
-
|
|
352882
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352116
352883
|
return msg3;
|
|
352117
352884
|
}
|
|
352118
352885
|
const playbook = m2.getPlaybook(existing.change.playbookId);
|
|
352119
352886
|
if (!playbook) {
|
|
352120
352887
|
ledger.finishChange(args.changeId, "failed", "playbook no longer exists");
|
|
352121
352888
|
const msg3 = `Playbook ${existing.change.playbookId} no longer exists; change marked failed.`;
|
|
352122
|
-
|
|
352889
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352123
352890
|
return msg3;
|
|
352124
352891
|
}
|
|
352125
352892
|
if (!ledger.markExecuting(args.changeId)) {
|
|
352126
352893
|
const msg3 = `Change ${args.changeId} could not transition to executing (status=${existing.change.status}).`;
|
|
352127
|
-
|
|
352894
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352128
352895
|
return msg3;
|
|
352129
352896
|
}
|
|
352130
352897
|
const settings = settingsFromContext(context2);
|
|
@@ -352146,7 +352913,7 @@ Next: manage_change action=approve changeId=${changeId}, then action=run.`;
|
|
|
352146
352913
|
const errMsg = error40 instanceof Error ? error40.message : String(error40);
|
|
352147
352914
|
ledger.finishChange(args.changeId, "failed", errMsg);
|
|
352148
352915
|
const msg3 = `Change ${args.changeId} failed to execute: ${errMsg}`;
|
|
352149
|
-
|
|
352916
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352150
352917
|
return msg3;
|
|
352151
352918
|
}
|
|
352152
352919
|
const finalStatus = deriveFinalStatus(record2);
|
|
@@ -352164,19 +352931,19 @@ Next: manage_change action=approve changeId=${changeId}, then action=run.`;
|
|
|
352164
352931
|
}
|
|
352165
352932
|
const msg2 = `Change ${args.changeId} finished with status=${finalStatus} (runId=${record2.runId}).
|
|
352166
352933
|
${lines.join("\n")}`;
|
|
352167
|
-
|
|
352934
|
+
emit9(context2, "manage_change", args, msg2);
|
|
352168
352935
|
return msg2;
|
|
352169
352936
|
}
|
|
352170
352937
|
if (action === "status") {
|
|
352171
352938
|
if (!args.changeId) {
|
|
352172
352939
|
const msg3 = "status requires changeId.";
|
|
352173
|
-
|
|
352940
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352174
352941
|
return msg3;
|
|
352175
352942
|
}
|
|
352176
352943
|
const got = ledger.getChange(args.changeId);
|
|
352177
352944
|
if (!got) {
|
|
352178
352945
|
const msg3 = `No change "${args.changeId}".`;
|
|
352179
|
-
|
|
352946
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352180
352947
|
return msg3;
|
|
352181
352948
|
}
|
|
352182
352949
|
const { change, steps } = got;
|
|
@@ -352195,14 +352962,14 @@ ${meta}
|
|
|
352195
352962
|
Targets: ${change.targetsSnapshot ?? "n/a"}
|
|
352196
352963
|
Events:
|
|
352197
352964
|
${body}`;
|
|
352198
|
-
|
|
352965
|
+
emit9(context2, "manage_change", args, msg2);
|
|
352199
352966
|
return msg2;
|
|
352200
352967
|
}
|
|
352201
352968
|
if (action === "list") {
|
|
352202
352969
|
const rows = ledger.listChanges({ status: args.status, limit: args.limit ?? 20 });
|
|
352203
352970
|
if (!rows.length) {
|
|
352204
352971
|
const msg3 = "No changes recorded yet. Plan one with manage_change action=plan.";
|
|
352205
|
-
|
|
352972
|
+
emit9(context2, "manage_change", args, msg3);
|
|
352206
352973
|
return msg3;
|
|
352207
352974
|
}
|
|
352208
352975
|
const body = rows.map(
|
|
@@ -352210,18 +352977,18 @@ ${body}`;
|
|
|
352210
352977
|
).join("\n");
|
|
352211
352978
|
const msg2 = `Changes (${rows.length}):
|
|
352212
352979
|
${body}`;
|
|
352213
|
-
|
|
352980
|
+
emit9(context2, "manage_change", args, msg2);
|
|
352214
352981
|
return msg2;
|
|
352215
352982
|
}
|
|
352216
352983
|
const msg = `Unknown action "${action}".`;
|
|
352217
|
-
|
|
352984
|
+
emit9(context2, "manage_change", args, msg);
|
|
352218
352985
|
return msg;
|
|
352219
352986
|
}
|
|
352220
352987
|
|
|
352221
352988
|
// ../../packages/backend/src/services/AgentHelper/tools/trigger_tools.ts
|
|
352222
352989
|
init_zod();
|
|
352223
352990
|
var import_crypto6 = require("crypto");
|
|
352224
|
-
function
|
|
352991
|
+
function emit10(context2, name, input, output) {
|
|
352225
352992
|
context2.sendEvent(context2.sessionId, {
|
|
352226
352993
|
messageId: context2.messageId,
|
|
352227
352994
|
type: "tool_call",
|
|
@@ -352250,7 +353017,7 @@ async function manageTrigger(args, context2) {
|
|
|
352250
353017
|
const m2 = context2.automationManager;
|
|
352251
353018
|
if (!m2 || typeof m2.listTriggers !== "function") {
|
|
352252
353019
|
const msg2 = "Automation store with trigger support is not available in this runtime.";
|
|
352253
|
-
|
|
353020
|
+
emit10(context2, "manage_trigger", args, msg2);
|
|
352254
353021
|
return msg2;
|
|
352255
353022
|
}
|
|
352256
353023
|
const engine = context2.triggerEngine;
|
|
@@ -352259,7 +353026,7 @@ async function manageTrigger(args, context2) {
|
|
|
352259
353026
|
const all = m2.listTriggers();
|
|
352260
353027
|
if (!all.length) {
|
|
352261
353028
|
const msg3 = "No triggers configured.";
|
|
352262
|
-
|
|
353029
|
+
emit10(context2, "manage_trigger", args, msg3);
|
|
352263
353030
|
return msg3;
|
|
352264
353031
|
}
|
|
352265
353032
|
const body = all.map((t) => {
|
|
@@ -352268,14 +353035,14 @@ async function manageTrigger(args, context2) {
|
|
|
352268
353035
|
}).join("\n");
|
|
352269
353036
|
const msg2 = `Triggers (${all.length}):
|
|
352270
353037
|
${body}`;
|
|
352271
|
-
|
|
353038
|
+
emit10(context2, "manage_trigger", args, msg2);
|
|
352272
353039
|
return msg2;
|
|
352273
353040
|
}
|
|
352274
353041
|
if (action === "fires") {
|
|
352275
353042
|
const fires = engine?.listFires?.() ?? [];
|
|
352276
353043
|
if (!fires.length) {
|
|
352277
353044
|
const msg3 = "No trigger firings recorded yet.";
|
|
352278
|
-
|
|
353045
|
+
emit10(context2, "manage_trigger", args, msg3);
|
|
352279
353046
|
return msg3;
|
|
352280
353047
|
}
|
|
352281
353048
|
const limit2 = args.limit ?? 20;
|
|
@@ -352284,23 +353051,23 @@ ${body}`;
|
|
|
352284
353051
|
).join("\n");
|
|
352285
353052
|
const msg2 = `Recent trigger firings (${Math.min(limit2, fires.length)} of ${fires.length}):
|
|
352286
353053
|
${body}`;
|
|
352287
|
-
|
|
353054
|
+
emit10(context2, "manage_trigger", args, msg2);
|
|
352288
353055
|
return msg2;
|
|
352289
353056
|
}
|
|
352290
353057
|
if (action === "create") {
|
|
352291
353058
|
if (!args.name) {
|
|
352292
353059
|
const msg3 = "create requires a name.";
|
|
352293
|
-
|
|
353060
|
+
emit10(context2, "manage_trigger", args, msg3);
|
|
352294
353061
|
return msg3;
|
|
352295
353062
|
}
|
|
352296
353063
|
if (!args.kind) {
|
|
352297
353064
|
const msg3 = "create requires a kind (pattern|threshold|webhook|schedule).";
|
|
352298
|
-
|
|
353065
|
+
emit10(context2, "manage_trigger", args, msg3);
|
|
352299
353066
|
return msg3;
|
|
352300
353067
|
}
|
|
352301
353068
|
if (!args.playbookId) {
|
|
352302
353069
|
const msg3 = "create requires playbookId.";
|
|
352303
|
-
|
|
353070
|
+
emit10(context2, "manage_trigger", args, msg3);
|
|
352304
353071
|
return msg3;
|
|
352305
353072
|
}
|
|
352306
353073
|
const entry = {
|
|
@@ -352326,20 +353093,20 @@ ${body}`;
|
|
|
352326
353093
|
} catch {
|
|
352327
353094
|
}
|
|
352328
353095
|
const msg2 = `Created trigger "${entry.name}" (${entry.id}) [${entry.kind}] \u2192 ${entry.action} ${entry.playbookId}.`;
|
|
352329
|
-
|
|
353096
|
+
emit10(context2, "manage_trigger", args, msg2);
|
|
352330
353097
|
return msg2;
|
|
352331
353098
|
}
|
|
352332
353099
|
if (action === "update") {
|
|
352333
353100
|
const key = args.id ?? args.name;
|
|
352334
353101
|
if (!key) {
|
|
352335
353102
|
const msg3 = "update requires id or name.";
|
|
352336
|
-
|
|
353103
|
+
emit10(context2, "manage_trigger", args, msg3);
|
|
352337
353104
|
return msg3;
|
|
352338
353105
|
}
|
|
352339
353106
|
const existing = m2.listTriggers().find((t) => t.id === key || t.name.trim().toLowerCase() === key.trim().toLowerCase());
|
|
352340
353107
|
if (!existing) {
|
|
352341
353108
|
const msg3 = `No trigger "${key}".`;
|
|
352342
|
-
|
|
353109
|
+
emit10(context2, "manage_trigger", args, msg3);
|
|
352343
353110
|
return msg3;
|
|
352344
353111
|
}
|
|
352345
353112
|
const merged = {
|
|
@@ -352362,14 +353129,14 @@ ${body}`;
|
|
|
352362
353129
|
} catch {
|
|
352363
353130
|
}
|
|
352364
353131
|
const msg2 = `Updated trigger "${merged.name}" (${merged.id}).`;
|
|
352365
|
-
|
|
353132
|
+
emit10(context2, "manage_trigger", args, msg2);
|
|
352366
353133
|
return msg2;
|
|
352367
353134
|
}
|
|
352368
353135
|
if (action === "delete") {
|
|
352369
353136
|
const key = args.id ?? args.name;
|
|
352370
353137
|
if (!key) {
|
|
352371
353138
|
const msg3 = "delete requires id or name.";
|
|
352372
|
-
|
|
353139
|
+
emit10(context2, "manage_trigger", args, msg3);
|
|
352373
353140
|
return msg3;
|
|
352374
353141
|
}
|
|
352375
353142
|
const ok = m2.deleteTrigger(key);
|
|
@@ -352380,14 +353147,14 @@ ${body}`;
|
|
|
352380
353147
|
}
|
|
352381
353148
|
}
|
|
352382
353149
|
const msg2 = ok ? `Deleted trigger "${key}".` : `No trigger "${key}".`;
|
|
352383
|
-
|
|
353150
|
+
emit10(context2, "manage_trigger", args, msg2);
|
|
352384
353151
|
return msg2;
|
|
352385
353152
|
}
|
|
352386
353153
|
if (action === "enable" || action === "disable") {
|
|
352387
353154
|
const key = args.id ?? args.name;
|
|
352388
353155
|
if (!key) {
|
|
352389
353156
|
const msg3 = `${action} requires id or name.`;
|
|
352390
|
-
|
|
353157
|
+
emit10(context2, "manage_trigger", args, msg3);
|
|
352391
353158
|
return msg3;
|
|
352392
353159
|
}
|
|
352393
353160
|
const ok = m2.setTriggerEnabled(key, action === "enable");
|
|
@@ -352399,11 +353166,11 @@ ${body}`;
|
|
|
352399
353166
|
}
|
|
352400
353167
|
}
|
|
352401
353168
|
const msg2 = ok ? `Trigger "${key}" ${action}d.` : `No trigger "${key}".`;
|
|
352402
|
-
|
|
353169
|
+
emit10(context2, "manage_trigger", args, msg2);
|
|
352403
353170
|
return msg2;
|
|
352404
353171
|
}
|
|
352405
353172
|
const msg = `Unknown action "${action}".`;
|
|
352406
|
-
|
|
353173
|
+
emit10(context2, "manage_trigger", args, msg);
|
|
352407
353174
|
return msg;
|
|
352408
353175
|
}
|
|
352409
353176
|
|
|
@@ -352761,10 +353528,10 @@ async function listGatewayMethods(args, context2) {
|
|
|
352761
353528
|
const lines = methods.map((mm) => `- ${mm.name} [${mm.category}] ${mm.description}${mm.params ? " (params: " + Object.entries(mm.params).map(([k, v]) => `${k}${v.optional ? "?" : ""}:${v.type}`).join(", ") + ")" : ""}`);
|
|
352762
353529
|
const out = `Gateway methods (${methods.length} of ${payload.count}, registry v${payload.version}):
|
|
352763
353530
|
${lines.join("\n")}`;
|
|
352764
|
-
|
|
353531
|
+
emit11(context2, "list_gateway_methods", args, out);
|
|
352765
353532
|
return out;
|
|
352766
353533
|
}
|
|
352767
|
-
function
|
|
353534
|
+
function emit11(context2, toolName, input, output) {
|
|
352768
353535
|
context2.sendEvent(context2.sessionId, {
|
|
352769
353536
|
messageId: context2.messageId,
|
|
352770
353537
|
type: "tool_call",
|
|
@@ -352777,7 +353544,7 @@ function obs(context2, toolName, args) {
|
|
|
352777
353544
|
const o = context2.observability;
|
|
352778
353545
|
if (!o) {
|
|
352779
353546
|
const msg = `${toolName} is not available in this runtime (observability not wired).`;
|
|
352780
|
-
|
|
353547
|
+
emit11(context2, toolName, args, msg);
|
|
352781
353548
|
return { o: null, msg };
|
|
352782
353549
|
}
|
|
352783
353550
|
return { o, msg: null };
|
|
@@ -352789,7 +353556,7 @@ async function getMetrics(args, context2) {
|
|
|
352789
353556
|
const { o, msg } = obs(context2, "get_metrics", args);
|
|
352790
353557
|
if (!o) return msg;
|
|
352791
353558
|
const out = args.format === "prometheus" ? o.metricsExport.renderPrometheus() || "# no host metrics recorded yet" : await o.dashboard.summary();
|
|
352792
|
-
|
|
353559
|
+
emit11(context2, "get_metrics", args, out);
|
|
352793
353560
|
return out;
|
|
352794
353561
|
}
|
|
352795
353562
|
var manageSecretSchema = external_exports.object({
|
|
@@ -352804,7 +353571,7 @@ async function manageSecret(args, context2) {
|
|
|
352804
353571
|
const v = o.secrets;
|
|
352805
353572
|
if (!v.unlocked()) {
|
|
352806
353573
|
const m2 = "Secrets vault is locked \u2014 start RTerm with RTERM_SECRETS_MASTER_KEY set.";
|
|
352807
|
-
|
|
353574
|
+
emit11(context2, "manage_secret", args, m2);
|
|
352808
353575
|
return m2;
|
|
352809
353576
|
}
|
|
352810
353577
|
let out;
|
|
@@ -352831,7 +353598,7 @@ async function manageSecret(args, context2) {
|
|
|
352831
353598
|
out = v.has(args.key) ? `'${args.key}' exists.` : `'${args.key}' does not exist.`;
|
|
352832
353599
|
}
|
|
352833
353600
|
}
|
|
352834
|
-
|
|
353601
|
+
emit11(context2, "manage_secret", args, out);
|
|
352835
353602
|
return out;
|
|
352836
353603
|
}
|
|
352837
353604
|
var manageOncallSchema = external_exports.object({
|
|
@@ -352883,7 +353650,7 @@ async function manageOncall(args, context2) {
|
|
|
352883
353650
|
} catch (e) {
|
|
352884
353651
|
out = `on-call error: ${e instanceof Error ? e.message : String(e)}`;
|
|
352885
353652
|
}
|
|
352886
|
-
|
|
353653
|
+
emit11(context2, "manage_oncall", args, out);
|
|
352887
353654
|
return out;
|
|
352888
353655
|
}
|
|
352889
353656
|
var getCostSchema = external_exports.object({
|
|
@@ -352907,7 +353674,7 @@ async function getCost(args, context2) {
|
|
|
352907
353674
|
const b = o.cost.listBudgets();
|
|
352908
353675
|
out = b.length ? b.map((x) => `- ${x.id}: ${x.model ?? "*"}/${x.profileId ?? "*"} ${x.period} cap $${x.capUsd}`).join("\n") : "No budgets configured.";
|
|
352909
353676
|
}
|
|
352910
|
-
|
|
353677
|
+
emit11(context2, "get_cost", args, out);
|
|
352911
353678
|
return out;
|
|
352912
353679
|
}
|
|
352913
353680
|
var manageRecordingSchema = external_exports.object({
|
|
@@ -352973,7 +353740,7 @@ async function manageRecording(args, context2) {
|
|
|
352973
353740
|
} catch (e) {
|
|
352974
353741
|
out = `recording error: ${e instanceof Error ? e.message : String(e)}`;
|
|
352975
353742
|
}
|
|
352976
|
-
|
|
353743
|
+
emit11(context2, "manage_recording", args, out);
|
|
352977
353744
|
return out;
|
|
352978
353745
|
}
|
|
352979
353746
|
var manageGitopsSchema = external_exports.object({
|
|
@@ -353005,7 +353772,7 @@ async function manageGitops(args, context2) {
|
|
|
353005
353772
|
} catch (e) {
|
|
353006
353773
|
out = `gitops error: ${e instanceof Error ? e.message : String(e)}`;
|
|
353007
353774
|
}
|
|
353008
|
-
|
|
353775
|
+
emit11(context2, "manage_gitops", args, out);
|
|
353009
353776
|
return out;
|
|
353010
353777
|
}
|
|
353011
353778
|
var managePlaybookVersionSchema = external_exports.object({
|
|
@@ -353052,7 +353819,7 @@ async function managePlaybookVersion(args, context2) {
|
|
|
353052
353819
|
} catch (e) {
|
|
353053
353820
|
out = `playbook error: ${e instanceof Error ? e.message : String(e)}`;
|
|
353054
353821
|
}
|
|
353055
|
-
|
|
353822
|
+
emit11(context2, "manage_playbook_version", args, out);
|
|
353056
353823
|
return out;
|
|
353057
353824
|
}
|
|
353058
353825
|
var getCloudInventorySchema = external_exports.object({
|
|
@@ -353079,7 +353846,7 @@ async function getCloudInventory(args, context2) {
|
|
|
353079
353846
|
} catch (e) {
|
|
353080
353847
|
out = `cloud error: ${e instanceof Error ? e.message : String(e)}`;
|
|
353081
353848
|
}
|
|
353082
|
-
|
|
353849
|
+
emit11(context2, "get_cloud_inventory", args, out);
|
|
353083
353850
|
return out;
|
|
353084
353851
|
}
|
|
353085
353852
|
var getMonitorStatusSchema = external_exports.object({
|
|
@@ -353094,7 +353861,7 @@ async function getMonitorStatus(args, context2) {
|
|
|
353094
353861
|
} else {
|
|
353095
353862
|
out = o.monitorStatus.summary();
|
|
353096
353863
|
}
|
|
353097
|
-
|
|
353864
|
+
emit11(context2, "get_monitor_status", args, out);
|
|
353098
353865
|
return out;
|
|
353099
353866
|
}
|
|
353100
353867
|
var getLiveDashboardSchema = external_exports.object({
|
|
@@ -353110,7 +353877,7 @@ async function getLiveDashboard(args, context2) {
|
|
|
353110
353877
|
const s = await o.dashboard.summary();
|
|
353111
353878
|
out = s;
|
|
353112
353879
|
}
|
|
353113
|
-
|
|
353880
|
+
emit11(context2, "get_live_dashboard", args, out);
|
|
353114
353881
|
return out;
|
|
353115
353882
|
}
|
|
353116
353883
|
var ingestApmSpansSchema = external_exports.object({
|
|
@@ -353123,7 +353890,7 @@ async function ingestApmSpans(args, context2) {
|
|
|
353123
353890
|
const { ingestOtlp: ingestOtlp2 } = await Promise.resolve().then(() => (init_spanLedger(), spanLedger_exports));
|
|
353124
353891
|
const n2 = ingestOtlp2(o.spanLedger, args.payload, args.defaultService);
|
|
353125
353892
|
const out = `Ingested ${n2} APM span(s) into the trace store.`;
|
|
353126
|
-
|
|
353893
|
+
emit11(context2, "ingest_apm_spans", args, out);
|
|
353127
353894
|
return out;
|
|
353128
353895
|
}
|
|
353129
353896
|
var getApmSummarySchema = external_exports.object({});
|
|
@@ -353132,7 +353899,7 @@ async function getApmSummary(_args, context2) {
|
|
|
353132
353899
|
if (!o) return msg;
|
|
353133
353900
|
const stats = o.spanLedger.serviceStats();
|
|
353134
353901
|
const out = stats.length ? `APM: ${o.spanLedger.size()} spans across ${stats.length} service(s). ` + stats.map((x) => `${x.service}(${x.spans}${x.errors ? ", " + x.errors + " err" : ""})`).join(", ") : "APM: no spans ingested yet.";
|
|
353135
|
-
|
|
353902
|
+
emit11(context2, "get_apm_summary", _args, out);
|
|
353136
353903
|
return out;
|
|
353137
353904
|
}
|
|
353138
353905
|
var ingestDemBeaconSchema = external_exports.object({
|
|
@@ -353143,7 +353910,7 @@ async function ingestDemBeacon(args, context2) {
|
|
|
353143
353910
|
if (!o) return msg;
|
|
353144
353911
|
const s = o.rumLedger.ingestBeacon(args.payload);
|
|
353145
353912
|
const out = s ? `Ingested RUM beacon for ${s.page}${s.lcpMs ? ` (LCP ${s.lcpMs}ms)` : ""}.` : "Beacon ignored \u2014 needs a `page` field.";
|
|
353146
|
-
|
|
353913
|
+
emit11(context2, "ingest_dem_beacon", args, out);
|
|
353147
353914
|
return out;
|
|
353148
353915
|
}
|
|
353149
353916
|
var getDemSummarySchema = external_exports.object({});
|
|
@@ -353152,7 +353919,7 @@ async function getDemSummary(_args, context2) {
|
|
|
353152
353919
|
if (!o) return msg;
|
|
353153
353920
|
const pages = o.rumLedger.pageStats();
|
|
353154
353921
|
const out = pages.length ? `DEM: ${o.rumLedger.size()} sessions across ${pages.length} page(s). ` + pages.map((p) => `${p.page}(${p.sessions}${p.errorRate ? `, ${(p.errorRate * 100).toFixed(0)}% err` : ""})`).join(", ") : "DEM: no RUM sessions ingested yet.";
|
|
353155
|
-
|
|
353922
|
+
emit11(context2, "get_dem_summary", _args, out);
|
|
353156
353923
|
return out;
|
|
353157
353924
|
}
|
|
353158
353925
|
var collectInfraSchema = external_exports.object({
|
|
@@ -353197,7 +353964,7 @@ async function collectInfra(args, context2) {
|
|
|
353197
353964
|
} catch (e) {
|
|
353198
353965
|
out = `infra collect failed (kubectl or cluster unavailable): ${e instanceof Error ? e.message : String(e)}`;
|
|
353199
353966
|
}
|
|
353200
|
-
|
|
353967
|
+
emit11(context2, "collect_infra", args, out);
|
|
353201
353968
|
return out;
|
|
353202
353969
|
}
|
|
353203
353970
|
var manageEtwSchema = external_exports.object({
|
|
@@ -353256,7 +354023,7 @@ ${buildStopCommands2(s).join("\n")}`;
|
|
|
353256
354023
|
} catch (e) {
|
|
353257
354024
|
out = `etw error: ${e instanceof Error ? e.message : String(e)}`;
|
|
353258
354025
|
}
|
|
353259
|
-
|
|
354026
|
+
emit11(context2, "manage_etw", args, out);
|
|
353260
354027
|
return out;
|
|
353261
354028
|
}
|
|
353262
354029
|
|
|
@@ -353649,6 +354416,46 @@ function buildToolsForModel(readFileSupport) {
|
|
|
353649
354416
|
name: "manage_etw",
|
|
353650
354417
|
description: "Windows ETW diagnostics \u2014 start/stop a trace (logman), parse captured Get-WinEvent/Get-Counter output, list sessions. Use against a Windows host for network/file/registry/process/DNS diagnostics.",
|
|
353651
354418
|
schema: manageEtwSchema
|
|
354419
|
+
},
|
|
354420
|
+
{
|
|
354421
|
+
name: "manage_incident",
|
|
354422
|
+
description: "Incident bundles \u2014 pack chat + terminals + recording + run id into one INC-* you can reopen (open/get/list/close).",
|
|
354423
|
+
schema: manageIncidentSchema
|
|
354424
|
+
},
|
|
354425
|
+
{
|
|
354426
|
+
name: "manage_collab",
|
|
354427
|
+
description: 'Two-operator session presence: join, takeConn ("I have the conn"), whoHasConn, list.',
|
|
354428
|
+
schema: manageCollabSchema
|
|
354429
|
+
},
|
|
354430
|
+
{
|
|
354431
|
+
name: "manage_jump_path",
|
|
354432
|
+
description: "Named multi-hop jump paths with time-boxed break-glass (define/list/breakGlass/allowed).",
|
|
354433
|
+
schema: manageJumpPathSchema
|
|
354434
|
+
},
|
|
354435
|
+
{
|
|
354436
|
+
name: "manage_approval",
|
|
354437
|
+
description: "Queued HITL approvals with TTL auto-deny and optional two-person approve (request/list/get/decide/sweep).",
|
|
354438
|
+
schema: manageApprovalSchema
|
|
354439
|
+
},
|
|
354440
|
+
{
|
|
354441
|
+
name: "snapshot_output",
|
|
354442
|
+
description: "Remember command output per connection and diff against the last snapshot.",
|
|
354443
|
+
schema: snapshotOutputSchema
|
|
354444
|
+
},
|
|
354445
|
+
{
|
|
354446
|
+
name: "replay_agent_run",
|
|
354447
|
+
description: "Replay agent steps with stubbed tool outputs \u2014 debug without touching live hosts.",
|
|
354448
|
+
schema: replayAgentRunSchema
|
|
354449
|
+
},
|
|
354450
|
+
{
|
|
354451
|
+
name: "plan_offline_join",
|
|
354452
|
+
description: "Plan offline domain join (djoin provision on DC + requestODJ on member) when SMB IPC$ is blocked.",
|
|
354453
|
+
schema: planOfflineJoinSchema
|
|
354454
|
+
},
|
|
354455
|
+
{
|
|
354456
|
+
name: "net_device",
|
|
354457
|
+
description: "Network device helpers: parse CDP neighbors, diff running vs startup config, detect config mode.",
|
|
354458
|
+
schema: netDeviceSchema
|
|
353652
354459
|
}
|
|
353653
354460
|
].map((tool2) => convertToOpenAITool(tool2));
|
|
353654
354461
|
}
|
|
@@ -353709,6 +354516,14 @@ var toolImplementations = {
|
|
|
353709
354516
|
collectInfra,
|
|
353710
354517
|
manageEtw,
|
|
353711
354518
|
listGatewayMethods,
|
|
354519
|
+
manageIncident,
|
|
354520
|
+
manageCollab,
|
|
354521
|
+
manageJumpPath,
|
|
354522
|
+
manageApproval,
|
|
354523
|
+
snapshotOutput,
|
|
354524
|
+
replayAgentRun,
|
|
354525
|
+
planOfflineJoin,
|
|
354526
|
+
netDevice,
|
|
353712
354527
|
writeFile,
|
|
353713
354528
|
editFile,
|
|
353714
354529
|
writeAndEdit,
|
|
@@ -355419,12 +356234,12 @@ function encodeURIPath(str3) {
|
|
|
355419
356234
|
return str3.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
355420
356235
|
}
|
|
355421
356236
|
var EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
355422
|
-
var createPathTagFunction = (pathEncoder = encodeURIPath) => function
|
|
356237
|
+
var createPathTagFunction = (pathEncoder = encodeURIPath) => function path34(statics, ...params) {
|
|
355423
356238
|
if (statics.length === 1)
|
|
355424
356239
|
return statics[0];
|
|
355425
356240
|
let postPath = false;
|
|
355426
356241
|
const invalidSegments = [];
|
|
355427
|
-
const
|
|
356242
|
+
const path35 = statics.reduce((previousValue, currentValue, index2) => {
|
|
355428
356243
|
if (/[?#]/.test(currentValue)) {
|
|
355429
356244
|
postPath = true;
|
|
355430
356245
|
}
|
|
@@ -355441,7 +356256,7 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path33(sta
|
|
|
355441
356256
|
}
|
|
355442
356257
|
return previousValue + currentValue + (index2 === params.length ? "" : encoded);
|
|
355443
356258
|
}, "");
|
|
355444
|
-
const pathOnly =
|
|
356259
|
+
const pathOnly = path35.split(/[?#]/, 1)[0];
|
|
355445
356260
|
const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
355446
356261
|
let match;
|
|
355447
356262
|
while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
@@ -355462,10 +356277,10 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path33(sta
|
|
|
355462
356277
|
}, "");
|
|
355463
356278
|
throw new OpenAIError(`Path parameters result in path with invalid segments:
|
|
355464
356279
|
${invalidSegments.map((e) => e.error).join("\n")}
|
|
355465
|
-
${
|
|
356280
|
+
${path35}
|
|
355466
356281
|
${underline}`);
|
|
355467
356282
|
}
|
|
355468
|
-
return
|
|
356283
|
+
return path35;
|
|
355469
356284
|
};
|
|
355470
356285
|
var path8 = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
|
|
355471
356286
|
|
|
@@ -355838,11 +356653,11 @@ var AbstractChatCompletionRunner = class extends EventStream {
|
|
|
355838
356653
|
this._addMessage(message);
|
|
355839
356654
|
return chatCompletion;
|
|
355840
356655
|
}
|
|
355841
|
-
_addMessage(message,
|
|
356656
|
+
_addMessage(message, emit12 = true) {
|
|
355842
356657
|
if (!("content" in message))
|
|
355843
356658
|
message.content = null;
|
|
355844
356659
|
this.messages.push(message);
|
|
355845
|
-
if (
|
|
356660
|
+
if (emit12) {
|
|
355846
356661
|
this._emit("message", message);
|
|
355847
356662
|
if (isToolMessage2(message) && message.content) {
|
|
355848
356663
|
this._emit("functionToolCallResult", message.content);
|
|
@@ -356094,8 +356909,8 @@ var ChatCompletionRunner = class _ChatCompletionRunner extends AbstractChatCompl
|
|
|
356094
356909
|
runner._run(() => runner._runTools(client2, params, opts));
|
|
356095
356910
|
return runner;
|
|
356096
356911
|
}
|
|
356097
|
-
_addMessage(message,
|
|
356098
|
-
super._addMessage(message,
|
|
356912
|
+
_addMessage(message, emit12 = true) {
|
|
356913
|
+
super._addMessage(message, emit12);
|
|
356099
356914
|
if (isAssistantMessage(message) && message.content) {
|
|
356100
356915
|
this._emit("content", message.content);
|
|
356101
356916
|
}
|
|
@@ -360282,9 +361097,9 @@ var OpenAI = class {
|
|
|
360282
361097
|
this.apiKey = token;
|
|
360283
361098
|
return true;
|
|
360284
361099
|
}
|
|
360285
|
-
buildURL(
|
|
361100
|
+
buildURL(path34, query, defaultBaseURL) {
|
|
360286
361101
|
const baseURL = !__classPrivateFieldGet(this, _OpenAI_instances, "m", _OpenAI_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
|
|
360287
|
-
const url2 = isAbsoluteURL(
|
|
361102
|
+
const url2 = isAbsoluteURL(path34) ? new URL(path34) : new URL(baseURL + (baseURL.endsWith("/") && path34.startsWith("/") ? path34.slice(1) : path34));
|
|
360288
361103
|
const defaultQuery = this.defaultQuery();
|
|
360289
361104
|
if (!isEmptyObj(defaultQuery)) {
|
|
360290
361105
|
query = { ...defaultQuery, ...query };
|
|
@@ -360308,24 +361123,24 @@ var OpenAI = class {
|
|
|
360308
361123
|
*/
|
|
360309
361124
|
async prepareRequest(request, { url: url2, options }) {
|
|
360310
361125
|
}
|
|
360311
|
-
get(
|
|
360312
|
-
return this.methodRequest("get",
|
|
361126
|
+
get(path34, opts) {
|
|
361127
|
+
return this.methodRequest("get", path34, opts);
|
|
360313
361128
|
}
|
|
360314
|
-
post(
|
|
360315
|
-
return this.methodRequest("post",
|
|
361129
|
+
post(path34, opts) {
|
|
361130
|
+
return this.methodRequest("post", path34, opts);
|
|
360316
361131
|
}
|
|
360317
|
-
patch(
|
|
360318
|
-
return this.methodRequest("patch",
|
|
361132
|
+
patch(path34, opts) {
|
|
361133
|
+
return this.methodRequest("patch", path34, opts);
|
|
360319
361134
|
}
|
|
360320
|
-
put(
|
|
360321
|
-
return this.methodRequest("put",
|
|
361135
|
+
put(path34, opts) {
|
|
361136
|
+
return this.methodRequest("put", path34, opts);
|
|
360322
361137
|
}
|
|
360323
|
-
delete(
|
|
360324
|
-
return this.methodRequest("delete",
|
|
361138
|
+
delete(path34, opts) {
|
|
361139
|
+
return this.methodRequest("delete", path34, opts);
|
|
360325
361140
|
}
|
|
360326
|
-
methodRequest(method,
|
|
361141
|
+
methodRequest(method, path34, opts) {
|
|
360327
361142
|
return this.request(Promise.resolve(opts).then((opts2) => {
|
|
360328
|
-
return { method, path:
|
|
361143
|
+
return { method, path: path34, ...opts2 };
|
|
360329
361144
|
}));
|
|
360330
361145
|
}
|
|
360331
361146
|
request(options, remainingRetries = null) {
|
|
@@ -360429,8 +361244,8 @@ var OpenAI = class {
|
|
|
360429
361244
|
}));
|
|
360430
361245
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
360431
361246
|
}
|
|
360432
|
-
getAPIList(
|
|
360433
|
-
return this.requestAPIList(Page2, { method: "get", path:
|
|
361247
|
+
getAPIList(path34, Page2, opts) {
|
|
361248
|
+
return this.requestAPIList(Page2, { method: "get", path: path34, ...opts });
|
|
360434
361249
|
}
|
|
360435
361250
|
requestAPIList(Page2, options) {
|
|
360436
361251
|
const request = this.makeRequest(options, null, void 0);
|
|
@@ -360508,8 +361323,8 @@ var OpenAI = class {
|
|
|
360508
361323
|
}
|
|
360509
361324
|
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
360510
361325
|
const options = { ...inputOptions };
|
|
360511
|
-
const { method, path:
|
|
360512
|
-
const url2 = this.buildURL(
|
|
361326
|
+
const { method, path: path34, query, defaultBaseURL } = options;
|
|
361327
|
+
const url2 = this.buildURL(path34, query, defaultBaseURL);
|
|
360513
361328
|
if ("timeout" in options)
|
|
360514
361329
|
validatePositiveInteger("timeout", options.timeout);
|
|
360515
361330
|
options.timeout = options.timeout ?? this.timeout;
|
|
@@ -362125,23 +362940,23 @@ function isNullable(schema2) {
|
|
|
362125
362940
|
}
|
|
362126
362941
|
return false;
|
|
362127
362942
|
}
|
|
362128
|
-
function ensureStrictJsonSchema(jsonSchema,
|
|
362943
|
+
function ensureStrictJsonSchema(jsonSchema, path34, root) {
|
|
362129
362944
|
if (typeof jsonSchema === "boolean") {
|
|
362130
|
-
throw new TypeError(`Expected object schema but got boolean; path=${
|
|
362945
|
+
throw new TypeError(`Expected object schema but got boolean; path=${path34.join("/")}`);
|
|
362131
362946
|
}
|
|
362132
362947
|
if (!isObject4(jsonSchema)) {
|
|
362133
|
-
throw new TypeError(`Expected ${JSON.stringify(jsonSchema)} to be an object; path=${
|
|
362948
|
+
throw new TypeError(`Expected ${JSON.stringify(jsonSchema)} to be an object; path=${path34.join("/")}`);
|
|
362134
362949
|
}
|
|
362135
362950
|
const defs = jsonSchema.$defs;
|
|
362136
362951
|
if (isObject4(defs)) {
|
|
362137
362952
|
for (const [defName, defSchema] of Object.entries(defs)) {
|
|
362138
|
-
ensureStrictJsonSchema(defSchema, [...
|
|
362953
|
+
ensureStrictJsonSchema(defSchema, [...path34, "$defs", defName], root);
|
|
362139
362954
|
}
|
|
362140
362955
|
}
|
|
362141
362956
|
const definitions = jsonSchema.definitions;
|
|
362142
362957
|
if (isObject4(definitions)) {
|
|
362143
362958
|
for (const [definitionName, definitionSchema] of Object.entries(definitions)) {
|
|
362144
|
-
ensureStrictJsonSchema(definitionSchema, [...
|
|
362959
|
+
ensureStrictJsonSchema(definitionSchema, [...path34, "definitions", definitionName], root);
|
|
362145
362960
|
}
|
|
362146
362961
|
}
|
|
362147
362962
|
const typ = jsonSchema.type;
|
|
@@ -362153,31 +362968,31 @@ function ensureStrictJsonSchema(jsonSchema, path33, root) {
|
|
|
362153
362968
|
if (isObject4(properties)) {
|
|
362154
362969
|
for (const [key, value] of Object.entries(properties)) {
|
|
362155
362970
|
if (!isNullable(value) && !required2.includes(key)) {
|
|
362156
|
-
throw new Error(`Zod field at \`${[...
|
|
362971
|
+
throw new Error(`Zod field at \`${[...path34, "properties", key].join("/")}\` uses \`.optional()\` without \`.nullable()\` which is not supported by the API. See: https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses#all-fields-must-be-required`);
|
|
362157
362972
|
}
|
|
362158
362973
|
}
|
|
362159
362974
|
jsonSchema.required = Object.keys(properties);
|
|
362160
362975
|
jsonSchema.properties = Object.fromEntries(Object.entries(properties).map(([key, propSchema]) => [
|
|
362161
362976
|
key,
|
|
362162
|
-
ensureStrictJsonSchema(propSchema, [...
|
|
362977
|
+
ensureStrictJsonSchema(propSchema, [...path34, "properties", key], root)
|
|
362163
362978
|
]));
|
|
362164
362979
|
}
|
|
362165
362980
|
const items = jsonSchema.items;
|
|
362166
362981
|
if (isObject4(items)) {
|
|
362167
|
-
jsonSchema.items = ensureStrictJsonSchema(items, [...
|
|
362982
|
+
jsonSchema.items = ensureStrictJsonSchema(items, [...path34, "items"], root);
|
|
362168
362983
|
}
|
|
362169
362984
|
const anyOf = jsonSchema.anyOf;
|
|
362170
362985
|
if (Array.isArray(anyOf)) {
|
|
362171
|
-
jsonSchema.anyOf = anyOf.map((variant, i) => ensureStrictJsonSchema(variant, [...
|
|
362986
|
+
jsonSchema.anyOf = anyOf.map((variant, i) => ensureStrictJsonSchema(variant, [...path34, "anyOf", String(i)], root));
|
|
362172
362987
|
}
|
|
362173
362988
|
const allOf = jsonSchema.allOf;
|
|
362174
362989
|
if (Array.isArray(allOf)) {
|
|
362175
362990
|
if (allOf.length === 1) {
|
|
362176
|
-
const resolved = ensureStrictJsonSchema(allOf[0], [...
|
|
362991
|
+
const resolved = ensureStrictJsonSchema(allOf[0], [...path34, "allOf", "0"], root);
|
|
362177
362992
|
Object.assign(jsonSchema, resolved);
|
|
362178
362993
|
delete jsonSchema.allOf;
|
|
362179
362994
|
} else {
|
|
362180
|
-
jsonSchema.allOf = allOf.map((entry, i) => ensureStrictJsonSchema(entry, [...
|
|
362995
|
+
jsonSchema.allOf = allOf.map((entry, i) => ensureStrictJsonSchema(entry, [...path34, "allOf", String(i)], root));
|
|
362181
362996
|
}
|
|
362182
362997
|
}
|
|
362183
362998
|
if (jsonSchema.default === null) {
|
|
@@ -362186,7 +363001,7 @@ function ensureStrictJsonSchema(jsonSchema, path33, root) {
|
|
|
362186
363001
|
const ref = jsonSchema.$ref;
|
|
362187
363002
|
if (ref && hasMoreThanNKeys(jsonSchema, 1)) {
|
|
362188
363003
|
if (typeof ref !== "string") {
|
|
362189
|
-
throw new TypeError(`Received non-string $ref - ${ref}; path=${
|
|
363004
|
+
throw new TypeError(`Received non-string $ref - ${ref}; path=${path34.join("/")}`);
|
|
362190
363005
|
}
|
|
362191
363006
|
const resolved = resolveRef(root, ref);
|
|
362192
363007
|
if (typeof resolved === "boolean") {
|
|
@@ -362197,7 +363012,7 @@ function ensureStrictJsonSchema(jsonSchema, path33, root) {
|
|
|
362197
363012
|
}
|
|
362198
363013
|
Object.assign(jsonSchema, { ...resolved, ...jsonSchema });
|
|
362199
363014
|
delete jsonSchema.$ref;
|
|
362200
|
-
return ensureStrictJsonSchema(jsonSchema,
|
|
363015
|
+
return ensureStrictJsonSchema(jsonSchema, path34, root);
|
|
362201
363016
|
}
|
|
362202
363017
|
return jsonSchema;
|
|
362203
363018
|
}
|
|
@@ -367105,6 +367920,7 @@ var AgentService_v2 = class {
|
|
|
367105
367920
|
* agent run (start/finish lifecycle + per-call token usage). */
|
|
367106
367921
|
agentRunLedger;
|
|
367107
367922
|
compoundingStore;
|
|
367923
|
+
opsService;
|
|
367108
367924
|
changeLedger;
|
|
367109
367925
|
mcpToolService;
|
|
367110
367926
|
skillService;
|
|
@@ -367242,6 +368058,9 @@ var AgentService_v2 = class {
|
|
|
367242
368058
|
setCompoundingStore(store) {
|
|
367243
368059
|
this.compoundingStore = store ?? void 0;
|
|
367244
368060
|
}
|
|
368061
|
+
setOpsService(svc) {
|
|
368062
|
+
this.opsService = svc ?? void 0;
|
|
368063
|
+
}
|
|
367245
368064
|
setFeedbackWaiter(waiter) {
|
|
367246
368065
|
this.waitForFeedback = waiter;
|
|
367247
368066
|
}
|
|
@@ -368767,6 +369586,78 @@ Actually, your intention might be different. Please re-read the description of t
|
|
|
368767
369586
|
}
|
|
368768
369587
|
break;
|
|
368769
369588
|
}
|
|
369589
|
+
case "manage_incident": {
|
|
369590
|
+
try {
|
|
369591
|
+
const validatedArgs = manageIncidentSchema.parse(toolCall.args || {});
|
|
369592
|
+
result = await toolImplementations.manageIncident(validatedArgs, executionContext);
|
|
369593
|
+
} catch (err) {
|
|
369594
|
+
result = `Parameter validation error for manage_incident: ${err.message}`;
|
|
369595
|
+
}
|
|
369596
|
+
break;
|
|
369597
|
+
}
|
|
369598
|
+
case "manage_collab": {
|
|
369599
|
+
try {
|
|
369600
|
+
const validatedArgs = manageCollabSchema.parse(toolCall.args || {});
|
|
369601
|
+
result = await toolImplementations.manageCollab(validatedArgs, executionContext);
|
|
369602
|
+
} catch (err) {
|
|
369603
|
+
result = `Parameter validation error for manage_collab: ${err.message}`;
|
|
369604
|
+
}
|
|
369605
|
+
break;
|
|
369606
|
+
}
|
|
369607
|
+
case "manage_jump_path": {
|
|
369608
|
+
try {
|
|
369609
|
+
const validatedArgs = manageJumpPathSchema.parse(toolCall.args || {});
|
|
369610
|
+
result = await toolImplementations.manageJumpPath(validatedArgs, executionContext);
|
|
369611
|
+
} catch (err) {
|
|
369612
|
+
result = `Parameter validation error for manage_jump_path: ${err.message}`;
|
|
369613
|
+
}
|
|
369614
|
+
break;
|
|
369615
|
+
}
|
|
369616
|
+
case "manage_approval": {
|
|
369617
|
+
try {
|
|
369618
|
+
const validatedArgs = manageApprovalSchema.parse(toolCall.args || {});
|
|
369619
|
+
result = await toolImplementations.manageApproval(validatedArgs, executionContext);
|
|
369620
|
+
} catch (err) {
|
|
369621
|
+
result = `Parameter validation error for manage_approval: ${err.message}`;
|
|
369622
|
+
}
|
|
369623
|
+
break;
|
|
369624
|
+
}
|
|
369625
|
+
case "snapshot_output": {
|
|
369626
|
+
try {
|
|
369627
|
+
const validatedArgs = snapshotOutputSchema.parse(toolCall.args || {});
|
|
369628
|
+
result = await toolImplementations.snapshotOutput(validatedArgs, executionContext);
|
|
369629
|
+
} catch (err) {
|
|
369630
|
+
result = `Parameter validation error for snapshot_output: ${err.message}`;
|
|
369631
|
+
}
|
|
369632
|
+
break;
|
|
369633
|
+
}
|
|
369634
|
+
case "replay_agent_run": {
|
|
369635
|
+
try {
|
|
369636
|
+
const validatedArgs = replayAgentRunSchema.parse(toolCall.args || {});
|
|
369637
|
+
result = await toolImplementations.replayAgentRun(validatedArgs, executionContext);
|
|
369638
|
+
} catch (err) {
|
|
369639
|
+
result = `Parameter validation error for replay_agent_run: ${err.message}`;
|
|
369640
|
+
}
|
|
369641
|
+
break;
|
|
369642
|
+
}
|
|
369643
|
+
case "plan_offline_join": {
|
|
369644
|
+
try {
|
|
369645
|
+
const validatedArgs = planOfflineJoinSchema.parse(toolCall.args || {});
|
|
369646
|
+
result = await toolImplementations.planOfflineJoin(validatedArgs, executionContext);
|
|
369647
|
+
} catch (err) {
|
|
369648
|
+
result = `Parameter validation error for plan_offline_join: ${err.message}`;
|
|
369649
|
+
}
|
|
369650
|
+
break;
|
|
369651
|
+
}
|
|
369652
|
+
case "net_device": {
|
|
369653
|
+
try {
|
|
369654
|
+
const validatedArgs = netDeviceSchema.parse(toolCall.args || {});
|
|
369655
|
+
result = await toolImplementations.netDevice(validatedArgs, executionContext);
|
|
369656
|
+
} catch (err) {
|
|
369657
|
+
result = `Parameter validation error for net_device: ${err.message}`;
|
|
369658
|
+
}
|
|
369659
|
+
break;
|
|
369660
|
+
}
|
|
368770
369661
|
case "manage_device_memory": {
|
|
368771
369662
|
try {
|
|
368772
369663
|
const validatedArgs = manageDeviceMemorySchema.parse(toolCall.args || {});
|
|
@@ -369244,6 +370135,22 @@ Actually, your intention might be different. Please re-read the description of t
|
|
|
369244
370135
|
return ti.manageGoal(args, executionContext);
|
|
369245
370136
|
case "estate_facts":
|
|
369246
370137
|
return ti.estateFacts(args, executionContext);
|
|
370138
|
+
case "manage_incident":
|
|
370139
|
+
return ti.manageIncident(args, executionContext);
|
|
370140
|
+
case "manage_collab":
|
|
370141
|
+
return ti.manageCollab(args, executionContext);
|
|
370142
|
+
case "manage_jump_path":
|
|
370143
|
+
return ti.manageJumpPath(args, executionContext);
|
|
370144
|
+
case "manage_approval":
|
|
370145
|
+
return ti.manageApproval(args, executionContext);
|
|
370146
|
+
case "snapshot_output":
|
|
370147
|
+
return ti.snapshotOutput(args, executionContext);
|
|
370148
|
+
case "replay_agent_run":
|
|
370149
|
+
return ti.replayAgentRun(args, executionContext);
|
|
370150
|
+
case "plan_offline_join":
|
|
370151
|
+
return ti.planOfflineJoin(args, executionContext);
|
|
370152
|
+
case "net_device":
|
|
370153
|
+
return ti.netDevice(args, executionContext);
|
|
369247
370154
|
case "list_gateway_methods":
|
|
369248
370155
|
return ti.listGatewayMethods(args, executionContext);
|
|
369249
370156
|
case "collect_facts":
|
|
@@ -369702,6 +370609,7 @@ ${reminder}`;
|
|
|
369702
370609
|
sessionLogger: this.sessionLogger,
|
|
369703
370610
|
agentRunLedger: this.agentRunLedger,
|
|
369704
370611
|
compoundingStore: this.compoundingStore,
|
|
370612
|
+
opsService: this.opsService,
|
|
369705
370613
|
changeLedger: this.changeLedger,
|
|
369706
370614
|
triggerEngine: this.triggerEngine,
|
|
369707
370615
|
observability: this.observability,
|
|
@@ -373122,6 +374030,134 @@ var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
|
373122
374030
|
// ../../packages/backend/src/services/Gateway/WebSocketGatewayAdapter.ts
|
|
373123
374031
|
var import_node_module4 = require("node:module");
|
|
373124
374032
|
|
|
374033
|
+
// ../../packages/backend/src/services/Gateway/opsBridge.ts
|
|
374034
|
+
function requireOps(deps) {
|
|
374035
|
+
const o = deps.ops();
|
|
374036
|
+
if (!o) throw new Error("ops service is not available on this runtime");
|
|
374037
|
+
return o;
|
|
374038
|
+
}
|
|
374039
|
+
var DEFAULT_APPROVAL_TTL_SECONDS = 900;
|
|
374040
|
+
function createOpsBridge(deps) {
|
|
374041
|
+
return {
|
|
374042
|
+
// ── collab ─────────────────────────────────────────────────────────────
|
|
374043
|
+
collabJoin: async (p) => requireOps(deps).joinCollab(p.sessionId, p.operator),
|
|
374044
|
+
collabTakeConn: async (p) => requireOps(deps).takeConn(p.sessionId, p.operator),
|
|
374045
|
+
collabWhoHasConn: async (p) => requireOps(deps).whoHasConn(p.sessionId),
|
|
374046
|
+
collabList: async () => ({ sessions: requireOps(deps).listCollabSessions() }),
|
|
374047
|
+
// ── incidents ──────────────────────────────────────────────────────────
|
|
374048
|
+
incidentOpen: async (p) => requireOps(deps).openIncident(p.title, {
|
|
374049
|
+
sessionId: p.chatId,
|
|
374050
|
+
tabIds: p.terminals,
|
|
374051
|
+
recordingId: p.recordingId,
|
|
374052
|
+
runId: p.runId,
|
|
374053
|
+
notes: p.notes
|
|
374054
|
+
}),
|
|
374055
|
+
incidentGet: async (p) => {
|
|
374056
|
+
const inc = requireOps(deps).getIncident(p.id);
|
|
374057
|
+
if (!inc) throw new Error(`no incident ${p.id}`);
|
|
374058
|
+
return inc;
|
|
374059
|
+
},
|
|
374060
|
+
incidentList: async (p) => ({ incidents: requireOps(deps).listIncidents(p?.status) }),
|
|
374061
|
+
incidentClose: async (p) => {
|
|
374062
|
+
const inc = requireOps(deps).closeIncident(p.id, p.notes);
|
|
374063
|
+
if (!inc) throw new Error(`no incident ${p.id}`);
|
|
374064
|
+
return inc;
|
|
374065
|
+
},
|
|
374066
|
+
// ── jump paths / break-glass ───────────────────────────────────────────
|
|
374067
|
+
jumpPathDefine: async (p) => requireOps(deps).defineJumpPath(p.name, p.hops),
|
|
374068
|
+
jumpPathList: async () => ({ paths: requireOps(deps).listJumpPaths() }),
|
|
374069
|
+
jumpPathBreakGlass: async (p) => requireOps(deps).grantBreakGlass(p.name, Math.max(0, p.ttlSeconds) * 1e3),
|
|
374070
|
+
jumpPathAllowed: async (p) => requireOps(deps).pathAllowed(p.name),
|
|
374071
|
+
// ── output snapshots ───────────────────────────────────────────────────
|
|
374072
|
+
snapshotRemember: async (p) => requireOps(deps).rememberOutput(p.connection, p.command, p.output),
|
|
374073
|
+
snapshotList: async (p) => ({ snapshots: requireOps(deps).listSnapshots(p?.connection) }),
|
|
374074
|
+
snapshotDiff: async (p) => requireOps(deps).diffOutput(p.connection, p.command, p.output),
|
|
374075
|
+
// ── approvals ──────────────────────────────────────────────────────────
|
|
374076
|
+
approvalRequest: async (p) => requireOps(deps).requestApproval(
|
|
374077
|
+
p.command,
|
|
374078
|
+
Math.max(1, p.ttlSeconds ?? DEFAULT_APPROVAL_TTL_SECONDS) * 1e3,
|
|
374079
|
+
p.twoPerson === true
|
|
374080
|
+
),
|
|
374081
|
+
approvalList: async (p) => ({ approvals: requireOps(deps).listApprovals(p?.state) }),
|
|
374082
|
+
approvalGet: async (p) => {
|
|
374083
|
+
const a = requireOps(deps).getApproval(p.id);
|
|
374084
|
+
if (!a) throw new Error(`no approval ${p.id}`);
|
|
374085
|
+
return a;
|
|
374086
|
+
},
|
|
374087
|
+
approvalDecide: async (p) => requireOps(deps).decideApproval(p.id, p.who, p.approve),
|
|
374088
|
+
approvalSweep: async () => ({ expired: requireOps(deps).sweepExpiredApprovals() }),
|
|
374089
|
+
// ── agent replay ───────────────────────────────────────────────────────
|
|
374090
|
+
replayRun: async (p) => requireOps(deps).replay(
|
|
374091
|
+
p.runId,
|
|
374092
|
+
p.steps.map((s) => ({
|
|
374093
|
+
tool: s.tool,
|
|
374094
|
+
args: s.args && typeof s.args === "object" && !Array.isArray(s.args) ? s.args : {},
|
|
374095
|
+
stub: typeof s.output === "string" ? s.output : ""
|
|
374096
|
+
}))
|
|
374097
|
+
),
|
|
374098
|
+
// ── offline domain join ────────────────────────────────────────────────
|
|
374099
|
+
djoinPlan: async (p) => requireOps(deps).planOfflineJoin(p),
|
|
374100
|
+
// ── network device ─────────────────────────────────────────────────────
|
|
374101
|
+
netParseCdp: async (p) => ({ neighbors: requireOps(deps).parseCdp(p.output) }),
|
|
374102
|
+
netConfigDiff: async (p) => requireOps(deps).configDiff(p.running, p.startup),
|
|
374103
|
+
netInConfigMode: async (p) => ({ inConfigMode: requireOps(deps).inConfigMode(p.prompt) })
|
|
374104
|
+
};
|
|
374105
|
+
}
|
|
374106
|
+
var OPS_METHODS = [
|
|
374107
|
+
"ops:collabJoin",
|
|
374108
|
+
"ops:collabTakeConn",
|
|
374109
|
+
"ops:collabWhoHasConn",
|
|
374110
|
+
"ops:collabList",
|
|
374111
|
+
"ops:incidentOpen",
|
|
374112
|
+
"ops:incidentGet",
|
|
374113
|
+
"ops:incidentList",
|
|
374114
|
+
"ops:incidentClose",
|
|
374115
|
+
"ops:jumpPathDefine",
|
|
374116
|
+
"ops:jumpPathList",
|
|
374117
|
+
"ops:jumpPathBreakGlass",
|
|
374118
|
+
"ops:jumpPathAllowed",
|
|
374119
|
+
"ops:snapshotRemember",
|
|
374120
|
+
"ops:snapshotList",
|
|
374121
|
+
"ops:snapshotDiff",
|
|
374122
|
+
"ops:approvalRequest",
|
|
374123
|
+
"ops:approvalList",
|
|
374124
|
+
"ops:approvalGet",
|
|
374125
|
+
"ops:approvalDecide",
|
|
374126
|
+
"ops:approvalSweep",
|
|
374127
|
+
"ops:replayRun",
|
|
374128
|
+
"ops:djoinPlan",
|
|
374129
|
+
"ops:netParseCdp",
|
|
374130
|
+
"ops:netConfigDiff",
|
|
374131
|
+
"ops:netInConfigMode"
|
|
374132
|
+
];
|
|
374133
|
+
var OPS_METHOD_INFO = [
|
|
374134
|
+
{ name: "ops:collabJoin", description: "Join a shared agent session as an operator (two-operator collab).", since: "3.8.1" },
|
|
374135
|
+
{ name: "ops:collabTakeConn", description: "Take the conn for a shared session \u2014 records who is currently driving.", since: "3.8.1" },
|
|
374136
|
+
{ name: "ops:collabWhoHasConn", description: "Who currently holds the conn for a session, plus joined operators.", since: "3.8.1" },
|
|
374137
|
+
{ name: "ops:collabList", description: "List sessions with operators and current holder.", since: "3.8.1" },
|
|
374138
|
+
{ name: "ops:incidentOpen", description: "Open an incident bundle (chat + terminals + recording + run id). Persisted.", since: "3.8.1" },
|
|
374139
|
+
{ name: "ops:incidentGet", description: "Fetch one incident bundle by id.", since: "3.8.1" },
|
|
374140
|
+
{ name: "ops:incidentList", description: "List incident bundles (optionally by status).", since: "3.8.1" },
|
|
374141
|
+
{ name: "ops:incidentClose", description: "Close an incident bundle with optional notes.", since: "3.8.1" },
|
|
374142
|
+
{ name: "ops:jumpPathDefine", description: "Define a named multi-hop jump path (laptop \u2192 jump \u2192 target).", since: "3.8.1" },
|
|
374143
|
+
{ name: "ops:jumpPathList", description: "List defined jump paths and their break-glass state.", since: "3.8.1" },
|
|
374144
|
+
{ name: "ops:jumpPathBreakGlass", description: "Grant time-boxed break-glass (TTL seconds) on a jump path.", since: "3.8.1" },
|
|
374145
|
+
{ name: "ops:jumpPathAllowed", description: "Is a jump path usable right now (break-glass valid) or expired?", since: "3.8.1" },
|
|
374146
|
+
{ name: "ops:snapshotRemember", description: "Store command output as the baseline for a connection+command.", since: "3.8.1" },
|
|
374147
|
+
{ name: "ops:snapshotList", description: "List stored output snapshots.", since: "3.8.1" },
|
|
374148
|
+
{ name: "ops:snapshotDiff", description: "Diff new output against the stored baseline, then update the baseline.", since: "3.8.1" },
|
|
374149
|
+
{ name: "ops:approvalRequest", description: "Request an approval with a TTL; twoPerson requires two distinct approvers.", since: "3.8.1" },
|
|
374150
|
+
{ name: "ops:approvalList", description: "List approvals (sweeps expired first).", since: "3.8.1" },
|
|
374151
|
+
{ name: "ops:approvalGet", description: "Get one approval by id.", since: "3.8.1" },
|
|
374152
|
+
{ name: "ops:approvalDecide", description: "Approve or deny an approval as a named person.", since: "3.8.1" },
|
|
374153
|
+
{ name: "ops:approvalSweep", description: "Expire pending approvals past their TTL; returns the count.", since: "3.8.1" },
|
|
374154
|
+
{ name: "ops:replayRun", description: "Replay agent steps with stubbed tool outputs \u2014 debug without touching live hosts.", since: "3.8.1" },
|
|
374155
|
+
{ name: "ops:djoinPlan", description: "Plan offline domain join (djoin provision + request) across a DC and a member.", since: "3.8.1" },
|
|
374156
|
+
{ name: "ops:netParseCdp", description: "Parse `show cdp neighbors` output into structured neighbors.", since: "3.8.1" },
|
|
374157
|
+
{ name: "ops:netConfigDiff", description: "Diff running-config vs startup-config for a network device.", since: "3.8.1" },
|
|
374158
|
+
{ name: "ops:netInConfigMode", description: "Detect whether a device prompt is in config mode.", since: "3.8.1" }
|
|
374159
|
+
];
|
|
374160
|
+
|
|
373125
374161
|
// ../../packages/backend/src/services/security/tokenScopes.ts
|
|
373126
374162
|
var SCOPE_FULL = "*";
|
|
373127
374163
|
function methodAllowed(method, scopes) {
|
|
@@ -373695,6 +374731,24 @@ var WebSocketGatewayAdapter = class {
|
|
|
373695
374731
|
}
|
|
373696
374732
|
return await fn(params);
|
|
373697
374733
|
}
|
|
374734
|
+
if (request.method.startsWith("ops:")) {
|
|
374735
|
+
const ops = this.options.opsBridge;
|
|
374736
|
+
if (!ops) {
|
|
374737
|
+
throw new WebSocketRpcError(
|
|
374738
|
+
"METHOD_NOT_FOUND",
|
|
374739
|
+
`${request.method} is not available on this websocket gateway.`
|
|
374740
|
+
);
|
|
374741
|
+
}
|
|
374742
|
+
const opName = request.method.slice("ops:".length);
|
|
374743
|
+
const opFn = ops[opName];
|
|
374744
|
+
if (typeof opFn !== "function") {
|
|
374745
|
+
throw new WebSocketRpcError(
|
|
374746
|
+
"METHOD_NOT_FOUND",
|
|
374747
|
+
`Unknown ops method: ${request.method}`
|
|
374748
|
+
);
|
|
374749
|
+
}
|
|
374750
|
+
return await opFn(params);
|
|
374751
|
+
}
|
|
373698
374752
|
switch (request.method) {
|
|
373699
374753
|
case "gateway:ping":
|
|
373700
374754
|
return { pong: true, ts: Date.now() };
|
|
@@ -373702,7 +374756,11 @@ var WebSocketGatewayAdapter = class {
|
|
|
373702
374756
|
return { sameMachine: this.isSameMachineBySocket.get(socket) === true };
|
|
373703
374757
|
case "gateway:describe": {
|
|
373704
374758
|
const obs2 = OBSERVABILITY_METHODS.map((name) => ({ name }));
|
|
373705
|
-
const
|
|
374759
|
+
const opsMethods = OPS_METHODS.map((name) => {
|
|
374760
|
+
const info = OPS_METHOD_INFO.find((m2) => m2.name === name);
|
|
374761
|
+
return { name, description: info?.description, since: info?.since };
|
|
374762
|
+
});
|
|
374763
|
+
const payload = buildDescribePayload([...obs2, ...opsMethods]);
|
|
373706
374764
|
const category = typeof params.category === "string" && params.category ? params.category : void 0;
|
|
373707
374765
|
const prefix = typeof params.prefix === "string" && params.prefix ? params.prefix : void 0;
|
|
373708
374766
|
let methods = payload.methods;
|
|
@@ -383068,20 +384126,25 @@ var FileAccessTokenStore = class {
|
|
|
383068
384126
|
});
|
|
383069
384127
|
}
|
|
383070
384128
|
async verify(tokenRaw) {
|
|
384129
|
+
const identified = await this.identify(tokenRaw);
|
|
384130
|
+
return identified !== null;
|
|
384131
|
+
}
|
|
384132
|
+
/** Return the matching token's id+name, or null. Used as operator identity. */
|
|
384133
|
+
async identify(tokenRaw) {
|
|
383071
384134
|
const token = String(tokenRaw || "").trim();
|
|
383072
|
-
if (!token) return
|
|
384135
|
+
if (!token) return null;
|
|
383073
384136
|
const payload = await this.readPayload();
|
|
383074
384137
|
for (const record2 of payload.tokens) {
|
|
383075
384138
|
try {
|
|
383076
384139
|
const expected = Buffer.from(record2.tokenHash, "base64");
|
|
383077
384140
|
const actual = await deriveTokenHash(token, record2.tokenSalt);
|
|
383078
384141
|
if (expected.length === actual.length && (0, import_node_crypto19.timingSafeEqual)(expected, actual)) {
|
|
383079
|
-
return
|
|
384142
|
+
return { id: record2.id, name: record2.name };
|
|
383080
384143
|
}
|
|
383081
384144
|
} catch {
|
|
383082
384145
|
}
|
|
383083
384146
|
}
|
|
383084
|
-
return
|
|
384147
|
+
return null;
|
|
383085
384148
|
}
|
|
383086
384149
|
async runExclusive(operation) {
|
|
383087
384150
|
const run = this.mutationQueue.then(operation, operation);
|
|
@@ -385112,8 +386175,8 @@ var IdleTimeoutService = class {
|
|
|
385112
386175
|
};
|
|
385113
386176
|
|
|
385114
386177
|
// ../../packages/backend/src/services/Gateway/restApi.ts
|
|
385115
|
-
function matchRestRoute(routes, method,
|
|
385116
|
-
const normalized =
|
|
386178
|
+
function matchRestRoute(routes, method, path34) {
|
|
386179
|
+
const normalized = path34.replace(/\/+$/, "") || "/";
|
|
385117
386180
|
const verb = method.toUpperCase();
|
|
385118
386181
|
for (const route of routes) {
|
|
385119
386182
|
if (route.method !== verb) continue;
|
|
@@ -393242,11 +394305,11 @@ function createObservability(deps) {
|
|
|
393242
394305
|
const policyEngine = new AgtPolicyEngine({
|
|
393243
394306
|
loadPolicy: async () => {
|
|
393244
394307
|
const req = (0, import_node_module5.createRequire)(typeof __filename !== "undefined" ? __filename : import_meta8.url);
|
|
393245
|
-
const
|
|
393246
|
-
const
|
|
393247
|
-
const policyPath =
|
|
393248
|
-
if (
|
|
393249
|
-
return parsePolicyYaml(
|
|
394308
|
+
const fs25 = req("node:fs");
|
|
394309
|
+
const path34 = req("node:path");
|
|
394310
|
+
const policyPath = path34.join(".", "policy.yaml");
|
|
394311
|
+
if (fs25.existsSync(policyPath)) {
|
|
394312
|
+
return parsePolicyYaml(fs25.readFileSync(policyPath, "utf8"));
|
|
393250
394313
|
}
|
|
393251
394314
|
return {
|
|
393252
394315
|
name: "rterm-default",
|
|
@@ -393288,18 +394351,18 @@ function createObservability(deps) {
|
|
|
393288
394351
|
const scanRoots = [pluginScanRoot, "./plugins"];
|
|
393289
394352
|
try {
|
|
393290
394353
|
const req = (0, import_node_module5.createRequire)(typeof __filename !== "undefined" ? __filename : import_meta8.url);
|
|
393291
|
-
const
|
|
393292
|
-
if (
|
|
394354
|
+
const fs25 = req("node:fs");
|
|
394355
|
+
if (fs25.existsSync(bundlePluginRoot)) scanRoots.push(bundlePluginRoot);
|
|
393293
394356
|
} catch {
|
|
393294
394357
|
}
|
|
393295
394358
|
try {
|
|
393296
394359
|
const req = (0, import_node_module5.createRequire)(typeof __filename !== "undefined" ? __filename : import_meta8.url);
|
|
393297
|
-
const
|
|
393298
|
-
const
|
|
394360
|
+
const fs25 = req("node:fs");
|
|
394361
|
+
const path34 = req("node:path");
|
|
393299
394362
|
const resourcesPath = process.resourcesPath;
|
|
393300
394363
|
if (resourcesPath) {
|
|
393301
|
-
const resourcesPlugins =
|
|
393302
|
-
if (
|
|
394364
|
+
const resourcesPlugins = path34.join(resourcesPath, "plugins");
|
|
394365
|
+
if (fs25.existsSync(resourcesPlugins)) scanRoots.push(resourcesPlugins);
|
|
393303
394366
|
}
|
|
393304
394367
|
} catch {
|
|
393305
394368
|
}
|
|
@@ -395986,9 +397049,9 @@ function numberFromEnv(name, fallback) {
|
|
|
395986
397049
|
function resolveDataDir() {
|
|
395987
397050
|
const custom3 = (import_node_process2.default.env.GYBACKEND_DATA_DIR || "").trim();
|
|
395988
397051
|
if (custom3) {
|
|
395989
|
-
return
|
|
397052
|
+
return import_node_path30.default.resolve(custom3);
|
|
395990
397053
|
}
|
|
395991
|
-
return
|
|
397054
|
+
return import_node_path30.default.join(import_node_process2.default.cwd(), ".gybackend-data");
|
|
395992
397055
|
}
|
|
395993
397056
|
async function startGyBackend() {
|
|
395994
397057
|
const dataDir = resolveDataDir();
|
|
@@ -396021,7 +397084,7 @@ async function startGyBackend() {
|
|
|
396021
397084
|
const modelCapabilityService = new ModelCapabilityService();
|
|
396022
397085
|
const imageAttachmentService = new ImageAttachmentService(dataDir);
|
|
396023
397086
|
const terminalStateStore = new TerminalStateStore(
|
|
396024
|
-
|
|
397087
|
+
import_node_path30.default.join(dataDir, "terminal-tabs-state.json")
|
|
396025
397088
|
);
|
|
396026
397089
|
const terminalService = new TerminalService({
|
|
396027
397090
|
terminalStateStore
|
|
@@ -396112,6 +397175,9 @@ async function startGyBackend() {
|
|
|
396112
397175
|
const { CompoundingStore: CompoundingStore2 } = await Promise.resolve().then(() => (init_compoundingStore(), compoundingStore_exports));
|
|
396113
397176
|
const compoundingStore = new CompoundingStore2();
|
|
396114
397177
|
agentService.setCompoundingStore(compoundingStore);
|
|
397178
|
+
const { OpsService: OpsService2 } = await Promise.resolve().then(() => (init_opsService(), opsService_exports));
|
|
397179
|
+
const opsService = new OpsService2();
|
|
397180
|
+
agentService.setOpsService(opsService);
|
|
396115
397181
|
try {
|
|
396116
397182
|
const { connectionIdentity: connectionIdentity2 } = await Promise.resolve().then(() => (init_compoundingKnowledge(), compoundingKnowledge_exports));
|
|
396117
397183
|
const winrm = settingsService.getSettings()?.connections?.winrm ?? [];
|
|
@@ -396237,7 +397303,7 @@ async function startGyBackend() {
|
|
|
396237
397303
|
console.warn("[gybackend] Plugin tool wiring skipped:", e instanceof Error ? e.message : String(e));
|
|
396238
397304
|
});
|
|
396239
397305
|
if (settingsService.getSettings().sessionLogging?.enabled) {
|
|
396240
|
-
const logDir =
|
|
397306
|
+
const logDir = import_node_path30.default.join(
|
|
396241
397307
|
import_node_process2.default.env.GYSHELL_STORE_DIR || "",
|
|
396242
397308
|
"session-logs"
|
|
396243
397309
|
);
|
|
@@ -396355,21 +397421,21 @@ async function startGyBackend() {
|
|
|
396355
397421
|
authFailureLimit: 5,
|
|
396356
397422
|
authLockoutMs: 6e4
|
|
396357
397423
|
});
|
|
396358
|
-
const settingsDir =
|
|
396359
|
-
const backupsDir = settingsDir ?
|
|
397424
|
+
const settingsDir = import_node_path30.default.dirname(settingsService.getSettingsPath?.() ?? "");
|
|
397425
|
+
const backupsDir = settingsDir ? import_node_path30.default.join(settingsDir, "backups") : "";
|
|
396360
397426
|
const settingsBackupService = new SettingsBackupService(
|
|
396361
397427
|
backupsDir ? {
|
|
396362
|
-
read: () =>
|
|
396363
|
-
write: (c) =>
|
|
396364
|
-
listBackups: () =>
|
|
396365
|
-
readBackup: (n2) =>
|
|
397428
|
+
read: () => import_node_fs14.default.readFileSync(settingsService.getSettingsPath(), "utf8"),
|
|
397429
|
+
write: (c) => import_node_fs14.default.writeFileSync(settingsService.getSettingsPath(), c),
|
|
397430
|
+
listBackups: () => import_node_fs14.default.existsSync(backupsDir) ? import_node_fs14.default.readdirSync(backupsDir) : [],
|
|
397431
|
+
readBackup: (n2) => import_node_fs14.default.readFileSync(import_node_path30.default.join(backupsDir, n2), "utf8"),
|
|
396366
397432
|
writeBackup: (n2, c) => {
|
|
396367
|
-
|
|
396368
|
-
|
|
397433
|
+
import_node_fs14.default.mkdirSync(backupsDir, { recursive: true });
|
|
397434
|
+
import_node_fs14.default.writeFileSync(import_node_path30.default.join(backupsDir, n2), c);
|
|
396369
397435
|
},
|
|
396370
397436
|
deleteBackup: (n2) => {
|
|
396371
|
-
const p =
|
|
396372
|
-
if (
|
|
397437
|
+
const p = import_node_path30.default.join(backupsDir, n2);
|
|
397438
|
+
if (import_node_fs14.default.existsSync(p)) import_node_fs14.default.unlinkSync(p);
|
|
396373
397439
|
}
|
|
396374
397440
|
} : { read: () => "", write: () => {
|
|
396375
397441
|
}, listBackups: () => [], readBackup: () => "", writeBackup: () => {
|
|
@@ -396877,6 +397943,9 @@ async function startGyBackend() {
|
|
|
396877
397943
|
observabilityBridge: createObservabilityBridge({
|
|
396878
397944
|
observability: () => observability,
|
|
396879
397945
|
terminalService: () => terminalService
|
|
397946
|
+
}),
|
|
397947
|
+
opsBridge: createOpsBridge({
|
|
397948
|
+
ops: () => opsService
|
|
396880
397949
|
})
|
|
396881
397950
|
});
|
|
396882
397951
|
restDispatchTarget = adapter;
|