From ac325866189b73d732a7aed1001a36705214abfd Mon Sep 17 00:00:00 2001 From: Brendan Date: Thu, 17 Sep 2026 00:43:36 +0000 Subject: [PATCH] GEN-2033 add per-job model selection --- packages/app/src/exe.ts | 3 +++ packages/app/src/flow-schemas.ts | 1 + packages/app/src/job-domain.ts | 1 + packages/app/src/tenant.ts | 11 +++++++---- packages/app/src/ui.ts | 13 ++++++++----- packages/app/test/flow-service.test.ts | 3 ++- packages/app/test/job-domain.test.ts | 1 + packages/app/test/ui.test.ts | 12 +++++++++++- packages/app/test/workspace.test.ts | 5 +++++ 9 files changed, 39 insertions(+), 11 deletions(-) diff --git a/packages/app/src/exe.ts b/packages/app/src/exe.ts index 3b9421b9..31d5fc51 100644 --- a/packages/app/src/exe.ts +++ b/packages/app/src/exe.ts @@ -7,6 +7,8 @@ export interface ExeConnection { cwd: string; herdrCommand?: string; agentCommand?: string; + /** Per-job harness model. Empty means the harness chooses its default. */ + model?: string; } export interface ExeResponse { @@ -159,6 +161,7 @@ function herdrBinary(connection: ExeConnection): string { function agentCommand(connection: ExeConnection, prompt?: string, cwd?: string): string { const command = connection.agentCommand?.trim() || defaultAgentCommand(connection.agentKind); const args = command ? shellWords(command).map(shellAtom) : []; + if (connection.model?.trim()) args.push(shellAtom("--model"), shellAtom(connection.model.trim())); if (connection.agentKind === "codex" && cwd) args.push("--dangerously-bypass-hook-trust", "--cd", shellAtom(cwd), "-c", shellAtom(`projects.${JSON.stringify(cwd)}.trust_level="trusted"`)); if (prompt !== undefined) args.push("--", shellAtom(prompt)); return args.length ? ` -- ${args.join(" ")}` : ""; diff --git a/packages/app/src/flow-schemas.ts b/packages/app/src/flow-schemas.ts index 6e40f866..0ab91d1b 100644 --- a/packages/app/src/flow-schemas.ts +++ b/packages/app/src/flow-schemas.ts @@ -35,6 +35,7 @@ export const jobInputSchema = z.object({ promptTemplate: z.string().min(1).max(50_000), concurrencyLimit: z.number().int().min(1).max(50).default(1), executionTargetId: z.string().min(1), + model: z.string().trim().max(120).optional(), triggers: z.array(triggerSchema).max(50).default([]), }).strict(); export const jobIdSchema = z.object({ jobId: z.string().min(1) }); diff --git a/packages/app/src/job-domain.ts b/packages/app/src/job-domain.ts index ac4cfecf..ceeb210a 100644 --- a/packages/app/src/job-domain.ts +++ b/packages/app/src/job-domain.ts @@ -27,6 +27,7 @@ export interface Job { name: string; slug: string; promptTemplate: string; + model: string; executionTarget: ExecutionTarget; concurrencyLimit: number; enabled: boolean; diff --git a/packages/app/src/tenant.ts b/packages/app/src/tenant.ts index f319bdc6..2ebf0632 100644 --- a/packages/app/src/tenant.ts +++ b/packages/app/src/tenant.ts @@ -444,7 +444,7 @@ export class TenantV2 extends DurableObject { if (!job) return undefined; let target: Record = {}; try { target = JSON.parse(String(job.execution_target)); } catch { return undefined; } - return { id: job.id, name: job.name, max_concurrency: job.concurrency_limit, workspace_name: job.slug, agent_kind: target.agentKind, cwd: target.cwd, execution_backend_kind: target.backendKind ?? "exe-herdr", execution_connection_id: target.connectionId, exe_connection_id: target.connectionId, enabled: job.enabled }; + return { id: job.id, name: job.name, max_concurrency: job.concurrency_limit, workspace_name: job.slug, agent_kind: target.agentKind, model: target.model ?? "", cwd: target.cwd, execution_backend_kind: target.backendKind ?? "exe-herdr", execution_connection_id: target.connectionId, exe_connection_id: target.connectionId, enabled: job.enabled }; } private async publicJob(row: Row): Promise> { @@ -467,6 +467,7 @@ export class TenantV2 extends DurableObject { return { id: row.id, name: row.name, slug: row.slug, promptTemplate: await decrypt(String(row.encrypted_prompt_template), this.env.CREDENTIAL_ENCRYPTION_KEY), + model: String(executionTarget.model ?? ""), concurrencyLimit: Number(row.concurrency_limit), runningCount: Number(runSummary?.running_count ?? 0), maxConcurrency: Number(row.concurrency_limit), @@ -493,6 +494,7 @@ export class TenantV2 extends DurableObject { private validateJobInput(input: any): void { if (!input?.name || !input.promptTemplate) throw new Error("Job name and prompt template are required"); if (!JOB_SLUG.test(String(input.slug ?? ""))) throw new Error("Job slug must start with a lowercase letter and contain only lowercase letters, digits, hyphens, or underscores (30 characters maximum)."); + if (input.model !== undefined && (typeof input.model !== "string" || input.model.trim().length > 120)) throw new Error("Job model must be a string of 120 characters or fewer"); if (!Array.isArray(input.triggers) || input.triggers.some((trigger: any) => !["manual", "schedule", "webhook", "jobLifecycle"].includes(trigger?.kind))) throw new Error("Job triggers are invalid"); Mustache.parse(input.promptTemplate); for (const trigger of input.triggers) { @@ -578,7 +580,7 @@ export class TenantV2 extends DurableObject { this.validateJobInput(input); if (this.one("SELECT id FROM jobs WHERE slug=?", input.slug)) throw new Error("Job slug is already in use"); await this.validateProviderIntegrations(input.triggers); - const target = await this.jobTarget(input.executionTargetId), jobId = id(), timestamp = now(); + const target = { ...await this.jobTarget(input.executionTargetId), model: text(input.model).trim() }, jobId = id(), timestamp = now(); const triggers = this.normalizedTriggers(input.triggers); this.validateLifecycleGraph(jobId, triggers); this.ctx.storage.sql.exec("INSERT INTO jobs (id,name,slug,encrypted_prompt_template,execution_target,concurrency_limit,enabled,created_at,updated_at) VALUES (?,?,?,?,?,?,?,?,?)", jobId, input.name, input.slug, await encrypt(input.promptTemplate, this.env.CREDENTIAL_ENCRYPTION_KEY), JSON.stringify(target), input.concurrencyLimit, 1, timestamp, timestamp); @@ -600,7 +602,7 @@ export class TenantV2 extends DurableObject { await this.validateProviderIntegrations(input.triggers, existing); const triggers = this.normalizedTriggers(input.triggers, existing); this.validateLifecycleGraph(jobId, triggers); - const target = await this.jobTarget(input.executionTargetId), timestamp = now(); + const target = { ...await this.jobTarget(input.executionTargetId), model: text(input.model).trim() }, timestamp = now(); this.ctx.storage.sql.exec("UPDATE jobs SET name=?,slug=?,encrypted_prompt_template=?,execution_target=?,concurrency_limit=?,updated_at=? WHERE id=?", input.name, input.slug, await encrypt(input.promptTemplate, this.env.CREDENTIAL_ENCRYPTION_KEY), JSON.stringify(target), input.concurrencyLimit, timestamp, jobId); const retained = new Set(); for (const trigger of triggers) { @@ -1476,7 +1478,8 @@ export class TenantV2 extends DurableObject { private async connectionForPipe(pipe: Row): Promise { const connection = await this.exeConnection(String(pipe.exe_connection_id || "default")); - return connection && pipe.cwd ? { ...connection, cwd: workingDirectoryFor(String(pipe.cwd), String(pipe.workspace_name)) } : connection; + if (!connection) return null; + return { ...connection, ...(pipe.cwd ? { cwd: workingDirectoryFor(String(pipe.cwd), String(pipe.workspace_name)) } : {}), model: String(pipe.model ?? "") }; } private async upsertMember(input: unknown): Promise { diff --git a/packages/app/src/ui.ts b/packages/app/src/ui.ts index b9b841e4..9c6f558e 100644 --- a/packages/app/src/ui.ts +++ b/packages/app/src/ui.ts @@ -66,7 +66,7 @@ export const jobPage = (viewer: { email: string }, jobId?: string) => shell(`${j

Step 1

Job details

Name this job and set how many runs it can process at once.

Step 2

Triggers

Choose the events that start this job and expose prompt context.

Context slugTypeConfigurationEnabledActions

Step 3

Prompt and context

Write the instructions for each run using context supplied by your triggers.

-

Step 4

Execution target

Select the connected environment that will run this job.

+

Step 4

Execution target

Select the connected environment and model that will run this job.

Add trigger

Provider credentials stay managed by Factorize.

@@ -74,7 +74,7 @@ export const jobPage = (viewer: { email: string }, jobId?: string) => shell(`${j
`, `${uiHelpers} -const jobId=${JSON.stringify(jobId ?? null)},contextCatalog=${JSON.stringify(triggerContextCatalog)},form=$('#job'),dialog=$('#trigger-dialog'),triggerForm=$('#trigger-form');let triggers=[],editing=-1,resources={projects:[],options:{statuses:[],users:[],labels:[]},installations:[],tailInstallations:[],repositories:new Map(),jobs:[]},clientId=0,reservedSlugs=new Set(),availability={}; +const jobId=${JSON.stringify(jobId ?? null)},contextCatalog=${JSON.stringify(triggerContextCatalog)},form=$('#job'),dialog=$('#trigger-dialog'),triggerForm=$('#trigger-form');let triggers=[],editing=-1,resources={targets:[],projects:[],options:{statuses:[],users:[],labels:[]},installations:[],tailInstallations:[],repositories:new Map(),jobs:[]},clientId=0,reservedSlugs=new Set(),availability={}; let slugEdited=Boolean(jobId);const jobSlug=value=>value.trim().toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-+|-+$/g,'').slice(0,30)||'job';form.name.addEventListener('input',()=>{if(!slugEdited)form.slug.value=jobSlug(form.name.value)});form.slug.addEventListener('input',()=>{slugEdited=true}); const kinds={manual:'Manual',schedule:'Schedule',linear:'Linear',github:'GitHub',cloudflareTail:'Cloudflare Tail',jobLifecycle:'Job lifecycle'}; const providerKind=t=>t.kind==='webhook'?t.config.provider:t.kind; @@ -105,6 +105,8 @@ $('#context-paths').addEventListener('click',e=>{const hint=e.target.closest('[d function nextSlug(){let n=1;while(reservedSlugs.has('trigger-'+n))n++;const slug='trigger-'+n;reservedSlugs.add(slug);return slug} async function repositories(installationId){const key=String(installationId);if(resources.repositories.has(key))return resources.repositories.get(key);const response=await fetch('/api/github/installations/'+encodeURIComponent(key)+'/repositories');const items=response.ok?await response.json():[];resources.repositories.set(key,items);return items} function options(select,items,label,value='id'){select.replaceChildren(...items.map(x=>new Option(x[label]||x.name,String(x[value]))))} +const modelChoices={codex:['gpt-5.5','gpt-5.5-codex','gpt-5.4','gpt-5.4-mini'],claude:['opus','sonnet','haiku'],pi:[]}; +function syncModels(){const target=resources.targets.find(x=>String(x.id)===form.executionTargetId.value),kind=String(target?.agentKind||'').toLowerCase(),models=modelChoices[kind]||[];$('#job-models').replaceChildren(...models.map(value=>new Option(value)));form.model.disabled=target?.kind==='amp';if(form.model.disabled)form.model.value='';$('#model-help').textContent=form.model.disabled?'This target manages its model in Amp.':models.length?'Choose a '+target.agentKind+' model or enter another model ID. Leave blank for the harness default.':'Enter a model ID, or leave blank for the harness default.'} async function syncRepositories(selected){const install=triggerForm.elements.installationId.value,repos=await repositories(install);options(triggerForm.elements.repositoryId,repos,'fullName');if(selected)triggerForm.elements.repositoryId.value=String(selected)} function linearRuleRows(){return [...$('#linear-rules').querySelectorAll('[data-linear-rule]')]} function syncLinearRuleButtons(){const rows=linearRuleRows();rows.forEach(row=>row.querySelector('[data-remove-linear-rule]').classList.toggle('invisible',rows.length===1))} @@ -119,9 +121,10 @@ $('#trigger-rows').onchange=e=>{if(e.target.dataset.enable===undefined)return;tr triggerForm.querySelectorAll('[name=scheduleMode]').forEach(input=>input.onchange=syncScheduleEditor);triggerForm.elements.intervalUnit.onchange=syncScheduleEditor;triggerForm.elements.intervalValue.oninput=syncScheduleEditor; triggerForm.onsubmit=e=>{e.preventDefault();try{const value=configFromForm();validate(value);if(editing>=0)triggers[editing]={...triggers[editing],...value};else triggers.push({...value,id:undefined,slug:nextSlug(),enabled:true,_clientId:++clientId});dialog.close();render()}catch(error){$('#dialog-error').textContent=error.message;$('#dialog-error').classList.remove('hidden')}}; $('#test-handler').onclick=async()=>{const output=$('#handler-result');try{const handlerCode=triggerForm.elements.handlerCode.value;if(!handlerCode)throw new Error('Enter handler code first.');const payload=JSON.parse(triggerForm.elements.testPayload.value);const result=await request('/api/job-handlers/test',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({handlerCode,payload})});output.textContent=result.ok?'Accepted: '+JSON.stringify(result.decision):'Rejected: '+result.category}catch(e){output.textContent=e.message}}; -async function init(){const [targets,projects,linearOptions,installResponse,tails,jobs,current]=await Promise.all([request('/api/execution-targets'),request('/api/linear/projects').catch(()=>[]),request('/api/linear/options').catch(()=>({statuses:[]})),fetch('/api/github/installations'),request('/api/connections/cloudflare-tail').catch(()=>[]),request('/api/jobs'),jobId?request('/api/jobs/'+encodeURIComponent(jobId)):null]);resources.projects=projects;resources.options=linearOptions;resources.installations=installResponse.ok?(await installResponse.json()).filter(x=>x.state==='active'):[];resources.tailInstallations=tails;resources.jobs=jobs;options(triggerForm.elements.tailIntegrationId,tails,'name','integrationId');options(form.executionTargetId,targets,'name');if(current){form.name.value=current.name;form.slug.value=current.slug;form.promptTemplate.value=current.promptTemplate;form.concurrencyLimit.value=current.concurrencyLimit;form.executionTargetId.value=current.executionTargetId;triggers=current.triggers.map(t=>({...t,config:{...t.config}}))}else triggers=[{kind:'manual',slug:'trigger-1',enabled:true,config:{}}];highlightPrompt();reservedSlugs=new Set(triggers.map(t=>t.slug));await refreshAvailability();render()} +async function init(){const [targets,projects,linearOptions,installResponse,tails,jobs,current]=await Promise.all([request('/api/execution-targets'),request('/api/linear/projects').catch(()=>[]),request('/api/linear/options').catch(()=>({statuses:[]})),fetch('/api/github/installations'),request('/api/connections/cloudflare-tail').catch(()=>[]),request('/api/jobs'),jobId?request('/api/jobs/'+encodeURIComponent(jobId)):null]);resources.targets=targets;resources.projects=projects;resources.options=linearOptions;resources.installations=installResponse.ok?(await installResponse.json()).filter(x=>x.state==='active'):[];resources.tailInstallations=tails;resources.jobs=jobs;options(triggerForm.elements.tailIntegrationId,tails,'name','integrationId');options(form.executionTargetId,targets,'name');if(current){form.name.value=current.name;form.slug.value=current.slug;form.promptTemplate.value=current.promptTemplate;form.concurrencyLimit.value=current.concurrencyLimit;form.executionTargetId.value=current.executionTargetId;form.model.value=current.model||'';triggers=current.triggers.map(t=>({...t,config:{...t.config}}))}else triggers=[{kind:'manual',slug:'trigger-1',enabled:true,config:{}}];syncModels();highlightPrompt();reservedSlugs=new Set(triggers.map(t=>t.slug));await refreshAvailability();render()} +form.executionTargetId.addEventListener('change',syncModels); window.addEventListener('focus',()=>refreshAvailability().catch(()=>{}));window.addEventListener('pageshow',()=>refreshAvailability().catch(()=>{})); -form.onsubmit=async e=>{e.preventDefault();const error=$('#error');error.classList.add('hidden');try{if(!triggers.length)throw new Error('Add at least one trigger.');const body={name:form.name.value,slug:form.slug.value,promptTemplate:form.promptTemplate.value,concurrencyLimit:Number(form.concurrencyLimit.value),executionTargetId:form.executionTargetId.value,triggers:triggers.map(({_clientId,...t})=>t)};const result=await request('/api/jobs'+(jobId?'/'+encodeURIComponent(jobId):''),{method:jobId?'PUT':'POST',headers:{'content-type':'application/json'},body:JSON.stringify(body)});location.href='/jobs/'+encodeURIComponent(result.id)}catch(e){error.textContent=e.message;error.classList.remove('hidden');error.scrollIntoView({block:'center'})}};init().catch(e=>{const error=$('#error');error.textContent=e.message;error.classList.remove('hidden')});`); +form.onsubmit=async e=>{e.preventDefault();const error=$('#error');error.classList.add('hidden');try{if(!triggers.length)throw new Error('Add at least one trigger.');const body={name:form.name.value,slug:form.slug.value,promptTemplate:form.promptTemplate.value,model:form.model.value.trim(),concurrencyLimit:Number(form.concurrencyLimit.value),executionTargetId:form.executionTargetId.value,triggers:triggers.map(({_clientId,...t})=>t)};const result=await request('/api/jobs'+(jobId?'/'+encodeURIComponent(jobId):''),{method:jobId?'PUT':'POST',headers:{'content-type':'application/json'},body:JSON.stringify(body)});location.href='/jobs/'+encodeURIComponent(result.id)}catch(e){error.textContent=e.message;error.classList.remove('hidden');error.scrollIntoView({block:'center'})}};init().catch(e=>{const error=$('#error');error.textContent=e.message;error.classList.remove('hidden')});`); export const jobDetailPage = (viewer: { email: string }, jobId: string) => shell("Job — Factorize", viewer, `
← Jobs

Loading job…

Run job manually

Add an optional prompt for this run.

`, `${uiHelpers} @@ -130,7 +133,7 @@ const manualRunDialog=$('#manual-run-dialog'),manualRunForm=$('#manual-run-form' function openManualRun(){manualRunForm.reset();$('#manual-run-error').classList.add('hidden');manualRunDialog.showModal();$('#manual-run-prompt').focus()} $('#cancel-manual-run').onclick=()=>manualRunDialog.close();manualRunDialog.onclick=e=>{if(e.target===manualRunDialog)manualRunDialog.close()}; manualRunForm.onsubmit=async e=>{e.preventDefault();const button=$('#submit-manual-run'),error=$('#manual-run-error');button.disabled=true;error.classList.add('hidden');try{const x=await request('/api/jobs/'+encodeURIComponent(id)+'/invocations',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({prompt:manualRunForm.elements.prompt.value})});location.href='/job-runs/'+encodeURIComponent(x.runId)}catch(e){error.textContent=e.message;error.classList.remove('hidden');button.disabled=false}}; -async function load(){const [j,runs]=await Promise.all([request('/api/jobs/'+encodeURIComponent(id)),request('/api/job-runs?jobId='+encodeURIComponent(id))]),triggers=j.triggers||[];const triggerDetail=triggers.map(t=>esc(t.slug)+' · '+esc(t.kind)).join(' · ');root.innerHTML='

'+esc(j.name)+'

'+triggers.map(t=>triggerBadge(t.kind)).join('')+(j.enabled?'':'Disabled')+'

'+triggerDetail+' · '+j.concurrencyLimit+' concurrent

Edit

Prompt template

'+esc(j.promptTemplate)+'

Runs

'+(runs.items.length?'':'

No runs yet.

')+'
';$('#run').onclick=openManualRun;$('#toggle').onclick=async()=>{await request('/api/jobs/'+encodeURIComponent(id)+'/'+(j.enabled?'disable':'enable'),{method:'POST'});load()};$('#delete').onclick=async()=>{if(confirm('Delete this job and its queued history?')){await request('/api/jobs/'+encodeURIComponent(id),{method:'DELETE'});location.href='/jobs'}}}load().catch(e=>root.innerHTML='

'+esc(e.message)+'

');`); +async function load(){const [j,runs]=await Promise.all([request('/api/jobs/'+encodeURIComponent(id)),request('/api/job-runs?jobId='+encodeURIComponent(id))]),triggers=j.triggers||[];const triggerDetail=triggers.map(t=>esc(t.slug)+' · '+esc(t.kind)).join(' · ');root.innerHTML='

'+esc(j.name)+'

'+triggers.map(t=>triggerBadge(t.kind)).join('')+(j.enabled?'':'Disabled')+'

'+triggerDetail+' · '+j.concurrencyLimit+' concurrent · '+esc(j.model||'Harness default')+'

Edit

Prompt template

'+esc(j.promptTemplate)+'

Runs

'+(runs.items.length?'':'

No runs yet.

')+'
';$('#run').onclick=openManualRun;$('#toggle').onclick=async()=>{await request('/api/jobs/'+encodeURIComponent(id)+'/'+(j.enabled?'disable':'enable'),{method:'POST'});load()};$('#delete').onclick=async()=>{if(confirm('Delete this job and its queued history?')){await request('/api/jobs/'+encodeURIComponent(id),{method:'DELETE'});location.href='/jobs'}}}load().catch(e=>root.innerHTML='

'+esc(e.message)+'

');`); export const jobRunPage = (viewer: { email: string }, runId: string) => shell("Run — Factorize", viewer, `

Loading run…

`, `${uiHelpers} const root=$('#run-detail'),id=root.dataset.id;request('/api/job-runs/'+encodeURIComponent(id)).then(r=>{const caps=r.capabilities||[],canOutput=caps.includes('output'),canStop=caps.includes('stop')&&['starting','running','blocked'].includes(r.state),trusted=typeof r.destination_url==='string'&&r.destination_url.startsWith('https://'),context=r.context===null?'

Context is not available for this legacy run.

':'
'+esc(JSON.stringify(r.context,null,2))+'
';root.innerHTML='← Job

Run '+esc(r.id.slice(0,8))+'

'+esc(r.backend_kind)+' · '+new Date(r.created_at).toLocaleString()+'

'+stateBadge(r.state)+(canStop?'':'')+'

Observation

'+(trusted?'Open '+esc(r.backend_kind)+' destination ↗':'

This backend has no external observation link.

')+'

Context sent to agent

'+context+'
'+(canOutput?'

Output

'+ansiToHtml(r.result||'Output is not available yet.')+'
':'
Output is available only in the backend observation experience.
');if(canStop)$('#stop-run').onclick=async()=>{await request('/api/job-runs/'+encodeURIComponent(id)+'/stop',{method:'POST'});location.reload()}}).catch(e=>root.innerHTML='

'+esc(e.message)+'

');`); diff --git a/packages/app/test/flow-service.test.ts b/packages/app/test/flow-service.test.ts index 8c640c2a..935f8b04 100644 --- a/packages/app/test/flow-service.test.ts +++ b/packages/app/test/flow-service.test.ts @@ -38,7 +38,8 @@ describe("shared API schemas", () => { }); it("validates job configuration and reserved invocation context", () => { - const job = jobInputSchema.parse({ name: "Deploy", slug: "deploy", promptTemplate: "Deploy {{trigger-1.prompt}}", concurrencyLimit: 2, executionTargetId: "exe-1", triggers: [{ kind: "schedule", config: { cron: "0 * * * *", timezone: "UTC" } }, { kind: "jobLifecycle", config: { sourceJobIds: ["worker"], states: ["succeeded", "failed"] } }] }); + const job = jobInputSchema.parse({ name: "Deploy", slug: "deploy", promptTemplate: "Deploy {{trigger-1.prompt}}", model: "gpt-5.5", concurrencyLimit: 2, executionTargetId: "exe-1", triggers: [{ kind: "schedule", config: { cron: "0 * * * *", timezone: "UTC" } }, { kind: "jobLifecycle", config: { sourceJobIds: ["worker"], states: ["succeeded", "failed"] } }] }); + expect(job.model).toBe("gpt-5.5"); expect(job.triggers.map(trigger => trigger.kind)).toEqual(["schedule", "jobLifecycle"]); expect(() => jobInputSchema.parse({ ...job, apiToken: "secret" })).toThrow(); expect(() => jobInputSchema.parse({ ...job, parameterDefaults: {} })).toThrow(); diff --git a/packages/app/test/job-domain.test.ts b/packages/app/test/job-domain.test.ts index b8d2e6bf..8585dd98 100644 --- a/packages/app/test/job-domain.test.ts +++ b/packages/app/test/job-domain.test.ts @@ -3,6 +3,7 @@ import { InvocationService, JOB_SCHEMA, renderJobPrompt, type Invocation, type J const job = (overrides: Partial = {}): Job => ({ id: "job-1", name: "Triage", slug: "triage", promptTemplate: "{{trigger-1.prompt}} · {{trigger-2.issue.title}}", + model: "", executionTarget: { connectionId: "exe-1", workspace: "triage", cwd: "/repo", agentKind: "codex" }, concurrencyLimit: 1, enabled: true, triggers: [], diff --git a/packages/app/test/ui.test.ts b/packages/app/test/ui.test.ts index b6b19212..43bb5ac3 100644 --- a/packages/app/test/ui.test.ts +++ b/packages/app/test/ui.test.ts @@ -100,10 +100,20 @@ describe("pages", () => { expect(html).toContain("Name this job and set how many runs it can process at once."); expect(html).toContain("Choose the events that start this job and expose prompt context."); expect(html).toContain("Write the instructions for each run using context supplied by your triggers."); - expect(html).toContain("Select the connected environment that will run this job."); + expect(html).toContain("Select the connected environment and model that will run this job."); } }); + it("selects a per-job model with harness-aware suggestions", () => { + const html = jobPage({ email: "owner@example.com" }, "job-1"); + expect(html).toContain('name="model"'); + expect(html).toContain('placeholder="Harness default"'); + expect(html).toContain("const modelChoices={codex:"); + expect(html).toContain("model:form.model.value.trim()"); + expect(html).toContain("form.model.value=current.model||''"); + expectInlineScriptsToParse(html); + }); + it("shows synchronized wildcard trigger hints while retaining detailed autocomplete", () => { const html = jobPage({ email: "owner@example.com" }, "job-1"); expect(html).toContain("const triggerHints=()=>triggers.map"); diff --git a/packages/app/test/workspace.test.ts b/packages/app/test/workspace.test.ts index 3c175f46..524b3243 100644 --- a/packages/app/test/workspace.test.ts +++ b/packages/app/test/workspace.test.ts @@ -73,6 +73,11 @@ describe("flow workspaces", () => { expect(command).toContain("-- '--model' 'gpt 5'"); }); + it("passes a per-job model as a safely quoted harness argument", () => { + const command = startAgentCommand("factorize-1", { vmName: "vm", apiToken: "token", agentKind: "codex", cwd: "/repo", model: "gpt-5.5 codex" }, "fix it", "factorize", "/repo/.factorize-runs/run", "lease"); + expect(command).toContain("-- '--dangerously-bypass-approvals-and-sandbox' '--model' 'gpt-5.5 codex'"); + }); + it("garbage collects only after terminal, run directory, and lease revalidation", () => { const command = garbageCollectPaneCommand({ vmName: "vm", apiToken: "token", agentKind: "codex", cwd: "/repo" }, "w1:p2", "term-7", "/repo/.factorize-runs/run", "lease-7"); expect(command).toContain(".terminal_id == $terminal");