@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/dist/index.mjs CHANGED
@@ -1891,10 +1891,47 @@ var ConversationsResource = class extends WorkspaceScopedResource {
1891
1891
  params: {
1892
1892
  path: { workspace_id: this.workspaceId, conversation_id: conversationId }
1893
1893
  },
1894
- body: request
1894
+ body: request,
1895
+ headers: { Accept: "application/json" }
1895
1896
  })
1896
1897
  );
1897
1898
  }
1899
+ /**
1900
+ * Send a message and receive the agent's response as an SSE stream.
1901
+ *
1902
+ * Returns a `ReadableStream` of SSE bytes. Use `EventSourceParserStream`
1903
+ * (from `eventsource-parser/stream`) to parse into typed `TurnStreamEvent`.
1904
+ *
1905
+ * @example
1906
+ * ```ts
1907
+ * const stream = await client.conversations.createTurnStream(convId, { message: "Hello" });
1908
+ * const events = stream
1909
+ * .pipeThrough(new TextDecoderStream())
1910
+ * .pipeThrough(new EventSourceParserStream());
1911
+ * for await (const event of events) {
1912
+ * const parsed = JSON.parse(event.data) as TurnStreamEvent;
1913
+ * if (parsed.event === "token") console.log(parsed.text);
1914
+ * }
1915
+ * ```
1916
+ */
1917
+ async createTurnStream(conversationId, request, options) {
1918
+ const result = await this.client.POST(
1919
+ "/v1/{workspace_id}/conversations/{conversation_id}/turns",
1920
+ {
1921
+ params: {
1922
+ path: { workspace_id: this.workspaceId, conversation_id: conversationId }
1923
+ },
1924
+ body: request,
1925
+ headers: { Accept: "text/event-stream" },
1926
+ parseAs: "stream",
1927
+ signal: options?.signal
1928
+ }
1929
+ );
1930
+ if (result.error !== void 0) {
1931
+ throw new Error(`API error: ${JSON.stringify(result.error)}`);
1932
+ }
1933
+ return result.data;
1934
+ }
1898
1935
  /** Build the real-time text WebSocket URL for browser or custom clients. */
1899
1936
  textStreamUrl(params) {
1900
1937
  const url = buildTextStreamUrl({