@amigo-ai/platform-sdk 0.17.3 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api.md CHANGED
@@ -239,6 +239,7 @@ All workspace-scoped resources also expose `withOptions(options)`.
239
239
  - `get`
240
240
  - `close`
241
241
  - `createTurn`
242
+ - `createTurnStream`
242
243
  - `textStreamUrl`
243
244
 
244
245
  ### `phoneNumbers`
package/dist/index.cjs CHANGED
@@ -1984,10 +1984,47 @@ var ConversationsResource = class extends WorkspaceScopedResource {
1984
1984
  params: {
1985
1985
  path: { workspace_id: this.workspaceId, conversation_id: conversationId }
1986
1986
  },
1987
- body: request
1987
+ body: request,
1988
+ headers: { Accept: "application/json" }
1988
1989
  })
1989
1990
  );
1990
1991
  }
1992
+ /**
1993
+ * Send a message and receive the agent's response as an SSE stream.
1994
+ *
1995
+ * Returns a `ReadableStream` of SSE bytes. Use `EventSourceParserStream`
1996
+ * (from `eventsource-parser/stream`) to parse into typed `TurnStreamEvent`.
1997
+ *
1998
+ * @example
1999
+ * ```ts
2000
+ * const stream = await client.conversations.createTurnStream(convId, { message: "Hello" });
2001
+ * const events = stream
2002
+ * .pipeThrough(new TextDecoderStream())
2003
+ * .pipeThrough(new EventSourceParserStream());
2004
+ * for await (const event of events) {
2005
+ * const parsed = JSON.parse(event.data) as TurnStreamEvent;
2006
+ * if (parsed.event === "token") console.log(parsed.text);
2007
+ * }
2008
+ * ```
2009
+ */
2010
+ async createTurnStream(conversationId, request, options) {
2011
+ const result = await this.client.POST(
2012
+ "/v1/{workspace_id}/conversations/{conversation_id}/turns",
2013
+ {
2014
+ params: {
2015
+ path: { workspace_id: this.workspaceId, conversation_id: conversationId }
2016
+ },
2017
+ body: request,
2018
+ headers: { Accept: "text/event-stream" },
2019
+ parseAs: "stream",
2020
+ signal: options?.signal
2021
+ }
2022
+ );
2023
+ if (result.error !== void 0) {
2024
+ throw new Error(`API error: ${JSON.stringify(result.error)}`);
2025
+ }
2026
+ return result.data;
2027
+ }
1991
2028
  /** Build the real-time text WebSocket URL for browser or custom clients. */
1992
2029
  textStreamUrl(params) {
1993
2030
  const url = buildTextStreamUrl({