@kenkaiiii/ggcoder 5.20.5 → 5.22.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 +20 -8
- package/dist/app-sidecar.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +16 -6
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session-compaction.test.js +19 -0
- package/dist/core/agent-session-compaction.test.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +1 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/compactor.d.ts.map +1 -1
- package/dist/core/compaction/compactor.js +20 -11
- package/dist/core/compaction/compactor.js.map +1 -1
- package/dist/core/compaction/compactor.test.js +13 -0
- package/dist/core/compaction/compactor.test.js.map +1 -1
- package/dist/core/event-bus.d.ts +1 -0
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/verify-commands.d.ts.map +1 -1
- package/dist/core/verify-commands.js +1 -6
- package/dist/core/verify-commands.js.map +1 -1
- package/dist/core/verify-commands.test.js +1 -5
- package/dist/core/verify-commands.test.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/system-prompt.d.ts.map +1 -1
- package/dist/system-prompt.js +10 -12
- package/dist/system-prompt.js.map +1 -1
- package/dist/system-prompt.test.js +19 -3
- package/dist/system-prompt.test.js.map +1 -1
- package/package.json +4 -4
package/dist/app-sidecar.js
CHANGED
|
@@ -43,7 +43,7 @@ import { loginKimi } from "./core/oauth/kimi.js";
|
|
|
43
43
|
import { AUTH_PROVIDERS } from "./core/auth-providers.js";
|
|
44
44
|
import { ensureAppDirs, loadSavedSettings } from "./config.js";
|
|
45
45
|
import { SettingsManager } from "./core/settings-manager.js";
|
|
46
|
-
import { getModel,
|
|
46
|
+
import { getModel, getDefaultThinkingLevel, getContextWindow, MODELS, } from "./core/model-registry.js";
|
|
47
47
|
import { resolveStartOrFallback } from "./core/resolve-start.js";
|
|
48
48
|
import { getGitBranch, getGitDirtyFileCount, isGitRepo } from "./utils/git.js";
|
|
49
49
|
import { extractPlanSteps } from "./utils/plan-steps.js";
|
|
@@ -567,12 +567,15 @@ async function main() {
|
|
|
567
567
|
const usageRateLimitedUntil = new Map();
|
|
568
568
|
const USAGE_RATE_LIMIT_BACKOFF_MS = 5 * 60_000;
|
|
569
569
|
async function fetchUsageProvider(provider) {
|
|
570
|
-
const displayName = provider === "anthropic" ? "Anthropic" : "Codex";
|
|
571
|
-
|
|
570
|
+
const displayName = provider === "anthropic" ? "Anthropic" : provider === "openai" ? "Codex" : "Kimi";
|
|
571
|
+
// Kimi plan usage is tracked on the OAuth credential specifically — the
|
|
572
|
+
// Moonshot platform API key is metered per-token, not per plan window.
|
|
573
|
+
const authKey = provider === "moonshot" ? MOONSHOT_OAUTH_KEY : provider;
|
|
574
|
+
if (!(await auth.hasProviderAuth(authKey))) {
|
|
572
575
|
return { provider, displayName, connected: false, windows: [], fetchedAt: Date.now() };
|
|
573
576
|
}
|
|
574
577
|
try {
|
|
575
|
-
let credentials = await auth.resolveCredentials(
|
|
578
|
+
let credentials = await auth.resolveCredentials(authKey);
|
|
576
579
|
try {
|
|
577
580
|
const snapshot = {
|
|
578
581
|
...(await fetchSubscriptionUsage(provider, credentials)),
|
|
@@ -585,7 +588,7 @@ async function main() {
|
|
|
585
588
|
// A provider can revoke an access token before its stored expiry. Refresh
|
|
586
589
|
// once on 401, matching inference auth recovery, then retry the usage call.
|
|
587
590
|
if (error instanceof SubscriptionUsageError && error.status === 401) {
|
|
588
|
-
credentials = await auth.resolveCredentials(
|
|
591
|
+
credentials = await auth.resolveCredentials(authKey, { forceRefresh: true });
|
|
589
592
|
const snapshot = {
|
|
590
593
|
...(await fetchSubscriptionUsage(provider, credentials)),
|
|
591
594
|
connected: true,
|
|
@@ -605,7 +608,7 @@ async function main() {
|
|
|
605
608
|
if (error instanceof SubscriptionUsageError && error.status === 429) {
|
|
606
609
|
usageRateLimitedUntil.set(provider, Date.now() + USAGE_RATE_LIMIT_BACKOFF_MS);
|
|
607
610
|
}
|
|
608
|
-
const connected = await auth.hasProviderAuth(
|
|
611
|
+
const connected = await auth.hasProviderAuth(authKey);
|
|
609
612
|
return {
|
|
610
613
|
provider,
|
|
611
614
|
displayName,
|
|
@@ -735,7 +738,7 @@ async function main() {
|
|
|
735
738
|
if (method === "GET" && (url === "/usage" || url.startsWith("/usage?"))) {
|
|
736
739
|
void (async () => {
|
|
737
740
|
const provider = new URL(url, `http://${host}`).searchParams.get("provider");
|
|
738
|
-
if (provider !== "anthropic" && provider !== "openai") {
|
|
741
|
+
if (provider !== "anthropic" && provider !== "openai" && provider !== "moonshot") {
|
|
739
742
|
daemonJson(res, 400, { error: "unsupported usage provider" });
|
|
740
743
|
return;
|
|
741
744
|
}
|
|
@@ -958,6 +961,10 @@ async function createSession(deps, opts) {
|
|
|
958
961
|
// parsing); the daemon owns the real listen host.
|
|
959
962
|
const host = "127.0.0.1";
|
|
960
963
|
const saved = loadSavedSettings(paths.settingsFile);
|
|
964
|
+
// Native login/logout and other live sessions share auth.json. Refresh the
|
|
965
|
+
// daemon-level snapshot before choosing this session's provider so a project
|
|
966
|
+
// never boots against credentials that were just replaced or disconnected.
|
|
967
|
+
await auth.load();
|
|
961
968
|
// Per-project model/thinking prefs win over the shared global settings.json:
|
|
962
969
|
// each window (one project cwd) restores its own selection instead of every
|
|
963
970
|
// window reading the same single global slot that the last writer clobbered
|
|
@@ -976,9 +983,14 @@ async function createSession(deps, opts) {
|
|
|
976
983
|
});
|
|
977
984
|
}
|
|
978
985
|
// Per-project thinking prefs win over the global settings.json fallback.
|
|
986
|
+
// With no saved level, the default follows the active credential's endpoint:
|
|
987
|
+
// Kimi K3 on the OAuth coding endpoint starts at its declared default (high),
|
|
988
|
+
// matching the official kimi-code CLI's plan-usage profile.
|
|
979
989
|
const thinkEnabled = projectPrefs?.thinkingEnabled ?? saved.thinkingEnabled;
|
|
980
990
|
const thinkingLevel = thinkEnabled
|
|
981
|
-
? (projectPrefs?.thinkingLevel ??
|
|
991
|
+
? (projectPrefs?.thinkingLevel ??
|
|
992
|
+
saved.thinkingLevel ??
|
|
993
|
+
getDefaultThinkingLevel(model, { baseUrl: auth.getStoredBaseUrl(provider) }))
|
|
982
994
|
: undefined;
|
|
983
995
|
// ── SSE fan-out (declared before the session so plan callbacks can use it) ─
|
|
984
996
|
const clients = new Set();
|