@integrity-labs/agt-cli 0.28.1160 → 0.28.1161
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
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
success,
|
|
41
41
|
table,
|
|
42
42
|
warn
|
|
43
|
-
} from "../chunk-
|
|
43
|
+
} from "../chunk-7M3EEBVM.js";
|
|
44
44
|
import {
|
|
45
45
|
getProjectDir,
|
|
46
46
|
isSessionResumeDisabled,
|
|
@@ -5513,7 +5513,7 @@ import { execFileSync, execSync } from "child_process";
|
|
|
5513
5513
|
import { existsSync as existsSync11, realpathSync as realpathSync2 } from "fs";
|
|
5514
5514
|
import chalk18 from "chalk";
|
|
5515
5515
|
import ora16 from "ora";
|
|
5516
|
-
var cliVersion = true ? "0.28.
|
|
5516
|
+
var cliVersion = true ? "0.28.1161" : "dev";
|
|
5517
5517
|
async function fetchLatestVersion() {
|
|
5518
5518
|
const host2 = getHost();
|
|
5519
5519
|
if (!host2) return null;
|
|
@@ -6773,7 +6773,7 @@ function handleError(err) {
|
|
|
6773
6773
|
}
|
|
6774
6774
|
|
|
6775
6775
|
// src/bin/agt.ts
|
|
6776
|
-
var cliVersion2 = true ? "0.28.
|
|
6776
|
+
var cliVersion2 = true ? "0.28.1161" : "dev";
|
|
6777
6777
|
var program = new Command();
|
|
6778
6778
|
program.name("agt").description("Augmented CLI \u2014 agent provisioning and management").version(cliVersion2).option("--json", "Emit machine-readable JSON output (suppress spinners and colors)").option("--skip-update-check", "Skip the automatic update check on startup");
|
|
6779
6779
|
program.hook("preAction", async (thisCommand, actionCommand) => {
|
|
@@ -8078,7 +8078,7 @@ function exchangeFailureKind(err) {
|
|
|
8078
8078
|
}
|
|
8079
8079
|
|
|
8080
8080
|
// src/lib/api-client.ts
|
|
8081
|
-
var agtCliVersion = true ? "0.28.
|
|
8081
|
+
var agtCliVersion = true ? "0.28.1161" : "dev";
|
|
8082
8082
|
var lastConfigHash = null;
|
|
8083
8083
|
function setConfigHash(hash) {
|
|
8084
8084
|
lastConfigHash = hash && hash.length > 0 ? hash : null;
|
|
@@ -13235,4 +13235,4 @@ export {
|
|
|
13235
13235
|
managerInstallSystemUnitCommand,
|
|
13236
13236
|
managerUninstallSystemUnitCommand
|
|
13237
13237
|
};
|
|
13238
|
-
//# sourceMappingURL=chunk-
|
|
13238
|
+
//# sourceMappingURL=chunk-7M3EEBVM.js.map
|
|
@@ -77,7 +77,7 @@ import {
|
|
|
77
77
|
setConfigHash,
|
|
78
78
|
shellGuard,
|
|
79
79
|
tripClass
|
|
80
|
-
} from "../chunk-
|
|
80
|
+
} from "../chunk-7M3EEBVM.js";
|
|
81
81
|
import {
|
|
82
82
|
CLAUDE_CODE_SECURITY_FLOOR,
|
|
83
83
|
SELF_UPDATE_TIMEOUTS,
|
|
@@ -15874,7 +15874,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
15874
15874
|
var lastVersionCheckAt = 0;
|
|
15875
15875
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
15876
15876
|
var lastResponsivenessProbeAt = 0;
|
|
15877
|
-
var agtCliVersion = true ? "0.28.
|
|
15877
|
+
var agtCliVersion = true ? "0.28.1161" : "dev";
|
|
15878
15878
|
function resolveBrewPath(execFileSync3) {
|
|
15879
15879
|
try {
|
|
15880
15880
|
const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -43095,7 +43095,7 @@ function emitHtmlEntityDecodeTelemetry(channel, count = 0) {
|
|
|
43095
43095
|
}
|
|
43096
43096
|
|
|
43097
43097
|
// src/slack-pending-inbound-cleanup.ts
|
|
43098
|
-
import { existsSync as existsSync4, readdirSync as readdirSync4, statSync as statSync3, unlinkSync } from "fs";
|
|
43098
|
+
import { existsSync as existsSync4, readFileSync as readFileSync5, readdirSync as readdirSync4, statSync as statSync3, unlinkSync } from "fs";
|
|
43099
43099
|
import { join as join9 } from "path";
|
|
43100
43100
|
function sanitizeMarkerSegment(value) {
|
|
43101
43101
|
return value.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
@@ -43123,6 +43123,20 @@ function clearAllSlackPendingMarkersForThread(dir, channel, threadTs, clear = de
|
|
|
43123
43123
|
const prefix = `${sanitizeMarkerSegment(channel)}__${sanitizeMarkerSegment(threadTs)}__`;
|
|
43124
43124
|
return applyToMatchingMarkers(dir, prefix, ".json", clear);
|
|
43125
43125
|
}
|
|
43126
|
+
function countOwedSlackRepliesForThread(dir, channel, threadTs) {
|
|
43127
|
+
const prefix = `${sanitizeMarkerSegment(channel)}__${sanitizeMarkerSegment(threadTs)}__`;
|
|
43128
|
+
let owed = 0;
|
|
43129
|
+
applyToMatchingMarkers(dir, prefix, ".json", (fullPath) => {
|
|
43130
|
+
try {
|
|
43131
|
+
const m = JSON.parse(readFileSync5(fullPath, "utf-8"));
|
|
43132
|
+
if (!m || typeof m !== "object") return;
|
|
43133
|
+
if (m.discretionary === true || m.undeliverable === true) return;
|
|
43134
|
+
owed += 1;
|
|
43135
|
+
} catch {
|
|
43136
|
+
}
|
|
43137
|
+
});
|
|
43138
|
+
return owed;
|
|
43139
|
+
}
|
|
43126
43140
|
function markSeenAllSlackPendingMarkersForThread(dir, channel, threadTs, markSeen) {
|
|
43127
43141
|
const prefix = `${sanitizeMarkerSegment(channel)}__${sanitizeMarkerSegment(threadTs)}__`;
|
|
43128
43142
|
return applyToMatchingMarkers(dir, prefix, ".json", markSeen);
|
|
@@ -43498,7 +43512,7 @@ function applyHotThreadGuard(input) {
|
|
|
43498
43512
|
}
|
|
43499
43513
|
|
|
43500
43514
|
// src/slack-hot-thread-telemetry.ts
|
|
43501
|
-
import { readFileSync as
|
|
43515
|
+
import { readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
|
|
43502
43516
|
import { join as join11 } from "path";
|
|
43503
43517
|
var HOT_THREAD_CLASSIFICATION_COUNTER_SUFFIX = "-hot-thread-classifications.json";
|
|
43504
43518
|
function hotThreadKey(mode, outcome, proactive) {
|
|
@@ -43509,7 +43523,7 @@ function recordHotThreadClassification(agentDir, channel, classification) {
|
|
|
43509
43523
|
const path = join11(agentDir, `${channel}${HOT_THREAD_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
43510
43524
|
let counts = {};
|
|
43511
43525
|
try {
|
|
43512
|
-
const parsed = JSON.parse(
|
|
43526
|
+
const parsed = JSON.parse(readFileSync6(path, "utf-8"));
|
|
43513
43527
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
43514
43528
|
for (const [k, v] of Object.entries(parsed)) {
|
|
43515
43529
|
if (typeof v === "number" && Number.isInteger(v) && v >= 0) counts[k] = v;
|
|
@@ -43526,7 +43540,7 @@ function recordHotThreadClassification(agentDir, channel, classification) {
|
|
|
43526
43540
|
}
|
|
43527
43541
|
|
|
43528
43542
|
// src/restart-confirm.ts
|
|
43529
|
-
import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as
|
|
43543
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync7, renameSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
43530
43544
|
import { dirname } from "path";
|
|
43531
43545
|
import { randomUUID } from "crypto";
|
|
43532
43546
|
var RESTART_CONFIRM_MAX_AGE_MS = 10 * 60 * 1e3;
|
|
@@ -43552,7 +43566,7 @@ function writeRestartConfirmMarker(filePath, marker) {
|
|
|
43552
43566
|
function readRestartConfirmMarker(filePath) {
|
|
43553
43567
|
try {
|
|
43554
43568
|
if (!existsSync6(filePath)) return null;
|
|
43555
|
-
const parsed = JSON.parse(
|
|
43569
|
+
const parsed = JSON.parse(readFileSync7(filePath, "utf8"));
|
|
43556
43570
|
if (!parsed || typeof parsed !== "object") return null;
|
|
43557
43571
|
return parsed;
|
|
43558
43572
|
} catch {
|
|
@@ -43712,7 +43726,7 @@ import {
|
|
|
43712
43726
|
ftruncateSync,
|
|
43713
43727
|
mkdirSync as mkdirSync10,
|
|
43714
43728
|
openSync as openSync2,
|
|
43715
|
-
readFileSync as
|
|
43729
|
+
readFileSync as readFileSync20,
|
|
43716
43730
|
readdirSync as readdirSync7,
|
|
43717
43731
|
renameSync as renameSync5,
|
|
43718
43732
|
statSync as statSync5,
|
|
@@ -43726,7 +43740,7 @@ import { homedir as homedir7 } from "os";
|
|
|
43726
43740
|
import { createHash as createHash3, randomUUID as randomUUID2 } from "crypto";
|
|
43727
43741
|
|
|
43728
43742
|
// src/slack-thread-store.ts
|
|
43729
|
-
import { mkdirSync as mkdirSync3, readFileSync as
|
|
43743
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync8, writeFileSync as writeFileSync5 } from "fs";
|
|
43730
43744
|
import { dirname as dirname2 } from "path";
|
|
43731
43745
|
function isParticipatingThread(entry) {
|
|
43732
43746
|
if (!entry) return false;
|
|
@@ -43741,7 +43755,7 @@ function loadThreadStore(filePath, opts = {}) {
|
|
|
43741
43755
|
const ttlMs = ttlDays * 24 * 60 * 60 * 1e3;
|
|
43742
43756
|
let raw;
|
|
43743
43757
|
try {
|
|
43744
|
-
raw =
|
|
43758
|
+
raw = readFileSync8(filePath, "utf-8");
|
|
43745
43759
|
} catch {
|
|
43746
43760
|
return { threads: /* @__PURE__ */ new Map(), pruned: 0 };
|
|
43747
43761
|
}
|
|
@@ -43842,7 +43856,7 @@ function isThreadEntry(value) {
|
|
|
43842
43856
|
}
|
|
43843
43857
|
|
|
43844
43858
|
// src/dm-restart-notice.ts
|
|
43845
|
-
import { mkdirSync as mkdirSync4, readFileSync as
|
|
43859
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync9, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "fs";
|
|
43846
43860
|
import { dirname as dirname3 } from "path";
|
|
43847
43861
|
var RECENT_DM_VERSION = 1;
|
|
43848
43862
|
var DEFAULT_RECENT_DM_TTL_MS = 30 * 60 * 1e3;
|
|
@@ -43866,7 +43880,7 @@ function loadRecentDms(filePath, opts = {}) {
|
|
|
43866
43880
|
const ttlMs = opts.ttlMs ?? DEFAULT_RECENT_DM_TTL_MS;
|
|
43867
43881
|
let raw;
|
|
43868
43882
|
try {
|
|
43869
|
-
raw =
|
|
43883
|
+
raw = readFileSync9(filePath, "utf-8");
|
|
43870
43884
|
} catch (err) {
|
|
43871
43885
|
const code = err.code;
|
|
43872
43886
|
if (code !== "ENOENT") {
|
|
@@ -43951,7 +43965,7 @@ var CHANNEL_ADD_RESTART_MAX_AGE_MS = 15 * 60 * 1e3;
|
|
|
43951
43965
|
function readChannelAddRestartMarker(filePath) {
|
|
43952
43966
|
let raw;
|
|
43953
43967
|
try {
|
|
43954
|
-
raw =
|
|
43968
|
+
raw = readFileSync9(filePath, "utf-8");
|
|
43955
43969
|
} catch {
|
|
43956
43970
|
return null;
|
|
43957
43971
|
}
|
|
@@ -44094,7 +44108,7 @@ function createReconnectScheduler(deps) {
|
|
|
44094
44108
|
}
|
|
44095
44109
|
|
|
44096
44110
|
// src/turn-initiator-marker.ts
|
|
44097
|
-
import { writeFileSync as writeFileSync7, readFileSync as
|
|
44111
|
+
import { writeFileSync as writeFileSync7, readFileSync as readFileSync10, mkdirSync as mkdirSync5, renameSync as renameSync2 } from "fs";
|
|
44098
44112
|
import { dirname as dirname4, join as join12 } from "path";
|
|
44099
44113
|
var TURN_INITIATOR_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
44100
44114
|
var TURN_INITIATOR_LEDGER_MAX_ENTRIES = 20;
|
|
@@ -44128,7 +44142,7 @@ function updateTurnInitiatorLedger(singleSlotFile, marker) {
|
|
|
44128
44142
|
const ledgerFile = turnInitiatorLedgerPath(singleSlotFile);
|
|
44129
44143
|
let existing = null;
|
|
44130
44144
|
try {
|
|
44131
|
-
const parsed = JSON.parse(
|
|
44145
|
+
const parsed = JSON.parse(readFileSync10(ledgerFile, "utf8"));
|
|
44132
44146
|
if (parsed && parsed.v === 1 && Array.isArray(parsed.entries)) existing = parsed;
|
|
44133
44147
|
} catch {
|
|
44134
44148
|
}
|
|
@@ -44155,7 +44169,7 @@ function writeTurnInitiatorMarker(input) {
|
|
|
44155
44169
|
}
|
|
44156
44170
|
|
|
44157
44171
|
// src/turn-context.ts
|
|
44158
|
-
import { mkdirSync as mkdirSync6, readFileSync as
|
|
44172
|
+
import { mkdirSync as mkdirSync6, readFileSync as readFileSync12 } from "fs";
|
|
44159
44173
|
import { homedir as homedir6 } from "os";
|
|
44160
44174
|
import { dirname as dirname5, join as join15 } from "path";
|
|
44161
44175
|
|
|
@@ -44199,7 +44213,7 @@ function resolveAgentDirAlias(input) {
|
|
|
44199
44213
|
}
|
|
44200
44214
|
|
|
44201
44215
|
// src/scheduled-turn-marker.ts
|
|
44202
|
-
import { readFileSync as
|
|
44216
|
+
import { readFileSync as readFileSync11, unlinkSync as unlinkSync5 } from "fs";
|
|
44203
44217
|
import { join as join14 } from "path";
|
|
44204
44218
|
var SCHEDULED_TURN_MARKER_FILENAME2 = ".current-scheduled-turn.json";
|
|
44205
44219
|
var SCHEDULED_TURN_MAX_AGE_MS = 15 * 60 * 1e3;
|
|
@@ -44238,7 +44252,7 @@ function readScheduledTurnMarker(agentDir, now = Date.now()) {
|
|
|
44238
44252
|
if (!agentDir) return null;
|
|
44239
44253
|
try {
|
|
44240
44254
|
const raw = JSON.parse(
|
|
44241
|
-
|
|
44255
|
+
readFileSync11(join14(agentDir, SCHEDULED_TURN_MARKER_FILENAME2), "utf8")
|
|
44242
44256
|
);
|
|
44243
44257
|
return validateScheduledTurnMarker(raw, now);
|
|
44244
44258
|
} catch {
|
|
@@ -44283,7 +44297,7 @@ function resolveTurnInitiatorFile(env2 = process.env, home = homedir6()) {
|
|
|
44283
44297
|
}
|
|
44284
44298
|
|
|
44285
44299
|
// src/slack-bot-photo.ts
|
|
44286
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readFileSync as
|
|
44300
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readFileSync as readFileSync13, writeFileSync as writeFileSync8 } from "fs";
|
|
44287
44301
|
import { dirname as dirname6 } from "path";
|
|
44288
44302
|
async function applyBotPhoto(opts) {
|
|
44289
44303
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
@@ -44293,7 +44307,7 @@ async function applyBotPhoto(opts) {
|
|
|
44293
44307
|
const { token, avatarUrl, markerPath } = opts;
|
|
44294
44308
|
if (markerPath && existsSync7(markerPath)) {
|
|
44295
44309
|
try {
|
|
44296
|
-
if (
|
|
44310
|
+
if (readFileSync13(markerPath, "utf-8").trim() === avatarUrl) {
|
|
44297
44311
|
return { status: "skipped-unchanged" };
|
|
44298
44312
|
}
|
|
44299
44313
|
} catch {
|
|
@@ -44418,7 +44432,7 @@ function conversationalLaneMeta(expectsReply = true) {
|
|
|
44418
44432
|
}
|
|
44419
44433
|
|
|
44420
44434
|
// src/inbound-lane-telemetry.ts
|
|
44421
|
-
import { readFileSync as
|
|
44435
|
+
import { readFileSync as readFileSync14, writeFileSync as writeFileSync9 } from "fs";
|
|
44422
44436
|
import { join as join16 } from "path";
|
|
44423
44437
|
var LANE_CLASSIFICATION_COUNTER_SUFFIX = "-lane-classifications.json";
|
|
44424
44438
|
var SUSPECTED_MISCLASSIFICATION_KEY = "suspected_misclassification";
|
|
@@ -44439,7 +44453,7 @@ function recordLaneClassification(agentDir, channel, classification) {
|
|
|
44439
44453
|
const path = join16(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
44440
44454
|
let counts = {};
|
|
44441
44455
|
try {
|
|
44442
|
-
const parsed = JSON.parse(
|
|
44456
|
+
const parsed = JSON.parse(readFileSync14(path, "utf-8"));
|
|
44443
44457
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
44444
44458
|
} catch {
|
|
44445
44459
|
}
|
|
@@ -44455,7 +44469,7 @@ function recordLaneClassification(agentDir, channel, classification) {
|
|
|
44455
44469
|
}
|
|
44456
44470
|
|
|
44457
44471
|
// src/slack-inbound-registry.ts
|
|
44458
|
-
import { readdirSync as readdirSync5, readFileSync as
|
|
44472
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync15 } from "fs";
|
|
44459
44473
|
import { join as join17 } from "path";
|
|
44460
44474
|
var DEFAULT_MAX_ENTRIES = 500;
|
|
44461
44475
|
var DEFAULT_CLEARED_TTL_MS = 6 * 60 * 60 * 1e3;
|
|
@@ -44577,7 +44591,7 @@ function createInboundRegistry(opts = {}) {
|
|
|
44577
44591
|
if (name.includes(".retry-") || name.includes(".poison")) continue;
|
|
44578
44592
|
let marker;
|
|
44579
44593
|
try {
|
|
44580
|
-
marker = JSON.parse(
|
|
44594
|
+
marker = JSON.parse(readFileSync15(join17(dir, name), "utf-8"));
|
|
44581
44595
|
} catch {
|
|
44582
44596
|
continue;
|
|
44583
44597
|
}
|
|
@@ -44622,7 +44636,7 @@ function slackInboundId(channel, threadTs, messageTs) {
|
|
|
44622
44636
|
}
|
|
44623
44637
|
|
|
44624
44638
|
// src/inbound-delivery-ledger.ts
|
|
44625
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync8, readdirSync as readdirSync6, readFileSync as
|
|
44639
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync8, readdirSync as readdirSync6, readFileSync as readFileSync16, renameSync as renameSync3, writeFileSync as writeFileSync10 } from "fs";
|
|
44626
44640
|
import { join as join18 } from "path";
|
|
44627
44641
|
function safeInboundId(inboundId) {
|
|
44628
44642
|
return inboundId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
@@ -44632,7 +44646,7 @@ var defaultDeps = {
|
|
|
44632
44646
|
writeFile: (path, data) => writeFileSync10(path, data, "utf8"),
|
|
44633
44647
|
rename: (from, to) => renameSync3(from, to),
|
|
44634
44648
|
readdir: (dir) => readdirSync6(dir),
|
|
44635
|
-
readFile: (path) =>
|
|
44649
|
+
readFile: (path) => readFileSync16(path, "utf8"),
|
|
44636
44650
|
exists: (path) => existsSync8(path)
|
|
44637
44651
|
};
|
|
44638
44652
|
function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
|
|
@@ -44826,7 +44840,7 @@ function describeSendOutcome(dest) {
|
|
|
44826
44840
|
}
|
|
44827
44841
|
|
|
44828
44842
|
// src/slack-reply-binding-telemetry.ts
|
|
44829
|
-
import { readFileSync as
|
|
44843
|
+
import { readFileSync as readFileSync17, writeFileSync as writeFileSync11 } from "fs";
|
|
44830
44844
|
import { join as join19 } from "path";
|
|
44831
44845
|
var REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX = "-reply-binding-classifications.json";
|
|
44832
44846
|
var UNKNOWN_INBOUND_ID_KEY = "unknown_inbound_id";
|
|
@@ -44845,7 +44859,7 @@ function recordReplyBindingClassification(agentDir, channel, input) {
|
|
|
44845
44859
|
const path = join19(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
44846
44860
|
let counts = {};
|
|
44847
44861
|
try {
|
|
44848
|
-
const parsed = JSON.parse(
|
|
44862
|
+
const parsed = JSON.parse(readFileSync17(path, "utf-8"));
|
|
44849
44863
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
44850
44864
|
} catch {
|
|
44851
44865
|
}
|
|
@@ -44863,7 +44877,7 @@ function recordScheduledChannelOverride(agentDir, channel, input) {
|
|
|
44863
44877
|
const path = join19(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
44864
44878
|
let counts = {};
|
|
44865
44879
|
try {
|
|
44866
|
-
const parsed = JSON.parse(
|
|
44880
|
+
const parsed = JSON.parse(readFileSync17(path, "utf-8"));
|
|
44867
44881
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
44868
44882
|
} catch {
|
|
44869
44883
|
}
|
|
@@ -44879,7 +44893,7 @@ function recordChannelMistarget(agentDir, channel, input) {
|
|
|
44879
44893
|
const path = join19(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
44880
44894
|
let counts = {};
|
|
44881
44895
|
try {
|
|
44882
|
-
const parsed = JSON.parse(
|
|
44896
|
+
const parsed = JSON.parse(readFileSync17(path, "utf-8"));
|
|
44883
44897
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
44884
44898
|
} catch {
|
|
44885
44899
|
}
|
|
@@ -44894,7 +44908,7 @@ function recordChannelMistarget(agentDir, channel, input) {
|
|
|
44894
44908
|
}
|
|
44895
44909
|
|
|
44896
44910
|
// src/slack-reply-target-telemetry.ts
|
|
44897
|
-
import { readFileSync as
|
|
44911
|
+
import { readFileSync as readFileSync18, writeFileSync as writeFileSync12 } from "fs";
|
|
44898
44912
|
import { join as join20 } from "path";
|
|
44899
44913
|
var REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX = "-reply-target-classifications.json";
|
|
44900
44914
|
function pendingThreadsBucket(n) {
|
|
@@ -44931,7 +44945,7 @@ function recordReplyTargetClassification(agentDir, channel, classification) {
|
|
|
44931
44945
|
const path = join20(agentDir, `${channel}${REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
44932
44946
|
let counts = {};
|
|
44933
44947
|
try {
|
|
44934
|
-
const parsed = JSON.parse(
|
|
44948
|
+
const parsed = JSON.parse(readFileSync18(path, "utf-8"));
|
|
44935
44949
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
44936
44950
|
} catch {
|
|
44937
44951
|
}
|
|
@@ -44954,13 +44968,18 @@ function scheduledDestOverridesNamedChannel(opts) {
|
|
|
44954
44968
|
if (!opts.namedChannel) return false;
|
|
44955
44969
|
return opts.scheduledTargetChannel !== opts.namedChannel;
|
|
44956
44970
|
}
|
|
44971
|
+
function explicitThreadForScheduledPriority(threadTs, owedReplies) {
|
|
44972
|
+
if (typeof threadTs !== "string" || !threadTs) return void 0;
|
|
44973
|
+
return owedReplies(threadTs) > 0 ? threadTs : void 0;
|
|
44974
|
+
}
|
|
44957
44975
|
function resolveSlackScheduledPriority(opts) {
|
|
44958
44976
|
const inboundUnresolved = !!opts.inboundId && opts.inboundResolved === false;
|
|
44959
44977
|
const inboundWins = !!(opts.inboundId && !inboundUnresolved || opts.enforceBound);
|
|
44960
44978
|
const effectiveChannel = inboundWins ? opts.bindingChannel ?? opts.fallbackChannel : opts.scheduledDest && !inboundUnresolved ? opts.scheduledDest.channel : opts.fallbackChannel;
|
|
44961
|
-
const
|
|
44979
|
+
const keepExplicitThread = !inboundWins && !inboundUnresolved && !!opts.scheduledDest && !opts.scheduledDest.thread_ts && !!opts.explicitThreadTs && opts.fallbackChannel === opts.scheduledDest.channel;
|
|
44980
|
+
const effectiveThreadTs = opts.forcedRoot ? void 0 : inboundWins ? opts.bindingThreadTs ?? void 0 : keepExplicitThread ? opts.explicitThreadTs ?? void 0 : opts.scheduledDest && !inboundUnresolved ? opts.scheduledDest.thread_ts : opts.fallbackThreadTs ?? void 0;
|
|
44962
44981
|
const settleThreadTs = inboundWins ? opts.bindingThreadTs ?? void 0 : opts.fallbackSettleThreadTs ?? void 0;
|
|
44963
|
-
const scheduledRetarget = !inboundWins && !inboundUnresolved && !!opts.scheduledDest;
|
|
44982
|
+
const scheduledRetarget = !inboundWins && !inboundUnresolved && !!opts.scheduledDest && !keepExplicitThread;
|
|
44964
44983
|
const fellBack = inboundUnresolved || scheduledRetarget;
|
|
44965
44984
|
const reason = inboundUnresolved ? "unresolved_inbound" : scheduledRetarget ? "scheduled" : opts.forcedRoot ? "forced_root" : inboundWins ? "bound" : "fallback";
|
|
44966
44985
|
return { effectiveChannel, effectiveThreadTs, settleThreadTs, reason, fellBack };
|
|
@@ -45879,7 +45898,7 @@ function textMentionsBot(text, botId) {
|
|
|
45879
45898
|
import {
|
|
45880
45899
|
existsSync as existsSync9,
|
|
45881
45900
|
mkdirSync as mkdirSync9,
|
|
45882
|
-
readFileSync as
|
|
45901
|
+
readFileSync as readFileSync19,
|
|
45883
45902
|
renameSync as renameSync4,
|
|
45884
45903
|
statSync as statSync4,
|
|
45885
45904
|
unlinkSync as unlinkSync6,
|
|
@@ -45976,7 +45995,7 @@ function defaultLockMtimeMs(path) {
|
|
|
45976
45995
|
function readLockHolder(path) {
|
|
45977
45996
|
if (!existsSync9(path)) return null;
|
|
45978
45997
|
try {
|
|
45979
|
-
const raw =
|
|
45998
|
+
const raw = readFileSync19(path, "utf8");
|
|
45980
45999
|
const parsed = JSON.parse(raw);
|
|
45981
46000
|
const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
|
|
45982
46001
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
@@ -46490,7 +46509,7 @@ function readLiveAllowedUsers() {
|
|
|
46490
46509
|
return liveAllowedUsersCache.value;
|
|
46491
46510
|
}
|
|
46492
46511
|
const value = extractAllowedUsersFromMcpJson(
|
|
46493
|
-
|
|
46512
|
+
readFileSync20(SLACK_MCP_CONFIG_PATH, "utf-8")
|
|
46494
46513
|
);
|
|
46495
46514
|
if (value === null) return null;
|
|
46496
46515
|
liveAllowedUsersCache = { mtimeMs, value };
|
|
@@ -46511,7 +46530,7 @@ function readLivePingAllowedUsers() {
|
|
|
46511
46530
|
return livePingAllowedUsersCache.value;
|
|
46512
46531
|
}
|
|
46513
46532
|
const value = extractPingAllowedUsersFromMcpJson(
|
|
46514
|
-
|
|
46533
|
+
readFileSync20(SLACK_MCP_CONFIG_PATH, "utf-8")
|
|
46515
46534
|
);
|
|
46516
46535
|
if (value === null) return null;
|
|
46517
46536
|
livePingAllowedUsersCache = { mtimeMs, value };
|
|
@@ -46603,7 +46622,7 @@ function markSlackMarkerPromisedInPlace(fullPath) {
|
|
|
46603
46622
|
function markSlackMarkerEngagedInPlace(fullPath, opts) {
|
|
46604
46623
|
let marker;
|
|
46605
46624
|
try {
|
|
46606
|
-
marker = JSON.parse(
|
|
46625
|
+
marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
|
|
46607
46626
|
} catch {
|
|
46608
46627
|
return false;
|
|
46609
46628
|
}
|
|
@@ -46618,7 +46637,7 @@ function markSlackMarkerEngagedInPlace(fullPath, opts) {
|
|
|
46618
46637
|
rewriteSlackMarkerInPlace(fullPath, marker);
|
|
46619
46638
|
if (!opts.promise) return false;
|
|
46620
46639
|
try {
|
|
46621
|
-
const readBack = JSON.parse(
|
|
46640
|
+
const readBack = JSON.parse(readFileSync20(fullPath, "utf-8"));
|
|
46622
46641
|
return typeof readBack.promised_at === "string" && readBack.promised_at.length > 0;
|
|
46623
46642
|
} catch {
|
|
46624
46643
|
return false;
|
|
@@ -46629,7 +46648,7 @@ function attachSlackReplayPayload(channel, threadTs, messageTs, payload) {
|
|
|
46629
46648
|
if (!path) return;
|
|
46630
46649
|
let marker;
|
|
46631
46650
|
try {
|
|
46632
|
-
marker = JSON.parse(
|
|
46651
|
+
marker = JSON.parse(readFileSync20(path, "utf-8"));
|
|
46633
46652
|
} catch {
|
|
46634
46653
|
return;
|
|
46635
46654
|
}
|
|
@@ -46640,7 +46659,7 @@ function readSlackPendingInboundMarker(channel, threadTs, messageTs) {
|
|
|
46640
46659
|
const path = slackPendingInboundPath(channel, threadTs, messageTs);
|
|
46641
46660
|
if (!path || !existsSync10(path)) return null;
|
|
46642
46661
|
try {
|
|
46643
|
-
return JSON.parse(
|
|
46662
|
+
return JSON.parse(readFileSync20(path, "utf-8"));
|
|
46644
46663
|
} catch {
|
|
46645
46664
|
return null;
|
|
46646
46665
|
}
|
|
@@ -46690,7 +46709,7 @@ function slackConversationReplayFacts(channel, threadTs) {
|
|
|
46690
46709
|
threadTs,
|
|
46691
46710
|
(fullPath) => {
|
|
46692
46711
|
try {
|
|
46693
|
-
const marker = JSON.parse(
|
|
46712
|
+
const marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
|
|
46694
46713
|
found.push({ hasPayload: Boolean(marker.payload), discretionary: marker.discretionary });
|
|
46695
46714
|
} catch {
|
|
46696
46715
|
found.push({ hasPayload: false });
|
|
@@ -46859,7 +46878,7 @@ function __resetSlackBusyAckNoticeThrottle() {
|
|
|
46859
46878
|
function clearSlackMarkerFileWithHeal(fullPath) {
|
|
46860
46879
|
let marker = null;
|
|
46861
46880
|
try {
|
|
46862
|
-
marker = JSON.parse(
|
|
46881
|
+
marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
|
|
46863
46882
|
} catch {
|
|
46864
46883
|
}
|
|
46865
46884
|
if (marker?.channel) {
|
|
@@ -46891,7 +46910,7 @@ var slackPromiseStampOutcome = { attempted: 0, stamped: 0 };
|
|
|
46891
46910
|
function healThenEngageSlackMarker(fullPath, opts) {
|
|
46892
46911
|
let marker = null;
|
|
46893
46912
|
try {
|
|
46894
|
-
marker = JSON.parse(
|
|
46913
|
+
marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
|
|
46895
46914
|
} catch {
|
|
46896
46915
|
return false;
|
|
46897
46916
|
}
|
|
@@ -46989,7 +47008,7 @@ function readSlackThreadMarkerState(channel, threadTs) {
|
|
|
46989
47008
|
threadTs,
|
|
46990
47009
|
(fullPath) => {
|
|
46991
47010
|
try {
|
|
46992
|
-
const m = JSON.parse(
|
|
47011
|
+
const m = JSON.parse(readFileSync20(fullPath, "utf-8"));
|
|
46993
47012
|
markers.push({ ingress_only: m.ingress_only });
|
|
46994
47013
|
} catch {
|
|
46995
47014
|
markers.push({});
|
|
@@ -47010,7 +47029,7 @@ async function processSlackRecoveryOutboxFile(filename) {
|
|
|
47010
47029
|
const fullPath = join22(SLACK_RECOVERY_OUTBOX_DIR, filename);
|
|
47011
47030
|
let payload;
|
|
47012
47031
|
try {
|
|
47013
|
-
payload = JSON.parse(
|
|
47032
|
+
payload = JSON.parse(readFileSync20(fullPath, "utf-8"));
|
|
47014
47033
|
} catch (err) {
|
|
47015
47034
|
process.stderr.write(
|
|
47016
47035
|
`slack-channel(${AGENT_CODE_NAME}): recovery outbox parse failed (${filename}): ${err.message}
|
|
@@ -47250,7 +47269,7 @@ async function processSlackNoticeOutboxFile(filename) {
|
|
|
47250
47269
|
}
|
|
47251
47270
|
let payload;
|
|
47252
47271
|
try {
|
|
47253
|
-
const parsed = JSON.parse(
|
|
47272
|
+
const parsed = JSON.parse(readFileSync20(fullPath, "utf-8"));
|
|
47254
47273
|
if (!parsed || typeof parsed !== "object") throw new Error("not an object");
|
|
47255
47274
|
payload = parsed;
|
|
47256
47275
|
} catch {
|
|
@@ -47409,7 +47428,7 @@ function sweepSlackStaleMarkers(thresholdMs) {
|
|
|
47409
47428
|
const fullPath = join22(SLACK_PENDING_INBOUND_DIR, filename);
|
|
47410
47429
|
let marker;
|
|
47411
47430
|
try {
|
|
47412
|
-
marker = JSON.parse(
|
|
47431
|
+
marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
|
|
47413
47432
|
} catch (err) {
|
|
47414
47433
|
process.stderr.write(
|
|
47415
47434
|
`slack-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactSlackId(filename)}: ${err.message}
|
|
@@ -47489,7 +47508,7 @@ var slackProgressTickRunning = false;
|
|
|
47489
47508
|
function readSlackProgressHeartbeat() {
|
|
47490
47509
|
if (!SLACK_PROGRESS_HEARTBEAT_PATH || !existsSync10(SLACK_PROGRESS_HEARTBEAT_PATH)) return null;
|
|
47491
47510
|
try {
|
|
47492
|
-
return parseProgressHeartbeat(
|
|
47511
|
+
return parseProgressHeartbeat(readFileSync20(SLACK_PROGRESS_HEARTBEAT_PATH, "utf-8"));
|
|
47493
47512
|
} catch {
|
|
47494
47513
|
return null;
|
|
47495
47514
|
}
|
|
@@ -47516,7 +47535,7 @@ function findSlackProgressTarget() {
|
|
|
47516
47535
|
if (!name.endsWith(".json")) continue;
|
|
47517
47536
|
let m;
|
|
47518
47537
|
try {
|
|
47519
|
-
m = JSON.parse(
|
|
47538
|
+
m = JSON.parse(readFileSync20(join22(SLACK_PENDING_INBOUND_DIR, name), "utf-8"));
|
|
47520
47539
|
} catch {
|
|
47521
47540
|
continue;
|
|
47522
47541
|
}
|
|
@@ -47667,7 +47686,7 @@ function listPendingSlackConversations() {
|
|
|
47667
47686
|
if (!name.endsWith(".json")) continue;
|
|
47668
47687
|
try {
|
|
47669
47688
|
const marker = JSON.parse(
|
|
47670
|
-
|
|
47689
|
+
readFileSync20(join22(SLACK_PENDING_INBOUND_DIR, name), "utf8")
|
|
47671
47690
|
);
|
|
47672
47691
|
if (typeof marker.channel !== "string" || !marker.channel) continue;
|
|
47673
47692
|
if (typeof marker.thread_ts !== "string" || !marker.thread_ts) continue;
|
|
@@ -47838,7 +47857,7 @@ function readRestartTopicForMarker(filename, channel, threadTs) {
|
|
|
47838
47857
|
if (!SLACK_RESTART_CONTEXT_DIR) return null;
|
|
47839
47858
|
let raw;
|
|
47840
47859
|
try {
|
|
47841
|
-
raw =
|
|
47860
|
+
raw = readFileSync20(join22(SLACK_RESTART_CONTEXT_DIR, filename), "utf-8");
|
|
47842
47861
|
} catch {
|
|
47843
47862
|
return null;
|
|
47844
47863
|
}
|
|
@@ -47892,7 +47911,7 @@ async function notifyStrandedInboundsOnFirstConnect() {
|
|
|
47892
47911
|
const fullPath = join22(SLACK_PENDING_INBOUND_DIR, filename);
|
|
47893
47912
|
let marker;
|
|
47894
47913
|
try {
|
|
47895
|
-
marker = JSON.parse(
|
|
47914
|
+
marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
|
|
47896
47915
|
} catch {
|
|
47897
47916
|
continue;
|
|
47898
47917
|
}
|
|
@@ -49514,12 +49533,6 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
49514
49533
|
};
|
|
49515
49534
|
}
|
|
49516
49535
|
}
|
|
49517
|
-
if (scheduledDest?.retargeted) {
|
|
49518
|
-
process.stderr.write(
|
|
49519
|
-
`slack-channel(${AGENT_CODE_NAME}): scheduled_turn_retargeted task=${scheduledMarker?.task_id ?? "?"} requested=${redactSlackId(channel)}/${redactSlackId(thread_ts)} routed=${redactSlackId(scheduledDest.channel)}/${redactSlackId(scheduledDest.thread_ts)}
|
|
49520
|
-
`
|
|
49521
|
-
);
|
|
49522
|
-
}
|
|
49523
49536
|
const effectiveMessageTs = channelGuard.corrected ? channelGuard.messageTs : message_ts;
|
|
49524
49537
|
if (bindingMode === "enforce" && binding.reject && !channelGuard.corrected && !scheduledDest) {
|
|
49525
49538
|
process.stderr.write(
|
|
@@ -49600,12 +49613,26 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
49600
49613
|
forcedRoot,
|
|
49601
49614
|
enforceBound,
|
|
49602
49615
|
scheduledDest: scheduledDest ?? null,
|
|
49616
|
+
// ENG-11715: the caller's own thread_ts, ONLY when a human in that thread
|
|
49617
|
+
// is still owed a reply (a non-discretionary pending-inbound marker). That
|
|
49618
|
+
// distinguishes a reply to a person from a scheduled task's output reusing
|
|
49619
|
+
// a stale thread (ENG-7712). Read before the send settles markers.
|
|
49620
|
+
explicitThreadTs: explicitThreadForScheduledPriority(
|
|
49621
|
+
thread_ts,
|
|
49622
|
+
(ts) => countOwedSlackRepliesForThread(SLACK_PENDING_INBOUND_DIR, resolvedFallbackChannel, ts)
|
|
49623
|
+
),
|
|
49603
49624
|
bindingChannel: binding.channel,
|
|
49604
49625
|
bindingThreadTs: binding.threadTs,
|
|
49605
49626
|
fallbackChannel: resolvedFallbackChannel,
|
|
49606
49627
|
fallbackThreadTs: channelGuard.corrected ? channelGuard.threadTs : hotThreadMode === "enforce" && hotGuard ? hotGuard.threadTs : baseThreadTs,
|
|
49607
49628
|
fallbackSettleThreadTs: channelGuard.corrected ? channelGuard.threadTs : thread_ts
|
|
49608
49629
|
});
|
|
49630
|
+
if (scheduledDest?.retargeted && routingReason === "scheduled") {
|
|
49631
|
+
process.stderr.write(
|
|
49632
|
+
`slack-channel(${AGENT_CODE_NAME}): scheduled_turn_retargeted task=${scheduledMarker?.task_id ?? "?"} requested=${redactSlackId(channel)}/${redactSlackId(thread_ts)} routed=${redactSlackId(effectiveChannel)}/${redactSlackId(effectiveThreadTs)}
|
|
49633
|
+
`
|
|
49634
|
+
);
|
|
49635
|
+
}
|
|
49609
49636
|
if (isResolvedTargetIngressOnly({
|
|
49610
49637
|
channel: effectiveChannel,
|
|
49611
49638
|
threadTs: effectiveThreadTs,
|
|
@@ -49991,7 +50018,7 @@ ${result.formatted}` : "No messages in range, or the bot is not a member of this
|
|
|
49991
50018
|
};
|
|
49992
50019
|
}
|
|
49993
50020
|
size = stat2.size;
|
|
49994
|
-
bytes =
|
|
50021
|
+
bytes = readFileSync20(resolvedPath);
|
|
49995
50022
|
} catch (err) {
|
|
49996
50023
|
return {
|
|
49997
50024
|
content: [{ type: "text", text: `Failed to read file: ${err.message}` }],
|
|
@@ -50801,7 +50828,7 @@ async function replayPendingSlackMarkers() {
|
|
|
50801
50828
|
const fullPath = join22(SLACK_PENDING_INBOUND_DIR, name);
|
|
50802
50829
|
let marker;
|
|
50803
50830
|
try {
|
|
50804
|
-
marker = JSON.parse(
|
|
50831
|
+
marker = JSON.parse(readFileSync20(fullPath, "utf-8"));
|
|
50805
50832
|
} catch {
|
|
50806
50833
|
continue;
|
|
50807
50834
|
}
|
package/package.json
CHANGED
|
File without changes
|