@gajae-code/coding-agent 0.15.4 → 0.15.6

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 (174) hide show
  1. package/CHANGELOG.md +46 -2
  2. package/dist/types/async/job-manager.d.ts +83 -0
  3. package/dist/types/cli/auth-gateway-cli.d.ts +17 -0
  4. package/dist/types/cli/model-presets-cli.d.ts +9 -0
  5. package/dist/types/cli/update-cli.d.ts +27 -5
  6. package/dist/types/commands/auth-gateway.d.ts +3 -0
  7. package/dist/types/commands/gc.d.ts +13 -0
  8. package/dist/types/commands/model-presets.d.ts +21 -0
  9. package/dist/types/config/autorouting-tier-map.d.ts +99 -0
  10. package/dist/types/config/file-lock.d.ts +49 -2
  11. package/dist/types/config/internal/model-preset-registry-test-state.d.ts +4 -0
  12. package/dist/types/config/internal/model-preset-registry-test-support.d.ts +3 -0
  13. package/dist/types/config/keybindings.d.ts +3 -2
  14. package/dist/types/config/model-preset-registry.d.ts +368 -0
  15. package/dist/types/config/model-profile-activation.d.ts +39 -0
  16. package/dist/types/config/model-profiles.d.ts +5 -3
  17. package/dist/types/config/model-registry.d.ts +11 -5
  18. package/dist/types/config/settings-schema.d.ts +9 -0
  19. package/dist/types/coordinator-mcp/model-preset.d.ts +7 -5
  20. package/dist/types/coordinator-mcp/projection-scan.d.ts +46 -0
  21. package/dist/types/extensibility/extensions/types.d.ts +4 -4
  22. package/dist/types/extensibility/shared-events.d.ts +2 -0
  23. package/dist/types/gjc-runtime/empty-delete-gc.d.ts +58 -0
  24. package/dist/types/gjc-runtime/gc-runtime.d.ts +2 -0
  25. package/dist/types/gjc-runtime/session-state-lock.d.ts +35 -6
  26. package/dist/types/gjc-runtime/session-state-sidecar.d.ts +6 -0
  27. package/dist/types/index.d.ts +1 -0
  28. package/dist/types/main.d.ts +3 -1
  29. package/dist/types/modes/components/jobs-overlay-model.d.ts +4 -2
  30. package/dist/types/modes/jobs-observer.d.ts +36 -0
  31. package/dist/types/sdk/broker/broker.d.ts +3 -0
  32. package/dist/types/sdk/bus/kind-aware-reconciliation.d.ts +3 -0
  33. package/dist/types/sdk/bus/prompt-reconciliation.d.ts +4 -0
  34. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +8 -1
  35. package/dist/types/sdk/cli/session-cli.d.ts +42 -1
  36. package/dist/types/sdk/client/discovery.d.ts +1 -0
  37. package/dist/types/sdk/host/host.d.ts +2 -0
  38. package/dist/types/sdk/host/model-pin.d.ts +7 -2
  39. package/dist/types/sdk/host/sdk-run-capability.d.ts +1 -0
  40. package/dist/types/sdk/host/session-runtime.d.ts +19 -1
  41. package/dist/types/sdk/prompt-deadline-manager.d.ts +11 -1
  42. package/dist/types/sdk/protocol/adapter-validation.d.ts +2 -0
  43. package/dist/types/sdk/router/session-router.d.ts +9 -0
  44. package/dist/types/session/account-inventory.d.ts +1 -0
  45. package/dist/types/session/agent-session.d.ts +19 -5
  46. package/dist/types/session/fold-coordinator.d.ts +201 -0
  47. package/dist/types/session/internal/managed-session-storage.d.ts +4 -3
  48. package/dist/types/session/sdk-run-capability-internal.d.ts +7 -0
  49. package/dist/types/session/sdk-run-capability.d.ts +2 -0
  50. package/dist/types/telemetry/control.d.ts +11 -0
  51. package/dist/types/telemetry/events.d.ts +20 -0
  52. package/dist/types/telemetry/index.d.ts +3 -0
  53. package/dist/types/telemetry/transport.d.ts +22 -0
  54. package/dist/types/tools/bash-interactive.d.ts +23 -0
  55. package/dist/types/tools/index.d.ts +6 -5
  56. package/dist/types/tools/path-utils.d.ts +5 -6
  57. package/dist/types/tools/tmux-self-injection-guard.d.ts +15 -0
  58. package/dist/types/web/search/providers/base.d.ts +9 -4
  59. package/dist/types/web/search/providers/xai.d.ts +2 -1
  60. package/dist/types/web/search/types.d.ts +14 -0
  61. package/package.json +10 -7
  62. package/scripts/generate-hotkeys-docs.ts +4 -0
  63. package/scripts/generate-sdk-operation-inventory.ts +3 -3
  64. package/src/async/job-manager.ts +671 -39
  65. package/src/cli/auth-broker-cli.ts +40 -12
  66. package/src/cli/auth-gateway-cli.ts +273 -97
  67. package/src/cli/config-cli.ts +2 -2
  68. package/src/cli/fast-help.ts +3 -0
  69. package/src/cli/model-presets-cli.ts +100 -0
  70. package/src/cli/update-cli.ts +142 -6
  71. package/src/cli.ts +6 -2
  72. package/src/commands/auth-gateway.ts +12 -8
  73. package/src/commands/gc.ts +19 -0
  74. package/src/commands/model-presets.ts +24 -0
  75. package/src/commands/sdk.ts +5 -0
  76. package/src/config/autorouting-tier-map.ts +33 -0
  77. package/src/config/file-lock-gc.ts +9 -4
  78. package/src/config/file-lock.ts +775 -59
  79. package/src/config/internal/model-preset-registry-test-state.ts +28 -0
  80. package/src/config/internal/model-preset-registry-test-support.ts +11 -0
  81. package/src/config/keybindings.ts +6 -2
  82. package/src/config/model-preset-registry.ts +2799 -0
  83. package/src/config/model-profile-activation.ts +115 -28
  84. package/src/config/model-profile-contract.ts +4 -1
  85. package/src/config/model-profiles.ts +56 -14
  86. package/src/config/model-registry.ts +1028 -123
  87. package/src/config/settings-schema.ts +11 -0
  88. package/src/config/settings.ts +6 -1
  89. package/src/coordinator-mcp/model-preset.ts +32 -17
  90. package/src/coordinator-mcp/policy.ts +1 -1
  91. package/src/coordinator-mcp/projection-scan.ts +571 -0
  92. package/src/coordinator-mcp/server.ts +19 -24
  93. package/src/coordinator-mcp/session-reaper.ts +9 -3
  94. package/src/extensibility/extensions/loader.ts +0 -1
  95. package/src/extensibility/extensions/types.ts +4 -2
  96. package/src/extensibility/gjc-plugins/runtime-adapters.ts +1 -0
  97. package/src/extensibility/shared-events.ts +2 -0
  98. package/src/gjc-runtime/empty-delete-gc.ts +301 -0
  99. package/src/gjc-runtime/gc-render.ts +29 -0
  100. package/src/gjc-runtime/gc-runtime.ts +174 -11
  101. package/src/gjc-runtime/launch-worktree.ts +44 -7
  102. package/src/gjc-runtime/ralplan-runtime.ts +14 -1
  103. package/src/gjc-runtime/session-state-lock.ts +1242 -141
  104. package/src/gjc-runtime/session-state-sidecar.ts +76 -3
  105. package/src/gjc-runtime/tmux-sessions.ts +145 -48
  106. package/src/index.ts +1 -0
  107. package/src/internal-urls/docs-index.generated.ts +14 -13
  108. package/src/lsp/config.ts +4 -3
  109. package/src/lsp/path-trust.ts +12 -6
  110. package/src/main.ts +9 -2
  111. package/src/modes/acp/acp-agent.ts +11 -5
  112. package/src/modes/components/jobs-overlay-model.ts +99 -16
  113. package/src/modes/components/model-selector.ts +158 -18
  114. package/src/modes/components/status-line/segments.ts +6 -1
  115. package/src/modes/controllers/extension-ui-controller.ts +1 -1
  116. package/src/modes/controllers/input-controller.ts +23 -6
  117. package/src/modes/interactive-mode.ts +14 -1
  118. package/src/modes/jobs-observer.ts +149 -16
  119. package/src/modes/prompt-action-autocomplete.ts +26 -47
  120. package/src/modes/runtime-init.ts +1 -1
  121. package/src/modes/utils/injected-user-submission.ts +15 -1
  122. package/src/prompts/tools/bash.md +2 -2
  123. package/src/prompts/tools/fold-receipt.md +3 -0
  124. package/src/prompts/tools/job.md +1 -1
  125. package/src/sdk/acp/adapter.ts +17 -2
  126. package/src/sdk/broker/broker.ts +48 -21
  127. package/src/sdk/broker/lifecycle.ts +32 -6
  128. package/src/sdk/bus/chat-daemon-control.ts +2 -2
  129. package/src/sdk/bus/chat-daemon-runtime.ts +11 -1
  130. package/src/sdk/bus/kind-aware-reconciliation.ts +46 -8
  131. package/src/sdk/bus/prompt-reconciliation.ts +33 -6
  132. package/src/sdk/bus/slack-conversation.ts +5 -1
  133. package/src/sdk/bus/telegram-daemon-contract.ts +8 -1
  134. package/src/sdk/cli/session-cli.ts +161 -5
  135. package/src/sdk/client/discovery.ts +3 -1
  136. package/src/sdk/host/control/dispatch.ts +3 -0
  137. package/src/sdk/host/host.ts +7 -0
  138. package/src/sdk/host/model-pin.ts +185 -25
  139. package/src/sdk/host/sdk-run-capability.ts +1 -0
  140. package/src/sdk/host/session-runtime.test.ts +1240 -107
  141. package/src/sdk/host/session-runtime.ts +1029 -115
  142. package/src/sdk/prompt-deadline-manager.ts +16 -1
  143. package/src/sdk/protocol/adapter-validation.ts +27 -0
  144. package/src/sdk/protocol/operation-inventory.generated.json +2 -2
  145. package/src/sdk/protocol/operation-registry.ts +4 -1
  146. package/src/sdk/router/session-router.ts +297 -111
  147. package/src/sdk/session.ts +83 -12
  148. package/src/session/account-inventory.ts +27 -11
  149. package/src/session/agent-session.ts +887 -95
  150. package/src/session/fold-coordinator.ts +433 -0
  151. package/src/session/internal/managed-session-storage.ts +64 -26
  152. package/src/session/sdk-run-capability-internal.ts +15 -0
  153. package/src/session/sdk-run-capability.ts +2 -0
  154. package/src/session/session-manager.ts +29 -10
  155. package/src/setup/provider-presets.json +1 -1
  156. package/src/slash-commands/helpers/credential-switch.ts +6 -1
  157. package/src/task/executor.ts +19 -3
  158. package/src/telemetry/control.ts +26 -0
  159. package/src/telemetry/events.ts +142 -0
  160. package/src/telemetry/index.ts +3 -0
  161. package/src/telemetry/transport.ts +87 -0
  162. package/src/tools/bash-interactive.ts +182 -85
  163. package/src/tools/bash.ts +786 -67
  164. package/src/tools/index.ts +7 -5
  165. package/src/tools/path-utils.ts +77 -29
  166. package/src/tools/tmux-self-injection-guard.ts +359 -0
  167. package/src/tools/tool-catalog.generated.ts +1 -1
  168. package/src/web/search/provider.ts +120 -11
  169. package/src/web/search/providers/anthropic.ts +89 -17
  170. package/src/web/search/providers/base.ts +9 -4
  171. package/src/web/search/providers/gemini.ts +87 -15
  172. package/src/web/search/providers/openai-compatible.ts +23 -8
  173. package/src/web/search/providers/xai.ts +98 -12
  174. package/src/web/search/types.ts +16 -0
