@hellcoder/companion 0.96.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/bin/cli.ts +168 -0
- package/bin/ctl.ts +528 -0
- package/bin/generate-token.ts +28 -0
- package/dist/apple-touch-icon.png +0 -0
- package/dist/assets/AgentsPage-DCFhrJ28.js +13 -0
- package/dist/assets/CronManager-EGwLJONv.js +1 -0
- package/dist/assets/IntegrationsPage-CTMRnbQS.js +1 -0
- package/dist/assets/LinearOAuthSettingsPage-CgQFMIgr.js +1 -0
- package/dist/assets/LinearSettingsPage-C9nok1qi.js +1 -0
- package/dist/assets/Playground-BV3k0RbV.js +109 -0
- package/dist/assets/PromptsPage-CFojqNKP.js +4 -0
- package/dist/assets/RunsPage-DUJ1QUSa.js +1 -0
- package/dist/assets/SandboxManager-CrVQ-VU_.js +8 -0
- package/dist/assets/SettingsPage-D1fPCL19.js +1 -0
- package/dist/assets/TailscalePage-D06cyvyC.js +1 -0
- package/dist/assets/index-BhUa1e6X.css +1 -0
- package/dist/assets/index-DkqeP-R9.js +134 -0
- package/dist/assets/sw-register-BibwRdvC.js +1 -0
- package/dist/assets/workbox-window.prod.es5-BIl4cyR9.js +2 -0
- package/dist/favicon.svg +8 -0
- package/dist/fonts/MesloLGSNerdFontMono-Bold.woff2 +0 -0
- package/dist/fonts/MesloLGSNerdFontMono-Regular.woff2 +0 -0
- package/dist/icon-192.png +0 -0
- package/dist/icon-512.png +0 -0
- package/dist/index.html +20 -0
- package/dist/logo-codex.svg +14 -0
- package/dist/logo-docker.svg +4 -0
- package/dist/logo.svg +14 -0
- package/dist/manifest.json +24 -0
- package/dist/sw.js +2 -0
- package/package.json +104 -0
- package/server/agent-cron-migrator.test.ts +610 -0
- package/server/agent-cron-migrator.ts +85 -0
- package/server/agent-executor.test.ts +1108 -0
- package/server/agent-executor.ts +346 -0
- package/server/agent-store.test.ts +588 -0
- package/server/agent-store.ts +185 -0
- package/server/agent-types.ts +138 -0
- package/server/ai-validation-settings.test.ts +128 -0
- package/server/ai-validation-settings.ts +35 -0
- package/server/ai-validator.test.ts +387 -0
- package/server/ai-validator.ts +271 -0
- package/server/auth-manager.test.ts +83 -0
- package/server/auth-manager.ts +150 -0
- package/server/auto-namer.test.ts +252 -0
- package/server/auto-namer.ts +78 -0
- package/server/backend-adapter.test.ts +38 -0
- package/server/backend-adapter.ts +54 -0
- package/server/cache-headers.test.ts +98 -0
- package/server/cache-headers.ts +61 -0
- package/server/claude-adapter.test.ts +1363 -0
- package/server/claude-adapter.ts +889 -0
- package/server/claude-container-auth.test.ts +44 -0
- package/server/claude-container-auth.ts +30 -0
- package/server/claude-protocol-contract.test.ts +71 -0
- package/server/claude-protocol-drift.test.ts +78 -0
- package/server/claude-session-discovery.test.ts +132 -0
- package/server/claude-session-discovery.ts +157 -0
- package/server/claude-session-history.test.ts +158 -0
- package/server/claude-session-history.ts +410 -0
- package/server/cli-launcher.test.ts +1343 -0
- package/server/cli-launcher.ts +1298 -0
- package/server/cli.test.ts +16 -0
- package/server/codex-adapter.test.ts +5545 -0
- package/server/codex-adapter.ts +3062 -0
- package/server/codex-container-auth.test.ts +50 -0
- package/server/codex-container-auth.ts +24 -0
- package/server/codex-home.test.ts +61 -0
- package/server/codex-home.ts +26 -0
- package/server/codex-protocol-contract.test.ts +96 -0
- package/server/codex-protocol-drift.test.ts +123 -0
- package/server/codex-ws-proxy.cjs +226 -0
- package/server/commands-discovery.test.ts +179 -0
- package/server/commands-discovery.ts +81 -0
- package/server/constants.ts +7 -0
- package/server/container-manager.test.ts +1211 -0
- package/server/container-manager.ts +1053 -0
- package/server/cron-scheduler.test.ts +957 -0
- package/server/cron-scheduler.ts +243 -0
- package/server/cron-store.test.ts +422 -0
- package/server/cron-store.ts +148 -0
- package/server/cron-types.ts +63 -0
- package/server/env-manager.test.ts +268 -0
- package/server/env-manager.ts +161 -0
- package/server/event-bus-types.ts +64 -0
- package/server/event-bus.test.ts +244 -0
- package/server/event-bus.ts +124 -0
- package/server/execution-store.test.ts +307 -0
- package/server/execution-store.ts +170 -0
- package/server/fs-utils.ts +15 -0
- package/server/git-utils.test.ts +938 -0
- package/server/git-utils.ts +421 -0
- package/server/github-pr.test.ts +498 -0
- package/server/github-pr.ts +379 -0
- package/server/image-pull-manager.test.ts +303 -0
- package/server/image-pull-manager.ts +279 -0
- package/server/index.ts +396 -0
- package/server/linear-agent-bridge.test.ts +1157 -0
- package/server/linear-agent-bridge.ts +629 -0
- package/server/linear-agent.test.ts +473 -0
- package/server/linear-agent.ts +479 -0
- package/server/linear-cache.test.ts +136 -0
- package/server/linear-cache.ts +113 -0
- package/server/linear-connections.test.ts +350 -0
- package/server/linear-connections.ts +231 -0
- package/server/linear-credential-migration.test.ts +337 -0
- package/server/linear-credential-migration.ts +63 -0
- package/server/linear-oauth-connections-migration.test.ts +268 -0
- package/server/linear-oauth-connections.test.ts +365 -0
- package/server/linear-oauth-connections.ts +294 -0
- package/server/linear-project-manager.test.ts +162 -0
- package/server/linear-project-manager.ts +111 -0
- package/server/linear-prompt-builder.test.ts +74 -0
- package/server/linear-prompt-builder.ts +61 -0
- package/server/linear-staging.test.ts +276 -0
- package/server/linear-staging.ts +142 -0
- package/server/logger.test.ts +393 -0
- package/server/logger.ts +259 -0
- package/server/metrics-collector.test.ts +413 -0
- package/server/metrics-collector.ts +350 -0
- package/server/metrics-types.ts +108 -0
- package/server/middleware/managed-auth.test.ts +264 -0
- package/server/middleware/managed-auth.ts +195 -0
- package/server/novnc-proxy.test.ts +333 -0
- package/server/novnc-proxy.ts +99 -0
- package/server/path-resolver.test.ts +552 -0
- package/server/path-resolver.ts +186 -0
- package/server/paths.test.ts +31 -0
- package/server/paths.ts +11 -0
- package/server/pr-poller.test.ts +191 -0
- package/server/pr-poller.ts +162 -0
- package/server/prompt-manager.test.ts +211 -0
- package/server/prompt-manager.ts +211 -0
- package/server/protocol/claude-upstream/README.md +19 -0
- package/server/protocol/claude-upstream/sdk.d.ts.txt +1943 -0
- package/server/protocol/codex-upstream/ClientNotification.ts.txt +5 -0
- package/server/protocol/codex-upstream/ClientRequest.ts.txt +60 -0
- package/server/protocol/codex-upstream/README.md +18 -0
- package/server/protocol/codex-upstream/ServerNotification.ts.txt +41 -0
- package/server/protocol/codex-upstream/ServerRequest.ts.txt +16 -0
- package/server/protocol/codex-upstream/v2/DynamicToolCallParams.ts.txt +6 -0
- package/server/protocol/codex-upstream/v2/DynamicToolCallResponse.ts.txt +6 -0
- package/server/protocol-monitor.ts +50 -0
- package/server/recorder.test.ts +454 -0
- package/server/recorder.ts +374 -0
- package/server/recording-hub/compat-validator.test.ts +150 -0
- package/server/recording-hub/compat-validator.ts +284 -0
- package/server/recording-hub/diagnostics.test.ts +140 -0
- package/server/recording-hub/diagnostics.ts +299 -0
- package/server/recording-hub/hub-config.test.ts +44 -0
- package/server/recording-hub/hub-config.ts +19 -0
- package/server/recording-hub/hub-routes.test.ts +417 -0
- package/server/recording-hub/hub-routes.ts +236 -0
- package/server/recording-hub/hub-store.test.ts +262 -0
- package/server/recording-hub/hub-store.ts +265 -0
- package/server/recording-hub/replay-adapter.test.ts +294 -0
- package/server/recording-hub/replay-adapter.ts +207 -0
- package/server/relay-client.test.ts +337 -0
- package/server/relay-client.ts +320 -0
- package/server/replay.test.ts +200 -0
- package/server/replay.ts +78 -0
- package/server/routes/agent-routes.test.ts +1400 -0
- package/server/routes/agent-routes.ts +409 -0
- package/server/routes/cron-routes.test.ts +881 -0
- package/server/routes/cron-routes.ts +103 -0
- package/server/routes/env-routes.test.ts +383 -0
- package/server/routes/env-routes.ts +95 -0
- package/server/routes/fs-routes.test.ts +1198 -0
- package/server/routes/fs-routes.ts +605 -0
- package/server/routes/git-routes.test.ts +813 -0
- package/server/routes/git-routes.ts +97 -0
- package/server/routes/linear-agent-routes.test.ts +721 -0
- package/server/routes/linear-agent-routes.ts +304 -0
- package/server/routes/linear-connection-routes.test.ts +927 -0
- package/server/routes/linear-connection-routes.ts +244 -0
- package/server/routes/linear-oauth-connection-routes.test.ts +406 -0
- package/server/routes/linear-oauth-connection-routes.ts +129 -0
- package/server/routes/linear-routes.test.ts +1510 -0
- package/server/routes/linear-routes.ts +953 -0
- package/server/routes/metrics-routes.test.ts +103 -0
- package/server/routes/metrics-routes.ts +13 -0
- package/server/routes/prompt-routes.ts +67 -0
- package/server/routes/sandbox-routes.test.ts +513 -0
- package/server/routes/sandbox-routes.ts +127 -0
- package/server/routes/settings-routes.ts +270 -0
- package/server/routes/skills-routes.test.ts +690 -0
- package/server/routes/skills-routes.ts +100 -0
- package/server/routes/system-routes.test.ts +637 -0
- package/server/routes/system-routes.ts +228 -0
- package/server/routes/tailscale-routes.test.ts +176 -0
- package/server/routes/tailscale-routes.ts +22 -0
- package/server/routes.test.ts +4655 -0
- package/server/routes.ts +1277 -0
- package/server/sandbox-manager.test.ts +378 -0
- package/server/sandbox-manager.ts +168 -0
- package/server/service.test.ts +1419 -0
- package/server/service.ts +718 -0
- package/server/session-creation-service.test.ts +661 -0
- package/server/session-creation-service.ts +473 -0
- package/server/session-git-info.ts +104 -0
- package/server/session-linear-issues.test.ts +118 -0
- package/server/session-linear-issues.ts +88 -0
- package/server/session-names.test.ts +94 -0
- package/server/session-names.ts +67 -0
- package/server/session-orchestrator.test.ts +1784 -0
- package/server/session-orchestrator.ts +973 -0
- package/server/session-state-machine.test.ts +606 -0
- package/server/session-state-machine.ts +207 -0
- package/server/session-store.test.ts +290 -0
- package/server/session-store.ts +146 -0
- package/server/session-types.ts +509 -0
- package/server/settings-manager.test.ts +275 -0
- package/server/settings-manager.ts +173 -0
- package/server/tailscale-manager.test.ts +553 -0
- package/server/tailscale-manager.ts +451 -0
- package/server/terminal-manager.ts +240 -0
- package/server/update-checker.test.ts +306 -0
- package/server/update-checker.ts +197 -0
- package/server/usage-limits.test.ts +536 -0
- package/server/usage-limits.ts +225 -0
- package/server/worktree-tracker.test.ts +243 -0
- package/server/worktree-tracker.ts +84 -0
- package/server/ws-auth.test.ts +59 -0
- package/server/ws-auth.ts +41 -0
- package/server/ws-bridge-browser-ingest.test.ts +272 -0
- package/server/ws-bridge-browser-ingest.ts +72 -0
- package/server/ws-bridge-browser.ts +112 -0
- package/server/ws-bridge-cli-ingest.test.ts +302 -0
- package/server/ws-bridge-cli-ingest.ts +81 -0
- package/server/ws-bridge-codex.test.ts +1837 -0
- package/server/ws-bridge-codex.ts +266 -0
- package/server/ws-bridge-controls.test.ts +124 -0
- package/server/ws-bridge-controls.ts +20 -0
- package/server/ws-bridge-persist.test.ts +296 -0
- package/server/ws-bridge-persist.ts +66 -0
- package/server/ws-bridge-publish.test.ts +234 -0
- package/server/ws-bridge-publish.ts +79 -0
- package/server/ws-bridge-replay.test.ts +44 -0
- package/server/ws-bridge-replay.ts +61 -0
- package/server/ws-bridge-types.ts +106 -0
- package/server/ws-bridge.test.ts +4777 -0
- package/server/ws-bridge.ts +1279 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import type { Hono } from "hono";
|
|
2
|
+
import { DEFAULT_ANTHROPIC_MODEL, getSettings, updateSettings, type UpdateChannel } from "../settings-manager.js";
|
|
3
|
+
import { linearCache } from "../linear-cache.js";
|
|
4
|
+
import { listConnections } from "../linear-connections.js";
|
|
5
|
+
import { hasContainerCodexAuth } from "../codex-container-auth.js";
|
|
6
|
+
|
|
7
|
+
export function registerSettingsRoutes(api: Hono): void {
|
|
8
|
+
api.get("/settings", (c) => {
|
|
9
|
+
const settings = getSettings();
|
|
10
|
+
const connections = listConnections();
|
|
11
|
+
return c.json({
|
|
12
|
+
anthropicApiKeyConfigured: !!settings.anthropicApiKey.trim(),
|
|
13
|
+
anthropicModel: settings.anthropicModel || DEFAULT_ANTHROPIC_MODEL,
|
|
14
|
+
claudeCodeOAuthTokenConfigured: !!settings.claudeCodeOAuthToken.trim(),
|
|
15
|
+
openaiApiKeyConfigured: !!settings.openaiApiKey.trim(),
|
|
16
|
+
codexDeviceAuthConfigured: hasContainerCodexAuth(),
|
|
17
|
+
onboardingCompleted: settings.onboardingCompleted,
|
|
18
|
+
linearApiKeyConfigured: !!settings.linearApiKey.trim() || connections.length > 0,
|
|
19
|
+
linearConnectionCount: connections.length,
|
|
20
|
+
linearAutoTransition: settings.linearAutoTransition,
|
|
21
|
+
linearAutoTransitionStateName: settings.linearAutoTransitionStateName,
|
|
22
|
+
linearArchiveTransition: settings.linearArchiveTransition,
|
|
23
|
+
linearArchiveTransitionStateName: settings.linearArchiveTransitionStateName,
|
|
24
|
+
linearOAuthConfigured: !!(settings.linearOAuthClientId.trim() && settings.linearOAuthClientSecret.trim() && settings.linearOAuthAccessToken.trim()),
|
|
25
|
+
linearOAuthCredentialsSaved: !!(settings.linearOAuthClientId.trim() && settings.linearOAuthClientSecret.trim()),
|
|
26
|
+
aiValidationEnabled: settings.aiValidationEnabled,
|
|
27
|
+
aiValidationAutoApprove: settings.aiValidationAutoApprove,
|
|
28
|
+
aiValidationAutoDeny: settings.aiValidationAutoDeny,
|
|
29
|
+
publicUrl: settings.publicUrl,
|
|
30
|
+
updateChannel: settings.updateChannel,
|
|
31
|
+
dockerAutoUpdate: settings.dockerAutoUpdate,
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
api.put("/settings", async (c) => {
|
|
36
|
+
const body = await c.req.json().catch(() => ({}));
|
|
37
|
+
if (body.anthropicApiKey !== undefined && typeof body.anthropicApiKey !== "string") {
|
|
38
|
+
return c.json({ error: "anthropicApiKey must be a string" }, 400);
|
|
39
|
+
}
|
|
40
|
+
if (body.anthropicModel !== undefined && typeof body.anthropicModel !== "string") {
|
|
41
|
+
return c.json({ error: "anthropicModel must be a string" }, 400);
|
|
42
|
+
}
|
|
43
|
+
if (body.linearApiKey !== undefined && typeof body.linearApiKey !== "string") {
|
|
44
|
+
return c.json({ error: "linearApiKey must be a string" }, 400);
|
|
45
|
+
}
|
|
46
|
+
if (body.linearAutoTransition !== undefined && typeof body.linearAutoTransition !== "boolean") {
|
|
47
|
+
return c.json({ error: "linearAutoTransition must be a boolean" }, 400);
|
|
48
|
+
}
|
|
49
|
+
if (body.linearAutoTransitionStateId !== undefined && typeof body.linearAutoTransitionStateId !== "string") {
|
|
50
|
+
return c.json({ error: "linearAutoTransitionStateId must be a string" }, 400);
|
|
51
|
+
}
|
|
52
|
+
if (body.linearAutoTransitionStateName !== undefined && typeof body.linearAutoTransitionStateName !== "string") {
|
|
53
|
+
return c.json({ error: "linearAutoTransitionStateName must be a string" }, 400);
|
|
54
|
+
}
|
|
55
|
+
if (body.linearArchiveTransition !== undefined && typeof body.linearArchiveTransition !== "boolean") {
|
|
56
|
+
return c.json({ error: "linearArchiveTransition must be a boolean" }, 400);
|
|
57
|
+
}
|
|
58
|
+
if (body.linearArchiveTransitionStateId !== undefined && typeof body.linearArchiveTransitionStateId !== "string") {
|
|
59
|
+
return c.json({ error: "linearArchiveTransitionStateId must be a string" }, 400);
|
|
60
|
+
}
|
|
61
|
+
if (body.linearArchiveTransitionStateName !== undefined && typeof body.linearArchiveTransitionStateName !== "string") {
|
|
62
|
+
return c.json({ error: "linearArchiveTransitionStateName must be a string" }, 400);
|
|
63
|
+
}
|
|
64
|
+
if (body.aiValidationEnabled !== undefined && typeof body.aiValidationEnabled !== "boolean") {
|
|
65
|
+
return c.json({ error: "aiValidationEnabled must be a boolean" }, 400);
|
|
66
|
+
}
|
|
67
|
+
if (body.aiValidationAutoApprove !== undefined && typeof body.aiValidationAutoApprove !== "boolean") {
|
|
68
|
+
return c.json({ error: "aiValidationAutoApprove must be a boolean" }, 400);
|
|
69
|
+
}
|
|
70
|
+
if (body.aiValidationAutoDeny !== undefined && typeof body.aiValidationAutoDeny !== "boolean") {
|
|
71
|
+
return c.json({ error: "aiValidationAutoDeny must be a boolean" }, 400);
|
|
72
|
+
}
|
|
73
|
+
if (body.publicUrl !== undefined) {
|
|
74
|
+
if (typeof body.publicUrl !== "string") {
|
|
75
|
+
return c.json({ error: "publicUrl must be a string" }, 400);
|
|
76
|
+
}
|
|
77
|
+
const trimmed = body.publicUrl.trim().replace(/\/+$/, "");
|
|
78
|
+
if (trimmed !== "" && !/^https?:\/\/.+/.test(trimmed)) {
|
|
79
|
+
return c.json({ error: "publicUrl must be a valid http/https URL" }, 400);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (body.updateChannel !== undefined && body.updateChannel !== "stable" && body.updateChannel !== "prerelease") {
|
|
83
|
+
return c.json({ error: "updateChannel must be 'stable' or 'prerelease'" }, 400);
|
|
84
|
+
}
|
|
85
|
+
if (body.linearOAuthClientId !== undefined && typeof body.linearOAuthClientId !== "string") {
|
|
86
|
+
return c.json({ error: "linearOAuthClientId must be a string" }, 400);
|
|
87
|
+
}
|
|
88
|
+
if (body.linearOAuthClientSecret !== undefined && typeof body.linearOAuthClientSecret !== "string") {
|
|
89
|
+
return c.json({ error: "linearOAuthClientSecret must be a string" }, 400);
|
|
90
|
+
}
|
|
91
|
+
if (body.linearOAuthWebhookSecret !== undefined && typeof body.linearOAuthWebhookSecret !== "string") {
|
|
92
|
+
return c.json({ error: "linearOAuthWebhookSecret must be a string" }, 400);
|
|
93
|
+
}
|
|
94
|
+
if (body.claudeCodeOAuthToken !== undefined && typeof body.claudeCodeOAuthToken !== "string") {
|
|
95
|
+
return c.json({ error: "claudeCodeOAuthToken must be a string" }, 400);
|
|
96
|
+
}
|
|
97
|
+
if (body.openaiApiKey !== undefined && typeof body.openaiApiKey !== "string") {
|
|
98
|
+
return c.json({ error: "openaiApiKey must be a string" }, 400);
|
|
99
|
+
}
|
|
100
|
+
if (body.onboardingCompleted !== undefined && typeof body.onboardingCompleted !== "boolean") {
|
|
101
|
+
return c.json({ error: "onboardingCompleted must be a boolean" }, 400);
|
|
102
|
+
}
|
|
103
|
+
if (body.dockerAutoUpdate !== undefined && typeof body.dockerAutoUpdate !== "boolean") {
|
|
104
|
+
return c.json({ error: "dockerAutoUpdate must be a boolean" }, 400);
|
|
105
|
+
}
|
|
106
|
+
const hasAnyField = body.anthropicApiKey !== undefined || body.anthropicModel !== undefined
|
|
107
|
+
|| body.claudeCodeOAuthToken !== undefined || body.openaiApiKey !== undefined
|
|
108
|
+
|| body.onboardingCompleted !== undefined
|
|
109
|
+
|| body.linearApiKey !== undefined || body.linearAutoTransition !== undefined
|
|
110
|
+
|| body.linearAutoTransitionStateId !== undefined || body.linearAutoTransitionStateName !== undefined
|
|
111
|
+
|| body.linearArchiveTransition !== undefined || body.linearArchiveTransitionStateId !== undefined
|
|
112
|
+
|| body.linearArchiveTransitionStateName !== undefined
|
|
113
|
+
|| body.linearOAuthClientId !== undefined || body.linearOAuthClientSecret !== undefined
|
|
114
|
+
|| body.linearOAuthWebhookSecret !== undefined
|
|
115
|
+
|| body.aiValidationEnabled !== undefined || body.aiValidationAutoApprove !== undefined
|
|
116
|
+
|| body.aiValidationAutoDeny !== undefined
|
|
117
|
+
|| body.publicUrl !== undefined
|
|
118
|
+
|| body.updateChannel !== undefined
|
|
119
|
+
|| body.dockerAutoUpdate !== undefined;
|
|
120
|
+
if (!hasAnyField) {
|
|
121
|
+
return c.json({ error: "At least one settings field is required" }, 400);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (typeof body.linearApiKey === "string") {
|
|
125
|
+
linearCache.clear();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const settings = updateSettings({
|
|
129
|
+
anthropicApiKey:
|
|
130
|
+
typeof body.anthropicApiKey === "string"
|
|
131
|
+
? body.anthropicApiKey.trim()
|
|
132
|
+
: undefined,
|
|
133
|
+
anthropicModel:
|
|
134
|
+
typeof body.anthropicModel === "string"
|
|
135
|
+
? (body.anthropicModel.trim() || DEFAULT_ANTHROPIC_MODEL)
|
|
136
|
+
: undefined,
|
|
137
|
+
claudeCodeOAuthToken:
|
|
138
|
+
typeof body.claudeCodeOAuthToken === "string"
|
|
139
|
+
? body.claudeCodeOAuthToken.trim()
|
|
140
|
+
: undefined,
|
|
141
|
+
openaiApiKey:
|
|
142
|
+
typeof body.openaiApiKey === "string"
|
|
143
|
+
? body.openaiApiKey.trim()
|
|
144
|
+
: undefined,
|
|
145
|
+
onboardingCompleted:
|
|
146
|
+
typeof body.onboardingCompleted === "boolean"
|
|
147
|
+
? body.onboardingCompleted
|
|
148
|
+
: undefined,
|
|
149
|
+
linearApiKey:
|
|
150
|
+
typeof body.linearApiKey === "string"
|
|
151
|
+
? body.linearApiKey.trim()
|
|
152
|
+
: undefined,
|
|
153
|
+
linearAutoTransition:
|
|
154
|
+
typeof body.linearAutoTransition === "boolean"
|
|
155
|
+
? body.linearAutoTransition
|
|
156
|
+
: undefined,
|
|
157
|
+
linearAutoTransitionStateId:
|
|
158
|
+
typeof body.linearAutoTransitionStateId === "string"
|
|
159
|
+
? body.linearAutoTransitionStateId.trim()
|
|
160
|
+
: undefined,
|
|
161
|
+
linearAutoTransitionStateName:
|
|
162
|
+
typeof body.linearAutoTransitionStateName === "string"
|
|
163
|
+
? body.linearAutoTransitionStateName.trim()
|
|
164
|
+
: undefined,
|
|
165
|
+
linearArchiveTransition:
|
|
166
|
+
typeof body.linearArchiveTransition === "boolean"
|
|
167
|
+
? body.linearArchiveTransition
|
|
168
|
+
: undefined,
|
|
169
|
+
linearArchiveTransitionStateId:
|
|
170
|
+
typeof body.linearArchiveTransitionStateId === "string"
|
|
171
|
+
? body.linearArchiveTransitionStateId.trim()
|
|
172
|
+
: undefined,
|
|
173
|
+
linearArchiveTransitionStateName:
|
|
174
|
+
typeof body.linearArchiveTransitionStateName === "string"
|
|
175
|
+
? body.linearArchiveTransitionStateName.trim()
|
|
176
|
+
: undefined,
|
|
177
|
+
linearOAuthClientId:
|
|
178
|
+
typeof body.linearOAuthClientId === "string"
|
|
179
|
+
? body.linearOAuthClientId.trim()
|
|
180
|
+
: undefined,
|
|
181
|
+
linearOAuthClientSecret:
|
|
182
|
+
typeof body.linearOAuthClientSecret === "string"
|
|
183
|
+
? body.linearOAuthClientSecret.trim()
|
|
184
|
+
: undefined,
|
|
185
|
+
linearOAuthWebhookSecret:
|
|
186
|
+
typeof body.linearOAuthWebhookSecret === "string"
|
|
187
|
+
? body.linearOAuthWebhookSecret.trim()
|
|
188
|
+
: undefined,
|
|
189
|
+
aiValidationEnabled:
|
|
190
|
+
typeof body.aiValidationEnabled === "boolean"
|
|
191
|
+
? body.aiValidationEnabled
|
|
192
|
+
: undefined,
|
|
193
|
+
aiValidationAutoApprove:
|
|
194
|
+
typeof body.aiValidationAutoApprove === "boolean"
|
|
195
|
+
? body.aiValidationAutoApprove
|
|
196
|
+
: undefined,
|
|
197
|
+
aiValidationAutoDeny:
|
|
198
|
+
typeof body.aiValidationAutoDeny === "boolean"
|
|
199
|
+
? body.aiValidationAutoDeny
|
|
200
|
+
: undefined,
|
|
201
|
+
publicUrl:
|
|
202
|
+
typeof body.publicUrl === "string"
|
|
203
|
+
? body.publicUrl.trim().replace(/\/+$/, "")
|
|
204
|
+
: undefined,
|
|
205
|
+
updateChannel:
|
|
206
|
+
body.updateChannel === "stable" || body.updateChannel === "prerelease"
|
|
207
|
+
? (body.updateChannel as UpdateChannel)
|
|
208
|
+
: undefined,
|
|
209
|
+
dockerAutoUpdate:
|
|
210
|
+
typeof body.dockerAutoUpdate === "boolean"
|
|
211
|
+
? body.dockerAutoUpdate
|
|
212
|
+
: undefined,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
const connectionsAfterUpdate = listConnections();
|
|
216
|
+
return c.json({
|
|
217
|
+
anthropicApiKeyConfigured: !!settings.anthropicApiKey.trim(),
|
|
218
|
+
anthropicModel: settings.anthropicModel || DEFAULT_ANTHROPIC_MODEL,
|
|
219
|
+
claudeCodeOAuthTokenConfigured: !!settings.claudeCodeOAuthToken.trim(),
|
|
220
|
+
openaiApiKeyConfigured: !!settings.openaiApiKey.trim(),
|
|
221
|
+
codexDeviceAuthConfigured: hasContainerCodexAuth(),
|
|
222
|
+
onboardingCompleted: settings.onboardingCompleted,
|
|
223
|
+
linearApiKeyConfigured: !!settings.linearApiKey.trim() || connectionsAfterUpdate.length > 0,
|
|
224
|
+
linearConnectionCount: connectionsAfterUpdate.length,
|
|
225
|
+
linearAutoTransition: settings.linearAutoTransition,
|
|
226
|
+
linearAutoTransitionStateName: settings.linearAutoTransitionStateName,
|
|
227
|
+
linearArchiveTransition: settings.linearArchiveTransition,
|
|
228
|
+
linearArchiveTransitionStateName: settings.linearArchiveTransitionStateName,
|
|
229
|
+
linearOAuthConfigured: !!(settings.linearOAuthClientId.trim() && settings.linearOAuthClientSecret.trim() && settings.linearOAuthAccessToken.trim()),
|
|
230
|
+
linearOAuthCredentialsSaved: !!(settings.linearOAuthClientId.trim() && settings.linearOAuthClientSecret.trim()),
|
|
231
|
+
aiValidationEnabled: settings.aiValidationEnabled,
|
|
232
|
+
aiValidationAutoApprove: settings.aiValidationAutoApprove,
|
|
233
|
+
aiValidationAutoDeny: settings.aiValidationAutoDeny,
|
|
234
|
+
publicUrl: settings.publicUrl,
|
|
235
|
+
updateChannel: settings.updateChannel,
|
|
236
|
+
dockerAutoUpdate: settings.dockerAutoUpdate,
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
api.post("/settings/anthropic/verify", async (c) => {
|
|
241
|
+
const body = await c.req.json().catch(() => ({} as { apiKey?: string }));
|
|
242
|
+
const apiKey = typeof body.apiKey === "string" ? body.apiKey.trim() : "";
|
|
243
|
+
if (!apiKey) {
|
|
244
|
+
return c.json({ valid: false, error: "API key is required" }, 400);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const controller = new AbortController();
|
|
248
|
+
const timer = setTimeout(() => controller.abort(), 10_000);
|
|
249
|
+
|
|
250
|
+
try {
|
|
251
|
+
const res = await fetch("https://api.anthropic.com/v1/models", {
|
|
252
|
+
headers: {
|
|
253
|
+
"x-api-key": apiKey,
|
|
254
|
+
"anthropic-version": "2023-06-01",
|
|
255
|
+
},
|
|
256
|
+
signal: controller.signal,
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
if (res.ok) {
|
|
260
|
+
return c.json({ valid: true });
|
|
261
|
+
}
|
|
262
|
+
return c.json({ valid: false, error: `API returned ${res.status}` });
|
|
263
|
+
} catch (err) {
|
|
264
|
+
const isAbort = err instanceof Error && err.name === "AbortError";
|
|
265
|
+
return c.json({ valid: false, error: isAbort ? "Request timed out" : "Request failed" });
|
|
266
|
+
} finally {
|
|
267
|
+
clearTimeout(timer);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|