reasonix 0.36.0 → 0.36.2
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/README.md +17 -0
- package/README.zh-CN.md +17 -0
- package/dashboard/dist/app.js +405 -196
- package/dashboard/dist/app.js.map +1 -1
- package/dist/cli/{chat-RGMYAOY2.js → chat-QSM6JKUA.js} +7 -7
- package/dist/cli/{chunk-ZU45XW3P.js → chunk-4D6TT2IB.js} +10 -2
- package/dist/cli/chunk-4D6TT2IB.js.map +1 -0
- package/dist/cli/{chunk-2MCYGFLK.js → chunk-C5543CRX.js} +17 -16
- package/dist/cli/chunk-C5543CRX.js.map +1 -0
- package/dist/cli/{chunk-KJQIA4US.js → chunk-K6W64QVE.js} +48 -29
- package/dist/cli/chunk-K6W64QVE.js.map +1 -0
- package/dist/cli/{chunk-EN4LAZW5.js → chunk-NHV5YGTB.js} +761 -642
- package/dist/cli/chunk-NHV5YGTB.js.map +1 -0
- package/dist/cli/{chunk-QRUQ2BFT.js → chunk-RNSZYYGB.js} +109 -41
- package/dist/cli/chunk-RNSZYYGB.js.map +1 -0
- package/dist/cli/{chunk-QPNZWUZF.js → chunk-S4GF3HPO.js} +26 -1
- package/dist/cli/chunk-S4GF3HPO.js.map +1 -0
- package/dist/cli/{code-KJB3WDU6.js → code-6C5A2CY3.js} +17 -9
- package/dist/cli/code-6C5A2CY3.js.map +1 -0
- package/dist/cli/index.js +10 -10
- package/dist/cli/{prompt-YEKXMNNV.js → prompt-QSEB7HNQ.js} +3 -3
- package/dist/cli/{run-FK5UBIIM.js → run-AG4Y45X7.js} +5 -5
- package/dist/cli/{server-W4XJK4GX.js → server-GNHR5K3N.js} +4 -4
- package/dist/cli/{sessions-YZXWMIWW.js → sessions-MHRF3GU4.js} +5 -5
- package/dist/cli/{version-DWD6RLIU.js → version-7AL4JZ63.js} +5 -5
- package/dist/index.d.ts +29 -1
- package/dist/index.js +146 -45
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/chunk-2MCYGFLK.js.map +0 -1
- package/dist/cli/chunk-EN4LAZW5.js.map +0 -1
- package/dist/cli/chunk-KJQIA4US.js.map +0 -1
- package/dist/cli/chunk-QPNZWUZF.js.map +0 -1
- package/dist/cli/chunk-QRUQ2BFT.js.map +0 -1
- package/dist/cli/chunk-ZU45XW3P.js.map +0 -1
- package/dist/cli/code-KJB3WDU6.js.map +0 -1
- /package/dist/cli/{chat-RGMYAOY2.js.map → chat-QSM6JKUA.js.map} +0 -0
- /package/dist/cli/{prompt-YEKXMNNV.js.map → prompt-QSEB7HNQ.js.map} +0 -0
- /package/dist/cli/{run-FK5UBIIM.js.map → run-AG4Y45X7.js.map} +0 -0
- /package/dist/cli/{server-W4XJK4GX.js.map → server-GNHR5K3N.js.map} +0 -0
- /package/dist/cli/{sessions-YZXWMIWW.js.map → sessions-MHRF3GU4.js.map} +0 -0
- /package/dist/cli/{version-DWD6RLIU.js.map → version-7AL4JZ63.js.map} +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
MemoryStore,
|
|
4
4
|
sanitizeMemoryName
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-4D6TT2IB.js";
|
|
6
6
|
import {
|
|
7
7
|
countTokens,
|
|
8
8
|
estimateConversationTokens,
|
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
} from "./chunk-KMWKGPFZ.js";
|
|
14
14
|
import {
|
|
15
15
|
pauseGate
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-S4GF3HPO.js";
|
|
17
17
|
import {
|
|
18
18
|
ESCALATION_CONTRACT,
|
|
19
19
|
NEGATIVE_CLAIM_RULE,
|
|
20
20
|
TUI_FORMATTING_RULES
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-K6W64QVE.js";
|
|
22
22
|
import {
|
|
23
23
|
formatHookOutcomeMessage,
|
|
24
24
|
runHooks
|
|
@@ -681,6 +681,48 @@ var ContextManager = class {
|
|
|
681
681
|
}
|
|
682
682
|
};
|
|
683
683
|
|
|
684
|
+
// src/core/inflight.ts
|
|
685
|
+
var InflightSet = class {
|
|
686
|
+
_set = /* @__PURE__ */ new Set();
|
|
687
|
+
_listeners = /* @__PURE__ */ new Set();
|
|
688
|
+
add(id) {
|
|
689
|
+
if (this._set.has(id)) return;
|
|
690
|
+
this._set.add(id);
|
|
691
|
+
this._notify();
|
|
692
|
+
}
|
|
693
|
+
delete(id) {
|
|
694
|
+
if (this._set.delete(id)) this._notify();
|
|
695
|
+
}
|
|
696
|
+
has(id) {
|
|
697
|
+
return this._set.has(id);
|
|
698
|
+
}
|
|
699
|
+
/** Snapshot for diagnostics / tests; live view, do not mutate. */
|
|
700
|
+
get size() {
|
|
701
|
+
return this._set.size;
|
|
702
|
+
}
|
|
703
|
+
/** Subscribe to add/delete; returns the unsubscribe function. */
|
|
704
|
+
subscribe(fn) {
|
|
705
|
+
this._listeners.add(fn);
|
|
706
|
+
return () => {
|
|
707
|
+
this._listeners.delete(fn);
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
/** Drop everything — only use at session reset. Notifies once. */
|
|
711
|
+
clear() {
|
|
712
|
+
if (this._set.size === 0) return;
|
|
713
|
+
this._set.clear();
|
|
714
|
+
this._notify();
|
|
715
|
+
}
|
|
716
|
+
_notify() {
|
|
717
|
+
for (const fn of this._listeners) {
|
|
718
|
+
try {
|
|
719
|
+
fn();
|
|
720
|
+
} catch {
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
|
|
684
726
|
// src/loop/errors.ts
|
|
685
727
|
function formatLoopError(err, probe) {
|
|
686
728
|
const msg = err.message ?? "";
|
|
@@ -1362,12 +1404,18 @@ var CacheFirstLoop = class {
|
|
|
1362
1404
|
_streamPreference;
|
|
1363
1405
|
/** Threaded through HTTP + every tool dispatch so Esc cancels in-flight work, not after. */
|
|
1364
1406
|
_turnAbort = new AbortController();
|
|
1407
|
+
/** Authoritative running-id set — UI cards consult this instead of trusting end-event delivery. Insert at dispatch entry, delete in finally. */
|
|
1408
|
+
_inflight = new InflightSet();
|
|
1365
1409
|
_proArmedForNextTurn = false;
|
|
1366
1410
|
_escalateThisTurn = false;
|
|
1367
1411
|
_turnFailures = new TurnFailureTracker();
|
|
1368
1412
|
_turnSelfCorrected = false;
|
|
1369
1413
|
_foldedThisTurn = false;
|
|
1370
1414
|
context;
|
|
1415
|
+
/** Subscribe API so UI hooks can derive `running` from finally-guaranteed insertions. */
|
|
1416
|
+
get inflight() {
|
|
1417
|
+
return this._inflight;
|
|
1418
|
+
}
|
|
1371
1419
|
get currentTurn() {
|
|
1372
1420
|
return this._turn;
|
|
1373
1421
|
}
|
|
@@ -1498,6 +1546,7 @@ var CacheFirstLoop = class {
|
|
|
1498
1546
|
}
|
|
1499
1547
|
}
|
|
1500
1548
|
this.scratch.reset();
|
|
1549
|
+
this._inflight.clear();
|
|
1501
1550
|
return { dropped };
|
|
1502
1551
|
}
|
|
1503
1552
|
configure(opts) {
|
|
@@ -1548,44 +1597,59 @@ var CacheFirstLoop = class {
|
|
|
1548
1597
|
const name = call.function?.name ?? "";
|
|
1549
1598
|
const args = call.function?.arguments ?? "{}";
|
|
1550
1599
|
const parsedArgs = safeParseToolArgs(args);
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
const
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1600
|
+
this._inflight.add(this.inflightIdFor(call));
|
|
1601
|
+
try {
|
|
1602
|
+
const preReport = await runHooks({
|
|
1603
|
+
hooks: this.hooks,
|
|
1604
|
+
payload: {
|
|
1605
|
+
event: "PreToolUse",
|
|
1606
|
+
cwd: this.hookCwd,
|
|
1607
|
+
toolName: name,
|
|
1608
|
+
toolArgs: parsedArgs
|
|
1609
|
+
}
|
|
1610
|
+
});
|
|
1611
|
+
const preWarnings = [...hookWarnings(preReport.outcomes, this._turn)];
|
|
1612
|
+
if (preReport.blocked) {
|
|
1613
|
+
const blocking = preReport.outcomes[preReport.outcomes.length - 1];
|
|
1614
|
+
const reason = (blocking?.stderr || blocking?.stdout || "blocked by PreToolUse hook").trim();
|
|
1615
|
+
return {
|
|
1616
|
+
preWarnings,
|
|
1617
|
+
postWarnings: [],
|
|
1618
|
+
result: `[hook block] ${blocking?.hook.command ?? "<unknown>"}
|
|
1568
1619
|
${reason}`
|
|
1569
|
-
|
|
1570
|
-
}
|
|
1571
|
-
const result = await this.tools.dispatch(name, args, {
|
|
1572
|
-
signal,
|
|
1573
|
-
maxResultTokens: DEFAULT_MAX_RESULT_TOKENS,
|
|
1574
|
-
confirmationGate: this.confirmationGate
|
|
1575
|
-
});
|
|
1576
|
-
const postReport = await runHooks({
|
|
1577
|
-
hooks: this.hooks,
|
|
1578
|
-
payload: {
|
|
1579
|
-
event: "PostToolUse",
|
|
1580
|
-
cwd: this.hookCwd,
|
|
1581
|
-
toolName: name,
|
|
1582
|
-
toolArgs: parsedArgs,
|
|
1583
|
-
toolResult: result
|
|
1620
|
+
};
|
|
1584
1621
|
}
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1622
|
+
const result = await this.tools.dispatch(name, args, {
|
|
1623
|
+
signal,
|
|
1624
|
+
maxResultTokens: DEFAULT_MAX_RESULT_TOKENS,
|
|
1625
|
+
confirmationGate: this.confirmationGate
|
|
1626
|
+
});
|
|
1627
|
+
const postReport = await runHooks({
|
|
1628
|
+
hooks: this.hooks,
|
|
1629
|
+
payload: {
|
|
1630
|
+
event: "PostToolUse",
|
|
1631
|
+
cwd: this.hookCwd,
|
|
1632
|
+
toolName: name,
|
|
1633
|
+
toolArgs: parsedArgs,
|
|
1634
|
+
toolResult: result
|
|
1635
|
+
}
|
|
1636
|
+
});
|
|
1637
|
+
const postWarnings = [...hookWarnings(postReport.outcomes, this._turn)];
|
|
1638
|
+
return { preWarnings, postWarnings, result };
|
|
1639
|
+
} finally {
|
|
1640
|
+
this._inflight.delete(this.inflightIdFor(call));
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
/** Stable per-call id used as the inflight key AND threaded into tool_start / tool events so the UI matches them up. */
|
|
1644
|
+
inflightIdFor(call) {
|
|
1645
|
+
if (call.id) return call.id;
|
|
1646
|
+
const fallback = call._inflightFallback;
|
|
1647
|
+
if (fallback) return fallback;
|
|
1648
|
+
const generated = `inflight-${++this._inflightCounter}`;
|
|
1649
|
+
call._inflightFallback = generated;
|
|
1650
|
+
return generated;
|
|
1588
1651
|
}
|
|
1652
|
+
_inflightCounter = 0;
|
|
1589
1653
|
buildMessages(pendingUser) {
|
|
1590
1654
|
const healed = healLoadedMessages(this.log.toMessages(), DEFAULT_MAX_RESULT_CHARS);
|
|
1591
1655
|
const msgs = [...this.prefix.toMessages(), ...healed.messages];
|
|
@@ -2027,12 +2091,15 @@ ${reason}`
|
|
|
2027
2091
|
chunk.push(repairedCalls[callIdx++]);
|
|
2028
2092
|
}
|
|
2029
2093
|
for (const call of chunk) {
|
|
2094
|
+
const callId = this.inflightIdFor(call);
|
|
2095
|
+
this._inflight.add(callId);
|
|
2030
2096
|
yield {
|
|
2031
2097
|
turn: this._turn,
|
|
2032
2098
|
role: "tool_start",
|
|
2033
2099
|
content: "",
|
|
2034
2100
|
toolName: call.function?.name ?? "",
|
|
2035
|
-
toolArgs: call.function?.arguments ?? "{}"
|
|
2101
|
+
toolArgs: call.function?.arguments ?? "{}",
|
|
2102
|
+
callId
|
|
2036
2103
|
};
|
|
2037
2104
|
}
|
|
2038
2105
|
const settled = await Promise.allSettled(chunk.map((c) => this.runOneToolCall(c, signal)));
|
|
@@ -2076,7 +2143,8 @@ ${reason}`
|
|
|
2076
2143
|
role: "tool",
|
|
2077
2144
|
content: result,
|
|
2078
2145
|
toolName: name,
|
|
2079
|
-
toolArgs: args
|
|
2146
|
+
toolArgs: args,
|
|
2147
|
+
callId: this.inflightIdFor(call)
|
|
2080
2148
|
};
|
|
2081
2149
|
}
|
|
2082
2150
|
}
|
|
@@ -5009,4 +5077,4 @@ export {
|
|
|
5009
5077
|
snapshotBeforeEdits,
|
|
5010
5078
|
restoreSnapshots
|
|
5011
5079
|
};
|
|
5012
|
-
//# sourceMappingURL=chunk-
|
|
5080
|
+
//# sourceMappingURL=chunk-RNSZYYGB.js.map
|