Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

833 B
Raw Blame
import type { AgentTriggerExecutionHostDeps } from './host';

type ContinueResolver = NonNullable<AgentTriggerExecutionHostDeps['prepareContinue']>;

export interface AgentContinuationResolverDeps {
  eventActor: ContinueResolver;
  internalSources: ReadonlyMap<string, ContinueResolver>;
}

/** Selects the single continuation adapter authorized for this delivery. */
export function createAgentContinuationResolver({
  eventActor,
  internalSources,
}: AgentContinuationResolverDeps): ContinueResolver {
  return (envelope, context) => {
    if (envelope.target.bindingId != null && envelope.target.sourceKeyId != null) {
      return eventActor(envelope, context);
    }
    if (envelope.event.source.type !== 'internal') {
      return;
    }
    return internalSources.get(envelope.event.source.id)?.(envelope, context);
  };
}