@integrity-labs/agt-cli 0.28.1268 → 0.28.1270
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/{api-client-MH7MLGTA.js → api-client-TPJBEIKR.js} +3 -3
- package/dist/bin/agt.js +7 -7
- package/dist/{chunk-X2FBQPNR.js → chunk-A22SKOQ4.js} +2 -2
- package/dist/{chunk-W2GHPRPZ.js → chunk-CJFHB3HA.js} +22 -1
- package/dist/chunk-CJFHB3HA.js.map +1 -0
- package/dist/{chunk-BMO6GCK2.js → chunk-HHDHYVLS.js} +2 -2
- package/dist/{chunk-TMZDRXAK.js → chunk-PVVFL73J.js} +5 -5
- package/dist/{chunk-ERO3R3Z7.js → chunk-SXQ6YCFR.js} +3 -3
- package/dist/{chunk-EHZQAT3Q.js → chunk-YP7VUMM4.js} +3 -3
- package/dist/{claude-code-updater-XISTQTZX.js → claude-code-updater-K6PENJ7A.js} +3 -3
- package/dist/{claude-pair-runtime-3PHBCCUP.js → claude-pair-runtime-NOVMDM62.js} +3 -3
- package/dist/lib/manager-worker.js +278 -189
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +193 -126
- package/dist/mcp/index.js +21 -0
- package/dist/mcp/origami.js +21 -0
- package/dist/mcp/slack-channel.js +137 -2
- package/dist/mcp/telegram-channel.js +21 -0
- package/dist/{persistent-session-BLZPYHBE.js → persistent-session-SMMVQBRS.js} +4 -4
- package/dist/{responsiveness-probe-T6O4V2XZ.js → responsiveness-probe-PX4FMO4H.js} +4 -4
- package/dist/{session-auth-dead-U62KZ342.js → session-auth-dead-47D57WMA.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-W2GHPRPZ.js.map +0 -1
- /package/dist/{api-client-MH7MLGTA.js.map → api-client-TPJBEIKR.js.map} +0 -0
- /package/dist/{chunk-X2FBQPNR.js.map → chunk-A22SKOQ4.js.map} +0 -0
- /package/dist/{chunk-BMO6GCK2.js.map → chunk-HHDHYVLS.js.map} +0 -0
- /package/dist/{chunk-TMZDRXAK.js.map → chunk-PVVFL73J.js.map} +0 -0
- /package/dist/{chunk-ERO3R3Z7.js.map → chunk-SXQ6YCFR.js.map} +0 -0
- /package/dist/{chunk-EHZQAT3Q.js.map → chunk-YP7VUMM4.js.map} +0 -0
- /package/dist/{claude-code-updater-XISTQTZX.js.map → claude-code-updater-K6PENJ7A.js.map} +0 -0
- /package/dist/{claude-pair-runtime-3PHBCCUP.js.map → claude-pair-runtime-NOVMDM62.js.map} +0 -0
- /package/dist/{persistent-session-BLZPYHBE.js.map → persistent-session-SMMVQBRS.js.map} +0 -0
- /package/dist/{responsiveness-probe-T6O4V2XZ.js.map → responsiveness-probe-PX4FMO4H.js.map} +0 -0
- /package/dist/{session-auth-dead-U62KZ342.js.map → session-auth-dead-47D57WMA.js.map} +0 -0
|
@@ -18867,7 +18867,7 @@ var require_filters = __commonJS({
|
|
|
18867
18867
|
return r.copySafeness(str2, res);
|
|
18868
18868
|
}
|
|
18869
18869
|
_exports.indent = indent;
|
|
18870
|
-
function
|
|
18870
|
+
function join20(arr, del, attr) {
|
|
18871
18871
|
del = del || "";
|
|
18872
18872
|
if (attr) {
|
|
18873
18873
|
arr = lib.map(arr, function(v) {
|
|
@@ -18876,7 +18876,7 @@ var require_filters = __commonJS({
|
|
|
18876
18876
|
}
|
|
18877
18877
|
return arr.join(del);
|
|
18878
18878
|
}
|
|
18879
|
-
_exports.join =
|
|
18879
|
+
_exports.join = join20;
|
|
18880
18880
|
function last(arr) {
|
|
18881
18881
|
return arr[arr.length - 1];
|
|
18882
18882
|
}
|
|
@@ -28844,6 +28844,40 @@ var require_lib3 = __commonJS({
|
|
|
28844
28844
|
}
|
|
28845
28845
|
});
|
|
28846
28846
|
|
|
28847
|
+
// ../core/dist/runtime/direct-chat-inflight.js
|
|
28848
|
+
import { renameSync, readFileSync, writeFileSync } from "fs";
|
|
28849
|
+
import { join } from "path";
|
|
28850
|
+
var DIRECT_CHAT_INFLIGHT_FILE = "direct-chat-inflight.json";
|
|
28851
|
+
var DIRECT_CHAT_INFLIGHT_MAX_AGE_MS = 5 * 6e4;
|
|
28852
|
+
function directChatInflightPath(agentDir) {
|
|
28853
|
+
return join(agentDir, DIRECT_CHAT_INFLIGHT_FILE);
|
|
28854
|
+
}
|
|
28855
|
+
function buildDirectChatInflightMarker(claims, pid) {
|
|
28856
|
+
if (claims.length === 0)
|
|
28857
|
+
return { ids: [], since_ms: 0, pid };
|
|
28858
|
+
return {
|
|
28859
|
+
ids: claims.map((c) => c.message_id),
|
|
28860
|
+
since_ms: Math.max(...claims.map((c) => c.claimed_at_ms)),
|
|
28861
|
+
pid
|
|
28862
|
+
};
|
|
28863
|
+
}
|
|
28864
|
+
function writeDirectChatInflightMarker(path, marker, fs = { writeFileSync, renameSync }) {
|
|
28865
|
+
const tmp = `${path}.${process.pid}.tmp`;
|
|
28866
|
+
try {
|
|
28867
|
+
fs.writeFileSync(tmp, JSON.stringify(marker), { mode: 384 });
|
|
28868
|
+
fs.renameSync(tmp, path);
|
|
28869
|
+
return true;
|
|
28870
|
+
} catch {
|
|
28871
|
+
return false;
|
|
28872
|
+
}
|
|
28873
|
+
}
|
|
28874
|
+
function publishDirectChatClaimsChange(snapshot, deps) {
|
|
28875
|
+
deps.saveClaims(snapshot);
|
|
28876
|
+
if (deps.inflightPath) {
|
|
28877
|
+
(deps.write ?? writeDirectChatInflightMarker)(deps.inflightPath, buildDirectChatInflightMarker(snapshot, deps.pid));
|
|
28878
|
+
}
|
|
28879
|
+
}
|
|
28880
|
+
|
|
28847
28881
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/core.js
|
|
28848
28882
|
var NEVER = Object.freeze({
|
|
28849
28883
|
status: "aborted"
|
|
@@ -36458,8 +36492,8 @@ var DirectChatClaimTracker = class {
|
|
|
36458
36492
|
};
|
|
36459
36493
|
|
|
36460
36494
|
// src/direct-chat-rehand.ts
|
|
36461
|
-
import { readFileSync } from "fs";
|
|
36462
|
-
import { join } from "path";
|
|
36495
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
36496
|
+
import { join as join2 } from "path";
|
|
36463
36497
|
var MARKER = /message_id="([^"]+)"/g;
|
|
36464
36498
|
function collectStrings(v, out) {
|
|
36465
36499
|
if (typeof v === "string") out.push(v);
|
|
@@ -36504,9 +36538,9 @@ function planRehand(claims, transcriptText, sessionStartedAtMs) {
|
|
|
36504
36538
|
};
|
|
36505
36539
|
}
|
|
36506
36540
|
function transcriptPathFor(transcriptDir, transcriptId) {
|
|
36507
|
-
return
|
|
36541
|
+
return join2(transcriptDir, `${transcriptId}.jsonl`);
|
|
36508
36542
|
}
|
|
36509
|
-
function readTranscriptText(path, read = (p2) =>
|
|
36543
|
+
function readTranscriptText(path, read = (p2) => readFileSync2(p2, "utf8")) {
|
|
36510
36544
|
try {
|
|
36511
36545
|
return read(path);
|
|
36512
36546
|
} catch {
|
|
@@ -36548,7 +36582,7 @@ function rehandSummaryLine(restored, plan, returned) {
|
|
|
36548
36582
|
// src/rate-limit-watch.ts
|
|
36549
36583
|
import { closeSync, fstatSync, openSync, readSync, readdirSync, statSync } from "fs";
|
|
36550
36584
|
import { homedir } from "os";
|
|
36551
|
-
import { join as
|
|
36585
|
+
import { join as join3 } from "path";
|
|
36552
36586
|
|
|
36553
36587
|
// ../core/dist/types/agent.js
|
|
36554
36588
|
var FRAMEWORK_MODEL_SLOTS = {
|
|
@@ -47647,6 +47681,27 @@ var HOST_KEY_ROTATION_GRACE_MAX_MS = 60 * 6e4;
|
|
|
47647
47681
|
var TEAM_SLUG_MAX_ATTEMPTS = 20;
|
|
47648
47682
|
var SUFFIX_RESERVE = `-${TEAM_SLUG_MAX_ATTEMPTS}`.length;
|
|
47649
47683
|
|
|
47684
|
+
// ../core/dist/branding/contrast.js
|
|
47685
|
+
var BRANDING_LIGHT_GROUND = "#ffffff";
|
|
47686
|
+
var BRANDING_DARK_GROUND = "#1a1a1e";
|
|
47687
|
+
var ACCENT_HEX_RE = /^#[0-9a-fA-F]{6}$/;
|
|
47688
|
+
function parseHexColor(value) {
|
|
47689
|
+
if (typeof value !== "string" || !ACCENT_HEX_RE.test(value))
|
|
47690
|
+
return null;
|
|
47691
|
+
return {
|
|
47692
|
+
r: parseInt(value.slice(1, 3), 16),
|
|
47693
|
+
g: parseInt(value.slice(3, 5), 16),
|
|
47694
|
+
b: parseInt(value.slice(5, 7), 16)
|
|
47695
|
+
};
|
|
47696
|
+
}
|
|
47697
|
+
var GROUNDS = {
|
|
47698
|
+
light: parseHexColor(BRANDING_LIGHT_GROUND),
|
|
47699
|
+
dark: parseHexColor(BRANDING_DARK_GROUND)
|
|
47700
|
+
};
|
|
47701
|
+
|
|
47702
|
+
// ../core/dist/branding/logo.js
|
|
47703
|
+
var MAX_BRANDING_UPLOAD_BYTES = 1024 * 1024;
|
|
47704
|
+
|
|
47650
47705
|
// src/rate-limit-watch.ts
|
|
47651
47706
|
var DEFAULT_WATCH_MS = 5e3;
|
|
47652
47707
|
var DEFAULT_POLL_MS = 400;
|
|
@@ -47719,7 +47774,7 @@ function oldestTimestampMs(text) {
|
|
|
47719
47774
|
function agentTranscriptDir(opts) {
|
|
47720
47775
|
const cwd = opts?.cwd ?? process.cwd();
|
|
47721
47776
|
const home = opts?.home ?? homedir();
|
|
47722
|
-
return
|
|
47777
|
+
return join3(home, ".claude", "projects", encodeClaudeProjectPath(cwd));
|
|
47723
47778
|
}
|
|
47724
47779
|
function classifyTranscriptSince(opts) {
|
|
47725
47780
|
const dir = opts.transcriptDir ?? agentTranscriptDir({ cwd: opts.cwd, home: opts.home });
|
|
@@ -47732,7 +47787,7 @@ function classifyTranscriptSince(opts) {
|
|
|
47732
47787
|
let newest = UNKNOWN_RATE_LIMIT;
|
|
47733
47788
|
for (const name of entries) {
|
|
47734
47789
|
if (!name.endsWith(".jsonl")) continue;
|
|
47735
|
-
const path =
|
|
47790
|
+
const path = join3(dir, name);
|
|
47736
47791
|
try {
|
|
47737
47792
|
const st = statSync(path);
|
|
47738
47793
|
if (!st.isFile() || st.mtimeMs < opts.sinceMs) continue;
|
|
@@ -47778,21 +47833,21 @@ async function watchForRateLimitRefusal(opts) {
|
|
|
47778
47833
|
}
|
|
47779
47834
|
|
|
47780
47835
|
// src/direct-chat-claim-store.ts
|
|
47781
|
-
import { mkdirSync, readFileSync as
|
|
47782
|
-
import { dirname, join as
|
|
47836
|
+
import { mkdirSync, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
47837
|
+
import { dirname, join as join4 } from "path";
|
|
47783
47838
|
var DIRECT_CHAT_CLAIMS_FILE = "direct-chat-claims.json";
|
|
47784
47839
|
var DEFAULT_CLAIM_MAX_AGE_MS = 6 * 60 * 60 * 1e3;
|
|
47785
47840
|
var DEFAULT_CLAIM_MAX_ENTRIES = 1e3;
|
|
47786
47841
|
var realFs = {
|
|
47787
|
-
readFile: (p2) =>
|
|
47788
|
-
writeFile: (p2, d) =>
|
|
47789
|
-
rename: (a, b) =>
|
|
47842
|
+
readFile: (p2) => readFileSync3(p2, "utf8"),
|
|
47843
|
+
writeFile: (p2, d) => writeFileSync2(p2, d, "utf8"),
|
|
47844
|
+
rename: (a, b) => renameSync2(a, b),
|
|
47790
47845
|
mkdir: (d) => {
|
|
47791
47846
|
mkdirSync(d, { recursive: true });
|
|
47792
47847
|
}
|
|
47793
47848
|
};
|
|
47794
47849
|
function directChatClaimsPath(dir) {
|
|
47795
|
-
return dir ?
|
|
47850
|
+
return dir ? join4(dir, DIRECT_CHAT_CLAIMS_FILE) : null;
|
|
47796
47851
|
}
|
|
47797
47852
|
function isEntry(v) {
|
|
47798
47853
|
if (!v || typeof v !== "object") return false;
|
|
@@ -48036,14 +48091,14 @@ function renderHistoryResult(result, requestedNotices) {
|
|
|
48036
48091
|
}
|
|
48037
48092
|
|
|
48038
48093
|
// src/direct-chat-session-state.ts
|
|
48039
|
-
import { existsSync, readFileSync as
|
|
48040
|
-
import { join as
|
|
48094
|
+
import { existsSync, readFileSync as readFileSync4 } from "fs";
|
|
48095
|
+
import { join as join5 } from "path";
|
|
48041
48096
|
function readDirectChatSessionState(agentDir, nowMs) {
|
|
48042
|
-
const path =
|
|
48097
|
+
const path = join5(agentDir, "direct-chat-session.json");
|
|
48043
48098
|
const fallback = { fresh: false, startedAtMs: nowMs, markerRead: false, sessionId: null };
|
|
48044
48099
|
try {
|
|
48045
48100
|
if (!existsSync(path)) return fallback;
|
|
48046
|
-
const parsed = JSON.parse(
|
|
48101
|
+
const parsed = JSON.parse(readFileSync4(path, "utf8"));
|
|
48047
48102
|
if (!parsed || typeof parsed !== "object") return fallback;
|
|
48048
48103
|
const o = parsed;
|
|
48049
48104
|
const fresh = o.fresh === true;
|
|
@@ -48090,12 +48145,12 @@ function buildDirectChatChannelMeta(input) {
|
|
|
48090
48145
|
}
|
|
48091
48146
|
|
|
48092
48147
|
// src/turn-context.ts
|
|
48093
|
-
import { mkdirSync as mkdirSync3, readFileSync as
|
|
48148
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync7 } from "fs";
|
|
48094
48149
|
import { homedir as homedir2 } from "os";
|
|
48095
|
-
import { dirname as dirname3, join as
|
|
48150
|
+
import { dirname as dirname3, join as join9 } from "path";
|
|
48096
48151
|
|
|
48097
48152
|
// ../core/dist/provisioning/frameworks/claudecode/agent-dir-alias.js
|
|
48098
|
-
import { isAbsolute, join as
|
|
48153
|
+
import { isAbsolute, join as join6, relative, sep } from "path";
|
|
48099
48154
|
var VALID_CODE_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
48100
48155
|
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}$/;
|
|
48101
48156
|
var INITIATOR_BASENAME = ".current-turn-initiator.json";
|
|
@@ -48103,7 +48158,7 @@ function isSafeAgentSegment(segment) {
|
|
|
48103
48158
|
return VALID_CODE_NAME.test(segment) || VALID_AGENT_ID.test(segment);
|
|
48104
48159
|
}
|
|
48105
48160
|
function initiatorDirSegment(initiatorFile, homeDir) {
|
|
48106
|
-
const rel = relative(
|
|
48161
|
+
const rel = relative(join6(homeDir, ".augmented"), initiatorFile);
|
|
48107
48162
|
if (!rel || isAbsolute(rel))
|
|
48108
48163
|
return null;
|
|
48109
48164
|
const parts = rel.split(sep);
|
|
@@ -48118,29 +48173,29 @@ function resolveAgentDirAlias(input) {
|
|
|
48118
48173
|
const { codeName, turnInitiatorFile, agentId, homeDir } = input;
|
|
48119
48174
|
const codeNameTrimmed = typeof codeName === "string" ? codeName.trim() : "";
|
|
48120
48175
|
if (codeNameTrimmed && VALID_CODE_NAME.test(codeNameTrimmed)) {
|
|
48121
|
-
return
|
|
48176
|
+
return join6(homeDir, ".augmented", codeNameTrimmed);
|
|
48122
48177
|
}
|
|
48123
48178
|
const initiator = typeof turnInitiatorFile === "string" ? turnInitiatorFile.trim() : "";
|
|
48124
48179
|
if (initiator) {
|
|
48125
48180
|
const segment = initiatorDirSegment(initiator, homeDir);
|
|
48126
48181
|
if (segment)
|
|
48127
|
-
return
|
|
48182
|
+
return join6(homeDir, ".augmented", segment);
|
|
48128
48183
|
}
|
|
48129
48184
|
const agentIdTrimmed = typeof agentId === "string" ? agentId.trim() : "";
|
|
48130
48185
|
if (agentIdTrimmed && VALID_AGENT_ID.test(agentIdTrimmed)) {
|
|
48131
|
-
return
|
|
48186
|
+
return join6(homeDir, ".augmented", agentIdTrimmed);
|
|
48132
48187
|
}
|
|
48133
48188
|
return null;
|
|
48134
48189
|
}
|
|
48135
48190
|
|
|
48136
48191
|
// src/turn-initiator-marker.ts
|
|
48137
|
-
import { writeFileSync as
|
|
48138
|
-
import { dirname as dirname2, join as
|
|
48192
|
+
import { writeFileSync as writeFileSync3, readFileSync as readFileSync5, mkdirSync as mkdirSync2, renameSync as renameSync3 } from "fs";
|
|
48193
|
+
import { dirname as dirname2, join as join7 } from "path";
|
|
48139
48194
|
var TURN_INITIATOR_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
48140
48195
|
var TURN_INITIATOR_LEDGER_MAX_ENTRIES = 20;
|
|
48141
48196
|
var TURN_INITIATOR_LEDGER_FILENAME = ".turn-initiator-ledger.json";
|
|
48142
48197
|
function turnInitiatorLedgerPath(singleSlotFile) {
|
|
48143
|
-
return
|
|
48198
|
+
return join7(dirname2(singleSlotFile), TURN_INITIATOR_LEDGER_FILENAME);
|
|
48144
48199
|
}
|
|
48145
48200
|
function foldTurnInitiatorLedger(existing, marker, maxAgeMs = TURN_INITIATOR_MAX_AGE_MS, maxEntries = TURN_INITIATOR_LEDGER_MAX_ENTRIES) {
|
|
48146
48201
|
const now = marker.ts;
|
|
@@ -48170,14 +48225,14 @@ function updateTurnInitiatorLedger(singleSlotFile, marker) {
|
|
|
48170
48225
|
const ledgerFile = turnInitiatorLedgerPath(singleSlotFile);
|
|
48171
48226
|
let existing = null;
|
|
48172
48227
|
try {
|
|
48173
|
-
const parsed = JSON.parse(
|
|
48228
|
+
const parsed = JSON.parse(readFileSync5(ledgerFile, "utf8"));
|
|
48174
48229
|
if (parsed && parsed.v === 1 && Array.isArray(parsed.entries)) existing = parsed;
|
|
48175
48230
|
} catch {
|
|
48176
48231
|
}
|
|
48177
48232
|
const next = foldTurnInitiatorLedger(existing, marker);
|
|
48178
48233
|
const tmp = `${ledgerFile}.${process.pid}.${Date.now()}.tmp`;
|
|
48179
|
-
|
|
48180
|
-
|
|
48234
|
+
writeFileSync3(tmp, JSON.stringify(next), "utf8");
|
|
48235
|
+
renameSync3(tmp, ledgerFile);
|
|
48181
48236
|
}
|
|
48182
48237
|
function writeTurnInitiatorMarker(input) {
|
|
48183
48238
|
const file = process.env["AGT_TURN_INITIATOR_FILE"];
|
|
@@ -48186,8 +48241,8 @@ function writeTurnInitiatorMarker(input) {
|
|
|
48186
48241
|
mkdirSync2(dirname2(file), { recursive: true });
|
|
48187
48242
|
const marker = { ...input, ts: Date.now() };
|
|
48188
48243
|
const tmp = `${file}.tmp`;
|
|
48189
|
-
|
|
48190
|
-
|
|
48244
|
+
writeFileSync3(tmp, JSON.stringify(marker), "utf8");
|
|
48245
|
+
renameSync3(tmp, file);
|
|
48191
48246
|
try {
|
|
48192
48247
|
updateTurnInitiatorLedger(file, marker);
|
|
48193
48248
|
} catch {
|
|
@@ -48197,14 +48252,14 @@ function writeTurnInitiatorMarker(input) {
|
|
|
48197
48252
|
}
|
|
48198
48253
|
|
|
48199
48254
|
// src/scheduled-turn-marker.ts
|
|
48200
|
-
import { readFileSync as
|
|
48201
|
-
import { join as
|
|
48255
|
+
import { readFileSync as readFileSync6, unlinkSync } from "fs";
|
|
48256
|
+
import { join as join8 } from "path";
|
|
48202
48257
|
var SCHEDULED_TURN_MARKER_FILENAME2 = ".current-scheduled-turn.json";
|
|
48203
48258
|
var SCHEDULED_TURN_MAX_AGE_MS = 15 * 60 * 1e3;
|
|
48204
48259
|
function clearScheduledTurnMarker(agentDir) {
|
|
48205
48260
|
if (!agentDir) return;
|
|
48206
48261
|
try {
|
|
48207
|
-
unlinkSync(
|
|
48262
|
+
unlinkSync(join8(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
|
|
48208
48263
|
} catch {
|
|
48209
48264
|
}
|
|
48210
48265
|
}
|
|
@@ -48240,7 +48295,7 @@ function resolveTurnInitiatorFile(env2 = process.env, home = homedir2()) {
|
|
|
48240
48295
|
turnInitiatorFile: null,
|
|
48241
48296
|
homeDir: home
|
|
48242
48297
|
});
|
|
48243
|
-
return dir ?
|
|
48298
|
+
return dir ? join9(dir, TURN_INITIATOR_MARKER_FILENAME) : null;
|
|
48244
48299
|
}
|
|
48245
48300
|
|
|
48246
48301
|
// src/direct-chat-turn-marker.ts
|
|
@@ -48276,12 +48331,12 @@ import {
|
|
|
48276
48331
|
existsSync as existsSync2,
|
|
48277
48332
|
mkdirSync as mkdirSync4,
|
|
48278
48333
|
readdirSync as readdirSync2,
|
|
48279
|
-
readFileSync as
|
|
48280
|
-
renameSync as
|
|
48334
|
+
readFileSync as readFileSync8,
|
|
48335
|
+
renameSync as renameSync4,
|
|
48281
48336
|
unlinkSync as unlinkSync2,
|
|
48282
|
-
writeFileSync as
|
|
48337
|
+
writeFileSync as writeFileSync4
|
|
48283
48338
|
} from "fs";
|
|
48284
|
-
import { join as
|
|
48339
|
+
import { join as join10 } from "path";
|
|
48285
48340
|
function hexEncodeSegment(value) {
|
|
48286
48341
|
return Buffer.from(value, "utf8").toString("hex");
|
|
48287
48342
|
}
|
|
@@ -48308,10 +48363,10 @@ function writeDirectChatPendingInboundMarker(dir, sessionId, messageId) {
|
|
|
48308
48363
|
received_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
48309
48364
|
inbound_id: directChatInboundId(sessionId, messageId)
|
|
48310
48365
|
};
|
|
48311
|
-
const final =
|
|
48366
|
+
const final = join10(dir, directChatMarkerName(sessionId, messageId));
|
|
48312
48367
|
const tmp = `${final}.tmp`;
|
|
48313
|
-
|
|
48314
|
-
|
|
48368
|
+
writeFileSync4(tmp, JSON.stringify(marker), "utf8");
|
|
48369
|
+
renameSync4(tmp, final);
|
|
48315
48370
|
} catch {
|
|
48316
48371
|
}
|
|
48317
48372
|
}
|
|
@@ -48327,15 +48382,15 @@ function clearDirectChatPendingMarkersForSession(dir, sessionId, op = defaultCle
|
|
|
48327
48382
|
}
|
|
48328
48383
|
for (const name of names) {
|
|
48329
48384
|
if (!name.startsWith(prefix) || !name.endsWith(".json")) continue;
|
|
48330
|
-
op(
|
|
48385
|
+
op(join10(dir, name));
|
|
48331
48386
|
cleared += 1;
|
|
48332
48387
|
}
|
|
48333
48388
|
return cleared;
|
|
48334
48389
|
}
|
|
48335
|
-
function readDirectChatPendingInboundMarker(dir, sessionId, messageId, readFileImpl = (path) =>
|
|
48390
|
+
function readDirectChatPendingInboundMarker(dir, sessionId, messageId, readFileImpl = (path) => readFileSync8(path, "utf8")) {
|
|
48336
48391
|
if (!dir || !sessionId || !messageId) return null;
|
|
48337
48392
|
try {
|
|
48338
|
-
const raw = readFileImpl(
|
|
48393
|
+
const raw = readFileImpl(join10(dir, directChatMarkerName(sessionId, messageId)));
|
|
48339
48394
|
return JSON.parse(raw);
|
|
48340
48395
|
} catch {
|
|
48341
48396
|
return null;
|
|
@@ -48358,7 +48413,7 @@ function sweepAgedDirectChatMarkers(dir, deps) {
|
|
|
48358
48413
|
}
|
|
48359
48414
|
for (const name of names) {
|
|
48360
48415
|
if (!name.endsWith(".json") || name.startsWith(".")) continue;
|
|
48361
|
-
const full =
|
|
48416
|
+
const full = join10(dir, name);
|
|
48362
48417
|
let marker;
|
|
48363
48418
|
try {
|
|
48364
48419
|
marker = JSON.parse(deps.readFile(full));
|
|
@@ -48457,17 +48512,17 @@ async function consumeDirectChatRecoveryFile(fullPath, filename, deps) {
|
|
|
48457
48512
|
}
|
|
48458
48513
|
|
|
48459
48514
|
// src/inbound-delivery-ledger.ts
|
|
48460
|
-
import { existsSync as existsSync3, mkdirSync as mkdirSync5, readdirSync as readdirSync3, readFileSync as
|
|
48461
|
-
import { join as
|
|
48515
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync5, readdirSync as readdirSync3, readFileSync as readFileSync9, renameSync as renameSync5, writeFileSync as writeFileSync5 } from "fs";
|
|
48516
|
+
import { join as join11 } from "path";
|
|
48462
48517
|
function safeInboundId(inboundId) {
|
|
48463
48518
|
return inboundId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
48464
48519
|
}
|
|
48465
48520
|
var defaultDeps = {
|
|
48466
48521
|
mkdir: (dir) => mkdirSync5(dir, { recursive: true }),
|
|
48467
|
-
writeFile: (path, data) =>
|
|
48468
|
-
rename: (from, to) =>
|
|
48522
|
+
writeFile: (path, data) => writeFileSync5(path, data, "utf8"),
|
|
48523
|
+
rename: (from, to) => renameSync5(from, to),
|
|
48469
48524
|
readdir: (dir) => readdirSync3(dir),
|
|
48470
|
-
readFile: (path) =>
|
|
48525
|
+
readFile: (path) => readFileSync9(path, "utf8"),
|
|
48471
48526
|
exists: (path) => existsSync3(path)
|
|
48472
48527
|
};
|
|
48473
48528
|
function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
|
|
@@ -48476,7 +48531,7 @@ function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
|
|
|
48476
48531
|
if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return;
|
|
48477
48532
|
try {
|
|
48478
48533
|
deps.mkdir(dir);
|
|
48479
|
-
const final =
|
|
48534
|
+
const final = join11(dir, `${safe}.json`);
|
|
48480
48535
|
const tmp = `${final}.tmp`;
|
|
48481
48536
|
deps.writeFile(tmp, JSON.stringify(record2));
|
|
48482
48537
|
deps.rename(tmp, final);
|
|
@@ -48488,24 +48543,24 @@ function inboundDeliveryLedgerHas(dir, inboundId, deps = defaultDeps) {
|
|
|
48488
48543
|
const safe = safeInboundId(inboundId);
|
|
48489
48544
|
if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return false;
|
|
48490
48545
|
try {
|
|
48491
|
-
return deps.exists(
|
|
48546
|
+
return deps.exists(join11(dir, `${safe}.json`));
|
|
48492
48547
|
} catch {
|
|
48493
48548
|
return false;
|
|
48494
48549
|
}
|
|
48495
48550
|
}
|
|
48496
48551
|
|
|
48497
48552
|
// src/ack-reaction.ts
|
|
48498
|
-
import { readdirSync as readdirSync4, readFileSync as
|
|
48499
|
-
import { join as
|
|
48553
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync11, writeFileSync as writeFileSync6 } from "fs";
|
|
48554
|
+
import { join as join13 } from "path";
|
|
48500
48555
|
|
|
48501
48556
|
// src/flags-cache-read.ts
|
|
48502
|
-
import { existsSync as existsSync4, readFileSync as
|
|
48557
|
+
import { existsSync as existsSync4, readFileSync as readFileSync10 } from "fs";
|
|
48503
48558
|
import { homedir as homedir3 } from "os";
|
|
48504
|
-
import { join as
|
|
48559
|
+
import { join as join12 } from "path";
|
|
48505
48560
|
function hasUsableFlags(path) {
|
|
48506
48561
|
try {
|
|
48507
48562
|
if (!existsSync4(path)) return false;
|
|
48508
|
-
const parsed = JSON.parse(
|
|
48563
|
+
const parsed = JSON.parse(readFileSync10(path, "utf8"));
|
|
48509
48564
|
if (!parsed || typeof parsed !== "object") return false;
|
|
48510
48565
|
const flags = parsed.flags;
|
|
48511
48566
|
return !!flags && typeof flags === "object" && !Array.isArray(flags);
|
|
@@ -48516,7 +48571,7 @@ function hasUsableFlags(path) {
|
|
|
48516
48571
|
function cacheUpdatedAt(path) {
|
|
48517
48572
|
try {
|
|
48518
48573
|
if (!existsSync4(path)) return void 0;
|
|
48519
|
-
const parsed = JSON.parse(
|
|
48574
|
+
const parsed = JSON.parse(readFileSync10(path, "utf8"));
|
|
48520
48575
|
if (!parsed || typeof parsed !== "object") return void 0;
|
|
48521
48576
|
const u = parsed.updated_at;
|
|
48522
48577
|
return typeof u === "string" && u.length > 0 ? u : void 0;
|
|
@@ -48525,10 +48580,10 @@ function cacheUpdatedAt(path) {
|
|
|
48525
48580
|
}
|
|
48526
48581
|
}
|
|
48527
48582
|
function defaultFlagsCachePath(env2 = process.env) {
|
|
48528
|
-
const hostWide =
|
|
48583
|
+
const hostWide = join12(homedir3(), ".augmented", "flags-cache.json");
|
|
48529
48584
|
const agentId = env2["AGT_AGENT_ID"]?.trim();
|
|
48530
48585
|
if (!agentId) return hostWide;
|
|
48531
|
-
const perAgent =
|
|
48586
|
+
const perAgent = join12(homedir3(), ".augmented", agentId, "flags-cache.json");
|
|
48532
48587
|
if (!hasUsableFlags(perAgent)) return hostWide;
|
|
48533
48588
|
const hostWideAt = cacheUpdatedAt(hostWide);
|
|
48534
48589
|
const perAgentAt = cacheUpdatedAt(perAgent);
|
|
@@ -48546,7 +48601,7 @@ function envBoolean(raw) {
|
|
|
48546
48601
|
function cachedBoolean(key, path) {
|
|
48547
48602
|
try {
|
|
48548
48603
|
if (!existsSync4(path)) return void 0;
|
|
48549
|
-
const parsed = JSON.parse(
|
|
48604
|
+
const parsed = JSON.parse(readFileSync10(path, "utf8"));
|
|
48550
48605
|
if (!parsed || typeof parsed !== "object") return void 0;
|
|
48551
48606
|
const flags = parsed.flags;
|
|
48552
48607
|
if (!flags || typeof flags !== "object") return void 0;
|
|
@@ -48578,7 +48633,7 @@ function parseMaintenanceMode(raw) {
|
|
|
48578
48633
|
function cachedMaintenanceMode(path) {
|
|
48579
48634
|
try {
|
|
48580
48635
|
if (!existsSync4(path)) return void 0;
|
|
48581
|
-
const parsed = JSON.parse(
|
|
48636
|
+
const parsed = JSON.parse(readFileSync10(path, "utf8"));
|
|
48582
48637
|
if (!parsed || typeof parsed !== "object") return void 0;
|
|
48583
48638
|
const flags = parsed.flags;
|
|
48584
48639
|
if (!flags || typeof flags !== "object") return void 0;
|
|
@@ -48661,7 +48716,7 @@ function undeliverableNoticeTextForRepeat(i) {
|
|
|
48661
48716
|
}
|
|
48662
48717
|
return null;
|
|
48663
48718
|
}
|
|
48664
|
-
function channelInboundGateOpen(readFile = (p2) =>
|
|
48719
|
+
function channelInboundGateOpen(readFile = (p2) => readFileSync11(p2, "utf-8")) {
|
|
48665
48720
|
const path = process.platform === "darwin" ? "/Library/Application Support/ClaudeCode/managed-settings.json" : "/etc/claude-code/managed-settings.json";
|
|
48666
48721
|
let raw;
|
|
48667
48722
|
try {
|
|
@@ -48726,7 +48781,7 @@ var GIVE_UP_SIGNAL_MAX_AGE_MS = 30 * 60 * 1e3;
|
|
|
48726
48781
|
function readGiveUpSignal(path, now = Date.now()) {
|
|
48727
48782
|
if (!path) return null;
|
|
48728
48783
|
try {
|
|
48729
|
-
const raw = JSON.parse(
|
|
48784
|
+
const raw = JSON.parse(readFileSync11(path, "utf8"));
|
|
48730
48785
|
if (typeof raw.gave_up_at !== "string") return null;
|
|
48731
48786
|
const t = Date.parse(raw.gave_up_at);
|
|
48732
48787
|
if (!Number.isFinite(t) || t > now) return null;
|
|
@@ -48740,12 +48795,12 @@ function readGiveUpSignal(path, now = Date.now()) {
|
|
|
48740
48795
|
var USAGE_LIMIT_LIVE_WINDOW_MS = 3 * 6e4;
|
|
48741
48796
|
function readUsageLimitForBusyAck(agentDir, now = Date.now()) {
|
|
48742
48797
|
if (!agentDir) return null;
|
|
48743
|
-
const path =
|
|
48798
|
+
const path = join13(agentDir, GIVE_UP_SIGNAL_FILENAME);
|
|
48744
48799
|
const sig = readGiveUpSignal(path, now);
|
|
48745
48800
|
if (sig?.reason !== "usage_limit") return null;
|
|
48746
48801
|
let lastSeenMs = null;
|
|
48747
48802
|
try {
|
|
48748
|
-
const raw = JSON.parse(
|
|
48803
|
+
const raw = JSON.parse(readFileSync11(path, "utf8"));
|
|
48749
48804
|
if (typeof raw.usage_limit_last_seen_at === "string") {
|
|
48750
48805
|
const t = Date.parse(raw.usage_limit_last_seen_at);
|
|
48751
48806
|
if (Number.isFinite(t) && t <= now) lastSeenMs = t;
|
|
@@ -48764,7 +48819,7 @@ function readBlockedPromptForBusyAck(agentDir, now = Date.now()) {
|
|
|
48764
48819
|
if (!agentDir) return null;
|
|
48765
48820
|
let raw;
|
|
48766
48821
|
try {
|
|
48767
|
-
raw = JSON.parse(
|
|
48822
|
+
raw = JSON.parse(readFileSync11(join13(agentDir, BLOCKED_PROMPT_SIGNAL_FILENAME), "utf8"));
|
|
48768
48823
|
} catch {
|
|
48769
48824
|
return null;
|
|
48770
48825
|
}
|
|
@@ -48818,7 +48873,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
|
|
|
48818
48873
|
if (opts?.exclude?.(name)) continue;
|
|
48819
48874
|
let receivedAt;
|
|
48820
48875
|
try {
|
|
48821
|
-
const raw = JSON.parse(
|
|
48876
|
+
const raw = JSON.parse(readFileSync11(join13(dir, name), "utf-8"));
|
|
48822
48877
|
if (markerOwesNoReply(raw)) continue;
|
|
48823
48878
|
if (!opts?.includeSeen && typeof raw.seen_at === "string" && raw.seen_at) continue;
|
|
48824
48879
|
receivedAt = raw.received_at;
|
|
@@ -48872,27 +48927,27 @@ function isMarkerGenuinelyAged(receivedAt, nowMs, thresholdMs) {
|
|
|
48872
48927
|
}
|
|
48873
48928
|
var DEFLECTION_COUNTER_SUFFIX = "-deflections.json";
|
|
48874
48929
|
function deflectionCounterPath(agentDir, channel) {
|
|
48875
|
-
return
|
|
48930
|
+
return join13(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
|
|
48876
48931
|
}
|
|
48877
48932
|
function recordChannelDeflection(agentDir, channel, cause) {
|
|
48878
48933
|
if (!agentDir) return;
|
|
48879
48934
|
const path = deflectionCounterPath(agentDir, channel);
|
|
48880
48935
|
let counts = {};
|
|
48881
48936
|
try {
|
|
48882
|
-
const parsed = JSON.parse(
|
|
48937
|
+
const parsed = JSON.parse(readFileSync11(path, "utf-8"));
|
|
48883
48938
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
48884
48939
|
} catch {
|
|
48885
48940
|
}
|
|
48886
48941
|
counts[cause] = (counts[cause] ?? 0) + 1;
|
|
48887
48942
|
try {
|
|
48888
|
-
|
|
48943
|
+
writeFileSync6(path, JSON.stringify(counts), { mode: 384 });
|
|
48889
48944
|
} catch {
|
|
48890
48945
|
}
|
|
48891
48946
|
}
|
|
48892
48947
|
|
|
48893
48948
|
// src/turn-failure-watch.ts
|
|
48894
48949
|
import { readdirSync as readdirSync5, statSync as statSync2 } from "fs";
|
|
48895
|
-
import { join as
|
|
48950
|
+
import { join as join14 } from "path";
|
|
48896
48951
|
function turnFailureNoticeEnabled(env2) {
|
|
48897
48952
|
return resolveHostBooleanFlag({
|
|
48898
48953
|
key: "wedge-transient-notice",
|
|
@@ -48922,7 +48977,7 @@ function classifyTurnFailureSince(opts) {
|
|
|
48922
48977
|
const unrecognised = /* @__PURE__ */ new Set();
|
|
48923
48978
|
for (const name of entries) {
|
|
48924
48979
|
if (!name.endsWith(".jsonl")) continue;
|
|
48925
|
-
const path =
|
|
48980
|
+
const path = join14(dir, name);
|
|
48926
48981
|
let fingerprint;
|
|
48927
48982
|
try {
|
|
48928
48983
|
const st = statSync2(path);
|
|
@@ -49176,14 +49231,14 @@ var PollFollowUps = class {
|
|
|
49176
49231
|
import {
|
|
49177
49232
|
existsSync as existsSync5,
|
|
49178
49233
|
mkdirSync as mkdirSync6,
|
|
49179
|
-
readFileSync as
|
|
49180
|
-
renameSync as
|
|
49234
|
+
readFileSync as readFileSync12,
|
|
49235
|
+
renameSync as renameSync6,
|
|
49181
49236
|
statSync as statSync3,
|
|
49182
49237
|
unlinkSync as unlinkSync3,
|
|
49183
49238
|
utimesSync,
|
|
49184
|
-
writeFileSync as
|
|
49239
|
+
writeFileSync as writeFileSync7
|
|
49185
49240
|
} from "fs";
|
|
49186
|
-
import { join as
|
|
49241
|
+
import { join as join15 } from "path";
|
|
49187
49242
|
var STALE_LOCK_MS = 9e4;
|
|
49188
49243
|
var HEARTBEAT_INTERVAL_MS = 3e4;
|
|
49189
49244
|
function defaultIsPidAlive(pid) {
|
|
@@ -49206,7 +49261,7 @@ function acquireMcpSpawnLock(args) {
|
|
|
49206
49261
|
const nowMs = options.nowMs ?? (() => Date.now());
|
|
49207
49262
|
const lockMtimeMs = options.lockMtimeMs ?? defaultLockMtimeMs;
|
|
49208
49263
|
const staleMs = options.staleMs ?? STALE_LOCK_MS;
|
|
49209
|
-
const path =
|
|
49264
|
+
const path = join15(agentDir, basename3);
|
|
49210
49265
|
const existing = readLockHolder(path);
|
|
49211
49266
|
if (existing) {
|
|
49212
49267
|
if (existing.pid === selfPid) {
|
|
@@ -49223,8 +49278,8 @@ function acquireMcpSpawnLock(args) {
|
|
|
49223
49278
|
mkdirSync6(agentDir, { recursive: true, mode: 448 });
|
|
49224
49279
|
const tmpPath = `${path}.${selfPid}.tmp`;
|
|
49225
49280
|
const payload = { pid: selfPid, started_at: now() };
|
|
49226
|
-
|
|
49227
|
-
|
|
49281
|
+
writeFileSync7(tmpPath, JSON.stringify(payload), { mode: 384 });
|
|
49282
|
+
renameSync6(tmpPath, path);
|
|
49228
49283
|
return { kind: "acquired", path };
|
|
49229
49284
|
}
|
|
49230
49285
|
function releaseMcpSpawnLock(lockPath, opts = {}) {
|
|
@@ -49273,7 +49328,7 @@ function defaultLockMtimeMs(path) {
|
|
|
49273
49328
|
function readLockHolder(path) {
|
|
49274
49329
|
if (!existsSync5(path)) return null;
|
|
49275
49330
|
try {
|
|
49276
|
-
const raw =
|
|
49331
|
+
const raw = readFileSync12(path, "utf8");
|
|
49277
49332
|
const parsed = JSON.parse(raw);
|
|
49278
49333
|
const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
|
|
49279
49334
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
@@ -49286,16 +49341,16 @@ function readLockHolder(path) {
|
|
|
49286
49341
|
|
|
49287
49342
|
// src/direct-chat-channel.ts
|
|
49288
49343
|
import { homedir as homedir5 } from "os";
|
|
49289
|
-
import { basename as basename2, join as
|
|
49344
|
+
import { basename as basename2, join as join19 } from "path";
|
|
49290
49345
|
import { randomUUID } from "crypto";
|
|
49291
49346
|
import {
|
|
49292
49347
|
watch,
|
|
49293
49348
|
mkdirSync as mkdirSync7,
|
|
49294
|
-
writeFileSync as
|
|
49295
|
-
readFileSync as
|
|
49349
|
+
writeFileSync as writeFileSync9,
|
|
49350
|
+
readFileSync as readFileSync15,
|
|
49296
49351
|
readdirSync as readdirSync6,
|
|
49297
49352
|
existsSync as existsSync6,
|
|
49298
|
-
renameSync as
|
|
49353
|
+
renameSync as renameSync7,
|
|
49299
49354
|
unlinkSync as unlinkSync4,
|
|
49300
49355
|
rmSync,
|
|
49301
49356
|
statSync as statSync4,
|
|
@@ -49303,7 +49358,7 @@ import {
|
|
|
49303
49358
|
} from "fs";
|
|
49304
49359
|
|
|
49305
49360
|
// src/direct-chat-inbound-attachments.ts
|
|
49306
|
-
import { join as
|
|
49361
|
+
import { join as join16 } from "path";
|
|
49307
49362
|
|
|
49308
49363
|
// ../../node_modules/.pnpm/postal-mime@4.0.5/node_modules/postal-mime/dist/esm/decode-strings.js
|
|
49309
49364
|
var textEncoder2 = new TextEncoder();
|
|
@@ -54548,7 +54603,7 @@ var OVER_CAP_ERROR = `exceeds the ${formatUploadSize(MAX_INBOUND_ATTACHMENT_BYTE
|
|
|
54548
54603
|
var INBOUND_ATTACHMENTS_SUBDIR = "direct-chat-inbound";
|
|
54549
54604
|
function resolveInboundAttachmentsDir(input) {
|
|
54550
54605
|
const alias = resolveAgentDirAlias(input);
|
|
54551
|
-
return alias === null ? null :
|
|
54606
|
+
return alias === null ? null : join16(alias, INBOUND_ATTACHMENTS_SUBDIR);
|
|
54552
54607
|
}
|
|
54553
54608
|
function isImageContentType(contentType) {
|
|
54554
54609
|
return typeof contentType === "string" && contentType.toLowerCase().startsWith("image/");
|
|
@@ -55508,19 +55563,19 @@ function shouldSendToolsOfflineNotice(opts) {
|
|
|
55508
55563
|
var TOOLS_OFFLINE_USER_NOTICE = "Heads up \u2014 Ninjafy is in a maintenance window right now, so I can't save anything: no tasks, canvases, notes or scheduled items. I can still talk things through, and you can ask me to set it up once maintenance is done.";
|
|
55509
55564
|
|
|
55510
55565
|
// src/account-enforcement-notice.ts
|
|
55511
|
-
import { readFileSync as
|
|
55566
|
+
import { readFileSync as readFileSync13 } from "fs";
|
|
55512
55567
|
import { homedir as homedir4 } from "os";
|
|
55513
|
-
import { join as
|
|
55568
|
+
import { join as join17 } from "path";
|
|
55514
55569
|
function accountEnforcementMarkerPath(codeName) {
|
|
55515
55570
|
if (!codeName) return null;
|
|
55516
|
-
return
|
|
55571
|
+
return join17(homedir4(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
|
|
55517
55572
|
}
|
|
55518
55573
|
function readAccountEnforcementMarker(opts) {
|
|
55519
55574
|
const path = opts.filePath ?? accountEnforcementMarkerPath(opts.codeName);
|
|
55520
55575
|
if (!path) return null;
|
|
55521
55576
|
let raw;
|
|
55522
55577
|
try {
|
|
55523
|
-
raw =
|
|
55578
|
+
raw = readFileSync13(path, "utf-8");
|
|
55524
55579
|
} catch {
|
|
55525
55580
|
return null;
|
|
55526
55581
|
}
|
|
@@ -55546,8 +55601,8 @@ function shouldSendAccountWarn(opts) {
|
|
|
55546
55601
|
}
|
|
55547
55602
|
|
|
55548
55603
|
// ../core/dist/direct-chat/cursor-advance-telemetry.js
|
|
55549
|
-
import { readFileSync as
|
|
55550
|
-
import { join as
|
|
55604
|
+
import { readFileSync as readFileSync14, writeFileSync as writeFileSync8 } from "fs";
|
|
55605
|
+
import { join as join18 } from "path";
|
|
55551
55606
|
var CURSOR_SHORTFALL_COUNTER_SUFFIX = "-cursor-advance-classifications.json";
|
|
55552
55607
|
function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
|
|
55553
55608
|
if (!agentDir)
|
|
@@ -55555,10 +55610,10 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
|
|
|
55555
55610
|
const key = cursorAdvanceCounterKey(route, verdict);
|
|
55556
55611
|
if (key === null)
|
|
55557
55612
|
return;
|
|
55558
|
-
const path =
|
|
55613
|
+
const path = join18(agentDir, `${source}${CURSOR_SHORTFALL_COUNTER_SUFFIX}`);
|
|
55559
55614
|
const counts = {};
|
|
55560
55615
|
try {
|
|
55561
|
-
const parsed = JSON.parse(
|
|
55616
|
+
const parsed = JSON.parse(readFileSync14(path, "utf-8"));
|
|
55562
55617
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
55563
55618
|
for (const [k, v] of Object.entries(parsed)) {
|
|
55564
55619
|
if (typeof v === "number" && Number.isInteger(v) && v >= 0)
|
|
@@ -55569,7 +55624,7 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
|
|
|
55569
55624
|
}
|
|
55570
55625
|
counts[key] = (counts[key] ?? 0) + 1;
|
|
55571
55626
|
try {
|
|
55572
|
-
|
|
55627
|
+
writeFileSync8(path, JSON.stringify(counts), { mode: 384 });
|
|
55573
55628
|
} catch {
|
|
55574
55629
|
}
|
|
55575
55630
|
}
|
|
@@ -55695,7 +55750,7 @@ var DIRECT_CHAT_ACCOUNT_WARN_COOLDOWN_MS = (() => {
|
|
|
55695
55750
|
var AGT_HOST = process.env.AGT_HOST;
|
|
55696
55751
|
var AGT_API_KEY = process.env.AGT_API_KEY;
|
|
55697
55752
|
var AGT_AGENT_ID = process.env.AGT_AGENT_ID;
|
|
55698
|
-
var DIRECT_CHAT_AGENT_DIR = AGT_AGENT_ID ?
|
|
55753
|
+
var DIRECT_CHAT_AGENT_DIR = AGT_AGENT_ID ? join19(homedir5(), ".augmented", AGT_AGENT_ID) : null;
|
|
55699
55754
|
var INBOUND_ATTACHMENTS_DIR = resolveInboundAttachmentsDir({
|
|
55700
55755
|
codeName: process.env.AGT_AGENT_CODE_NAME,
|
|
55701
55756
|
turnInitiatorFile: process.env.AGT_TURN_INITIATOR_FILE,
|
|
@@ -55712,10 +55767,10 @@ var AGT_AGENT_CODE_NAME = process.env.AGT_AGENT_CODE_NAME;
|
|
|
55712
55767
|
var directChatStderrLogStream = null;
|
|
55713
55768
|
if (AGT_AGENT_CODE_NAME) {
|
|
55714
55769
|
try {
|
|
55715
|
-
const logDir =
|
|
55770
|
+
const logDir = join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME);
|
|
55716
55771
|
mkdirSync7(logDir, { recursive: true });
|
|
55717
55772
|
directChatStderrLogStream = createWriteStream(
|
|
55718
|
-
|
|
55773
|
+
join19(logDir, "direct-chat-channel-stderr.log"),
|
|
55719
55774
|
{ flags: "a", mode: 384 }
|
|
55720
55775
|
);
|
|
55721
55776
|
directChatStderrLogStream.on("error", () => {
|
|
@@ -55734,10 +55789,10 @@ if (AGT_AGENT_CODE_NAME) {
|
|
|
55734
55789
|
} catch {
|
|
55735
55790
|
}
|
|
55736
55791
|
}
|
|
55737
|
-
var PROGRESS_HEARTBEAT_PATH = AGT_AGENT_CODE_NAME ?
|
|
55738
|
-
var DIRECT_CHAT_PENDING_INBOUND_DIR = AGT_AGENT_CODE_NAME ?
|
|
55739
|
-
var DIRECT_CHAT_DELIVERY_LEDGER_DIR = AGT_AGENT_CODE_NAME ?
|
|
55740
|
-
var DIRECT_CHAT_CODE_NAME_AGENT_DIR = AGT_AGENT_CODE_NAME ?
|
|
55792
|
+
var PROGRESS_HEARTBEAT_PATH = AGT_AGENT_CODE_NAME ? join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, "channel-progress-heartbeat.json") : null;
|
|
55793
|
+
var DIRECT_CHAT_PENDING_INBOUND_DIR = AGT_AGENT_CODE_NAME ? join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, "direct-chat-pending-inbound") : null;
|
|
55794
|
+
var DIRECT_CHAT_DELIVERY_LEDGER_DIR = AGT_AGENT_CODE_NAME ? join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, ".agt-inbound-delivery-ledger") : null;
|
|
55795
|
+
var DIRECT_CHAT_CODE_NAME_AGENT_DIR = AGT_AGENT_CODE_NAME ? join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME) : null;
|
|
55741
55796
|
var DIRECT_CHAT_STALE_MARKER_MS = 24 * 60 * 60 * 1e3;
|
|
55742
55797
|
function judgeCursorAdvance(input, ctx) {
|
|
55743
55798
|
const verdict = classifyCursorAdvance(input);
|
|
@@ -55757,8 +55812,8 @@ function recordDirectChatDelivery(sessionId, messageIds) {
|
|
|
55757
55812
|
delivered_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
55758
55813
|
});
|
|
55759
55814
|
}
|
|
55760
|
-
var DIRECT_CHAT_RECOVERY_OUTBOX_DIR = AGT_AGENT_CODE_NAME ?
|
|
55761
|
-
var DIRECT_CHAT_RECOVERY_LEDGER_DIR = AGT_AGENT_CODE_NAME ?
|
|
55815
|
+
var DIRECT_CHAT_RECOVERY_OUTBOX_DIR = AGT_AGENT_CODE_NAME ? join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, "direct-chat-recovery-outbox") : null;
|
|
55816
|
+
var DIRECT_CHAT_RECOVERY_LEDGER_DIR = AGT_AGENT_CODE_NAME ? join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME, ".agt-direct-chat-recovery-ledger") : null;
|
|
55762
55817
|
var progressReceivedAt = /* @__PURE__ */ new Map();
|
|
55763
55818
|
var directChatProgressState = { tracked: null };
|
|
55764
55819
|
var directChatProgressTickRunning = false;
|
|
@@ -55777,7 +55832,7 @@ var directChatKanbanCardClient = createKanbanCardActiveClient({
|
|
|
55777
55832
|
function readProgressHeartbeat() {
|
|
55778
55833
|
if (!PROGRESS_HEARTBEAT_PATH || !existsSync6(PROGRESS_HEARTBEAT_PATH)) return null;
|
|
55779
55834
|
try {
|
|
55780
|
-
return parseProgressHeartbeat(
|
|
55835
|
+
return parseProgressHeartbeat(readFileSync15(PROGRESS_HEARTBEAT_PATH, "utf-8"));
|
|
55781
55836
|
} catch {
|
|
55782
55837
|
return null;
|
|
55783
55838
|
}
|
|
@@ -55786,9 +55841,9 @@ function seedProgressHeartbeat() {
|
|
|
55786
55841
|
if (!PROGRESS_HEARTBEAT_PATH) return;
|
|
55787
55842
|
const tmp = `${PROGRESS_HEARTBEAT_PATH}.${process.pid}.tmp`;
|
|
55788
55843
|
try {
|
|
55789
|
-
mkdirSync7(
|
|
55790
|
-
|
|
55791
|
-
|
|
55844
|
+
mkdirSync7(join19(homedir5(), ".augmented", AGT_AGENT_CODE_NAME), { recursive: true });
|
|
55845
|
+
writeFileSync9(tmp, serializeProgressHeartbeat(SEED_PROGRESS_STEP, Date.now()), { mode: 384 });
|
|
55846
|
+
renameSync7(tmp, PROGRESS_HEARTBEAT_PATH);
|
|
55792
55847
|
} catch {
|
|
55793
55848
|
try {
|
|
55794
55849
|
unlinkSync4(tmp);
|
|
@@ -56017,8 +56072,8 @@ var inboundAttachmentDeps = {
|
|
|
56017
56072
|
fetchUrl: (url, expectedBytes) => fetchWithTransferDeadline(url, inboundDownloadTimeoutMs(expectedBytes)),
|
|
56018
56073
|
ensureDir: (dir) => mkdirSync7(dir, { recursive: true }),
|
|
56019
56074
|
removeDir: (dir) => rmSync(dir, { recursive: true, force: true }),
|
|
56020
|
-
writeFile: (path, bytes) =>
|
|
56021
|
-
joinPath: (...parts) =>
|
|
56075
|
+
writeFile: (path, bytes) => writeFileSync9(path, bytes, { mode: 384 }),
|
|
56076
|
+
joinPath: (...parts) => join19(...parts),
|
|
56022
56077
|
warn: (msg) => process.stderr.write(`${msg}
|
|
56023
56078
|
`)
|
|
56024
56079
|
};
|
|
@@ -56054,10 +56109,16 @@ var mcp = new Server(
|
|
|
56054
56109
|
);
|
|
56055
56110
|
var DIRECT_CHAT_CLAIMS_PATH = directChatClaimsPath(DIRECT_CHAT_AGENT_DIR);
|
|
56056
56111
|
var claimsTranscriptId = null;
|
|
56112
|
+
var DIRECT_CHAT_INFLIGHT_PATH = DIRECT_CHAT_AGENT_DIR ? directChatInflightPath(DIRECT_CHAT_AGENT_DIR) : null;
|
|
56057
56113
|
var claimTracker = new DirectChatClaimTracker({
|
|
56058
|
-
|
|
56059
|
-
|
|
56060
|
-
|
|
56114
|
+
// ENG-12100: also writes the in-flight marker the manager-restart gate reads,
|
|
56115
|
+
// on every claim change (empty once the push resolves), independent of the
|
|
56116
|
+
// doorbell binding the claims store depends on.
|
|
56117
|
+
onChange: (t) => publishDirectChatClaimsChange(t.snapshot(), {
|
|
56118
|
+
saveClaims: (snapshot) => saveDirectChatClaims(DIRECT_CHAT_CLAIMS_PATH, claimsTranscriptId, snapshot, Date.now()),
|
|
56119
|
+
inflightPath: DIRECT_CHAT_INFLIGHT_PATH,
|
|
56120
|
+
pid: process.pid
|
|
56121
|
+
})
|
|
56061
56122
|
});
|
|
56062
56123
|
mcp.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
56063
56124
|
tools: [
|
|
@@ -56536,7 +56597,7 @@ function directChatSessionReplayFacts(sessionId) {
|
|
|
56536
56597
|
sessionId,
|
|
56537
56598
|
(fullPath) => {
|
|
56538
56599
|
try {
|
|
56539
|
-
const marker = JSON.parse(
|
|
56600
|
+
const marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
|
|
56540
56601
|
found.push({ hasPayload: Boolean(marker.payload), discretionary: marker.discretionary });
|
|
56541
56602
|
} catch {
|
|
56542
56603
|
found.push({ hasPayload: false });
|
|
@@ -56595,7 +56656,7 @@ function scheduleDirectChatBusyAck(sessionId, messageId, arrivedWhileBusy) {
|
|
|
56595
56656
|
let paneLogFreshAgeMs = null;
|
|
56596
56657
|
if (DIRECT_CHAT_CODE_NAME_AGENT_DIR) {
|
|
56597
56658
|
try {
|
|
56598
|
-
const paneMtimeMs = statSync4(
|
|
56659
|
+
const paneMtimeMs = statSync4(join19(DIRECT_CHAT_CODE_NAME_AGENT_DIR, "pane.log")).mtimeMs;
|
|
56599
56660
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
56600
56661
|
} catch {
|
|
56601
56662
|
}
|
|
@@ -57054,6 +57115,9 @@ var stopLockHeartbeat = null;
|
|
|
57054
57115
|
stopLockHeartbeat = startMcpSpawnLockHeartbeat(acquiredLockPath);
|
|
57055
57116
|
}
|
|
57056
57117
|
}
|
|
57118
|
+
if (DIRECT_CHAT_INFLIGHT_PATH) {
|
|
57119
|
+
writeDirectChatInflightMarker(DIRECT_CHAT_INFLIGHT_PATH, buildDirectChatInflightMarker(claimTracker.snapshot(), process.pid));
|
|
57120
|
+
}
|
|
57057
57121
|
var DOORBELL_ENABLED = resolveHostBooleanFlag({
|
|
57058
57122
|
key: "direct-chat-doorbell",
|
|
57059
57123
|
envVar: "AGT_DIRECT_CHAT_DOORBELL_ENABLED",
|
|
@@ -57137,6 +57201,9 @@ if (DOORBELL_ENABLED && DIRECT_CHAT_AGENT_DIR) {
|
|
|
57137
57201
|
const transcriptText = recovered.length > 0 && claimPlan.bindTo ? readTranscriptText(transcriptPathFor(agentTranscriptDir(), claimPlan.bindTo)) : null;
|
|
57138
57202
|
const plan = recovered.length > 0 ? planRehand(recovered, transcriptText, sessionState.startedAtMs) : null;
|
|
57139
57203
|
claimTracker.restore(recovered, { unpushed: plan?.rehand ?? [] });
|
|
57204
|
+
if (DIRECT_CHAT_INFLIGHT_PATH && recovered.length > 0) {
|
|
57205
|
+
writeDirectChatInflightMarker(DIRECT_CHAT_INFLIGHT_PATH, buildDirectChatInflightMarker(claimTracker.snapshot(), process.pid));
|
|
57206
|
+
}
|
|
57140
57207
|
rehandPlan = plan ? { restored: recovered.length, plan } : null;
|
|
57141
57208
|
if (recovered.length > 0) {
|
|
57142
57209
|
process.stderr.write(
|
|
@@ -57240,7 +57307,7 @@ function sweepAgedDirectChatMarkersNow(thresholdMs) {
|
|
|
57240
57307
|
const now = Date.now();
|
|
57241
57308
|
const res = sweepAgedDirectChatMarkers(DIRECT_CHAT_PENDING_INBOUND_DIR, {
|
|
57242
57309
|
readdir: (dir) => readdirSync6(dir),
|
|
57243
|
-
readFile: (p2) =>
|
|
57310
|
+
readFile: (p2) => readFileSync15(p2, "utf8"),
|
|
57244
57311
|
unlink: (p2) => {
|
|
57245
57312
|
if (existsSync6(p2)) unlinkSync4(p2);
|
|
57246
57313
|
},
|
|
@@ -57289,8 +57356,8 @@ function sanitizeRecoveryText(text) {
|
|
|
57289
57356
|
}
|
|
57290
57357
|
function directChatRecoveryDeps() {
|
|
57291
57358
|
return {
|
|
57292
|
-
readFile: (p2) =>
|
|
57293
|
-
renameFile: (from, to) =>
|
|
57359
|
+
readFile: (p2) => readFileSync15(p2, "utf-8"),
|
|
57360
|
+
renameFile: (from, to) => renameSync7(from, to),
|
|
57294
57361
|
unlinkFile: (p2) => {
|
|
57295
57362
|
if (existsSync6(p2)) unlinkSync4(p2);
|
|
57296
57363
|
},
|
|
@@ -57302,7 +57369,7 @@ function directChatRecoveryDeps() {
|
|
|
57302
57369
|
if (!DIRECT_CHAT_RECOVERY_LEDGER_DIR) return;
|
|
57303
57370
|
if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return;
|
|
57304
57371
|
try {
|
|
57305
|
-
const p2 =
|
|
57372
|
+
const p2 = join19(DIRECT_CHAT_RECOVERY_LEDGER_DIR, markerName);
|
|
57306
57373
|
if (existsSync6(p2)) unlinkSync4(p2);
|
|
57307
57374
|
} catch {
|
|
57308
57375
|
}
|
|
@@ -57353,7 +57420,7 @@ async function processDirectChatRecoveryOutboxFile(filename) {
|
|
|
57353
57420
|
if (!enabled) return;
|
|
57354
57421
|
directChatRecoveryInFlight.add(filename);
|
|
57355
57422
|
try {
|
|
57356
|
-
const fullPath =
|
|
57423
|
+
const fullPath = join19(DIRECT_CHAT_RECOVERY_OUTBOX_DIR, filename);
|
|
57357
57424
|
await consumeDirectChatRecoveryFile(fullPath, filename, directChatRecoveryDeps());
|
|
57358
57425
|
} catch (err) {
|
|
57359
57426
|
process.stderr.write(
|
|
@@ -57381,7 +57448,7 @@ if (DIRECT_CHAT_RECOVERY_OUTBOX_DIR) {
|
|
|
57381
57448
|
if (!filename) return;
|
|
57382
57449
|
const name = filename.toString();
|
|
57383
57450
|
if (!name.endsWith(".json")) return;
|
|
57384
|
-
if (existsSync6(
|
|
57451
|
+
if (existsSync6(join19(DIRECT_CHAT_RECOVERY_OUTBOX_DIR, name))) {
|
|
57385
57452
|
void processDirectChatRecoveryOutboxFile(name);
|
|
57386
57453
|
}
|
|
57387
57454
|
});
|