Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

feat: route native Astra through OmniRush gateway

Samrat Talukdar1525f87fa694
diff --git a/apps/server/src/omnirush-agent-prompt.ts b/apps/server/src/omnirush-agent-prompt.ts
index 1b93da80..f3d4f48a 100644
--- a/apps/server/src/omnirush-agent-prompt.ts
+++ b/apps/server/src/omnirush-agent-prompt.ts
@@ -35,6 +35,7 @@ Hard rule: never copy private memory into repo files. Store only redacted summar
- If required setup or credentials are missing, ask one targeted question and continue once provided.
- If you change code, run the smallest meaningful test.
+- Use the task tool to delegate bounded, independent work to subagents when parallel exploration, implementation, or review will materially improve the result. Keep delegated activity visible in the session and synthesize it before answering.
- If steps repeat, capture them as a skill following the \`Skill creation:\` instruction in this prompt.
- Prefer clear, practical steps over abstract explanations.
diff --git a/apps/server/src/omnirush-runtime-config.test.ts b/apps/server/src/omnirush-runtime-config.test.ts
index d5572436..9b7ad0d9 100644
--- a/apps/server/src/omnirush-runtime-config.test.ts
+++ b/apps/server/src/omnirush-runtime-config.test.ts
@@ -111,6 +111,46 @@ describe("omnirush runtime config file", () => {
});
});
+ test("injects the account-scoped internal gateway without persisting its access token", () => {
+ const parsed = buildOmniRushRuntimeConfigObjectFromSnapshot({}, {
+ baseUrl: "http://127.0.0.1:8090/omnirush/v1",
+ });
+ const providers = parsed.provider as Record<string, Record<string, unknown>>;
+
+ expect(parsed.model).toBe("omnirush/gpt-6-astra");
+ expect(providers.omnirush).toMatchObject({
+ npm: "@ai-sdk/openai",
+ name: "OmniRush.ai",
+ env: ["OMNIRUSH_ACCESS_TOKEN"],
+ options: { baseURL: "http://127.0.0.1:8090/omnirush/v1" },
+ models: {
+ "gpt-6-astra": {
+ name: "Astra",
+ reasoning: true,
+ tool_call: true,
+ },
+ },
+ });
+ expect(JSON.stringify(parsed)).not.toContain("access-token");
+ });
+
+ test("reserves the internal provider id for the account-scoped gateway", () => {
+ const parsed = buildOmniRushRuntimeConfigObjectFromSnapshot({
+ provider: {
+ omnirush: { npm: "untrusted-override", name: "Wrong route" },
+ },
+ }, {
+ baseUrl: "https://api.omnirush.ai/omnirush/v1",
+ });
+ const providers = parsed.provider as Record<string, Record<string, unknown>>;
+
+ expect(parsed.model).toBe("omnirush/gpt-6-astra");
+ expect(providers.omnirush).toMatchObject({
+ npm: "@ai-sdk/openai",
+ options: { baseURL: "https://api.omnirush.ai/omnirush/v1" },
+ });
+ });
+
test("workspace runtime rows never reach the injected file", async () => {
const { config } = await setup();
await writeRuntimeOpencodeConfig(config, "ws_1", (current) => ({
@@ -137,6 +177,7 @@ describe("omnirush runtime config file", () => {
expect(prompt).toContain("## Memory\n");
expect(prompt).toContain("## OmniRush.ai Artifacts");
expect(prompt).toContain("## Connected work");
+ expect(prompt).toContain("delegate bounded, independent work to subagents");
// Den removed the Memory Bank; the prompt must not teach capabilities that
// the live catalog can no longer return.
expect(prompt).not.toContain("Memory Bank");
diff --git a/apps/server/src/omnirush-runtime-config.ts b/apps/server/src/omnirush-runtime-config.ts
index 57bcddfc..688ad61a 100644
--- a/apps/server/src/omnirush-runtime-config.ts
+++ b/apps/server/src/omnirush-runtime-config.ts
@@ -43,6 +43,56 @@ import {
import { CONNECT_MCP_SERVER_NAME_PREFIX } from "./connect-mcp-server-catalog.js";
import { OMNIRUSH_AGENT_PROMPT } from "./omnirush-agent-prompt.js";
+const INTERNAL_PROVIDER_ID = "omnirush";
+const INTERNAL_MODEL_ID = "gpt-6-astra";
+
+type InternalGatewayRuntime = {
+ baseUrl: string;
+};
+
+function resolveInternalGatewayRuntime(
+ env: NodeJS.ProcessEnv = process.env,
+): InternalGatewayRuntime | undefined {
+ const baseUrl = env.OMNIRUSH_GATEWAY_URL?.trim().replace(/\/+$/, "");
+ const accessToken = env.OMNIRUSH_ACCESS_TOKEN?.trim();
+ if (!baseUrl || !accessToken) return undefined;
+
+ let url: URL;
+ try {
+ url = new URL(baseUrl);
+ } catch {
+ return undefined;
+ }
+ if (url.protocol !== "https:" && !(url.protocol === "http:" && ["127.0.0.1", "localhost", "::1"].includes(url.hostname))) {
+ return undefined;
+ }
+ return { baseUrl: url.toString().replace(/\/$/, "") };
+}
+
+function internalGatewayProvider(runtime: InternalGatewayRuntime): Record<string, unknown> {
+ return {
+ // The native OpenAI provider uses the Responses API, which preserves
+ // reasoning summaries, tool calls, and delegated task events. The generic
+ // compatibility provider only emits /chat/completions and loses those
+ // Astra capabilities.
+ npm: "@ai-sdk/openai",
+ name: "OmniRush.ai",
+ env: ["OMNIRUSH_ACCESS_TOKEN"],
+ options: { baseURL: runtime.baseUrl },
+ models: {
+ [INTERNAL_MODEL_ID]: {
+ name: "Astra",
+ reasoning: true,
+ tool_call: true,
+ structured_output: true,
+ temperature: true,
+ limit: { context: 400_000, output: 128_000 },
+ modalities: { input: ["text", "image", "pdf"], output: ["text"] },
+ },
+ },
+ };
+}
+
export async function buildOmniRushRuntimeConfigObject(
config?: ServerConfig,
): Promise<Record<string, unknown>> {
@@ -52,18 +102,30 @@ export async function buildOmniRushRuntimeConfigObject(
// engine-pool fingerprint. Per-workspace MCPs reach the engine through the
// dynamic push path instead.
const runtimeConfig = config ? await readGlobalRuntimeOpencodeConfig(config) : {};
- return buildOmniRushRuntimeConfigObjectFromSnapshot(runtimeConfig);
+ return buildOmniRushRuntimeConfigObjectFromSnapshot(
+ runtimeConfig,
+ resolveInternalGatewayRuntime(),
+ );
}
export function buildOmniRushRuntimeConfigObjectFromSnapshot(
runtimeConfig: RuntimeOpencodeConfig,
+ internalGateway?: InternalGatewayRuntime,
): Record<string, unknown> {
const disabledProviders = runtimeDisabledProviderList(runtimeConfig);
const permissions = legacyExecutionPermissions(runtimeConfig.managedPolicy?.execution);
const { managedPolicy: _managedPolicy, ...engineConfig } = runtimeConfig;
- const provider = runtimeProviderMap(runtimeConfig);
+ const provider = {
+ ...runtimeProviderMap(runtimeConfig),
+ ...(internalGateway
+ ? { [INTERNAL_PROVIDER_ID]: internalGatewayProvider(internalGateway) }
+ : {}),
+ };
return {
...engineConfig,
+ ...(internalGateway
+ ? { model: `${INTERNAL_PROVIDER_ID}/${INTERNAL_MODEL_ID}` }
+ : {}),
...(runtimeConfig.managedPolicy?.allowCustomProviders === false ? { enabled_providers: [
...Object.keys(provider).filter((id) => /^(?:lpr_|omnirush$)/i.test(id)),
...(runtimeConfig.managedPolicy.allowZenModel !== false ? ["opencode"] : []),