@adhdev/daemon-core 0.9.82-rc.213 → 0.9.82-rc.214
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/index.js +138 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +138 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/cli-state-engine.ts +25 -1
- package/src/commands/router.ts +84 -0
- package/src/providers/native-history/codex-cli-transcript.ts +62 -2
package/dist/index.js
CHANGED
|
@@ -10401,7 +10401,25 @@ var init_cli_state_engine = __esm({
|
|
|
10401
10401
|
"CLI",
|
|
10402
10402
|
`[${this.provider.type}] settled diagnostics prompt=${JSON.stringify(this.currentTurnScope?.prompt || "").slice(0, 140)} status=${String(status || "")} parsedStatus=${String(parsedStatus || "")} parsedMsgCount=${parsedMessages.length} lastParsedAssistant=${JSON.stringify((lastParsedAssistant?.content || "").slice(0, 120)).slice(0, 160)} responseBuffer=${JSON.stringify((snap.responseBuffer || "").slice(0, 160)).slice(0, 220)} recentActivity=${recentInteractiveActivity}`
|
|
10403
10403
|
);
|
|
10404
|
-
const
|
|
10404
|
+
const hasFinalCurrentTurnAssistant = (() => {
|
|
10405
|
+
if (parsedStatus !== "idle") return false;
|
|
10406
|
+
const msgs = Array.isArray(parsedMessages) ? parsedMessages : [];
|
|
10407
|
+
let lastUserIdx = -1;
|
|
10408
|
+
for (let i = msgs.length - 1; i >= 0; i--) {
|
|
10409
|
+
if (msgs[i]?.role === "user") {
|
|
10410
|
+
lastUserIdx = i;
|
|
10411
|
+
break;
|
|
10412
|
+
}
|
|
10413
|
+
}
|
|
10414
|
+
const searchSlice = lastUserIdx >= 0 ? msgs.slice(lastUserIdx + 1) : msgs;
|
|
10415
|
+
return searchSlice.some((m) => {
|
|
10416
|
+
if (!m || m.role !== "assistant") return false;
|
|
10417
|
+
if (typeof m.content !== "string" || !m.content.trim()) return false;
|
|
10418
|
+
const kind = typeof m.kind === "string" && m.kind.trim() ? m.kind.trim() : "standard";
|
|
10419
|
+
return kind === "standard" && m.meta?.streaming !== true;
|
|
10420
|
+
});
|
|
10421
|
+
})();
|
|
10422
|
+
const shouldHoldGenerating = status === "idle" && this.isWaitingForResponse && !!this.currentTurnScope && !modal && !hasFinalCurrentTurnAssistant;
|
|
10405
10423
|
if (shouldHoldGenerating) {
|
|
10406
10424
|
this.applyHoldGenerating(ctx);
|
|
10407
10425
|
return;
|
|
@@ -35792,6 +35810,35 @@ function extractToolOutputContent(payload) {
|
|
|
35792
35810
|
}
|
|
35793
35811
|
return "";
|
|
35794
35812
|
}
|
|
35813
|
+
function hasAssistantStandardMessageSinceLastUser(records, content) {
|
|
35814
|
+
const normalized = content.trim();
|
|
35815
|
+
if (!normalized) return false;
|
|
35816
|
+
for (let i = records.length - 1; i >= 0; i--) {
|
|
35817
|
+
const record = records[i];
|
|
35818
|
+
if (record.kind === "session_start") continue;
|
|
35819
|
+
if (record.role === "user") return false;
|
|
35820
|
+
if (record.role === "assistant" && record.kind === "standard" && record.content.trim() === normalized) {
|
|
35821
|
+
return true;
|
|
35822
|
+
}
|
|
35823
|
+
}
|
|
35824
|
+
return false;
|
|
35825
|
+
}
|
|
35826
|
+
function pushAssistantStandardMessage(records, sessionId, receivedAt, content, workspace) {
|
|
35827
|
+
const text = content.trim();
|
|
35828
|
+
if (!text) return;
|
|
35829
|
+
if (hasAssistantStandardMessageSinceLastUser(records, text)) return;
|
|
35830
|
+
const msg = {
|
|
35831
|
+
ts: new Date(receivedAt).toISOString(),
|
|
35832
|
+
receivedAt,
|
|
35833
|
+
role: "assistant",
|
|
35834
|
+
content: text,
|
|
35835
|
+
kind: "standard",
|
|
35836
|
+
agent: "codex-cli",
|
|
35837
|
+
historySessionId: sessionId
|
|
35838
|
+
};
|
|
35839
|
+
if (workspace) msg.workspace = workspace;
|
|
35840
|
+
records.push(msg);
|
|
35841
|
+
}
|
|
35795
35842
|
function readSessionMeta(filePath) {
|
|
35796
35843
|
try {
|
|
35797
35844
|
const firstLine = fs15.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
|
|
@@ -35847,13 +35894,34 @@ function parseSessionFile(filePath, sessionId, workspaceFallback) {
|
|
|
35847
35894
|
}
|
|
35848
35895
|
continue;
|
|
35849
35896
|
}
|
|
35850
|
-
if (type !== "response_item") continue;
|
|
35851
35897
|
const payloadType = String(payload.type ?? "").trim();
|
|
35898
|
+
if (type === "event_msg") {
|
|
35899
|
+
if (payloadType === "task_complete") {
|
|
35900
|
+
pushAssistantStandardMessage(
|
|
35901
|
+
records,
|
|
35902
|
+
sessionId,
|
|
35903
|
+
receivedAt,
|
|
35904
|
+
flattenCodexContent(payload.last_agent_message),
|
|
35905
|
+
detectedWorkspace
|
|
35906
|
+
);
|
|
35907
|
+
} else if (payloadType === "agent_message" && String(payload.phase ?? "").trim() === "final_answer") {
|
|
35908
|
+
pushAssistantStandardMessage(
|
|
35909
|
+
records,
|
|
35910
|
+
sessionId,
|
|
35911
|
+
receivedAt,
|
|
35912
|
+
flattenCodexContent(payload.message),
|
|
35913
|
+
detectedWorkspace
|
|
35914
|
+
);
|
|
35915
|
+
}
|
|
35916
|
+
continue;
|
|
35917
|
+
}
|
|
35918
|
+
if (type !== "response_item") continue;
|
|
35852
35919
|
if (payloadType === "message") {
|
|
35853
35920
|
const role = String(payload.role ?? "").trim();
|
|
35854
35921
|
if (role !== "user" && role !== "assistant") continue;
|
|
35855
35922
|
const content = flattenCodexContent(payload.content);
|
|
35856
35923
|
if (!content) continue;
|
|
35924
|
+
if (role === "assistant" && hasAssistantStandardMessageSinceLastUser(records, content)) continue;
|
|
35857
35925
|
const msg = {
|
|
35858
35926
|
ts: new Date(receivedAt).toISOString(),
|
|
35859
35927
|
receivedAt,
|
|
@@ -39786,6 +39854,7 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
|
39786
39854
|
|
|
39787
39855
|
// src/commands/router.ts
|
|
39788
39856
|
init_mesh_work_queue();
|
|
39857
|
+
init_repo_mesh_types();
|
|
39789
39858
|
var import_os3 = require("os");
|
|
39790
39859
|
var import_path10 = require("path");
|
|
39791
39860
|
var fs22 = __toESM(require("fs"));
|
|
@@ -42345,7 +42414,8 @@ var DaemonCommandRouter = class {
|
|
|
42345
42414
|
...result ? {
|
|
42346
42415
|
success: result.success === true,
|
|
42347
42416
|
result,
|
|
42348
|
-
finalBranchConvergenceState: result.finalBranchConvergenceState
|
|
42417
|
+
finalBranchConvergenceState: result.finalBranchConvergenceState,
|
|
42418
|
+
...result.blockerContext ? { blockerContext: result.blockerContext } : {}
|
|
42349
42419
|
} : {}
|
|
42350
42420
|
}
|
|
42351
42421
|
});
|
|
@@ -42875,6 +42945,27 @@ var DaemonCommandRouter = class {
|
|
|
42875
42945
|
finalBranchConvergenceState
|
|
42876
42946
|
};
|
|
42877
42947
|
}
|
|
42948
|
+
const requireApprovalForPush = mesh?.policy?.requireApprovalForPush ?? DEFAULT_MESH_POLICY.requireApprovalForPush;
|
|
42949
|
+
let pushResult;
|
|
42950
|
+
if (!requireApprovalForPush) {
|
|
42951
|
+
const pushStarted = Date.now();
|
|
42952
|
+
try {
|
|
42953
|
+
await execFileAsync3("git", ["push", "origin", baseBranch], { cwd: repoRoot, encoding: "utf8" });
|
|
42954
|
+
pushResult = { pushed: true, remote: "origin", branch: baseBranch, durationMs: Date.now() - pushStarted };
|
|
42955
|
+
recordMeshRefineStage(refineStages, "push", "passed", pushStarted, pushResult);
|
|
42956
|
+
finalBranchConvergenceState.status = "merged_pushed";
|
|
42957
|
+
} catch (e) {
|
|
42958
|
+
pushResult = {
|
|
42959
|
+
pushed: false,
|
|
42960
|
+
remote: "origin",
|
|
42961
|
+
branch: baseBranch,
|
|
42962
|
+
error: e?.message || String(e),
|
|
42963
|
+
stderr: e?.stderr,
|
|
42964
|
+
durationMs: Date.now() - pushStarted
|
|
42965
|
+
};
|
|
42966
|
+
recordMeshRefineStage(refineStages, "push", "failed", pushStarted, pushResult);
|
|
42967
|
+
}
|
|
42968
|
+
}
|
|
42878
42969
|
return {
|
|
42879
42970
|
success: true,
|
|
42880
42971
|
merged: true,
|
|
@@ -42888,7 +42979,13 @@ var DaemonCommandRouter = class {
|
|
|
42888
42979
|
mergeResult,
|
|
42889
42980
|
refineStages,
|
|
42890
42981
|
...ledgerError ? { ledgerError } : {},
|
|
42891
|
-
finalBranchConvergenceState
|
|
42982
|
+
finalBranchConvergenceState,
|
|
42983
|
+
// Push outcome or readiness info for coordinator.
|
|
42984
|
+
...pushResult ? { pushResult } : {
|
|
42985
|
+
pushReady: true,
|
|
42986
|
+
pushCommand: `git push origin ${baseBranch}`,
|
|
42987
|
+
pushNote: "requireApprovalForPush is enabled \u2014 run the push command or obtain user approval before pushing."
|
|
42988
|
+
}
|
|
42892
42989
|
};
|
|
42893
42990
|
} catch (e) {
|
|
42894
42991
|
return { success: false, error: e.message, refineStages };
|
|
@@ -42906,9 +43003,46 @@ var DaemonCommandRouter = class {
|
|
|
42906
43003
|
const refineCode = typeof result.code === "string" ? result.code : "";
|
|
42907
43004
|
const refineTerminalKind = result.success === true ? "completed" : refineCode === "blocked_review" ? "blocked_review" : refineCode === "validation_failed" || refineCode === "validation_dependencies_missing" ? "validation_failed" : refineCode === "submodule_reachability_failed" ? "submodule_reachability_failed" : refineCode === "merge_failed" || refineCode === "patch_equivalence_failed" || refineCode === "needs_rebase" || refineCode === "needs_rebase_with_conflicts" ? "merge_failed" : refineCode === "cleanup_failed" ? "cleanup_failed" : "merge_failed";
|
|
42908
43005
|
const isTerminalSuccess = refineTerminalKind === "completed";
|
|
43006
|
+
const blockerContext = isTerminalSuccess ? void 0 : (() => {
|
|
43007
|
+
const code = typeof result.code === "string" ? result.code : refineTerminalKind;
|
|
43008
|
+
const stage = refineTerminalKind === "validation_failed" ? "validation" : refineTerminalKind === "submodule_reachability_failed" ? "submodule_reachability" : refineCode === "patch_equivalence_failed" ? "patch_equivalence" : refineCode === "needs_rebase" || refineCode === "needs_rebase_with_conflicts" ? "patch_equivalence" : refineTerminalKind === "merge_failed" ? "merge" : refineTerminalKind === "cleanup_failed" ? "cleanup" : "unknown";
|
|
43009
|
+
const ctx = {
|
|
43010
|
+
stage,
|
|
43011
|
+
reason: code,
|
|
43012
|
+
terminalKind: refineTerminalKind
|
|
43013
|
+
};
|
|
43014
|
+
if (typeof result.error === "string") ctx.error = result.error;
|
|
43015
|
+
if (typeof result.blockedReason === "string") ctx.blockedReason = result.blockedReason;
|
|
43016
|
+
if (stage === "patch_equivalence" && result.patchEquivalence) {
|
|
43017
|
+
const pe = result.patchEquivalence;
|
|
43018
|
+
ctx.details = {
|
|
43019
|
+
expectedPatchId: pe.expectedPatchId,
|
|
43020
|
+
actualPatchId: pe.actualPatchId,
|
|
43021
|
+
status: pe.status,
|
|
43022
|
+
actionableHint: pe.actionableHint,
|
|
43023
|
+
error: pe.error
|
|
43024
|
+
};
|
|
43025
|
+
}
|
|
43026
|
+
if (stage === "submodule_reachability" && Array.isArray(result.unreachableSubmoduleCommits)) {
|
|
43027
|
+
ctx.details = {
|
|
43028
|
+
unreachableCount: result.unreachableSubmoduleCommits.length,
|
|
43029
|
+
paths: result.unreachableSubmoduleCommits.map((e) => e.path),
|
|
43030
|
+
autoPublishAllowed: result.unreachableSubmoduleCommits[0]?.autoPublishAllowed
|
|
43031
|
+
};
|
|
43032
|
+
}
|
|
43033
|
+
if (stage === "validation" && result.validationSummary) {
|
|
43034
|
+
const vs = result.validationSummary;
|
|
43035
|
+
ctx.details = {
|
|
43036
|
+
failureCode: vs.failureCode,
|
|
43037
|
+
commandsRun: Array.isArray(vs.commandsRun) ? vs.commandsRun.length : void 0
|
|
43038
|
+
};
|
|
43039
|
+
}
|
|
43040
|
+
return ctx;
|
|
43041
|
+
})();
|
|
42909
43042
|
const normalizedResult = {
|
|
42910
43043
|
...result,
|
|
42911
43044
|
terminalKind: refineTerminalKind,
|
|
43045
|
+
...blockerContext ? { blockerContext } : {},
|
|
42912
43046
|
...result.nextStep === void 0 && !isTerminalSuccess ? {
|
|
42913
43047
|
nextStep: refineTerminalKind === "blocked_review" ? "Request user review/approval before attempting to merge again." : refineTerminalKind === "validation_failed" ? "Fix failing tests or configure validation.bootstrapCommands and retry mesh_refine_node." : refineTerminalKind === "submodule_reachability_failed" ? "Push unreachable submodule commits to origin/main, then retry mesh_refine_node." : refineTerminalKind === "merge_failed" ? "Resolve merge conflicts or patch equivalence issues, then retry mesh_refine_node." : refineTerminalKind === "cleanup_failed" ? "Manually remove the worktree and retry or use mesh_remove_node." : "Inspect refineStages for the failing stage and retry."
|
|
42914
43048
|
} : {}
|