@amigo-ai/platform-sdk 0.19.0 → 0.22.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 +3 -2
- package/dist/index.cjs +103 -2
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -2
- package/dist/index.mjs.map +2 -2
- package/dist/resources/conversations.js +112 -1
- package/dist/resources/conversations.js.map +1 -1
- package/dist/resources/operators.js.map +1 -1
- package/dist/types/generated/api.d.ts +995 -390
- package/dist/types/generated/api.d.ts.map +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/resources/calls.d.ts +1 -1
- package/dist/types/resources/conversations.d.ts +79 -1
- package/dist/types/resources/conversations.d.ts.map +1 -1
- package/dist/types/resources/functions.d.ts.map +1 -1
- package/dist/types/resources/metrics.d.ts.map +1 -1
- package/dist/types/resources/operators.d.ts +8 -5
- package/dist/types/resources/operators.d.ts.map +1 -1
- package/dist/types/resources/recordings.d.ts +1 -1
- package/dist/types/resources/settings.d.ts.map +1 -1
- package/package.json +1 -1
package/api.md
CHANGED
|
@@ -51,8 +51,8 @@ Notes:
|
|
|
51
51
|
- Request option types: `AmigoRequestOptions`, `ScopedRequestOptions`
|
|
52
52
|
- Webhooks: `verifyWebhookSignature`, `parseWebhookEvent`, `WebhookVerificationError`
|
|
53
53
|
- Pagination and response helpers: `paginate`, `buildLastResponse`, `extractRequestId`
|
|
54
|
-
- Conversation helpers: `textStreamAuthProtocols`
|
|
55
|
-
- Conversation types: `ConversationDetail`, `ConversationListResponse`, `ConversationSummary`, `ConversationTurn`, `CreateConversationRequest`, `ListConversationsParams`, `TextStreamAuthProtocols` (WebSocket constructor subprotocol tuple), `TextStreamUrlParams`, `TurnRequest`, `TurnResponse`
|
|
54
|
+
- Conversation helpers: `sessionConnectAuthProtocols`, `textStreamAuthProtocols`
|
|
55
|
+
- Conversation types: `ConversationDetail`, `ConversationListResponse`, `ConversationSummary`, `ConversationTurn`, `CreateConversationRequest`, `ListConversationsParams`, `SessionConnectUrlParams`, `TextStreamAuthProtocols` (WebSocket constructor subprotocol tuple), `TextStreamUrlParams`, `TurnDoneEvent`, `TurnErrorEvent`, `TurnMessageEvent`, `TurnRequest`, `TurnResponse`, `TurnStreamEvent`, `TurnThinkingEvent`, `TurnTokenEvent`, `TurnToolCallCompletedEvent`, `TurnToolCallStartedEvent`
|
|
56
56
|
- Response and hook types: `PaginatedList`, `ListParams`, `LastResponseInfo`, `ResponseMetadata`, `WithResponseMetadata`, `AmigoResponse`, `RetryOptions`, `RateLimitInfo`, `ClientHooks`, `RequestHookContext`, `ResponseHookContext`, `ErrorHookContext`
|
|
57
57
|
- Generated OpenAPI types: `paths`, `components`, `operations`
|
|
58
58
|
- Generated API types are produced with `npm run gen-types` from the committed `openapi.json` snapshot.
|
|
@@ -241,6 +241,7 @@ All workspace-scoped resources also expose `withOptions(options)`.
|
|
|
241
241
|
- `createTurn`
|
|
242
242
|
- `createTurnStream`
|
|
243
243
|
- `textStreamUrl`
|
|
244
|
+
- `sessionConnectUrl`
|
|
244
245
|
|
|
245
246
|
### `phoneNumbers`
|
|
246
247
|
|
package/dist/index.cjs
CHANGED
|
@@ -82,6 +82,7 @@ __export(index_exports, {
|
|
|
82
82
|
personaId: () => personaId,
|
|
83
83
|
phoneNumberId: () => phoneNumberId,
|
|
84
84
|
serviceId: () => serviceId,
|
|
85
|
+
sessionConnectAuthProtocols: () => sessionConnectAuthProtocols,
|
|
85
86
|
simulationRunId: () => simulationRunId,
|
|
86
87
|
simulationSessionId: () => simulationSessionId,
|
|
87
88
|
skillId: () => skillId,
|
|
@@ -1978,11 +1979,22 @@ var ConversationsResource = class extends WorkspaceScopedResource {
|
|
|
1978
1979
|
}
|
|
1979
1980
|
});
|
|
1980
1981
|
}
|
|
1981
|
-
|
|
1982
|
+
/**
|
|
1983
|
+
* Send a user message and receive the agent's synchronous JSON response.
|
|
1984
|
+
*
|
|
1985
|
+
* Pass `options.includeToolCalls: true` to request tool-call metadata
|
|
1986
|
+
* alongside the response turns. Server-side default is `false` — without
|
|
1987
|
+
* this opt-in the `tool_calls` array on the `TurnResponse` will be empty
|
|
1988
|
+
* even when the agent invoked tools during the turn.
|
|
1989
|
+
*/
|
|
1990
|
+
async createTurn(conversationId, request, options) {
|
|
1982
1991
|
return extractData(
|
|
1983
1992
|
await this.client.POST("/v1/{workspace_id}/conversations/{conversation_id}/turns", {
|
|
1984
1993
|
params: {
|
|
1985
|
-
path: { workspace_id: this.workspaceId, conversation_id: conversationId }
|
|
1994
|
+
path: { workspace_id: this.workspaceId, conversation_id: conversationId },
|
|
1995
|
+
...options?.includeToolCalls !== void 0 && {
|
|
1996
|
+
query: { include_tool_calls: options.includeToolCalls }
|
|
1997
|
+
}
|
|
1986
1998
|
},
|
|
1987
1999
|
body: request,
|
|
1988
2000
|
headers: { Accept: "application/json" }
|
|
@@ -2034,6 +2046,32 @@ var ConversationsResource = class extends WorkspaceScopedResource {
|
|
|
2034
2046
|
});
|
|
2035
2047
|
return url.toString();
|
|
2036
2048
|
}
|
|
2049
|
+
/**
|
|
2050
|
+
* Build the URL for the workspace-scoped session-connect WebSocket
|
|
2051
|
+
* (``WS /v1/{workspace_id}/sessions/connect``).
|
|
2052
|
+
*
|
|
2053
|
+
* Pair the returned URL with {@link sessionConnectAuthProtocols} so the
|
|
2054
|
+
* bearer token is delivered via the ``Sec-WebSocket-Protocol`` header — the
|
|
2055
|
+
* endpoint rejects query-param tokens to keep credentials out of URLs.
|
|
2056
|
+
*
|
|
2057
|
+
* @example
|
|
2058
|
+
* ```ts
|
|
2059
|
+
* const url = client.conversations.sessionConnectUrl({
|
|
2060
|
+
* serviceId: SERVICE_ID,
|
|
2061
|
+
* entityId: ENTITY_ID,
|
|
2062
|
+
* conversationId: existingConversationId, // optional resume
|
|
2063
|
+
* });
|
|
2064
|
+
* const ws = new WebSocket(url, sessionConnectAuthProtocols(apiKey));
|
|
2065
|
+
* ```
|
|
2066
|
+
*/
|
|
2067
|
+
sessionConnectUrl(params) {
|
|
2068
|
+
const url = buildSessionConnectUrl({
|
|
2069
|
+
baseUrl: this.platformBaseUrl,
|
|
2070
|
+
workspaceId: this.workspaceId,
|
|
2071
|
+
...params
|
|
2072
|
+
});
|
|
2073
|
+
return url.toString();
|
|
2074
|
+
}
|
|
2037
2075
|
};
|
|
2038
2076
|
function textStreamAuthProtocols(apiKey) {
|
|
2039
2077
|
const token = validateTextStreamAuthToken(apiKey, "apiKey");
|
|
@@ -2045,6 +2083,9 @@ function textStreamAuthProtocols(apiKey) {
|
|
|
2045
2083
|
}
|
|
2046
2084
|
return ["auth", token];
|
|
2047
2085
|
}
|
|
2086
|
+
function sessionConnectAuthProtocols(apiKey) {
|
|
2087
|
+
return textStreamAuthProtocols(apiKey);
|
|
2088
|
+
}
|
|
2048
2089
|
function buildTextStreamUrl({
|
|
2049
2090
|
baseUrl,
|
|
2050
2091
|
workspaceId: workspaceId2,
|
|
@@ -2120,6 +2161,66 @@ function deriveTextStreamUrl(baseUrl) {
|
|
|
2120
2161
|
url.hash = "";
|
|
2121
2162
|
return url;
|
|
2122
2163
|
}
|
|
2164
|
+
function buildSessionConnectUrl({
|
|
2165
|
+
baseUrl,
|
|
2166
|
+
workspaceId: workspaceId2,
|
|
2167
|
+
serviceId: serviceId2,
|
|
2168
|
+
entityId: entityId2,
|
|
2169
|
+
conversationId,
|
|
2170
|
+
toolEvents,
|
|
2171
|
+
sessionConnectUrl: sessionConnectUrlOverride
|
|
2172
|
+
}) {
|
|
2173
|
+
const url = sessionConnectUrlOverride ? parseSessionConnectUrlOverride(sessionConnectUrlOverride) : deriveSessionConnectUrl(baseUrl, workspaceId2);
|
|
2174
|
+
url.searchParams.set("service_id", serviceId2);
|
|
2175
|
+
url.searchParams.set("entity_id", entityId2);
|
|
2176
|
+
if (conversationId) url.searchParams.set("conversation_id", conversationId);
|
|
2177
|
+
if (toolEvents === false) url.searchParams.set("tool_events", "false");
|
|
2178
|
+
return url;
|
|
2179
|
+
}
|
|
2180
|
+
function parseSessionConnectUrlOverride(sessionConnectUrl) {
|
|
2181
|
+
try {
|
|
2182
|
+
const url = new URL(sessionConnectUrl);
|
|
2183
|
+
if (url.protocol !== "ws:" && url.protocol !== "wss:") {
|
|
2184
|
+
throw new ConfigurationError("sessionConnectUrl overrides must use ws: or wss: URLs");
|
|
2185
|
+
}
|
|
2186
|
+
if (url.search || url.hash) {
|
|
2187
|
+
throw new ConfigurationError(
|
|
2188
|
+
"sessionConnectUrl overrides must not include query parameters or fragments; pass SDK-managed fields through sessionConnectUrl() options"
|
|
2189
|
+
);
|
|
2190
|
+
}
|
|
2191
|
+
return url;
|
|
2192
|
+
} catch (cause) {
|
|
2193
|
+
if (cause instanceof ConfigurationError) throw cause;
|
|
2194
|
+
throw new ConfigurationError(
|
|
2195
|
+
`sessionConnectUrl must be an absolute URL for session-connect overrides: ${String(cause)}`
|
|
2196
|
+
);
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
function deriveSessionConnectUrl(baseUrl, workspaceId2) {
|
|
2200
|
+
if (!/^[a-z][a-z\d+.-]*:\/\//i.test(baseUrl)) {
|
|
2201
|
+
throw new ConfigurationError(
|
|
2202
|
+
"sessionConnectUrl cannot be derived from a relative baseUrl; pass sessionConnectUrl explicitly"
|
|
2203
|
+
);
|
|
2204
|
+
}
|
|
2205
|
+
const url = new URL(baseUrl);
|
|
2206
|
+
if (url.protocol === "ws:" || url.protocol === "wss:") {
|
|
2207
|
+
} else if (url.protocol === "http:" || url.protocol === "https:") {
|
|
2208
|
+
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
2209
|
+
} else {
|
|
2210
|
+
throw new ConfigurationError(
|
|
2211
|
+
"sessionConnectUrl can only be derived from an http, https, ws, or wss baseUrl; pass sessionConnectUrl explicitly"
|
|
2212
|
+
);
|
|
2213
|
+
}
|
|
2214
|
+
if (url.pathname !== "/" && url.pathname !== "") {
|
|
2215
|
+
throw new ConfigurationError(
|
|
2216
|
+
"sessionConnectUrl can only be derived from an origin-only baseUrl; pass sessionConnectUrl explicitly when using path-prefixed gateways"
|
|
2217
|
+
);
|
|
2218
|
+
}
|
|
2219
|
+
url.pathname = `/v1/${workspaceId2}/sessions/connect`;
|
|
2220
|
+
url.search = "";
|
|
2221
|
+
url.hash = "";
|
|
2222
|
+
return url;
|
|
2223
|
+
}
|
|
2123
2224
|
function describeInvalidSubprotocolChars(token) {
|
|
2124
2225
|
const chars = /* @__PURE__ */ new Set();
|
|
2125
2226
|
for (const char of token) {
|