Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,9 @@ docs/tutorials/captures/
# Vendored binaries (large, platform-specific)
scripts/bin/yt-dlp
scripts/bin/yt-dlp_*

# Local debugging scripts — not shipped
# codex-sniff.ts: local proxy between Codex CLI and Vercel AI Gateway
# for inspecting request/response shapes end-to-end. Kept out of git
# because it's a developer tool, not product code.
scripts/codex-sniff.ts
6 changes: 3 additions & 3 deletions deploy/cloud-agent-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"start": "tsx entrypoint.ts"
},
"dependencies": {
"@elizaos/core": "workspace:*",
"@elizaos/plugin-sql": "workspace:*",
"@elizaos/plugin-elizacloud": "workspace:*",
"@elizaos/core": "2.0.0-alpha.115",
"@elizaos/plugin-sql": "2.0.0-alpha.18",
"@elizaos/plugin-elizacloud": "2.0.0-alpha.7",
"tsx": "4.21.0"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"@clack/prompts": "^1.1.0",
"@electric-sql/pglite": "^0.3.16",
"@elizaos/core": "workspace:*",
"@elizaos/plugin-agent-orchestrator": "workspace:*",
"@elizaos/plugin-agent-orchestrator": "0.6.1",
"@elizaos/plugin-agent-skills": "workspace:*",
"@elizaos/plugin-commands": "workspace:*",
"@elizaos/plugin-anthropic": "workspace:*",
Expand Down
5 changes: 3 additions & 2 deletions packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"dependencies": {
"@clack/prompts": "^1.0.0",
"@elizaos/core": "workspace:*",
"@elizaos/plugin-agent-orchestrator": "workspace:*",
"@elizaos/plugin-agent-orchestrator": "0.6.1",
"@elizaos/plugin-agent-skills": "workspace:*",
"@elizaos/plugin-anthropic": "workspace:*",
"@elizaos/plugin-coding-agent": "0.1.0-next.0",
Expand Down Expand Up @@ -152,6 +152,7 @@
"@miladyai/shared": "workspace:*",
"@noble/curves": "^2.0.1",
"@whiskeysockets/baileys": "7.0.0-rc.9",
"coding-agent-adapters": "0.16.3",
"dotenv": "^17.2.3",
"drizzle-orm": "0.45.1",
"ethers": "^6.16.0",
Expand All @@ -160,7 +161,7 @@
"json5": "^2.2.3",
"pg": "^8.16.3",
"pino": "^10.3.1",
"pty-manager": "1.10.2",
"pty-manager": "1.11.0",
"puppeteer-core": "^24.37.5",
"qrcode": "^1.5.4",
"ws": "^8.19.0",
Expand Down
65 changes: 40 additions & 25 deletions packages/agent/src/api/coding-agent-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import crypto from "node:crypto";
import http from "node:http";
import type http from "node:http";

import {
type AgentRuntime,
Expand All @@ -17,38 +17,35 @@ import {
stringToUuid,
type UUID,
} from "@elizaos/core";

import type {
CoordinationLLMResponse,
PTYService,
} from "./parse-action-block.js";
import {
parseActionBlock,
stripActionBlockFromDisplay,
} from "./parse-action-block.js";
import type { ElizaConfig } from "../config/config.js";
import type { AgentEventPayloadLike } from "../runtime/agent-event-service.js";
import type { AppManager } from "../services/app-manager.js";
import type { SandboxManager } from "../services/sandbox-manager.js";
import { generateChatResponse as generateChatResponseFromChatRoutes } from "./chat-routes.js";
import type { CloudRouteState } from "./cloud-routes.js";
import type { ConnectorHealthMonitor } from "./connector-health.js";
import type {
SwarmEvent,
TaskCompletionSummary,
TaskContext,
} from "./coordinator-types.js";
import type { AgentEventPayloadLike } from "../runtime/agent-event-service.js";
import { resolveAppUserName, type ConversationMeta } from "./server-helpers.js";
import type { DropService } from "./drop-service.js";
import {
readJsonBody as parseJsonBody,
type ReadJsonBodyOptions,
sendJson,
sendJsonError,
} from "./http-helpers.js";
import type {
CoordinationLLMResponse,
PTYService,
} from "./parse-action-block.js";
import {
generateChatResponse as generateChatResponseFromChatRoutes,
} from "./chat-routes.js";
import type { ElizaConfig } from "../config/config.js";
import type { SandboxManager } from "../services/sandbox-manager.js";
import type { AppManager } from "../services/app-manager.js";
parseActionBlock,
stripActionBlockFromDisplay,
} from "./parse-action-block.js";
import type { RegistryService } from "./registry-service.js";
import type { DropService } from "./drop-service.js";
import type { CloudRouteState } from "./cloud-routes.js";
import type { ConnectorHealthMonitor } from "./connector-health.js";
import { type ConversationMeta, resolveAppUserName } from "./server-helpers.js";

// ---------------------------------------------------------------------------
// Internal type re-used in this module
Expand Down Expand Up @@ -256,7 +253,9 @@ export function wireCodingAgentWsBridge(st: CodingAgentServerState): boolean {
* finish, we synthesize a summary via the agent's LLM and post it as a
* persisted message in the conversation.
*/
export function wireCodingAgentSwarmSynthesis(st: CodingAgentServerState): boolean {
export function wireCodingAgentSwarmSynthesis(
st: CodingAgentServerState,
): boolean {
if (!st.runtime) return false;
const coordinator = getCoordinatorFromRuntime(st.runtime);
if (!coordinator?.setSwarmCompleteCallback) return false;
Expand Down Expand Up @@ -370,7 +369,9 @@ export async function handleSwarmSynthesis(
* If the callback fails or Eliza's response has no action block,
* returns null → coordinator falls back to the small LLM.
*/
export function wireCoordinatorEventRouting(st: CodingAgentServerState): boolean {
export function wireCoordinatorEventRouting(
st: CodingAgentServerState,
): boolean {
if (!st.runtime) return false;
const coordinator = getCoordinatorFromRuntime(st.runtime);
if (!coordinator?.setAgentDecisionCallback) return false;
Expand Down Expand Up @@ -453,9 +454,14 @@ export function wireCoordinatorEventRouting(st: CodingAgentServerState): boolean
rt.llmModeOption = "SMALL";
let result: { text: string; agentName?: string };
try {
result = await generateChatResponseFromChatRoutes(runtime, message, agentName, {
resolveNoResponseText: () => "I'll look into that.",
});
result = await generateChatResponseFromChatRoutes(
runtime,
message,
agentName,
{
resolveNoResponseText: () => "I'll look into that.",
},
);
} finally {
rt.llmModeOption = prevLlmMode;
}
Expand Down Expand Up @@ -536,6 +542,7 @@ export async function handleCodingAgentsFallback(
installed?: boolean;
installCommand?: string;
docsUrl?: string;
auth?: Record<string, unknown>;
};
type CodeTaskService = {
getTasks?: () => Promise<
Expand Down Expand Up @@ -673,6 +680,9 @@ export async function handleCodingAgentsFallback(
? raw.installCommand
: undefined,
docsUrl: typeof raw.docsUrl === "string" ? raw.docsUrl : undefined,
...(raw.auth && typeof raw.auth === "object"
? { auth: raw.auth as Record<string, unknown> }
: {}),
},
];
});
Expand Down Expand Up @@ -890,6 +900,11 @@ export async function handleCodingAgentsFallback(
}
}

// NOTE: POST /api/coding-agents/auth/:agent lives in server.ts's
// private `handleCodingAgentsFallback`, which is the copy actually
// wired into the request pipeline. Don't re-add it here — the
// handlers would drift and only one would run. See PR #1757 review.

// Not handled by fallback
return false;
}
Expand Down
41 changes: 33 additions & 8 deletions packages/agent/src/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,18 @@ import {
ONBOARDING_PROVIDER_CATALOG,
} from "../contracts/onboarding.js";
import { createIntegrationTelemetrySpan } from "../diagnostics/integration-observability.js";
import { registerClientChatSendHandler } from "../services/client-chat-sender.js";
import { EMOTE_BY_ID, EMOTE_CATALOG } from "../emotes/catalog.js";
import { resolveDefaultAgentWorkspaceDir } from "../providers/workspace.js";
import {
type AgentEventPayloadLike,
type AgentEventServiceLike,
getAgentEventService,
} from "../runtime/agent-event-service.js";
import * as agentOrchestratorCompat from "../runtime/agent-orchestrator-compat.js";
import {
CORE_PLUGINS,
OPTIONAL_CORE_PLUGINS,
} from "../runtime/core-plugins.js";
import * as agentOrchestratorCompat from "../runtime/agent-orchestrator-compat.js";
import {
buildTestHandler,
registerCustomActionLive,
Expand Down Expand Up @@ -116,6 +115,7 @@ import {
importAgent,
} from "../services/agent-export.js";
import { AppManager } from "../services/app-manager.js";
import { registerClientChatSendHandler } from "../services/client-chat-sender.js";
import { createConfigPluginManager } from "../services/config-plugin-manager.js";
import {
getMcpServerDetails,
Expand Down Expand Up @@ -181,6 +181,7 @@ import { handleAppPackageRoutes } from "./app-package-routes.js";
import { handleAppsRoutes } from "./apps-routes.js";
import { handleAuthRoutes } from "./auth-routes.js";
import { handleAvatarRoutes } from "./avatar-routes.js";
import { handleBrowserWorkspaceRoutes } from "./browser-workspace-routes.js";
import {
buildBscApproveUnsignedTx,
buildBscBuyUnsignedTx,
Expand All @@ -191,7 +192,6 @@ import {
resolvePrimaryBscRpcUrl,
} from "./bsc-trade.js";
import { handleBugReportRoutes } from "./bug-report-routes.js";
import { handleBrowserWorkspaceRoutes } from "./browser-workspace-routes.js";
import { handleCharacterRoutes } from "./character-routes.js";
import {
generateChatResponse as generateChatResponseFromChatRoutes,
Expand Down Expand Up @@ -237,6 +237,8 @@ import {
sendJson,
sendJsonError,
} from "./http-helpers.js";
import { handleIMessageRoute } from "./imessage-routes.js";
import { handleInboxRoute } from "./inbox-routes.js";
import { handleKnowledgeRoutes } from "./knowledge-routes.js";
import { getKnowledgeService } from "./knowledge-service-loader.js";
import { handleLifeOpsRoutes } from "./lifeops-routes.js";
Expand All @@ -251,14 +253,14 @@ import { handleMemoryRoutes } from "./memory-routes.js";
import { buildWhitelistTree, generateProof } from "./merkle-tree.js";
import { handleMiscRoutes } from "./misc-routes.js";
import { handleModelsRoutes } from "./models-routes.js";
import { tryHandleMusicPlayerStatusFallback } from "./music-player-route-fallback.js";
import { handleNfaRoutes } from "./nfa-routes.js";
import { handleOnboardingRoutes } from "./onboarding-routes.js";
import type {
CoordinationLLMResponse,
PTYService,
} from "./parse-action-block.js";
import { handlePermissionRoutes } from "./permissions-routes.js";
import { handleRolodexRoutes } from "./rolodex-routes.js";
import { handlePermissionsExtraRoutes } from "./permissions-routes-extra.js";
import { handlePluginRoutes } from "./plugin-routes.js";
import {
Expand All @@ -272,7 +274,7 @@ import {
import { handleProviderSwitchRoutes } from "./provider-switch-routes.js";
import { handleRegistryRoutes } from "./registry-routes.js";
import { RegistryService } from "./registry-service.js";
import { tryHandleMusicPlayerStatusFallback } from "./music-player-route-fallback.js";
import { handleRolodexRoutes } from "./rolodex-routes.js";
import { tryHandleRuntimePluginRoute } from "./runtime-plugin-routes.js";
import { handleSandboxRoute } from "./sandbox-routes.js";
import { hasPersistedOnboardingState } from "./server-helpers.js";
Expand All @@ -295,7 +297,6 @@ import {
} from "./twitter-verify.js";
import { TxService } from "./tx-service.js";
import { handleUpdateRoutes } from "./update-routes.js";
import { handleWebsiteBlockerRoutes } from "./website-blocker-routes.js";
import {
fetchEvmBalances,
fetchSolanaBalances,
Expand All @@ -315,12 +316,11 @@ import {
recordWalletTradeLedgerEntry,
updateWalletTradeLedgerEntryStatus,
} from "./wallet-trading-profile.js";
import { handleWebsiteBlockerRoutes } from "./website-blocker-routes.js";
import {
applyWhatsAppQrOverride,
handleWhatsAppRoute,
} from "./whatsapp-routes.js";
import { handleIMessageRoute } from "./imessage-routes.js";
import { handleInboxRoute } from "./inbox-routes.js";
import { handleWorkbenchRoutes } from "./workbench-routes.js";

export {
Expand Down Expand Up @@ -4245,6 +4245,7 @@ async function handleCodingAgentsFallback(
installed?: boolean;
installCommand?: string;
docsUrl?: string;
auth?: Record<string, unknown>;
};
type CodeTaskService = {
getTasks?: () => Promise<
Expand Down Expand Up @@ -4382,6 +4383,9 @@ async function handleCodingAgentsFallback(
? raw.installCommand
: undefined,
docsUrl: typeof raw.docsUrl === "string" ? raw.docsUrl : undefined,
...(raw.auth && typeof raw.auth === "object"
? { auth: raw.auth as Record<string, unknown> }
: {}),
},
];
});
Expand Down Expand Up @@ -4611,6 +4615,27 @@ async function handleCodingAgentsFallback(
}
}

// POST /api/coding-agents/auth/:agent — trigger CLI auth flow
const authMatch = pathname.match(/^\/api\/coding-agents\/auth\/(\w+)$/);
if (method === "POST" && authMatch) {
const agentType = authMatch[1];
try {
const { createAdapter } = await import("coding-agent-adapters");
const adapter = createAdapter(
agentType as import("coding-agent-adapters").AdapterType,
);
const result = await adapter.triggerAuth();
if (!result) {
json(res, { error: `No auth flow available for ${agentType}` });
} else {
json(res, result);
}
} catch (e) {
error(res, `Auth trigger failed: ${e}`, 500);
}
return true;
}

// Not handled by fallback
return false;
}
Expand Down
Loading
Loading