From 3e57b43a4a59e2f91d13f5fc08a6db5d4e3fb164 Mon Sep 17 00:00:00 2001 From: James Long Date: Tue, 7 Jul 2026 14:17:20 -0400 Subject: [PATCH] feat(session): support admit-only synthetic messages (#35774) --- packages/client/src/effect/api/api.ts | 1 + packages/client/src/effect/generated/client.ts | 8 +++++++- packages/client/src/promise/generated/client.ts | 7 ++++++- packages/client/src/promise/generated/types.ts | 9 +++++++++ packages/core/src/session.ts | 2 ++ packages/protocol/src/groups/session.ts | 1 + packages/server/src/handlers/session.ts | 1 + 7 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/client/src/effect/api/api.ts b/packages/client/src/effect/api/api.ts index 59202fe0efa..d70a2838e8a 100644 --- a/packages/client/src/effect/api/api.ts +++ b/packages/client/src/effect/api/api.ts @@ -154,6 +154,7 @@ export type Endpoint4_12Input = { readonly text: Endpoint4_12Request["payload"]["text"] readonly description?: Endpoint4_12Request["payload"]["description"] readonly metadata?: Endpoint4_12Request["payload"]["metadata"] + readonly resume?: Endpoint4_12Request["payload"]["resume"] } export type Endpoint4_12Output = EffectValue> export type SessionSyntheticOperation = (input: Endpoint4_12Input) => Effect.Effect diff --git a/packages/client/src/effect/generated/client.ts b/packages/client/src/effect/generated/client.ts index 94de0970f30..ab65a65f925 100644 --- a/packages/client/src/effect/generated/client.ts +++ b/packages/client/src/effect/generated/client.ts @@ -209,11 +209,17 @@ type Endpoint4_12Input = { readonly text: Endpoint4_12Request["payload"]["text"] readonly description?: Endpoint4_12Request["payload"]["description"] readonly metadata?: Endpoint4_12Request["payload"]["metadata"] + readonly resume?: Endpoint4_12Request["payload"]["resume"] } const Endpoint4_12 = (raw: RawClient["server.session"]) => (input: Endpoint4_12Input) => raw["session.synthetic"]({ params: { sessionID: input["sessionID"] }, - payload: { text: input["text"], description: input["description"], metadata: input["metadata"] }, + payload: { + text: input["text"], + description: input["description"], + metadata: input["metadata"], + resume: input["resume"], + }, }).pipe(Effect.mapError(mapClientError)) type Endpoint4_13Request = Parameters[0] diff --git a/packages/client/src/promise/generated/client.ts b/packages/client/src/promise/generated/client.ts index 4c57621d480..82930a324eb 100644 --- a/packages/client/src/promise/generated/client.ts +++ b/packages/client/src/promise/generated/client.ts @@ -538,7 +538,12 @@ export function make(options: ClientOptions) { { method: "POST", path: `/api/session/${encodeURIComponent(input.sessionID)}/synthetic`, - body: { text: input["text"], description: input["description"], metadata: input["metadata"] }, + body: { + text: input["text"], + description: input["description"], + metadata: input["metadata"], + resume: input["resume"], + }, successStatus: 204, declaredStatuses: [404, 400, 401], empty: true, diff --git a/packages/client/src/promise/generated/types.ts b/packages/client/src/promise/generated/types.ts index aaee9778b3b..e74b7cec55f 100644 --- a/packages/client/src/promise/generated/types.ts +++ b/packages/client/src/promise/generated/types.ts @@ -856,17 +856,26 @@ export type SessionSyntheticInput = { readonly text: string readonly description?: string | null readonly metadata?: { readonly [x: string]: JsonValue } + readonly resume?: boolean | null }["text"] readonly description?: { readonly text: string readonly description?: string | null readonly metadata?: { readonly [x: string]: JsonValue } + readonly resume?: boolean | null }["description"] readonly metadata?: { readonly text: string readonly description?: string | null readonly metadata?: { readonly [x: string]: JsonValue } + readonly resume?: boolean | null }["metadata"] + readonly resume?: { + readonly text: string + readonly description?: string | null + readonly metadata?: { readonly [x: string]: JsonValue } + readonly resume?: boolean | null + }["resume"] } export type SessionSyntheticOutput = void diff --git a/packages/core/src/session.ts b/packages/core/src/session.ts index b5d28c46127..ea18ed39093 100644 --- a/packages/core/src/session.ts +++ b/packages/core/src/session.ts @@ -243,6 +243,7 @@ export interface Interface { text: string description?: string metadata?: Record + resume?: boolean }) => Effect.Effect readonly revert: { readonly stage: (input: { @@ -682,6 +683,7 @@ const layer = Layer.effect( description: input.description, metadata: input.metadata, }) + if (input.resume === false) return yield* execution .resume(input.sessionID) .pipe(Effect.ignore, Effect.forkIn(scope, { startImmediately: true }), Effect.asVoid) diff --git a/packages/protocol/src/groups/session.ts b/packages/protocol/src/groups/session.ts index 090df62eb69..bc9cd1ab2f4 100644 --- a/packages/protocol/src/groups/session.ts +++ b/packages/protocol/src/groups/session.ts @@ -344,6 +344,7 @@ export const makeSessionGroup = (sessionLo text: Schema.String, description: Schema.String.pipe(Schema.optional), metadata: SessionMessage.Synthetic.fields.metadata, + resume: Schema.Boolean.pipe(Schema.optional), }), success: HttpApiSchema.NoContent, error: SessionNotFoundError, diff --git a/packages/server/src/handlers/session.ts b/packages/server/src/handlers/session.ts index ce3bc15f364..6059dcb89a2 100644 --- a/packages/server/src/handlers/session.ts +++ b/packages/server/src/handlers/session.ts @@ -329,6 +329,7 @@ export const SessionHandler = HttpApiBuilder.group(Api, "server.session", (handl text: ctx.payload.text, description: ctx.payload.description, metadata: ctx.payload.metadata, + resume: ctx.payload.resume, }) .pipe( Effect.catchTag("Session.NotFoundError", (error) =>