@kenkaiiii/ggcoder 5.26.2 → 5.27.0
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/app-sidecar.js +81 -47
- package/dist/app-sidecar.js.map +1 -1
- package/dist/core/agent-session-marker-anchors.test.js +181 -2
- package/dist/core/agent-session-marker-anchors.test.js.map +1 -1
- package/dist/core/agent-session-process-gate.test.d.ts +2 -0
- package/dist/core/agent-session-process-gate.test.d.ts.map +1 -0
- package/dist/core/agent-session-process-gate.test.js +88 -0
- package/dist/core/agent-session-process-gate.test.js.map +1 -0
- package/dist/core/agent-session-slash-restore.test.d.ts +2 -0
- package/dist/core/agent-session-slash-restore.test.d.ts.map +1 -0
- package/dist/core/agent-session-slash-restore.test.js +121 -0
- package/dist/core/agent-session-slash-restore.test.js.map +1 -0
- package/dist/core/agent-session.d.ts +66 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +304 -35
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/compactor.d.ts +21 -0
- package/dist/core/compaction/compactor.d.ts.map +1 -1
- package/dist/core/compaction/compactor.js +16 -0
- package/dist/core/compaction/compactor.js.map +1 -1
- package/dist/core/compaction/compactor.test.js +91 -0
- package/dist/core/compaction/compactor.test.js.map +1 -1
- package/dist/core/foreign-session-import.d.ts +120 -0
- package/dist/core/foreign-session-import.d.ts.map +1 -0
- package/dist/core/foreign-session-import.js +594 -0
- package/dist/core/foreign-session-import.js.map +1 -0
- package/dist/core/foreign-session-import.test.d.ts +2 -0
- package/dist/core/foreign-session-import.test.d.ts.map +1 -0
- package/dist/core/foreign-session-import.test.js +220 -0
- package/dist/core/foreign-session-import.test.js.map +1 -0
- package/dist/core/foreign-transcript-blocks.d.ts +51 -0
- package/dist/core/foreign-transcript-blocks.d.ts.map +1 -0
- package/dist/core/foreign-transcript-blocks.js +151 -0
- package/dist/core/foreign-transcript-blocks.js.map +1 -0
- package/dist/core/mcp/catalog-cache.d.ts +63 -0
- package/dist/core/mcp/catalog-cache.d.ts.map +1 -0
- package/dist/core/mcp/catalog-cache.js +163 -0
- package/dist/core/mcp/catalog-cache.js.map +1 -0
- package/dist/core/mcp/catalog-cache.test.d.ts +2 -0
- package/dist/core/mcp/catalog-cache.test.d.ts.map +1 -0
- package/dist/core/mcp/catalog-cache.test.js +99 -0
- package/dist/core/mcp/catalog-cache.test.js.map +1 -0
- package/dist/core/mcp/client.d.ts +61 -0
- package/dist/core/mcp/client.d.ts.map +1 -1
- package/dist/core/mcp/client.js +216 -31
- package/dist/core/mcp/client.js.map +1 -1
- package/dist/core/mcp/legacy-negotiation.test.d.ts +2 -0
- package/dist/core/mcp/legacy-negotiation.test.d.ts.map +1 -0
- package/dist/core/mcp/legacy-negotiation.test.js +80 -0
- package/dist/core/mcp/legacy-negotiation.test.js.map +1 -0
- package/dist/core/mcp/oauth-provider.d.ts +1 -2
- package/dist/core/mcp/oauth-provider.d.ts.map +1 -1
- package/dist/core/mcp/oauth-provider.js +5 -1
- package/dist/core/mcp/oauth-provider.js.map +1 -1
- package/dist/core/mcp/oauth-store.d.ts +1 -1
- package/dist/core/mcp/oauth-store.d.ts.map +1 -1
- package/dist/core/mcp/oauth-store.js.map +1 -1
- package/dist/core/mcp/when-connected.test.d.ts +2 -0
- package/dist/core/mcp/when-connected.test.d.ts.map +1 -0
- package/dist/core/mcp/when-connected.test.js +46 -0
- package/dist/core/mcp/when-connected.test.js.map +1 -0
- package/dist/core/process-gate.d.ts +45 -0
- package/dist/core/process-gate.d.ts.map +1 -0
- package/dist/core/process-gate.js +71 -0
- package/dist/core/process-gate.js.map +1 -0
- package/dist/core/process-gate.test.d.ts +2 -0
- package/dist/core/process-gate.test.d.ts.map +1 -0
- package/dist/core/process-gate.test.js +87 -0
- package/dist/core/process-gate.test.js.map +1 -0
- package/dist/core/process-manager.d.ts +9 -0
- package/dist/core/process-manager.d.ts.map +1 -1
- package/dist/core/process-manager.js +17 -15
- package/dist/core/process-manager.js.map +1 -1
- package/dist/core/session-history.d.ts +61 -4
- package/dist/core/session-history.d.ts.map +1 -1
- package/dist/core/session-history.js +144 -15
- package/dist/core/session-history.js.map +1 -1
- package/dist/core/session-history.test.js +50 -1
- package/dist/core/session-history.test.js.map +1 -1
- package/dist/core/session-manager.d.ts +35 -6
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +39 -10
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-manager.test.js +14 -2
- package/dist/core/session-manager.test.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +6 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts +2 -0
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +17 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/slash-commands.test.js +1 -0
- package/dist/core/slash-commands.test.js.map +1 -1
- package/dist/tools/tool-search.d.ts +12 -1
- package/dist/tools/tool-search.d.ts.map +1 -1
- package/dist/tools/tool-search.js +22 -3
- package/dist/tools/tool-search.js.map +1 -1
- package/dist/tools/tool-search.test.d.ts +2 -0
- package/dist/tools/tool-search.test.d.ts.map +1 -0
- package/dist/tools/tool-search.test.js +69 -0
- package/dist/tools/tool-search.test.js.map +1 -0
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +27 -1
- package/dist/ui/App.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session.d.ts","sourceRoot":"","sources":["../../src/core/agent-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,QAAQ,EAEb,KAAK,aAAa,EAInB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAA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AAmB;YAkInB,qBAAqB;YAIrB,cAAc;IAmB5B,OAAO,CAAC,yBAAyB;IAwDjC;;;;;OAKG;IACG,uBAAuB,CAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAO,GAC1B,OAAO,CAAC,6BAA6B,CAAC;CA2B1C"}
|
|
@@ -12,15 +12,20 @@ import { kimiCodingHeaders, isKimiCodingEndpoint } from "./oauth/kimi.js";
|
|
|
12
12
|
import { SessionManager, KEN_TURN_CUSTOM_KIND, AUTOPILOT_MARKER_CUSTOM_KIND, APP_MARKER_CUSTOM_KIND, } from "./session-manager.js";
|
|
13
13
|
import { ExtensionLoader } from "./extensions/loader.js";
|
|
14
14
|
import { shouldCompact, compact } from "./compaction/compactor.js";
|
|
15
|
+
import { remapAnchorForCompaction, stripRecordedPosition } from "./session-history.js";
|
|
15
16
|
import { getAuthStorageKeys, getContextWindow, getModel, getToolResultCharLimit, MODELS, } from "./model-registry.js";
|
|
16
17
|
import { discoverSkills } from "./skills.js";
|
|
17
18
|
import { ensureAppDirs } from "../config.js";
|
|
18
19
|
import { buildSystemPrompt } from "../system-prompt.js";
|
|
19
20
|
import { createTools, createWebSearchTool, } from "../tools/index.js";
|
|
21
|
+
import { buildProcessCompletionFollowUp } from "./process-gate.js";
|
|
20
22
|
import { buildSubAgentCompletionFollowUp } from "./subagent-manager.js";
|
|
21
23
|
import { applyAsyncSubagentPolicy } from "./subagent-policy.js";
|
|
24
|
+
import { z } from "zod";
|
|
22
25
|
import { MCPClientManager, getAllMcpServers } from "./mcp/index.js";
|
|
23
26
|
import { DeferredToolCatalog } from "./mcp/deferred-catalog.js";
|
|
27
|
+
import { McpCatalogCache } from "./mcp/catalog-cache.js";
|
|
28
|
+
import { describeDropped, importForeignSession, } from "./foreign-session-import.js";
|
|
24
29
|
import { createToolSearchTool } from "../tools/tool-search.js";
|
|
25
30
|
import { log } from "./logger.js";
|
|
26
31
|
import { setEstimatorModel, calibrateEstimatorFromUsage } from "./compaction/token-estimator.js";
|
|
@@ -135,6 +140,10 @@ export class AgentSession {
|
|
|
135
140
|
/** 0 = none; 1 = first nudge sent; 2 = final stop-and-report injected. */
|
|
136
141
|
loopBreakInjected = 0;
|
|
137
142
|
regroundingInjected = false;
|
|
143
|
+
/** Wall-clock start of the current run; scopes the background-process gate. */
|
|
144
|
+
runStartedAt = 0;
|
|
145
|
+
/** Gate injections spent this run, capped by MAX_PROCESS_GATE_INJECTIONS. */
|
|
146
|
+
processGateInjected = 0;
|
|
138
147
|
compactionOccurred = false;
|
|
139
148
|
lastCompactionCompacted = false;
|
|
140
149
|
compactionRetryAfter = 0;
|
|
@@ -167,6 +176,11 @@ export class AgentSession {
|
|
|
167
176
|
mcpManager;
|
|
168
177
|
/** Deferred MCP tools awaiting discovery via tool_search (bench A win). */
|
|
169
178
|
mcpCatalog;
|
|
179
|
+
/** Live (connected) MCP tools by name — the reconcile target for cached stubs. */
|
|
180
|
+
liveMcpTools = new Map();
|
|
181
|
+
/** Server name for each cached-only tool, so a stub knows what to wait on. */
|
|
182
|
+
cachedMcpToolServers = new Map();
|
|
183
|
+
mcpCatalogCache = new McpCatalogCache();
|
|
170
184
|
provider;
|
|
171
185
|
model;
|
|
172
186
|
cwd;
|
|
@@ -342,7 +356,10 @@ export class AgentSession {
|
|
|
342
356
|
// its listening handshake until this resolves), `backgroundMcpConnect`
|
|
343
357
|
// moves the connect off the critical path so the session becomes usable
|
|
344
358
|
// immediately and tools are appended whenever the servers come up.
|
|
345
|
-
this.mcpManager = new MCPClientManager(
|
|
359
|
+
this.mcpManager = new MCPClientManager({
|
|
360
|
+
catalogCache: this.mcpCatalogCache,
|
|
361
|
+
modernProtocol: this.settingsManager.get("mcpModernProtocol"),
|
|
362
|
+
});
|
|
346
363
|
if (this.opts.backgroundMcpConnect) {
|
|
347
364
|
void this.connectMcpServers();
|
|
348
365
|
}
|
|
@@ -505,6 +522,11 @@ export class AgentSession {
|
|
|
505
522
|
if (this.opts.allowedTools && mcpWhitelist) {
|
|
506
523
|
servers = servers.filter((s) => mcpWhitelist.includes(s.name));
|
|
507
524
|
}
|
|
525
|
+
// Seed the catalog from the on-disk cache BEFORE connecting. With
|
|
526
|
+
// `backgroundMcpConnect` the first turns would otherwise run against an
|
|
527
|
+
// empty catalog and tool_search would answer "the catalog is empty" for
|
|
528
|
+
// capabilities that genuinely exist — a wrong answer, not a slow one.
|
|
529
|
+
await this.seedMcpCatalogFromCache(servers);
|
|
508
530
|
const connected = await this.mcpManager.connectAll(servers);
|
|
509
531
|
// Defense-in-depth: even from a whitelisted server, only push tools that
|
|
510
532
|
// pass the allow-list (no-op when there's no allow-list).
|
|
@@ -540,23 +562,146 @@ export class AgentSession {
|
|
|
540
562
|
addMcpTools(mcpTools) {
|
|
541
563
|
if (mcpTools.length === 0)
|
|
542
564
|
return;
|
|
565
|
+
for (const tool of mcpTools) {
|
|
566
|
+
this.liveMcpTools.set(tool.name, tool);
|
|
567
|
+
this.cachedMcpToolServers.delete(tool.name);
|
|
568
|
+
}
|
|
543
569
|
const defer = !this.opts.allowedTools && this.settingsManager.get("deferredMcpTools");
|
|
544
570
|
if (!defer) {
|
|
545
|
-
this.
|
|
571
|
+
this.replaceOrPushTools(mcpTools);
|
|
546
572
|
return;
|
|
547
573
|
}
|
|
548
574
|
this.mcpCatalog ??= new DeferredToolCatalog();
|
|
575
|
+
// `add` is name-keyed, so live definitions replace cached stubs in place.
|
|
549
576
|
this.mcpCatalog.add(mcpTools);
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
577
|
+
// A stub the model already promoted lives in `this.tools`; swap it for the
|
|
578
|
+
// live tool so later calls dispatch directly instead of through the stub.
|
|
579
|
+
this.replaceLivePromotedTools(mcpTools);
|
|
580
|
+
this.ensureToolSearchTool();
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Register `tool_search` once. Promotion of a cached-only entry waits for its
|
|
584
|
+
* server so the model is told immediately when that capability turns out to
|
|
585
|
+
* be unreachable, instead of promoting a tool that fails on first call.
|
|
586
|
+
*/
|
|
587
|
+
ensureToolSearchTool() {
|
|
588
|
+
if (!this.mcpCatalog)
|
|
589
|
+
return;
|
|
590
|
+
if (this.tools.some((t) => t.name === "tool_search"))
|
|
591
|
+
return;
|
|
592
|
+
this.tools.push(createToolSearchTool(this.mcpCatalog, (promoted) => {
|
|
593
|
+
this.tools.push(...promoted);
|
|
594
|
+
}, async (toolName) => {
|
|
595
|
+
if (this.liveMcpTools.has(toolName))
|
|
596
|
+
return undefined;
|
|
597
|
+
const serverName = this.cachedMcpToolServers.get(toolName);
|
|
598
|
+
if (!serverName)
|
|
599
|
+
return undefined;
|
|
600
|
+
const outcome = (await this.mcpManager?.whenConnected(serverName)) ?? {
|
|
601
|
+
ok: false,
|
|
602
|
+
error: "MCP is disabled for this session",
|
|
603
|
+
};
|
|
604
|
+
return outcome.ok
|
|
605
|
+
? { serverName, ok: true }
|
|
606
|
+
: { serverName, ok: false, error: outcome.error };
|
|
607
|
+
}));
|
|
608
|
+
}
|
|
609
|
+
/** Append tools, replacing any same-named entry (cached stub → live tool). */
|
|
610
|
+
replaceOrPushTools(tools) {
|
|
611
|
+
for (const tool of tools) {
|
|
612
|
+
const index = this.tools.findIndex((t) => t.name === tool.name);
|
|
613
|
+
if (index >= 0)
|
|
614
|
+
this.tools[index] = tool;
|
|
615
|
+
else
|
|
616
|
+
this.tools.push(tool);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
/** Swap already-promoted cached stubs for their live equivalents, in place. */
|
|
620
|
+
replaceLivePromotedTools(tools) {
|
|
621
|
+
for (const tool of tools) {
|
|
622
|
+
const index = this.tools.findIndex((t) => t.name === tool.name);
|
|
623
|
+
if (index >= 0)
|
|
624
|
+
this.tools[index] = tool;
|
|
554
625
|
}
|
|
555
626
|
}
|
|
556
627
|
/**
|
|
557
|
-
*
|
|
628
|
+
* Publish cached tool definitions into the deferred catalog so `tool_search`
|
|
629
|
+
* answers correctly on turn 1. A cached stub carries the real name, one-line
|
|
630
|
+
* description and input schema; calling it waits for the live connection and
|
|
631
|
+
* then dispatches against the real client, or returns a clear error when that
|
|
632
|
+
* server ultimately failed. Live tools replace stubs on connect.
|
|
558
633
|
*/
|
|
559
|
-
async
|
|
634
|
+
async seedMcpCatalogFromCache(servers) {
|
|
635
|
+
if (!this.opts.backgroundMcpConnect)
|
|
636
|
+
return;
|
|
637
|
+
if (this.opts.allowedTools || !this.settingsManager.get("deferredMcpTools"))
|
|
638
|
+
return;
|
|
639
|
+
let entries;
|
|
640
|
+
try {
|
|
641
|
+
entries = await this.mcpCatalogCache.entriesFor(servers);
|
|
642
|
+
}
|
|
643
|
+
catch {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
const stubs = [];
|
|
647
|
+
for (const [serverName, entry] of entries) {
|
|
648
|
+
for (const cached of entry.tools) {
|
|
649
|
+
if (this.liveMcpTools.has(cached.name))
|
|
650
|
+
continue;
|
|
651
|
+
this.cachedMcpToolServers.set(cached.name, serverName);
|
|
652
|
+
stubs.push(this.buildCachedMcpTool(serverName, cached));
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
if (stubs.length === 0)
|
|
656
|
+
return;
|
|
657
|
+
log("INFO", "mcp", "Seeded deferred tool catalog from cache", {
|
|
658
|
+
tools: String(stubs.length),
|
|
659
|
+
servers: String(entries.size),
|
|
660
|
+
});
|
|
661
|
+
this.addCachedMcpTools(stubs);
|
|
662
|
+
}
|
|
663
|
+
/** Catalog-only registration for cached stubs — never marks them live. */
|
|
664
|
+
addCachedMcpTools(stubs) {
|
|
665
|
+
this.mcpCatalog ??= new DeferredToolCatalog();
|
|
666
|
+
this.mcpCatalog.add(stubs);
|
|
667
|
+
this.ensureToolSearchTool();
|
|
668
|
+
}
|
|
669
|
+
buildCachedMcpTool(serverName, cached) {
|
|
670
|
+
return {
|
|
671
|
+
name: cached.name,
|
|
672
|
+
description: cached.description,
|
|
673
|
+
parameters: z.record(z.string(), z.unknown()),
|
|
674
|
+
rawInputSchema: cached.rawInputSchema,
|
|
675
|
+
execute: async (args, context) => {
|
|
676
|
+
const live = this.liveMcpTools.get(cached.name);
|
|
677
|
+
if (live)
|
|
678
|
+
return live.execute(args, context);
|
|
679
|
+
const outcome = (await this.mcpManager?.whenConnected(serverName)) ?? {
|
|
680
|
+
ok: false,
|
|
681
|
+
error: "MCP is disabled for this session",
|
|
682
|
+
};
|
|
683
|
+
if (!outcome.ok) {
|
|
684
|
+
return (`MCP tool ${cached.name} is unavailable: server "${serverName}" did not connect ` +
|
|
685
|
+
`(${outcome.error}). This tool was offered from a cached catalog. ` +
|
|
686
|
+
`Use a different approach or ask the user to check their MCP configuration.`);
|
|
687
|
+
}
|
|
688
|
+
const connected = this.liveMcpTools.get(cached.name);
|
|
689
|
+
if (!connected) {
|
|
690
|
+
return (`MCP tool ${cached.name} no longer exists: server "${serverName}" connected but ` +
|
|
691
|
+
`does not expose it. The cached catalog entry was stale.`);
|
|
692
|
+
}
|
|
693
|
+
return connected.execute(args, context);
|
|
694
|
+
},
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Resolve a `/name [args]` input to the prompt template it expands into, or
|
|
699
|
+
* null when it isn't a prompt-template command for THIS session (an ordinary
|
|
700
|
+
* message, a registry/action command, or any slash input on a non-coder
|
|
701
|
+
* agent). Shared by {@link prompt} and {@link willExpandPromptTemplate} so
|
|
702
|
+
* callers can't drift from the expansion that actually happens.
|
|
703
|
+
*/
|
|
704
|
+
async resolveSlashInput(content) {
|
|
560
705
|
const parsedInput = this.slashCommands.parse(content);
|
|
561
706
|
const coderCommands = this.opts.coderSlashCommands !== false;
|
|
562
707
|
// Non-coder agents only intercept commands registered in their own registry.
|
|
@@ -564,27 +709,51 @@ export class AgentSession {
|
|
|
564
709
|
const parsed = parsedInput && (coderCommands || this.slashCommands.get(parsedInput.name))
|
|
565
710
|
? parsedInput
|
|
566
711
|
: null;
|
|
567
|
-
if (parsed)
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
712
|
+
if (!parsed)
|
|
713
|
+
return null;
|
|
714
|
+
// GG Coder alone can resolve its prompt-template and project commands.
|
|
715
|
+
const builtinPromptCmd = coderCommands ? getPromptCommand(parsed.name) : undefined;
|
|
716
|
+
const customCmds = coderCommands ? await loadCustomCommands(this.cwd) : [];
|
|
717
|
+
const customPromptCmd = !builtinPromptCmd
|
|
718
|
+
? customCmds.find((c) => c.name === parsed.name)
|
|
719
|
+
: undefined;
|
|
720
|
+
const promptText = builtinPromptCmd?.prompt ?? customPromptCmd?.prompt;
|
|
721
|
+
// No template body — a registry/action command that runs and returns text
|
|
722
|
+
// instead of becoming a user message.
|
|
723
|
+
if (!promptText)
|
|
724
|
+
return { kind: "command" };
|
|
725
|
+
return {
|
|
726
|
+
kind: "template",
|
|
727
|
+
fullPrompt: parsed.args
|
|
728
|
+
? `${promptText}\n\n## User Instructions\n\n${parsed.args}`
|
|
729
|
+
: promptText,
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Whether {@link prompt} would expand this input into a template body and
|
|
734
|
+
* persist it as a user message. Hosts use it to record the typed `/name` for
|
|
735
|
+
* transcript restore — gating on anything looser risks tagging an unrelated
|
|
736
|
+
* message when the command turns out NOT to expand.
|
|
737
|
+
*/
|
|
738
|
+
async willExpandPromptTemplate(content) {
|
|
739
|
+
return (await this.resolveSlashInput(content))?.kind === "template";
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Process user input. Handles slash commands or runs agent loop.
|
|
743
|
+
*/
|
|
744
|
+
async prompt(content) {
|
|
745
|
+
const slash = await this.resolveSlashInput(content);
|
|
746
|
+
if (slash?.kind === "template") {
|
|
747
|
+
// Inject the prompt-template command as a user message to the agent, then
|
|
748
|
+
// run as a normal prompt (push message + agent loop).
|
|
749
|
+
const userMessage = { role: "user", content: slash.fullPrompt };
|
|
750
|
+
this.messages.push(userMessage);
|
|
751
|
+
await this.persistMessage(userMessage);
|
|
752
|
+
this.lastPersistedIndex = this.messages.length;
|
|
753
|
+
await this.runLoop();
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
if (slash?.kind === "command") {
|
|
588
757
|
const cmdContext = this.createSlashCommandContext();
|
|
589
758
|
const result = await this.slashCommands.execute(content, cmdContext);
|
|
590
759
|
if (result) {
|
|
@@ -702,6 +871,8 @@ export class AgentSession {
|
|
|
702
871
|
this.idealReviewPhase = "idle";
|
|
703
872
|
this.loopBreakInjected = 0;
|
|
704
873
|
this.regroundingInjected = false;
|
|
874
|
+
this.runStartedAt = Date.now();
|
|
875
|
+
this.processGateInjected = 0;
|
|
705
876
|
this.compactionOccurred = false;
|
|
706
877
|
this.originalRequest = originalRequest;
|
|
707
878
|
}
|
|
@@ -893,6 +1064,17 @@ export class AgentSession {
|
|
|
893
1064
|
const childCompletionFollowUp = buildSubAgentCompletionFollowUp(this.subAgentManager);
|
|
894
1065
|
if (childCompletionFollowUp)
|
|
895
1066
|
return childCompletionFollowUp;
|
|
1067
|
+
// Background processes started this run and never read block completion:
|
|
1068
|
+
// their progress/exit checkpoints only land on the steering path, which an
|
|
1069
|
+
// agent about to stop never reaches.
|
|
1070
|
+
const processFollowUp = buildProcessCompletionFollowUp(this.processManager?.list() ?? [], this.runStartedAt, this.processGateInjected);
|
|
1071
|
+
if (processFollowUp) {
|
|
1072
|
+
this.processGateInjected += 1;
|
|
1073
|
+
log("INFO", "process-gate", "Injecting background-process completion gate", {
|
|
1074
|
+
injected: String(this.processGateInjected),
|
|
1075
|
+
});
|
|
1076
|
+
return processFollowUp;
|
|
1077
|
+
}
|
|
896
1078
|
if (this.opts.selfCorrectionHooks === false || this.idealReviewSuppressed)
|
|
897
1079
|
return null;
|
|
898
1080
|
if (this.idealReviewPhase === "reviewing") {
|
|
@@ -1358,6 +1540,8 @@ export class AgentSession {
|
|
|
1358
1540
|
// re-adding. Some tools may already have been promoted out of the catalog.
|
|
1359
1541
|
this.tools = this.tools.filter((t) => !t.name.startsWith("mcp__"));
|
|
1360
1542
|
this.mcpCatalog?.removeWhere((name) => name.startsWith("mcp__"));
|
|
1543
|
+
this.liveMcpTools.clear();
|
|
1544
|
+
this.cachedMcpToolServers.clear();
|
|
1361
1545
|
this.addMcpTools(mcpTools);
|
|
1362
1546
|
}
|
|
1363
1547
|
catch (err) {
|
|
@@ -1422,6 +1606,11 @@ export class AgentSession {
|
|
|
1422
1606
|
return;
|
|
1423
1607
|
}
|
|
1424
1608
|
this.providerContext = null;
|
|
1609
|
+
// Compaction rewrote the message list, so every transcript anchor recorded
|
|
1610
|
+
// against the old indices must move with it — otherwise the markers are
|
|
1611
|
+
// re-persisted pointing at positions that no longer mean anything and
|
|
1612
|
+
// replay far below where they happened (or past the end).
|
|
1613
|
+
this.remapMarkerAnchors(result.result.anchorRemap);
|
|
1425
1614
|
// Transient sessions (Ken chat/autopilot, subagent spawns) must NEVER touch
|
|
1426
1615
|
// the session store: without this guard, the first auto-compaction called
|
|
1427
1616
|
// sessionManager.create() and assigned a real sessionPath, silently turning
|
|
@@ -1847,6 +2036,29 @@ export class AgentSession {
|
|
|
1847
2036
|
getAutopilotMarkers() {
|
|
1848
2037
|
return this.autopilotMarkers;
|
|
1849
2038
|
}
|
|
2039
|
+
/** Non-system messages that are actually on disk. Transcript markers anchor
|
|
2040
|
+
* against this (not the in-memory list, which can run ahead after a failed
|
|
2041
|
+
* run), so hosts computing marker-derived values must use the same base. */
|
|
2042
|
+
getPersistedTranscriptCount() {
|
|
2043
|
+
return this.persistedTranscriptCount();
|
|
2044
|
+
}
|
|
2045
|
+
/**
|
|
2046
|
+
* Rebase every transcript anchor (Ken turns, autopilot verdicts, app markers)
|
|
2047
|
+
* onto a freshly compacted message list. Called right after `this.messages`
|
|
2048
|
+
* is replaced and before the markers are re-persisted into the continuation
|
|
2049
|
+
* file, so the new file carries positions that match its own transcript.
|
|
2050
|
+
*/
|
|
2051
|
+
remapMarkerAnchors(remap) {
|
|
2052
|
+
if (!remap)
|
|
2053
|
+
return;
|
|
2054
|
+
const move = (payload) => ({
|
|
2055
|
+
...payload,
|
|
2056
|
+
afterMessageCount: remapAnchorForCompaction(payload.afterMessageCount, remap),
|
|
2057
|
+
});
|
|
2058
|
+
this.kenTurns = this.kenTurns.map(move);
|
|
2059
|
+
this.autopilotMarkers = this.autopilotMarkers.map(move);
|
|
2060
|
+
this.appMarkers = this.appMarkers.map(move);
|
|
2061
|
+
}
|
|
1850
2062
|
/**
|
|
1851
2063
|
* Record one Ken Kai (mentor agent) turn against this build session: the
|
|
1852
2064
|
* user's question + Ken's reply. Kept in memory for the live transcript and
|
|
@@ -1887,7 +2099,7 @@ export class AgentSession {
|
|
|
1887
2099
|
id: crypto.randomUUID(),
|
|
1888
2100
|
parentId: null,
|
|
1889
2101
|
timestamp: new Date().toISOString(),
|
|
1890
|
-
data: payload,
|
|
2102
|
+
data: stripRecordedPosition(payload),
|
|
1891
2103
|
};
|
|
1892
2104
|
await this.sessionManager.appendEntry(this.sessionPath, entry);
|
|
1893
2105
|
}
|
|
@@ -1935,7 +2147,7 @@ export class AgentSession {
|
|
|
1935
2147
|
id: crypto.randomUUID(),
|
|
1936
2148
|
parentId: null,
|
|
1937
2149
|
timestamp: new Date().toISOString(),
|
|
1938
|
-
data: payload,
|
|
2150
|
+
data: stripRecordedPosition(payload),
|
|
1939
2151
|
};
|
|
1940
2152
|
await this.sessionManager.appendEntry(this.sessionPath, entry);
|
|
1941
2153
|
}
|
|
@@ -1984,7 +2196,7 @@ export class AgentSession {
|
|
|
1984
2196
|
id: crypto.randomUUID(),
|
|
1985
2197
|
parentId: null,
|
|
1986
2198
|
timestamp: new Date().toISOString(),
|
|
1987
|
-
data: payload,
|
|
2199
|
+
data: stripRecordedPosition(payload),
|
|
1988
2200
|
};
|
|
1989
2201
|
await this.sessionManager.appendEntry(this.sessionPath, entry);
|
|
1990
2202
|
}
|
|
@@ -2117,11 +2329,14 @@ export class AgentSession {
|
|
|
2117
2329
|
legacyLabel || loaded.header.preview || findUserSessionPrompt(loadedMessages);
|
|
2118
2330
|
// Restore Ken's advisory turns (custom entries, not on the message branch) so
|
|
2119
2331
|
// they reappear in the transcript and survive into the continuation file.
|
|
2120
|
-
|
|
2332
|
+
// The leaf is passed so each marker also carries its FILE-order position,
|
|
2333
|
+
// the fallback used when a legacy anchor is out of range (see
|
|
2334
|
+
// RecordedPosition).
|
|
2335
|
+
this.kenTurns = this.sessionManager.getKenTurns(loaded.entries, loaded.header.leafId);
|
|
2121
2336
|
// Restore autopilot verdict markers the same way (not on the message DAG).
|
|
2122
|
-
this.autopilotMarkers = this.sessionManager.getAutopilotMarkers(loaded.entries);
|
|
2337
|
+
this.autopilotMarkers = this.sessionManager.getAutopilotMarkers(loaded.entries, loaded.header.leafId);
|
|
2123
2338
|
// Restore app transcript markers (plan banner / task header / errors / hints).
|
|
2124
|
-
this.appMarkers = this.sessionManager.getAppMarkers(loaded.entries);
|
|
2339
|
+
this.appMarkers = this.sessionManager.getAppMarkers(loaded.entries, loaded.header.leafId);
|
|
2125
2340
|
this.turnMetrics = this.sessionManager.getTurnMetrics(loaded.entries);
|
|
2126
2341
|
// Track the current leaf for subsequent entries
|
|
2127
2342
|
this.currentLeafId = loaded.header.leafId;
|
|
@@ -2169,6 +2384,9 @@ export class AgentSession {
|
|
|
2169
2384
|
signal: this.opts.signal,
|
|
2170
2385
|
});
|
|
2171
2386
|
this.messages = compacted.messages;
|
|
2387
|
+
// Same anchor rebase as compact(): the restored markers were recorded
|
|
2388
|
+
// against the pre-compaction transcript.
|
|
2389
|
+
this.remapMarkerAnchors(compacted.result.anchorRemap);
|
|
2172
2390
|
log("INFO", "session", `Auto-compaction complete`, {
|
|
2173
2391
|
before: String(compacted.result.originalCount),
|
|
2174
2392
|
after: String(compacted.result.newCount),
|
|
@@ -2275,7 +2493,58 @@ export class AgentSession {
|
|
|
2275
2493
|
addDirectory: (dir) => this.addDirectory(dir),
|
|
2276
2494
|
removeDirectory: (dir) => this.removeDirectory(dir),
|
|
2277
2495
|
getAdditionalRoots: () => this.getAdditionalRoots(),
|
|
2496
|
+
importTranscript: async (filePath) => {
|
|
2497
|
+
const result = await this.importForeignTranscript(filePath);
|
|
2498
|
+
return result.ok
|
|
2499
|
+
? `Imported ${result.messageCount} message(s) from a ${result.format} transcript into ${result.cwd}.\n` +
|
|
2500
|
+
`Dropped: ${result.dropped}.\n` +
|
|
2501
|
+
`Resume it with /resume (session ${result.sessionId.slice(0, 8)}).`
|
|
2502
|
+
: `Import failed: ${result.error}`;
|
|
2503
|
+
},
|
|
2278
2504
|
};
|
|
2279
2505
|
}
|
|
2506
|
+
/**
|
|
2507
|
+
* Import a Claude Code / Codex / Cursor transcript as a resumable GG Coder
|
|
2508
|
+
* session in this session's sessions directory. Never throws — a bad path or
|
|
2509
|
+
* an unrecognized format comes back as `{ ok: false, error }` so both the CLI
|
|
2510
|
+
* and the desktop app can show it verbatim.
|
|
2511
|
+
*/
|
|
2512
|
+
async importForeignTranscript(filePath, opts = {}) {
|
|
2513
|
+
try {
|
|
2514
|
+
const imported = await importForeignSession({
|
|
2515
|
+
filePath: resolveHomePath(filePath),
|
|
2516
|
+
sessionManager: this.sessionManager,
|
|
2517
|
+
provider: this.provider,
|
|
2518
|
+
model: this.model,
|
|
2519
|
+
cwd: opts.cwd ?? undefined,
|
|
2520
|
+
});
|
|
2521
|
+
log("INFO", "import", "Imported foreign transcript", {
|
|
2522
|
+
format: imported.format,
|
|
2523
|
+
messages: String(imported.messageCount),
|
|
2524
|
+
});
|
|
2525
|
+
return {
|
|
2526
|
+
ok: true,
|
|
2527
|
+
sessionId: imported.sessionId,
|
|
2528
|
+
sessionPath: imported.sessionPath,
|
|
2529
|
+
cwd: imported.cwd,
|
|
2530
|
+
format: imported.format,
|
|
2531
|
+
messageCount: imported.messageCount,
|
|
2532
|
+
dropped: describeDropped(imported.dropped),
|
|
2533
|
+
...(imported.preview ? { preview: imported.preview } : {}),
|
|
2534
|
+
};
|
|
2535
|
+
}
|
|
2536
|
+
catch (err) {
|
|
2537
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
/** Expand a leading `~` so `/import ~/.codex/...` works from any shell. */
|
|
2542
|
+
function resolveHomePath(filePath) {
|
|
2543
|
+
if (filePath === "~")
|
|
2544
|
+
return os.homedir();
|
|
2545
|
+
if (filePath.startsWith("~/") || filePath.startsWith("~\\")) {
|
|
2546
|
+
return path.join(os.homedir(), filePath.slice(2));
|
|
2547
|
+
}
|
|
2548
|
+
return filePath;
|
|
2280
2549
|
}
|
|
2281
2550
|
//# sourceMappingURL=agent-session.js.map
|