|
1 | 1 | import { AGENT_TOOLS, AGENT_TOOL_NAMES, RESERVED_AGENT_TOOL_NAMES, getToolsForMode, SYSTEM_PROMPT_ASK, SYSTEM_PROMPT_ACT, SYSTEM_PROMPT_ACT_COMPACT, SYSTEM_PROMPT_ACT_MID, SYSTEM_PROMPT_DEV_APPENDIX } from './tools.js'; |
| 2 | +import { handleDoneJson } from './cloud-output.js'; |
2 | 3 | import { URL_FAMILY_TOOLS, resourceBucket, bucketArgsKey } from './loop-bucket.js'; |
3 | 4 | import { isCredentialField, CREDENTIAL_NOTE_STRICT } from './credential-fields.js'; |
4 | 5 | import { detectProgressAction, formatLedgerRow, formatLedgerSummary, isBlockedLedgerDowngrade, isTerminalLedgerStatus, isValidLedgerStatus, ledgerDoneBlock, normalizeLedgerStatus, progressCounts, selectLedgerRows, unresolvedLedgerRows, upsertLedgerItems } from './progress-ledger.js'; |
@@ -224,6 +225,7 @@ export class Agent { |
224 | 225 | // abort() and clearConversation() cancel all pending clarifications so |
225 | 226 | // the agent loop doesn't deadlock. |
226 | 227 | this._pendingClarifications = new Map(); |
| 228 | + this.cloudRunContexts = new Map(); // tabId -> { outputSchema, schemaRepairUsed } |
227 | 229 | // Deterministic capability × origin permission gate. "Always" grants are |
228 | 230 | // persisted in extension storage; "once" grants live for the current turn. |
229 | 231 | this.permissions = new PermissionManager({ |
@@ -8071,6 +8073,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d |
8071 | 8073 | } |
8072 | 8074 |
|
8073 | 8075 | async executeTool(tabId, name, args, onUpdate = null) { |
| 8076 | + if (name === 'done_json') { |
| 8077 | + return handleDoneJson(this.cloudRunContexts.get(tabId), args); |
| 8078 | + } |
8074 | 8079 | if (name === 'get_window_info') { |
8075 | 8080 | return await this._getWindowInfo(tabId); |
8076 | 8081 | } |
@@ -11595,10 +11600,18 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d |
11595 | 11600 | } |
11596 | 11601 | this._clearLoopState(tabId); |
11597 | 11602 | this._runningTabs.add(tabId); |
| 11603 | + const previousCloudContext = this.cloudRunContexts.get(tabId); |
| 11604 | + if (runOptions.cloudRun) { |
| 11605 | + this.cloudRunContexts.set(tabId, { outputSchema: runOptions.outputSchema || null, schemaRepairUsed: false }); |
| 11606 | + } |
11598 | 11607 | try { |
11599 | 11608 | return await this._processMessageInner(tabId, userMessage, onUpdate, mode, attachments, runOptions); |
11600 | 11609 | } finally { |
11601 | 11610 | this.currentCostState.delete(tabId); |
| 11611 | + if (runOptions.cloudRun) { |
| 11612 | + if (previousCloudContext) this.cloudRunContexts.set(tabId, previousCloudContext); |
| 11613 | + else this.cloudRunContexts.delete(tabId); |
| 11614 | + } |
11602 | 11615 | this._runningTabs.delete(tabId); |
11603 | 11616 | this._clearLoopState(tabId); |
11604 | 11617 | } |
@@ -11746,7 +11759,14 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d |
11746 | 11759 | } |
11747 | 11760 | const tier = provider.promptTier; |
11748 | 11761 | const skillTools = this._skillToolDefinitions(mode, tier); |
11749 | | - const tools = getToolsForMode(mode, { strictSecretMode: this.strictSecretMode, tier, skillTools }); |
| 11762 | + const cloudRunContext = this.cloudRunContexts.get(tabId) || null; |
| 11763 | + const tools = getToolsForMode(mode, { |
| 11764 | + strictSecretMode: this.strictSecretMode, |
| 11765 | + tier, |
| 11766 | + skillTools, |
| 11767 | + cloudRun: !!cloudRunContext, |
| 11768 | + outputSchema: cloudRunContext?.outputSchema || null, |
| 11769 | + }); |
11750 | 11770 | const allowedToolNames = new Set(tools.map(t => t.function.name)); |
11751 | 11771 | const plannerTemperature = this._isActionMode(mode) ? 0.15 : 0.3; |
11752 | 11772 | let steps = 0; |
@@ -12058,10 +12078,18 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d |
12058 | 12078 | } |
12059 | 12079 | this._clearLoopState(tabId); |
12060 | 12080 | this._runningTabs.add(tabId); |
| 12081 | + const previousCloudContext = this.cloudRunContexts.get(tabId); |
| 12082 | + if (runOptions.cloudRun) { |
| 12083 | + this.cloudRunContexts.set(tabId, { outputSchema: runOptions.outputSchema || null, schemaRepairUsed: false }); |
| 12084 | + } |
12061 | 12085 | try { |
12062 | 12086 | return await this._processMessageStreamInner(tabId, userMessage, onUpdate, mode, runOptions); |
12063 | 12087 | } finally { |
12064 | 12088 | this.currentCostState.delete(tabId); |
| 12089 | + if (runOptions.cloudRun) { |
| 12090 | + if (previousCloudContext) this.cloudRunContexts.set(tabId, previousCloudContext); |
| 12091 | + else this.cloudRunContexts.delete(tabId); |
| 12092 | + } |
12065 | 12093 | this._runningTabs.delete(tabId); |
12066 | 12094 | this._clearLoopState(tabId); |
12067 | 12095 | } |
@@ -12129,7 +12157,14 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d |
12129 | 12157 | } |
12130 | 12158 | const tier = provider.promptTier; |
12131 | 12159 | const skillTools = this._skillToolDefinitions(mode, tier); |
12132 | | - const tools = getToolsForMode(mode, { strictSecretMode: this.strictSecretMode, tier, skillTools }); |
| 12160 | + const cloudRunContext = this.cloudRunContexts.get(tabId) || null; |
| 12161 | + const tools = getToolsForMode(mode, { |
| 12162 | + strictSecretMode: this.strictSecretMode, |
| 12163 | + tier, |
| 12164 | + skillTools, |
| 12165 | + cloudRun: !!cloudRunContext, |
| 12166 | + outputSchema: cloudRunContext?.outputSchema || null, |
| 12167 | + }); |
12133 | 12168 | const allowedToolNames = new Set(tools.map(t => t.function.name)); |
12134 | 12169 | const plannerTemperature = this._isActionMode(mode) ? 0.15 : 0.3; |
12135 | 12170 | let steps = 0; |
|
0 commit comments