@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.js
CHANGED
|
@@ -5609,6 +5609,8 @@ function handleMeshForwardEvent(components, payload) {
|
|
|
5609
5609
|
const nodeId = readNonEmptyString2(payload.nodeId);
|
|
5610
5610
|
const workspace = readNonEmptyString2(payload.workspace);
|
|
5611
5611
|
const nodeLabel = nodeId ? `Node '${nodeId}'` : workspace ? `Agent at ${workspace}` : "Remote agent";
|
|
5612
|
+
const relayModalMessage = readNonEmptyString2(payload.modalMessage);
|
|
5613
|
+
const relayModalButtons = Array.isArray(payload.modalButtons) ? payload.modalButtons.filter((b) => typeof b === "string" && b.trim().length > 0) : null;
|
|
5612
5614
|
return injectMeshSystemMessage(components, {
|
|
5613
5615
|
meshId,
|
|
5614
5616
|
nodeId,
|
|
@@ -5626,6 +5628,8 @@ function handleMeshForwardEvent(components, payload) {
|
|
|
5626
5628
|
startedAt: readNonEmptyString2(payload.startedAt),
|
|
5627
5629
|
completedAt: readNonEmptyString2(payload.completedAt),
|
|
5628
5630
|
retryOfJobId: readNonEmptyString2(payload.retryOfJobId),
|
|
5631
|
+
...relayModalMessage ? { modalMessage: relayModalMessage } : {},
|
|
5632
|
+
...relayModalButtons && relayModalButtons.length > 0 ? { modalButtons: relayModalButtons } : {},
|
|
5629
5633
|
...payload.result && typeof payload.result === "object" && !Array.isArray(payload.result) ? { result: payload.result } : {},
|
|
5630
5634
|
...payload.completionDiagnostic && typeof payload.completionDiagnostic === "object" && !Array.isArray(payload.completionDiagnostic) ? { completionDiagnostic: payload.completionDiagnostic } : {},
|
|
5631
5635
|
...payload.workerResult && typeof payload.workerResult === "object" && !Array.isArray(payload.workerResult) ? { workerResult: payload.workerResult } : {},
|
|
@@ -25960,6 +25964,13 @@ var TerminalAdapter = class {
|
|
|
25960
25964
|
snapshot() {
|
|
25961
25965
|
return this.lastScreen || this.computeScreen();
|
|
25962
25966
|
}
|
|
25967
|
+
getCursorPosition() {
|
|
25968
|
+
const buf = this.term.buffer.active;
|
|
25969
|
+
return {
|
|
25970
|
+
row: Math.max(0, buf.cursorY ?? 0),
|
|
25971
|
+
col: Math.max(0, buf.cursorX ?? 0)
|
|
25972
|
+
};
|
|
25973
|
+
}
|
|
25963
25974
|
kill() {
|
|
25964
25975
|
this.stopTimers();
|
|
25965
25976
|
try {
|
|
@@ -26064,14 +26075,33 @@ function compileLinePattern(ref) {
|
|
|
26064
26075
|
const flags = (ref.flags ?? "m").replace(/g/g, "");
|
|
26065
26076
|
return new RegExp(ref.pattern, flags);
|
|
26066
26077
|
}
|
|
26067
|
-
function matchState(state, sections, fullScreen, trace) {
|
|
26078
|
+
function matchState(state, sections, fullScreen, trace, cursor) {
|
|
26068
26079
|
const haystack = sectionText(sections, state.when.section, fullScreen);
|
|
26069
26080
|
const re = compileRegex(state.when);
|
|
26070
26081
|
if (!re.test(haystack)) {
|
|
26071
26082
|
trace.push({ kind: "state_skip", text: `state[${state.id}] when ${state.when.section ?? "*"}~/${state.when.regex}/ no match` });
|
|
26072
26083
|
return { matched: false, title: null };
|
|
26073
26084
|
}
|
|
26074
|
-
|
|
26085
|
+
if (cursor !== void 0) {
|
|
26086
|
+
const w = state.when;
|
|
26087
|
+
if (w.cursor_row_min !== void 0 && cursor.row < w.cursor_row_min) {
|
|
26088
|
+
trace.push({ kind: "state_skip", text: `state[${state.id}] cursor row ${cursor.row} < cursor_row_min ${w.cursor_row_min}` });
|
|
26089
|
+
return { matched: false, title: null };
|
|
26090
|
+
}
|
|
26091
|
+
if (w.cursor_row_max !== void 0 && cursor.row > w.cursor_row_max) {
|
|
26092
|
+
trace.push({ kind: "state_skip", text: `state[${state.id}] cursor row ${cursor.row} > cursor_row_max ${w.cursor_row_max}` });
|
|
26093
|
+
return { matched: false, title: null };
|
|
26094
|
+
}
|
|
26095
|
+
if (w.cursor_col_min !== void 0 && cursor.col < w.cursor_col_min) {
|
|
26096
|
+
trace.push({ kind: "state_skip", text: `state[${state.id}] cursor col ${cursor.col} < cursor_col_min ${w.cursor_col_min}` });
|
|
26097
|
+
return { matched: false, title: null };
|
|
26098
|
+
}
|
|
26099
|
+
if (w.cursor_col_max !== void 0 && cursor.col > w.cursor_col_max) {
|
|
26100
|
+
trace.push({ kind: "state_skip", text: `state[${state.id}] cursor col ${cursor.col} > cursor_col_max ${w.cursor_col_max}` });
|
|
26101
|
+
return { matched: false, title: null };
|
|
26102
|
+
}
|
|
26103
|
+
}
|
|
26104
|
+
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})` : ""}` });
|
|
26075
26105
|
let title = null;
|
|
26076
26106
|
if (state.extract_title) {
|
|
26077
26107
|
const titleHay = sectionText(sections, state.extract_title.section, fullScreen);
|
|
@@ -26129,17 +26159,20 @@ function extractModal(state, sections, fullScreen, title, trace) {
|
|
|
26129
26159
|
trace.push({ kind: "modal", text: `modal_buttons matched ${buttons.length} choices` });
|
|
26130
26160
|
return { title, buttons };
|
|
26131
26161
|
}
|
|
26132
|
-
function evaluate(spec, screenText) {
|
|
26162
|
+
function evaluate(spec, screenText, cursor) {
|
|
26133
26163
|
const trace = [];
|
|
26134
26164
|
const lines = screenText.split("\n");
|
|
26135
26165
|
const sections = resolveSections(spec, lines);
|
|
26136
26166
|
for (const s of sections) {
|
|
26137
26167
|
trace.push({ kind: "section", text: `section[${s.id}] lines [${s.fromLine}, ${s.toLine}) (${s.toLine - s.fromLine} lines)` });
|
|
26138
26168
|
}
|
|
26169
|
+
if (cursor !== void 0) {
|
|
26170
|
+
trace.push({ kind: "section", text: `cursor (${cursor.row}, ${cursor.col})` });
|
|
26171
|
+
}
|
|
26139
26172
|
let activeState = null;
|
|
26140
26173
|
let modal = null;
|
|
26141
26174
|
for (const st of spec.states) {
|
|
26142
|
-
const { matched, title } = matchState(st, sections, screenText, trace);
|
|
26175
|
+
const { matched, title } = matchState(st, sections, screenText, trace, cursor);
|
|
26143
26176
|
if (!matched) continue;
|
|
26144
26177
|
const extractedModal = extractModal(st, sections, screenText, title, trace);
|
|
26145
26178
|
if (st.modal_buttons && !extractedModal) {
|
|
@@ -26407,6 +26440,22 @@ var SCHEMA = {
|
|
|
26407
26440
|
"flags": {
|
|
26408
26441
|
"type": "string",
|
|
26409
26442
|
"default": "i"
|
|
26443
|
+
},
|
|
26444
|
+
"cursor_row_min": {
|
|
26445
|
+
"type": "integer",
|
|
26446
|
+
"minimum": 0
|
|
26447
|
+
},
|
|
26448
|
+
"cursor_row_max": {
|
|
26449
|
+
"type": "integer",
|
|
26450
|
+
"minimum": 0
|
|
26451
|
+
},
|
|
26452
|
+
"cursor_col_min": {
|
|
26453
|
+
"type": "integer",
|
|
26454
|
+
"minimum": 0
|
|
26455
|
+
},
|
|
26456
|
+
"cursor_col_max": {
|
|
26457
|
+
"type": "integer",
|
|
26458
|
+
"minimum": 0
|
|
26410
26459
|
}
|
|
26411
26460
|
}
|
|
26412
26461
|
},
|
|
@@ -26936,6 +26985,9 @@ var SpecDriver = class {
|
|
|
26936
26985
|
snapshot() {
|
|
26937
26986
|
return this.adapter.snapshot();
|
|
26938
26987
|
}
|
|
26988
|
+
getCursorPosition() {
|
|
26989
|
+
return this.adapter.getCursorPosition();
|
|
26990
|
+
}
|
|
26939
26991
|
shutdown() {
|
|
26940
26992
|
for (const t of this.delegateTimers.values()) clearTimeout(t);
|
|
26941
26993
|
this.delegateTimers.clear();
|
|
@@ -27000,7 +27052,8 @@ var SpecDriver = class {
|
|
|
27000
27052
|
}
|
|
27001
27053
|
reevaluate(forceEmit = false) {
|
|
27002
27054
|
const screen = this.adapter.snapshot();
|
|
27003
|
-
const
|
|
27055
|
+
const cursor = this.adapter.getCursorPosition();
|
|
27056
|
+
const ev = evaluate(this.spec, screen, cursor);
|
|
27004
27057
|
let evState = ev.state;
|
|
27005
27058
|
const busyHoldMs = this.spec.debounce?.busy_hold_ms ?? BUSY_HOLD_MS;
|
|
27006
27059
|
if (this.currentStateId === "busy" && evState.id === "idle") {
|