Another Service as a step

The running jobjob_7Hq2 · working · $49.00 held

Import one of your Services and make it a step. It is ordered the way an agent orders it, at its price, and keeps its own job and ledger.

A nested Service answers one question: which part of this work is already a Service you sell?

services/translated-summary.ts
import translation from './translation.ts'
  deliver: { translate: translation, summarize: 'ai' },
Run
npx services.dev check
captured
  steps   translate · Translation → summarize · ai → review · ai · adversarial

On the Service

KeyWrittenLeft outDoes
deliverDeliver'ai', briefed by services/<id>.mdWho does the work: 'ai', a person or a role word, a URL, your function, or named steps in order.

Another of your Services, ordered the way an agent orders it: at its price, with this job's id as the key.

The step orders your Translation at its price, with this job's id as the key, so a retry never orders it twice. The nested job keeps its own id, record and ledger, and this job pays it:

Run
npx services.dev translated-summary document=report.pdf to=fr-CA --max 79
captured
job_7Hv5 · working · $79.00 held
job_7Hv5 · delivered · report.fr-CA.pdf · summary.pdf · $79.00 charged
  record  translate · service · job_7Hq6 · $49.00 | summarize · ai | review · ai · pass
  ledger  +$79.00 · AI $0.84 · your Translation $49.00 · you $29.16
  brand   +$79.00 · AI $1.68 · you $77.32 across job_7Hv5 and job_7Hq6

The ledger line is this job's: it paid $49 to your Translation. The brand line adds both jobs up, because the $49 stayed with you.

This job's input must have everything the nested Service needs. TypeScript says so before anything runs, as the refusals below show.

check counts the nested price as a cost of this Service, so price_below_cost fails one priced below what it orders.

OpAPICLIMCPSDKSiteDocsApp
service.orderPOST /jobs, POST /:service<service> k=v …order_<service><service>.order()/<service>: the order form10 error pagescustomer portal

Operations has every column of every row.

check gateWhy
price_below_costA delivered job could lose money: payout, nested Services and the AI cap add up to more than the price.
WrittenWhat TypeScript says
input: { document: 'file' }, output: { document: 'file' }, deliver: { translate: translation }, price: 99Property 'to' is missing in type '{ readonly document: FileRef; }' but required in type '{ readonly document: FileRef; readonly to: string; }'.