@gajae-code/coding-agent 0.21.0 → 0.21.1
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/CHANGELOG.md +60 -0
- package/dist/types/config/autorouting-contract.d.ts +4 -4
- package/dist/types/config/autorouting-tier-map.d.ts +1 -1
- package/dist/types/config/keybindings.d.ts +1 -5
- package/dist/types/config/model-profile-activation.d.ts +30 -3
- package/dist/types/config/model-registry.d.ts +2 -0
- package/dist/types/config/models-config-schema.d.ts +8 -0
- package/dist/types/config/settings-schema.d.ts +7 -3
- package/dist/types/coordinator-mcp/canonical-json.d.ts +7 -0
- package/dist/types/extensibility/gjc-plugins/metadata.d.ts +1 -1
- package/dist/types/harness-control-plane/receipts.d.ts +1 -1
- package/dist/types/modes/components/settings-selector.d.ts +5 -2
- package/dist/types/modes/controllers/command-controller.d.ts +1 -1
- package/dist/types/modes/controllers/input-controller.d.ts +12 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +1 -1
- package/dist/types/modes/interactive-mode.d.ts +1 -1
- package/dist/types/modes/shared/agent-wire/workflow-gate-schema.d.ts +1 -1
- package/dist/types/modes/types.d.ts +1 -1
- package/dist/types/session/agent-session.d.ts +101 -6
- package/dist/types/session/session-manager.d.ts +124 -9
- package/dist/types/setup/provider-onboarding.d.ts +55 -2
- package/dist/types/slash-commands/builtin-registry.d.ts +11 -0
- package/dist/types/utils/clipboard.d.ts +18 -0
- package/dist/types/utils/pasted-image-path.d.ts +2 -0
- package/dist/types/web/search/providers/keenable.d.ts +30 -0
- package/dist/types/web/search/types.d.ts +2 -2
- package/package.json +7 -7
- package/scripts/generate-sdk-operation-inventory.ts +28 -0
- package/src/cli/doctor/config-repairs.ts +1 -4
- package/src/cli/local-provider-smoke.ts +1 -4
- package/src/cli/public-command-help.ts +1 -1
- package/src/config/autorouting-contract.ts +5 -8
- package/src/config/autorouting-tier-map.ts +1 -1
- package/src/config/keybindings.ts +1 -2
- package/src/config/model-profile-activation.ts +332 -28
- package/src/config/model-registry.ts +156 -8
- package/src/config/models-config-schema.ts +27 -0
- package/src/config/settings-schema.ts +6 -0
- package/src/coordinator-mcp/canonical-json.ts +15 -0
- package/src/coordinator-mcp/policy.ts +1 -0
- package/src/coordinator-mcp/question-gate-codec.ts +1 -2
- package/src/coordinator-mcp/question-state.ts +2 -12
- package/src/coordinator-mcp/server.ts +1 -10
- package/src/customization/import.ts +1 -5
- package/src/discovery/mcp-compat.ts +1 -5
- package/src/discovery/mcp-json.ts +1 -4
- package/src/edit/notebook.ts +1 -5
- package/src/extensibility/gjc-plugins/lifecycle.ts +1 -3
- package/src/extensibility/gjc-plugins/metadata.ts +2 -5
- package/src/extensibility/gjc-plugins/schema.ts +1 -4
- package/src/gjc-runtime/deep-interview-crystallize.ts +1 -4
- package/src/gjc-runtime/deep-interview-runtime.ts +1 -4
- package/src/gjc-runtime/state-renderer.ts +1 -5
- package/src/gjc-runtime/tmux-owner-isolation.ts +1 -3
- package/src/gjc-runtime/ultragoal-owner-loss-recovery.ts +1 -4
- package/src/gjc-runtime/ultragoal-succession.ts +1 -4
- package/src/goals/continuation-timeout-guard.ts +1 -4
- package/src/harness-control-plane/receipts.ts +1 -1
- package/src/internal-urls/docs-index.generated.ts +4 -4
- package/src/migrate/mcp-mapper.ts +2 -4
- package/src/modes/components/hook-editor.ts +4 -8
- package/src/modes/components/hook-selector.ts +3 -1
- package/src/modes/components/settings-selector.ts +26 -2
- package/src/modes/controllers/command-controller.ts +4 -98
- package/src/modes/controllers/extension-ui-controller.ts +6 -14
- package/src/modes/controllers/goal-mode-controller.ts +4 -4
- package/src/modes/controllers/input-controller.ts +110 -46
- package/src/modes/controllers/plan-mode-controller.ts +6 -10
- package/src/modes/controllers/selector-controller.ts +66 -23
- package/src/modes/controllers/todo-command-controller.ts +2 -2
- package/src/modes/interactive-mode.ts +2 -2
- package/src/modes/prompt-action-autocomplete.ts +1 -1
- package/src/modes/runtime-init.ts +4 -4
- package/src/modes/shared/agent-wire/workflow-gate-schema.ts +1 -1
- package/src/modes/types.ts +1 -1
- package/src/modes/utils/hotkeys-markdown.ts +1 -1
- package/src/runtime-mcp/client.ts +1 -4
- package/src/runtime-mcp/elicitation.ts +1 -5
- package/src/runtime-mcp/protocol.ts +2 -4
- package/src/sdk/broker/lifecycle-ledger.ts +1 -0
- package/src/sdk/broker/lifecycle.ts +1 -0
- package/src/sdk/cli/rows.ts +2 -3
- package/src/sdk/cli/session-cli.ts +2 -8
- package/src/sdk/host/query/cursor.ts +1 -0
- package/src/sdk/host/reverse-leases.ts +1 -0
- package/src/sdk/lifecycle/service.ts +1 -0
- package/src/sdk/protocol/operation-inventory.generated.json +154 -0
- package/src/session/agent-session.ts +1877 -224
- package/src/session/btw-prefix-ledger.ts +1 -4
- package/src/session/internal/managed-gc-retirement-codec.ts +1 -4
- package/src/session/session-manager.ts +732 -224
- package/src/session/task-artifact-owner-codec.ts +1 -4
- package/src/session-import/claude.ts +1 -4
- package/src/session-import/detect.ts +1 -6
- package/src/session-import/provider-codex.ts +1 -6
- package/src/session-import/provider-service.ts +4 -0
- package/src/setup/hermes-setup.ts +1 -4
- package/src/setup/provider-onboarding.ts +514 -26
- package/src/slash-commands/builtin-registry.ts +26 -13
- package/src/slash-commands/helpers/todo.ts +3 -1
- package/src/task/delegation-hint.ts +1 -4
- package/src/task/executor.ts +4 -2
- package/src/task/provider-retry-status.ts +1 -4
- package/src/tools/json-tree.ts +1 -4
- package/src/tools/recipe/runners/pkg.ts +1 -5
- package/src/utils/clipboard.ts +155 -2
- package/src/utils/mac-file-urls.applescript +37 -0
- package/src/utils/pasted-image-path.ts +5 -0
- package/src/web/search/provider.ts +6 -0
- package/src/web/search/providers/keenable.ts +207 -0
- package/src/web/search/types.ts +2 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keenable Web Search Provider
|
|
3
|
+
*
|
|
4
|
+
* Uses the Keenable search API. Works without an API key through the public
|
|
5
|
+
* endpoint (rate-limited per IP); a KEENABLE_API_KEY or stored "keenable"
|
|
6
|
+
* credential switches to the keyed endpoint for higher limits.
|
|
7
|
+
*/
|
|
8
|
+
import type { AuthStorage } from "@gajae-code/ai/core";
|
|
9
|
+
import type { SearchResponse, SearchSource } from "../../../web/search/types";
|
|
10
|
+
import { SearchProviderError } from "../../../web/search/types";
|
|
11
|
+
import { clampNumResults, dateToAgeSeconds } from "../utils";
|
|
12
|
+
import type { SearchParams } from "./base";
|
|
13
|
+
import { SearchProvider } from "./base";
|
|
14
|
+
import { classifyProviderHttpError, withHardTimeout } from "./utils";
|
|
15
|
+
|
|
16
|
+
const KEENABLE_SEARCH_URL = "https://api.keenable.ai/v1/search";
|
|
17
|
+
const KEENABLE_PUBLIC_SEARCH_URL = "https://api.keenable.ai/v1/search/public";
|
|
18
|
+
/** App identifier the public endpoint requires on keyless requests. */
|
|
19
|
+
const KEENABLE_APP_TITLE = "Gajae-Code";
|
|
20
|
+
const DEFAULT_NUM_RESULTS = 10;
|
|
21
|
+
const MAX_NUM_RESULTS = 50;
|
|
22
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
23
|
+
/** Cap on provider-supplied error text surfaced in fallback warnings and tool errors. */
|
|
24
|
+
const MAX_ERROR_MESSAGE_CHARS = 200;
|
|
25
|
+
|
|
26
|
+
/** Map our recency filter to a lookback window for Keenable's `published_after`. */
|
|
27
|
+
const RECENCY_DAYS: Record<"day" | "week" | "month" | "year", number> = {
|
|
28
|
+
day: 1,
|
|
29
|
+
week: 7,
|
|
30
|
+
month: 30,
|
|
31
|
+
year: 365,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export interface KeenableSearchParams {
|
|
35
|
+
query: string;
|
|
36
|
+
num_results?: number;
|
|
37
|
+
recency?: "day" | "week" | "month" | "year";
|
|
38
|
+
signal?: AbortSignal;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface KeenableSearchResult {
|
|
42
|
+
title?: string | null;
|
|
43
|
+
url?: string | null;
|
|
44
|
+
snippet?: string | null;
|
|
45
|
+
/** ISO 8601 publication timestamp in UTC, when known. */
|
|
46
|
+
published_at?: string | null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface KeenableSearchResponse {
|
|
50
|
+
results: KeenableSearchResult[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function asRecord(value: unknown): Record<string, unknown> | null {
|
|
54
|
+
if (typeof value !== "object" || value === null) return null;
|
|
55
|
+
return value as Record<string, unknown>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function malformedResponse(detail: string): never {
|
|
59
|
+
throw new SearchProviderError("keenable", `Keenable API returned malformed response body (${detail})`, 502);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Validate a 2xx body. A missing, null, or non-array `results` is a provider failure,
|
|
64
|
+
* so the caller tries its fallback providers; `results: []` is a real no-hit answer.
|
|
65
|
+
*/
|
|
66
|
+
function parseSearchResponse(value: unknown): KeenableSearchResponse {
|
|
67
|
+
const record = asRecord(value);
|
|
68
|
+
if (!record || Array.isArray(record)) malformedResponse("expected a JSON object");
|
|
69
|
+
if (!Array.isArray(record.results)) malformedResponse("results must be an array");
|
|
70
|
+
return { results: record.results as KeenableSearchResult[] };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getErrorMessage(value: unknown): string | null {
|
|
74
|
+
if (typeof value === "string") {
|
|
75
|
+
const trimmed = value.trim();
|
|
76
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const record = asRecord(value);
|
|
80
|
+
if (!record) return null;
|
|
81
|
+
|
|
82
|
+
for (const key of ["message", "error", "detail"]) {
|
|
83
|
+
const message = getErrorMessage(record[key]);
|
|
84
|
+
if (message) return message;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Collapse whitespace and control characters in remote error text and cap its length. */
|
|
91
|
+
function boundErrorMessage(text: string): string {
|
|
92
|
+
const collapsed = text.replace(/[\s\p{Cc}\p{Cf}]+/gu, " ").trim();
|
|
93
|
+
if (collapsed.length <= MAX_ERROR_MESSAGE_CHARS) return collapsed;
|
|
94
|
+
return `${collapsed.slice(0, MAX_ERROR_MESSAGE_CHARS - 1)}…`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Find an optional Keenable API key through AuthStorage's unified refresh pipeline. */
|
|
98
|
+
export async function findApiKey(
|
|
99
|
+
authStorage: AuthStorage,
|
|
100
|
+
sessionId: string | undefined,
|
|
101
|
+
signal: AbortSignal | undefined,
|
|
102
|
+
): Promise<string | null> {
|
|
103
|
+
return (await authStorage.getApiKey("keenable", sessionId, { signal })) ?? null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Exported for testing. Builds the Keenable request body from unified params. */
|
|
107
|
+
export function buildRequestBody(params: KeenableSearchParams, now: Date = new Date()): Record<string, unknown> {
|
|
108
|
+
const body: Record<string, unknown> = {
|
|
109
|
+
query: params.query,
|
|
110
|
+
max_results: clampNumResults(params.num_results, DEFAULT_NUM_RESULTS, MAX_NUM_RESULTS),
|
|
111
|
+
};
|
|
112
|
+
if (params.recency) {
|
|
113
|
+
// Send the full timestamp: a bare date resolves to midnight UTC on Keenable's
|
|
114
|
+
// side and would widen the window by up to a day.
|
|
115
|
+
const since = new Date(now.getTime() - RECENCY_DAYS[params.recency] * DAY_MS);
|
|
116
|
+
body.published_after = since.toISOString();
|
|
117
|
+
}
|
|
118
|
+
return body;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function callKeenableSearch(
|
|
122
|
+
apiKey: string | null,
|
|
123
|
+
params: KeenableSearchParams,
|
|
124
|
+
): Promise<KeenableSearchResponse> {
|
|
125
|
+
const headers: Record<string, string> = {
|
|
126
|
+
"Content-Type": "application/json",
|
|
127
|
+
"X-Keenable-Title": KEENABLE_APP_TITLE,
|
|
128
|
+
};
|
|
129
|
+
if (apiKey) headers["X-API-Key"] = apiKey;
|
|
130
|
+
|
|
131
|
+
const response = await fetch(apiKey ? KEENABLE_SEARCH_URL : KEENABLE_PUBLIC_SEARCH_URL, {
|
|
132
|
+
method: "POST",
|
|
133
|
+
headers,
|
|
134
|
+
body: JSON.stringify(buildRequestBody(params)),
|
|
135
|
+
signal: withHardTimeout(params.signal, "api"),
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
if (!response.ok) {
|
|
139
|
+
const errorText = await response.text();
|
|
140
|
+
const classified = classifyProviderHttpError("keenable", response.status, errorText);
|
|
141
|
+
if (classified) throw classified;
|
|
142
|
+
let message = errorText.trim();
|
|
143
|
+
if (message.length === 0) {
|
|
144
|
+
message = response.statusText;
|
|
145
|
+
} else {
|
|
146
|
+
try {
|
|
147
|
+
message = getErrorMessage(JSON.parse(errorText)) ?? message;
|
|
148
|
+
} catch {
|
|
149
|
+
// Keep raw text fallback.
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
throw new SearchProviderError(
|
|
153
|
+
"keenable",
|
|
154
|
+
`Keenable API error (${response.status}): ${boundErrorMessage(message)}`,
|
|
155
|
+
response.status,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return parseSearchResponse(await response.json());
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Execute Keenable web search. */
|
|
163
|
+
export async function searchKeenable(params: SearchParams): Promise<SearchResponse> {
|
|
164
|
+
const keenableParams: KeenableSearchParams = {
|
|
165
|
+
query: params.query,
|
|
166
|
+
num_results: params.numSearchResults ?? params.limit,
|
|
167
|
+
recency: params.recency,
|
|
168
|
+
signal: params.signal,
|
|
169
|
+
};
|
|
170
|
+
const apiKey = await findApiKey(params.authStorage, params.sessionId, params.signal);
|
|
171
|
+
const numResults = clampNumResults(keenableParams.num_results, DEFAULT_NUM_RESULTS, MAX_NUM_RESULTS);
|
|
172
|
+
const response = await callKeenableSearch(apiKey, keenableParams);
|
|
173
|
+
const sources: SearchSource[] = [];
|
|
174
|
+
|
|
175
|
+
for (const result of response.results) {
|
|
176
|
+
if (!result?.url) continue;
|
|
177
|
+
const snippet = result.snippet?.replace(/\s+/g, " ").trim();
|
|
178
|
+
const publishedDate = typeof result.published_at === "string" ? result.published_at : undefined;
|
|
179
|
+
sources.push({
|
|
180
|
+
title: result.title?.trim() || result.url,
|
|
181
|
+
url: result.url,
|
|
182
|
+
snippet: snippet || undefined,
|
|
183
|
+
publishedDate,
|
|
184
|
+
ageSeconds: dateToAgeSeconds(publishedDate),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
provider: "keenable",
|
|
190
|
+
sources: sources.slice(0, numResults),
|
|
191
|
+
authMode: apiKey ? "api_key" : undefined,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Search provider for Keenable web search. Keyless, so always available once selected. */
|
|
196
|
+
export class KeenableProvider extends SearchProvider {
|
|
197
|
+
readonly id = "keenable";
|
|
198
|
+
readonly label = "Keenable";
|
|
199
|
+
|
|
200
|
+
isAvailable(_authStorage: AuthStorage): boolean {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
search(params: SearchParams): Promise<SearchResponse> {
|
|
205
|
+
return searchKeenable(params);
|
|
206
|
+
}
|
|
207
|
+
}
|
package/src/web/search/types.ts
CHANGED
|
@@ -23,6 +23,7 @@ export type SearchProviderId =
|
|
|
23
23
|
| "kagi"
|
|
24
24
|
| "synthetic"
|
|
25
25
|
| "searxng"
|
|
26
|
+
| "keenable"
|
|
26
27
|
| "openai-compatible";
|
|
27
28
|
|
|
28
29
|
export type WebSearchMode = "on" | "off" | "auto";
|
|
@@ -71,6 +72,7 @@ export const CONFIGURABLE_SEARCH_PROVIDER_IDS = [
|
|
|
71
72
|
"kagi",
|
|
72
73
|
"synthetic",
|
|
73
74
|
"searxng",
|
|
75
|
+
"keenable",
|
|
74
76
|
] as const satisfies readonly SearchProviderId[];
|
|
75
77
|
|
|
76
78
|
const SEARCH_PROVIDER_IDS = [...CONFIGURABLE_SEARCH_PROVIDER_IDS, "openai-compatible"] as const;
|