@integrity-labs/agt-cli 0.28.1088 → 0.28.1089
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/bin/agt.js +3 -3
- package/dist/{chunk-JAXSZCTH.js → chunk-OBSRWYMM.js} +2 -2
- package/dist/lib/manager-worker.js +2 -2
- package/dist/mcp/direct-chat-channel.js +173 -132
- package/dist/mcp/index.js +172 -40
- package/dist/mcp/slack-channel.js +344 -261
- package/dist/mcp/teams-channel.js +210 -86
- package/dist/mcp/telegram-channel.js +287 -206
- package/dist/mcp/whatsapp-channel.js +194 -69
- package/package.json +1 -1
- /package/dist/{chunk-JAXSZCTH.js.map → chunk-OBSRWYMM.js.map} +0 -0
|
@@ -3599,49 +3599,49 @@ var require_fast_uri = __commonJS({
|
|
|
3599
3599
|
schemelessOptions.skipEscape = true;
|
|
3600
3600
|
return serialize(resolved, schemelessOptions);
|
|
3601
3601
|
}
|
|
3602
|
-
function resolveComponent(base,
|
|
3602
|
+
function resolveComponent(base, relative2, options, skipNormalization) {
|
|
3603
3603
|
const target = {};
|
|
3604
3604
|
if (!skipNormalization) {
|
|
3605
3605
|
base = parse3(serialize(base, options), options);
|
|
3606
|
-
|
|
3606
|
+
relative2 = parse3(serialize(relative2, options), options);
|
|
3607
3607
|
}
|
|
3608
3608
|
options = options || {};
|
|
3609
|
-
if (!options.tolerant &&
|
|
3610
|
-
target.scheme =
|
|
3611
|
-
target.userinfo =
|
|
3612
|
-
target.host =
|
|
3613
|
-
target.port =
|
|
3614
|
-
target.path = removeDotSegments(
|
|
3615
|
-
target.query =
|
|
3609
|
+
if (!options.tolerant && relative2.scheme) {
|
|
3610
|
+
target.scheme = relative2.scheme;
|
|
3611
|
+
target.userinfo = relative2.userinfo;
|
|
3612
|
+
target.host = relative2.host;
|
|
3613
|
+
target.port = relative2.port;
|
|
3614
|
+
target.path = removeDotSegments(relative2.path || "");
|
|
3615
|
+
target.query = relative2.query;
|
|
3616
3616
|
} else {
|
|
3617
|
-
if (
|
|
3618
|
-
target.userinfo =
|
|
3619
|
-
target.host =
|
|
3620
|
-
target.port =
|
|
3621
|
-
target.path = removeDotSegments(
|
|
3622
|
-
target.query =
|
|
3617
|
+
if (relative2.userinfo !== void 0 || relative2.host !== void 0 || relative2.port !== void 0) {
|
|
3618
|
+
target.userinfo = relative2.userinfo;
|
|
3619
|
+
target.host = relative2.host;
|
|
3620
|
+
target.port = relative2.port;
|
|
3621
|
+
target.path = removeDotSegments(relative2.path || "");
|
|
3622
|
+
target.query = relative2.query;
|
|
3623
3623
|
} else {
|
|
3624
|
-
if (!
|
|
3624
|
+
if (!relative2.path) {
|
|
3625
3625
|
target.path = base.path;
|
|
3626
|
-
if (
|
|
3627
|
-
target.query =
|
|
3626
|
+
if (relative2.query !== void 0) {
|
|
3627
|
+
target.query = relative2.query;
|
|
3628
3628
|
} else {
|
|
3629
3629
|
target.query = base.query;
|
|
3630
3630
|
}
|
|
3631
3631
|
} else {
|
|
3632
|
-
if (
|
|
3633
|
-
target.path = removeDotSegments(
|
|
3632
|
+
if (relative2.path[0] === "/") {
|
|
3633
|
+
target.path = removeDotSegments(relative2.path);
|
|
3634
3634
|
} else {
|
|
3635
3635
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
3636
|
-
target.path = "/" +
|
|
3636
|
+
target.path = "/" + relative2.path;
|
|
3637
3637
|
} else if (!base.path) {
|
|
3638
|
-
target.path =
|
|
3638
|
+
target.path = relative2.path;
|
|
3639
3639
|
} else {
|
|
3640
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
3640
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
|
|
3641
3641
|
}
|
|
3642
3642
|
target.path = removeDotSegments(target.path);
|
|
3643
3643
|
}
|
|
3644
|
-
target.query =
|
|
3644
|
+
target.query = relative2.query;
|
|
3645
3645
|
}
|
|
3646
3646
|
target.userinfo = base.userinfo;
|
|
3647
3647
|
target.host = base.host;
|
|
@@ -3649,7 +3649,7 @@ var require_fast_uri = __commonJS({
|
|
|
3649
3649
|
}
|
|
3650
3650
|
target.scheme = base.scheme;
|
|
3651
3651
|
}
|
|
3652
|
-
target.fragment =
|
|
3652
|
+
target.fragment = relative2.fragment;
|
|
3653
3653
|
return target;
|
|
3654
3654
|
}
|
|
3655
3655
|
function equal(uriA, uriB, options) {
|
|
@@ -13114,7 +13114,7 @@ var require_filesystem = __commonJS({
|
|
|
13114
13114
|
var LDD_PATH = "/usr/bin/ldd";
|
|
13115
13115
|
var SELF_PATH = "/proc/self/exe";
|
|
13116
13116
|
var MAX_LENGTH = 2048;
|
|
13117
|
-
var
|
|
13117
|
+
var readFileSync5 = (path) => {
|
|
13118
13118
|
const fd = fs5.openSync(path, "r");
|
|
13119
13119
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
13120
13120
|
const bytesRead = fs5.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
@@ -13139,7 +13139,7 @@ var require_filesystem = __commonJS({
|
|
|
13139
13139
|
module.exports = {
|
|
13140
13140
|
LDD_PATH,
|
|
13141
13141
|
SELF_PATH,
|
|
13142
|
-
readFileSync:
|
|
13142
|
+
readFileSync: readFileSync5,
|
|
13143
13143
|
readFile: readFile2
|
|
13144
13144
|
};
|
|
13145
13145
|
}
|
|
@@ -13188,7 +13188,7 @@ var require_detect_libc = __commonJS({
|
|
|
13188
13188
|
"use strict";
|
|
13189
13189
|
var childProcess = __require("child_process");
|
|
13190
13190
|
var { isLinux, getReport } = require_process();
|
|
13191
|
-
var { LDD_PATH, SELF_PATH, readFile: readFile2, readFileSync:
|
|
13191
|
+
var { LDD_PATH, SELF_PATH, readFile: readFile2, readFileSync: readFileSync5 } = require_filesystem();
|
|
13192
13192
|
var { interpreterPath } = require_elf();
|
|
13193
13193
|
var cachedFamilyInterpreter;
|
|
13194
13194
|
var cachedFamilyFilesystem;
|
|
@@ -13280,7 +13280,7 @@ var require_detect_libc = __commonJS({
|
|
|
13280
13280
|
}
|
|
13281
13281
|
cachedFamilyFilesystem = null;
|
|
13282
13282
|
try {
|
|
13283
|
-
const lddContent =
|
|
13283
|
+
const lddContent = readFileSync5(LDD_PATH);
|
|
13284
13284
|
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
|
13285
13285
|
} catch (e) {
|
|
13286
13286
|
}
|
|
@@ -13305,7 +13305,7 @@ var require_detect_libc = __commonJS({
|
|
|
13305
13305
|
}
|
|
13306
13306
|
cachedFamilyInterpreter = null;
|
|
13307
13307
|
try {
|
|
13308
|
-
const selfContent =
|
|
13308
|
+
const selfContent = readFileSync5(SELF_PATH);
|
|
13309
13309
|
const path = interpreterPath(selfContent);
|
|
13310
13310
|
cachedFamilyInterpreter = familyFromInterpreterPath(path);
|
|
13311
13311
|
} catch (e) {
|
|
@@ -13369,7 +13369,7 @@ var require_detect_libc = __commonJS({
|
|
|
13369
13369
|
}
|
|
13370
13370
|
cachedVersionFilesystem = null;
|
|
13371
13371
|
try {
|
|
13372
|
-
const lddContent =
|
|
13372
|
+
const lddContent = readFileSync5(LDD_PATH);
|
|
13373
13373
|
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
|
13374
13374
|
if (versionMatch) {
|
|
13375
13375
|
cachedVersionFilesystem = versionMatch[1];
|
|
@@ -36322,7 +36322,7 @@ var require_thread_stream = __commonJS({
|
|
|
36322
36322
|
var { version: version3 } = require_package2();
|
|
36323
36323
|
var { EventEmitter: EventEmitter4 } = __require("events");
|
|
36324
36324
|
var { Worker } = __require("worker_threads");
|
|
36325
|
-
var { join:
|
|
36325
|
+
var { join: join9 } = __require("path");
|
|
36326
36326
|
var { pathToFileURL } = __require("url");
|
|
36327
36327
|
var { wait } = require_wait2();
|
|
36328
36328
|
var {
|
|
@@ -36358,7 +36358,7 @@ var require_thread_stream = __commonJS({
|
|
|
36358
36358
|
function createWorker(stream, opts) {
|
|
36359
36359
|
const { filename, workerData } = opts;
|
|
36360
36360
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
36361
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
36361
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join9(__dirname, "lib", "worker.js");
|
|
36362
36362
|
const worker = new Worker(toExecute, {
|
|
36363
36363
|
...opts.workerOpts,
|
|
36364
36364
|
trackUnmanagedFds: false,
|
|
@@ -36744,7 +36744,7 @@ var require_transport = __commonJS({
|
|
|
36744
36744
|
"use strict";
|
|
36745
36745
|
var { createRequire } = __require("module");
|
|
36746
36746
|
var getCallers = require_caller();
|
|
36747
|
-
var { join:
|
|
36747
|
+
var { join: join9, isAbsolute: isAbsolute2, sep: sep2 } = __require("path");
|
|
36748
36748
|
var sleep = require_atomic_sleep();
|
|
36749
36749
|
var onExit = require_on_exit_leak_free();
|
|
36750
36750
|
var ThreadStream = require_thread_stream();
|
|
@@ -36807,7 +36807,7 @@ var require_transport = __commonJS({
|
|
|
36807
36807
|
throw new Error("only one of target or targets can be specified");
|
|
36808
36808
|
}
|
|
36809
36809
|
if (targets) {
|
|
36810
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
36810
|
+
target = bundlerOverrides["pino-worker"] || join9(__dirname, "worker.js");
|
|
36811
36811
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
36812
36812
|
return {
|
|
36813
36813
|
...dest,
|
|
@@ -36825,7 +36825,7 @@ var require_transport = __commonJS({
|
|
|
36825
36825
|
});
|
|
36826
36826
|
});
|
|
36827
36827
|
} else if (pipeline2) {
|
|
36828
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
36828
|
+
target = bundlerOverrides["pino-worker"] || join9(__dirname, "worker.js");
|
|
36829
36829
|
options.pipelines = [pipeline2.map((dest) => {
|
|
36830
36830
|
return {
|
|
36831
36831
|
...dest,
|
|
@@ -36843,16 +36843,16 @@ var require_transport = __commonJS({
|
|
|
36843
36843
|
return buildStream(fixTarget(target), options, worker, sync);
|
|
36844
36844
|
function fixTarget(origin) {
|
|
36845
36845
|
origin = bundlerOverrides[origin] || origin;
|
|
36846
|
-
if (
|
|
36846
|
+
if (isAbsolute2(origin) || origin.indexOf("file://") === 0) {
|
|
36847
36847
|
return origin;
|
|
36848
36848
|
}
|
|
36849
36849
|
if (origin === "pino/file") {
|
|
36850
|
-
return
|
|
36850
|
+
return join9(__dirname, "..", "file.js");
|
|
36851
36851
|
}
|
|
36852
36852
|
let fixTarget2;
|
|
36853
36853
|
for (const filePath of callers) {
|
|
36854
36854
|
try {
|
|
36855
|
-
const context = filePath === "node:repl" ? process.cwd() +
|
|
36855
|
+
const context = filePath === "node:repl" ? process.cwd() + sep2 : filePath;
|
|
36856
36856
|
fixTarget2 = createRequire(context).resolve(origin);
|
|
36857
36857
|
break;
|
|
36858
36858
|
} catch (err) {
|
|
@@ -37837,7 +37837,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
37837
37837
|
return circularValue;
|
|
37838
37838
|
}
|
|
37839
37839
|
let res = "";
|
|
37840
|
-
let
|
|
37840
|
+
let join9 = ",";
|
|
37841
37841
|
const originalIndentation = indentation;
|
|
37842
37842
|
if (Array.isArray(value)) {
|
|
37843
37843
|
if (value.length === 0) {
|
|
@@ -37851,7 +37851,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
37851
37851
|
indentation += spacer;
|
|
37852
37852
|
res += `
|
|
37853
37853
|
${indentation}`;
|
|
37854
|
-
|
|
37854
|
+
join9 = `,
|
|
37855
37855
|
${indentation}`;
|
|
37856
37856
|
}
|
|
37857
37857
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -37859,13 +37859,13 @@ ${indentation}`;
|
|
|
37859
37859
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
37860
37860
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
37861
37861
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
37862
|
-
res +=
|
|
37862
|
+
res += join9;
|
|
37863
37863
|
}
|
|
37864
37864
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
37865
37865
|
res += tmp !== void 0 ? tmp : "null";
|
|
37866
37866
|
if (value.length - 1 > maximumBreadth) {
|
|
37867
37867
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
37868
|
-
res += `${
|
|
37868
|
+
res += `${join9}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
37869
37869
|
}
|
|
37870
37870
|
if (spacer !== "") {
|
|
37871
37871
|
res += `
|
|
@@ -37886,7 +37886,7 @@ ${originalIndentation}`;
|
|
|
37886
37886
|
let separator = "";
|
|
37887
37887
|
if (spacer !== "") {
|
|
37888
37888
|
indentation += spacer;
|
|
37889
|
-
|
|
37889
|
+
join9 = `,
|
|
37890
37890
|
${indentation}`;
|
|
37891
37891
|
whitespace = " ";
|
|
37892
37892
|
}
|
|
@@ -37900,13 +37900,13 @@ ${indentation}`;
|
|
|
37900
37900
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
37901
37901
|
if (tmp !== void 0) {
|
|
37902
37902
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
37903
|
-
separator =
|
|
37903
|
+
separator = join9;
|
|
37904
37904
|
}
|
|
37905
37905
|
}
|
|
37906
37906
|
if (keyLength > maximumBreadth) {
|
|
37907
37907
|
const removedKeys = keyLength - maximumBreadth;
|
|
37908
37908
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
37909
|
-
separator =
|
|
37909
|
+
separator = join9;
|
|
37910
37910
|
}
|
|
37911
37911
|
if (spacer !== "" && separator.length > 1) {
|
|
37912
37912
|
res = `
|
|
@@ -37947,7 +37947,7 @@ ${originalIndentation}`;
|
|
|
37947
37947
|
}
|
|
37948
37948
|
const originalIndentation = indentation;
|
|
37949
37949
|
let res = "";
|
|
37950
|
-
let
|
|
37950
|
+
let join9 = ",";
|
|
37951
37951
|
if (Array.isArray(value)) {
|
|
37952
37952
|
if (value.length === 0) {
|
|
37953
37953
|
return "[]";
|
|
@@ -37960,7 +37960,7 @@ ${originalIndentation}`;
|
|
|
37960
37960
|
indentation += spacer;
|
|
37961
37961
|
res += `
|
|
37962
37962
|
${indentation}`;
|
|
37963
|
-
|
|
37963
|
+
join9 = `,
|
|
37964
37964
|
${indentation}`;
|
|
37965
37965
|
}
|
|
37966
37966
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -37968,13 +37968,13 @@ ${indentation}`;
|
|
|
37968
37968
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
37969
37969
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
37970
37970
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
37971
|
-
res +=
|
|
37971
|
+
res += join9;
|
|
37972
37972
|
}
|
|
37973
37973
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
37974
37974
|
res += tmp !== void 0 ? tmp : "null";
|
|
37975
37975
|
if (value.length - 1 > maximumBreadth) {
|
|
37976
37976
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
37977
|
-
res += `${
|
|
37977
|
+
res += `${join9}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
37978
37978
|
}
|
|
37979
37979
|
if (spacer !== "") {
|
|
37980
37980
|
res += `
|
|
@@ -37987,7 +37987,7 @@ ${originalIndentation}`;
|
|
|
37987
37987
|
let whitespace = "";
|
|
37988
37988
|
if (spacer !== "") {
|
|
37989
37989
|
indentation += spacer;
|
|
37990
|
-
|
|
37990
|
+
join9 = `,
|
|
37991
37991
|
${indentation}`;
|
|
37992
37992
|
whitespace = " ";
|
|
37993
37993
|
}
|
|
@@ -37996,7 +37996,7 @@ ${indentation}`;
|
|
|
37996
37996
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
37997
37997
|
if (tmp !== void 0) {
|
|
37998
37998
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
37999
|
-
separator =
|
|
37999
|
+
separator = join9;
|
|
38000
38000
|
}
|
|
38001
38001
|
}
|
|
38002
38002
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -38054,20 +38054,20 @@ ${originalIndentation}`;
|
|
|
38054
38054
|
indentation += spacer;
|
|
38055
38055
|
let res2 = `
|
|
38056
38056
|
${indentation}`;
|
|
38057
|
-
const
|
|
38057
|
+
const join10 = `,
|
|
38058
38058
|
${indentation}`;
|
|
38059
38059
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
38060
38060
|
let i = 0;
|
|
38061
38061
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
38062
38062
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
38063
38063
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
38064
|
-
res2 +=
|
|
38064
|
+
res2 += join10;
|
|
38065
38065
|
}
|
|
38066
38066
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
38067
38067
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
38068
38068
|
if (value.length - 1 > maximumBreadth) {
|
|
38069
38069
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
38070
|
-
res2 += `${
|
|
38070
|
+
res2 += `${join10}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
38071
38071
|
}
|
|
38072
38072
|
res2 += `
|
|
38073
38073
|
${originalIndentation}`;
|
|
@@ -38083,16 +38083,16 @@ ${originalIndentation}`;
|
|
|
38083
38083
|
return '"[Object]"';
|
|
38084
38084
|
}
|
|
38085
38085
|
indentation += spacer;
|
|
38086
|
-
const
|
|
38086
|
+
const join9 = `,
|
|
38087
38087
|
${indentation}`;
|
|
38088
38088
|
let res = "";
|
|
38089
38089
|
let separator = "";
|
|
38090
38090
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
38091
38091
|
if (isTypedArrayWithEntries(value)) {
|
|
38092
|
-
res += stringifyTypedArray(value,
|
|
38092
|
+
res += stringifyTypedArray(value, join9, maximumBreadth);
|
|
38093
38093
|
keys = keys.slice(value.length);
|
|
38094
38094
|
maximumPropertiesToStringify -= value.length;
|
|
38095
|
-
separator =
|
|
38095
|
+
separator = join9;
|
|
38096
38096
|
}
|
|
38097
38097
|
if (deterministic) {
|
|
38098
38098
|
keys = sort(keys, comparator);
|
|
@@ -38103,13 +38103,13 @@ ${indentation}`;
|
|
|
38103
38103
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
38104
38104
|
if (tmp !== void 0) {
|
|
38105
38105
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
38106
|
-
separator =
|
|
38106
|
+
separator = join9;
|
|
38107
38107
|
}
|
|
38108
38108
|
}
|
|
38109
38109
|
if (keyLength > maximumBreadth) {
|
|
38110
38110
|
const removedKeys = keyLength - maximumBreadth;
|
|
38111
38111
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
38112
|
-
separator =
|
|
38112
|
+
separator = join9;
|
|
38113
38113
|
}
|
|
38114
38114
|
if (separator !== "") {
|
|
38115
38115
|
res = `
|
|
@@ -49315,9 +49315,9 @@ var StdioServerTransport = class {
|
|
|
49315
49315
|
};
|
|
49316
49316
|
|
|
49317
49317
|
// src/whatsapp-channel.ts
|
|
49318
|
-
import { readFileSync, readdirSync, statSync, watch } from "fs";
|
|
49319
|
-
import { homedir } from "os";
|
|
49320
|
-
import { join as
|
|
49318
|
+
import { readFileSync as readFileSync4, readdirSync, statSync, watch } from "fs";
|
|
49319
|
+
import { homedir as homedir2 } from "os";
|
|
49320
|
+
import { join as join8 } from "path";
|
|
49321
49321
|
|
|
49322
49322
|
// src/kapso-client.ts
|
|
49323
49323
|
var REQUEST_TIMEOUT_MS = 15e3;
|
|
@@ -155932,9 +155932,132 @@ var WHATSAPP_EGRESS_TOOLS = /* @__PURE__ */ new Set([
|
|
|
155932
155932
|
"whatsapp.send_template"
|
|
155933
155933
|
]);
|
|
155934
155934
|
|
|
155935
|
+
// src/turn-context.ts
|
|
155936
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync3 } from "fs";
|
|
155937
|
+
import { homedir } from "os";
|
|
155938
|
+
import { dirname as dirname2, join as join7 } from "path";
|
|
155939
|
+
|
|
155940
|
+
// ../core/dist/provisioning/frameworks/claudecode/agent-dir-alias.js
|
|
155941
|
+
import { isAbsolute, join as join4, relative, sep } from "path";
|
|
155942
|
+
var VALID_CODE_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
155943
|
+
var VALID_AGENT_ID = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
155944
|
+
var INITIATOR_BASENAME = ".current-turn-initiator.json";
|
|
155945
|
+
function isSafeAgentSegment(segment) {
|
|
155946
|
+
return VALID_CODE_NAME.test(segment) || VALID_AGENT_ID.test(segment);
|
|
155947
|
+
}
|
|
155948
|
+
function initiatorDirSegment(initiatorFile, homeDir) {
|
|
155949
|
+
const rel = relative(join4(homeDir, ".augmented"), initiatorFile);
|
|
155950
|
+
if (!rel || isAbsolute(rel))
|
|
155951
|
+
return null;
|
|
155952
|
+
const parts = rel.split(sep);
|
|
155953
|
+
if (parts.length !== 2 || parts[1] !== INITIATOR_BASENAME)
|
|
155954
|
+
return null;
|
|
155955
|
+
const segment = parts[0];
|
|
155956
|
+
if (segment === void 0)
|
|
155957
|
+
return null;
|
|
155958
|
+
return isSafeAgentSegment(segment) ? segment : null;
|
|
155959
|
+
}
|
|
155960
|
+
function resolveAgentDirAlias(input) {
|
|
155961
|
+
const { codeName, turnInitiatorFile, agentId, homeDir } = input;
|
|
155962
|
+
const codeNameTrimmed = typeof codeName === "string" ? codeName.trim() : "";
|
|
155963
|
+
if (codeNameTrimmed && VALID_CODE_NAME.test(codeNameTrimmed)) {
|
|
155964
|
+
return join4(homeDir, ".augmented", codeNameTrimmed);
|
|
155965
|
+
}
|
|
155966
|
+
const initiator = typeof turnInitiatorFile === "string" ? turnInitiatorFile.trim() : "";
|
|
155967
|
+
if (initiator) {
|
|
155968
|
+
const segment = initiatorDirSegment(initiator, homeDir);
|
|
155969
|
+
if (segment)
|
|
155970
|
+
return join4(homeDir, ".augmented", segment);
|
|
155971
|
+
}
|
|
155972
|
+
const agentIdTrimmed = typeof agentId === "string" ? agentId.trim() : "";
|
|
155973
|
+
if (agentIdTrimmed && VALID_AGENT_ID.test(agentIdTrimmed)) {
|
|
155974
|
+
return join4(homeDir, ".augmented", agentIdTrimmed);
|
|
155975
|
+
}
|
|
155976
|
+
return null;
|
|
155977
|
+
}
|
|
155978
|
+
|
|
155979
|
+
// src/turn-initiator-marker.ts
|
|
155980
|
+
import { writeFileSync, readFileSync, mkdirSync, renameSync } from "fs";
|
|
155981
|
+
import { dirname, join as join5 } from "path";
|
|
155982
|
+
var TURN_INITIATOR_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
155983
|
+
var TURN_INITIATOR_LEDGER_MAX_ENTRIES = 20;
|
|
155984
|
+
var TURN_INITIATOR_LEDGER_FILENAME = ".turn-initiator-ledger.json";
|
|
155985
|
+
function turnInitiatorLedgerPath(singleSlotFile) {
|
|
155986
|
+
return join5(dirname(singleSlotFile), TURN_INITIATOR_LEDGER_FILENAME);
|
|
155987
|
+
}
|
|
155988
|
+
function foldTurnInitiatorLedger(existing, marker, maxAgeMs = TURN_INITIATOR_MAX_AGE_MS, maxEntries = TURN_INITIATOR_LEDGER_MAX_ENTRIES) {
|
|
155989
|
+
const now = marker.ts;
|
|
155990
|
+
const key = (e) => `${e.channel}\0${e.channel_ref ?? ""}`;
|
|
155991
|
+
const markerKey = key(marker);
|
|
155992
|
+
const prior = existing && Array.isArray(existing.entries) ? existing.entries : [];
|
|
155993
|
+
const kept = prior.filter(
|
|
155994
|
+
(e) => e && typeof e.ts === "number" && Number.isFinite(e.ts) && now - e.ts <= maxAgeMs && now - e.ts >= 0 && key(e) !== markerKey
|
|
155995
|
+
// the same thread is replaced by the new entry below
|
|
155996
|
+
);
|
|
155997
|
+
kept.push({
|
|
155998
|
+
channel: marker.channel,
|
|
155999
|
+
sender_id: marker.sender_id,
|
|
156000
|
+
...marker.sender_name ? { sender_name: marker.sender_name } : {},
|
|
156001
|
+
...marker.channel_ref ? { channel_ref: marker.channel_ref } : {},
|
|
156002
|
+
...marker.chat_kind ? { chat_kind: marker.chat_kind } : {},
|
|
156003
|
+
...marker.chat_id ? { chat_id: marker.chat_id } : {},
|
|
156004
|
+
...marker.unattributed ? { unattributed: true } : {},
|
|
156005
|
+
ts: marker.ts
|
|
156006
|
+
});
|
|
156007
|
+
kept.sort((a, b) => b.ts - a.ts);
|
|
156008
|
+
return { v: 1, entries: kept.slice(0, maxEntries) };
|
|
156009
|
+
}
|
|
156010
|
+
function updateTurnInitiatorLedger(singleSlotFile, marker) {
|
|
156011
|
+
const ledgerFile = turnInitiatorLedgerPath(singleSlotFile);
|
|
156012
|
+
let existing = null;
|
|
156013
|
+
try {
|
|
156014
|
+
const parsed = JSON.parse(readFileSync(ledgerFile, "utf8"));
|
|
156015
|
+
if (parsed && parsed.v === 1 && Array.isArray(parsed.entries)) existing = parsed;
|
|
156016
|
+
} catch {
|
|
156017
|
+
}
|
|
156018
|
+
const next = foldTurnInitiatorLedger(existing, marker);
|
|
156019
|
+
const tmp = `${ledgerFile}.${process.pid}.${Date.now()}.tmp`;
|
|
156020
|
+
writeFileSync(tmp, JSON.stringify(next), "utf8");
|
|
156021
|
+
renameSync(tmp, ledgerFile);
|
|
156022
|
+
}
|
|
156023
|
+
|
|
156024
|
+
// src/scheduled-turn-marker.ts
|
|
156025
|
+
import { readFileSync as readFileSync2, unlinkSync } from "fs";
|
|
156026
|
+
import { join as join6 } from "path";
|
|
156027
|
+
var SCHEDULED_TURN_MAX_AGE_MS = 15 * 60 * 1e3;
|
|
156028
|
+
|
|
156029
|
+
// src/turn-context.ts
|
|
156030
|
+
var TURN_INITIATOR_MARKER_FILENAME = ".current-turn-initiator.json";
|
|
156031
|
+
function writeUnattributedTurnMarker(channel, opts = {}) {
|
|
156032
|
+
try {
|
|
156033
|
+
const file = resolveTurnInitiatorFile(opts.env ?? process.env, opts.home ?? homedir());
|
|
156034
|
+
if (!file) return;
|
|
156035
|
+
mkdirSync2(dirname2(file), { recursive: true });
|
|
156036
|
+
updateTurnInitiatorLedger(file, {
|
|
156037
|
+
channel,
|
|
156038
|
+
sender_id: "",
|
|
156039
|
+
channel_ref: "unattributed",
|
|
156040
|
+
unattributed: true,
|
|
156041
|
+
ts: opts.now ?? Date.now()
|
|
156042
|
+
});
|
|
156043
|
+
} catch {
|
|
156044
|
+
}
|
|
156045
|
+
}
|
|
156046
|
+
function resolveTurnInitiatorFile(env = process.env, home = homedir()) {
|
|
156047
|
+
const injected = env["AGT_TURN_INITIATOR_FILE"]?.trim();
|
|
156048
|
+
if (injected) return injected;
|
|
156049
|
+
const dir = resolveAgentDirAlias({
|
|
156050
|
+
codeName: env["AGT_AGENT_CODE_NAME"],
|
|
156051
|
+
agentId: env["AGT_AGENT_ID"],
|
|
156052
|
+
turnInitiatorFile: null,
|
|
156053
|
+
homeDir: home
|
|
156054
|
+
});
|
|
156055
|
+
return dir ? join7(dir, TURN_INITIATOR_MARKER_FILENAME) : null;
|
|
156056
|
+
}
|
|
156057
|
+
|
|
155935
156058
|
// src/whatsapp-channel.ts
|
|
155936
156059
|
var CODE_NAME = process.env["AGT_AGENT_CODE_NAME"] ?? "";
|
|
155937
|
-
var PENDING_INBOUND_DIR = CODE_NAME ?
|
|
156060
|
+
var PENDING_INBOUND_DIR = CODE_NAME ? join8(homedir2(), ".augmented", CODE_NAME, "whatsapp-pending-inbound") : null;
|
|
155938
156061
|
var PROVIDER = (process.env["WHATSAPP_PROVIDER"] ?? "kapso").toLowerCase();
|
|
155939
156062
|
var IS_BAILEYS = PROVIDER === "baileys";
|
|
155940
156063
|
var kapso = IS_BAILEYS ? null : createKapsoClient({
|
|
@@ -155951,10 +156074,10 @@ async function processPendingFile(filename) {
|
|
|
155951
156074
|
if (!PENDING_INBOUND_DIR) return;
|
|
155952
156075
|
if (processed.has(filename)) return;
|
|
155953
156076
|
processed.add(filename);
|
|
155954
|
-
const full =
|
|
156077
|
+
const full = join8(PENDING_INBOUND_DIR, filename);
|
|
155955
156078
|
let raw;
|
|
155956
156079
|
try {
|
|
155957
|
-
raw = JSON.parse(
|
|
156080
|
+
raw = JSON.parse(readFileSync4(full, "utf8"));
|
|
155958
156081
|
} catch (err) {
|
|
155959
156082
|
processed.delete(filename);
|
|
155960
156083
|
process.stderr.write(`whatsapp-channel: read/parse failed for ${filename} (${err.message})
|
|
@@ -155968,6 +156091,7 @@ async function processPendingFile(filename) {
|
|
|
155968
156091
|
return;
|
|
155969
156092
|
}
|
|
155970
156093
|
lastInboundBySender.set(note.senderId, note.receivedAtMs);
|
|
156094
|
+
writeUnattributedTurnMarker("whatsapp");
|
|
155971
156095
|
try {
|
|
155972
156096
|
await mcp.notification({
|
|
155973
156097
|
method: "notifications/claude/channel",
|
|
@@ -155986,7 +156110,7 @@ function startPendingInboundWatcher() {
|
|
|
155986
156110
|
return;
|
|
155987
156111
|
}
|
|
155988
156112
|
try {
|
|
155989
|
-
const entries = readdirSync(PENDING_INBOUND_DIR).filter((f) => f.endsWith(".json") && !f.startsWith(".")).map((f) => ({ f, m: safeMtimeMs(
|
|
156113
|
+
const entries = readdirSync(PENDING_INBOUND_DIR).filter((f) => f.endsWith(".json") && !f.startsWith(".")).map((f) => ({ f, m: safeMtimeMs(join8(PENDING_INBOUND_DIR, f)) })).sort((a, b) => a.m - b.m).map((e) => e.f);
|
|
155990
156114
|
for (const f of entries) {
|
|
155991
156115
|
void processPendingFile(f);
|
|
155992
156116
|
}
|
|
@@ -156001,7 +156125,7 @@ function startPendingInboundWatcher() {
|
|
|
156001
156125
|
if (!name || typeof name !== "string") return;
|
|
156002
156126
|
if (!name.endsWith(".json") || name.startsWith(".")) return;
|
|
156003
156127
|
try {
|
|
156004
|
-
statSync(
|
|
156128
|
+
statSync(join8(PENDING_INBOUND_DIR, name));
|
|
156005
156129
|
} catch {
|
|
156006
156130
|
return;
|
|
156007
156131
|
}
|
|
@@ -156037,6 +156161,7 @@ async function pushBaileysInbound(msg, attempt = 1) {
|
|
|
156037
156161
|
if (msg.senderName) meta["sender_name"] = msg.senderName;
|
|
156038
156162
|
if (msg.isGroup) meta["is_group"] = "true";
|
|
156039
156163
|
if (msg.participant) meta["participant"] = msg.participant;
|
|
156164
|
+
writeUnattributedTurnMarker("whatsapp");
|
|
156040
156165
|
try {
|
|
156041
156166
|
await mcp.notification({
|
|
156042
156167
|
method: "notifications/claude/channel",
|
|
@@ -156065,7 +156190,7 @@ async function startBaileysRuntime() {
|
|
|
156065
156190
|
process.stderr.write("whatsapp-channel: AGT_AGENT_CODE_NAME not set \u2014 baileys disabled\n");
|
|
156066
156191
|
return;
|
|
156067
156192
|
}
|
|
156068
|
-
const authDir =
|
|
156193
|
+
const authDir = join8(homedir2(), ".augmented", CODE_NAME, "whatsapp-baileys-auth");
|
|
156069
156194
|
try {
|
|
156070
156195
|
baileysSession = await startBaileysSession({
|
|
156071
156196
|
authDir,
|
package/package.json
CHANGED
|
File without changes
|