@kenkaiiii/ggcoder 5.36.0 → 5.38.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.
Files changed (125) hide show
  1. package/dist/app-sidecar-auth-broadcast.test.js +66 -0
  2. package/dist/app-sidecar-auth-broadcast.test.js.map +1 -1
  3. package/dist/app-sidecar.js +108 -38
  4. package/dist/app-sidecar.js.map +1 -1
  5. package/dist/cli/auth.d.ts.map +1 -1
  6. package/dist/cli/auth.js +28 -34
  7. package/dist/cli/auth.js.map +1 -1
  8. package/dist/cli.d.ts.map +1 -1
  9. package/dist/cli.js +12 -1
  10. package/dist/cli.js.map +1 -1
  11. package/dist/config.d.ts +15 -4
  12. package/dist/config.d.ts.map +1 -1
  13. package/dist/config.js +34 -75
  14. package/dist/config.js.map +1 -1
  15. package/dist/config.test.js +19 -11
  16. package/dist/config.test.js.map +1 -1
  17. package/dist/core/agent-session-process-gate.test.js +7 -1
  18. package/dist/core/agent-session-process-gate.test.js.map +1 -1
  19. package/dist/core/agent-session.d.ts +24 -0
  20. package/dist/core/agent-session.d.ts.map +1 -1
  21. package/dist/core/agent-session.js +68 -26
  22. package/dist/core/agent-session.js.map +1 -1
  23. package/dist/core/agents.d.ts +29 -1
  24. package/dist/core/agents.d.ts.map +1 -1
  25. package/dist/core/agents.js +47 -97
  26. package/dist/core/agents.js.map +1 -1
  27. package/dist/core/agents.test.js +85 -5
  28. package/dist/core/agents.test.js.map +1 -1
  29. package/dist/core/auth-providers.d.ts +36 -0
  30. package/dist/core/auth-providers.d.ts.map +1 -1
  31. package/dist/core/auth-providers.js +83 -3
  32. package/dist/core/auth-providers.js.map +1 -1
  33. package/dist/core/bundled-agents.d.ts +3 -0
  34. package/dist/core/bundled-agents.d.ts.map +1 -0
  35. package/dist/core/bundled-agents.js +252 -0
  36. package/dist/core/bundled-agents.js.map +1 -0
  37. package/dist/core/oauth/xai.d.ts +2 -0
  38. package/dist/core/oauth/xai.d.ts.map +1 -0
  39. package/dist/core/oauth/xai.js +4 -0
  40. package/dist/core/oauth/xai.js.map +1 -0
  41. package/dist/core/process-manager-dev-server-repro.test.js +42 -3
  42. package/dist/core/process-manager-dev-server-repro.test.js.map +1 -1
  43. package/dist/core/process-manager-notifications.test.js +23 -13
  44. package/dist/core/process-manager-notifications.test.js.map +1 -1
  45. package/dist/core/process-manager.d.ts +22 -0
  46. package/dist/core/process-manager.d.ts.map +1 -1
  47. package/dist/core/process-manager.js +58 -2
  48. package/dist/core/process-manager.js.map +1 -1
  49. package/dist/core/project-discovery.d.ts.map +1 -1
  50. package/dist/core/project-discovery.js +54 -40
  51. package/dist/core/project-discovery.js.map +1 -1
  52. package/dist/core/session-manager.d.ts.map +1 -1
  53. package/dist/core/session-manager.js +83 -67
  54. package/dist/core/session-manager.js.map +1 -1
  55. package/dist/core/session-storage-fd-leak.test.d.ts +2 -0
  56. package/dist/core/session-storage-fd-leak.test.d.ts.map +1 -0
  57. package/dist/core/session-storage-fd-leak.test.js +116 -0
  58. package/dist/core/session-storage-fd-leak.test.js.map +1 -0
  59. package/dist/core/session-storage.d.ts +20 -0
  60. package/dist/core/session-storage.d.ts.map +1 -1
  61. package/dist/core/session-storage.js +29 -2
  62. package/dist/core/session-storage.js.map +1 -1
  63. package/dist/core/shutdown.d.ts +71 -0
  64. package/dist/core/shutdown.d.ts.map +1 -0
  65. package/dist/core/shutdown.js +144 -0
  66. package/dist/core/shutdown.js.map +1 -0
  67. package/dist/core/shutdown.test.d.ts +2 -0
  68. package/dist/core/shutdown.test.d.ts.map +1 -0
  69. package/dist/core/shutdown.test.js +160 -0
  70. package/dist/core/shutdown.test.js.map +1 -0
  71. package/dist/core/subagent-manager.d.ts +9 -0
  72. package/dist/core/subagent-manager.d.ts.map +1 -1
  73. package/dist/core/subagent-manager.js +45 -12
  74. package/dist/core/subagent-manager.js.map +1 -1
  75. package/dist/core/subagent-manager.test.js +13 -7
  76. package/dist/core/subagent-manager.test.js.map +1 -1
  77. package/dist/modes/agent-home-mode.d.ts.map +1 -1
  78. package/dist/modes/agent-home-mode.js +15 -11
  79. package/dist/modes/agent-home-mode.js.map +1 -1
  80. package/dist/modes/json-mode.d.ts +8 -0
  81. package/dist/modes/json-mode.d.ts.map +1 -1
  82. package/dist/modes/json-mode.js +2 -0
  83. package/dist/modes/json-mode.js.map +1 -1
  84. package/dist/modes/serve-mode.d.ts +2 -1
  85. package/dist/modes/serve-mode.d.ts.map +1 -1
  86. package/dist/modes/serve-mode.js +15 -9
  87. package/dist/modes/serve-mode.js.map +1 -1
  88. package/dist/modes/subagent-worker-mode.d.ts +5 -0
  89. package/dist/modes/subagent-worker-mode.d.ts.map +1 -1
  90. package/dist/modes/subagent-worker-mode.js.map +1 -1
  91. package/dist/system-prompt.d.ts +31 -0
  92. package/dist/system-prompt.d.ts.map +1 -1
  93. package/dist/system-prompt.js +81 -0
  94. package/dist/system-prompt.js.map +1 -1
  95. package/dist/system-prompt.test.js +48 -1
  96. package/dist/system-prompt.test.js.map +1 -1
  97. package/dist/tools/index.d.ts +1 -0
  98. package/dist/tools/index.d.ts.map +1 -1
  99. package/dist/tools/index.js +4 -0
  100. package/dist/tools/index.js.map +1 -1
  101. package/dist/tools/prompt-hints.d.ts +9 -0
  102. package/dist/tools/prompt-hints.d.ts.map +1 -1
  103. package/dist/tools/prompt-hints.js +38 -0
  104. package/dist/tools/prompt-hints.js.map +1 -1
  105. package/dist/tools/subagent-control.d.ts.map +1 -1
  106. package/dist/tools/subagent-control.js +20 -5
  107. package/dist/tools/subagent-control.js.map +1 -1
  108. package/dist/tools/subagent-control.test.js +34 -1
  109. package/dist/tools/subagent-control.test.js.map +1 -1
  110. package/dist/tools/subagent-shared.d.ts +19 -0
  111. package/dist/tools/subagent-shared.d.ts.map +1 -1
  112. package/dist/tools/subagent-shared.js +32 -5
  113. package/dist/tools/subagent-shared.js.map +1 -1
  114. package/dist/tools/subagent-shared.test.js +42 -8
  115. package/dist/tools/subagent-shared.test.js.map +1 -1
  116. package/dist/tools/subagent.d.ts.map +1 -1
  117. package/dist/tools/subagent.js +11 -8
  118. package/dist/tools/subagent.js.map +1 -1
  119. package/dist/tools/subagent.test.js +3 -0
  120. package/dist/tools/subagent.test.js.map +1 -1
  121. package/dist/tools/task-send.test.js +15 -6
  122. package/dist/tools/task-send.test.js.map +1 -1
  123. package/dist/ui/login.js +1 -1
  124. package/dist/ui/login.js.map +1 -1
  125. package/package.json +4 -4
