@firstpick/pi-package-webui 0.9.6 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -5
- package/bin/pi-webui.mjs +480 -96
- package/index.ts +2 -1
- package/lib/git-workflow-preferences.mjs +21 -1
- package/lib/optional-feature-catalog.mjs +1 -1
- package/lib/session-tree-event-targets.mjs +70 -0
- package/lib/subagent-launch-policy.mjs +375 -0
- package/lib/subagent-launch-slots.mjs +2 -1
- package/package.json +1 -1
- package/public/app.js +1348 -131
- package/public/guided-git-command-state.mjs +175 -1
- package/public/index.html +48 -9
- package/public/service-worker.js +1 -1
- package/public/styles.css +387 -34
- package/public/transcript-renderer.mjs +62 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/control-visibility.spec.mjs +141 -2
- package/tests/browser/events-tree-context-menu.spec.mjs +240 -0
- package/tests/browser/footer-model-advanced-layout.spec.mjs +512 -0
- package/tests/browser/guided-git-extension-command.spec.mjs +180 -0
- package/tests/browser/guided-git-fallback.spec.mjs +218 -0
- package/tests/browser/interaction-continuity.spec.mjs +33 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/compact-sections-static.test.mjs +4 -0
- package/tests/compaction-static.test.mjs +1 -1
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-visibility-static.test.mjs +66 -3
- package/tests/controls-layout-static.test.mjs +3 -3
- package/tests/events-tree-context-menu-static.test.mjs +131 -0
- package/tests/fast-mode-client-static.test.mjs +5 -2
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/file-viewer-image-static.test.mjs +3 -3
- package/tests/fixtures/fake-pi.mjs +34 -3
- package/tests/git-footer-context-menu-static.test.mjs +103 -1
- package/tests/git-workflow-preferences.test.mjs +30 -1
- package/tests/guided-git-activation-http.test.mjs +194 -0
- package/tests/guided-git-activation-static.test.mjs +80 -0
- package/tests/guided-git-activation.test.mjs +244 -0
- package/tests/guided-git-fallback-runtime.test.mjs +419 -0
- package/tests/guided-git-fallback-ui-static.test.mjs +60 -0
- package/tests/guided-git-message-reliability-static.test.mjs +9 -7
- package/tests/guided-git-optional-feature.test.mjs +31 -0
- package/tests/http-endpoints-harness.test.mjs +3 -0
- package/tests/interaction-state-stability-static.test.mjs +1 -1
- package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
- package/tests/main-output-loading-static.test.mjs +11 -9
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +92 -9
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/persistent-ui-layout-static.test.mjs +3 -3
- package/tests/prompt-input-vertical-scroll-static.test.mjs +6 -6
- package/tests/prompt-routing-input-clear-static.test.mjs +1 -1
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/remote-auth-settings-harness.test.mjs +23 -0
- package/tests/resource-defaults-helper.test.mjs +12 -0
- package/tests/session-sampling-helper.test.mjs +1 -0
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/session-tree-event-targets.test.mjs +106 -0
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/subagent-launch-policy.test.mjs +532 -0
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/subagents-helper.test.mjs +211 -1
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/tab-close-continuity-static.test.mjs +25 -0
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thinking-block-grouping.test.mjs +79 -0
- package/webui-rpc-helper.mjs +220 -3
package/webui-rpc-helper.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { closeSync, existsSync, fstatSync, openSync, readFileSync, readSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { AgentSession, formatSkillsForPrompt } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import { Type } from "typebox";
|
|
5
6
|
import {
|
|
6
7
|
AGENT_RUN_PROVIDER_EVENT,
|
|
7
8
|
AgentRunIndex,
|
|
@@ -14,9 +15,11 @@ import {
|
|
|
14
15
|
resolveResourceSelection,
|
|
15
16
|
} from "./lib/resource-selection.mjs";
|
|
16
17
|
import { mutatePiRuntimeFollowUpQueue } from "./lib/queue-mutation.mjs";
|
|
18
|
+
import { applySubagentLaunchSlotDefaults } from "./lib/subagent-launch-policy.mjs";
|
|
17
19
|
import {
|
|
18
20
|
formatSubagentLaunchSlotGuidance,
|
|
19
21
|
resolveSubagentLaunchSlotProjectKey,
|
|
22
|
+
subagentLaunchSlotRevision,
|
|
20
23
|
subagentLaunchSlotScopeEntry,
|
|
21
24
|
} from "./lib/subagent-launch-slots.mjs";
|
|
22
25
|
import { SUBAGENT_GATE_UPDATE_EVENT } from "./lib/subagent-gate.mjs";
|
|
@@ -88,6 +91,17 @@ const SUBAGENT_TELEMETRY_CONTEXT_WINDOW_LIMIT = 16_000_000;
|
|
|
88
91
|
const SUBAGENT_TELEMETRY_RESPONSE_DURATION_MS = 15 * 60 * 1000;
|
|
89
92
|
const SUBAGENT_TELEMETRY_SPEED_LIMIT = 1_000_000;
|
|
90
93
|
const STATS_INITIAL_PROMPT_ESTIMATE_TYPE = "stats_initial_prompt_estimate";
|
|
94
|
+
const SUBAGENT_DEVIATION_PERMIT_LIMIT = 8;
|
|
95
|
+
const SUBAGENT_DEVIATION_PERMIT_TTL_MS = 2 * 60 * 1000;
|
|
96
|
+
const SUBAGENT_DEVIATION_REQUESTED_MODEL_LIMIT = 280;
|
|
97
|
+
const SUBAGENT_DEVIATION_REASON_LIMIT = 500;
|
|
98
|
+
|
|
99
|
+
const SubagentModelDeviationParams = Type.Object({
|
|
100
|
+
role: Type.Literal("reviewer"),
|
|
101
|
+
occurrence: Type.Integer({ minimum: 1, maximum: SUBAGENT_DEVIATION_PERMIT_LIMIT }),
|
|
102
|
+
requestedModel: Type.String({ minLength: 1, maxLength: SUBAGENT_DEVIATION_REQUESTED_MODEL_LIMIT }),
|
|
103
|
+
reason: Type.String({ minLength: 1, maxLength: SUBAGENT_DEVIATION_REASON_LIMIT }),
|
|
104
|
+
}, { additionalProperties: false });
|
|
91
105
|
|
|
92
106
|
const ACTIVE_COMMAND_SESSION_KEY = Symbol.for("pi.webui.helper.activeCommandSession");
|
|
93
107
|
|
|
@@ -942,6 +956,11 @@ export default function webuiRpcHelper(pi) {
|
|
|
942
956
|
let resourceRpcActive = false;
|
|
943
957
|
let sessionSamplingParams = {};
|
|
944
958
|
let subagentLaunchSlotGuidance = "";
|
|
959
|
+
let subagentLaunchSlotRoles = null;
|
|
960
|
+
let subagentLaunchSlotSnapshotLoadFailed = false;
|
|
961
|
+
let activeSubagentLaunchSlotRevision = null;
|
|
962
|
+
let subagentLaunchSlotGeneration = 0;
|
|
963
|
+
let subagentModelDeviationPermits = [];
|
|
945
964
|
let subagentContext = null;
|
|
946
965
|
let subagentBridgeAvailable = false;
|
|
947
966
|
let subagentPollTimer = null;
|
|
@@ -2133,14 +2152,153 @@ export default function webuiRpcHelper(pi) {
|
|
|
2133
2152
|
return (await readWebuiSettings()).resourceDefaults;
|
|
2134
2153
|
}
|
|
2135
2154
|
|
|
2155
|
+
function clearSubagentModelDeviationPermits() {
|
|
2156
|
+
subagentModelDeviationPermits = [];
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
function pruneSubagentModelDeviationPermits(now = Date.now()) {
|
|
2160
|
+
subagentModelDeviationPermits = subagentModelDeviationPermits.filter((permit) => permit.expiresAt > now
|
|
2161
|
+
&& permit.slotRevision === activeSubagentLaunchSlotRevision
|
|
2162
|
+
&& permit.helperGeneration === subagentLaunchSlotGeneration);
|
|
2163
|
+
return subagentModelDeviationPermits;
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
function subagentModelDeviationDescriptors() {
|
|
2167
|
+
return pruneSubagentModelDeviationPermits().map((permit) => ({
|
|
2168
|
+
id: permit.id,
|
|
2169
|
+
role: permit.role,
|
|
2170
|
+
occurrence: permit.occurrence,
|
|
2171
|
+
requestedModel: permit.requestedModel,
|
|
2172
|
+
expiresAt: permit.expiresAt,
|
|
2173
|
+
}));
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
function removeSubagentModelDeviationPermits(ids) {
|
|
2177
|
+
const consumed = new Set(ids);
|
|
2178
|
+
if (!consumed.size) return;
|
|
2179
|
+
subagentModelDeviationPermits = subagentModelDeviationPermits.filter((permit) => !consumed.has(permit.id));
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
async function approveSubagentModelDeviation(params = {}) {
|
|
2183
|
+
pruneSubagentModelDeviationPermits();
|
|
2184
|
+
if (!subagentLaunchSlotRoles || !activeSubagentLaunchSlotRevision) {
|
|
2185
|
+
throw new Error("Reviewer model deviation approval is unavailable until the active WebUI launch-slot snapshot loads.");
|
|
2186
|
+
}
|
|
2187
|
+
if (params.role !== "reviewer" || !Number.isInteger(params.occurrence)
|
|
2188
|
+
|| params.occurrence < 1 || params.occurrence > SUBAGENT_DEVIATION_PERMIT_LIMIT) {
|
|
2189
|
+
throw new Error("Reviewer model deviation approval requires reviewer occurrence 1 through 8.");
|
|
2190
|
+
}
|
|
2191
|
+
if (typeof params.requestedModel !== "string" || params.requestedModel.length > SUBAGENT_DEVIATION_REQUESTED_MODEL_LIMIT) {
|
|
2192
|
+
throw new Error(`Requested model must be at most ${SUBAGENT_DEVIATION_REQUESTED_MODEL_LIMIT} characters.`);
|
|
2193
|
+
}
|
|
2194
|
+
const requestedModel = params.requestedModel.trim();
|
|
2195
|
+
if (!requestedModel) throw new Error("Requested model must not be blank.");
|
|
2196
|
+
if (typeof params.reason !== "string" || params.reason.length > SUBAGENT_DEVIATION_REASON_LIMIT) {
|
|
2197
|
+
throw new Error(`Deviation reason must be at most ${SUBAGENT_DEVIATION_REASON_LIMIT} characters.`);
|
|
2198
|
+
}
|
|
2199
|
+
const reason = params.reason.trim();
|
|
2200
|
+
if (!reason) throw new Error("Deviation reason must not be blank.");
|
|
2201
|
+
if (subagentModelDeviationPermits.length >= SUBAGENT_DEVIATION_PERMIT_LIMIT) {
|
|
2202
|
+
throw new Error("The active WebUI tab already has 8 unused reviewer model deviation permits.");
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
const approvalSlotRevision = activeSubagentLaunchSlotRevision;
|
|
2206
|
+
const approvalGeneration = subagentLaunchSlotGeneration;
|
|
2207
|
+
const context = subagentContext;
|
|
2208
|
+
if (context?.hasUI !== true || typeof context.ui?.confirm !== "function") {
|
|
2209
|
+
throw new Error("Reviewer model deviation approval requires an interactive WebUI confirmation.");
|
|
2210
|
+
}
|
|
2211
|
+
const confirmed = await context.ui.confirm(
|
|
2212
|
+
"Authorize reviewer model deviation?",
|
|
2213
|
+
`Allow reviewer occurrence ${params.occurrence} to use ${requestedModel} once within 2 minutes?\n\nReason: ${reason}`,
|
|
2214
|
+
);
|
|
2215
|
+
if (confirmed !== true) throw new Error("Reviewer model deviation approval was not confirmed by the user.");
|
|
2216
|
+
|
|
2217
|
+
pruneSubagentModelDeviationPermits();
|
|
2218
|
+
if (!subagentLaunchSlotRoles || !activeSubagentLaunchSlotRevision) {
|
|
2219
|
+
throw new Error("Reviewer model deviation approval is unavailable until the active WebUI launch-slot snapshot loads.");
|
|
2220
|
+
}
|
|
2221
|
+
if (activeSubagentLaunchSlotRevision !== approvalSlotRevision || subagentLaunchSlotGeneration !== approvalGeneration) {
|
|
2222
|
+
throw new Error("Reviewer model deviation approval expired because the active WebUI launch-slot snapshot changed during confirmation.");
|
|
2223
|
+
}
|
|
2224
|
+
if (subagentModelDeviationPermits.length >= SUBAGENT_DEVIATION_PERMIT_LIMIT) {
|
|
2225
|
+
throw new Error("The active WebUI tab already has 8 unused reviewer model deviation permits.");
|
|
2226
|
+
}
|
|
2227
|
+
const createdAt = Date.now();
|
|
2228
|
+
const permit = {
|
|
2229
|
+
id: randomUUID(),
|
|
2230
|
+
role: "reviewer",
|
|
2231
|
+
occurrence: params.occurrence,
|
|
2232
|
+
requestedModel,
|
|
2233
|
+
reason,
|
|
2234
|
+
slotRevision: activeSubagentLaunchSlotRevision,
|
|
2235
|
+
helperGeneration: subagentLaunchSlotGeneration,
|
|
2236
|
+
createdAt,
|
|
2237
|
+
expiresAt: createdAt + SUBAGENT_DEVIATION_PERMIT_TTL_MS,
|
|
2238
|
+
};
|
|
2239
|
+
subagentModelDeviationPermits.push(permit);
|
|
2240
|
+
return {
|
|
2241
|
+
content: [{
|
|
2242
|
+
type: "text",
|
|
2243
|
+
text: `Approved one reviewer occurrence ${permit.occurrence} launch with ${permit.requestedModel}. The local permit expires in 2 minutes and is consumed by one admitted launch or leased workflow.`,
|
|
2244
|
+
}],
|
|
2245
|
+
details: {
|
|
2246
|
+
permitId: permit.id,
|
|
2247
|
+
role: permit.role,
|
|
2248
|
+
occurrence: permit.occurrence,
|
|
2249
|
+
requestedModel: permit.requestedModel,
|
|
2250
|
+
createdAt: permit.createdAt,
|
|
2251
|
+
expiresAt: permit.expiresAt,
|
|
2252
|
+
},
|
|
2253
|
+
};
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
function reviewerModelPolicyBlockReason(decisions) {
|
|
2257
|
+
const decision = decisions[0];
|
|
2258
|
+
const more = decisions.length > 1 ? ` (${decisions.length - 1} more mismatch${decisions.length === 2 ? "" : "es"} also blocked.)` : "";
|
|
2259
|
+
return `Reviewer occurrence ${decision.occurrence} model mismatch: expected ${decision.expectedModel}, requested ${decision.requestedModel}. Retry with ${decision.correctionModel} or omit model to use the configured slot; use approve_subagent_model_deviation only after explicit user authorization.${more}`;
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
function inputRequestsReviewer(input) {
|
|
2263
|
+
const role = (value) => typeof value === "string" ? value.trim() : "";
|
|
2264
|
+
if (!isPlainObject(input)) return false;
|
|
2265
|
+
if (role(input.agent) === "reviewer") return true;
|
|
2266
|
+
if (Array.isArray(input.tasks) && input.tasks.some((task) => role(task?.agent) === "reviewer")) return true;
|
|
2267
|
+
return Array.isArray(input.chain) && input.chain.some((step) => role(step?.agent) === "reviewer"
|
|
2268
|
+
|| (Array.isArray(step?.parallel) && step.parallel.some((task) => role(task?.agent) === "reviewer"))
|
|
2269
|
+
|| role(step?.parallel?.agent) === "reviewer");
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
function launchNeedsLoadedSlotSnapshot(toolName, input) {
|
|
2273
|
+
if (!isPlainObject(input) || input.action !== undefined || input.resume !== undefined) return false;
|
|
2274
|
+
if (toolName === "subagent" && typeof input.workflowScript === "string" && input.workflowScript.trim()) return true;
|
|
2275
|
+
return inputRequestsReviewer(input);
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2136
2278
|
async function loadSubagentLaunchSlotGuidance(ctx) {
|
|
2279
|
+
const generation = ++subagentLaunchSlotGeneration;
|
|
2280
|
+
clearSubagentModelDeviationPermits();
|
|
2281
|
+
activeSubagentLaunchSlotRevision = null;
|
|
2137
2282
|
try {
|
|
2138
2283
|
const settings = await readWebuiSettings();
|
|
2139
2284
|
const projectKey = await resolveSubagentLaunchSlotProjectKey(ctx?.cwd);
|
|
2140
2285
|
const effective = subagentLaunchSlotScopeEntry(settings.subagentLaunchSlots, "project", projectKey);
|
|
2141
|
-
|
|
2286
|
+
const revision = subagentLaunchSlotRevision(settings.subagentLaunchSlots, "project", projectKey);
|
|
2287
|
+
if (generation !== subagentLaunchSlotGeneration) return;
|
|
2288
|
+
subagentLaunchSlotRoles = effective.entry.roles;
|
|
2289
|
+
subagentLaunchSlotSnapshotLoadFailed = false;
|
|
2290
|
+
activeSubagentLaunchSlotRevision = revision;
|
|
2291
|
+
const assignments = formatSubagentLaunchSlotGuidance(subagentLaunchSlotRoles);
|
|
2292
|
+
subagentLaunchSlotGuidance = assignments
|
|
2293
|
+
? `${assignments}\nExplicit reviewer model or thinking mismatches are blocked before launch. The approve_subagent_model_deviation tool is valid only after the user explicitly authorizes that exact reviewer occurrence and requested model, and it always requires interactive confirmation.`
|
|
2294
|
+
: "";
|
|
2142
2295
|
} catch (error) {
|
|
2296
|
+
if (generation !== subagentLaunchSlotGeneration) return;
|
|
2297
|
+
subagentLaunchSlotRoles = null;
|
|
2298
|
+
subagentLaunchSlotSnapshotLoadFailed = true;
|
|
2143
2299
|
subagentLaunchSlotGuidance = "";
|
|
2300
|
+
activeSubagentLaunchSlotRevision = null;
|
|
2301
|
+
clearSubagentModelDeviationPermits();
|
|
2144
2302
|
console.warn(`Web UI subagent launch slots could not be read: ${error instanceof Error ? error.message : String(error)}`);
|
|
2145
2303
|
}
|
|
2146
2304
|
}
|
|
@@ -2325,7 +2483,22 @@ export default function webuiRpcHelper(pi) {
|
|
|
2325
2483
|
function dismissSubagentRun(payload = {}) {
|
|
2326
2484
|
const runId = subagentText(payload.runId, 160);
|
|
2327
2485
|
if (!runId) throw new Error("Subagent dismiss requires runId");
|
|
2328
|
-
const entry =
|
|
2486
|
+
const entry = ordinarySubagentRunEntries().find((candidate) => candidate.run?.id === runId);
|
|
2487
|
+
if (!entry) {
|
|
2488
|
+
const canonicalRunId = canonicalAgentRunId(runId, "run");
|
|
2489
|
+
const staleProviderInstances = [...agentRunProviderSnapshots.values()]
|
|
2490
|
+
.flatMap((rows) => [...rows.values()])
|
|
2491
|
+
.filter((instance) => instance.runId === canonicalRunId && ["done", "failed", "cancelled"].includes(instance.status));
|
|
2492
|
+
rememberDismissedHelperAgentRunProjections(staleProviderInstances);
|
|
2493
|
+
// Dismiss is idempotent. Force a fresh empty projection so a server that
|
|
2494
|
+
// still has the previous terminal snapshot can clear it immediately.
|
|
2495
|
+
lastPublishedSubagentSignature = "";
|
|
2496
|
+
lastPublishedSubagentAt = 0;
|
|
2497
|
+
lastPublishedAgentRunSignature = "";
|
|
2498
|
+
lastPublishedAgentRunAt = 0;
|
|
2499
|
+
publishSubagentStatus();
|
|
2500
|
+
return { runId, dismissed: true, alreadyMissing: true };
|
|
2501
|
+
}
|
|
2329
2502
|
if (entry.run.status === "running") throw new Error(`Cannot dismiss running subagent run: ${runId}`);
|
|
2330
2503
|
rememberDismissedHelperAgentRunProjections(canonicalInstancesFromPublicRun(entry.run, new Set()));
|
|
2331
2504
|
entry.runs.delete(entry.key);
|
|
@@ -2408,6 +2581,21 @@ export default function webuiRpcHelper(pi) {
|
|
|
2408
2581
|
}
|
|
2409
2582
|
}
|
|
2410
2583
|
|
|
2584
|
+
pi.registerTool({
|
|
2585
|
+
name: "approve_subagent_model_deviation",
|
|
2586
|
+
label: "Approve reviewer model deviation",
|
|
2587
|
+
description: "Request interactive user confirmation for one short-lived, one-use local permit covering an explicit reviewer model mismatch. The confirmation identifies the exact reviewer occurrence and requested model.",
|
|
2588
|
+
promptSnippet: "Request confirmation for one reviewer model deviation",
|
|
2589
|
+
promptGuidelines: [
|
|
2590
|
+
"Call approve_subagent_model_deviation only after the user explicitly authorizes that exact reviewer occurrence and requested model; never infer authorization from task text or use it merely to bypass a mismatch block. The tool still displays an interactive confirmation and fails closed without UI or on rejection.",
|
|
2591
|
+
"The permit is local, expires after 2 minutes, and is consumed by one admitted structured launch or leased into one workflow wrapper.",
|
|
2592
|
+
],
|
|
2593
|
+
parameters: SubagentModelDeviationParams,
|
|
2594
|
+
async execute(_toolCallId, params) {
|
|
2595
|
+
return approveSubagentModelDeviation(params);
|
|
2596
|
+
},
|
|
2597
|
+
});
|
|
2598
|
+
|
|
2411
2599
|
pi.registerCommand(HELPER_COMMAND, {
|
|
2412
2600
|
description: "Internal Web UI helper for browser-native tools and skills configuration",
|
|
2413
2601
|
handler: async (args, ctx) => {
|
|
@@ -2451,6 +2639,7 @@ export default function webuiRpcHelper(pi) {
|
|
|
2451
2639
|
resourceRpcActive = ctx.mode === "rpc";
|
|
2452
2640
|
if (resourceRpcActive) await recomputeResourceState(ctx);
|
|
2453
2641
|
restoreSamplingParamsFromBranch(ctx);
|
|
2642
|
+
await loadSubagentLaunchSlotGuidance(ctx);
|
|
2454
2643
|
subagentContext = ctx;
|
|
2455
2644
|
subagentPollGeneration += 1;
|
|
2456
2645
|
foregroundSubagentRuns.clear();
|
|
@@ -2473,6 +2662,29 @@ export default function webuiRpcHelper(pi) {
|
|
|
2473
2662
|
await recomputeResourceState(ctx, event.model);
|
|
2474
2663
|
});
|
|
2475
2664
|
|
|
2665
|
+
pi.on("tool_call", (event) => {
|
|
2666
|
+
if (!["subagent", "subagent_gate"].includes(event.toolName)) return;
|
|
2667
|
+
const deviations = subagentModelDeviationDescriptors();
|
|
2668
|
+
if (!subagentLaunchSlotRoles) {
|
|
2669
|
+
if (subagentLaunchSlotSnapshotLoadFailed && launchNeedsLoadedSlotSnapshot(event.toolName, event.input)) {
|
|
2670
|
+
return {
|
|
2671
|
+
block: true,
|
|
2672
|
+
reason: "Reviewer launch policy is unavailable because the WebUI launch-slot snapshot could not be loaded. Reload the active tab after fixing settings before launching reviewers or workflows.",
|
|
2673
|
+
};
|
|
2674
|
+
}
|
|
2675
|
+
return;
|
|
2676
|
+
}
|
|
2677
|
+
const report = applySubagentLaunchSlotDefaults(event.toolName, event.input, subagentLaunchSlotRoles, { deviations });
|
|
2678
|
+
if (report.blocked.length) {
|
|
2679
|
+
return { block: true, reason: reviewerModelPolicyBlockReason(report.blocked) };
|
|
2680
|
+
}
|
|
2681
|
+
const workflowWrapped = report.applied.some((item) => item.location === "workflowScript" && item.reason === "runtime-role-defaults");
|
|
2682
|
+
removeSubagentModelDeviationPermits(workflowWrapped
|
|
2683
|
+
? deviations.map((deviation) => deviation.id)
|
|
2684
|
+
: report.consumedDeviationIds);
|
|
2685
|
+
return undefined;
|
|
2686
|
+
});
|
|
2687
|
+
|
|
2476
2688
|
pi.on("tool_execution_start", (event, ctx) => {
|
|
2477
2689
|
if (event.toolName !== "subagent" || event.args?.action) return;
|
|
2478
2690
|
const id = subagentText(event.toolCallId, 160);
|
|
@@ -2578,6 +2790,11 @@ export default function webuiRpcHelper(pi) {
|
|
|
2578
2790
|
resourceGeneration += 1;
|
|
2579
2791
|
subagentContext = null;
|
|
2580
2792
|
subagentLaunchSlotGuidance = "";
|
|
2793
|
+
subagentLaunchSlotRoles = null;
|
|
2794
|
+
subagentLaunchSlotSnapshotLoadFailed = false;
|
|
2795
|
+
activeSubagentLaunchSlotRevision = null;
|
|
2796
|
+
subagentLaunchSlotGeneration += 1;
|
|
2797
|
+
clearSubagentModelDeviationPermits();
|
|
2581
2798
|
subagentPollGeneration += 1;
|
|
2582
2799
|
clearTimeout(subagentPollTimer);
|
|
2583
2800
|
subagentPollTimer = null;
|