@integrity-labs/agt-cli 0.28.331 → 0.28.332
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-4Y3UPOR2.js → chunk-YNHMQ4CW.js} +119 -26
- package/dist/chunk-YNHMQ4CW.js.map +1 -0
- package/dist/lib/manager-worker.js +4 -4
- package/dist/mcp/direct-chat-channel.js +92 -51
- package/dist/mcp/slack-channel.js +155 -118
- package/dist/mcp/teams-channel.js +100 -51
- package/dist/mcp/telegram-channel.js +146 -98
- package/dist/{responsiveness-probe-OJJESVVX.js → responsiveness-probe-46XFHCPY.js} +12 -2
- package/dist/responsiveness-probe-46XFHCPY.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-4Y3UPOR2.js.map +0 -1
- package/dist/responsiveness-probe-OJJESVVX.js.map +0 -1
|
@@ -13865,19 +13865,19 @@ var StdioServerTransport = class {
|
|
|
13865
13865
|
|
|
13866
13866
|
// src/teams-channel.ts
|
|
13867
13867
|
import {
|
|
13868
|
-
existsSync as
|
|
13869
|
-
mkdirSync as
|
|
13870
|
-
readdirSync as
|
|
13871
|
-
readFileSync as
|
|
13872
|
-
renameSync,
|
|
13868
|
+
existsSync as existsSync6,
|
|
13869
|
+
mkdirSync as mkdirSync5,
|
|
13870
|
+
readdirSync as readdirSync3,
|
|
13871
|
+
readFileSync as readFileSync5,
|
|
13872
|
+
renameSync as renameSync2,
|
|
13873
13873
|
rmSync,
|
|
13874
13874
|
statSync,
|
|
13875
13875
|
unlinkSync as unlinkSync2,
|
|
13876
13876
|
watch,
|
|
13877
|
-
writeFileSync as
|
|
13877
|
+
writeFileSync as writeFileSync6
|
|
13878
13878
|
} from "fs";
|
|
13879
13879
|
import { homedir as homedir3 } from "os";
|
|
13880
|
-
import { join as
|
|
13880
|
+
import { join as join7, resolve as resolvePath2 } from "path";
|
|
13881
13881
|
import { basename } from "path";
|
|
13882
13882
|
|
|
13883
13883
|
// src/slack-loop-throttle.ts
|
|
@@ -15147,6 +15147,45 @@ function removeRecoveryLedgerEntry(ledgerDir, markerName, unlink = (p) => {
|
|
|
15147
15147
|
}
|
|
15148
15148
|
}
|
|
15149
15149
|
|
|
15150
|
+
// src/inbound-delivery-ledger.ts
|
|
15151
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync4, readdirSync as readdirSync2, readFileSync as readFileSync4, renameSync, writeFileSync as writeFileSync5 } from "fs";
|
|
15152
|
+
import { join as join6 } from "path";
|
|
15153
|
+
function safeInboundId(inboundId) {
|
|
15154
|
+
return inboundId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
15155
|
+
}
|
|
15156
|
+
var defaultDeps = {
|
|
15157
|
+
mkdir: (dir) => mkdirSync4(dir, { recursive: true }),
|
|
15158
|
+
writeFile: (path, data) => writeFileSync5(path, data, "utf8"),
|
|
15159
|
+
rename: (from, to) => renameSync(from, to),
|
|
15160
|
+
readdir: (dir) => readdirSync2(dir),
|
|
15161
|
+
readFile: (path) => readFileSync4(path, "utf8"),
|
|
15162
|
+
exists: (path) => existsSync5(path)
|
|
15163
|
+
};
|
|
15164
|
+
function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
|
|
15165
|
+
if (!dir || !record2.inbound_id || !record2.conv_key) return;
|
|
15166
|
+
const safe = safeInboundId(record2.inbound_id);
|
|
15167
|
+
if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return;
|
|
15168
|
+
try {
|
|
15169
|
+
deps.mkdir(dir);
|
|
15170
|
+
const final = join6(dir, `${safe}.json`);
|
|
15171
|
+
const tmp = `${final}.tmp`;
|
|
15172
|
+
deps.writeFile(tmp, JSON.stringify(record2));
|
|
15173
|
+
deps.rename(tmp, final);
|
|
15174
|
+
} catch {
|
|
15175
|
+
}
|
|
15176
|
+
}
|
|
15177
|
+
|
|
15178
|
+
// src/channel-inbound-id.ts
|
|
15179
|
+
import { createHash } from "crypto";
|
|
15180
|
+
var INBOUND_ID_HEX_LEN = 12;
|
|
15181
|
+
function hashInboundId(payload) {
|
|
15182
|
+
const digest = createHash("sha256").update(payload).digest("hex").slice(0, INBOUND_ID_HEX_LEN);
|
|
15183
|
+
return `ib_${digest}`;
|
|
15184
|
+
}
|
|
15185
|
+
function teamsInboundId(conversationId, activityId) {
|
|
15186
|
+
return hashInboundId(`${conversationId}|${activityId}`);
|
|
15187
|
+
}
|
|
15188
|
+
|
|
15150
15189
|
// src/teams-channel.ts
|
|
15151
15190
|
var APP_ID = process.env.MSTEAMS_APP_ID ?? null;
|
|
15152
15191
|
var CLIENT_SECRET = process.env.MSTEAMS_CLIENT_SECRET ?? null;
|
|
@@ -15230,7 +15269,7 @@ var ADAPTIVE_CARDS_ENABLED = process.env.MSTEAMS_ADAPTIVE_CARDS_ENABLED === "tru
|
|
|
15230
15269
|
var ADAPTIVE_CARDS_ASK_USER_ENABLED = process.env.MSTEAMS_ADAPTIVE_CARDS_ASK_USER_ENABLED === "true";
|
|
15231
15270
|
var ASK_USER_DEFAULT_TIMEOUT_SECONDS = 300;
|
|
15232
15271
|
var ASK_USER_POLL_INTERVAL_MS = 1e3;
|
|
15233
|
-
var PROJECT_DIR = AGENT_CODE_NAME ? resolvePath2(
|
|
15272
|
+
var PROJECT_DIR = AGENT_CODE_NAME ? resolvePath2(join7(homedir3(), ".augmented", AGENT_CODE_NAME, "project")) : null;
|
|
15234
15273
|
var MAX_UPLOAD_BYTES = 4 * 1024 * 1024;
|
|
15235
15274
|
var AAD_TOKEN_URL = (tenantId) => `https://login.microsoftonline.com/${encodeURIComponent(tenantId)}/oauth2/v2.0/token`;
|
|
15236
15275
|
var BOT_FRAMEWORK_SCOPE = "https://api.botframework.com/.default";
|
|
@@ -15350,7 +15389,7 @@ var trackedThreads = /* @__PURE__ */ new Map();
|
|
|
15350
15389
|
var threadPersister = null;
|
|
15351
15390
|
function threadStorePath() {
|
|
15352
15391
|
if (!AGENT_CODE_NAME) return null;
|
|
15353
|
-
return
|
|
15392
|
+
return join7(homedir3(), ".augmented", AGENT_CODE_NAME, "msteams-tracked-threads.json");
|
|
15354
15393
|
}
|
|
15355
15394
|
function loadTrackedThreads() {
|
|
15356
15395
|
const path = threadStorePath();
|
|
@@ -15395,14 +15434,14 @@ function rememberThread(conversationId, serviceUrl, mode, activityId) {
|
|
|
15395
15434
|
});
|
|
15396
15435
|
threadPersister?.schedule(trackedThreads);
|
|
15397
15436
|
}
|
|
15398
|
-
var AGENT_DIR = AGENT_CODE_NAME ?
|
|
15399
|
-
var PENDING_INBOUND_DIR = AGENT_DIR ?
|
|
15400
|
-
var PROCESSED_DIR = PENDING_INBOUND_DIR ?
|
|
15437
|
+
var AGENT_DIR = AGENT_CODE_NAME ? join7(homedir3(), ".augmented", AGENT_CODE_NAME) : null;
|
|
15438
|
+
var PENDING_INBOUND_DIR = AGENT_DIR ? join7(AGENT_DIR, "msteams-pending-inbound") : null;
|
|
15439
|
+
var PROCESSED_DIR = PENDING_INBOUND_DIR ? join7(PENDING_INBOUND_DIR, ".processed") : null;
|
|
15401
15440
|
function ensurePendingDirs() {
|
|
15402
15441
|
if (!PENDING_INBOUND_DIR || !PROCESSED_DIR) return;
|
|
15403
15442
|
try {
|
|
15404
|
-
|
|
15405
|
-
|
|
15443
|
+
mkdirSync5(PENDING_INBOUND_DIR, { recursive: true });
|
|
15444
|
+
mkdirSync5(PROCESSED_DIR, { recursive: true });
|
|
15406
15445
|
} catch (err) {
|
|
15407
15446
|
process.stderr.write(
|
|
15408
15447
|
`teams-channel: failed to ensure pending-inbound dir (${err.message})
|
|
@@ -15413,10 +15452,10 @@ function ensurePendingDirs() {
|
|
|
15413
15452
|
async function processPendingFile(filename) {
|
|
15414
15453
|
if (!PENDING_INBOUND_DIR || !PROCESSED_DIR) return;
|
|
15415
15454
|
if (!filename.endsWith(".json")) return;
|
|
15416
|
-
const fullPath =
|
|
15455
|
+
const fullPath = join7(PENDING_INBOUND_DIR, filename);
|
|
15417
15456
|
let activity;
|
|
15418
15457
|
try {
|
|
15419
|
-
const raw =
|
|
15458
|
+
const raw = readFileSync5(fullPath, "utf8");
|
|
15420
15459
|
activity = JSON.parse(raw);
|
|
15421
15460
|
} catch (err) {
|
|
15422
15461
|
process.stderr.write(
|
|
@@ -15425,7 +15464,7 @@ async function processPendingFile(filename) {
|
|
|
15425
15464
|
);
|
|
15426
15465
|
if (PROCESSED_DIR) {
|
|
15427
15466
|
try {
|
|
15428
|
-
|
|
15467
|
+
renameSync2(fullPath, join7(PROCESSED_DIR, `${filename}.invalid`));
|
|
15429
15468
|
} catch {
|
|
15430
15469
|
}
|
|
15431
15470
|
}
|
|
@@ -15439,7 +15478,7 @@ async function processPendingFile(filename) {
|
|
|
15439
15478
|
peerAgentMode: PEER_AGENT_MODE
|
|
15440
15479
|
});
|
|
15441
15480
|
try {
|
|
15442
|
-
|
|
15481
|
+
renameSync2(fullPath, join7(PROCESSED_DIR, filename));
|
|
15443
15482
|
} catch {
|
|
15444
15483
|
return;
|
|
15445
15484
|
}
|
|
@@ -15595,7 +15634,7 @@ function startPendingInboundWatcher() {
|
|
|
15595
15634
|
}
|
|
15596
15635
|
ensurePendingDirs();
|
|
15597
15636
|
try {
|
|
15598
|
-
const entries =
|
|
15637
|
+
const entries = readdirSync3(PENDING_INBOUND_DIR).filter((f) => f.endsWith(".json")).map((f) => ({ f, m: safeMtimeMs(join7(PENDING_INBOUND_DIR, f)) })).sort((a, b) => a.m - b.m).map((e) => e.f);
|
|
15599
15638
|
for (const f of entries) {
|
|
15600
15639
|
void processPendingFile(f).catch((err) => {
|
|
15601
15640
|
process.stderr.write(
|
|
@@ -15620,7 +15659,7 @@ function startPendingInboundWatcher() {
|
|
|
15620
15659
|
if (!name || typeof name !== "string") return;
|
|
15621
15660
|
if (!name.endsWith(".json")) return;
|
|
15622
15661
|
if (name.startsWith(".")) return;
|
|
15623
|
-
const fullPath =
|
|
15662
|
+
const fullPath = join7(PENDING_INBOUND_DIR, name);
|
|
15624
15663
|
try {
|
|
15625
15664
|
statSync(fullPath);
|
|
15626
15665
|
} catch {
|
|
@@ -15877,6 +15916,12 @@ async function handleReply(args) {
|
|
|
15877
15916
|
});
|
|
15878
15917
|
recordReply(conversationId, throttleKey, now, throttleCfg);
|
|
15879
15918
|
clearPendingMarkersForConversation(conversationId);
|
|
15919
|
+
writeInboundDeliveryLedgerEntry(DELIVERY_LEDGER_DIR, {
|
|
15920
|
+
inbound_id: teamsInboundId(conversationId, replyToId ?? ""),
|
|
15921
|
+
source: "msteams",
|
|
15922
|
+
conv_key: conversationId,
|
|
15923
|
+
delivered_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
15924
|
+
});
|
|
15880
15925
|
if (THREAD_AUTO_FOLLOW !== "off") {
|
|
15881
15926
|
rememberThread(conversationId, serviceUrl, replyToId ? "mentioned" : "started", result.id);
|
|
15882
15927
|
}
|
|
@@ -16039,11 +16084,11 @@ function optionalStringArg(args, key2) {
|
|
|
16039
16084
|
function errResult(text) {
|
|
16040
16085
|
return { content: [{ type: "text", text }], isError: true };
|
|
16041
16086
|
}
|
|
16042
|
-
var PENDING_INTERACTIONS_DIR = AGENT_DIR ?
|
|
16087
|
+
var PENDING_INTERACTIONS_DIR = AGENT_DIR ? join7(AGENT_DIR, "msteams-pending-interactions") : null;
|
|
16043
16088
|
function ensurePendingInteractionsDir() {
|
|
16044
16089
|
if (!PENDING_INTERACTIONS_DIR) return;
|
|
16045
16090
|
try {
|
|
16046
|
-
|
|
16091
|
+
mkdirSync5(PENDING_INTERACTIONS_DIR, { recursive: true });
|
|
16047
16092
|
} catch (err) {
|
|
16048
16093
|
process.stderr.write(
|
|
16049
16094
|
`teams-channel: failed to ensure pending-interactions dir (${err.message})
|
|
@@ -16054,16 +16099,16 @@ function ensurePendingInteractionsDir() {
|
|
|
16054
16099
|
function writePendingInteraction(entry) {
|
|
16055
16100
|
if (!PENDING_INTERACTIONS_DIR) return;
|
|
16056
16101
|
ensurePendingInteractionsDir();
|
|
16057
|
-
|
|
16058
|
-
|
|
16102
|
+
writeFileSync6(
|
|
16103
|
+
join7(PENDING_INTERACTIONS_DIR, `${entry.interaction_id}.json`),
|
|
16059
16104
|
JSON.stringify(entry, null, 2)
|
|
16060
16105
|
);
|
|
16061
16106
|
}
|
|
16062
16107
|
function readInteractionAnswer(interactionId) {
|
|
16063
16108
|
if (!PENDING_INTERACTIONS_DIR) return null;
|
|
16064
|
-
const path =
|
|
16109
|
+
const path = join7(PENDING_INTERACTIONS_DIR, `${interactionId}.answer.json`);
|
|
16065
16110
|
try {
|
|
16066
|
-
const raw =
|
|
16111
|
+
const raw = readFileSync5(path, "utf8");
|
|
16067
16112
|
const parsed = JSON.parse(raw);
|
|
16068
16113
|
if (typeof parsed.value !== "string") return null;
|
|
16069
16114
|
return {
|
|
@@ -16085,7 +16130,7 @@ function readInteractionAnswer(interactionId) {
|
|
|
16085
16130
|
function clearPendingInteraction(interactionId) {
|
|
16086
16131
|
if (!PENDING_INTERACTIONS_DIR) return;
|
|
16087
16132
|
for (const suffix of [".json", ".answer.json"]) {
|
|
16088
|
-
const path =
|
|
16133
|
+
const path = join7(PENDING_INTERACTIONS_DIR, `${interactionId}${suffix}`);
|
|
16089
16134
|
try {
|
|
16090
16135
|
unlinkSync2(path);
|
|
16091
16136
|
} catch (err) {
|
|
@@ -16249,7 +16294,7 @@ async function handleUploadFile(args) {
|
|
|
16249
16294
|
);
|
|
16250
16295
|
}
|
|
16251
16296
|
try {
|
|
16252
|
-
buffer =
|
|
16297
|
+
buffer = readFileSync5(sandboxed.resolved);
|
|
16253
16298
|
} catch (err) {
|
|
16254
16299
|
return errResult(`Failed to read file: ${err.message}`);
|
|
16255
16300
|
}
|
|
@@ -16292,9 +16337,10 @@ async function handleUploadFile(args) {
|
|
|
16292
16337
|
return errResult(`Failed: ${err.message}`);
|
|
16293
16338
|
}
|
|
16294
16339
|
}
|
|
16295
|
-
var PENDING_MARKER_DIR = PENDING_INBOUND_DIR ?
|
|
16296
|
-
var RECOVERY_OUTBOX_DIR = AGENT_DIR ?
|
|
16297
|
-
var RECOVERY_LEDGER_DIR = AGENT_DIR ?
|
|
16340
|
+
var PENDING_MARKER_DIR = PENDING_INBOUND_DIR ? join7(PENDING_INBOUND_DIR, ".markers") : null;
|
|
16341
|
+
var RECOVERY_OUTBOX_DIR = AGENT_DIR ? join7(AGENT_DIR, "msteams-recovery-outbox") : null;
|
|
16342
|
+
var RECOVERY_LEDGER_DIR = AGENT_DIR ? join7(AGENT_DIR, ".agt-msteams-recovery-ledger") : null;
|
|
16343
|
+
var DELIVERY_LEDGER_DIR = AGENT_DIR ? join7(AGENT_DIR, ".agt-inbound-delivery-ledger") : null;
|
|
16298
16344
|
var STALE_MARKER_MS = 24 * 60 * 60 * 1e3;
|
|
16299
16345
|
var RECOVERY_RETRY_SCAN_INTERVAL_MS = 6e4;
|
|
16300
16346
|
var RECOVERY_RETRY_BACKOFFS_MS = [6e4, 12e4, 24e4];
|
|
@@ -16303,7 +16349,7 @@ function ensureGhostReplyDirs() {
|
|
|
16303
16349
|
for (const dir of [PENDING_MARKER_DIR, RECOVERY_OUTBOX_DIR]) {
|
|
16304
16350
|
if (!dir) continue;
|
|
16305
16351
|
try {
|
|
16306
|
-
|
|
16352
|
+
mkdirSync5(dir, { recursive: true });
|
|
16307
16353
|
} catch (err) {
|
|
16308
16354
|
process.stderr.write(
|
|
16309
16355
|
`teams-channel: failed to ensure ${dir} (${err.message})
|
|
@@ -16321,8 +16367,8 @@ function writePendingMarker(activity) {
|
|
|
16321
16367
|
ensureGhostReplyDirs();
|
|
16322
16368
|
const name = safeMarkerName(activity.conversation.id, activity.id);
|
|
16323
16369
|
try {
|
|
16324
|
-
|
|
16325
|
-
|
|
16370
|
+
writeFileSync6(
|
|
16371
|
+
join7(PENDING_MARKER_DIR, name),
|
|
16326
16372
|
JSON.stringify(
|
|
16327
16373
|
{
|
|
16328
16374
|
conversation_id: activity.conversation.id,
|
|
@@ -16330,7 +16376,10 @@ function writePendingMarker(activity) {
|
|
|
16330
16376
|
activity_id: activity.id,
|
|
16331
16377
|
from: activity.from,
|
|
16332
16378
|
text: activity.text,
|
|
16333
|
-
received_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
16379
|
+
received_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
16380
|
+
// ENG-7806 (fm1): deterministic inbound id (marker-semantics-neutral);
|
|
16381
|
+
// the Stop hook reads it to look up the inbound-delivery ledger.
|
|
16382
|
+
inbound_id: teamsInboundId(activity.conversation.id, activity.id ?? "")
|
|
16334
16383
|
},
|
|
16335
16384
|
null,
|
|
16336
16385
|
2
|
|
@@ -16348,14 +16397,14 @@ function clearPendingMarkersForConversation(conversationId) {
|
|
|
16348
16397
|
const safe = Buffer.from(conversationId, "utf8").toString("hex").slice(0, 64);
|
|
16349
16398
|
let entries;
|
|
16350
16399
|
try {
|
|
16351
|
-
entries =
|
|
16400
|
+
entries = readdirSync3(PENDING_MARKER_DIR);
|
|
16352
16401
|
} catch {
|
|
16353
16402
|
return;
|
|
16354
16403
|
}
|
|
16355
16404
|
for (const f of entries) {
|
|
16356
16405
|
if (f.startsWith(`${safe}--`)) {
|
|
16357
16406
|
try {
|
|
16358
|
-
unlinkSync2(
|
|
16407
|
+
unlinkSync2(join7(PENDING_MARKER_DIR, f));
|
|
16359
16408
|
} catch {
|
|
16360
16409
|
}
|
|
16361
16410
|
}
|
|
@@ -16365,14 +16414,14 @@ function sweepStaleMarkersOnBoot() {
|
|
|
16365
16414
|
if (!PENDING_MARKER_DIR) return;
|
|
16366
16415
|
let entries;
|
|
16367
16416
|
try {
|
|
16368
|
-
entries =
|
|
16417
|
+
entries = readdirSync3(PENDING_MARKER_DIR);
|
|
16369
16418
|
} catch {
|
|
16370
16419
|
return;
|
|
16371
16420
|
}
|
|
16372
16421
|
let pruned = 0;
|
|
16373
16422
|
const now = Date.now();
|
|
16374
16423
|
for (const f of entries) {
|
|
16375
|
-
const path =
|
|
16424
|
+
const path = join7(PENDING_MARKER_DIR, f);
|
|
16376
16425
|
try {
|
|
16377
16426
|
const stats = statSync(path);
|
|
16378
16427
|
if (now - stats.mtimeMs > STALE_MARKER_MS) {
|
|
@@ -16404,10 +16453,10 @@ function recoveryNextAttempt(filename) {
|
|
|
16404
16453
|
}
|
|
16405
16454
|
async function processRecoveryFile(filename) {
|
|
16406
16455
|
if (!RECOVERY_OUTBOX_DIR) return;
|
|
16407
|
-
const fullPath =
|
|
16456
|
+
const fullPath = join7(RECOVERY_OUTBOX_DIR, filename);
|
|
16408
16457
|
let payload;
|
|
16409
16458
|
try {
|
|
16410
|
-
payload = JSON.parse(
|
|
16459
|
+
payload = JSON.parse(readFileSync5(fullPath, "utf8"));
|
|
16411
16460
|
} catch (err) {
|
|
16412
16461
|
process.stderr.write(
|
|
16413
16462
|
`teams-channel: recovery file ${filename} unreadable (${err.message}) \u2014 dropping
|
|
@@ -16487,7 +16536,7 @@ async function processRecoveryFile(filename) {
|
|
|
16487
16536
|
return;
|
|
16488
16537
|
}
|
|
16489
16538
|
try {
|
|
16490
|
-
|
|
16539
|
+
renameSync2(fullPath, join7(RECOVERY_OUTBOX_DIR, next.next));
|
|
16491
16540
|
process.stderr.write(
|
|
16492
16541
|
`teams-channel: recovery ${filename} \u2192 attempt ${next.attempt} (${err.message})
|
|
16493
16542
|
`
|
|
@@ -16509,11 +16558,11 @@ function startRecoveryOutboxWatcher() {
|
|
|
16509
16558
|
ensureGhostReplyDirs();
|
|
16510
16559
|
const scan = () => {
|
|
16511
16560
|
try {
|
|
16512
|
-
const entries =
|
|
16561
|
+
const entries = readdirSync3(RECOVERY_OUTBOX_DIR);
|
|
16513
16562
|
for (const f of entries) {
|
|
16514
16563
|
if (!f.endsWith(".json")) continue;
|
|
16515
16564
|
if (f.startsWith(".")) continue;
|
|
16516
|
-
const path =
|
|
16565
|
+
const path = join7(RECOVERY_OUTBOX_DIR, f);
|
|
16517
16566
|
let mtimeMs;
|
|
16518
16567
|
try {
|
|
16519
16568
|
mtimeMs = statSync(path).mtimeMs;
|
|
@@ -16538,7 +16587,7 @@ function startRecoveryOutboxWatcher() {
|
|
|
16538
16587
|
if (!name || typeof name !== "string") return;
|
|
16539
16588
|
if (!name.endsWith(".json")) return;
|
|
16540
16589
|
if (name.startsWith(".")) return;
|
|
16541
|
-
const path =
|
|
16590
|
+
const path = join7(RECOVERY_OUTBOX_DIR, name);
|
|
16542
16591
|
let mtimeMs;
|
|
16543
16592
|
try {
|
|
16544
16593
|
mtimeMs = statSync(path).mtimeMs;
|
|
@@ -16604,7 +16653,7 @@ ensureGhostReplyDirs();
|
|
|
16604
16653
|
sweepStaleMarkersOnBoot();
|
|
16605
16654
|
startPendingInboundWatcher();
|
|
16606
16655
|
startRecoveryOutboxWatcher();
|
|
16607
|
-
var NOTICE_OUTBOX_DIR = AGENT_DIR ?
|
|
16656
|
+
var NOTICE_OUTBOX_DIR = AGENT_DIR ? join7(AGENT_DIR, "msteams-notice-outbox") : null;
|
|
16608
16657
|
var NOTICE_MAX_AGE_MS = 9e4;
|
|
16609
16658
|
function isNoticePayload(value) {
|
|
16610
16659
|
if (!value || typeof value !== "object") return false;
|
|
@@ -16618,7 +16667,7 @@ async function processNoticeFile(filename) {
|
|
|
16618
16667
|
if (filename.startsWith(".") || filename.endsWith(".tmp") || !filename.endsWith(".json")) return;
|
|
16619
16668
|
if (NOTICE_INFLIGHT.has(filename)) return;
|
|
16620
16669
|
NOTICE_INFLIGHT.add(filename);
|
|
16621
|
-
const fullPath =
|
|
16670
|
+
const fullPath = join7(NOTICE_OUTBOX_DIR, filename);
|
|
16622
16671
|
try {
|
|
16623
16672
|
let mtimeMs;
|
|
16624
16673
|
try {
|
|
@@ -16635,7 +16684,7 @@ async function processNoticeFile(filename) {
|
|
|
16635
16684
|
}
|
|
16636
16685
|
let payload;
|
|
16637
16686
|
try {
|
|
16638
|
-
payload = JSON.parse(
|
|
16687
|
+
payload = JSON.parse(readFileSync5(fullPath, "utf8"));
|
|
16639
16688
|
} catch {
|
|
16640
16689
|
try {
|
|
16641
16690
|
unlinkSync2(fullPath);
|
|
@@ -16686,20 +16735,20 @@ async function processNoticeFile(filename) {
|
|
|
16686
16735
|
function startNoticeOutboxWatcher() {
|
|
16687
16736
|
if (!NOTICE_OUTBOX_DIR) return;
|
|
16688
16737
|
try {
|
|
16689
|
-
|
|
16738
|
+
mkdirSync5(NOTICE_OUTBOX_DIR, { recursive: true, mode: 448 });
|
|
16690
16739
|
} catch (err) {
|
|
16691
16740
|
process.stderr.write(`teams-channel: notice outbox mkdir failed (${err.message})
|
|
16692
16741
|
`);
|
|
16693
16742
|
return;
|
|
16694
16743
|
}
|
|
16695
16744
|
try {
|
|
16696
|
-
for (const f of
|
|
16745
|
+
for (const f of readdirSync3(NOTICE_OUTBOX_DIR)) void processNoticeFile(f);
|
|
16697
16746
|
} catch {
|
|
16698
16747
|
}
|
|
16699
16748
|
try {
|
|
16700
16749
|
const w = watch(NOTICE_OUTBOX_DIR, (_event, name) => {
|
|
16701
16750
|
if (!name) return;
|
|
16702
|
-
if (
|
|
16751
|
+
if (existsSync6(join7(NOTICE_OUTBOX_DIR, name))) void processNoticeFile(name);
|
|
16703
16752
|
});
|
|
16704
16753
|
w.unref?.();
|
|
16705
16754
|
} catch (err) {
|