@@ -1,6 +1,9 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { stripBom } from "../utils/text.js";
4
+ import { log } from "./logger.js";
5
+ import { BUILTIN_TOOL_NAMES } from "../tools/prompt-hints.js";
6
+ import { BUNDLED_AGENTS } from "./bundled-agents.js";
4
7
  /**
5
8
  * MCP server names an agent's `tools:` list asks for, derived from any
6
9
  * `mcp__<server>__<tool>` entries.
@@ -22,6 +25,30 @@ export function mcpServersForAgent(tools) {
22
25
  }
23
26
  return [...servers];
24
27
  }
28
+ const BUILTIN_TOOL_NAME_SET = new Set(BUILTIN_TOOL_NAMES);
29
+ // mcp__<server>__<tool> — the only non-built-in shape a session can register.
30
+ const MCP_TOOL_PATTERN = /^mcp__(.+?)__(.+)$/;
31
+ /**
32
+ * Report `tools:` entries the session could never register.
33
+ *
34
+ * `AgentSession` filters its tool set by name, so an unknown entry is dropped
35
+ * without a word: the agent just quietly loses a capability (or, if every name
36
+ * is wrong, runs with nothing). Warn instead — and stay non-fatal, because a
37
+ * bad agent file must never take down a session.
38
+ *
39
+ * @returns the unrecognized names, for tests and callers that want to report.
40
+ */
41
+ export function validateAgentTools(agent, origin) {
42
+ const unknown = agent.tools.filter((tool) => !BUILTIN_TOOL_NAME_SET.has(tool) && !MCP_TOOL_PATTERN.test(tool));
43
+ if (unknown.length > 0) {
44
+ log("WARN", "agents", "Agent lists unknown tools; they will be ignored", {
45
+ agent: agent.name,
46
+ origin,
47
+ unknown,
48
+ });
49
+ }
50
+ return unknown;
51
+ }
25
52
  /**
26
53
  * Discover agent definitions from global and project-local directories.
27
54
  * Agent files are markdown with frontmatter (similar to skills).
@@ -48,6 +75,7 @@ export async function discoverAgents(options) {
48
75
  const userNames = new Set(agents.map((a) => a.name.toLowerCase()));
49
76
  for (const bundled of BUNDLED_AGENTS) {
50
77
  if (!userNames.has(bundled.name.toLowerCase())) {
78
+ validateAgentTools(bundled, "bundled");
51
79
  agents.push(bundled);
52
80
  }
53
81
  }
@@ -72,6 +100,7 @@ async function loadAgentsFromDir(dir, source) {
72
100
  if (!agent.name) {
73
101
  agent.name = path.basename(file, ".md");
74
102
  }
103
+ validateAgentTools(agent, filePath);
75
104
  agents.push(agent);
76
105
  }
77
106
  catch {
@@ -99,6 +128,8 @@ export function parseAgentFile(rawInput, source) {
99
128
  let name = "";
100
129
  let description = "";
101
130
  let tools = [];
131
+ let model;
132
+ let context;
102
133
  let systemPrompt = raw;
103
134
  if (raw.startsWith("---")) {
104
135
  const endIndex = raw.indexOf("---", 3);
@@ -121,106 +152,25 @@ export function parseAgentFile(rawInput, source) {
121
152
  .map((t) => t.trim())
122
153
  .filter(Boolean);
123
154
  }
155
+ else if (key === "model") {
156
+ if (value)
157
+ model = value;
158
+ }
159
+ else if (key === "context") {
160
+ const normalized = value.toLowerCase();
161
+ if (normalized === "project" || normalized === "none")
162
+ context = normalized;
163
+ }
164
+ // Unknown keys are ignored on purpose: agent files stay
165
+ // forward-compatible with fields a newer ggcoder understands.
124
166
  }
125
167
  }
126
168
  }
127
- return { name, description, tools, systemPrompt, source };
169
+ return { name, description, tools, model, context, systemPrompt, source };
128
170
  }
129
171
  // ── Bundled agents ─────────────────────────────────────────
130
- // Shipped with ggcoder. Used by /bullet-proof and available to any
131
- // subagent call. User-defined agents with the same name override these.
132
- const AUDITOR_PROMPT = `You are Auditor, a defensive security analyst tasked with finding exploitable weaknesses in this codebase so the team can patch them before the project ships.
133
-
134
- You review code rigorously: you look for bypasses that would matter in practice, not pattern violations. You trace data flow from untrusted sources to dangerous sinks. Assume a sophisticated adversary with SDK-level access, an intercepting proxy, the public source, and time — and identify what would expose the project to them.
135
-
136
- ## Core discipline
137
-
138
- 1. **Trace, don't pattern-match.** Every finding must have a concrete Source → Sink path traced through the actual code.
139
- 2. **Untrusted vs trusted inputs.** Before flagging, decide whether the input is *actually* reachable by an untrusted source, or a settings constant / build-time string / hardcoded value. If the latter, drop it.
140
- 3. **Vulnerability scenarios are mandatory.** Describe how the weakness is triggered: input, system response, resulting exposure. If you cannot describe the steps, you cannot flag the finding.
141
- 4. **Confidence ≥0.8 only.** Better to miss theoretical issues than flood the report with noise.
142
- 5. **Framework awareness.** ORM parameterization, auto-escape, memory-safe languages, JSX/template escaping all eliminate entire vuln classes. Don't flag what the framework already handles.
143
-
144
- ## Output for each finding
145
-
146
- - **Location**: file:line
147
- - **Category**: <slug> (sql_injection, ssrf, prototype_pollution, supply_chain, ...)
148
- - **CWE**: CWE-XXX
149
- - **Confidence**: 0.0–1.0
150
- - **Source → Sink**: the actual data path
151
- - **Vulnerability scenario**: numbered steps showing trigger → response → exposure
152
- - **Impact**: what is exposed, blast radius
153
- - **Fix**: concrete code-level remediation
154
-
155
- ## Hard exclusions — do NOT report:
156
-
157
- - DOS / rate-limiting / memory exhaustion without an amplification primitive
158
- - Theoretical race conditions without a demonstrable window
159
- - Regex-DOS without untrusted-supplied regex
160
- - Log spoofing / log injection (cosmetic)
161
- - SSRF where the URL is a settings constant or build-time string
162
- - Env-var trust (env is server-controlled by definition)
163
- - Client-side authentication theatre on a server-validated endpoint
164
- - React/Vue/Angular XSS without unsafe sinks (\`dangerouslySetInnerHTML\`, \`v-html\`, \`bypassSecurityTrust*\` are the only real ones)
165
- - Shell-script command injection without an untrusted input path
166
- - Findings in documentation, example code, or test fixtures
167
- - Insecure-by-design dev tooling that doesn't ship to users
168
- - "Could be improved" preferences with no demonstrable path
169
-
170
- Return findings ranked Critical → High → Medium. If nothing meets the bar, return "No high-confidence findings."`;
171
- const SKEPTIC_PROMPT = `You are Skeptic, a rigorous reviewer whose job is to DISPROVE security findings handed to you. You start from "this is a false positive" and only conclude otherwise if the evidence is overwhelming.
172
-
173
- ## Your mission
174
-
175
- Given a security finding, attempt to break it. Try every angle:
176
-
177
- 1. **Reachability**: Is the claimed source actually untrusted-controlled, or a settings constant, build-time value, or env var (server-controlled by definition)?
178
- 2. **Control flow**: Even if the source is real, does control flow actually reach the sink? Is there a guard, validator, or sanitizer in between that the original audit missed?
179
- 3. **Framework handling**: Would the framework (ORM, template engine, auto-escape, memory-safe language) eliminate this entire vuln class?
180
- 4. **Trigger feasibility**: Can you actually construct the input that triggers the path? What would the response look like? If you can't construct it, the finding stands on theory.
181
- 5. **Severity inflation**: Is the impact overstated? "RCE" claims often turn out to be "writes to a sandboxed file path."
182
-
183
- Read the code yourself. Do not trust the audit's claim — verify each step.
184
-
185
- ## Verdict format
186
-
187
- For each finding, return:
188
- - **Verdict**: CONFIRMED / DROP / DOWNGRADE
189
- - **Reason**: 1-3 sentence explanation
190
- - **If CONFIRMED**: re-state the vulnerability scenario in your own words to prove you verified it end-to-end
191
- - **If DROP**: cite which exclusion rule applies, or which step in the chain fails
192
- - **If DOWNGRADE**: new severity + reason
193
-
194
- ## Hard exclusions — automatic DROP regardless of source:
195
-
196
- - DOS / rate-limiting / memory exhaustion without an amplification primitive
197
- - Theoretical race conditions without a demonstrable window
198
- - Regex-DOS without untrusted-supplied regex
199
- - Log spoofing / log injection (cosmetic only)
200
- - SSRF where the URL is a settings constant or build-time string
201
- - Env-var trust ("untrusted source controls \\$HOME" — env is server-controlled)
202
- - Client-side authn checks on endpoints that re-validate server-side
203
- - React/Vue/Angular XSS unless \`dangerouslySetInnerHTML\` / \`v-html\` / \`bypassSecurityTrust*\` is the sink
204
- - Shell-script command injection without an untrusted input path
205
- - Findings in documentation, example code, or test fixtures
206
- - Insecure-by-design dev tooling that doesn't ship to users
207
- - "Could be improved" preferences with no demonstrable path
208
-
209
- Be rigorous. The cost of a false positive is the user's trust in the entire report.`;
210
- export const BUNDLED_AGENTS = [
211
- {
212
- name: "auditor",
213
- description: "Defensive security analyst — finds exploitable weaknesses with concrete vulnerability scenarios",
214
- tools: ["read", "grep", "find", "ls", "bash", "web_fetch", "web_search"],
215
- systemPrompt: AUDITOR_PROMPT,
216
- source: "bundled",
217
- },
218
- {
219
- name: "skeptic",
220
- description: "Rigorous false-positive reviewer — disproves security findings and applies exclusion rules strictly",
221
- tools: ["read", "grep", "find", "ls", "bash", "web_fetch", "web_search"],
222
- systemPrompt: SKEPTIC_PROMPT,
223
- source: "bundled",
224
- },
225
- ];
172
+ // Shipped with ggcoder (see ./bundled-agents.ts). Used by /bullet-proof and
173
+ // available to any subagent call. User-defined agents with the same name
174
+ // override these because they come first in `discoverAgents`.
175
+ export { BUNDLED_AGENTS };
226
176
  //# sourceMappingURL=agents.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/core/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAU5C;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAwB;IACzD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,qEAAqE;QACrE,iEAAiE;QACjE,MAAM,KAAK,GAAG,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AACtB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAGpC;IACC,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,wCAA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3D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;gBAEhD,IAAI,GAAG,KAAK,MAAM;oBAAE,IAAI,GAAG,KAAK,CAAC;qBAC5B,IAAI,GAAG,KAAK,aAAa;oBAAE,WAAW,GAAG,KAAK,CAAC;qBAC/C,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;oBACzB,KAAK,GAAG,KAAK;yBACV,KAAK,CAAC,GAAG,CAAC;yBACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;yBACpB,MAAM,CAAC,OAAO,CAAC,CAAC;gBACrB,CAAC;qBAAM,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;oBAC3B,IAAI,KAAK;wBAAE,KAAK,GAAG,KAAK,CAAC;gBAC3B,CAAC;qBAAM,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;oBAC7B,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;oBACvC,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,MAAM;wBAAE,OAAO,GAAG,UAAU,CAAC;gBAC9E,CAAC;gBACD,wDAAwD;gBACxD,8DAA8D;YAChE,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;AAC5E,CAAC;AAED,8DAA8D;AAC9D,4EAA4E;AAC5E,yEAAyE;AACzE,8DAA8D;AAC9D,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -2,7 +2,7 @@ import { describe, it, expect } from "vitest";
2
2
  import fs from "node:fs";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
- import { BUNDLED_AGENTS, discoverAgents, mcpServersForAgent, parseAgentFile } from "./agents.js";
5
+ import { BUNDLED_AGENTS, discoverAgents, mcpServersForAgent, parseAgentFile, validateAgentTools, } from "./agents.js";
6
6
  describe("mcpServersForAgent", () => {
7
7
  it("derives server names from mcp__<server>__<tool> entries", () => {
8
8
  expect(mcpServersForAgent([
@@ -33,11 +33,91 @@ describe("mcpServersForAgent", () => {
33
33
  expect(mcpServersForAgent(agent.tools)).toEqual(["kencode-search"]);
34
34
  });
35
35
  });
36
+ describe("parseAgentFile", () => {
37
+ it("reads the model and context policies from frontmatter", () => {
38
+ const agent = parseAgentFile([
39
+ "---",
40
+ "name: scout",
41
+ "description: Recon",
42
+ "tools: read, grep",
43
+ "model: fast",
44
+ "context: none",
45
+ "---",
46
+ "Scout it.",
47
+ ].join("\n"), "project");
48
+ expect(agent.model).toBe("fast");
49
+ expect(agent.context).toBe("none");
50
+ expect(agent.systemPrompt).toBe("Scout it.");
51
+ });
52
+ it("leaves both unset when absent, and ignores unknown keys", () => {
53
+ const agent = parseAgentFile(["---", "name: scout", "description: Recon", "temperature: 0.3", "---", "Scout."].join("\n"), "project");
54
+ expect(agent.model).toBeUndefined();
55
+ expect(agent.context).toBeUndefined();
56
+ expect(agent.name).toBe("scout");
57
+ });
58
+ it("accepts an explicit model id and rejects a nonsense context", () => {
59
+ const agent = parseAgentFile([
60
+ "---",
61
+ "name: scout",
62
+ "description: Recon",
63
+ "model: claude-haiku-4-5",
64
+ "context: sometimes",
65
+ "---",
66
+ "Scout.",
67
+ ].join("\n"), "project");
68
+ expect(agent.model).toBe("claude-haiku-4-5");
69
+ expect(agent.context).toBeUndefined();
70
+ });
71
+ });
72
+ describe("validateAgentTools", () => {
73
+ const base = {
74
+ name: "scout",
75
+ description: "Recon",
76
+ systemPrompt: "x",
77
+ source: "project",
78
+ };
79
+ it("accepts built-in and mcp__<server>__<tool> names", () => {
80
+ expect(validateAgentTools({ ...base, tools: ["read", "code_search", "mcp__kencode-search__searchCode"] }, "test")).toEqual([]);
81
+ });
82
+ it("reports names no session could ever register", () => {
83
+ expect(validateAgentTools({ ...base, tools: ["read", "webfetch", "Bash", "mcp__broken"] }, "test")).toEqual(["webfetch", "Bash", "mcp__broken"]);
84
+ });
85
+ });
36
86
  describe("bundled agents", () => {
37
- it("ships auditor and skeptic so /bullet-proof always resolves them", () => {
38
- const names = BUNDLED_AGENTS.map((a) => a.name);
39
- expect(names).toContain("auditor");
40
- expect(names).toContain("skeptic");
87
+ it("ships all six agents on a fresh install", () => {
88
+ expect(BUNDLED_AGENTS.map((a) => a.name).sort()).toEqual([
89
+ "auditor",
90
+ "bee",
91
+ "owl",
92
+ "researcher",
93
+ "skeptic",
94
+ "worker",
95
+ ]);
96
+ });
97
+ it("lists only tools a session can actually register", () => {
98
+ for (const agent of BUNDLED_AGENTS) {
99
+ expect(validateAgentTools(agent, "bundled"), agent.name).toEqual([]);
100
+ }
101
+ });
102
+ it("declares its model policy instead of leaving it to inference", () => {
103
+ for (const agent of BUNDLED_AGENTS) {
104
+ expect(agent.model, agent.name).toBeDefined();
105
+ }
106
+ // Only cheap structural recon opts out of the parent's model.
107
+ const fast = BUNDLED_AGENTS.filter((a) => a.model === "fast").map((a) => a.name);
108
+ expect(fast).toEqual(["owl"]);
109
+ });
110
+ it("writes descriptions that route — distinct, and never 'does anything'", () => {
111
+ const descriptions = BUNDLED_AGENTS.map((a) => a.description);
112
+ expect(new Set(descriptions).size).toBe(BUNDLED_AGENTS.length);
113
+ for (const description of descriptions) {
114
+ expect(description.toLowerCase()).not.toContain("does anything");
115
+ expect(description.length).toBeGreaterThan(40);
116
+ }
117
+ });
118
+ it("gives the researcher live code search so it cannot fall back to training data", () => {
119
+ const researcher = BUNDLED_AGENTS.find((a) => a.name === "researcher");
120
+ expect(mcpServersForAgent(researcher.tools)).toEqual(["kencode-search"]);
41
121
  });
42
122
  it("does not shadow bundled agents unless the user defines that name", async () => {
43
123
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), "gg-agents-"));
@@ -1 +1 @@
1
- {"version":3,"file":"agents.test.js","sourceRoot":"","sources":["../../src/core/agents.test.ts"],"names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CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC;QACjE,IAAI,CAAC;YACH,EAAE,CAAC,aAAa,CACd,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,EAC5B,kEAAkE,EAClE,OAAO,CACR,CAAC;YACF,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;YAC9D,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;YAC5D,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACjC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;gBAAS,CAAC;YACT,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -33,7 +33,43 @@ export interface AuthProviderMeta {
33
33
  * for every provider with a single API-key credential.
34
34
  */
