diff --git a/.changeset/update-workflows-sdk.md b/.changeset/update-workflows-sdk.md new file mode 100644 index 00000000..8475660d --- /dev/null +++ b/.changeset/update-workflows-sdk.md @@ -0,0 +1,5 @@ +--- +"@llamaindex/workflows-client": minor +--- + + diff --git a/packages/workflows-client/openapi.json b/packages/workflows-client/openapi.json index 1214c778..ea09e785 100644 --- a/packages/workflows-client/openapi.json +++ b/packages/workflows-client/openapi.json @@ -2,7 +2,7 @@ "openapi": "3.0.0", "info": { "title": "Workflows API", - "version": "2.8.3" + "version": "2.9.0" }, "components": { "schemas": { @@ -337,7 +337,7 @@ "/events/{handler_id}": { "get": { "summary": "Stream workflow events", - "description": "Streams events produced by a workflow execution. Events are emitted as\nnewline-delimited JSON by default, or as Server-Sent Events when `sse=true`.\nEvent data is returned as an envelope that preserves backward-compatible fields\nand adds metadata for type-safety on the client:\n{\n \"__is_pydantic\": true,\n \"value\": ,\n \"qualified_name\": , # deprecated, prefer `mro`\n \"mro\": [],\n \"origin\": \"builtin\" | \"user\"\n}\n\nEvent queue is mutable. Elements are added to the queue by the workflow handler, and removed by any consumer of the queue.\nThe queue is protected by a lock that is acquired by the consumer, so only one consumer of the queue at a time is allowed.\n", + "description": "Streams events produced by a workflow execution. Events are emitted as\nnewline-delimited JSON by default, or as Server-Sent Events when `sse=true`.\nEvent data is returned as an envelope that preserves backward-compatible fields\nand adds metadata for type-safety on the client:\n{\n \"value\": ,\n \"types\": [],\n \"type\": ,\n \"qualified_name\": ,\n}\n\nEvent queue is mutable. Elements are added to the queue by the workflow handler, and removed by any consumer of the queue.\nThe queue is protected by a lock that is acquired by the consumer, so only one consumer of the queue at a time is allowed.\n", "parameters": [ { "in": "path", @@ -377,6 +377,16 @@ "default": 1 }, "description": "Timeout for acquiring the lock to iterate over the events." + }, + { + "in": "query", + "name": "include_qualified_name", + "required": false, + "schema": { + "type": "boolean", + "default": true + }, + "description": "If true, include the qualified name of the event in the response body." } ], "responses": { @@ -392,6 +402,17 @@ "type": "object", "description": "The event value." }, + "type": { + "type": "string", + "description": "The class name of the event." + }, + "types": { + "type": "array", + "description": "Superclass names from MRO (excluding the event class and base Event).", + "items": { + "type": "string" + } + }, "qualified_name": { "type": "string", "description": "The qualified name of the event." @@ -399,7 +420,7 @@ }, "required": [ "value", - "qualified_name" + "type" ] } } @@ -432,14 +453,30 @@ "type": "object", "properties": { "event": { - "type": "string", - "description": "Serialized event in JSON format.", - "examples": { - "type": "event_name", - "data": { - "key": "value" + "description": "Serialized event. Accepts object or JSON-encoded string for backward compatibility.", + "oneOf": [ + { + "type": "string", + "description": "JSON string of the event envelope or value.", + "examples": [ + "{\"type\": \"ExternalEvent\", \"value\": {\"response\": \"hi\"}}" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "The class name of the event." + }, + "value": { + "type": "object", + "description": "The event value object (preferred over data)." + } + }, + "additionalProperties": true } - } + ] }, "step": { "type": "string", diff --git a/packages/workflows-client/src/generated/client/utils.gen.ts b/packages/workflows-client/src/generated/client/utils.gen.ts index b4bcc4d1..4c48a9ee 100644 --- a/packages/workflows-client/src/generated/client/utils.gen.ts +++ b/packages/workflows-client/src/generated/client/utils.gen.ts @@ -12,9 +12,8 @@ import { getUrl } from '../core/utils.gen'; import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; export const createQuerySerializer = ({ - allowReserved, - array, - object, + parameters = {}, + ...args }: QuerySerializerOptions = {}) => { const querySerializer = (queryParams: T) => { const search: string[] = []; @@ -26,29 +25,31 @@ export const createQuerySerializer = ({ continue; } + const options = parameters[name] || args; + if (Array.isArray(value)) { const serializedArray = serializeArrayParam({ - allowReserved, + allowReserved: options.allowReserved, explode: true, name, style: 'form', value, - ...array, + ...options.array, }); if (serializedArray) search.push(serializedArray); } else if (typeof value === 'object') { const serializedObject = serializeObjectParam({ - allowReserved, + allowReserved: options.allowReserved, explode: true, name, style: 'deepObject', value: value as Record, - ...object, + ...options.object, }); if (serializedObject) search.push(serializedObject); } else { const serializedPrimitive = serializePrimitiveParam({ - allowReserved, + allowReserved: options.allowReserved, name, value: value as string, }); diff --git a/packages/workflows-client/src/generated/core/bodySerializer.gen.ts b/packages/workflows-client/src/generated/core/bodySerializer.gen.ts index 49cd8925..552b50f7 100644 --- a/packages/workflows-client/src/generated/core/bodySerializer.gen.ts +++ b/packages/workflows-client/src/generated/core/bodySerializer.gen.ts @@ -10,11 +10,19 @@ export type QuerySerializer = (query: Record) => string; export type BodySerializer = (body: any) => any; -export interface QuerySerializerOptions { +type QuerySerializerOptionsObject = { allowReserved?: boolean; - array?: SerializerOptions; - object?: SerializerOptions; -} + array?: Partial>; + object?: Partial>; +}; + +export type QuerySerializerOptions = QuerySerializerOptionsObject & { + /** + * Per-parameter serialization overrides. When provided, these settings + * override the global array/object settings for specific parameter names. + */ + parameters?: Record; +}; const serializeFormDataPair = ( data: FormData, diff --git a/packages/workflows-client/src/generated/sdk.gen.ts b/packages/workflows-client/src/generated/sdk.gen.ts index 01b1d506..8103f9cb 100644 --- a/packages/workflows-client/src/generated/sdk.gen.ts +++ b/packages/workflows-client/src/generated/sdk.gen.ts @@ -100,11 +100,10 @@ export const getResultsByHandlerId = (opti * Event data is returned as an envelope that preserves backward-compatible fields * and adds metadata for type-safety on the client: * { - * "__is_pydantic": true, * "value": , - * "qualified_name": , # deprecated, prefer `mro` - * "mro": [], - * "origin": "builtin" | "user" + * "types": [], + * "type": , + * "qualified_name": , * } * * Event queue is mutable. Elements are added to the queue by the workflow handler, and removed by any consumer of the queue. diff --git a/packages/workflows-client/src/generated/types.gen.ts b/packages/workflows-client/src/generated/types.gen.ts index b4aa090a..935ce111 100644 --- a/packages/workflows-client/src/generated/types.gen.ts +++ b/packages/workflows-client/src/generated/types.gen.ts @@ -255,6 +255,10 @@ export type GetEventsByHandlerIdData = { * Timeout for acquiring the lock to iterate over the events. */ acquire_timeout?: number; + /** + * If true, include the qualified name of the event in the response body. + */ + include_qualified_name?: boolean; }; url: '/events/{handler_id}'; }; @@ -277,10 +281,18 @@ export type GetEventsByHandlerIdResponses = { value: { [key: string]: unknown; }; + /** + * The class name of the event. + */ + type: string; + /** + * Superclass names from MRO (excluding the event class and base Event). + */ + types?: Array; /** * The qualified name of the event. */ - qualified_name: string; + qualified_name?: string; }; }; @@ -289,9 +301,23 @@ export type GetEventsByHandlerIdResponse = GetEventsByHandlerIdResponses[keyof G export type PostEventsByHandlerIdData = { body: { /** - * Serialized event in JSON format. + * Serialized event. Accepts object or JSON-encoded string for backward compatibility. */ - event: string; + event: string | { + /** + * The class name of the event. + */ + type?: string; + /** + * The event value object (preferred over data). + */ + value?: { + [key: string]: unknown; + }; + [key: string]: unknown | string | { + [key: string]: unknown; + } | undefined; + }; /** * Optional target step name. If not provided, event is sent to all steps. */