@adhdev/daemon-core 0.9.82-rc.188 → 0.9.82-rc.189
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 +58 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -5
- package/dist/index.mjs.map +1 -1
- package/dist/providers/spec/adapter.d.ts +4 -0
- package/dist/providers/spec/driver.d.ts +4 -0
- package/dist/providers/spec/evaluator.d.ts +9 -1
- package/dist/providers/spec/schema.gen.d.ts +16 -0
- package/dist/providers/spec/types.d.ts +15 -0
- package/package.json +1 -1
- package/src/mesh/mesh-events.ts +7 -0
- package/src/providers/spec/adapter.ts +8 -0
- package/src/providers/spec/driver.ts +6 -1
- package/src/providers/spec/evaluator.ts +39 -3
- package/src/providers/spec/schema.gen.ts +16 -0
- package/src/providers/spec/schema.json +5 -1
- package/src/providers/spec/types.ts +15 -0
package/dist/index.mjs
CHANGED
|
@@ -5604,6 +5604,8 @@ function handleMeshForwardEvent(components, payload) {
|
|
|
5604
5604
|
const nodeId = readNonEmptyString2(payload.nodeId);
|
|
5605
5605
|
const workspace = readNonEmptyString2(payload.workspace);
|
|
5606
5606
|
const nodeLabel = nodeId ? `Node '${nodeId}'` : workspace ? `Agent at ${workspace}` : "Remote agent";
|
|
5607
|
+
const relayModalMessage = readNonEmptyString2(payload.modalMessage);
|
|
5608
|
+
const relayModalButtons = Array.isArray(payload.modalButtons) ? payload.modalButtons.filter((b) => typeof b === "string" && b.trim().length > 0) : null;
|
|
5607
5609
|
return injectMeshSystemMessage(components, {
|
|
5608
5610
|
meshId,
|
|
5609
5611
|
nodeId,
|
|
@@ -5621,6 +5623,8 @@ function handleMeshForwardEvent(components, payload) {
|
|
|
5621
5623
|
startedAt: readNonEmptyString2(payload.startedAt),
|
|
5622
5624
|
completedAt: readNonEmptyString2(payload.completedAt),
|
|
5623
5625
|
retryOfJobId: readNonEmptyString2(payload.retryOfJobId),
|
|
5626
|
+
...relayModalMessage ? { modalMessage: relayModalMessage } : {},
|
|
5627
|
+
...relayModalButtons && relayModalButtons.length > 0 ? { modalButtons: relayModalButtons } : {},
|
|
5624
5628
|
...payload.result && typeof payload.result === "object" && !Array.isArray(payload.result) ? { result: payload.result } : {},
|
|
5625
5629
|
...payload.completionDiagnostic && typeof payload.completionDiagnostic === "object" && !Array.isArray(payload.completionDiagnostic) ? { completionDiagnostic: payload.completionDiagnostic } : {},
|
|
5626
5630
|
...payload.workerResult && typeof payload.workerResult === "object" && !Array.isArray(payload.workerResult) ? { workerResult: payload.workerResult } : {},
|
|
@@ -25650,6 +25654,13 @@ var TerminalAdapter = class {
|
|
|
25650
25654
|
snapshot() {
|
|
25651
25655
|
return this.lastScreen || this.computeScreen();
|
|
25652
25656
|
}
|
|
25657
|
+
getCursorPosition() {
|
|
25658
|
+
const buf = this.term.buffer.active;
|
|
25659
|
+
return {
|
|
25660
|
+
row: Math.max(0, buf.cursorY ?? 0),
|
|
25661
|
+
col: Math.max(0, buf.cursorX ?? 0)
|
|
25662
|
+
};
|
|
25663
|
+
}
|
|
25653
25664
|
kill() {
|
|
25654
25665
|
this.stopTimers();
|
|
25655
25666
|
try {
|
|
@@ -25754,14 +25765,33 @@ function compileLinePattern(ref) {
|
|
|
25754
25765
|
const flags = (ref.flags ?? "m").replace(/g/g, "");
|
|
25755
25766
|
return new RegExp(ref.pattern, flags);
|
|
25756
25767
|
}
|
|
25757
|
-
function matchState(state, sections, fullScreen, trace) {
|
|
25768
|
+
function matchState(state, sections, fullScreen, trace, cursor) {
|
|
25758
25769
|
const haystack = sectionText(sections, state.when.section, fullScreen);
|
|
25759
25770
|
const re = compileRegex(state.when);
|
|
25760
25771
|
if (!re.test(haystack)) {
|
|
25761
25772
|
trace.push({ kind: "state_skip", text: `state[${state.id}] when ${state.when.section ?? "*"}~/${state.when.regex}/ no match` });
|
|
25762
25773
|
return { matched: false, title: null };
|
|
25763
25774
|
}
|
|
25764
|
-
|
|
25775
|
+
if (cursor !== void 0) {
|
|
25776
|
+
const w = state.when;
|
|
25777
|
+
if (w.cursor_row_min !== void 0 && cursor.row < w.cursor_row_min) {
|
|
25778
|
+
trace.push({ kind: "state_skip", text: `state[${state.id}] cursor row ${cursor.row} < cursor_row_min ${w.cursor_row_min}` });
|
|
25779
|
+
return { matched: false, title: null };
|
|
25780
|
+
}
|
|
25781
|
+
if (w.cursor_row_max !== void 0 && cursor.row > w.cursor_row_max) {
|
|
25782
|
+
trace.push({ kind: "state_skip", text: `state[${state.id}] cursor row ${cursor.row} > cursor_row_max ${w.cursor_row_max}` });
|
|
25783
|
+
return { matched: false, title: null };
|
|
25784
|
+
}
|
|
25785
|
+
if (w.cursor_col_min !== void 0 && cursor.col < w.cursor_col_min) {
|
|
25786
|
+
trace.push({ kind: "state_skip", text: `state[${state.id}] cursor col ${cursor.col} < cursor_col_min ${w.cursor_col_min}` });
|
|
25787
|
+
return { matched: false, title: null };
|
|
25788
|
+
}
|
|
25789
|
+
if (w.cursor_col_max !== void 0 && cursor.col > w.cursor_col_max) {
|
|
25790
|
+
trace.push({ kind: "state_skip", text: `state[${state.id}] cursor col ${cursor.col} > cursor_col_max ${w.cursor_col_max}` });
|
|
25791
|
+
return { matched: false, title: null };
|
|
25792
|
+
}
|
|
25793
|
+
}
|
|
25794
|
+
trace.push({ kind: "state_match", text: `state[${state.id}] matched via ${state.when.section ?? "*"}~/${state.when.regex}/${cursor !== void 0 ? ` cursor=(${cursor.row},${cursor.col})` : ""}` });
|
|
25765
25795
|
let title = null;
|
|
25766
25796
|
if (state.extract_title) {
|
|
25767
25797
|
const titleHay = sectionText(sections, state.extract_title.section, fullScreen);
|
|
@@ -25819,17 +25849,20 @@ function extractModal(state, sections, fullScreen, title, trace) {
|
|
|
25819
25849
|
trace.push({ kind: "modal", text: `modal_buttons matched ${buttons.length} choices` });
|
|
25820
25850
|
return { title, buttons };
|
|
25821
25851
|
}
|
|
25822
|
-
function evaluate(spec, screenText) {
|
|
25852
|
+
function evaluate(spec, screenText, cursor) {
|
|
25823
25853
|
const trace = [];
|
|
25824
25854
|
const lines = screenText.split("\n");
|
|
25825
25855
|
const sections = resolveSections(spec, lines);
|
|
25826
25856
|
for (const s of sections) {
|
|
25827
25857
|
trace.push({ kind: "section", text: `section[${s.id}] lines [${s.fromLine}, ${s.toLine}) (${s.toLine - s.fromLine} lines)` });
|
|
25828
25858
|
}
|
|
25859
|
+
if (cursor !== void 0) {
|
|
25860
|
+
trace.push({ kind: "section", text: `cursor (${cursor.row}, ${cursor.col})` });
|
|
25861
|
+
}
|
|
25829
25862
|
let activeState = null;
|
|
25830
25863
|
let modal = null;
|
|
25831
25864
|
for (const st of spec.states) {
|
|
25832
|
-
const { matched, title } = matchState(st, sections, screenText, trace);
|
|
25865
|
+
const { matched, title } = matchState(st, sections, screenText, trace, cursor);
|
|
25833
25866
|
if (!matched) continue;
|
|
25834
25867
|
const extractedModal = extractModal(st, sections, screenText, title, trace);
|
|
25835
25868
|
if (st.modal_buttons && !extractedModal) {
|
|
@@ -26097,6 +26130,22 @@ var SCHEMA = {
|
|
|
26097
26130
|
"flags": {
|
|
26098
26131
|
"type": "string",
|
|
26099
26132
|
"default": "i"
|
|
26133
|
+
},
|
|
26134
|
+
"cursor_row_min": {
|
|
26135
|
+
"type": "integer",
|
|
26136
|
+
"minimum": 0
|
|
26137
|
+
},
|
|
26138
|
+
"cursor_row_max": {
|
|
26139
|
+
"type": "integer",
|
|
26140
|
+
"minimum": 0
|
|
26141
|
+
},
|
|
26142
|
+
"cursor_col_min": {
|
|
26143
|
+
"type": "integer",
|
|
26144
|
+
"minimum": 0
|
|
26145
|
+
},
|
|
26146
|
+
"cursor_col_max": {
|
|
26147
|
+
"type": "integer",
|
|
26148
|
+
"minimum": 0
|
|
26100
26149
|
}
|
|
26101
26150
|
}
|
|
26102
26151
|
},
|
|
@@ -26626,6 +26675,9 @@ var SpecDriver = class {
|
|
|
26626
26675
|
snapshot() {
|
|
26627
26676
|
return this.adapter.snapshot();
|
|
26628
26677
|
}
|
|
26678
|
+
getCursorPosition() {
|
|
26679
|
+
return this.adapter.getCursorPosition();
|
|
26680
|
+
}
|
|
26629
26681
|
shutdown() {
|
|
26630
26682
|
for (const t of this.delegateTimers.values()) clearTimeout(t);
|
|
26631
26683
|
this.delegateTimers.clear();
|
|
@@ -26690,7 +26742,8 @@ var SpecDriver = class {
|
|
|
26690
26742
|
}
|
|
26691
26743
|
reevaluate(forceEmit = false) {
|
|
26692
26744
|
const screen = this.adapter.snapshot();
|
|
26693
|
-
const
|
|
26745
|
+
const cursor = this.adapter.getCursorPosition();
|
|
26746
|
+
const ev = evaluate(this.spec, screen, cursor);
|
|
26694
26747
|
let evState = ev.state;
|
|
26695
26748
|
const busyHoldMs = this.spec.debounce?.busy_hold_ms ?? BUSY_HOLD_MS;
|
|
26696
26749
|
if (this.currentStateId === "busy" && evState.id === "idle") {
|