feat: configure agentrun provider profiles online
This commit is contained in:
@@ -93,6 +93,7 @@ async function processCommand(command) {
|
||||
case "goto": return withObserverSync(await gotoTarget(command.path || command.url || targetPath), "goto");
|
||||
case "newSession": return withObserverSync(await createSessionFromUi(), "newSession");
|
||||
case "sendPrompt": return withObserverSync(await sendPrompt(String(command.text || ""), {
|
||||
provider: command.provider,
|
||||
expectedAction: "turn",
|
||||
responsePath: "/v1/agent/chat",
|
||||
alternateResponsePaths: ["/v1/agent/chat/steer"],
|
||||
@@ -1593,9 +1594,11 @@ async function forceRecoverControlPageForCommand(reason) {
|
||||
async function sendPrompt(text, options = {}) {
|
||||
if (text.trim().length === 0) throw new Error("sendPrompt requires non-empty text");
|
||||
const responsePath = options.responsePath || "/v1/agent/chat";
|
||||
const requestedProvider = String(options.provider || "").trim();
|
||||
const controlRecovery = await ensureControlPageResponsiveForCommand("sendPrompt");
|
||||
const beforeUrl = currentPageUrl();
|
||||
const beforeEvidence = await promptSideEffectSnapshot();
|
||||
const providerSelection = requestedProvider ? await selectProvider(requestedProvider) : null;
|
||||
let editor = null;
|
||||
let composerRecovery = null;
|
||||
let editorWaitError = null;
|
||||
@@ -1618,7 +1621,7 @@ async function sendPrompt(text, options = {}) {
|
||||
if (!editor) {
|
||||
const snapshot = await controlPageLivenessSnapshot("sendPrompt-composer-editor-missing-final", 3000);
|
||||
const error = new Error("sendPrompt composer editor did not become visible");
|
||||
error.details = { beforeUrl, afterUrl: currentPageUrl(), controlRecovery, composerRecovery, snapshot, editorWaitError: errorSummary(editorWaitError), pageId, pageEpoch: controlPageEpoch, valuesRedacted: true };
|
||||
error.details = { beforeUrl, afterUrl: currentPageUrl(), requestedProvider: requestedProvider || null, providerSelection, controlRecovery, composerRecovery, snapshot, editorWaitError: errorSummary(editorWaitError), pageId, pageEpoch: controlPageEpoch, valuesRedacted: true };
|
||||
throw error;
|
||||
}
|
||||
editor = await fillComposerEditorWithRetry(editor, text, { beforeUrl, controlRecovery });
|
||||
@@ -1658,6 +1661,8 @@ async function sendPrompt(text, options = {}) {
|
||||
afterUrl: currentPageUrl(),
|
||||
textHash: sha256Text(text),
|
||||
textBytes: Buffer.byteLength(text),
|
||||
requestedProvider: requestedProvider || null,
|
||||
providerSelection,
|
||||
submitted: false,
|
||||
blocked: true,
|
||||
degradedReason: options.noActiveReason || "composer-action-mismatch",
|
||||
@@ -1708,6 +1713,8 @@ async function sendPrompt(text, options = {}) {
|
||||
afterUrl: currentPageUrl(),
|
||||
textHash: sha256Text(text),
|
||||
textBytes: Buffer.byteLength(text),
|
||||
requestedProvider: requestedProvider || null,
|
||||
providerSelection,
|
||||
chatSubmit: { status: null, statusText: null, urlPath: responsePath, waitError: chatResponse.waitError, sideEffectObserved: true, sideEffect },
|
||||
controlRecovery,
|
||||
pageId,
|
||||
@@ -1720,6 +1727,8 @@ async function sendPrompt(text, options = {}) {
|
||||
afterUrl: currentPageUrl(),
|
||||
textHash: sha256Text(text),
|
||||
textBytes: Buffer.byteLength(text),
|
||||
requestedProvider: requestedProvider || null,
|
||||
providerSelection,
|
||||
chatSubmit: { status: null, statusText: null, urlPath: responsePath, waitError: chatResponse.waitError, sideEffectObserved: false, sideEffect },
|
||||
controlRecovery,
|
||||
pageId,
|
||||
@@ -1755,6 +1764,8 @@ async function sendPrompt(text, options = {}) {
|
||||
afterUrl: currentPageUrl(),
|
||||
textHash: sha256Text(text),
|
||||
textBytes: Buffer.byteLength(text),
|
||||
requestedProvider: requestedProvider || null,
|
||||
providerSelection,
|
||||
chatSubmit: {
|
||||
status: chatStatus,
|
||||
statusText: chatResponse.statusText(),
|
||||
|
||||
Reference in New Issue
Block a user