@tjamescouch/gro 1.3.11 → 1.3.12
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/main.js +11 -49
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -22,7 +22,8 @@ import { groError, asError, isGroError, errorLogFields } from "./errors.js";
|
|
|
22
22
|
import { bashToolDefinition, executeBash } from "./tools/bash.js";
|
|
23
23
|
import { agentpatchToolDefinition, executeAgentpatch } from "./tools/agentpatch.js";
|
|
24
24
|
import { groVersionToolDefinition, executeGroVersion, getGroVersion } from "./tools/version.js";
|
|
25
|
-
|
|
25
|
+
// Stream marker imports — parser disabled for now, markers pass through as visible text.
|
|
26
|
+
// import { createMarkerParser, extractMarkers } from "./stream-markers.js";
|
|
26
27
|
const VERSION = getGroVersion();
|
|
27
28
|
// ---------------------------------------------------------------------------
|
|
28
29
|
// Graceful shutdown state — module-level so signal handlers can save sessions.
|
|
@@ -520,31 +521,15 @@ async function executeTurn(driver, memory, mcp, cfg, sessionId) {
|
|
|
520
521
|
let brokeCleanly = false;
|
|
521
522
|
let idleNudges = 0;
|
|
522
523
|
for (let round = 0; round < cfg.maxToolRounds; round++) {
|
|
523
|
-
//
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
Logger.info(`Stream marker: model-change '${marker.arg}' → ${newModel}`);
|
|
528
|
-
activeModel = newModel;
|
|
529
|
-
cfg.model = newModel; // persist across turns
|
|
530
|
-
memory.setModel(newModel); // persist in session metadata on save
|
|
531
|
-
}
|
|
532
|
-
else {
|
|
533
|
-
Logger.debug(`Stream marker: ${marker.name}('${marker.arg}')`);
|
|
534
|
-
}
|
|
535
|
-
};
|
|
536
|
-
// Create a fresh marker parser per round so partial state doesn't leak
|
|
537
|
-
const markerParser = createMarkerParser({
|
|
538
|
-
onToken: rawOnToken,
|
|
539
|
-
onMarker: handleMarker,
|
|
540
|
-
});
|
|
524
|
+
// Stream markers: currently pass-through (visible in output).
|
|
525
|
+
// Model-change and other marker actions are disabled until the
|
|
526
|
+
// infrastructure is ready for hot-swapping.
|
|
527
|
+
const onToken = rawOnToken;
|
|
541
528
|
const output = await driver.chat(memory.messages(), {
|
|
542
529
|
model: activeModel,
|
|
543
530
|
tools: tools.length > 0 ? tools : undefined,
|
|
544
|
-
onToken
|
|
531
|
+
onToken,
|
|
545
532
|
});
|
|
546
|
-
// Flush any remaining buffered tokens from the marker parser
|
|
547
|
-
markerParser.flush();
|
|
548
533
|
// Track token usage for niki budget enforcement
|
|
549
534
|
if (output.usage) {
|
|
550
535
|
turnTokensIn += output.usage.inputTokens;
|
|
@@ -552,13 +537,10 @@ async function executeTurn(driver, memory, mcp, cfg, sessionId) {
|
|
|
552
537
|
// Log cumulative usage to stderr — niki parses these patterns for budget enforcement
|
|
553
538
|
process.stderr.write(`"input_tokens": ${turnTokensIn}, "output_tokens": ${turnTokensOut}\n`);
|
|
554
539
|
}
|
|
555
|
-
// Accumulate
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
// Store clean text in memory — markers are runtime directives, not conversation content.
|
|
560
|
-
// The original output.text is preserved in case we need it for debugging.
|
|
561
|
-
const assistantMsg = { role: "assistant", from: "Assistant", content: cleanText || "" };
|
|
540
|
+
// Accumulate output text
|
|
541
|
+
if (output.text)
|
|
542
|
+
finalText += output.text;
|
|
543
|
+
const assistantMsg = { role: "assistant", from: "Assistant", content: output.text || "" };
|
|
562
544
|
if (output.toolCalls.length > 0) {
|
|
563
545
|
assistantMsg.tool_calls = output.toolCalls;
|
|
564
546
|
}
|
|
@@ -597,14 +579,6 @@ async function executeTurn(driver, memory, mcp, cfg, sessionId) {
|
|
|
597
579
|
Logger.debug(`Failed to parse args for ${fnName}: ${asError(e).message}, using empty args`);
|
|
598
580
|
fnArgs = {};
|
|
599
581
|
}
|
|
600
|
-
// Scan tool call string args for stream markers (e.g. model sends
|
|
601
|
-
// @@model-change('haiku')@@ inside an agentchat_send message).
|
|
602
|
-
// Strip markers from args so they don't leak into tool output.
|
|
603
|
-
for (const key of Object.keys(fnArgs)) {
|
|
604
|
-
if (typeof fnArgs[key] === "string") {
|
|
605
|
-
fnArgs[key] = extractMarkers(fnArgs[key], handleMarker);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
582
|
Logger.debug(`Tool call: ${fnName}(${JSON.stringify(fnArgs)})`);
|
|
609
583
|
let result;
|
|
610
584
|
try {
|
|
@@ -696,12 +670,6 @@ async function singleShot(cfg, driver, mcp, sessionId, positionalArgs) {
|
|
|
696
670
|
// Resume existing session if requested
|
|
697
671
|
if (cfg.continueSession || cfg.resumeSession) {
|
|
698
672
|
await memory.load(sessionId);
|
|
699
|
-
const sess = loadSession(sessionId);
|
|
700
|
-
if (sess?.meta.model && sess.meta.model !== cfg.model) {
|
|
701
|
-
Logger.info(`Restoring model from session: ${cfg.model} → ${sess.meta.model}`);
|
|
702
|
-
cfg.model = sess.meta.model;
|
|
703
|
-
memory.setModel(sess.meta.model);
|
|
704
|
-
}
|
|
705
673
|
}
|
|
706
674
|
await memory.add({ role: "user", from: "User", content: prompt });
|
|
707
675
|
let text;
|
|
@@ -751,12 +719,6 @@ async function interactive(cfg, driver, mcp, sessionId) {
|
|
|
751
719
|
if (sess) {
|
|
752
720
|
const msgCount = sess.messages.filter((m) => m.role !== "system").length;
|
|
753
721
|
Logger.info(C.gray(`Resumed session ${sessionId} (${msgCount} messages)`));
|
|
754
|
-
// Restore model from session metadata (e.g. after a stream marker model-change)
|
|
755
|
-
if (sess.meta.model && sess.meta.model !== cfg.model) {
|
|
756
|
-
Logger.info(`Restoring model from session: ${cfg.model} → ${sess.meta.model}`);
|
|
757
|
-
cfg.model = sess.meta.model;
|
|
758
|
-
memory.setModel(sess.meta.model);
|
|
759
|
-
}
|
|
760
722
|
}
|
|
761
723
|
}
|
|
762
724
|
const rl = readline.createInterface({
|
package/dist/package.json
CHANGED