35
35
  apiKeyVariants?: ApiKeyVariant[];
36
+ /**
37
+ * Per-method guidance overrides. Only providers whose methods differ in
38
+ * billing/entitlement (the dual-auth ones) need these; everything else is
39
+ * described generically by {@link describeAuthMethods}.
40
+ */
41
+ methodDetails?: Partial<Record<AuthMethod, AuthMethodMeta>>;
42
+ }
43
+ /**
44
+ * What one auth method means for a provider, so both UIs can answer "which do I
45
+ * pick?" without hardcoding provider knowledge in a component.
46
+ */
47
+ export interface AuthMethodMeta {
48
+ method: AuthMethod;
49
+ /** Button/row label, e.g. "Sign in with Grok (SuperGrok / X Premium)". */
50
+ label: string;
51
+ /** What the user spends on this method. */
52
+ billing: string;
53
+ /** When to choose it. */
54
+ when: string;
55
+ /** Prerequisite the user must already have, if any. */
56
+ requires?: string;
36
57
  }
37
58
  export declare const AUTH_PROVIDERS: AuthProviderMeta[];
38
59
  export declare function getAuthProvider(value: string): AuthProviderMeta | undefined;
60
+ /**
61
+ * Per-method guidance for a provider, in resolution order. Providers with a
62
+ * single method get a generic description; the dual-auth ones (Kimi, Grok) carry
63
+ * explicit `methodDetails` because the choice changes what the user is billed.
64
+ */
65
+ export declare function describeAuthMethods(provider: string): AuthMethodMeta[];
66
+ /**
67
+ * How the runtime picks between two connected methods, phrased for the UI. Only
68
+ * dual-auth providers have a choice to explain; everything else returns
69
+ * undefined so callers can omit the note entirely.
70
+ *
71
+ * Keep this wording in sync with AuthStorage's actual resolution order in
72
+ * gg-core (`DUAL_AUTH_PROVIDERS`) — it is the user-facing description of it.
73
+ */
74
+ export declare function authPriorityNote(provider: string): string | undefined;
39
75
  //# sourceMappingURL=auth-providers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-providers.d.ts","sourceRoot":"","sources":["../../src/core/auth-providers.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,qFAAqF;IACrF,GAAG,EAAE,MAAM,CAAC;IACZ,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,M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zB,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,cAAc,EAAE,gBAAgB,EA0H5C,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAE3E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE,CAuBtE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQrE"}
