@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/api.md CHANGED
@@ -250,6 +250,7 @@ All workspace-scoped resources also expose `withOptions(options)`.
250
250
  - `get`
251
251
  - `close`
252
252
  - `createTurn`
253
+ - `pollTurn`
253
254
  - `createTurnStream`
254
255
  - `streamTurn`
255
256
  - `textStreamUrl`
package/dist/index.cjs CHANGED
@@ -2206,21 +2206,47 @@ var ConversationsResource = class extends WorkspaceScopedResource {
2206
2206
  * alongside the response turns. Server-side default is `false` — without
2207
2207
  * this opt-in the `tool_calls` array on the `TurnResponse` will be empty
2208
2208
  * even when the agent invoked tools during the turn.
2209
+ *
2210
+ * Pass `options.poll: true` for a no-message drain-and-report poll (see
2211
+ * {@link pollTurn} for the ergonomic wrapper): the agent surfaces any
2212
+ * background tool results that completed since the last turn. A poll must
2213
+ * NOT carry a `request.message` (the server rejects it 422); prefer
2214
+ * {@link pollTurn}.
2209
2215
  */
2210
2216
  async createTurn(conversationId, request, options) {
2217
+ if (options?.poll && request.message) {
2218
+ throw new ConfigurationError("poll cannot be combined with a message; use pollTurn() instead");
2219
+ }
2220
+ const query = {};
2221
+ if (options?.includeToolCalls !== void 0) query.include_tool_calls = options.includeToolCalls;
2222
+ if (options?.poll !== void 0) query.poll = options.poll;
2211
2223
  return extractData(
2212
2224
  await this.client.POST("/v1/{workspace_id}/conversations/{conversation_id}/turns", {
2213
2225
  params: {
2214
2226
  path: { workspace_id: this.workspaceId, conversation_id: conversationId },
2215
- ...options?.includeToolCalls !== void 0 && {
2216
- query: { include_tool_calls: options.includeToolCalls }
2217
- }
2227
+ ...Object.keys(query).length > 0 && { query }
2218
2228
  },
2219
2229
  body: request,
2220
2230
  headers: { Accept: "application/json" }
2221
2231
  })
2222
2232
  );
2223
2233
  }
2234
+ /**
2235
+ * Poll a conversation for background tool results without sending a user
2236
+ * message. Drains any background tool calls that completed since the last
2237
+ * turn and returns the agent's report; when nothing is pending the response
2238
+ * has empty `output` and `tool_calls` (the idle case) — treat that as "keep
2239
+ * polling". Poll no more than once every ~5s per conversation.
2240
+ *
2241
+ * @example
2242
+ * ```ts
2243
+ * const res = await client.conversations.pollTurn(convId, { includeToolCalls: true });
2244
+ * if (res.output.length || res.tool_calls?.length) render(res); // else poll again later
2245
+ * ```
2246
+ */
2247
+ async pollTurn(conversationId, options) {
2248
+ return this.createTurn(conversationId, {}, { ...options, poll: true });
2249
+ }
2224
2250
  /**
2225
2251
  * Send a message and receive the agent's response as an SSE byte stream.
2226
2252
  *