forked from NoeFabris/opencode-antigravity-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-schema.ts
More file actions
89 lines (78 loc) · 4.04 KB
/
Copy pathbuild-schema.ts
File metadata and controls
89 lines (78 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { writeFileSync, mkdirSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { AntigravityConfigSchema } from "../src/plugin/config/schema.js";
const __dirname = dirname(fileURLToPath(import.meta.url));
const outputPath = join(__dirname, "../assets/antigravity.schema.json");
// Use zod v4's built-in toJSONSchema method
const rawSchema = AntigravityConfigSchema.toJSONSchema({
unrepresentable: "any",
override: (_ctx) => undefined // Use default handling
}) as Record<string, unknown>;
// Remove the "required" array since all fields have defaults and are optional
// This preserves backwards compatibility with the draft-07 schema behavior
delete rawSchema.required;
const envVarDescriptions: Record<string, string> = {
quiet_mode:
"Suppress most toast notifications (rate limit, account switching). Recovery toasts always shown. Env: OPENCODE_ANTIGRAVITY_QUIET=1",
debug:
"Enable debug logging to file. Env: OPENCODE_ANTIGRAVITY_DEBUG=1 (or =2 for verbose)",
log_dir:
"Custom directory for debug logs. Env: OPENCODE_ANTIGRAVITY_LOG_DIR=/path/to/logs",
keep_thinking:
"Preserve thinking blocks for Claude models using signature caching. May cause signature errors. Env: OPENCODE_ANTIGRAVITY_KEEP_THINKING=1",
session_recovery:
"Enable automatic session recovery from tool_result_missing errors. Env: OPENCODE_ANTIGRAVITY_SESSION_RECOVERY=1",
auto_resume:
"Automatically send resume prompt after successful recovery. Env: OPENCODE_ANTIGRAVITY_AUTO_RESUME=1",
resume_text:
"Custom text to send when auto-resuming after recovery. Env: OPENCODE_ANTIGRAVITY_RESUME_TEXT=continue",
empty_response_max_attempts:
"Maximum retry attempts when Antigravity returns an empty response (no candidates).",
empty_response_retry_delay_ms:
"Delay in milliseconds between empty response retries.",
tool_id_recovery:
"Enable tool ID orphan recovery. Matches mismatched tool responses by function name or creates placeholders.",
claude_tool_hardening:
"Enable tool hallucination prevention for Claude models. Injects parameter signatures and strict usage rules.",
proactive_token_refresh:
"Enable proactive background token refresh before expiry, ensuring requests never block.",
proactive_refresh_buffer_seconds:
"Seconds before token expiry to trigger proactive refresh.",
proactive_refresh_check_interval_seconds:
"Interval between proactive refresh checks in seconds.",
auto_update: "Enable automatic plugin updates. Env: OPENCODE_ANTIGRAVITY_AUTO_UPDATE=1",
};
const signatureCacheDescriptions: Record<string, string> = {
enabled: "Enable disk caching of thinking block signatures.",
memory_ttl_seconds: "In-memory TTL in seconds.",
disk_ttl_seconds: "Disk TTL in seconds.",
write_interval_seconds: "Background write interval in seconds.",
};
function addDescriptions(schema: Record<string, unknown>): void {
const props = schema.properties as Record<string, Record<string, unknown>> | undefined;
if (!props) return;
for (const [key, prop] of Object.entries(props)) {
if (envVarDescriptions[key]) {
prop.description = envVarDescriptions[key];
}
if (key === "signature_cache" && prop.properties) {
const cacheProps = prop.properties as Record<string, Record<string, unknown>>;
for (const [cacheKey, cacheProp] of Object.entries(cacheProps)) {
if (signatureCacheDescriptions[cacheKey]) {
cacheProp.description = signatureCacheDescriptions[cacheKey];
}
}
prop.description = "Signature cache configuration for persisting thinking block signatures. Only used when keep_thinking is enabled.";
}
}
}
const definitions = rawSchema.definitions as Record<string, Record<string, unknown>> | undefined;
if (definitions?.AntigravityConfig) {
addDescriptions(definitions.AntigravityConfig);
} else {
addDescriptions(rawSchema);
}
mkdirSync(dirname(outputPath), { recursive: true });
writeFileSync(outputPath, JSON.stringify(rawSchema, null, 2) + "\n");
console.log(`Schema written to ${outputPath}`);