Draft
Conversation
Open
|
You're treating Just skip the special handling for Diffsapp/src/chatSession.ts@@ -156,12 +156,6 @@ export class ChatSession {
this.pushSnippet(renderChatStatusSnippet("Session error", "error"));
this.pushSnippet(renderChatErrorSnippet(details, this.errorId()));
},
- onAuthenticationRequired: (authMethod) => {
- // Show authentication required message with instructions from the agent
- const message = `**Authentication Required**\n\n${authMethod.description}\n\nAfter authenticating, come back and create a new agent.`;
- this.pushSnippet(renderChatStatusSnippet("Authentication required", "error"));
- this.pushSnippet(renderChatErrorSnippet(message, this.errorId()));
- },
onPromptResult: (_requestId, result, metadata) => {
const promptMeta = asPromptMetadata(metadata);
if (!promptMeta) {app/src/agentProtocolSession.ts@@ -47,8 +47,6 @@ export interface AgentProtocolSessionOptions {
onInitializeError?: (error: unknown, message: Record<string, unknown>) => void;
onSessionReady?: (sessionId: string) => void;
onSessionError?: (error: unknown, message: Record<string, unknown>) => void;
- /** Called when agent requires authentication (e.g., opencode-login) */
- onAuthenticationRequired?: (authMethod: { id: string; name: string; description: string }) => void;
onPromptQueued?: (requestId: string, text: string, metadata: unknown) => void;
onPromptSent?: (requestId: string, text: string, metadata: unknown) => void;
onPromptResult?: (requestId: string, result: Record<string, unknown>, metadata: unknown) => void;
@@ -94,20 +92,12 @@ export class AgentProtocolSession {
}
this.initializationComplete = true;
// Check if agent advertises auth methods that require explicit authenticate call
- const authMethods = readAuthMethods(payload.result);
- const authMethodIds = authMethods?.map((m) => m.id) ?? [];
- // Only call authenticate for gemini-api-key; claude-login is informational only
+ const authMethodIds = readAuthMethodIds(payload.result);
+ // Only call authenticate for gemini-api-key; claude-login and opencode-login are informational only
// (Claude Code ACP doesn't implement authenticate - API key passed via env)
- if (authMethodIds.includes("gemini-api-key")) {
+ // (OpenCode uses credentials stored in ~/.config/opencode - if present, auth is already done)
+ if (authMethodIds && authMethodIds.includes("gemini-api-key")) {
this.dispatchAuthenticate("gemini-api-key");
- } else if (authMethodIds.includes("opencode-login")) {
- // OpenCode requires user to run `opencode auth login` in terminal
- const method = authMethods?.find((m) => m.id === "opencode-login");
- if (method) {
- this.options.onAuthenticationRequired?.(method);
- }
- // Don't proceed to session/new - agent can't work without auth
- return true;
} else {
this.dispatchSessionNew();
}
@@ -488,28 +478,18 @@ function readArray(value: unknown): unknown[] | null {
return Array.isArray(value) ? value : null;
}
-interface AuthMethod {
- id: string;
- name: string;
- description: string;
-}
-
-function readAuthMethods(result: unknown): AuthMethod[] | null {
+function readAuthMethodIds(result: unknown): string[] | null {
const obj = readObject(result);
if (!obj) return null;
const methods = readArray(obj.authMethods);
if (!methods || methods.length === 0) return [];
- const authMethods: AuthMethod[] = [];
+ const ids: string[] = [];
for (const m of methods) {
const rec = readObject(m);
const id = rec ? readString(rec.id) : null;
- const name = rec ? readString(rec.name) : null;
- const description = rec ? readString(rec.description) : null;
- if (id) {
- authMethods.push({ id, name: name ?? id, description: description ?? "" });
- }
+ if (id) ids.push(id);
}
- return authMethods;
+ return ids;
}
function readPermissionOptions(value: unknown): PermissionRequestOption[] | null { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Working except auth is not being inherited after login.