@@ -2,7 +2,7 @@
2
2
  // authenticates. Mirrors the CLI's `ggcoder login` provider list (ui/login.tsx)
3
3
  // so the desktop app and the terminal stay in lockstep. The app fetches this
4
4
  // (plus live connection status) from the sidecar's /auth/status endpoint.
5
- import { XIAOMI_CREDITS_KEY } from "@kenkaiiii/gg-core";
5
+ import { XIAOMI_CREDITS_KEY, dualAuthProvider } from "@kenkaiiii/gg-core";
6
6
  export const AUTH_PROVIDERS = [
7
7
  {
8
8
  value: "anthropic",
@@ -25,9 +25,26 @@ export const AUTH_PROVIDERS = [
25
25
  {
26
26
  value: "xai",
27
27
  label: "xAI (Grok)",
28
- description: "Grok 4.5",
29
- methods: ["apikey"],
28
+ description: "Grok 4.5 · OAuth or API key",
29
+ methods: ["oauth", "apikey"],
30
30
  apiKeyLabel: "xAI",
31
+ methodDetails: {
32
+ oauth: {
33
+ method: "oauth",
34
+ label: "Sign in with Grok",
35
+ billing: "Uses your SuperGrok or X Premium subscription — no per-token API billing.",
36
+ when: "Preferred. Pick this if you already pay for Grok.",
37
+ requires: "An active SuperGrok or X Premium subscription. xAI gates this endpoint by tier, " +
38
+ "so a valid login can still be refused — keep an API key as backup.",
39
+ },
40
+ apikey: {
41
+ method: "apikey",
42
+ label: "xAI API key",
43
+ billing: "Metered pay-per-token billing on your console.x.ai credits.",
44
+ when: "Use without a Grok subscription, or as the fallback when OAuth usage runs out.",
45
+ requires: "An API key from console.x.ai.",
46
+ },
47
+ },
31
48
  },
32
49
  {
33
50
  value: "moonshot",
@@ -35,6 +52,22 @@ export const AUTH_PROVIDERS = [
35
52
  description: "Kimi K3, K2.7 Code · OAuth or API key",
36
53
  methods: ["oauth", "apikey"],
37
54
  apiKeyLabel: "Moonshot",
55
+ methodDetails: {
56
+ oauth: {
57
+ method: "oauth",
58
+ label: "Sign in with Kimi",
59
+ billing: "Uses your Kimi For Coding plan — no per-token API billing.",
60
+ when: "Preferred. Pick this if you have a Kimi coding plan.",
61
+ requires: "An active Kimi For Coding subscription.",
62
+ },
63
+ apikey: {
64
+ method: "apikey",
65
+ label: "Moonshot API key",
66
+ billing: "Metered pay-per-token billing on your Moonshot platform credits.",
67
+ when: "Use without a Kimi plan, or as the fallback when plan usage runs out.",
68
+ requires: "An API key from platform.moonshot.ai.",
69
+ },
70
+ },
38
71
  },
39
72
  {
40
73
  value: "glm",
@@ -95,4 +128,51 @@ export const AUTH_PROVIDERS = [
95
128
  export function getAuthProvider(value) {
96
129
  return AUTH_PROVIDERS.find((p) => p.value === value);
97
130
  }
131
+ /**
132
+ * Per-method guidance for a provider, in resolution order. Providers with a
133
+ * single method get a generic description; the dual-auth ones (Kimi, Grok) carry
134
+ * explicit `methodDetails` because the choice changes what the user is billed.
135
+ */
136
+ export function describeAuthMethods(provider) {
137
+ const meta = getAuthProvider(provider);
138
+ if (!meta)
139
+ return [];
140
+ return meta.methods.map((method) => {
141
+ const override = meta.methodDetails?.[method];
142
+ // Copy rather than hand back the table entry itself: callers serialize this
143
+ // alongside the provider meta, and a shared reference appearing twice in one
144
+ // payload trips the sidecar's cycle-safe JSON encoder ([CIRCULAR]).
145
+ if (override)
146
+ return { ...override };
147
+ return method === "oauth"
148
+ ? {
149
+ method,
150
+ label: `Sign in with ${meta.label}`,
151
+ billing: "Uses your existing plan with this provider.",
152
+ when: "The only way to connect this provider.",
153
+ }
154
+ : {
155
+ method,
156
+ label: `${meta.apiKeyLabel ?? meta.label} API key`,
157
+ billing: "Metered pay-per-token billing on this provider's credits.",
158
+ when: "The only way to connect this provider.",
159
+ };
160
+ });
161
+ }
162
+ /**
163
+ * How the runtime picks between two connected methods, phrased for the UI. Only
164
+ * dual-auth providers have a choice to explain; everything else returns
165
+ * undefined so callers can omit the note entirely.
166
+ *
167
+ * Keep this wording in sync with AuthStorage's actual resolution order in
168
+ * gg-core (`DUAL_AUTH_PROVIDERS`) — it is the user-facing description of it.
169
+ */
170
+ export function authPriorityNote(provider) {
171
+ const dual = dualAuthProvider(provider);
172
+ if (!dual)
173
+ return undefined;
174
+ return (`With both connected, ${dual.oauthLabel} is used first. The ${dual.apiKeyLabel} takes over ` +
175
+ `automatically while subscription usage is out (or if the OAuth login expires), then ` +
176
+ `${dual.oauthLabel} resumes on its own.`);
177
+ }
98
178
  //# sourceMappingURL=auth-providers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-providers.js","sourceRoot":"","sources":["../../src/core/auth-providers.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,gFAAgF;AAChF,6EAA6E;AAC7E,0EAA0E;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAyCxD,MAAM,CAAC,MAAM,cAAc,GAAuB;IAChD;QACE,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,6CAA6C;QAC1D,OAAO,EAAE,CAAC,OAAO,CAAC;KACnB;IACD;QACE,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,mDAAmD;QAChE,OAAO,EAAE,CAAC,OAAO,CAAC;KACnB;IACD;QACE,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,mEAAmE;QAChF,OAAO,EAAE,CAAC,OAAO,CAAC;KACnB;IACD;QACE,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,YAAY;QACnB,W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,KAAK,EAAE;gBACnC,OAAO,EAAE,6CAA6C;gBACtD,IAAI,EAAE,wCAAwC;aAC/C;YACH,CAAC,CAAC;gBACE,MAAM;gBACN,KAAK,EAAE,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,UAAU;gBAClD,OAAO,EAAE,2DAA2D;gBACpE,IAAI,EAAE,wCAAwC;aAC/C,CAAC;IACR,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,MAAM,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,OAAO,CACL,wBAAwB,IAAI,CAAC,UAAU,uBAAuB,IAAI,CAAC,WAAW,cAAc;QAC5F,sFAAsF;QACtF,GAAG,IAAI,CAAC,UAAU,sBAAsB,CACzC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AgentDefinition } from "./agents.js";
2
+ export declare const BUNDLED_AGENTS: AgentDefinition[];
3
+ //# sourceMappingURL=bundled-agents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundled-agents.d.ts","sourceRoot":"","sources":["../../src/core/bundled-agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAkMnD,eAAO,MAAM,cAAc,EAAE,eAAe,EAuE3C,CAAC"}