← Files RivetARCHIVED FILE

node_modules/rivet-design/dist/cli/hostWorkNextAction.js

3.86 KB · Nov 7, 2026 · 13:16 UTC

↓ Download file

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withHostWorkNextAction = exports.buildHostWorkNextAction = void 0;
const workItemBriefing_1 = require("../agent-variants/workItemBriefing");
const WorkerExecutorService_1 = require("../agent-variants/WorkerExecutorService");
const isImplementationWorkItem = (item) => item.kind === 'static_preview' ||
    item.kind === 'refine_variant' ||
    item.kind === 'code_gen';
const buildHostWorkNextAction = (status, options) => {
    const hostWork = (status.variants?.hostWork ?? [])
        .filter(isImplementationWorkItem)
        .filter((item) => item.leaseOwner !== WorkerExecutorService_1.EXECUTOR_LEASE_OWNER);
    if (hostWork.length === 0) {
        return null;
    }
    const isSingleItem = hostWork.length === 1;
    const isDirect = isSingleItem &&
        (!hostWork[0].workerSelection?.model ||
            hostWork[0].workerSelection.model === options?.callerModel);
    const sessionId = status.variants?.sessionId;
    const completionCommandContext = {
        ...(status.session?.projectPath
            ? { projectPath: status.session.projectPath }
            : {}),
        ...(sessionId ? { sessionId } : {}),
    };
    const workItems = hostWork.map((item) => ({
        ...item,
        completeCommand: (0, workItemBriefing_1.workItemCompleteCommand)(item.workId, completionCommandContext),
        workerPrompt: sessionId
            ? (0, workItemBriefing_1.workItemWorkerPrompt)(sessionId, item)
            : `You are implementing one Rivet design variant ("${item.direction.label}"). Follow this work item's packet fields exactly (direction, mode, workspace) and finish by running: ${(0, workItemBriefing_1.workItemCompleteCommand)(item.workId, completionCommandContext)}`,
    }));
    return {
        action: 'complete_host_variant_work',
        message: isDirect
            ? 'Complete this variant work item directly in the current host, then run its completeCommand.'
            : 'Complete these independent variant work items concurrently. Each item MUST be reported the moment it finishes via its own completeCommand — never hold completions to batch them.',
        command: 'rivet variants complete',
        worker: { binding: 'none' },
        parallelism: isDirect
            ? {
                recommended: false,
                strategy: 'direct',
                instructions: 'Avoid subagent startup for one item. Read the briefing file named in its workerPrompt, edit its assigned workspace directly, then run its completeCommand.',
            }
            : {
                recommended: true,
                strategy: 'one_worker_per_work_item',
                instructions: `Spawn every worker in this turn as native background subagents with the current permissions and approvals, one per item, passing that item's workerPrompt VERBATIM as the entire worker prompt. Inherit the current model unless workerSelection specifies a requested model. Use native model selection for that requirement; if unsupported, report that item failed before editing. Do not select a fixed-model agent definition or launch a detached provider CLI. Briefs are final and the briefing file contains the full packet and completion command. Each worker reports completion immediately. Denied or unavailable approval must be reported through the completion command without broader retries or server execution.`,
            },
        ...(status.variants?.sessionId
            ? { sessionId: status.variants.sessionId }
            : {}),
        workItems,
    };
};
exports.buildHostWorkNextAction = buildHostWorkNextAction;
const withHostWorkNextAction = (status, options) => {
    const nextAction = (0, exports.buildHostWorkNextAction)(status, options);
    return nextAction ? { ...status, nextAction } : status;
};
exports.withHostWorkNextAction = withHostWorkNextAction;
//# sourceMappingURL=hostWorkNextAction.js.map

SHA-256: 2c88c67176df108f403709d065e7e83703389c7cdc260be39338948b7cd79760