Skip to content

Commit c85533a

Browse files
committed
chore(contracts): sync the worker's steering v2 contract
Additive copies of the worker's SteerV2Request, SteerV2Response and steering_applied frame shape, generated from simstudioai/mothership#929. Nothing in Sim uses them yet; Sim's side of a paired contract merges first.
1 parent 7ee2814 commit c85533a

2 files changed

Lines changed: 87 additions & 0 deletions

File tree

‎apps/sim/lib/mothership/generated/mothership-stream-v1.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type MothershipStreamV1EventEnvelope =
2323
| MothershipStreamV1RunResumedEventEnvelope
2424
| MothershipStreamV1CompactionStartEventEnvelope
2525
| MothershipStreamV1CompactionDoneEventEnvelope
26+
| MothershipStreamV1SteeringAppliedEventEnvelope
2627
| MothershipStreamV1TaskArmedEventEnvelope
2728
| MothershipStreamV1TaskDeliveredEventEnvelope
2829
| MothershipStreamV1ErrorEventEnvelope
@@ -371,6 +372,25 @@ export interface MothershipStreamV1CompactionDonePayload {
371372
export interface MothershipStreamV1CompactionDoneData {
372373
summary_chars: number
373374
}
375+
export interface MothershipStreamV1SteeringAppliedEventEnvelope {
376+
payload: MothershipStreamV1SteeringAppliedPayload
377+
scope?: MothershipStreamV1StreamScope
378+
seq: number
379+
stream: MothershipStreamV1StreamRef
380+
trace?: MothershipStreamV1Trace
381+
ts: string
382+
type: 'run'
383+
v: 1
384+
}
385+
export interface MothershipStreamV1SteeringAppliedPayload {
386+
content?: string
387+
eventSeq?: number
388+
kind: 'steering_applied'
389+
messageId?: string
390+
mode?: 'deferred' | 'interrupt'
391+
steeringId: string
392+
textOffset?: number
393+
}
374394
export interface MothershipStreamV1TaskArmedEventEnvelope {
375395
payload: MothershipStreamV1TaskArmedPayload
376396
scope?: MothershipStreamV1StreamScope

‎apps/sim/lib/mothership/generated/protocol.ts‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,73 @@ export interface SteerRequest {
511511
content: string;
512512
}
513513

514+
/**
515+
* The images one run takes in steers over its whole life. With a turn's own five they stay
516+
* under the twenty image and document blocks a model request holds.
517+
*/
518+
export const MAX_RUN_STEERED_IMAGES = 10;
519+
520+
/** The most attachments and mentions one steer carries: Sim's MAX_CHAT_CONTEXTS for a turn. */
521+
export const MAX_STEER_CONTEXTS = 100;
522+
523+
/**
524+
* POST /api/streams/steer/v2: steer the live run `messageId` with one immutable input, answered
525+
* with its durable disposition, which a retry of the same body reads back. Only `not_applied`
526+
* (or a 422) lets the caller send the input as a new turn, with the steeringId as its
527+
* messageId; a turn for an input a run applied is refused. Refusals keep nothing:
528+
* - 400: an invalid body, or images outside an organization chat (`steering_scope`).
529+
* - 404 `steering_target_missing`: no such run (or not admitted yet).
530+
* - 409 `steering_conflict`: a different input under this steeringId.
531+
* - 422 `steering_image_limit`: past MAX_RUN_STEERED_IMAGES, applied images included. Final
532+
* for the run: send the input as the next turn once the run ends.
533+
* - 429 `steering_capacity`: the pending queue is full; retryable once the run applies it.
534+
*/
535+
export const SteerV2Request = z.strictObject({
536+
messageId: z.uuid(),
537+
steeringId: z.uuid(),
538+
content: z.string().min(1).max(1_048_576),
539+
/** Attachments and @-mentions, rendered into the steer the way a turn renders its own. */
540+
context: ChatPayloadSchema.shape.context.unwrap().max(MAX_STEER_CONTEXTS).default([]),
541+
/** Only an organization chat accepts images, as for a turn (400 otherwise). */
542+
assistantImages: ChatPayloadSchema.shape.assistantImages,
543+
});
544+
export type SteerV2Request = z.infer<typeof SteerV2Request>;
545+
546+
/**
547+
* - `queued`: accepted; the run applies it at its next model step, or ends first and then
548+
* reports `not_applied`.
549+
* - `applied`: logged into the run's model input, which its next model request carries (as
550+
* v1's frame means). `eventSeq` is its steering_input event in the chat
551+
* log and `textOffset` the main answer's length when it applied (UTF-16 code units), the
552+
* same values the `steering_applied` frame carries.
553+
* - `not_applied`: the run ended, or was stopped, before applying it, and never will. A run
554+
* that would apply it only by exceeding its usage limit, or one whose input the request
555+
* supplies (an execution, a structured response), ends instead and reports this.
556+
*
557+
* A steeringId belongs to the run of the chat that first accepted it: a retry naming another
558+
* run of the chat reads that run's disposition.
559+
*/
560+
export const SteerV2Response = z.discriminatedUnion("status", [
561+
z.strictObject({ steeringId: z.string(), status: z.literal("queued") }),
562+
z.strictObject({
563+
steeringId: z.string(),
564+
status: z.literal("applied"),
565+
eventSeq: z.number().int().positive(),
566+
textOffset: z.number().int().nonnegative(),
567+
}),
568+
z.strictObject({ steeringId: z.string(), status: z.literal("not_applied") }),
569+
]);
570+
export type SteerV2Response = z.infer<typeof SteerV2Response>;
571+
572+
/** The `run`/`steering_applied` frame: a steer reached the run's model input. */
573+
export interface StreamSteeringApplied {
574+
kind: "steering_applied";
575+
steeringId: string;
576+
/** As in SteerV2Response's `applied`; absent only on frames from workers without steer v2. */
577+
eventSeq?: number | undefined;
578+
textOffset?: number | undefined;
579+
}
580+
514581
/** POST /api/chats/fork — copy a selected conversation snapshot, never live execution. */
515582
export const ForkChatRequest = z
516583
.strictObject({

0 commit comments

Comments
 (0)