@kenkaiiii/ggcoder 5.88.1 → 5.90.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/app-settings.d.ts +5 -0
- package/dist/app-sidecar/app-settings.js +13 -0
- package/dist/app-sidecar/app-settings.js.map +1 -1
- package/dist/app-sidecar/history-routes.js +17 -0
- package/dist/app-sidecar/history-routes.js.map +1 -1
- package/dist/app-sidecar/history.d.ts +12 -0
- package/dist/app-sidecar/history.js.map +1 -1
- package/dist/app-sidecar/route-context.d.ts +5 -0
- package/dist/app-sidecar/run-control-routes.js +9 -2
- package/dist/app-sidecar/run-control-routes.js.map +1 -1
- package/dist/app-sidecar/session-routes.js +6 -0
- package/dist/app-sidecar/session-routes.js.map +1 -1
- package/dist/app-sidecar/shell-routes.d.ts +12 -0
- package/dist/app-sidecar/shell-routes.js +133 -0
- package/dist/app-sidecar/shell-routes.js.map +1 -0
- package/dist/app-sidecar/shell-runs.d.ts +103 -0
- package/dist/app-sidecar/shell-runs.js +268 -0
- package/dist/app-sidecar/shell-runs.js.map +1 -0
- package/dist/app-sidecar/shell-suggestions.d.ts +33 -0
- package/dist/app-sidecar/shell-suggestions.js +152 -0
- package/dist/app-sidecar/shell-suggestions.js.map +1 -0
- package/dist/app-sidecar.js +110 -10
- package/dist/app-sidecar.js.map +1 -1
- package/dist/core/agent-session.d.ts +18 -4
- package/dist/core/agent-session.js +73 -29
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/env-delta.d.ts +3 -3
- package/dist/core/env-delta.js +4 -5
- package/dist/core/env-delta.js.map +1 -1
- package/dist/core/language-detector.d.ts +2 -3
- package/dist/core/language-detector.js.map +1 -1
- package/dist/core/prompt-commands.js +1 -1
- package/dist/core/session-manager.d.ts +4 -1
- package/dist/core/session-manager.js +2 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/user-shell-context.d.ts +8 -0
- package/dist/core/user-shell-context.js +12 -0
- package/dist/core/user-shell-context.js.map +1 -0
- package/dist/core/verify-commands.d.ts +1 -1
- package/dist/modes/json-mode.js +5 -0
- package/dist/modes/json-mode.js.map +1 -1
- package/dist/system-prompt.d.ts +4 -3
- package/dist/system-prompt.js +5 -8
- package/dist/system-prompt.js.map +1 -1
- package/dist/tools/bash.d.ts +7 -0
- package/dist/tools/bash.js +10 -3
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +3 -5
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/prompt-hints.d.ts +2 -0
- package/dist/tools/prompt-hints.js +10 -1
- package/dist/tools/prompt-hints.js.map +1 -1
- package/dist/tools/side-web-search.d.ts +30 -0
- package/dist/tools/side-web-search.js +86 -0
- package/dist/tools/side-web-search.js.map +1 -0
- package/dist/tools/steroids.d.ts +7 -6
- package/dist/tools/steroids.js +193 -74
- package/dist/tools/steroids.js.map +1 -1
- package/dist/tools/web-fetch.d.ts +8 -0
- package/dist/tools/web-fetch.js +123 -17
- package/dist/tools/web-fetch.js.map +1 -1
- package/dist/tools/web-search.d.ts +3 -2
- package/dist/tools/web-search.js +25 -1
- package/dist/tools/web-search.js.map +1 -1
- package/dist/ui/App.js +22 -20
- package/dist/ui/App.js.map +1 -1
- package/dist/ui/language-pack-update.d.ts +25 -0
- package/dist/ui/language-pack-update.js +19 -0
- package/dist/ui/language-pack-update.js.map +1 -0
- package/package.json +4 -4
- package/dist/core/setup-history.d.ts +0 -6
- package/dist/core/setup-history.js +0 -55
- package/dist/core/setup-history.js.map +0 -1
- package/dist/core/style-packs/index.d.ts +0 -18
- package/dist/core/style-packs/index.js +0 -60
- package/dist/core/style-packs/index.js.map +0 -1
- package/dist/core/style-packs/packs.d.ts +0 -8
- package/dist/core/style-packs/packs.js +0 -188
- package/dist/core/style-packs/packs.js.map +0 -1
|
@@ -465,9 +465,9 @@ export declare class AgentSession {
|
|
|
465
465
|
/** Latest plan notice appended — re-announced if compaction drops it. */
|
|
466
466
|
private lastPlanNotice;
|
|
467
467
|
/**
|
|
468
|
-
* Project languages whose
|
|
469
|
-
*
|
|
470
|
-
*
|
|
468
|
+
* Project languages whose verify commands are in the standard prompt.
|
|
469
|
+
* Only ever grows within a session (same policy as the terminal UI): a
|
|
470
|
+
* section disappearing mid-task would rewrite the cached prefix
|
|
471
471
|
* for no benefit.
|
|
472
472
|
*/
|
|
473
473
|
private activeLanguages;
|
|
@@ -514,6 +514,8 @@ export declare class AgentSession {
|
|
|
514
514
|
* dropped as out-of-range. Anchoring to the persisted prefix keeps resume
|
|
515
515
|
* placement 1:1 with where the row appeared live.
|
|
516
516
|
*/
|
|
517
|
+
/** Commands the user ran themselves, held until their next message. */
|
|
518
|
+
private pendingUserShell;
|
|
517
519
|
private persistedTranscriptCount;
|
|
518
520
|
/** Current leaf entry ID in the session DAG — used to chain parentIds for branching. */
|
|
519
521
|
private currentLeafId;
|
|
@@ -595,6 +597,7 @@ export declare class AgentSession {
|
|
|
595
597
|
* one discovery turn, a false hit only the ~2.5k-token schema.
|
|
596
598
|
*/
|
|
597
599
|
private attachWebSearchIfAsked;
|
|
600
|
+
private runSideWebSearch;
|
|
598
601
|
/** Append a deferred built-in to the live tool list (append-only). */
|
|
599
602
|
private promoteDeferredBuiltin;
|
|
600
603
|
private wrapToPromote;
|
|
@@ -870,6 +873,17 @@ export declare class AgentSession {
|
|
|
870
873
|
* as steering. Returns the new queue length. No-op semantics are the caller's
|
|
871
874
|
* concern. */
|
|
872
875
|
queueMessage(text: string, attachments?: SessionAttachment[]): number;
|
|
876
|
+
/**
|
|
877
|
+
* Hold the output of a command the user ran themselves (`!cmd` in the app)
|
|
878
|
+
* so it reaches the agent with their next message: a prompt, or a message
|
|
879
|
+
* queued as steering. Never on its own, and never mid-run without one.
|
|
880
|
+
*/
|
|
881
|
+
addUserShellContext(runId: string, text: string): void;
|
|
882
|
+
/** Run ids of user commands still waiting for the next message. */
|
|
883
|
+
getPendingUserShellRunIds(): string[];
|
|
884
|
+
private takeUserShellContext;
|
|
885
|
+
/** Persist pending user command output just ahead of the human message. */
|
|
886
|
+
private deliverUserShellContext;
|
|
873
887
|
/** Pending queued messages (id + text), oldest first, for client display. */
|
|
874
888
|
listQueuedMessages(): Array<{
|
|
875
889
|
id: string;
|
|
@@ -1034,7 +1048,7 @@ export declare class AgentSession {
|
|
|
1034
1048
|
private prepareSystemPromptForRequest;
|
|
1035
1049
|
private hasReply;
|
|
1036
1050
|
/**
|
|
1037
|
-
* Give the model
|
|
1051
|
+
* Give the model verify commands for languages that appeared after its prompt
|
|
1038
1052
|
* was cached (e.g. the previous task scaffolded a TypeScript project), as a
|
|
1039
1053
|
* hidden message appended to the history rather than a prompt re-render that
|
|
1040
1054
|
* would throw away the whole cache. Runs just before a new user message is
|
|
@@ -15,6 +15,7 @@ import { SettingsManager } from "./settings-manager.js";
|
|
|
15
15
|
import { AuthStorage } from "./auth-storage.js";
|
|
16
16
|
import { dualAuthProvider } from "@kenkaiiii/gg-core";
|
|
17
17
|
import { getClaudeCliUserAgent } from "./claude-code-version.js";
|
|
18
|
+
import { runSideWebSearch, SIDE_SEARCH_MODEL, } from "../tools/side-web-search.js";
|
|
18
19
|
import { kimiCodingHeaders, isKimiCodingEndpoint } from "./oauth/kimi.js";
|
|
19
20
|
import { isGrokCliEndpoint } from "./oauth/xai.js";
|
|
20
21
|
import { SessionManager, } from "./session-manager.js";
|
|
@@ -57,6 +58,7 @@ import { buildLoopBreakMessage } from "./loop-breaker.js";
|
|
|
57
58
|
import { buildRegroundingMessage, requestTextForRegrounding } from "./regrounding.js";
|
|
58
59
|
import { buildSemanticLoopJudgePrompt, buildSemanticLoopMessage, parseSemanticLoopVerdict, SEMANTIC_LOOP_JUDGE_TIMEOUT_MS, withJudgeTimeout, } from "./semantic-loop-check.js";
|
|
59
60
|
import { buildEnvDeltaMessage, buildLanguageUpdateMessage } from "./env-delta.js";
|
|
61
|
+
import { buildUserShellContextText } from "./user-shell-context.js";
|
|
60
62
|
import { buildPlanStateMessage, samePlanState } from "./plan-delta.js";
|
|
61
63
|
import { listProjectFiles } from "./project-files.js";
|
|
62
64
|
import { wrapSteeringText, buildNotificationSteeringText, buildIdleWakeNotificationText, STEERING_PREFIX, } from "./steering.js";
|
|
@@ -381,9 +383,9 @@ export class AgentSession {
|
|
|
381
383
|
/** Latest plan notice appended — re-announced if compaction drops it. */
|
|
382
384
|
lastPlanNotice = null;
|
|
383
385
|
/**
|
|
384
|
-
* Project languages whose
|
|
385
|
-
*
|
|
386
|
-
*
|
|
386
|
+
* Project languages whose verify commands are in the standard prompt.
|
|
387
|
+
* Only ever grows within a session (same policy as the terminal UI): a
|
|
388
|
+
* section disappearing mid-task would rewrite the cached prefix
|
|
387
389
|
* for no benefit.
|
|
388
390
|
*/
|
|
389
391
|
activeLanguages = new Set();
|
|
@@ -430,6 +432,8 @@ export class AgentSession {
|
|
|
430
432
|
* dropped as out-of-range. Anchoring to the persisted prefix keeps resume
|
|
431
433
|
* placement 1:1 with where the row appeared live.
|
|
432
434
|
*/
|
|
435
|
+
/** Commands the user ran themselves, held until their next message. */
|
|
436
|
+
pendingUserShell = [];
|
|
433
437
|
persistedTranscriptCount() {
|
|
434
438
|
return this.messages.slice(0, this.lastPersistedIndex).filter((m) => m.role !== "system")
|
|
435
439
|
.length;
|
|
@@ -579,6 +583,7 @@ export class AgentSession {
|
|
|
579
583
|
allowUnixSockets: this.settingsManager.get("sandboxAllowUnixSockets"),
|
|
580
584
|
}),
|
|
581
585
|
getUseExternalGrep: () => this.settingsManager.get("grepUseRipgrep"),
|
|
586
|
+
sideWebSearch: (request) => this.runSideWebSearch(request),
|
|
582
587
|
authStorage: this.authStorage,
|
|
583
588
|
onFileMutated: (filePath) => {
|
|
584
589
|
const relative = path.relative(this.cwd, filePath) || path.basename(filePath);
|
|
@@ -938,11 +943,9 @@ export class AgentSession {
|
|
|
938
943
|
nativeWebSearchOn() {
|
|
939
944
|
if (this.provider !== "anthropic")
|
|
940
945
|
return true;
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
return true;
|
|
945
|
-
// A restored, branched or compacted conversation can already hold native
|
|
946
|
+
// Anthropic search runs inside the client web_search tool as a side
|
|
947
|
+
// request (runSideWebSearch): its result pages cost 11–20k cache-write
|
|
948
|
+
// tokens each in the main context. A restored, branched or compacted conversation can already hold native
|
|
946
949
|
// `web_search` blocks from when the tool was attached. Anthropic rejects
|
|
947
950
|
// any request whose history references a server tool that is not declared
|
|
948
951
|
// (400 "`server_tool_use` block references `web_search`…"), so the history
|
|
@@ -958,7 +961,7 @@ export class AgentSession {
|
|
|
958
961
|
* one discovery turn, a false hit only the ~2.5k-token schema.
|
|
959
962
|
*/
|
|
960
963
|
attachWebSearchIfAsked(content) {
|
|
961
|
-
if (this.provider !== "anthropic" || this.
|
|
964
|
+
if (this.provider !== "anthropic" || this.tools.some((t) => t.name === "web_search"))
|
|
962
965
|
return;
|
|
963
966
|
const text = typeof content === "string"
|
|
964
967
|
? content
|
|
@@ -970,6 +973,18 @@ export class AgentSession {
|
|
|
970
973
|
if (WEB_INTENT.test(text))
|
|
971
974
|
this.promoteDeferredBuiltin("web_search");
|
|
972
975
|
}
|
|
976
|
+
async runSideWebSearch(request) {
|
|
977
|
+
if (this.provider !== "anthropic")
|
|
978
|
+
return null;
|
|
979
|
+
const creds = await this.authStorage.resolveCredentials("anthropic", {
|
|
980
|
+
storageKeys: getAuthStorageKeys("anthropic", SIDE_SEARCH_MODEL),
|
|
981
|
+
});
|
|
982
|
+
return await runSideWebSearch(request, {
|
|
983
|
+
apiKey: creds.accessToken,
|
|
984
|
+
baseUrl: this.baseUrl ?? creds.baseUrl,
|
|
985
|
+
userAgent: await getClaudeCliUserAgent(),
|
|
986
|
+
});
|
|
987
|
+
}
|
|
973
988
|
/** Append a deferred built-in to the live tool list (append-only). */
|
|
974
989
|
promoteDeferredBuiltin(name) {
|
|
975
990
|
if (!this.deferredBuiltinToolNames.includes(name))
|
|
@@ -1082,6 +1097,8 @@ export class AgentSession {
|
|
|
1082
1097
|
// Prompt templates remain human-originated: the user invoked the command.
|
|
1083
1098
|
const userMessage = { role: "user", content: slash.fullPrompt, provenance };
|
|
1084
1099
|
await this.announceNewLanguages();
|
|
1100
|
+
if (provenance.source === "human")
|
|
1101
|
+
await this.deliverUserShellContext();
|
|
1085
1102
|
this.messages.push(userMessage);
|
|
1086
1103
|
await this.persistMessage(userMessage);
|
|
1087
1104
|
this.lastPersistedIndex = this.messages.length;
|
|
@@ -1099,6 +1116,8 @@ export class AgentSession {
|
|
|
1099
1116
|
// Push user message
|
|
1100
1117
|
const userMessage = { role: "user", content, provenance };
|
|
1101
1118
|
await this.announceNewLanguages();
|
|
1119
|
+
if (provenance.source === "human")
|
|
1120
|
+
await this.deliverUserShellContext();
|
|
1102
1121
|
this.messages.push(userMessage);
|
|
1103
1122
|
await this.persistMessage(userMessage);
|
|
1104
1123
|
this.lastPersistedIndex = this.messages.length;
|
|
@@ -1128,6 +1147,7 @@ export class AgentSession {
|
|
|
1128
1147
|
provenance: { source: "human", kind: "prompt", visibility: "transcript" },
|
|
1129
1148
|
};
|
|
1130
1149
|
await this.announceNewLanguages();
|
|
1150
|
+
await this.deliverUserShellContext();
|
|
1131
1151
|
this.messages.push(userMessage);
|
|
1132
1152
|
await this.persistMessage(userMessage);
|
|
1133
1153
|
this.lastPersistedIndex = this.messages.length;
|
|
@@ -1437,9 +1457,11 @@ export class AgentSession {
|
|
|
1437
1457
|
];
|
|
1438
1458
|
return { role: "user", content: parts, provenance };
|
|
1439
1459
|
});
|
|
1460
|
+
const userShell = this.takeUserShellContext();
|
|
1440
1461
|
return [
|
|
1441
1462
|
...(environmentDelta ? [environmentDelta] : []),
|
|
1442
1463
|
...(planNotice ? [planNotice] : []),
|
|
1464
|
+
...(userShell ? [userShell] : []),
|
|
1443
1465
|
...steeringMessages,
|
|
1444
1466
|
...(notificationMessage ? [notificationMessage] : []),
|
|
1445
1467
|
];
|
|
@@ -2175,8 +2197,9 @@ export class AgentSession {
|
|
|
2175
2197
|
// fallback key, not the model's first preference).
|
|
2176
2198
|
const badKey = (await this.authStorage.pickStorageKey(this.currentAuthStorageKeys())) ??
|
|
2177
2199
|
this.currentAuthStorageKeys()[0];
|
|
2178
|
-
|
|
2179
|
-
|
|
2200
|
+
const cleared = await this.authStorage.clearRejectedApiKey(badKey);
|
|
2201
|
+
log("WARN", "auth", `Got 401 for ${this.provider} (${badKey}) — ` +
|
|
2202
|
+
(cleared ? "API key is invalid or revoked" : "key rejected, kept on file"));
|
|
2180
2203
|
return true;
|
|
2181
2204
|
};
|
|
2182
2205
|
try {
|
|
@@ -2349,25 +2372,15 @@ export class AgentSession {
|
|
|
2349
2372
|
}
|
|
2350
2373
|
// Update provider-specific tools when provider changes
|
|
2351
2374
|
if (provider && provider !== prevProvider) {
|
|
2352
|
-
//
|
|
2353
|
-
//
|
|
2375
|
+
// The client web_search tool serves every provider (on Anthropic it
|
|
2376
|
+
// runs the native search as a side request), so a switch only adds it
|
|
2377
|
+
// when an untiered session lacks it.
|
|
2354
2378
|
const hasWebSearch = this.tools.some((t) => t.name === "web_search");
|
|
2355
|
-
if (this.deferredBuiltinToolNames.includes("web_search")) {
|
|
2356
|
-
// Tiered: the client tool lives in the catalog for every provider and,
|
|
2357
|
-
// once promoted, is swapped for the native server tool by the Anthropic
|
|
2358
|
-
// transport. Nothing to add or remove — doing so would either load the
|
|
2359
|
-
// schema eagerly or take away a capability the model already has.
|
|
2360
|
-
}
|
|
2361
|
-
else if (this.provider === "anthropic" && hasWebSearch) {
|
|
2362
|
-
// Switching TO anthropic — remove client-side web_search (server-side handles it)
|
|
2363
|
-
this.tools = this.tools.filter((t) => t.name !== "web_search");
|
|
2364
|
-
}
|
|
2365
|
-
else if (this.provider !== "anthropic" && !hasWebSearch) {
|
|
2366
|
-
// Switching FROM anthropic — add client-side web_search
|
|
2379
|
+
if (!this.deferredBuiltinToolNames.includes("web_search") && !hasWebSearch) {
|
|
2367
2380
|
this.tools.push(createWebSearchTool(() => ({
|
|
2368
2381
|
mode: this.settingsManager.get("networkMode"),
|
|
2369
2382
|
allow: this.settingsManager.get("networkAllow"),
|
|
2370
|
-
})));
|
|
2383
|
+
}), (request) => this.runSideWebSearch(request)));
|
|
2371
2384
|
}
|
|
2372
2385
|
// Reconnect MCP servers ONLY when GLM is involved on either side — GLM
|
|
2373
2386
|
// is the only provider with a different server set (Z.AI tools), so a
|
|
@@ -3154,6 +3167,37 @@ export class AgentSession {
|
|
|
3154
3167
|
listener();
|
|
3155
3168
|
return this.userQueue.length;
|
|
3156
3169
|
}
|
|
3170
|
+
/**
|
|
3171
|
+
* Hold the output of a command the user ran themselves (`!cmd` in the app)
|
|
3172
|
+
* so it reaches the agent with their next message: a prompt, or a message
|
|
3173
|
+
* queued as steering. Never on its own, and never mid-run without one.
|
|
3174
|
+
*/
|
|
3175
|
+
addUserShellContext(runId, text) {
|
|
3176
|
+
if (text.trim())
|
|
3177
|
+
this.pendingUserShell.push({ runId, text });
|
|
3178
|
+
}
|
|
3179
|
+
/** Run ids of user commands still waiting for the next message. */
|
|
3180
|
+
getPendingUserShellRunIds() {
|
|
3181
|
+
return this.pendingUserShell.map((entry) => entry.runId);
|
|
3182
|
+
}
|
|
3183
|
+
takeUserShellContext() {
|
|
3184
|
+
if (this.pendingUserShell.length === 0)
|
|
3185
|
+
return null;
|
|
3186
|
+
const blocks = this.pendingUserShell.splice(0).map((entry) => entry.text);
|
|
3187
|
+
return {
|
|
3188
|
+
role: "user",
|
|
3189
|
+
content: buildUserShellContextText(blocks),
|
|
3190
|
+
provenance: { source: "runtime", kind: "notification", visibility: "hidden" },
|
|
3191
|
+
};
|
|
3192
|
+
}
|
|
3193
|
+
/** Persist pending user command output just ahead of the human message. */
|
|
3194
|
+
async deliverUserShellContext() {
|
|
3195
|
+
const message = this.takeUserShellContext();
|
|
3196
|
+
if (!message)
|
|
3197
|
+
return;
|
|
3198
|
+
this.messages.push(message);
|
|
3199
|
+
await this.persistMessage(message);
|
|
3200
|
+
}
|
|
3157
3201
|
/** Pending queued messages (id + text), oldest first, for client display. */
|
|
3158
3202
|
listQueuedMessages() {
|
|
3159
3203
|
return this.userQueue.map((m) => ({ id: m.id, text: m.text }));
|
|
@@ -3526,7 +3570,7 @@ export class AgentSession {
|
|
|
3526
3570
|
return this.messages.some((m) => m.role === "assistant");
|
|
3527
3571
|
}
|
|
3528
3572
|
/**
|
|
3529
|
-
* Give the model
|
|
3573
|
+
* Give the model verify commands for languages that appeared after its prompt
|
|
3530
3574
|
* was cached (e.g. the previous task scaffolded a TypeScript project), as a
|
|
3531
3575
|
* hidden message appended to the history rather than a prompt re-render that
|
|
3532
3576
|
* would throw away the whole cache. Runs just before a new user message is
|
|
@@ -3555,7 +3599,7 @@ export class AgentSession {
|
|
|
3555
3599
|
this.messages.push(update);
|
|
3556
3600
|
await this.persistMessage(update);
|
|
3557
3601
|
this.lastPersistedIndex = this.messages.length;
|
|
3558
|
-
log("INFO", "language", "Appended
|
|
3602
|
+
log("INFO", "language", "Appended verify commands for new languages", {
|
|
3559
3603
|
added: [...fresh].join(","),
|
|
3560
3604
|
});
|
|
3561
3605
|
}
|
|
@@ -3591,7 +3635,7 @@ export class AgentSession {
|
|
|
3591
3635
|
return false;
|
|
3592
3636
|
}
|
|
3593
3637
|
if (grew) {
|
|
3594
|
-
log("INFO", "language", "
|
|
3638
|
+
log("INFO", "language", "Languages active", {
|
|
3595
3639
|
active: [...this.activeLanguages].join(","),
|
|
3596
3640
|
});
|
|
3597
3641
|
}
|