@amigo-ai/platform-sdk 0.62.1 → 0.64.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
@@ -2095,21 +2095,47 @@ var ConversationsResource = class extends WorkspaceScopedResource {
2095
2095
  * alongside the response turns. Server-side default is `false` — without
2096
2096
  * this opt-in the `tool_calls` array on the `TurnResponse` will be empty
2097
2097
  * even when the agent invoked tools during the turn.
2098
+ *
2099
+ * Pass `options.poll: true` for a no-message drain-and-report poll (see
2100
+ * {@link pollTurn} for the ergonomic wrapper): the agent surfaces any
2101
+ * background tool results that completed since the last turn. A poll must
2102
+ * NOT carry a `request.message` (the server rejects it 422); prefer
2103
+ * {@link pollTurn}.
2098
2104
  */
2099
2105
  async createTurn(conversationId, request, options) {
2106
+ if (options?.poll && request.message) {
2107
+ throw new ConfigurationError("poll cannot be combined with a message; use pollTurn() instead");
2108
+ }
2109
+ const query = {};
2110
+ if (options?.includeToolCalls !== void 0) query.include_tool_calls = options.includeToolCalls;
2111
+ if (options?.poll !== void 0) query.poll = options.poll;
2100
2112
  return extractData(
2101
2113
  await this.client.POST("/v1/{workspace_id}/conversations/{conversation_id}/turns", {
2102
2114
  params: {
2103
2115
  path: { workspace_id: this.workspaceId, conversation_id: conversationId },
2104
- ...options?.includeToolCalls !== void 0 && {
2105
- query: { include_tool_calls: options.includeToolCalls }
2106
- }
2116
+ ...Object.keys(query).length > 0 && { query }
2107
2117
  },
2108
2118
  body: request,
2109
2119
  headers: { Accept: "application/json" }
2110
2120
  })
2111
2121
  );
2112
2122
  }
2123
+ /**
2124
+ * Poll a conversation for background tool results without sending a user
2125
+ * message. Drains any background tool calls that completed since the last
2126
+ * turn and returns the agent's report; when nothing is pending the response
2127
+ * has empty `output` and `tool_calls` (the idle case) — treat that as "keep
2128
+ * polling". Poll no more than once every ~5s per conversation.
2129
+ *
2130
+ * @example
2131
+ * ```ts
2132
+ * const res = await client.conversations.pollTurn(convId, { includeToolCalls: true });
2133
+ * if (res.output.length || res.tool_calls?.length) render(res); // else poll again later
2134
+ * ```
2135
+ */
2136
+ async pollTurn(conversationId, options) {
2137
+ return this.createTurn(conversationId, {}, { ...options, poll: true });
2138
+ }
2113
2139
  /**
2114
2140
  * Send a message and receive the agent's response as an SSE byte stream.
2115
2141
  *