@@ -6,7 +6,14 @@
6
6
  */
7
7
  import type { AuthStorage } from "@gajae-code/ai/core";
8
8
  import { $credentialEnv, $env } from "@gajae-code/utils";
9
- import type { SearchCitation, SearchResponse, SearchSource, SearchUsage } from "../../../web/search/types";
9
+ import type {
10
+ ActiveSearchModelContext,
11
+ ActiveSearchModelCredentials,
12
+ SearchCitation,
13
+ SearchResponse,
14
+ SearchSource,
15
+ SearchUsage,
16
+ } from "../../../web/search/types";
10
17
  import { SearchProviderError } from "../../../web/search/types";
11
18
  import type { SearchParams } from "./base";
12
19
  import { SearchProvider } from "./base";
@@ -49,11 +56,13 @@ export interface XaiSearchParams {
49
56
  signal?: AbortSignal;
50
57
  authStorage: AuthStorage;
51
58
  sessionId?: string;
59
+ activeModelContext?: ActiveSearchModelContext;
52
60
  }
53
61
 
54
62
  interface XaiAuth {
55
63
  bearer: string;
56
64
  mode: "api_key" | "oauth";
65
+ headers?: Record<string, string>;
57
66
  }
58
67
 
59
68
  interface PreparedXaiTools {
@@ -67,7 +76,53 @@ function asTrimmed(value: string | undefined): string | undefined {
67
76
  return trimmed.length > 0 ? trimmed : undefined;
68
77
  }
69
78
 
70
- function getModel(): string {
79
+ function isOpenAICompatWire(api: string): boolean {
80
+ return api === "openai-responses" || api === "openai-completions";
81
+ }
82
+
83
+ function looksXaiModelId(modelId: string | undefined): boolean {
84
+ if (!modelId) return false;
85
+ const id = modelId.toLowerCase();
86
+ return id.startsWith("grok-") || id.startsWith("x-ai/grok-") || id.startsWith("xai/grok-");
87
+ }
88
+
89
+ function isOfficialXaiBaseUrl(baseUrl: string | undefined): boolean {
90
+ if (!baseUrl?.trim()) return true;
91
+ try {
92
+ return new URL(baseUrl).hostname.toLowerCase().replace(/\.$/, "") === "api.x.ai";
93
+ } catch {
94
+ return false;
95
+ }
96
+ }
97
+
98
+ function isCustomXaiContext(ctx: ActiveSearchModelContext | undefined): ctx is ActiveSearchModelContext {
99
+ if (!ctx || !isOpenAICompatWire(ctx.api)) return false;
100
+ if (ctx.ownerAuthOverride) return true;
101
+ const provider = ctx.provider.toLowerCase();
102
+ if (provider === "xai" && !isOfficialXaiBaseUrl(ctx.baseUrl)) return true;
103
+ if (!looksXaiModelId(ctx.wireModelId) && !looksXaiModelId(ctx.modelId)) return false;
104
+ if (!isOfficialXaiBaseUrl(ctx.baseUrl)) return true;
105
+ return provider !== "xai";
106
+ }
107
+
108
+ function hasHeader(headers: Record<string, string>, name: string): boolean {
109
+ const normalized = name.toLowerCase();
110
+ return Object.keys(headers).some(key => key.toLowerCase() === normalized);
111
+ }
112
+
113
+ function explicitCredentialHeader(headers: Record<string, string> | undefined): string | undefined {
114
+ for (const [key, value] of Object.entries(headers ?? {})) {
115
+ const normalized = key.toLowerCase();
116
+ if (normalized === "authorization" || normalized === "x-api-key") return value;
117
+ }
118
+ return undefined;
119
+ }
120
+
121
+ function getModel(activeModelContext?: ActiveSearchModelContext): string {
122
+ const ctx = activeModelContext;
123
+ if (isCustomXaiContext(ctx)) {
124
+ return ctx.wireModelId ?? ctx.modelId;
125
+ }
71
126
  return asTrimmed($env.PI_XAI_WEB_SEARCH_MODEL) ?? asTrimmed($env.XAI_WEB_SEARCH_MODEL) ?? DEFAULT_MODEL;
72
127
  }
73
128
 
@@ -76,12 +131,14 @@ export function resolveXaiSearchBaseUrlForTest(): string {
76
131
  return getBaseUrl();
77
132
  }
78
133
 
79
- function getBaseUrl(): string {
134
+ function getBaseUrl(activeModelContext?: ActiveSearchModelContext): string {
135
+ const ctx = activeModelContext;
136
+ if (isCustomXaiContext(ctx) && ctx.baseUrl) return ctx.baseUrl;
80
137
  return asTrimmed($credentialEnv("XAI_SEARCH_BASE_URL")) ?? DEFAULT_BASE_URL;
81
138
  }
82
139
 
83
- function responsesEndpoint(): string {
84
- return `${getBaseUrl().replace(/\/+$/, "")}/responses`;
140
+ function responsesEndpoint(activeModelContext?: ActiveSearchModelContext): string {
141
+ return `${getBaseUrl(activeModelContext).replace(/\/+$/, "")}/responses`;
85
142
  }
86
143
 
87
144
  async function resolveXaiAuth(
@@ -89,7 +146,26 @@ async function resolveXaiAuth(
89
146
  sessionId: string | undefined,
90
147
  model: string,
91
148
  signal: AbortSignal | undefined,
149
+ activeModelContext?: ActiveSearchModelContext,
92
150
  ): Promise<XaiAuth | null> {
151
+ const ctx = activeModelContext;
152
+ if (isCustomXaiContext(ctx)) {
153
+ const activeCredentials: ActiveSearchModelCredentials = ctx.resolveCredentials
154
+ ? await ctx.resolveCredentials({ sessionId, signal })
155
+ : {
156
+ apiKey: await authStorage.getApiKey(ctx.provider, sessionId, {
157
+ baseUrl: ctx.baseUrl,
158
+ modelId: ctx.modelId,
159
+ signal,
160
+ }),
161
+ headers: ctx.headers,
162
+ };
163
+ const headers = { ...(activeCredentials.headers ?? ctx.headers ?? {}) };
164
+ const bearer = activeCredentials.apiKey ?? explicitCredentialHeader(headers);
165
+ if (!bearer) return null;
166
+ return { bearer, mode: "api_key", headers };
167
+ }
168
+
93
169
  const credentialSessionId = sessionId ?? `xai-search:${crypto.randomUUID()}`;
94
170
  const bearer = await authStorage.getApiKey("xai", credentialSessionId, {
95
171
  baseUrl: getBaseUrl(),
@@ -409,8 +485,14 @@ function parseUsage(json: any): SearchUsage | undefined {
409
485
 
410
486
  /** Execute xAI web/X search through the Responses API search tools. */
411
487
  export async function searchXai(params: XaiSearchParams): Promise<SearchResponse> {
412
- const model = getModel();
413
- const auth = await resolveXaiAuth(params.authStorage, params.sessionId, model, params.signal);
488
+ const model = getModel(params.activeModelContext);
489
+ const auth = await resolveXaiAuth(
490
+ params.authStorage,
491
+ params.sessionId,
492
+ model,
493
+ params.signal,
494
+ params.activeModelContext,
495
+ );
414
496
  if (!auth) {
415
497
  throw new SearchProviderError(
416
498
  "xai",
@@ -419,12 +501,15 @@ export async function searchXai(params: XaiSearchParams): Promise<SearchResponse
419
501
  );
420
502
  }
421
503
 
422
- const response = await fetch(responsesEndpoint(), {
504
+ const headers = { ...(auth.headers ?? {}) };
505
+ if (!hasHeader(headers, "authorization") && !hasHeader(headers, "x-api-key")) {
506
+ headers.Authorization = `Bearer ${auth.bearer}`;
507
+ }
508
+ if (!hasHeader(headers, "content-type")) headers["Content-Type"] = "application/json";
509
+
510
+ const response = await fetch(responsesEndpoint(params.activeModelContext), {
423
511
  method: "POST",
424
- headers: {
425
- Authorization: `Bearer ${auth.bearer}`,
426
- "Content-Type": "application/json",
427
- },
512
+ headers,
428
513
  body: JSON.stringify(
429
514
  buildXaiRequestBody({
430
515
  query: params.query,
@@ -511,6 +596,7 @@ export class XaiProvider extends SearchProvider {
511
596
  signal: params.signal,
512
597
  authStorage: params.authStorage,
513
598
  sessionId: params.sessionId,
599
+ activeModelContext: params.activeModelContext,
514
600
  });
515
601
  }
516
602
  }
@@ -27,6 +27,18 @@ export type SearchProviderId =
27
27
 
28
28
  export type WebSearchMode = "on" | "off" | "auto";
29
29
 
30
+ /** Credentials and request headers resolved for the active model. */
31
+ export interface ActiveSearchModelCredentials {
32
+ apiKey?: string;
33
+ headers?: Record<string, string>;
34
+ }
35
+
36
+ /** Refresh-aware resolver supplied by the model registry for native search. */
37
+ export type ActiveSearchModelCredentialResolver = (options: {
38
+ sessionId?: string;
39
+ signal?: AbortSignal;
40
+ }) => Promise<ActiveSearchModelCredentials>;
41
+
30
42
  export interface ActiveSearchModelContext {
31
43
  provider: string;
32
44
  modelId: string;
@@ -34,6 +46,10 @@ export interface ActiveSearchModelContext {
34
46
  api: string;
35
47
  baseUrl?: string;
36
48
  headers?: Record<string, string>;
49
+ /** Resolve the active model key and current headers before each native search. */
50
+ resolveCredentials?: ActiveSearchModelCredentialResolver;
51
+ /** True when registry-owned auth or transport overrides this active model. */
52
+ ownerAuthOverride?: boolean;
37
53
  webSearch?: WebSearchMode;
38
54
  }
39
55