tasqmate 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tasqmate.js +630 -174
- package/package.json +2 -2
package/dist/tasqmate.js
CHANGED
|
@@ -639,8 +639,8 @@ var require_help = __commonJS({
|
|
|
639
639
|
* @param {string} str
|
|
640
640
|
* @returns {number}
|
|
641
641
|
*/
|
|
642
|
-
displayWidth(
|
|
643
|
-
return stripColor(
|
|
642
|
+
displayWidth(str2) {
|
|
643
|
+
return stripColor(str2).length;
|
|
644
644
|
}
|
|
645
645
|
/**
|
|
646
646
|
* Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc.
|
|
@@ -648,11 +648,11 @@ var require_help = __commonJS({
|
|
|
648
648
|
* @param {string} str
|
|
649
649
|
* @returns {string}
|
|
650
650
|
*/
|
|
651
|
-
styleTitle(
|
|
652
|
-
return
|
|
651
|
+
styleTitle(str2) {
|
|
652
|
+
return str2;
|
|
653
653
|
}
|
|
654
|
-
styleUsage(
|
|
655
|
-
return
|
|
654
|
+
styleUsage(str2) {
|
|
655
|
+
return str2.split(" ").map((word) => {
|
|
656
656
|
if (word === "[options]") return this.styleOptionText(word);
|
|
657
657
|
if (word === "[command]") return this.styleSubcommandText(word);
|
|
658
658
|
if (word[0] === "[" || word[0] === "<")
|
|
@@ -660,46 +660,46 @@ var require_help = __commonJS({
|
|
|
660
660
|
return this.styleCommandText(word);
|
|
661
661
|
}).join(" ");
|
|
662
662
|
}
|
|
663
|
-
styleCommandDescription(
|
|
664
|
-
return this.styleDescriptionText(
|
|
663
|
+
styleCommandDescription(str2) {
|
|
664
|
+
return this.styleDescriptionText(str2);
|
|
665
665
|
}
|
|
666
|
-
styleOptionDescription(
|
|
667
|
-
return this.styleDescriptionText(
|
|
666
|
+
styleOptionDescription(str2) {
|
|
667
|
+
return this.styleDescriptionText(str2);
|
|
668
668
|
}
|
|
669
|
-
styleSubcommandDescription(
|
|
670
|
-
return this.styleDescriptionText(
|
|
669
|
+
styleSubcommandDescription(str2) {
|
|
670
|
+
return this.styleDescriptionText(str2);
|
|
671
671
|
}
|
|
672
|
-
styleArgumentDescription(
|
|
673
|
-
return this.styleDescriptionText(
|
|
672
|
+
styleArgumentDescription(str2) {
|
|
673
|
+
return this.styleDescriptionText(str2);
|
|
674
674
|
}
|
|
675
|
-
styleDescriptionText(
|
|
676
|
-
return
|
|
675
|
+
styleDescriptionText(str2) {
|
|
676
|
+
return str2;
|
|
677
677
|
}
|
|
678
|
-
styleOptionTerm(
|
|
679
|
-
return this.styleOptionText(
|
|
678
|
+
styleOptionTerm(str2) {
|
|
679
|
+
return this.styleOptionText(str2);
|
|
680
680
|
}
|
|
681
|
-
styleSubcommandTerm(
|
|
682
|
-
return
|
|
681
|
+
styleSubcommandTerm(str2) {
|
|
682
|
+
return str2.split(" ").map((word) => {
|
|
683
683
|
if (word === "[options]") return this.styleOptionText(word);
|
|
684
684
|
if (word[0] === "[" || word[0] === "<")
|
|
685
685
|
return this.styleArgumentText(word);
|
|
686
686
|
return this.styleSubcommandText(word);
|
|
687
687
|
}).join(" ");
|
|
688
688
|
}
|
|
689
|
-
styleArgumentTerm(
|
|
690
|
-
return this.styleArgumentText(
|
|
689
|
+
styleArgumentTerm(str2) {
|
|
690
|
+
return this.styleArgumentText(str2);
|
|
691
691
|
}
|
|
692
|
-
styleOptionText(
|
|
693
|
-
return
|
|
692
|
+
styleOptionText(str2) {
|
|
693
|
+
return str2;
|
|
694
694
|
}
|
|
695
|
-
styleArgumentText(
|
|
696
|
-
return
|
|
695
|
+
styleArgumentText(str2) {
|
|
696
|
+
return str2;
|
|
697
697
|
}
|
|
698
|
-
styleSubcommandText(
|
|
699
|
-
return
|
|
698
|
+
styleSubcommandText(str2) {
|
|
699
|
+
return str2;
|
|
700
700
|
}
|
|
701
|
-
styleCommandText(
|
|
702
|
-
return
|
|
701
|
+
styleCommandText(str2) {
|
|
702
|
+
return str2;
|
|
703
703
|
}
|
|
704
704
|
/**
|
|
705
705
|
* Calculate the pad width from the maximum term length.
|
|
@@ -722,8 +722,8 @@ var require_help = __commonJS({
|
|
|
722
722
|
* @param {string} str
|
|
723
723
|
* @returns {boolean}
|
|
724
724
|
*/
|
|
725
|
-
preformatted(
|
|
726
|
-
return /\n[^\S\r\n]/.test(
|
|
725
|
+
preformatted(str2) {
|
|
726
|
+
return /\n[^\S\r\n]/.test(str2);
|
|
727
727
|
}
|
|
728
728
|
/**
|
|
729
729
|
* Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
|
|
@@ -769,9 +769,9 @@ ${itemIndentStr}`);
|
|
|
769
769
|
* @param {number} width
|
|
770
770
|
* @returns {string}
|
|
771
771
|
*/
|
|
772
|
-
boxWrap(
|
|
773
|
-
if (width < this.minWidthToWrap) return
|
|
774
|
-
const rawLines =
|
|
772
|
+
boxWrap(str2, width) {
|
|
773
|
+
if (width < this.minWidthToWrap) return str2;
|
|
774
|
+
const rawLines = str2.split(/\r\n|\n/);
|
|
775
775
|
const chunkPattern = /[\s]*[^\s]+/g;
|
|
776
776
|
const wrappedLines = [];
|
|
777
777
|
rawLines.forEach((line2) => {
|
|
@@ -799,9 +799,9 @@ ${itemIndentStr}`);
|
|
|
799
799
|
return wrappedLines.join("\n");
|
|
800
800
|
}
|
|
801
801
|
};
|
|
802
|
-
function stripColor(
|
|
802
|
+
function stripColor(str2) {
|
|
803
803
|
const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
|
|
804
|
-
return
|
|
804
|
+
return str2.replace(sgrPattern, "");
|
|
805
805
|
}
|
|
806
806
|
exports.Help = Help2;
|
|
807
807
|
exports.stripColor = stripColor;
|
|
@@ -1073,9 +1073,9 @@ var require_option = __commonJS({
|
|
|
1073
1073
|
return option.negate === (negativeValue === value);
|
|
1074
1074
|
}
|
|
1075
1075
|
};
|
|
1076
|
-
function camelcase(
|
|
1077
|
-
return
|
|
1078
|
-
return
|
|
1076
|
+
function camelcase(str2) {
|
|
1077
|
+
return str2.split("-").reduce((str3, word) => {
|
|
1078
|
+
return str3 + word[0].toUpperCase() + word.slice(1);
|
|
1079
1079
|
});
|
|
1080
1080
|
}
|
|
1081
1081
|
function splitOptionFlags(flags) {
|
|
@@ -1258,14 +1258,14 @@ var require_command = __commonJS({
|
|
|
1258
1258
|
this._showSuggestionAfterError = true;
|
|
1259
1259
|
this._savedState = null;
|
|
1260
1260
|
this._outputConfiguration = {
|
|
1261
|
-
writeOut: (
|
|
1262
|
-
writeErr: (
|
|
1263
|
-
outputError: (
|
|
1261
|
+
writeOut: (str2) => process3.stdout.write(str2),
|
|
1262
|
+
writeErr: (str2) => process3.stderr.write(str2),
|
|
1263
|
+
outputError: (str2, write) => write(str2),
|
|
1264
1264
|
getOutHelpWidth: () => process3.stdout.isTTY ? process3.stdout.columns : void 0,
|
|
1265
1265
|
getErrHelpWidth: () => process3.stderr.isTTY ? process3.stderr.columns : void 0,
|
|
1266
1266
|
getOutHasColors: () => useColor() ?? (process3.stdout.isTTY && process3.stdout.hasColors?.()),
|
|
1267
1267
|
getErrHasColors: () => useColor() ?? (process3.stderr.isTTY && process3.stderr.hasColors?.()),
|
|
1268
|
-
stripColor: (
|
|
1268
|
+
stripColor: (str2) => stripColor(str2)
|
|
1269
1269
|
};
|
|
1270
1270
|
this._hidden = false;
|
|
1271
1271
|
this._helpOption = void 0;
|
|
@@ -2989,18 +2989,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2989
2989
|
* @param {string} [description]
|
|
2990
2990
|
* @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments
|
|
2991
2991
|
*/
|
|
2992
|
-
version(
|
|
2993
|
-
if (
|
|
2994
|
-
this._version =
|
|
2992
|
+
version(str2, flags, description) {
|
|
2993
|
+
if (str2 === void 0) return this._version;
|
|
2994
|
+
this._version = str2;
|
|
2995
2995
|
flags = flags || "-V, --version";
|
|
2996
2996
|
description = description || "output the version number";
|
|
2997
2997
|
const versionOption = this.createOption(flags, description);
|
|
2998
2998
|
this._versionOptionName = versionOption.attributeName();
|
|
2999
2999
|
this._registerOption(versionOption);
|
|
3000
3000
|
this.on("option:" + versionOption.name(), () => {
|
|
3001
|
-
this._outputConfiguration.writeOut(`${
|
|
3001
|
+
this._outputConfiguration.writeOut(`${str2}
|
|
3002
3002
|
`);
|
|
3003
|
-
this._exit(0, "commander.version",
|
|
3003
|
+
this._exit(0, "commander.version", str2);
|
|
3004
3004
|
});
|
|
3005
3005
|
return this;
|
|
3006
3006
|
}
|
|
@@ -3011,10 +3011,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3011
3011
|
* @param {object} [argsDescription]
|
|
3012
3012
|
* @return {(string|Command)}
|
|
3013
3013
|
*/
|
|
3014
|
-
description(
|
|
3015
|
-
if (
|
|
3014
|
+
description(str2, argsDescription) {
|
|
3015
|
+
if (str2 === void 0 && argsDescription === void 0)
|
|
3016
3016
|
return this._description;
|
|
3017
|
-
this._description =
|
|
3017
|
+
this._description = str2;
|
|
3018
3018
|
if (argsDescription) {
|
|
3019
3019
|
this._argsDescription = argsDescription;
|
|
3020
3020
|
}
|
|
@@ -3026,9 +3026,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3026
3026
|
* @param {string} [str]
|
|
3027
3027
|
* @return {(string|Command)}
|
|
3028
3028
|
*/
|
|
3029
|
-
summary(
|
|
3030
|
-
if (
|
|
3031
|
-
this._summary =
|
|
3029
|
+
summary(str2) {
|
|
3030
|
+
if (str2 === void 0) return this._summary;
|
|
3031
|
+
this._summary = str2;
|
|
3032
3032
|
return this;
|
|
3033
3033
|
}
|
|
3034
3034
|
/**
|
|
@@ -3076,8 +3076,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3076
3076
|
* @param {string} [str]
|
|
3077
3077
|
* @return {(string|Command)}
|
|
3078
3078
|
*/
|
|
3079
|
-
usage(
|
|
3080
|
-
if (
|
|
3079
|
+
usage(str2) {
|
|
3080
|
+
if (str2 === void 0) {
|
|
3081
3081
|
if (this._usage) return this._usage;
|
|
3082
3082
|
const args = this.registeredArguments.map((arg) => {
|
|
3083
3083
|
return humanReadableArgName(arg);
|
|
@@ -3088,7 +3088,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3088
3088
|
this.registeredArguments.length ? args : []
|
|
3089
3089
|
).join(" ");
|
|
3090
3090
|
}
|
|
3091
|
-
this._usage =
|
|
3091
|
+
this._usage = str2;
|
|
3092
3092
|
return this;
|
|
3093
3093
|
}
|
|
3094
3094
|
/**
|
|
@@ -3097,9 +3097,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3097
3097
|
* @param {string} [str]
|
|
3098
3098
|
* @return {(string|Command)}
|
|
3099
3099
|
*/
|
|
3100
|
-
name(
|
|
3101
|
-
if (
|
|
3102
|
-
this._name =
|
|
3100
|
+
name(str2) {
|
|
3101
|
+
if (str2 === void 0) return this._name;
|
|
3102
|
+
this._name = str2;
|
|
3103
3103
|
return this;
|
|
3104
3104
|
}
|
|
3105
3105
|
/**
|
|
@@ -3233,17 +3233,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3233
3233
|
let hasColors;
|
|
3234
3234
|
let helpWidth;
|
|
3235
3235
|
if (error48) {
|
|
3236
|
-
baseWrite = (
|
|
3236
|
+
baseWrite = (str2) => this._outputConfiguration.writeErr(str2);
|
|
3237
3237
|
hasColors = this._outputConfiguration.getErrHasColors();
|
|
3238
3238
|
helpWidth = this._outputConfiguration.getErrHelpWidth();
|
|
3239
3239
|
} else {
|
|
3240
|
-
baseWrite = (
|
|
3240
|
+
baseWrite = (str2) => this._outputConfiguration.writeOut(str2);
|
|
3241
3241
|
hasColors = this._outputConfiguration.getOutHasColors();
|
|
3242
3242
|
helpWidth = this._outputConfiguration.getOutHelpWidth();
|
|
3243
3243
|
}
|
|
3244
|
-
const write = (
|
|
3245
|
-
if (!hasColors)
|
|
3246
|
-
return baseWrite(
|
|
3244
|
+
const write = (str2) => {
|
|
3245
|
+
if (!hasColors) str2 = this._outputConfiguration.stripColor(str2);
|
|
3246
|
+
return baseWrite(str2);
|
|
3247
3247
|
};
|
|
3248
3248
|
return { error: error48, write, hasColors, helpWidth };
|
|
3249
3249
|
}
|
|
@@ -3612,39 +3612,39 @@ var require_utils = __commonJS({
|
|
|
3612
3612
|
function codeRegex(capture) {
|
|
3613
3613
|
return capture ? /\u001b\[((?:\d*;){0,5}\d*)m/g : /\u001b\[(?:\d*;){0,5}\d*m/g;
|
|
3614
3614
|
}
|
|
3615
|
-
function strlen(
|
|
3615
|
+
function strlen(str2) {
|
|
3616
3616
|
let code = codeRegex();
|
|
3617
|
-
let stripped = ("" +
|
|
3617
|
+
let stripped = ("" + str2).replace(code, "");
|
|
3618
3618
|
let split = stripped.split("\n");
|
|
3619
3619
|
return split.reduce(function(memo, s) {
|
|
3620
3620
|
return stringWidth(s) > memo ? stringWidth(s) : memo;
|
|
3621
3621
|
}, 0);
|
|
3622
3622
|
}
|
|
3623
|
-
function repeat(
|
|
3624
|
-
return Array(times + 1).join(
|
|
3623
|
+
function repeat(str2, times) {
|
|
3624
|
+
return Array(times + 1).join(str2);
|
|
3625
3625
|
}
|
|
3626
|
-
function pad(
|
|
3627
|
-
let length = strlen(
|
|
3626
|
+
function pad(str2, len, pad2, dir) {
|
|
3627
|
+
let length = strlen(str2);
|
|
3628
3628
|
if (len + 1 >= length) {
|
|
3629
3629
|
let padlen = len - length;
|
|
3630
3630
|
switch (dir) {
|
|
3631
3631
|
case "right": {
|
|
3632
|
-
|
|
3632
|
+
str2 = repeat(pad2, padlen) + str2;
|
|
3633
3633
|
break;
|
|
3634
3634
|
}
|
|
3635
3635
|
case "center": {
|
|
3636
3636
|
let right = Math.ceil(padlen / 2);
|
|
3637
3637
|
let left = padlen - right;
|
|
3638
|
-
|
|
3638
|
+
str2 = repeat(pad2, left) + str2 + repeat(pad2, right);
|
|
3639
3639
|
break;
|
|
3640
3640
|
}
|
|
3641
3641
|
default: {
|
|
3642
|
-
|
|
3642
|
+
str2 = str2 + repeat(pad2, padlen);
|
|
3643
3643
|
break;
|
|
3644
3644
|
}
|
|
3645
3645
|
}
|
|
3646
3646
|
}
|
|
3647
|
-
return
|
|
3647
|
+
return str2;
|
|
3648
3648
|
}
|
|
3649
3649
|
var codeCache = {};
|
|
3650
3650
|
function addToCodeCache(name, on, off) {
|
|
@@ -3728,25 +3728,25 @@ var require_utils = __commonJS({
|
|
|
3728
3728
|
}
|
|
3729
3729
|
return ret;
|
|
3730
3730
|
}
|
|
3731
|
-
function truncateWidth(
|
|
3732
|
-
if (
|
|
3733
|
-
return
|
|
3731
|
+
function truncateWidth(str2, desiredLength) {
|
|
3732
|
+
if (str2.length === strlen(str2)) {
|
|
3733
|
+
return str2.substr(0, desiredLength);
|
|
3734
3734
|
}
|
|
3735
|
-
while (strlen(
|
|
3736
|
-
|
|
3735
|
+
while (strlen(str2) > desiredLength) {
|
|
3736
|
+
str2 = str2.slice(0, -1);
|
|
3737
3737
|
}
|
|
3738
|
-
return
|
|
3738
|
+
return str2;
|
|
3739
3739
|
}
|
|
3740
|
-
function truncateWidthWithAnsi(
|
|
3740
|
+
function truncateWidthWithAnsi(str2, desiredLength) {
|
|
3741
3741
|
let code = codeRegex(true);
|
|
3742
|
-
let split =
|
|
3742
|
+
let split = str2.split(codeRegex());
|
|
3743
3743
|
let splitIndex = 0;
|
|
3744
3744
|
let retLen = 0;
|
|
3745
3745
|
let ret = "";
|
|
3746
3746
|
let myArray;
|
|
3747
3747
|
let state = {};
|
|
3748
3748
|
while (retLen < desiredLength) {
|
|
3749
|
-
myArray = code.exec(
|
|
3749
|
+
myArray = code.exec(str2);
|
|
3750
3750
|
let toAdd = split[splitIndex];
|
|
3751
3751
|
splitIndex++;
|
|
3752
3752
|
if (retLen + strlen(toAdd) > desiredLength) {
|
|
@@ -3764,17 +3764,17 @@ var require_utils = __commonJS({
|
|
|
3764
3764
|
}
|
|
3765
3765
|
return unwindState(state, ret);
|
|
3766
3766
|
}
|
|
3767
|
-
function truncate(
|
|
3767
|
+
function truncate(str2, desiredLength, truncateChar) {
|
|
3768
3768
|
truncateChar = truncateChar || "\u2026";
|
|
3769
|
-
let lengthOfStr = strlen(
|
|
3769
|
+
let lengthOfStr = strlen(str2);
|
|
3770
3770
|
if (lengthOfStr <= desiredLength) {
|
|
3771
|
-
return
|
|
3771
|
+
return str2;
|
|
3772
3772
|
}
|
|
3773
3773
|
desiredLength -= strlen(truncateChar);
|
|
3774
|
-
let ret = truncateWidthWithAnsi(
|
|
3774
|
+
let ret = truncateWidthWithAnsi(str2, desiredLength);
|
|
3775
3775
|
ret += truncateChar;
|
|
3776
3776
|
const hrefTag = "\x1B]8;;\x07";
|
|
3777
|
-
if (
|
|
3777
|
+
if (str2.includes(hrefTag) && !ret.includes(hrefTag)) {
|
|
3778
3778
|
ret += hrefTag;
|
|
3779
3779
|
}
|
|
3780
3780
|
return ret;
|
|
@@ -3853,9 +3853,9 @@ var require_utils = __commonJS({
|
|
|
3853
3853
|
function textWrap(maxLength, input) {
|
|
3854
3854
|
let lines = [];
|
|
3855
3855
|
let line2 = "";
|
|
3856
|
-
function pushLine(
|
|
3856
|
+
function pushLine(str2, ws) {
|
|
3857
3857
|
if (line2.length && ws) line2 += ws;
|
|
3858
|
-
line2 +=
|
|
3858
|
+
line2 += str2;
|
|
3859
3859
|
while (line2.length > maxLength) {
|
|
3860
3860
|
lines.push(line2.slice(0, maxLength));
|
|
3861
3861
|
line2 = line2.slice(maxLength);
|
|
@@ -4444,25 +4444,25 @@ var require_colors = __commonJS({
|
|
|
4444
4444
|
colors.disable = function() {
|
|
4445
4445
|
colors.enabled = false;
|
|
4446
4446
|
};
|
|
4447
|
-
colors.stripColors = colors.strip = function(
|
|
4448
|
-
return ("" +
|
|
4447
|
+
colors.stripColors = colors.strip = function(str2) {
|
|
4448
|
+
return ("" + str2).replace(/\x1B\[\d+m/g, "");
|
|
4449
4449
|
};
|
|
4450
|
-
var stylize = colors.stylize = function stylize2(
|
|
4450
|
+
var stylize = colors.stylize = function stylize2(str2, style) {
|
|
4451
4451
|
if (!colors.enabled) {
|
|
4452
|
-
return
|
|
4452
|
+
return str2 + "";
|
|
4453
4453
|
}
|
|
4454
4454
|
var styleMap = ansiStyles[style];
|
|
4455
4455
|
if (!styleMap && style in colors) {
|
|
4456
|
-
return colors[style](
|
|
4456
|
+
return colors[style](str2);
|
|
4457
4457
|
}
|
|
4458
|
-
return styleMap.open +
|
|
4458
|
+
return styleMap.open + str2 + styleMap.close;
|
|
4459
4459
|
};
|
|
4460
4460
|
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
|
4461
|
-
var escapeStringRegexp = function(
|
|
4462
|
-
if (typeof
|
|
4461
|
+
var escapeStringRegexp = function(str2) {
|
|
4462
|
+
if (typeof str2 !== "string") {
|
|
4463
4463
|
throw new TypeError("Expected a string");
|
|
4464
4464
|
}
|
|
4465
|
-
return
|
|
4465
|
+
return str2.replace(matchOperatorsRe, "\\$&");
|
|
4466
4466
|
};
|
|
4467
4467
|
function build(_styles) {
|
|
4468
4468
|
var builder = function builder2() {
|
|
@@ -4489,29 +4489,29 @@ var require_colors = __commonJS({
|
|
|
4489
4489
|
}, styles);
|
|
4490
4490
|
function applyStyle() {
|
|
4491
4491
|
var args = Array.prototype.slice.call(arguments);
|
|
4492
|
-
var
|
|
4492
|
+
var str2 = args.map(function(arg) {
|
|
4493
4493
|
if (arg != null && arg.constructor === String) {
|
|
4494
4494
|
return arg;
|
|
4495
4495
|
} else {
|
|
4496
4496
|
return util.inspect(arg);
|
|
4497
4497
|
}
|
|
4498
4498
|
}).join(" ");
|
|
4499
|
-
if (!colors.enabled || !
|
|
4500
|
-
return
|
|
4499
|
+
if (!colors.enabled || !str2) {
|
|
4500
|
+
return str2;
|
|
4501
4501
|
}
|
|
4502
|
-
var newLinesPresent =
|
|
4502
|
+
var newLinesPresent = str2.indexOf("\n") != -1;
|
|
4503
4503
|
var nestedStyles = this._styles;
|
|
4504
4504
|
var i = nestedStyles.length;
|
|
4505
4505
|
while (i--) {
|
|
4506
4506
|
var code = ansiStyles[nestedStyles[i]];
|
|
4507
|
-
|
|
4507
|
+
str2 = code.open + str2.replace(code.closeRe, code.open) + code.close;
|
|
4508
4508
|
if (newLinesPresent) {
|
|
4509
|
-
|
|
4509
|
+
str2 = str2.replace(newLineRegex, function(match) {
|
|
4510
4510
|
return code.close + match + code.open;
|
|
4511
4511
|
});
|
|
4512
4512
|
}
|
|
4513
4513
|
}
|
|
4514
|
-
return
|
|
4514
|
+
return str2;
|
|
4515
4515
|
}
|
|
4516
4516
|
colors.setTheme = function(theme) {
|
|
4517
4517
|
if (typeof theme === "string") {
|
|
@@ -4520,15 +4520,15 @@ var require_colors = __commonJS({
|
|
|
4520
4520
|
}
|
|
4521
4521
|
for (var style in theme) {
|
|
4522
4522
|
(function(style2) {
|
|
4523
|
-
colors[style2] = function(
|
|
4523
|
+
colors[style2] = function(str2) {
|
|
4524
4524
|
if (typeof theme[style2] === "object") {
|
|
4525
|
-
var out =
|
|
4525
|
+
var out = str2;
|
|
4526
4526
|
for (var i in theme[style2]) {
|
|
4527
4527
|
out = colors[theme[style2][i]](out);
|
|
4528
4528
|
}
|
|
4529
4529
|
return out;
|
|
4530
4530
|
}
|
|
4531
|
-
return colors[theme[style2]](
|
|
4531
|
+
return colors[theme[style2]](str2);
|
|
4532
4532
|
};
|
|
4533
4533
|
})(style);
|
|
4534
4534
|
}
|
|
@@ -4544,8 +4544,8 @@ var require_colors = __commonJS({
|
|
|
4544
4544
|
});
|
|
4545
4545
|
return ret;
|
|
4546
4546
|
}
|
|
4547
|
-
var sequencer = function sequencer2(map3,
|
|
4548
|
-
var exploded =
|
|
4547
|
+
var sequencer = function sequencer2(map3, str2) {
|
|
4548
|
+
var exploded = str2.split("");
|
|
4549
4549
|
exploded = exploded.map(map3);
|
|
4550
4550
|
return exploded.join("");
|
|
4551
4551
|
};
|
|
@@ -4558,8 +4558,8 @@ var require_colors = __commonJS({
|
|
|
4558
4558
|
colors.maps.random = require_random()(colors);
|
|
4559
4559
|
for (map2 in colors.maps) {
|
|
4560
4560
|
(function(map3) {
|
|
4561
|
-
colors[map3] = function(
|
|
4562
|
-
return sequencer(colors.maps[map3],
|
|
4561
|
+
colors[map3] = function(str2) {
|
|
4562
|
+
return sequencer(colors.maps[map3], str2);
|
|
4563
4563
|
};
|
|
4564
4564
|
})(map2);
|
|
4565
4565
|
}
|
|
@@ -5268,8 +5268,8 @@ var require_table = __commonJS({
|
|
|
5268
5268
|
return result.join("\n");
|
|
5269
5269
|
}
|
|
5270
5270
|
get width() {
|
|
5271
|
-
let
|
|
5272
|
-
return
|
|
5271
|
+
let str2 = this.toString().split("\n");
|
|
5272
|
+
return str2[0].length;
|
|
5273
5273
|
}
|
|
5274
5274
|
};
|
|
5275
5275
|
Table2.reset = () => debug.reset();
|
|
@@ -5278,8 +5278,8 @@ var require_table = __commonJS({
|
|
|
5278
5278
|
row.forEach(function(cell2) {
|
|
5279
5279
|
line2.push(cell2.draw(lineNum));
|
|
5280
5280
|
});
|
|
5281
|
-
let
|
|
5282
|
-
if (
|
|
5281
|
+
let str2 = line2.join("");
|
|
5282
|
+
if (str2.length) result.push(str2);
|
|
5283
5283
|
}
|
|
5284
5284
|
module.exports = Table2;
|
|
5285
5285
|
}
|
|
@@ -6581,6 +6581,7 @@ function toTasqmateError(status, body, retryAfterHeader) {
|
|
|
6581
6581
|
|
|
6582
6582
|
// ../sdk/src/client.ts
|
|
6583
6583
|
var PROJECT_UPDATES_PAGE_MAX = 100;
|
|
6584
|
+
var RUN_HEADER = "x-tasqmate-run";
|
|
6584
6585
|
function assertPrefix(token, prefix, label2) {
|
|
6585
6586
|
if (!token.startsWith(prefix)) {
|
|
6586
6587
|
throw new Error(
|
|
@@ -6614,6 +6615,7 @@ var TasqmateClient = class _TasqmateClient {
|
|
|
6614
6615
|
#baseUrl;
|
|
6615
6616
|
#token;
|
|
6616
6617
|
#fetch;
|
|
6618
|
+
#runId;
|
|
6617
6619
|
/** A client with no credential, for the two anonymous auth calls. */
|
|
6618
6620
|
static anonymous(baseUrl, fetchImpl) {
|
|
6619
6621
|
return new _TasqmateClient({ baseUrl, fetch: fetchImpl });
|
|
@@ -6622,6 +6624,7 @@ var TasqmateClient = class _TasqmateClient {
|
|
|
6622
6624
|
this.#baseUrl = normaliseBaseUrl(options.baseUrl);
|
|
6623
6625
|
this.#token = credential(options.auth);
|
|
6624
6626
|
this.#fetch = options.fetch ?? globalThis.fetch;
|
|
6627
|
+
this.#runId = options.runId === void 0 || options.runId === "" ? void 0 : options.runId;
|
|
6625
6628
|
}
|
|
6626
6629
|
async #request(path, init = {}) {
|
|
6627
6630
|
const { anonymous = false, timeoutMs, ...requestInit } = init;
|
|
@@ -6629,6 +6632,7 @@ var TasqmateClient = class _TasqmateClient {
|
|
|
6629
6632
|
if (!anonymous) {
|
|
6630
6633
|
if (this.#token === void 0) throw noCredentialError();
|
|
6631
6634
|
headers.set("authorization", `Bearer ${this.#token}`);
|
|
6635
|
+
if (this.#runId !== void 0) headers.set(RUN_HEADER, this.#runId);
|
|
6632
6636
|
}
|
|
6633
6637
|
if (requestInit.body !== void 0 && !headers.has("content-type")) {
|
|
6634
6638
|
headers.set("content-type", "application/json");
|
|
@@ -7094,6 +7098,28 @@ var TasqmateClient = class _TasqmateClient {
|
|
|
7094
7098
|
`/workspaces/${encodeURIComponent(slug)}/agents/me/chats/${encodeURIComponent(chatId)}/reply`,
|
|
7095
7099
|
{ method: "POST", body: JSON.stringify(reply) }
|
|
7096
7100
|
),
|
|
7101
|
+
/**
|
|
7102
|
+
* Open a run for one of this agent's wakes (CHAT-2). Opening the same
|
|
7103
|
+
* wake again while its run is still going returns that run.
|
|
7104
|
+
*/
|
|
7105
|
+
openRun: (slug, input) => this.#request(
|
|
7106
|
+
`/workspaces/${encodeURIComponent(slug)}/agents/me/runs`,
|
|
7107
|
+
{ method: "POST", body: JSON.stringify(input) }
|
|
7108
|
+
),
|
|
7109
|
+
/**
|
|
7110
|
+
* Post a batch of a run's steps (at most 100). A `seq` already stored is
|
|
7111
|
+
* skipped, so a retried batch is harmless. The answer says whether
|
|
7112
|
+
* someone pressed Stop.
|
|
7113
|
+
*/
|
|
7114
|
+
postRunEvents: (slug, runId, events) => this.#request(
|
|
7115
|
+
`/workspaces/${encodeURIComponent(slug)}/agents/me/runs/${encodeURIComponent(runId)}/events`,
|
|
7116
|
+
{ method: "POST", body: JSON.stringify({ events }) }
|
|
7117
|
+
),
|
|
7118
|
+
/** End a run: `done`, `failed` or `stopped`, with one line on how it went. */
|
|
7119
|
+
finishRun: (slug, runId, finish) => this.#request(
|
|
7120
|
+
`/workspaces/${encodeURIComponent(slug)}/agents/me/runs/${encodeURIComponent(runId)}/finish`,
|
|
7121
|
+
{ method: "POST", body: JSON.stringify(finish) }
|
|
7122
|
+
),
|
|
7097
7123
|
/** The bridge unpairs itself: its record and this key are revoked. */
|
|
7098
7124
|
unpairBridge: (slug) => this.#request(
|
|
7099
7125
|
`/workspaces/${encodeURIComponent(slug)}/agents/me/bridge`,
|
|
@@ -7320,6 +7346,10 @@ function reportError(error48, io2) {
|
|
|
7320
7346
|
return EXIT_RATE_LIMITED;
|
|
7321
7347
|
}
|
|
7322
7348
|
if (error48 instanceof TasqmatePolicyDeniedError) {
|
|
7349
|
+
if (error48.policyVersion === void 0 && error48.message !== "") {
|
|
7350
|
+
io2.err(`${error48.message.replace(/\.$/, "")}.`);
|
|
7351
|
+
return EXIT_POLICY_DENIED;
|
|
7352
|
+
}
|
|
7323
7353
|
const version2 = error48.policyVersion ?? "?";
|
|
7324
7354
|
const action = error48.action ?? "this action";
|
|
7325
7355
|
io2.err(`Policy v${version2} does not allow ${action}.`);
|
|
@@ -7343,7 +7373,7 @@ function reportError(error48, io2) {
|
|
|
7343
7373
|
// package.json
|
|
7344
7374
|
var package_default = {
|
|
7345
7375
|
name: "tasqmate",
|
|
7346
|
-
version: "0.
|
|
7376
|
+
version: "0.5.0",
|
|
7347
7377
|
description: "Command-line client for Tasqmate, for humans and agents alike. Installs the tasqmate and tasqmate commands.",
|
|
7348
7378
|
keywords: [
|
|
7349
7379
|
"tasqmate",
|
|
@@ -9255,14 +9285,14 @@ function promiseAllObject(promisesObj) {
|
|
|
9255
9285
|
}
|
|
9256
9286
|
function randomString(length = 10) {
|
|
9257
9287
|
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
9258
|
-
let
|
|
9288
|
+
let str2 = "";
|
|
9259
9289
|
for (let i = 0; i < length; i++) {
|
|
9260
|
-
|
|
9290
|
+
str2 += chars[Math.floor(Math.random() * chars.length)];
|
|
9261
9291
|
}
|
|
9262
|
-
return
|
|
9292
|
+
return str2;
|
|
9263
9293
|
}
|
|
9264
|
-
function esc(
|
|
9265
|
-
return JSON.stringify(
|
|
9294
|
+
function esc(str2) {
|
|
9295
|
+
return JSON.stringify(str2);
|
|
9266
9296
|
}
|
|
9267
9297
|
function slugify(input) {
|
|
9268
9298
|
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -9362,8 +9392,8 @@ var getParsedType = (data) => {
|
|
|
9362
9392
|
};
|
|
9363
9393
|
var propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
9364
9394
|
var primitiveTypes = /* @__PURE__ */ new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
|
|
9365
|
-
function escapeRegex(
|
|
9366
|
-
return
|
|
9395
|
+
function escapeRegex(str2) {
|
|
9396
|
+
return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9367
9397
|
}
|
|
9368
9398
|
function clone(inst, def, params) {
|
|
9369
9399
|
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
@@ -22268,6 +22298,104 @@ function fileLog(path, echo, now = () => /* @__PURE__ */ new Date()) {
|
|
|
22268
22298
|
};
|
|
22269
22299
|
}
|
|
22270
22300
|
|
|
22301
|
+
// src/bridge/steps.ts
|
|
22302
|
+
import { isAbsolute, relative } from "path";
|
|
22303
|
+
var noSteps = () => {
|
|
22304
|
+
};
|
|
22305
|
+
function displayPath(path, cwd) {
|
|
22306
|
+
if (!isAbsolute(path)) return path;
|
|
22307
|
+
const inside2 = relative(cwd, path);
|
|
22308
|
+
return inside2 !== "" && !inside2.startsWith("..") && !isAbsolute(inside2) ? inside2 : path;
|
|
22309
|
+
}
|
|
22310
|
+
function lineCount(text) {
|
|
22311
|
+
return text === "" ? 0 : text.split("\n").length;
|
|
22312
|
+
}
|
|
22313
|
+
var textSchema = external_exports.string().min(1);
|
|
22314
|
+
function str(input, ...keys) {
|
|
22315
|
+
for (const key of keys) {
|
|
22316
|
+
const value = textSchema.safeParse(input[key]);
|
|
22317
|
+
if (value.success) return value.data;
|
|
22318
|
+
}
|
|
22319
|
+
return null;
|
|
22320
|
+
}
|
|
22321
|
+
function toolDetail(tool, path, lines) {
|
|
22322
|
+
const detail = { tool };
|
|
22323
|
+
if (path !== null) detail.path = path;
|
|
22324
|
+
if (lines !== void 0) {
|
|
22325
|
+
detail.added = lines.added;
|
|
22326
|
+
if (lines.removed !== void 0) detail.removed = lines.removed;
|
|
22327
|
+
}
|
|
22328
|
+
return detail;
|
|
22329
|
+
}
|
|
22330
|
+
function quoted(text) {
|
|
22331
|
+
const line2 = text.replace(/\s+/g, " ").trim();
|
|
22332
|
+
return `\u201C${line2.length <= 60 ? line2 : `${line2.slice(0, 59)}\u2026`}\u201D`;
|
|
22333
|
+
}
|
|
22334
|
+
function mcpToolName(name) {
|
|
22335
|
+
const parts = name.split("__");
|
|
22336
|
+
return (parts.at(-1) ?? name).replace(/[_-]+/g, " ").trim();
|
|
22337
|
+
}
|
|
22338
|
+
function describeTool(name, input, cwd) {
|
|
22339
|
+
const path = str(input, "file_path", "notebook_path", "path");
|
|
22340
|
+
const shown = path === null ? null : displayPath(path, cwd);
|
|
22341
|
+
const tool = name;
|
|
22342
|
+
switch (name) {
|
|
22343
|
+
case "Read":
|
|
22344
|
+
case "NotebookRead":
|
|
22345
|
+
return { kind: "action", title: `Opened ${shown ?? "a file"}`, detail: toolDetail(tool, shown) };
|
|
22346
|
+
case "Edit":
|
|
22347
|
+
case "MultiEdit":
|
|
22348
|
+
case "NotebookEdit": {
|
|
22349
|
+
const oldText = str(input, "old_string") ?? "";
|
|
22350
|
+
const newText = str(input, "new_string", "new_source") ?? "";
|
|
22351
|
+
return {
|
|
22352
|
+
kind: "action",
|
|
22353
|
+
title: `Edited ${shown ?? "a file"}`,
|
|
22354
|
+
detail: toolDetail(tool, shown, { added: lineCount(newText), removed: lineCount(oldText) })
|
|
22355
|
+
};
|
|
22356
|
+
}
|
|
22357
|
+
case "Write":
|
|
22358
|
+
return {
|
|
22359
|
+
kind: "action",
|
|
22360
|
+
title: `Wrote ${shown ?? "a file"}`,
|
|
22361
|
+
detail: toolDetail(tool, shown, { added: lineCount(str(input, "content") ?? "") })
|
|
22362
|
+
};
|
|
22363
|
+
case "Glob":
|
|
22364
|
+
return { kind: "action", title: `Listed files matching ${quoted(str(input, "pattern") ?? "*")}`, detail: { tool } };
|
|
22365
|
+
case "Grep":
|
|
22366
|
+
return { kind: "action", title: `Searched for ${quoted(str(input, "pattern") ?? "")}`, detail: { tool } };
|
|
22367
|
+
case "Bash":
|
|
22368
|
+
return { kind: "action", title: `Ran ${quoted(str(input, "command") ?? "a command")}`, detail: { tool } };
|
|
22369
|
+
default:
|
|
22370
|
+
if (name.startsWith("mcp__")) {
|
|
22371
|
+
return { kind: "action", title: `Tasqmate: ${mcpToolName(name)}`, detail: { tool } };
|
|
22372
|
+
}
|
|
22373
|
+
return { kind: "action", title: `Used ${name}`, detail: { tool } };
|
|
22374
|
+
}
|
|
22375
|
+
}
|
|
22376
|
+
function planStep(entries) {
|
|
22377
|
+
const done = entries.filter((entry) => entry.status === "completed").length;
|
|
22378
|
+
return {
|
|
22379
|
+
kind: "plan",
|
|
22380
|
+
title: `Plan \xB7 ${done} of ${entries.length} done`,
|
|
22381
|
+
detail: { entries: entries.slice(0, 50).map((entry) => ({ ...entry, text: entry.text.slice(0, 300) })) }
|
|
22382
|
+
};
|
|
22383
|
+
}
|
|
22384
|
+
function planStatus(status) {
|
|
22385
|
+
if (status === "completed" || status === "done") return "completed";
|
|
22386
|
+
if (status === "in_progress" || status === "inProgress" || status === "active") return "in_progress";
|
|
22387
|
+
return "pending";
|
|
22388
|
+
}
|
|
22389
|
+
function thoughtStep(text) {
|
|
22390
|
+
return { kind: "thought", title: "Thinking\u2026", detail: { text } };
|
|
22391
|
+
}
|
|
22392
|
+
function messageStep(text) {
|
|
22393
|
+
return { kind: "message", title: text.replace(/\s+/g, " ").trim().slice(0, 200) || "Reply", detail: { text } };
|
|
22394
|
+
}
|
|
22395
|
+
function errorStep(text) {
|
|
22396
|
+
return { kind: "error", title: text };
|
|
22397
|
+
}
|
|
22398
|
+
|
|
22271
22399
|
// src/bridge/adapters/claude.ts
|
|
22272
22400
|
var CLAUDE_SDK_PACKAGE = "@anthropic-ai/claude-agent-sdk";
|
|
22273
22401
|
var CLAUDE_SDK_RANGE = "^0.3.314";
|
|
@@ -22305,8 +22433,8 @@ var PARENT_SESSION_VARS = [
|
|
|
22305
22433
|
"CLAUDE_CODE_SSE_PORT",
|
|
22306
22434
|
"CLAUDE_PID"
|
|
22307
22435
|
];
|
|
22308
|
-
function runEnvironment(base,
|
|
22309
|
-
const env = { ...base, ...
|
|
22436
|
+
function runEnvironment(base, tasqmateEnv2) {
|
|
22437
|
+
const env = { ...base, ...tasqmateEnv2, CLAUDE_AGENT_SDK_CLIENT_APP: "tasqmate-bridge" };
|
|
22310
22438
|
for (const name of PARENT_SESSION_VARS) delete env[name];
|
|
22311
22439
|
return env;
|
|
22312
22440
|
}
|
|
@@ -22323,9 +22451,41 @@ var resultSchema = external_exports.object({
|
|
|
22323
22451
|
var assistantSchema = external_exports.object({
|
|
22324
22452
|
type: external_exports.literal("assistant"),
|
|
22325
22453
|
message: external_exports.object({
|
|
22326
|
-
content: external_exports.array(
|
|
22454
|
+
content: external_exports.array(
|
|
22455
|
+
external_exports.object({
|
|
22456
|
+
type: external_exports.string(),
|
|
22457
|
+
text: external_exports.string().optional(),
|
|
22458
|
+
/** A `thinking` block's text. */
|
|
22459
|
+
thinking: external_exports.string().optional(),
|
|
22460
|
+
/** A `tool_use` block's tool and input. */
|
|
22461
|
+
name: external_exports.string().optional(),
|
|
22462
|
+
input: external_exports.json().optional()
|
|
22463
|
+
})
|
|
22464
|
+
)
|
|
22327
22465
|
})
|
|
22328
22466
|
});
|
|
22467
|
+
var todosSchema = external_exports.object({
|
|
22468
|
+
todos: external_exports.array(external_exports.object({ content: external_exports.string(), status: external_exports.string() }))
|
|
22469
|
+
});
|
|
22470
|
+
function reportClaudeBlocks(blocks, cwd, step) {
|
|
22471
|
+
for (const block of blocks) {
|
|
22472
|
+
if (block.type === "thinking" && block.thinking?.trim()) {
|
|
22473
|
+
step(thoughtStep(block.thinking.trim()));
|
|
22474
|
+
} else if (block.type === "text" && block.text?.trim()) {
|
|
22475
|
+
step(messageStep(block.text.trim()));
|
|
22476
|
+
} else if (block.type === "tool_use" && block.name !== void 0) {
|
|
22477
|
+
const input = asToolInput(block.input ?? {});
|
|
22478
|
+
if (block.name === "TodoWrite") {
|
|
22479
|
+
const todos = todosSchema.safeParse(input);
|
|
22480
|
+
if (todos.success) {
|
|
22481
|
+
step(planStep(todos.data.todos.map((todo) => ({ text: todo.content, status: planStatus(todo.status) }))));
|
|
22482
|
+
continue;
|
|
22483
|
+
}
|
|
22484
|
+
}
|
|
22485
|
+
step(describeTool(block.name, input, cwd));
|
|
22486
|
+
}
|
|
22487
|
+
}
|
|
22488
|
+
}
|
|
22329
22489
|
var initSchema = external_exports.object({
|
|
22330
22490
|
type: external_exports.literal("system"),
|
|
22331
22491
|
subtype: external_exports.literal("init"),
|
|
@@ -22409,6 +22569,7 @@ function claudeAdapter(sdk) {
|
|
|
22409
22569
|
const assistant = assistantSchema.safeParse(message);
|
|
22410
22570
|
if (assistant.success) {
|
|
22411
22571
|
assistantTurns += 1;
|
|
22572
|
+
reportClaudeBlocks(assistant.data.message.content, run.cwd, run.step ?? noSteps);
|
|
22412
22573
|
const text = assistant.data.message.content.flatMap((block) => block.type === "text" && block.text ? [block.text] : []).join("\n").trim();
|
|
22413
22574
|
if (text !== "") lastText = text;
|
|
22414
22575
|
}
|
|
@@ -22448,7 +22609,7 @@ function claudeAdapter(sdk) {
|
|
|
22448
22609
|
// src/bridge/adapters/codex.ts
|
|
22449
22610
|
import { spawn } from "child_process";
|
|
22450
22611
|
import { createInterface as createInterface2 } from "readline";
|
|
22451
|
-
var CODEX_MCP_ENV = ["TASQMATE_API_KEY", "TASQMATE_API_URL", "TASQMATE_WORKSPACE"];
|
|
22612
|
+
var CODEX_MCP_ENV = ["TASQMATE_API_KEY", "TASQMATE_API_URL", "TASQMATE_WORKSPACE", "TASQMATE_RUN_ID"];
|
|
22452
22613
|
var responseSchema = external_exports.object({
|
|
22453
22614
|
id: external_exports.union([external_exports.number(), external_exports.string()]),
|
|
22454
22615
|
result: external_exports.json().optional(),
|
|
@@ -22472,11 +22633,57 @@ var itemSchema = external_exports.object({
|
|
|
22472
22633
|
item: external_exports.object({
|
|
22473
22634
|
id: external_exports.string(),
|
|
22474
22635
|
type: external_exports.string(),
|
|
22475
|
-
changes: external_exports.array(
|
|
22636
|
+
changes: external_exports.array(
|
|
22637
|
+
external_exports.object({
|
|
22638
|
+
path: external_exports.string(),
|
|
22639
|
+
/** `add`, `delete` or `update`, as a string or `{ type }`. */
|
|
22640
|
+
kind: external_exports.union([external_exports.string(), external_exports.object({ type: external_exports.string() }).transform((kind) => kind.type)]).optional()
|
|
22641
|
+
})
|
|
22642
|
+
).optional(),
|
|
22476
22643
|
/** An `agentMessage` item's text: the last one is the turn's answer. */
|
|
22477
|
-
text: external_exports.string().optional()
|
|
22644
|
+
text: external_exports.string().optional(),
|
|
22645
|
+
/** A `reasoning` item's summary. */
|
|
22646
|
+
summary: external_exports.array(external_exports.string()).optional(),
|
|
22647
|
+
/** A `commandExecution` item's command line. */
|
|
22648
|
+
command: external_exports.string().optional(),
|
|
22649
|
+
/** An `mcpToolCall` item's server and tool. */
|
|
22650
|
+
server: external_exports.string().optional(),
|
|
22651
|
+
tool: external_exports.string().optional()
|
|
22478
22652
|
})
|
|
22479
22653
|
});
|
|
22654
|
+
var deltaSchema = external_exports.object({ itemId: external_exports.string(), delta: external_exports.string() });
|
|
22655
|
+
var planUpdateSchema = external_exports.object({
|
|
22656
|
+
plan: external_exports.array(external_exports.object({ step: external_exports.string(), status: external_exports.string() }))
|
|
22657
|
+
});
|
|
22658
|
+
function changeVerb(kind) {
|
|
22659
|
+
if (kind === "add") return "Created";
|
|
22660
|
+
if (kind === "delete") return "Deleted";
|
|
22661
|
+
return "Edited";
|
|
22662
|
+
}
|
|
22663
|
+
function codexItemSteps(item, cwd) {
|
|
22664
|
+
switch (item.type) {
|
|
22665
|
+
case "reasoning": {
|
|
22666
|
+
const text = (item.summary ?? []).join("\n").trim();
|
|
22667
|
+
return text === "" ? [] : [thoughtStep(text)];
|
|
22668
|
+
}
|
|
22669
|
+
case "commandExecution": {
|
|
22670
|
+
const line2 = (item.command ?? "a command").replace(/\s+/g, " ").trim();
|
|
22671
|
+
return [{ kind: "action", title: `Ran \u201C${line2.length <= 60 ? line2 : `${line2.slice(0, 59)}\u2026`}\u201D`, detail: { tool: "commandExecution" } }];
|
|
22672
|
+
}
|
|
22673
|
+
case "fileChange":
|
|
22674
|
+
return (item.changes ?? []).map((change) => {
|
|
22675
|
+
const path = displayPath(change.path, cwd);
|
|
22676
|
+
return { kind: "action", title: `${changeVerb(change.kind)} ${path}`, detail: { tool: "fileChange", path } };
|
|
22677
|
+
});
|
|
22678
|
+
case "mcpToolCall":
|
|
22679
|
+
case "dynamicToolCall": {
|
|
22680
|
+
const name = (item.tool ?? "a tool").replace(/[_-]+/g, " ");
|
|
22681
|
+
return [{ kind: "action", title: item.server === "tasqmate" ? `Tasqmate: ${name}` : `Used ${name}`, detail: { tool: item.tool ?? item.type } }];
|
|
22682
|
+
}
|
|
22683
|
+
default:
|
|
22684
|
+
return [];
|
|
22685
|
+
}
|
|
22686
|
+
}
|
|
22480
22687
|
var commandApprovalSchema = external_exports.object({
|
|
22481
22688
|
itemId: external_exports.string(),
|
|
22482
22689
|
command: external_exports.string().nullable().optional()
|
|
@@ -22564,6 +22771,8 @@ function codexAdapter(version2, spawnImpl = spawnCodex) {
|
|
|
22564
22771
|
let actions = 0;
|
|
22565
22772
|
let settled = false;
|
|
22566
22773
|
let lastMessage = null;
|
|
22774
|
+
const step = run.step ?? noSteps;
|
|
22775
|
+
const streamed = /* @__PURE__ */ new Set();
|
|
22567
22776
|
const finish = (result) => {
|
|
22568
22777
|
if (settled) return;
|
|
22569
22778
|
settled = true;
|
|
@@ -22627,12 +22836,31 @@ function codexAdapter(version2, spawnImpl = spawnCodex) {
|
|
|
22627
22836
|
}
|
|
22628
22837
|
};
|
|
22629
22838
|
peer.onNotification = (method, params) => {
|
|
22839
|
+
if (method === "item/agentMessage/delta") {
|
|
22840
|
+
const parsed = deltaSchema.safeParse(params);
|
|
22841
|
+
if (parsed.success && parsed.data.delta !== "") {
|
|
22842
|
+
streamed.add(parsed.data.itemId);
|
|
22843
|
+
step(messageStep(parsed.data.delta));
|
|
22844
|
+
}
|
|
22845
|
+
return;
|
|
22846
|
+
}
|
|
22847
|
+
if (method === "turn/plan/updated") {
|
|
22848
|
+
const parsed = planUpdateSchema.safeParse(params);
|
|
22849
|
+
if (parsed.success) {
|
|
22850
|
+
step(planStep(parsed.data.plan.map((entry) => ({ text: entry.step, status: planStatus(entry.status) }))));
|
|
22851
|
+
}
|
|
22852
|
+
return;
|
|
22853
|
+
}
|
|
22630
22854
|
if (method === "item/started" || method === "item/completed") {
|
|
22631
22855
|
const parsed = itemSchema.safeParse(params);
|
|
22632
22856
|
if (!parsed.success) return;
|
|
22633
22857
|
if (method === "item/completed" && parsed.data.item.type === "agentMessage") {
|
|
22634
22858
|
const text = parsed.data.item.text?.trim() ?? "";
|
|
22635
22859
|
if (text !== "") lastMessage = text;
|
|
22860
|
+
if (text !== "" && !streamed.has(parsed.data.item.id)) step(messageStep(text));
|
|
22861
|
+
}
|
|
22862
|
+
if (method === "item/completed") {
|
|
22863
|
+
for (const itemStep of codexItemSteps(parsed.data.item, run.cwd)) step(itemStep);
|
|
22636
22864
|
}
|
|
22637
22865
|
if (parsed.data.item.changes !== void 0) {
|
|
22638
22866
|
changes.set(parsed.data.item.id, parsed.data.item.changes.map((change) => change.path));
|
|
@@ -22718,7 +22946,7 @@ import { createInterface as createInterface3 } from "readline";
|
|
|
22718
22946
|
// src/bridge/exec.ts
|
|
22719
22947
|
import { spawn as spawn2 } from "child_process";
|
|
22720
22948
|
import { accessSync, constants } from "fs";
|
|
22721
|
-
import { delimiter, isAbsolute, join as join4 } from "path";
|
|
22949
|
+
import { delimiter, isAbsolute as isAbsolute2, join as join4 } from "path";
|
|
22722
22950
|
var exec = (command, args, options = {}) => new Promise((resolve3) => {
|
|
22723
22951
|
const child = spawn2(command, [...args], {
|
|
22724
22952
|
cwd: options.cwd,
|
|
@@ -22748,7 +22976,7 @@ var exec = (command, args, options = {}) => new Promise((resolve3) => {
|
|
|
22748
22976
|
child.stdin.end(options.input ?? "");
|
|
22749
22977
|
});
|
|
22750
22978
|
function which(name, env = process.env, platform = process.platform) {
|
|
22751
|
-
if (
|
|
22979
|
+
if (isAbsolute2(name)) return isExecutable(name) ? name : null;
|
|
22752
22980
|
const extensions = platform === "win32" ? (env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";") : [""];
|
|
22753
22981
|
for (const dir of (env.PATH ?? "").split(delimiter)) {
|
|
22754
22982
|
if (dir === "") continue;
|
|
@@ -22939,9 +23167,45 @@ var rawEditInputSchema = external_exports.object({
|
|
|
22939
23167
|
var sessionUpdateSchema = external_exports.object({
|
|
22940
23168
|
update: external_exports.object({
|
|
22941
23169
|
sessionUpdate: external_exports.string(),
|
|
22942
|
-
content: external_exports.
|
|
23170
|
+
content: external_exports.unknown().optional(),
|
|
23171
|
+
/** A `tool_call`'s one line and the files it touches. */
|
|
23172
|
+
title: external_exports.string().optional(),
|
|
23173
|
+
kind: external_exports.string().optional(),
|
|
23174
|
+
locations: external_exports.array(external_exports.object({ path: external_exports.string() })).optional(),
|
|
23175
|
+
/** A `plan`'s entries. */
|
|
23176
|
+
entries: external_exports.array(external_exports.object({ content: external_exports.string(), status: external_exports.string() })).optional()
|
|
22943
23177
|
})
|
|
22944
23178
|
});
|
|
23179
|
+
var textContentSchema = external_exports.object({ type: external_exports.literal("text"), text: external_exports.string() });
|
|
23180
|
+
function chunkText(update) {
|
|
23181
|
+
const parsed = textContentSchema.safeParse(update.content);
|
|
23182
|
+
return parsed.success ? parsed.data.text : null;
|
|
23183
|
+
}
|
|
23184
|
+
function acpUpdateStep(update, cwd) {
|
|
23185
|
+
switch (update.sessionUpdate) {
|
|
23186
|
+
case "agent_thought_chunk": {
|
|
23187
|
+
const text = chunkText(update);
|
|
23188
|
+
return text ? thoughtStep(text) : null;
|
|
23189
|
+
}
|
|
23190
|
+
case "agent_message_chunk": {
|
|
23191
|
+
const text = chunkText(update);
|
|
23192
|
+
return text ? messageStep(text) : null;
|
|
23193
|
+
}
|
|
23194
|
+
case "tool_call": {
|
|
23195
|
+
const path = update.locations?.[0]?.path;
|
|
23196
|
+
const shown = path === void 0 ? void 0 : displayPath(path, cwd);
|
|
23197
|
+
return {
|
|
23198
|
+
kind: "action",
|
|
23199
|
+
title: update.title?.trim() || `Used ${update.kind ?? "a tool"}`,
|
|
23200
|
+
detail: toolDetail(update.kind ?? "tool", shown ?? null)
|
|
23201
|
+
};
|
|
23202
|
+
}
|
|
23203
|
+
case "plan":
|
|
23204
|
+
return planStep((update.entries ?? []).map((entry) => ({ text: entry.content, status: planStatus(entry.status) })));
|
|
23205
|
+
default:
|
|
23206
|
+
return null;
|
|
23207
|
+
}
|
|
23208
|
+
}
|
|
22945
23209
|
var initializeResultSchema = external_exports.object({
|
|
22946
23210
|
agentCapabilities: external_exports.object({ loadSession: external_exports.boolean().optional() }).nullable().optional()
|
|
22947
23211
|
});
|
|
@@ -23055,6 +23319,7 @@ function hermesAdapter(version2, spawnImpl = spawnHermes) {
|
|
|
23055
23319
|
let settled = false;
|
|
23056
23320
|
let prompting = false;
|
|
23057
23321
|
let spoken = "";
|
|
23322
|
+
const step = run.step ?? noSteps;
|
|
23058
23323
|
const finish = (result) => {
|
|
23059
23324
|
if (settled) return;
|
|
23060
23325
|
settled = true;
|
|
@@ -23113,8 +23378,10 @@ function hermesAdapter(version2, spawnImpl = spawnHermes) {
|
|
|
23113
23378
|
const parsed = sessionUpdateSchema.safeParse(params);
|
|
23114
23379
|
if (!parsed.success || !prompting) return;
|
|
23115
23380
|
const { update } = parsed.data;
|
|
23381
|
+
const reported = acpUpdateStep(update, run.cwd);
|
|
23382
|
+
if (reported !== null) step(reported);
|
|
23116
23383
|
if (update.sessionUpdate === "agent_message_chunk") {
|
|
23117
|
-
|
|
23384
|
+
spoken += chunkText(update) ?? "";
|
|
23118
23385
|
return;
|
|
23119
23386
|
}
|
|
23120
23387
|
if (update.sessionUpdate !== "tool_call") return;
|
|
@@ -23683,7 +23950,7 @@ import { mkdirSync as mkdirSync5 } from "fs";
|
|
|
23683
23950
|
|
|
23684
23951
|
// src/bridge/guard.ts
|
|
23685
23952
|
import { existsSync as existsSync3, realpathSync } from "fs";
|
|
23686
|
-
import { dirname as dirname2, isAbsolute as
|
|
23953
|
+
import { dirname as dirname2, isAbsolute as isAbsolute3, relative as relative2, resolve, sep } from "path";
|
|
23687
23954
|
var TASQMATE_TOOL_PREFIX = "mcp__tasqmate__";
|
|
23688
23955
|
var READ_TOOLS = /* @__PURE__ */ new Map([
|
|
23689
23956
|
["Read", "file_path"],
|
|
@@ -23717,8 +23984,8 @@ function realish(path) {
|
|
|
23717
23984
|
return resolve(realpathSync(current), ...tail);
|
|
23718
23985
|
}
|
|
23719
23986
|
function inside(root, path) {
|
|
23720
|
-
const rel =
|
|
23721
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
23987
|
+
const rel = relative2(root, path);
|
|
23988
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
|
|
23722
23989
|
}
|
|
23723
23990
|
function createGuard(folder) {
|
|
23724
23991
|
const root = realish(resolve(folder));
|
|
@@ -23729,7 +23996,7 @@ function createGuard(folder) {
|
|
|
23729
23996
|
if (!inside(root, target)) {
|
|
23730
23997
|
return { allow: false, reason: `${path} is outside this run's folder (${root}); edits stay inside it.` };
|
|
23731
23998
|
}
|
|
23732
|
-
const segments =
|
|
23999
|
+
const segments = relative2(root, target).split(sep);
|
|
23733
24000
|
const protectedDir = segments.find((segment) => PROTECTED_DIRS.includes(segment));
|
|
23734
24001
|
if (protectedDir !== void 0) {
|
|
23735
24002
|
return {
|
|
@@ -23746,7 +24013,7 @@ function createGuard(folder) {
|
|
|
23746
24013
|
if (readKey !== void 0) {
|
|
23747
24014
|
const path = pathIn(input, readKey) ?? root;
|
|
23748
24015
|
const pattern = pathIn(input, "pattern");
|
|
23749
|
-
if (tool === "Glob" && pattern !== null &&
|
|
24016
|
+
if (tool === "Glob" && pattern !== null && isAbsolute3(pattern)) {
|
|
23750
24017
|
const fixed = pattern.split(GLOB_CHARS)[0] ?? pattern;
|
|
23751
24018
|
const fixedDecision = decideRead(fixed === "" ? sep : fixed);
|
|
23752
24019
|
if (!fixedDecision.allow) return fixedDecision;
|
|
@@ -23919,7 +24186,10 @@ function buildChatPrompt(input) {
|
|
|
23919
24186
|
"## Rules",
|
|
23920
24187
|
[
|
|
23921
24188
|
"- Your final message is posted in the chat as your reply. Answer there, in plain Markdown; do not post the answer as a comment.",
|
|
23922
|
-
`- Use the ${tools} tools to read and change things in Tasqmate when the request needs it (
|
|
24189
|
+
`- Use the ${tools} tools to read and change things in Tasqmate when the request needs it: create and edit tasks (\`task_create_many\` for several), docs, projects, milestones, labels, initiatives and cycles. What you change shows in the workspace's activity like any teammate's work.`,
|
|
24190
|
+
"- Before a wide or hard-to-undo change (archiving, or more than about ten items at once), say what you will do and wait for a yes. Otherwise just do it.",
|
|
24191
|
+
`- Tasqmate decides what you may do: your policy, and for projects, milestones, labels, initiatives and cycles, whether ${person} could do it themselves. If a tool is refused, don't retry; say what was refused and why.`,
|
|
24192
|
+
'- In your reply, name what you made or changed by its key or name (ENG-42, "Q1 launch"), so it can be found.',
|
|
23923
24193
|
...input.harness === "hermes_acp" ? [
|
|
23924
24194
|
"- Edit files only inside your working folder; edits anywhere else are refused. Commands that need approval are refused on this bridge; if you need one, say what and why in your reply instead."
|
|
23925
24195
|
] : [
|
|
@@ -23945,6 +24215,117 @@ function buildChatPrompt(input) {
|
|
|
23945
24215
|
return sections.join("\n\n");
|
|
23946
24216
|
}
|
|
23947
24217
|
|
|
24218
|
+
// src/bridge/run-events.ts
|
|
24219
|
+
var FLUSH_MS = 300;
|
|
24220
|
+
var STOP_POLL_MS = 1e3;
|
|
24221
|
+
var MAX_EVENTS = 500;
|
|
24222
|
+
var BATCH_MAX = 100;
|
|
24223
|
+
var DETAIL_MAX_BYTES = 4096;
|
|
24224
|
+
var CHATTER_LIMIT = 400;
|
|
24225
|
+
var TEXT_MAX = 3e3;
|
|
24226
|
+
var TITLE_MAX = 200;
|
|
24227
|
+
function byteLength(value) {
|
|
24228
|
+
return new TextEncoder().encode(JSON.stringify(value)).length;
|
|
24229
|
+
}
|
|
24230
|
+
function clip(text, max) {
|
|
24231
|
+
return text.length <= max ? text : `${text.slice(0, max - 1)}\u2026`;
|
|
24232
|
+
}
|
|
24233
|
+
function toEventInput(step, seq, at) {
|
|
24234
|
+
const title = clip(step.title.replace(/\s+/g, " ").trim(), TITLE_MAX) || step.kind;
|
|
24235
|
+
let detail = step.detail ?? null;
|
|
24236
|
+
if (detail?.text !== void 0) detail = { ...detail, text: clip(detail.text, TEXT_MAX) };
|
|
24237
|
+
if (detail !== null && byteLength(detail) > DETAIL_MAX_BYTES) {
|
|
24238
|
+
detail = detail.text === void 0 ? null : { text: clip(detail.text, 1e3) };
|
|
24239
|
+
}
|
|
24240
|
+
return { seq, kind: step.kind, title, detail, at: at.toISOString() };
|
|
24241
|
+
}
|
|
24242
|
+
function createRunReporter(options) {
|
|
24243
|
+
const { client, slug, runId, log } = options;
|
|
24244
|
+
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
24245
|
+
const stopPollMs = options.stopPollMs ?? STOP_POLL_MS;
|
|
24246
|
+
const queue = [];
|
|
24247
|
+
const stopListeners = [];
|
|
24248
|
+
let seq = 0;
|
|
24249
|
+
let sending = null;
|
|
24250
|
+
let sendingCount = 0;
|
|
24251
|
+
let lastContact = now().getTime();
|
|
24252
|
+
let stopRequested = false;
|
|
24253
|
+
let gone = false;
|
|
24254
|
+
let warned = false;
|
|
24255
|
+
const send = async () => {
|
|
24256
|
+
if (gone) return;
|
|
24257
|
+
const batch = queue.slice(0, BATCH_MAX);
|
|
24258
|
+
sendingCount = batch.length;
|
|
24259
|
+
try {
|
|
24260
|
+
const answer = await client.postRunEvents(slug, runId, batch);
|
|
24261
|
+
queue.splice(0, batch.length);
|
|
24262
|
+
lastContact = now().getTime();
|
|
24263
|
+
warned = false;
|
|
24264
|
+
if (answer.stopRequested && !stopRequested) {
|
|
24265
|
+
stopRequested = true;
|
|
24266
|
+
log.info("someone pressed Stop in Tasqmate; stopping the run");
|
|
24267
|
+
for (const listener of stopListeners) listener();
|
|
24268
|
+
}
|
|
24269
|
+
} catch (error48) {
|
|
24270
|
+
if (error48 instanceof TasqmateApiError && (error48.status === 404 || error48.status === 400)) {
|
|
24271
|
+
gone = true;
|
|
24272
|
+
queue.length = 0;
|
|
24273
|
+
log.warn(`the run's steps can't be posted (${error48.message}); working on without them`);
|
|
24274
|
+
return;
|
|
24275
|
+
}
|
|
24276
|
+
if (!warned) log.warn(`could not post the run's steps (${error48 instanceof Error ? error48.message : String(error48)}); retrying`);
|
|
24277
|
+
warned = true;
|
|
24278
|
+
} finally {
|
|
24279
|
+
sendingCount = 0;
|
|
24280
|
+
}
|
|
24281
|
+
};
|
|
24282
|
+
const tick = () => {
|
|
24283
|
+
if (sending !== null || gone) return;
|
|
24284
|
+
const due = queue.length > 0 || now().getTime() - lastContact >= stopPollMs;
|
|
24285
|
+
if (!due) return;
|
|
24286
|
+
sending = send().finally(() => {
|
|
24287
|
+
sending = null;
|
|
24288
|
+
});
|
|
24289
|
+
};
|
|
24290
|
+
const timer = setInterval(tick, options.flushMs ?? FLUSH_MS);
|
|
24291
|
+
timer.unref?.();
|
|
24292
|
+
return {
|
|
24293
|
+
push: (step) => {
|
|
24294
|
+
if (gone) return;
|
|
24295
|
+
const chatter = step.kind === "message" || step.kind === "thought";
|
|
24296
|
+
if (seq >= MAX_EVENTS - 1 && step.kind !== "error") return;
|
|
24297
|
+
if (seq >= MAX_EVENTS) return;
|
|
24298
|
+
const last = queue.at(-1);
|
|
24299
|
+
const lastIsWaiting = last !== void 0 && queue.length > sendingCount;
|
|
24300
|
+
if (chatter && lastIsWaiting && last.kind === step.kind && (last.detail?.text?.length ?? 0) + (step.detail?.text?.length ?? 0) <= TEXT_MAX) {
|
|
24301
|
+
const text = `${last.detail?.text ?? ""}${step.detail?.text ?? ""}`;
|
|
24302
|
+
last.detail = { text };
|
|
24303
|
+
if (step.kind === "message") last.title = clip(text.replace(/\s+/g, " ").trim(), TITLE_MAX) || last.title;
|
|
24304
|
+
return;
|
|
24305
|
+
}
|
|
24306
|
+
if (chatter && seq >= CHATTER_LIMIT) return;
|
|
24307
|
+
seq += 1;
|
|
24308
|
+
queue.push(toEventInput(step, seq, now()));
|
|
24309
|
+
},
|
|
24310
|
+
get stopRequested() {
|
|
24311
|
+
return stopRequested;
|
|
24312
|
+
},
|
|
24313
|
+
onStop: (listener) => {
|
|
24314
|
+
stopListeners.push(listener);
|
|
24315
|
+
},
|
|
24316
|
+
close: async () => {
|
|
24317
|
+
clearInterval(timer);
|
|
24318
|
+
if (sending !== null) await sending;
|
|
24319
|
+
for (let failures = 0; failures < 3 && queue.length > 0 && !gone; ) {
|
|
24320
|
+
const before = queue.length;
|
|
24321
|
+
await send();
|
|
24322
|
+
failures = queue.length < before ? 0 : failures + 1;
|
|
24323
|
+
}
|
|
24324
|
+
if (queue.length > 0 && !gone) log.warn(`dropped ${queue.length} steps the server did not take`);
|
|
24325
|
+
}
|
|
24326
|
+
};
|
|
24327
|
+
}
|
|
24328
|
+
|
|
23948
24329
|
// src/bridge/loop.ts
|
|
23949
24330
|
var BRIDGE_WAKE_KINDS = /* @__PURE__ */ new Set([
|
|
23950
24331
|
"mention",
|
|
@@ -23973,6 +24354,74 @@ function replyBody(text) {
|
|
|
23973
24354
|
|
|
23974
24355
|
(Reply cut short: it was too long.)`;
|
|
23975
24356
|
}
|
|
24357
|
+
var STOPPED_REASON = "someone pressed Stop in Tasqmate";
|
|
24358
|
+
async function trackRun(deps, event) {
|
|
24359
|
+
const { client, config: config2, log } = deps;
|
|
24360
|
+
const slug = config2.workspace;
|
|
24361
|
+
const stop = new AbortController();
|
|
24362
|
+
const { openRun, postRunEvents, finishRun } = client.agents;
|
|
24363
|
+
let reporter = null;
|
|
24364
|
+
let runId = null;
|
|
24365
|
+
if (openRun !== void 0 && postRunEvents !== void 0) {
|
|
24366
|
+
try {
|
|
24367
|
+
runId = (await openRun(slug, { eventId: event.id, harness: config2.harness })).run.id;
|
|
24368
|
+
reporter = createRunReporter({ client: { postRunEvents }, slug, runId, log });
|
|
24369
|
+
reporter.onStop(() => stop.abort(new Error(STOPPED_REASON)));
|
|
24370
|
+
} catch (error48) {
|
|
24371
|
+
log.warn(
|
|
24372
|
+
`${label(event)}: could not open a run (${error48 instanceof Error ? error48.message : String(error48)}); working without live steps`
|
|
24373
|
+
);
|
|
24374
|
+
}
|
|
24375
|
+
}
|
|
24376
|
+
return {
|
|
24377
|
+
runId,
|
|
24378
|
+
step: reporter === null ? noSteps : reporter.push,
|
|
24379
|
+
stopSignal: stop.signal,
|
|
24380
|
+
get stopped() {
|
|
24381
|
+
return stop.signal.aborted;
|
|
24382
|
+
},
|
|
24383
|
+
finish: async (result) => {
|
|
24384
|
+
if (reporter === null || runId === null) return;
|
|
24385
|
+
const stopped = stop.signal.aborted;
|
|
24386
|
+
if (!result.ok && !stopped) reporter.push(errorStep(result.summary));
|
|
24387
|
+
await reporter.close();
|
|
24388
|
+
const refused = result.denied === 0 ? "" : `, ${result.denied} refused`;
|
|
24389
|
+
const summary = stopped ? "Stopped from Tasqmate" : `${result.summary}${refused}`;
|
|
24390
|
+
await finishRun?.(slug, runId, {
|
|
24391
|
+
state: stopped ? "stopped" : result.ok ? "done" : "failed",
|
|
24392
|
+
summary: summary.slice(0, 200)
|
|
24393
|
+
}).catch((error48) => log.warn(`${label(event)}: could not finish the run (${error48.message})`));
|
|
24394
|
+
}
|
|
24395
|
+
};
|
|
24396
|
+
}
|
|
24397
|
+
function tasqmateEnv(deps, slug, tracker) {
|
|
24398
|
+
const env = {
|
|
24399
|
+
TASQMATE_API_KEY: deps.key,
|
|
24400
|
+
TASQMATE_API_URL: deps.config.apiUrl,
|
|
24401
|
+
TASQMATE_WORKSPACE: slug
|
|
24402
|
+
};
|
|
24403
|
+
if (tracker.runId !== null) env.TASQMATE_RUN_ID = tracker.runId;
|
|
24404
|
+
return env;
|
|
24405
|
+
}
|
|
24406
|
+
function stopSignals(deps, tracker) {
|
|
24407
|
+
return deps.signal === void 0 ? tracker.stopSignal : AbortSignal.any([deps.signal, tracker.stopSignal]);
|
|
24408
|
+
}
|
|
24409
|
+
async function finishing(tracker, work) {
|
|
24410
|
+
let result;
|
|
24411
|
+
try {
|
|
24412
|
+
result = await work();
|
|
24413
|
+
} catch (error48) {
|
|
24414
|
+
await tracker.finish({
|
|
24415
|
+
ok: false,
|
|
24416
|
+
sessionId: null,
|
|
24417
|
+
denied: 0,
|
|
24418
|
+
summary: `failed: ${error48 instanceof Error ? error48.message : String(error48)}`
|
|
24419
|
+
});
|
|
24420
|
+
throw error48;
|
|
24421
|
+
}
|
|
24422
|
+
await tracker.finish(result);
|
|
24423
|
+
return result;
|
|
24424
|
+
}
|
|
23976
24425
|
async function whileRunning(deps, event, work) {
|
|
23977
24426
|
const { client, config: config2, log } = deps;
|
|
23978
24427
|
const slug = config2.workspace;
|
|
@@ -24018,6 +24467,7 @@ async function handleChat(deps, event, chat) {
|
|
|
24018
24467
|
if (!folder.mapped) mkdirSync5(folder.folder, { recursive: true, mode: 448 });
|
|
24019
24468
|
const subject = `chat:${chat.id}`;
|
|
24020
24469
|
const stored = deps.sessions.get(subject, config2.harness);
|
|
24470
|
+
const tracker = await trackRun(deps, event);
|
|
24021
24471
|
const attempt = (resumeSessionId) => deps.limiter.run(
|
|
24022
24472
|
(signal) => deps.adapter.run({
|
|
24023
24473
|
prompt: buildChatPrompt({
|
|
@@ -24031,33 +24481,34 @@ async function handleChat(deps, event, chat) {
|
|
|
24031
24481
|
cwd: folder.folder,
|
|
24032
24482
|
harnessPath: config2.harnessPath,
|
|
24033
24483
|
mcp: config2.mcpCommand,
|
|
24034
|
-
tasqmateEnv:
|
|
24035
|
-
TASQMATE_API_KEY: deps.key,
|
|
24036
|
-
TASQMATE_API_URL: config2.apiUrl,
|
|
24037
|
-
TASQMATE_WORKSPACE: slug
|
|
24038
|
-
},
|
|
24484
|
+
tasqmateEnv: tasqmateEnv(deps, slug, tracker),
|
|
24039
24485
|
maxTurns: deps.limiter.limits.maxTurns,
|
|
24040
24486
|
resumeSessionId,
|
|
24041
24487
|
guard: createGuard(folder.folder),
|
|
24042
24488
|
signal,
|
|
24043
|
-
log
|
|
24489
|
+
log,
|
|
24490
|
+
step: tracker.step
|
|
24044
24491
|
}),
|
|
24045
|
-
deps
|
|
24492
|
+
stopSignals(deps, tracker),
|
|
24046
24493
|
"chat"
|
|
24047
24494
|
);
|
|
24048
24495
|
log.info(
|
|
24049
24496
|
`${label(event)}: ${stored === null ? "starting" : "resuming"} ${config2.harness} in ${folder.mapped ? folder.folder : "the scratch folder"}`
|
|
24050
24497
|
);
|
|
24051
|
-
const result = await whileRunning(
|
|
24052
|
-
|
|
24053
|
-
|
|
24054
|
-
|
|
24055
|
-
|
|
24056
|
-
|
|
24498
|
+
const result = await whileRunning(
|
|
24499
|
+
deps,
|
|
24500
|
+
event,
|
|
24501
|
+
() => finishing(tracker, async () => {
|
|
24502
|
+
const first = await attempt(stored);
|
|
24503
|
+
if (!first.resumeFailed) return first;
|
|
24504
|
+
log.info(`${label(event)}: ${first.summary}; starting a fresh session with the chat's history`);
|
|
24505
|
+
return attempt(null);
|
|
24506
|
+
})
|
|
24507
|
+
);
|
|
24057
24508
|
if (result.sessionId !== null) deps.sessions.record(subject, config2.harness, result.sessionId);
|
|
24058
24509
|
const refused = result.denied === 0 ? "" : `, ${result.denied} refused`;
|
|
24059
24510
|
const said = result.finalMessage?.trim() ?? "";
|
|
24060
|
-
const body = result.ok ? said === "" ? "(Finished, with nothing to say.)" : said : [said, `_I couldn't finish this turn: ${result.summary}._`].filter((part) => part !== "").join("\n\n");
|
|
24511
|
+
const body = tracker.stopped ? [said, "_Stopped before finishing._"].filter((part) => part !== "").join("\n\n") : result.ok ? said === "" ? "(Finished, with nothing to say.)" : said : [said, `_I couldn't finish this turn: ${result.summary}._`].filter((part) => part !== "").join("\n\n");
|
|
24061
24512
|
try {
|
|
24062
24513
|
await client.agents.replyToChat(slug, chat.id, { body: replyBody(body), eventId: event.id });
|
|
24063
24514
|
} catch (error48) {
|
|
@@ -24133,24 +24584,25 @@ async function handle(deps, event) {
|
|
|
24133
24584
|
await report();
|
|
24134
24585
|
const heartbeat = setInterval(report, HEARTBEAT_MS);
|
|
24135
24586
|
log.info(`${label(event)}: starting ${config2.harness} in ${folder.mapped ? folder.folder : "the scratch folder"}`);
|
|
24587
|
+
const tracker = await trackRun(deps, event);
|
|
24136
24588
|
try {
|
|
24137
|
-
const result = await
|
|
24138
|
-
|
|
24139
|
-
|
|
24140
|
-
|
|
24141
|
-
|
|
24142
|
-
|
|
24143
|
-
|
|
24144
|
-
|
|
24145
|
-
|
|
24146
|
-
|
|
24147
|
-
|
|
24148
|
-
|
|
24149
|
-
|
|
24150
|
-
|
|
24151
|
-
|
|
24152
|
-
|
|
24153
|
-
|
|
24589
|
+
const result = await finishing(
|
|
24590
|
+
tracker,
|
|
24591
|
+
() => deps.limiter.run(
|
|
24592
|
+
(signal) => deps.adapter.run({
|
|
24593
|
+
prompt,
|
|
24594
|
+
cwd: folder.folder,
|
|
24595
|
+
harnessPath: config2.harnessPath,
|
|
24596
|
+
mcp: config2.mcpCommand,
|
|
24597
|
+
tasqmateEnv: tasqmateEnv(deps, slug, tracker),
|
|
24598
|
+
maxTurns: deps.limiter.limits.maxTurns,
|
|
24599
|
+
guard: createGuard(folder.folder),
|
|
24600
|
+
signal,
|
|
24601
|
+
log,
|
|
24602
|
+
step: tracker.step
|
|
24603
|
+
}),
|
|
24604
|
+
stopSignals(deps, tracker)
|
|
24605
|
+
)
|
|
24154
24606
|
);
|
|
24155
24607
|
if (result.sessionId !== null) {
|
|
24156
24608
|
deps.sessions.record(event.taskId ?? event.threadId ?? event.id, config2.harness, result.sessionId);
|
|
@@ -24160,6 +24612,10 @@ async function handle(deps, event) {
|
|
|
24160
24612
|
log.info(`${label(event)}: ${result.summary}${refused}`);
|
|
24161
24613
|
return true;
|
|
24162
24614
|
}
|
|
24615
|
+
if (tracker.stopped) {
|
|
24616
|
+
log.info(`${label(event)}: stopped from Tasqmate${refused}; acknowledged`);
|
|
24617
|
+
return true;
|
|
24618
|
+
}
|
|
24163
24619
|
log.warn(`${label(event)}: ${result.summary}${refused}; left for redelivery`);
|
|
24164
24620
|
return false;
|
|
24165
24621
|
} finally {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tasqmate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Command-line client for Tasqmate, for humans and agents alike. Installs the tasqmate and tasqmate commands.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tasqmate",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"zod": "4.3.6"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@tasqmate/sdk": "0.
|
|
54
|
+
"@tasqmate/sdk": "0.5.0",
|
|
55
55
|
"@types/bun": "^1.3.12",
|
|
56
56
|
"tsup": "^8.5.0",
|
|
57
57
|
"typescript": "^5.7.2"
|