@dosu/cli 0.67.0-beta.7 → 0.67.0-beta.8
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/bin/dosu.js +220 -70
- package/package.json +1 -1
package/bin/dosu.js
CHANGED
|
@@ -450,7 +450,7 @@ function isNpxInvocation(channel = INSTALL_CHANNEL, env = process.env) {
|
|
|
450
450
|
function getVersionString() {
|
|
451
451
|
return `v${VERSION}`;
|
|
452
452
|
}
|
|
453
|
-
var VERSION = "0.67.0-beta.
|
|
453
|
+
var VERSION = "0.67.0-beta.8", INSTALL_CHANNEL = "npm";
|
|
454
454
|
|
|
455
455
|
// src/debug/logger.ts
|
|
456
456
|
import {
|
|
@@ -22237,7 +22237,7 @@ var init_backlog = __esm(() => {
|
|
|
22237
22237
|
});
|
|
22238
22238
|
|
|
22239
22239
|
// src/telemetry/debug-id.ts
|
|
22240
|
-
var BUNDLE_DEBUG_ID_PLACEHOLDER = "
|
|
22240
|
+
var BUNDLE_DEBUG_ID_PLACEHOLDER = "b1ea3994-833d-5f18-6475-6e2164756e21";
|
|
22241
22241
|
|
|
22242
22242
|
// src/telemetry/telemetry.ts
|
|
22243
22243
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
@@ -23539,6 +23539,152 @@ var init_session_start = __esm(() => {
|
|
|
23539
23539
|
init_normalize();
|
|
23540
23540
|
});
|
|
23541
23541
|
|
|
23542
|
+
// src/shipper/usage.ts
|
|
23543
|
+
import { readFileSync as readFileSync25 } from "node:fs";
|
|
23544
|
+
function isObject7(value) {
|
|
23545
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23546
|
+
}
|
|
23547
|
+
function str2(value) {
|
|
23548
|
+
return typeof value === "string" && value !== "" ? value : null;
|
|
23549
|
+
}
|
|
23550
|
+
function int(value) {
|
|
23551
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.trunc(value) : 0;
|
|
23552
|
+
}
|
|
23553
|
+
function parseLines(transcript) {
|
|
23554
|
+
const lines = [];
|
|
23555
|
+
for (const line of transcript.split(`
|
|
23556
|
+
`)) {
|
|
23557
|
+
if (line.trim() === "")
|
|
23558
|
+
continue;
|
|
23559
|
+
try {
|
|
23560
|
+
const value = JSON.parse(line);
|
|
23561
|
+
if (isObject7(value))
|
|
23562
|
+
lines.push(value);
|
|
23563
|
+
} catch {}
|
|
23564
|
+
}
|
|
23565
|
+
return lines;
|
|
23566
|
+
}
|
|
23567
|
+
function billed(request) {
|
|
23568
|
+
return request.input + request.output + request.cache_read + request.cache_write > 0 || request.tool_call_ids.length > 0;
|
|
23569
|
+
}
|
|
23570
|
+
function claudeUsage(transcript) {
|
|
23571
|
+
const requests = new Map;
|
|
23572
|
+
for (const line of parseLines(transcript)) {
|
|
23573
|
+
if (line.type !== "assistant" || !isObject7(line.message))
|
|
23574
|
+
continue;
|
|
23575
|
+
const message = line.message;
|
|
23576
|
+
const usage = message.usage;
|
|
23577
|
+
const id = str2(line.requestId) ?? str2(message.id) ?? str2(line.uuid);
|
|
23578
|
+
if (!isObject7(usage) || id === null)
|
|
23579
|
+
continue;
|
|
23580
|
+
const toolCallIds = Array.isArray(message.content) ? message.content.filter((block) => isObject7(block) && block.type === "tool_use").map((block) => str2(block.id)).filter((toolId) => toolId !== null) : [];
|
|
23581
|
+
const cacheCreation = isObject7(usage.cache_creation) ? usage.cache_creation : {};
|
|
23582
|
+
const entry = {
|
|
23583
|
+
id,
|
|
23584
|
+
model: str2(message.model),
|
|
23585
|
+
timestamp: str2(line.timestamp),
|
|
23586
|
+
input: int(usage.input_tokens),
|
|
23587
|
+
output: int(usage.output_tokens),
|
|
23588
|
+
cache_read: int(usage.cache_read_input_tokens),
|
|
23589
|
+
cache_write: int(usage.cache_creation_input_tokens),
|
|
23590
|
+
cache_write_1h: int(cacheCreation.ephemeral_1h_input_tokens),
|
|
23591
|
+
speed: str2(usage.speed),
|
|
23592
|
+
tool_call_ids: toolCallIds
|
|
23593
|
+
};
|
|
23594
|
+
const previous = requests.get(id);
|
|
23595
|
+
if (previous === undefined) {
|
|
23596
|
+
requests.set(id, entry);
|
|
23597
|
+
continue;
|
|
23598
|
+
}
|
|
23599
|
+
const latest = entry.output >= previous.output ? entry : previous;
|
|
23600
|
+
requests.set(id, {
|
|
23601
|
+
...latest,
|
|
23602
|
+
timestamp: entry.timestamp ?? previous.timestamp,
|
|
23603
|
+
tool_call_ids: [...new Set([...previous.tool_call_ids, ...entry.tool_call_ids])]
|
|
23604
|
+
});
|
|
23605
|
+
}
|
|
23606
|
+
return [...requests.values()].filter(billed);
|
|
23607
|
+
}
|
|
23608
|
+
function codexUsage(transcript) {
|
|
23609
|
+
const requests = [];
|
|
23610
|
+
let model = null;
|
|
23611
|
+
let ownSessionId = null;
|
|
23612
|
+
let historyStart = null;
|
|
23613
|
+
let lastTotal = null;
|
|
23614
|
+
let toolCallIds = [];
|
|
23615
|
+
for (const line of parseLines(transcript)) {
|
|
23616
|
+
const payload = isObject7(line.payload) ? line.payload : {};
|
|
23617
|
+
const ordinal = typeof line.ordinal === "number" ? line.ordinal : null;
|
|
23618
|
+
if (historyStart !== null && ordinal !== null && ordinal < historyStart)
|
|
23619
|
+
continue;
|
|
23620
|
+
if (line.type === "session_meta") {
|
|
23621
|
+
const metaId = str2(payload.id);
|
|
23622
|
+
if (ownSessionId === null) {
|
|
23623
|
+
ownSessionId = metaId;
|
|
23624
|
+
if (str2(payload.forked_from_id) !== null) {
|
|
23625
|
+
const start = payload.subagent_history_start_ordinal;
|
|
23626
|
+
historyStart = typeof start === "number" ? start : null;
|
|
23627
|
+
}
|
|
23628
|
+
}
|
|
23629
|
+
} else if (line.type === "turn_context") {
|
|
23630
|
+
model = str2(payload.model) ?? model;
|
|
23631
|
+
} else if (line.type === "response_item") {
|
|
23632
|
+
const callId = str2(payload.call_id);
|
|
23633
|
+
if (callId !== null && typeof payload.type === "string" && payload.type.endsWith("_call")) {
|
|
23634
|
+
toolCallIds.push(callId);
|
|
23635
|
+
}
|
|
23636
|
+
} else if (line.type === "event_msg" && payload.type === "token_count") {
|
|
23637
|
+
const info = isObject7(payload.info) ? payload.info : null;
|
|
23638
|
+
const last = info && isObject7(info.last_token_usage) ? info.last_token_usage : null;
|
|
23639
|
+
const total = info && isObject7(info.total_token_usage) ? info.total_token_usage : null;
|
|
23640
|
+
if (last === null || total === null)
|
|
23641
|
+
continue;
|
|
23642
|
+
const runningTotal = int(total.total_tokens);
|
|
23643
|
+
if (runningTotal === lastTotal)
|
|
23644
|
+
continue;
|
|
23645
|
+
lastTotal = runningTotal;
|
|
23646
|
+
const input = int(last.input_tokens);
|
|
23647
|
+
const cached = int(last.cached_input_tokens);
|
|
23648
|
+
const cacheWrite = int(last.cache_write_input_tokens);
|
|
23649
|
+
const disjoint = cached + cacheWrite <= input;
|
|
23650
|
+
const request = {
|
|
23651
|
+
id: `codex:${runningTotal}`,
|
|
23652
|
+
model,
|
|
23653
|
+
timestamp: str2(line.timestamp),
|
|
23654
|
+
input: Math.max(0, input - cached - (disjoint ? cacheWrite : 0)),
|
|
23655
|
+
output: int(last.output_tokens),
|
|
23656
|
+
cache_read: cached,
|
|
23657
|
+
cache_write: disjoint ? cacheWrite : 0,
|
|
23658
|
+
cache_write_1h: 0,
|
|
23659
|
+
speed: null,
|
|
23660
|
+
tool_call_ids: toolCallIds
|
|
23661
|
+
};
|
|
23662
|
+
toolCallIds = [];
|
|
23663
|
+
if (billed(request))
|
|
23664
|
+
requests.push(request);
|
|
23665
|
+
}
|
|
23666
|
+
}
|
|
23667
|
+
return requests;
|
|
23668
|
+
}
|
|
23669
|
+
function readSessionUsage(session) {
|
|
23670
|
+
const reader = READERS[session.harness];
|
|
23671
|
+
if (!reader)
|
|
23672
|
+
return null;
|
|
23673
|
+
try {
|
|
23674
|
+
const requests = reader(readFileSync25(session.path, "utf8"));
|
|
23675
|
+
return requests.length > 0 ? { requests } : null;
|
|
23676
|
+
} catch {
|
|
23677
|
+
return null;
|
|
23678
|
+
}
|
|
23679
|
+
}
|
|
23680
|
+
var READERS;
|
|
23681
|
+
var init_usage = __esm(() => {
|
|
23682
|
+
READERS = {
|
|
23683
|
+
claude: claudeUsage,
|
|
23684
|
+
codex: codexUsage
|
|
23685
|
+
};
|
|
23686
|
+
});
|
|
23687
|
+
|
|
23542
23688
|
// src/shipper/worthiness.ts
|
|
23543
23689
|
function isTrivialTrajectory(records) {
|
|
23544
23690
|
let asked = false;
|
|
@@ -23568,6 +23714,7 @@ function createShipStep(options) {
|
|
|
23568
23714
|
const fetchImpl = options.fetchImpl ?? fetch;
|
|
23569
23715
|
const isIncognito = options.isIncognito ?? isIncognitoSession;
|
|
23570
23716
|
const normalize = options.normalize ?? normalizeSessionRecords;
|
|
23717
|
+
const readUsage = options.readUsage ?? readSessionUsage;
|
|
23571
23718
|
async function shipOne(session, shipped, resolve, hold) {
|
|
23572
23719
|
const held = hold(session);
|
|
23573
23720
|
if (held === "stop")
|
|
@@ -23597,6 +23744,7 @@ function createShipStep(options) {
|
|
|
23597
23744
|
const start = sessionStartOf(records, copied);
|
|
23598
23745
|
const branch = start.recorded ?? resolve.resolveBranch(session, start.firstPromptAt);
|
|
23599
23746
|
const parentSessionId = session.parentId ?? session.forkOf?.id;
|
|
23747
|
+
const usage = readUsage(session);
|
|
23600
23748
|
const body = JSON.stringify({
|
|
23601
23749
|
records: plan.records,
|
|
23602
23750
|
metadata: {
|
|
@@ -23608,7 +23756,8 @@ function createShipStep(options) {
|
|
|
23608
23756
|
...branch ? { branch } : {},
|
|
23609
23757
|
...parentSessionId ? { parent_session_id: parentSessionId } : {},
|
|
23610
23758
|
...plan.continuation ? { continuation: plan.continuation } : {}
|
|
23611
|
-
}
|
|
23759
|
+
},
|
|
23760
|
+
...usage ? { usage } : {}
|
|
23612
23761
|
});
|
|
23613
23762
|
const late = hold(session);
|
|
23614
23763
|
if (late === "stop")
|
|
@@ -23680,12 +23829,13 @@ var init_runner = __esm(() => {
|
|
|
23680
23829
|
init_continuation();
|
|
23681
23830
|
init_normalize();
|
|
23682
23831
|
init_session_start();
|
|
23832
|
+
init_usage();
|
|
23683
23833
|
REJECTED_STATUSES = new Set([400, 413, 422]);
|
|
23684
23834
|
});
|
|
23685
23835
|
|
|
23686
23836
|
// src/memory/context-hook.ts
|
|
23687
23837
|
import { basename as basename10 } from "node:path";
|
|
23688
|
-
function
|
|
23838
|
+
function str3(value) {
|
|
23689
23839
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
23690
23840
|
}
|
|
23691
23841
|
function harnessOf(agent) {
|
|
@@ -23723,10 +23873,10 @@ function incognitoCheckOf(agent) {
|
|
|
23723
23873
|
return transcriptHasIncognitoMarker;
|
|
23724
23874
|
}
|
|
23725
23875
|
function sessionIdOf(payload, format) {
|
|
23726
|
-
const transcript =
|
|
23876
|
+
const transcript = str3(payload.transcript_path);
|
|
23727
23877
|
if (format === "codex" && transcript?.endsWith(".jsonl"))
|
|
23728
23878
|
return basename10(transcript, ".jsonl");
|
|
23729
|
-
return
|
|
23879
|
+
return str3(payload.session_id);
|
|
23730
23880
|
}
|
|
23731
23881
|
function claudeCaller(id, transcript, agentId) {
|
|
23732
23882
|
if (!agentId)
|
|
@@ -23745,7 +23895,7 @@ function outsideIncognitoSession(stdin, options) {
|
|
|
23745
23895
|
const id = sessionIdOf(payload, options.format ?? "claude");
|
|
23746
23896
|
if (!id)
|
|
23747
23897
|
return null;
|
|
23748
|
-
const stored = storedSession2({ harness, id, transcript:
|
|
23898
|
+
const stored = storedSession2({ harness, id, transcript: str3(payload.transcript_path) });
|
|
23749
23899
|
if (!stored || scannedEverywhere(harness, stored.path))
|
|
23750
23900
|
return null;
|
|
23751
23901
|
return options.incognito.sessions[`${harness}/${id}`]?.by_agent ? null : stored;
|
|
@@ -23765,16 +23915,16 @@ function denial(reason) {
|
|
|
23765
23915
|
function memoryToolHookOutput(payload, isIncognito, incognito) {
|
|
23766
23916
|
if (typeof payload.tool_name !== "string" || !MEMORY_TOOL.test(payload.tool_name))
|
|
23767
23917
|
return "";
|
|
23768
|
-
const transcript =
|
|
23769
|
-
const id =
|
|
23918
|
+
const transcript = str3(payload.transcript_path);
|
|
23919
|
+
const id = str3(payload.session_id);
|
|
23770
23920
|
const how = incognito ? agentSwitchOf(incognito, { harness: "claude", id }, () => id && transcript ? sessionAtPath("claude", id, transcript) : null) : null;
|
|
23771
23921
|
if (how)
|
|
23772
23922
|
return denial(agentSwitchMessage(how, "claude", TOOLS_UNAVAILABLE));
|
|
23773
23923
|
if (transcript && isIncognito(transcript))
|
|
23774
23924
|
return denial(INCOGNITO_DENIAL);
|
|
23775
|
-
const toolUseId =
|
|
23925
|
+
const toolUseId = str3(payload.tool_use_id);
|
|
23776
23926
|
if (toolUseId && id) {
|
|
23777
|
-
recordClaudeToolCall(toolUseId, claudeCaller(id, transcript,
|
|
23927
|
+
recordClaudeToolCall(toolUseId, claudeCaller(id, transcript, str3(payload.agent_id)));
|
|
23778
23928
|
}
|
|
23779
23929
|
return "";
|
|
23780
23930
|
}
|
|
@@ -23792,7 +23942,7 @@ async function contextHookOutput(stdin, options) {
|
|
|
23792
23942
|
}
|
|
23793
23943
|
if (format !== "plain" && payload.hook_event_name !== "UserPromptSubmit")
|
|
23794
23944
|
return "";
|
|
23795
|
-
const prompt =
|
|
23945
|
+
const prompt = str3(payload.prompt);
|
|
23796
23946
|
if (!prompt || NOTIFICATION_PROMPT.test(prompt))
|
|
23797
23947
|
return "";
|
|
23798
23948
|
if (textHasIncognitoMarker(prompt) || promptRunsIncognito(prompt))
|
|
@@ -23800,14 +23950,14 @@ async function contextHookOutput(stdin, options) {
|
|
|
23800
23950
|
const agent = options.agent ?? CLAUDE_CODE_AGENT;
|
|
23801
23951
|
const harness = harnessOf(agent);
|
|
23802
23952
|
const sessionId = sessionIdOf(payload, format);
|
|
23803
|
-
const transcript =
|
|
23953
|
+
const transcript = str3(payload.transcript_path);
|
|
23804
23954
|
const switchedOff = harness && options.incognito ? agentSwitchOf(options.incognito, { harness, id: sessionId }, () => sessionId ? storedSession2({ harness, id: sessionId, transcript }) : null) : null;
|
|
23805
23955
|
if (switchedOff)
|
|
23806
23956
|
return "";
|
|
23807
23957
|
const isIncognito = options.isIncognito ?? incognitoCheckOf(agent);
|
|
23808
23958
|
if (transcript && isIncognito(transcript))
|
|
23809
23959
|
return "";
|
|
23810
|
-
const cwd =
|
|
23960
|
+
const cwd = str3(payload.cwd);
|
|
23811
23961
|
const fetchImpl = options.fetchImpl ?? fetch;
|
|
23812
23962
|
const budgetMs = options.timeoutMs ?? CONTEXT_TIMEOUT_MS;
|
|
23813
23963
|
const startedAt = Date.now();
|
|
@@ -23835,9 +23985,9 @@ async function contextHookOutput(stdin, options) {
|
|
|
23835
23985
|
return "";
|
|
23836
23986
|
}
|
|
23837
23987
|
const body = await response.json();
|
|
23838
|
-
const digest =
|
|
23988
|
+
const digest = str3(body.digest);
|
|
23839
23989
|
if (!digest) {
|
|
23840
|
-
note(`no digest, ${
|
|
23990
|
+
note(`no digest, ${str3(body.reason) ?? "none"}`);
|
|
23841
23991
|
return "";
|
|
23842
23992
|
}
|
|
23843
23993
|
const count = Array.isArray(body.memory_ids) ? body.memory_ids.length : 0;
|
|
@@ -23869,7 +24019,7 @@ var init_context_hook = __esm(() => {
|
|
|
23869
24019
|
});
|
|
23870
24020
|
|
|
23871
24021
|
// src/commands/knowledge.ts
|
|
23872
|
-
import { readFileSync as
|
|
24022
|
+
import { readFileSync as readFileSync26 } from "node:fs";
|
|
23873
24023
|
function collectValues(value, previous = []) {
|
|
23874
24024
|
return [...previous, value];
|
|
23875
24025
|
}
|
|
@@ -24126,7 +24276,7 @@ function buildShipper() {
|
|
|
24126
24276
|
};
|
|
24127
24277
|
}
|
|
24128
24278
|
function readStdin3() {
|
|
24129
|
-
return
|
|
24279
|
+
return readFileSync26(0, "utf-8");
|
|
24130
24280
|
}
|
|
24131
24281
|
function contextCommand2() {
|
|
24132
24282
|
return new Command("context").description("Prompt-submit hook: add task memory to the agent's context").option("--agent <source>", "Trajectory source the session ships as", "claude-code").option("--format <format>", "Output: claude or codex hook JSON, or plain digest text", "claude").action(async (opts) => {
|
|
@@ -24850,17 +25000,17 @@ var init_members = __esm(() => {
|
|
|
24850
25000
|
});
|
|
24851
25001
|
|
|
24852
25002
|
// src/mcp/relay.ts
|
|
24853
|
-
function
|
|
25003
|
+
function isObject8(value) {
|
|
24854
25004
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24855
25005
|
}
|
|
24856
25006
|
function messagesOf(value) {
|
|
24857
25007
|
return Array.isArray(value) ? value : [value];
|
|
24858
25008
|
}
|
|
24859
25009
|
function requestIds(message) {
|
|
24860
|
-
return messagesOf(message).flatMap((m) =>
|
|
25010
|
+
return messagesOf(message).flatMap((m) => isObject8(m) && typeof m.method === "string" && (typeof m.id === "string" || typeof m.id === "number") ? [m.id] : []);
|
|
24861
25011
|
}
|
|
24862
25012
|
function responseIds(message) {
|
|
24863
|
-
return messagesOf(message).flatMap((m) =>
|
|
25013
|
+
return messagesOf(message).flatMap((m) => isObject8(m) && (typeof m.id === "string" || typeof m.id === "number") && (("result" in m) || ("error" in m)) ? [m.id] : []);
|
|
24864
25014
|
}
|
|
24865
25015
|
function transportError(id, message) {
|
|
24866
25016
|
return { jsonrpc: "2.0", id, error: { code: TRANSPORT_ERROR, message } };
|
|
@@ -24868,9 +25018,9 @@ function transportError(id, message) {
|
|
|
24868
25018
|
function errorDetail(body) {
|
|
24869
25019
|
try {
|
|
24870
25020
|
const parsed = JSON.parse(body);
|
|
24871
|
-
if (
|
|
25021
|
+
if (isObject8(parsed)) {
|
|
24872
25022
|
const { error, error_description, detail } = parsed;
|
|
24873
|
-
if (
|
|
25023
|
+
if (isObject8(error) && typeof error.message === "string")
|
|
24874
25024
|
return error.message;
|
|
24875
25025
|
if (typeof error_description === "string")
|
|
24876
25026
|
return error_description;
|
|
@@ -24885,7 +25035,7 @@ function errorDetail(body) {
|
|
|
24885
25035
|
function jsonRpcErrorBody(body, ids) {
|
|
24886
25036
|
try {
|
|
24887
25037
|
const parsed = JSON.parse(body);
|
|
24888
|
-
if (
|
|
25038
|
+
if (isObject8(parsed) && isObject8(parsed.error) && ids.includes(parsed.id)) {
|
|
24889
25039
|
return parsed;
|
|
24890
25040
|
}
|
|
24891
25041
|
} catch {}
|
|
@@ -24979,9 +25129,9 @@ function createMcpRelay(options) {
|
|
|
24979
25129
|
return out;
|
|
24980
25130
|
}
|
|
24981
25131
|
function noteInitialized(sent, reply) {
|
|
24982
|
-
const initializeIds = messagesOf(sent).flatMap((m) =>
|
|
25132
|
+
const initializeIds = messagesOf(sent).flatMap((m) => isObject8(m) && m.method === "initialize" ? [m.id] : []);
|
|
24983
25133
|
for (const m of messagesOf(reply)) {
|
|
24984
|
-
if (!
|
|
25134
|
+
if (!isObject8(m) || !initializeIds.includes(m.id) || !isObject8(m.result))
|
|
24985
25135
|
continue;
|
|
24986
25136
|
if (typeof m.result.protocolVersion === "string")
|
|
24987
25137
|
protocolVersion = m.result.protocolVersion;
|
|
@@ -25106,13 +25256,13 @@ function openSession(options) {
|
|
|
25106
25256
|
function proxyRelay(options = {}) {
|
|
25107
25257
|
return openSession(options).relay;
|
|
25108
25258
|
}
|
|
25109
|
-
function
|
|
25259
|
+
function isObject9(value) {
|
|
25110
25260
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25111
25261
|
}
|
|
25112
25262
|
function firstRootDir(answer) {
|
|
25113
|
-
const roots =
|
|
25263
|
+
const roots = isObject9(answer.result) ? answer.result.roots : undefined;
|
|
25114
25264
|
for (const root of Array.isArray(roots) ? roots : []) {
|
|
25115
|
-
if (!
|
|
25265
|
+
if (!isObject9(root) || typeof root.uri !== "string" || !root.uri.startsWith("file:"))
|
|
25116
25266
|
continue;
|
|
25117
25267
|
try {
|
|
25118
25268
|
return fileURLToPath3(root.uri);
|
|
@@ -25146,10 +25296,10 @@ async function serveStdio(session, input, write) {
|
|
|
25146
25296
|
emit({ jsonrpc: "2.0", id: ROOTS_REQUEST_ID, method: "roots/list" });
|
|
25147
25297
|
};
|
|
25148
25298
|
const screen = (message) => {
|
|
25149
|
-
const call =
|
|
25299
|
+
const call = isObject9(message) && message.method === "tools/call" ? message : null;
|
|
25150
25300
|
if (!call)
|
|
25151
25301
|
return { callSession: null, refusal: null };
|
|
25152
|
-
const callSession =
|
|
25302
|
+
const callSession = isObject9(call.params) ? takeCallSession(call.params, session.client) : null;
|
|
25153
25303
|
const text = callRefusal(session.client, callSession ? [callSession] : []);
|
|
25154
25304
|
if (!text)
|
|
25155
25305
|
return { callSession, refusal: null };
|
|
@@ -25174,14 +25324,14 @@ async function serveStdio(session, input, write) {
|
|
|
25174
25324
|
emit(PARSE_ERROR);
|
|
25175
25325
|
return;
|
|
25176
25326
|
}
|
|
25177
|
-
const method =
|
|
25178
|
-
if (takeRoots &&
|
|
25327
|
+
const method = isObject9(message) ? message.method : undefined;
|
|
25328
|
+
if (takeRoots && isObject9(message) && message.id === ROOTS_REQUEST_ID && !method) {
|
|
25179
25329
|
takeRoots(message);
|
|
25180
25330
|
return;
|
|
25181
25331
|
}
|
|
25182
|
-
if (method === "initialize" &&
|
|
25183
|
-
const params =
|
|
25184
|
-
agentOffersRoots =
|
|
25332
|
+
if (method === "initialize" && isObject9(message)) {
|
|
25333
|
+
const params = isObject9(message.params) ? message.params : {};
|
|
25334
|
+
agentOffersRoots = isObject9(params.capabilities) && isObject9(params.capabilities.roots);
|
|
25185
25335
|
}
|
|
25186
25336
|
let outgoing = message;
|
|
25187
25337
|
let named = null;
|
|
@@ -25421,12 +25571,12 @@ var init_org = __esm(() => {
|
|
|
25421
25571
|
});
|
|
25422
25572
|
|
|
25423
25573
|
// src/sessions/project-links.ts
|
|
25424
|
-
import { existsSync as existsSync19, readFileSync as
|
|
25574
|
+
import { existsSync as existsSync19, readFileSync as readFileSync27 } from "node:fs";
|
|
25425
25575
|
function readLinksFile(configDir) {
|
|
25426
25576
|
const path = projectLinksPath(configDir);
|
|
25427
25577
|
if (!existsSync19(path))
|
|
25428
25578
|
return { links: [] };
|
|
25429
|
-
const raw =
|
|
25579
|
+
const raw = readFileSync27(path, "utf-8").trim();
|
|
25430
25580
|
if (!raw)
|
|
25431
25581
|
return { links: [] };
|
|
25432
25582
|
let parsed;
|
|
@@ -25875,7 +26025,7 @@ var init_time_range = __esm(() => {
|
|
|
25875
26025
|
});
|
|
25876
26026
|
|
|
25877
26027
|
// src/commands/review.ts
|
|
25878
|
-
import { readFileSync as
|
|
26028
|
+
import { readFileSync as readFileSync28 } from "node:fs";
|
|
25879
26029
|
function requireConfig10() {
|
|
25880
26030
|
return requireLoginConfig();
|
|
25881
26031
|
}
|
|
@@ -26113,7 +26263,7 @@ function reviewCommand() {
|
|
|
26113
26263
|
let body = opts.body;
|
|
26114
26264
|
if (opts.bodyFile) {
|
|
26115
26265
|
try {
|
|
26116
|
-
body =
|
|
26266
|
+
body = readFileSync28(opts.bodyFile, "utf-8");
|
|
26117
26267
|
} catch (err) {
|
|
26118
26268
|
throw invalidArgument(`Failed to read --body-file: ${err.message}`);
|
|
26119
26269
|
}
|
|
@@ -27057,7 +27207,7 @@ import {
|
|
|
27057
27207
|
existsSync as existsSync20,
|
|
27058
27208
|
lstatSync,
|
|
27059
27209
|
mkdirSync as mkdirSync12,
|
|
27060
|
-
readFileSync as
|
|
27210
|
+
readFileSync as readFileSync29,
|
|
27061
27211
|
rmSync as rmSync4,
|
|
27062
27212
|
symlinkSync,
|
|
27063
27213
|
writeFileSync as writeFileSync13
|
|
@@ -27099,7 +27249,7 @@ function readSkillInstallState() {
|
|
|
27099
27249
|
const path = installStatePath();
|
|
27100
27250
|
if (!existsSync20(path))
|
|
27101
27251
|
return null;
|
|
27102
|
-
const data = JSON.parse(
|
|
27252
|
+
const data = JSON.parse(readFileSync29(path, "utf-8"));
|
|
27103
27253
|
if (typeof data?.version === "string" && Array.isArray(data.agents) && data.agents.every((agent) => typeof agent === "string") && typeof data.installedAt === "number") {
|
|
27104
27254
|
return { version: data.version, agents: data.agents, installedAt: data.installedAt };
|
|
27105
27255
|
}
|
|
@@ -27126,7 +27276,7 @@ function pruneLegacySkillLock() {
|
|
|
27126
27276
|
try {
|
|
27127
27277
|
if (!existsSync20(lockPath))
|
|
27128
27278
|
return [];
|
|
27129
|
-
const lock = JSON.parse(
|
|
27279
|
+
const lock = JSON.parse(readFileSync29(lockPath, "utf-8"));
|
|
27130
27280
|
const skills = lock?.skills;
|
|
27131
27281
|
if (!skills || typeof skills !== "object")
|
|
27132
27282
|
return [];
|
|
@@ -27595,7 +27745,7 @@ import {
|
|
|
27595
27745
|
existsSync as existsSync21,
|
|
27596
27746
|
lstatSync as lstatSync2,
|
|
27597
27747
|
mkdirSync as mkdirSync13,
|
|
27598
|
-
readFileSync as
|
|
27748
|
+
readFileSync as readFileSync30,
|
|
27599
27749
|
renameSync as renameSync5,
|
|
27600
27750
|
unlinkSync as unlinkSync6,
|
|
27601
27751
|
writeFileSync as writeFileSync14
|
|
@@ -27670,7 +27820,7 @@ function readTelemetrySettings() {
|
|
|
27670
27820
|
}
|
|
27671
27821
|
let content;
|
|
27672
27822
|
try {
|
|
27673
|
-
content =
|
|
27823
|
+
content = readFileSync30(path, "utf-8");
|
|
27674
27824
|
} catch {
|
|
27675
27825
|
return { status: "error", settings: disabledTelemetrySettings() };
|
|
27676
27826
|
}
|
|
@@ -28178,7 +28328,7 @@ var init_claude = __esm(() => {
|
|
|
28178
28328
|
});
|
|
28179
28329
|
|
|
28180
28330
|
// src/mcp/providers/codex.ts
|
|
28181
|
-
import { existsSync as existsSync22, readFileSync as
|
|
28331
|
+
import { existsSync as existsSync22, readFileSync as readFileSync31 } from "node:fs";
|
|
28182
28332
|
import { dirname as dirname9, join as join27 } from "node:path";
|
|
28183
28333
|
function codexHome4() {
|
|
28184
28334
|
return process.env.CODEX_HOME || expandHome("~/.codex");
|
|
@@ -28191,7 +28341,7 @@ function getConfigPath2(global) {
|
|
|
28191
28341
|
function readTOML(path) {
|
|
28192
28342
|
if (!existsSync22(path))
|
|
28193
28343
|
return "";
|
|
28194
|
-
return
|
|
28344
|
+
return readFileSync31(path, "utf-8");
|
|
28195
28345
|
}
|
|
28196
28346
|
function writeTOML(path, content) {
|
|
28197
28347
|
writeSecureFile(path, content);
|
|
@@ -28732,7 +28882,7 @@ import {
|
|
|
28732
28882
|
existsSync as existsSync23,
|
|
28733
28883
|
mkdirSync as mkdirSync14,
|
|
28734
28884
|
openSync as openSync8,
|
|
28735
|
-
readFileSync as
|
|
28885
|
+
readFileSync as readFileSync32,
|
|
28736
28886
|
rmSync as rmSync5,
|
|
28737
28887
|
statSync as statSync11,
|
|
28738
28888
|
writeFileSync as writeFileSync15,
|
|
@@ -28751,7 +28901,7 @@ function isValidVersion(value) {
|
|
|
28751
28901
|
}
|
|
28752
28902
|
function readState() {
|
|
28753
28903
|
try {
|
|
28754
|
-
const raw = JSON.parse(
|
|
28904
|
+
const raw = JSON.parse(readFileSync32(statePath(), "utf-8"));
|
|
28755
28905
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
28756
28906
|
return {};
|
|
28757
28907
|
const data = raw;
|
|
@@ -28846,7 +28996,7 @@ function releaseLock() {
|
|
|
28846
28996
|
}
|
|
28847
28997
|
function readLockVersion() {
|
|
28848
28998
|
try {
|
|
28849
|
-
const version =
|
|
28999
|
+
const version = readFileSync32(lockPath2(), "utf-8").trim();
|
|
28850
29000
|
return isValidVersion(version) ? version : undefined;
|
|
28851
29001
|
} catch {
|
|
28852
29002
|
return;
|
|
@@ -28920,7 +29070,7 @@ var init_auto_update = __esm(() => {
|
|
|
28920
29070
|
});
|
|
28921
29071
|
|
|
28922
29072
|
// src/version/mcp-refresh-check.ts
|
|
28923
|
-
import { existsSync as existsSync24, mkdirSync as mkdirSync15, readFileSync as
|
|
29073
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync15, readFileSync as readFileSync33, writeFileSync as writeFileSync16 } from "node:fs";
|
|
28924
29074
|
import { join as join34 } from "node:path";
|
|
28925
29075
|
function getCachePath2() {
|
|
28926
29076
|
return join34(getConfigDir(), CACHE_FILENAME3);
|
|
@@ -28930,7 +29080,7 @@ function readMcpRefreshCache() {
|
|
|
28930
29080
|
const path = getCachePath2();
|
|
28931
29081
|
if (!existsSync24(path))
|
|
28932
29082
|
return null;
|
|
28933
|
-
const data = JSON.parse(
|
|
29083
|
+
const data = JSON.parse(readFileSync33(path, "utf-8"));
|
|
28934
29084
|
if (typeof data?.version === "string")
|
|
28935
29085
|
return { version: data.version };
|
|
28936
29086
|
return null;
|
|
@@ -29084,7 +29234,7 @@ function createLogFollower(path, emit) {
|
|
|
29084
29234
|
var init_follow = () => {};
|
|
29085
29235
|
|
|
29086
29236
|
// src/sessions/session-title.ts
|
|
29087
|
-
import { existsSync as existsSync25, mkdirSync as mkdirSync16, readFileSync as
|
|
29237
|
+
import { existsSync as existsSync25, mkdirSync as mkdirSync16, readFileSync as readFileSync34, renameSync as renameSync6, statSync as statSync13, writeFileSync as writeFileSync17 } from "node:fs";
|
|
29088
29238
|
import { homedir as homedir11 } from "node:os";
|
|
29089
29239
|
import { join as join35 } from "node:path";
|
|
29090
29240
|
function cachePath2(configDir) {
|
|
@@ -29092,7 +29242,7 @@ function cachePath2(configDir) {
|
|
|
29092
29242
|
}
|
|
29093
29243
|
function loadCacheFile2(configDir) {
|
|
29094
29244
|
try {
|
|
29095
|
-
const raw = JSON.parse(
|
|
29245
|
+
const raw = JSON.parse(readFileSync34(cachePath2(configDir), "utf-8"));
|
|
29096
29246
|
if (raw.schema_version !== CACHE_SCHEMA_VERSION2 || typeof raw.entries !== "object")
|
|
29097
29247
|
return {};
|
|
29098
29248
|
return raw.entries;
|
|
@@ -29160,7 +29310,7 @@ function reconstructSession(harness, id, slug, home = homedir11(), exists = exis
|
|
|
29160
29310
|
}
|
|
29161
29311
|
function readHead3(path) {
|
|
29162
29312
|
try {
|
|
29163
|
-
return
|
|
29313
|
+
return readFileSync34(path, "utf-8").slice(0, 128 * 1024);
|
|
29164
29314
|
} catch {
|
|
29165
29315
|
return null;
|
|
29166
29316
|
}
|
|
@@ -29240,7 +29390,7 @@ var init_alt_screen = __esm(() => {
|
|
|
29240
29390
|
});
|
|
29241
29391
|
|
|
29242
29392
|
// src/tui/activity-view.ts
|
|
29243
|
-
import { existsSync as existsSync26, readFileSync as
|
|
29393
|
+
import { existsSync as existsSync26, readFileSync as readFileSync35 } from "node:fs";
|
|
29244
29394
|
import { basename as basename11 } from "node:path";
|
|
29245
29395
|
function reduceActivityViewKey(key) {
|
|
29246
29396
|
if (key === "q" || key === ESC7 || key === CTRL_C4)
|
|
@@ -29564,7 +29714,7 @@ function createRowNamer() {
|
|
|
29564
29714
|
}
|
|
29565
29715
|
function defaultReadLog2() {
|
|
29566
29716
|
try {
|
|
29567
|
-
return
|
|
29717
|
+
return readFileSync35(logger.getLogPath(), "utf-8");
|
|
29568
29718
|
} catch {
|
|
29569
29719
|
return "";
|
|
29570
29720
|
}
|
|
@@ -29784,7 +29934,7 @@ var init_activity_view = __esm(() => {
|
|
|
29784
29934
|
});
|
|
29785
29935
|
|
|
29786
29936
|
// src/rules/installer.ts
|
|
29787
|
-
import { existsSync as existsSync27, mkdirSync as mkdirSync17, readFileSync as
|
|
29937
|
+
import { existsSync as existsSync27, mkdirSync as mkdirSync17, readFileSync as readFileSync36, unlinkSync as unlinkSync7, writeFileSync as writeFileSync18 } from "node:fs";
|
|
29788
29938
|
import { homedir as homedir12 } from "node:os";
|
|
29789
29939
|
import { dirname as dirname10, join as join36 } from "node:path";
|
|
29790
29940
|
function claudeConfigDir4() {
|
|
@@ -29825,7 +29975,7 @@ function writeIfChanged2(path, content) {
|
|
|
29825
29975
|
writeFileSync18(path, content, "utf-8");
|
|
29826
29976
|
return "created";
|
|
29827
29977
|
}
|
|
29828
|
-
if (
|
|
29978
|
+
if (readFileSync36(path, "utf-8") === content)
|
|
29829
29979
|
return "unchanged";
|
|
29830
29980
|
writeFileSync18(path, content, "utf-8");
|
|
29831
29981
|
return "updated";
|
|
@@ -29860,7 +30010,7 @@ function upsertSection(path, content) {
|
|
|
29860
30010
|
`, "utf-8");
|
|
29861
30011
|
return "created";
|
|
29862
30012
|
}
|
|
29863
|
-
const existing =
|
|
30013
|
+
const existing = readFileSync36(path, "utf-8");
|
|
29864
30014
|
const lineEnding = lineEndingFor(existing);
|
|
29865
30015
|
const section = buildSection(content, lineEnding);
|
|
29866
30016
|
const location = findSection(existing);
|
|
@@ -29896,7 +30046,7 @@ function removeRuleForAgent(agent) {
|
|
|
29896
30046
|
unlinkSync7(path);
|
|
29897
30047
|
return { agent, path, action: "removed" };
|
|
29898
30048
|
}
|
|
29899
|
-
const existing =
|
|
30049
|
+
const existing = readFileSync36(path, "utf-8");
|
|
29900
30050
|
const lineEnding = lineEndingFor(existing);
|
|
29901
30051
|
const location = findSection(existing);
|
|
29902
30052
|
if (!location)
|
|
@@ -29957,7 +30107,7 @@ var init_installer = __esm(() => {
|
|
|
29957
30107
|
|
|
29958
30108
|
// src/setup/agents-md-step.ts
|
|
29959
30109
|
import { execSync as execSync2 } from "node:child_process";
|
|
29960
|
-
import { existsSync as existsSync28, readFileSync as
|
|
30110
|
+
import { existsSync as existsSync28, readFileSync as readFileSync37, writeFileSync as writeFileSync19 } from "node:fs";
|
|
29961
30111
|
import { join as join37 } from "node:path";
|
|
29962
30112
|
function inGitWorkTree(cwd = process.cwd()) {
|
|
29963
30113
|
try {
|
|
@@ -29975,7 +30125,7 @@ function dosuAgentsSectionState(cwd = process.cwd()) {
|
|
|
29975
30125
|
const path = join37(cwd, "AGENTS.md");
|
|
29976
30126
|
if (!existsSync28(path))
|
|
29977
30127
|
return "missing";
|
|
29978
|
-
const content =
|
|
30128
|
+
const content = readFileSync37(path, "utf-8");
|
|
29979
30129
|
const startMatch = content.match(SECTION_START_RE);
|
|
29980
30130
|
if (!startMatch || !content.includes(DOSU_SECTION_END))
|
|
29981
30131
|
return "missing";
|
|
@@ -30017,7 +30167,7 @@ function upsertDosuAgentsSection(cwd = process.cwd(), content = FALLBACK_DOSU_RU
|
|
|
30017
30167
|
`);
|
|
30018
30168
|
return { path, action: "created" };
|
|
30019
30169
|
}
|
|
30020
|
-
const existing =
|
|
30170
|
+
const existing = readFileSync37(path, "utf-8");
|
|
30021
30171
|
const lineEnding = lineEndingFor2(existing);
|
|
30022
30172
|
const section = renderDosuAgentsSection(content, lineEnding);
|
|
30023
30173
|
const location = findSection2(existing);
|
|
@@ -32117,7 +32267,7 @@ var init_incognito_backfill_check = __esm(() => {
|
|
|
32117
32267
|
});
|
|
32118
32268
|
|
|
32119
32269
|
// src/version/update-check.ts
|
|
32120
|
-
import { existsSync as existsSync30, mkdirSync as mkdirSync19, readFileSync as
|
|
32270
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync19, readFileSync as readFileSync38, writeFileSync as writeFileSync21 } from "node:fs";
|
|
32121
32271
|
import { join as join39 } from "node:path";
|
|
32122
32272
|
function isValidVersion2(value) {
|
|
32123
32273
|
return typeof value === "string" && SEMVER_PATTERN.test(value);
|
|
@@ -32178,7 +32328,7 @@ function readCache() {
|
|
|
32178
32328
|
const path = getCachePath3();
|
|
32179
32329
|
if (!existsSync30(path))
|
|
32180
32330
|
return null;
|
|
32181
|
-
const data = JSON.parse(
|
|
32331
|
+
const data = JSON.parse(readFileSync38(path, "utf-8"));
|
|
32182
32332
|
if (typeof data.lastCheck === "number" && isValidVersion2(data.latestVersion)) {
|
|
32183
32333
|
return data;
|
|
32184
32334
|
}
|
|
@@ -34049,7 +34199,7 @@ var init_flow3 = __esm(() => {
|
|
|
34049
34199
|
});
|
|
34050
34200
|
|
|
34051
34201
|
// src/cli/cli.ts
|
|
34052
|
-
import { readFileSync as
|
|
34202
|
+
import { readFileSync as readFileSync39, unlinkSync as unlinkSync8 } from "node:fs";
|
|
34053
34203
|
function shouldRunBackgroundChecks(command) {
|
|
34054
34204
|
return !NO_BACKGROUND_CHECKS.has(command);
|
|
34055
34205
|
}
|
|
@@ -34503,7 +34653,7 @@ Use 'dosu mcp add <agent>' to add Dosu MCP to a tool.`);
|
|
|
34503
34653
|
}
|
|
34504
34654
|
if (opts.follow) {
|
|
34505
34655
|
try {
|
|
34506
|
-
const lines =
|
|
34656
|
+
const lines = readFileSync39(logPath, "utf-8").split(`
|
|
34507
34657
|
`);
|
|
34508
34658
|
if (lines.at(-1) === "")
|
|
34509
34659
|
lines.pop();
|
|
@@ -34519,7 +34669,7 @@ Use 'dosu mcp add <agent>' to add Dosu MCP to a tool.`);
|
|
|
34519
34669
|
if (opts.tail !== undefined) {
|
|
34520
34670
|
const n = typeof opts.tail === "string" ? parseInt(opts.tail, 10) || 50 : 50;
|
|
34521
34671
|
try {
|
|
34522
|
-
const content =
|
|
34672
|
+
const content = readFileSync39(logPath, "utf-8");
|
|
34523
34673
|
const lines = content.split(`
|
|
34524
34674
|
`);
|
|
34525
34675
|
console.log(lines.slice(-n).join(`
|
|
@@ -34705,4 +34855,4 @@ main().catch((err) => {
|
|
|
34705
34855
|
process.exit(1);
|
|
34706
34856
|
});
|
|
34707
34857
|
|
|
34708
|
-
//# debugId=
|
|
34858
|
+
//# debugId=b1ea3994-833d-5f18-6475-6e2164756e21
|