Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Merge remote-tracking branch 'upstream/main' into fix/cursor-reply-failure-6706

Absterrg024e2ef00a381
diff --cc server/drivers/acp/core.ts
index f41a5c5203,65844c7551..5d2c17a016
--- a/server/drivers/acp/core.ts
+++ b/server/drivers/acp/core.ts
@@@ -64,10 -65,10 +64,10 @@@ import { acpSessionOperationKey, acpShe
import { openQuestionRequest, questionRequestFor, type AcpQuestionRequest } from "./question-requests.ts";
import { commandSummary, toolDetailPreview } from "../../tool-summary.ts";
import { acpToolEndEvents } from "./tool-items.ts";
- import { AcpHost } from "./host.ts"; import { SignInRequests, type AcpDriverHooks } from "./driver-hooks.ts";
+ import { AcpHost } from "./host.ts"; import { LiveSwitchRefused, SignInRequests, type AcpDriverHooks } from "./driver-hooks.ts";
import { exitBeforeResult } from "./exit-report.ts"; import { readNodeVersion } from "./node-version.ts";
import { decodeAcpConfig } from "./config-decode.ts";
-import { endTurn, trackAssistantImage, trackAssistantWords, trackThoughtAfterTool, trackRunningTool, trackToolEndShown, type AcpAskFinish, type AcpSession, type AcpTurn } from "./turn-state.ts";
+import { endTurn, receiveText, trackAssistantImage, trackAssistantWords, trackThoughtAfterTool, trackRunningTool, trackToolEndShown, type AcpAskFinish, type AcpSession, type AcpTurn } from "./turn-state.ts";
import { recoveryPromptFor } from "../../resume-recovery.ts";
import { noticeFailure } from "../../chat-notices.ts";
import { armIdleClose, engineIdleMs, sessionIdlePolicy, stopIdleClose } from "../session-idle.ts";
diff --cc server/drivers/acp/driver-hooks.ts
index bb405c4b52,83eea38aec..179a6b9266
--- a/server/drivers/acp/driver-hooks.ts
+++ b/server/drivers/acp/driver-hooks.ts
@@@ -29,12 -31,33 +31,37 @@@ export interface AcpDriverHooks
/** The failure a turn's thrown error stands for, in the person's words (a usage limit with its reset), or undefined to
* keep the error as it is. Must not throw. */
reportedFailure?(error: unknown): Error | undefined;
+ /** Gets the last text chunk of a prompt the agent answered with end_turn. When the agent sent a failed model call as
+ * that chunk instead of failing the prompt, returns the failure in its words, which fails the turn as a thrown one
+ * does; the text before the chunk stays the reply. Null for any other chunk. */
+ replyFailure?(chunk: string): string | null;
+ /** initialize's own `_meta` (beside clientCapabilities' vendor `_meta`), for an agent that reads who its client is there. */
+ initializeMeta?: Record<string, unknown>;
+ /** session/cancel's `_meta`, for an agent that reads how its turn was stopped there. */
+ cancelMeta?: Record<string, unknown>;
+ /** An agent that also ends each prompt with a notification of its own, which may come before the prompt's reply or
+ * without it. */
+ promptCompletion?: AcpPromptCompletion;
+ /** For an agent that can leave session/load unanswered after replaying the history: how long the replay must go quiet
+ * before the load counts as done. Undefined waits for the answer. */
+ loadReplayQuietMs?(turn: SendTurnInput): number | undefined;
+ /** The part of spawnArgs a running process must match for a turn to reuse it. What it leaves out, configureSession
+ * changes inside the live session, throwing LiveSwitchRefused when the agent refuses; a reused session then restarts. */
+ spawnContractArgs?(config: AcpConfig, turn: SendTurnInput): string[];
}
+ /** How an agent names the end of a prompt outside its session/prompt reply. */
+ export interface AcpPromptCompletion {
+ /** `_meta` each session/prompt carries, so the agent names that prompt when it ends. */
+ meta(promptId: string): Record<string, unknown>;
+ /** The prompt a notification ends (its session, and its id or null when it names none) and its answer in a session/prompt
+ * reply's shape; null for any other notification. */
+ read(msg: { method?: unknown; params?: unknown }): { sessionId: string; promptId: string | null; result: { stopReason: string; error?: string } } | null;
+ }
+
+ /** configureSession could not change a running session's model or effort in place. */
+ export class LiveSwitchRefused extends Error {}
+
const MAX_LINE_CHARS = 64 * 1024;
export class SignInRequests {