phonic 0.32.20 → 0.32.22
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/cjs/BaseClient.js +2 -2
- package/dist/cjs/Client.d.ts +3 -0
- package/dist/cjs/Client.js +13 -8
- package/dist/cjs/api/errors/BadGatewayError.d.ts +6 -0
- package/dist/cjs/api/errors/BadGatewayError.js +54 -0
- package/dist/cjs/api/errors/index.d.ts +1 -0
- package/dist/cjs/api/errors/index.js +1 -0
- package/dist/cjs/api/resources/agents/client/requests/AgentsCreateRequest.d.ts +2 -0
- package/dist/cjs/api/resources/agents/client/requests/UpdateAgentRequest.d.ts +2 -0
- package/dist/cjs/api/resources/conversations/client/Client.d.ts +3 -0
- package/dist/cjs/api/resources/conversations/client/Client.js +9 -0
- package/dist/cjs/api/resources/index.d.ts +2 -0
- package/dist/cjs/api/resources/index.js +3 -1
- package/dist/cjs/api/resources/responses/client/Client.d.ts +72 -0
- package/dist/cjs/api/resources/responses/client/Client.js +169 -0
- package/dist/cjs/api/resources/responses/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/responses/client/index.js +17 -0
- package/dist/cjs/api/resources/responses/client/requests/GenerateResponsesRequest.d.ts +46 -0
- package/dist/cjs/api/resources/responses/client/requests/GenerateResponsesRequest.js +3 -0
- package/dist/cjs/api/resources/responses/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/responses/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/responses/exports.d.ts +2 -0
- package/dist/cjs/api/resources/responses/exports.js +21 -0
- package/dist/cjs/api/resources/responses/index.d.ts +1 -0
- package/dist/cjs/api/resources/responses/index.js +17 -0
- package/dist/cjs/api/resources/tools/client/requests/CreateToolRequest.d.ts +3 -1
- package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.d.ts +3 -1
- package/dist/cjs/api/types/Agent.d.ts +2 -0
- package/dist/cjs/api/types/ConfigOptions.d.ts +2 -0
- package/dist/cjs/api/types/ConflictErrorBody.d.ts +2 -0
- package/dist/cjs/api/types/ConflictErrorBody.js +3 -0
- package/dist/cjs/api/types/Conversation.d.ts +2 -0
- package/dist/cjs/api/types/CreateAgentRequest.d.ts +2 -0
- package/dist/cjs/api/types/GenerateResponsesResponse.d.ts +5 -0
- package/dist/cjs/api/types/GenerateResponsesResponse.js +3 -0
- package/dist/cjs/api/types/GeneratedResponse.d.ts +7 -0
- package/dist/cjs/api/types/GeneratedResponse.js +3 -0
- package/dist/cjs/api/types/GeneratedToolCall.d.ts +10 -0
- package/dist/cjs/api/types/GeneratedToolCall.js +3 -0
- package/dist/cjs/api/types/OutboundCallConfig.d.ts +2 -0
- package/dist/cjs/api/types/ResponsesAssistantMessage.d.ts +11 -0
- package/dist/cjs/api/types/ResponsesAssistantMessage.js +3 -0
- package/dist/cjs/api/types/ResponsesInputItem.d.ts +5 -0
- package/dist/cjs/api/types/ResponsesInputItem.js +3 -0
- package/dist/cjs/api/types/ResponsesToolCall.d.ts +13 -0
- package/dist/cjs/api/types/ResponsesToolCall.js +3 -0
- package/dist/cjs/api/types/ResponsesToolCallOutput.d.ts +24 -0
- package/dist/cjs/api/types/ResponsesToolCallOutput.js +3 -0
- package/dist/cjs/api/types/ResponsesToolDefinition.d.ts +11 -0
- package/dist/cjs/api/types/ResponsesToolDefinition.js +3 -0
- package/dist/cjs/api/types/ResponsesUserMessage.d.ts +8 -0
- package/dist/cjs/api/types/ResponsesUserMessage.js +3 -0
- package/dist/cjs/api/types/Tool.d.ts +3 -1
- package/dist/cjs/api/types/index.d.ts +10 -0
- package/dist/cjs/api/types/index.js +10 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/Client.d.mts +3 -0
- package/dist/esm/Client.mjs +5 -0
- package/dist/esm/api/errors/BadGatewayError.d.mts +6 -0
- package/dist/esm/api/errors/BadGatewayError.mjs +17 -0
- package/dist/esm/api/errors/index.d.mts +1 -0
- package/dist/esm/api/errors/index.mjs +1 -0
- package/dist/esm/api/resources/agents/client/requests/AgentsCreateRequest.d.mts +2 -0
- package/dist/esm/api/resources/agents/client/requests/UpdateAgentRequest.d.mts +2 -0
- package/dist/esm/api/resources/conversations/client/Client.d.mts +3 -0
- package/dist/esm/api/resources/conversations/client/Client.mjs +9 -0
- package/dist/esm/api/resources/index.d.mts +2 -0
- package/dist/esm/api/resources/index.mjs +2 -0
- package/dist/esm/api/resources/responses/client/Client.d.mts +72 -0
- package/dist/esm/api/resources/responses/client/Client.mjs +132 -0
- package/dist/esm/api/resources/responses/client/index.d.mts +1 -0
- package/dist/esm/api/resources/responses/client/index.mjs +1 -0
- package/dist/esm/api/resources/responses/client/requests/GenerateResponsesRequest.d.mts +46 -0
- package/dist/esm/api/resources/responses/client/requests/GenerateResponsesRequest.mjs +2 -0
- package/dist/esm/api/resources/responses/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/responses/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/responses/exports.d.mts +2 -0
- package/dist/esm/api/resources/responses/exports.mjs +3 -0
- package/dist/esm/api/resources/responses/index.d.mts +1 -0
- package/dist/esm/api/resources/responses/index.mjs +1 -0
- package/dist/esm/api/resources/tools/client/requests/CreateToolRequest.d.mts +3 -1
- package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.d.mts +3 -1
- package/dist/esm/api/types/Agent.d.mts +2 -0
- package/dist/esm/api/types/ConfigOptions.d.mts +2 -0
- package/dist/esm/api/types/ConflictErrorBody.d.mts +2 -0
- package/dist/esm/api/types/ConflictErrorBody.mjs +2 -0
- package/dist/esm/api/types/Conversation.d.mts +2 -0
- package/dist/esm/api/types/CreateAgentRequest.d.mts +2 -0
- package/dist/esm/api/types/GenerateResponsesResponse.d.mts +5 -0
- package/dist/esm/api/types/GenerateResponsesResponse.mjs +2 -0
- package/dist/esm/api/types/GeneratedResponse.d.mts +7 -0
- package/dist/esm/api/types/GeneratedResponse.mjs +2 -0
- package/dist/esm/api/types/GeneratedToolCall.d.mts +10 -0
- package/dist/esm/api/types/GeneratedToolCall.mjs +2 -0
- package/dist/esm/api/types/OutboundCallConfig.d.mts +2 -0
- package/dist/esm/api/types/ResponsesAssistantMessage.d.mts +11 -0
- package/dist/esm/api/types/ResponsesAssistantMessage.mjs +2 -0
- package/dist/esm/api/types/ResponsesInputItem.d.mts +5 -0
- package/dist/esm/api/types/ResponsesInputItem.mjs +2 -0
- package/dist/esm/api/types/ResponsesToolCall.d.mts +13 -0
- package/dist/esm/api/types/ResponsesToolCall.mjs +2 -0
- package/dist/esm/api/types/ResponsesToolCallOutput.d.mts +24 -0
- package/dist/esm/api/types/ResponsesToolCallOutput.mjs +2 -0
- package/dist/esm/api/types/ResponsesToolDefinition.d.mts +11 -0
- package/dist/esm/api/types/ResponsesToolDefinition.mjs +2 -0
- package/dist/esm/api/types/ResponsesUserMessage.d.mts +8 -0
- package/dist/esm/api/types/ResponsesUserMessage.mjs +2 -0
- package/dist/esm/api/types/Tool.d.mts +3 -1
- package/dist/esm/api/types/index.d.mts +10 -0
- package/dist/esm/api/types/index.mjs +10 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +12 -1
- package/reference.md +104 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
12
|
+
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
13
|
+
import * as core from "../../../../core/index.mjs";
|
|
14
|
+
import * as environments from "../../../../environments.mjs";
|
|
15
|
+
import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
|
|
16
|
+
import * as errors from "../../../../errors/index.mjs";
|
|
17
|
+
import * as Phonic from "../../../index.mjs";
|
|
18
|
+
export class ResponsesClient {
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generates one or more alternative assistant responses for a conversation
|
|
24
|
+
* you supply inline to simulate Phonic agent behavior.
|
|
25
|
+
*
|
|
26
|
+
* This endpoint is stateless, so it does not create a new conversation or
|
|
27
|
+
* store anything. The request carries the system prompt, a conversation so
|
|
28
|
+
* far as `input`, and the tools the assistant may call as
|
|
29
|
+
* `tool_definitions`.
|
|
30
|
+
*
|
|
31
|
+
* Each item in `input` is a user message, an assistant message (with
|
|
32
|
+
* optional `tool_calls`), or a `tool_call_output`. Every assistant tool
|
|
33
|
+
* call must be followed immediately by the `tool_call_output` item that
|
|
34
|
+
* carries its result.
|
|
35
|
+
*
|
|
36
|
+
* This is an experimental feature and must be enabled for your workspace;
|
|
37
|
+
* otherwise, it returns `404`. Please contact our team if you would like
|
|
38
|
+
* access.
|
|
39
|
+
*
|
|
40
|
+
* @param {Phonic.GenerateResponsesRequest} request
|
|
41
|
+
* @param {ResponsesClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
42
|
+
*
|
|
43
|
+
* @throws {@link Phonic.BadRequestError}
|
|
44
|
+
* @throws {@link Phonic.UnauthorizedError}
|
|
45
|
+
* @throws {@link Phonic.NotFoundError}
|
|
46
|
+
* @throws {@link Phonic.TooManyRequestsError}
|
|
47
|
+
* @throws {@link Phonic.InternalServerError}
|
|
48
|
+
* @throws {@link Phonic.BadGatewayError}
|
|
49
|
+
* @throws {@link Phonic.ServiceUnavailableError}
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* await client.responses.create({
|
|
53
|
+
* system_prompt: "You help callers find a pizza shop. Be friendly and concise.",
|
|
54
|
+
* voice_id: "sabrina",
|
|
55
|
+
* default_language: "en",
|
|
56
|
+
* additional_languages: ["es"],
|
|
57
|
+
* input: [{
|
|
58
|
+
* role: "user",
|
|
59
|
+
* text: "Where should I get pizza near Union Square?"
|
|
60
|
+
* }],
|
|
61
|
+
* tool_definitions: [{
|
|
62
|
+
* name: "search_pizza_shop_recs",
|
|
63
|
+
* description: "Search for pizza shop recommendations.",
|
|
64
|
+
* parameters: {
|
|
65
|
+
* type: "object",
|
|
66
|
+
* properties: {
|
|
67
|
+
* "location": {
|
|
68
|
+
* "type": "string",
|
|
69
|
+
* "description": "The neighborhood to search in."
|
|
70
|
+
* }
|
|
71
|
+
* },
|
|
72
|
+
* required: ["location"],
|
|
73
|
+
* additionalProperties: false
|
|
74
|
+
* }
|
|
75
|
+
* }],
|
|
76
|
+
* num_responses: 2
|
|
77
|
+
* })
|
|
78
|
+
*/
|
|
79
|
+
create(request, requestOptions) {
|
|
80
|
+
return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
|
|
81
|
+
}
|
|
82
|
+
__create(request, requestOptions) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
85
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
86
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
87
|
+
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
88
|
+
url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
|
|
89
|
+
.base, "responses"),
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: _headers,
|
|
92
|
+
contentType: "application/json",
|
|
93
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
94
|
+
requestType: "json",
|
|
95
|
+
body: request,
|
|
96
|
+
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
|
|
97
|
+
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
|
|
98
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
99
|
+
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
|
|
100
|
+
logging: this._options.logging,
|
|
101
|
+
});
|
|
102
|
+
if (_response.ok) {
|
|
103
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
104
|
+
}
|
|
105
|
+
if (_response.error.reason === "status-code") {
|
|
106
|
+
switch (_response.error.statusCode) {
|
|
107
|
+
case 400:
|
|
108
|
+
throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
|
|
109
|
+
case 401:
|
|
110
|
+
throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
111
|
+
case 404:
|
|
112
|
+
throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
|
|
113
|
+
case 429:
|
|
114
|
+
throw new Phonic.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
115
|
+
case 500:
|
|
116
|
+
throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
|
|
117
|
+
case 502:
|
|
118
|
+
throw new Phonic.BadGatewayError(_response.error.body, _response.rawResponse);
|
|
119
|
+
case 503:
|
|
120
|
+
throw new Phonic.ServiceUnavailableError(_response.error.body, _response.rawResponse);
|
|
121
|
+
default:
|
|
122
|
+
throw new errors.PhonicError({
|
|
123
|
+
statusCode: _response.error.statusCode,
|
|
124
|
+
body: _response.error.body,
|
|
125
|
+
rawResponse: _response.rawResponse,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/responses");
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.mjs";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type * as Phonic from "../../../../index.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* @example
|
|
4
|
+
* {
|
|
5
|
+
* system_prompt: "You help callers find a pizza shop. Be friendly and concise.",
|
|
6
|
+
* voice_id: "sabrina",
|
|
7
|
+
* default_language: "en",
|
|
8
|
+
* additional_languages: ["es"],
|
|
9
|
+
* input: [{
|
|
10
|
+
* role: "user",
|
|
11
|
+
* text: "Where should I get pizza near Union Square?"
|
|
12
|
+
* }],
|
|
13
|
+
* tool_definitions: [{
|
|
14
|
+
* name: "search_pizza_shop_recs",
|
|
15
|
+
* description: "Search for pizza shop recommendations.",
|
|
16
|
+
* parameters: {
|
|
17
|
+
* type: "object",
|
|
18
|
+
* properties: {
|
|
19
|
+
* "location": {
|
|
20
|
+
* "type": "string",
|
|
21
|
+
* "description": "The neighborhood to search in."
|
|
22
|
+
* }
|
|
23
|
+
* },
|
|
24
|
+
* required: ["location"],
|
|
25
|
+
* additionalProperties: false
|
|
26
|
+
* }
|
|
27
|
+
* }],
|
|
28
|
+
* num_responses: 2
|
|
29
|
+
* }
|
|
30
|
+
*/
|
|
31
|
+
export interface GenerateResponsesRequest {
|
|
32
|
+
/** The system prompt the assistant should follow. */
|
|
33
|
+
system_prompt: string;
|
|
34
|
+
/** ID of the voice the assistant would speak with. It shapes how the responses are worded. */
|
|
35
|
+
voice_id?: string;
|
|
36
|
+
/** ISO 639-1 language code that sets the assistant's default language to recognize and speak. */
|
|
37
|
+
default_language?: Phonic.LanguageCode;
|
|
38
|
+
/** Array of additional ISO 639-1 language codes that the assistant should be able to recognize and speak. Should not include `default_language`. */
|
|
39
|
+
additional_languages?: Phonic.LanguageCode[];
|
|
40
|
+
/** The conversation so far, in order. Must contain at least one item. */
|
|
41
|
+
input: Phonic.ResponsesInputItem[];
|
|
42
|
+
/** The tools the assistant may call, defined inline. Names must be unique and cannot be one of the names Phonic reserves for its built-in tools. */
|
|
43
|
+
tool_definitions?: Phonic.ResponsesToolDefinition[];
|
|
44
|
+
/** Number of alternative responses to generate. */
|
|
45
|
+
num_responses?: number;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { GenerateResponsesRequest } from "./GenerateResponsesRequest.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./client/index.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./client/index.mjs";
|
|
@@ -205,13 +205,15 @@ export interface CreateToolRequest {
|
|
|
205
205
|
phone_number?: string | null;
|
|
206
206
|
/** DTMF digits to send after the transfer connects (e.g., "1234"). Defaults to null. Ignored when dynamic_dtmf is true. */
|
|
207
207
|
dtmf?: string | null;
|
|
208
|
+
/** Fixed line the agent speaks into the bridged call once the transfer connects. Defaults to null, meaning no announcement. Must be null when keep_listening is false, since a SIP REFER transfer has no bridged call to speak it on. Only available for built_in_transfer_to_phone_number tools. */
|
|
209
|
+
post_transfer_message?: string | null;
|
|
208
210
|
/** When true, the agent determines the DTMF digits at call time (and may choose to send none); the static dtmf is ignored. Only sent when use_agent_phone_number is true (not on a SIP REFER transfer). */
|
|
209
211
|
dynamic_dtmf?: boolean;
|
|
210
212
|
/** When true, Phonic will transfer the call using the agent's phone number. When false, Phonic will transfer the call using the phone number of the party to whom the agent is connected. This is only available for built_in_transfer_to_phone_number tools. */
|
|
211
213
|
use_agent_phone_number?: boolean;
|
|
212
214
|
/** When true, Phonic will listen in and tell the user if the transfer hits voicemail. This is only available for built_in_transfer_to_phone_number tools when use_agent_phone_number is true. */
|
|
213
215
|
detect_voicemail?: boolean;
|
|
214
|
-
/** When true, Phonic bridges the transfer and stays on the call. When false, the call is handed off with a SIP REFER and Phonic drops out, which requires use_agent_phone_number and detect_voicemail to be false, dtmf to be null and dynamic_dtmf to be false. Only available for built_in_transfer_to_phone_number tools. Defaults to the value of use_agent_phone_number. */
|
|
216
|
+
/** When true, Phonic bridges the transfer and stays on the call. When false, the call is handed off with a SIP REFER and Phonic drops out, which requires use_agent_phone_number and detect_voicemail to be false, dtmf and post_transfer_message to be null and dynamic_dtmf to be false. Only available for built_in_transfer_to_phone_number tools. Defaults to the value of use_agent_phone_number. */
|
|
215
217
|
keep_listening?: boolean;
|
|
216
218
|
/** Array of agent names that the LLM can choose from when transferring. Required for built_in_transfer_to_agent tools. All agents must exist in the same project as the tool. */
|
|
217
219
|
agents_to_transfer_to?: string[];
|
|
@@ -45,13 +45,15 @@ export interface UpdateToolRequest {
|
|
|
45
45
|
phone_number?: string | null;
|
|
46
46
|
/** DTMF digits to send after the transfer connects (e.g., "1234"). Can be set to null to remove DTMF. Ignored when dynamic_dtmf is true. */
|
|
47
47
|
dtmf?: string | null;
|
|
48
|
+
/** Fixed line the agent speaks into the bridged call once the transfer connects. Can be set to null to remove the announcement. Must be null when the resulting keep_listening is false. Only applicable to built_in_transfer_to_phone_number tools. */
|
|
49
|
+
post_transfer_message?: string | null;
|
|
48
50
|
/** When true, the agent determines the DTMF digits at call time (and may choose to send none); the static dtmf is ignored. Only sent when use_agent_phone_number is true (not on a SIP REFER transfer). */
|
|
49
51
|
dynamic_dtmf?: boolean;
|
|
50
52
|
/** When true, Phonic will transfer the call using the agent's phone number. When false, Phonic will transfer the call using the phone number of the party to whom the agent is connected. This is only available for built_in_transfer_to_phone_number tools. */
|
|
51
53
|
use_agent_phone_number?: boolean;
|
|
52
54
|
/** When true, Phonic will listen in and tell the user if the transfer hits voicemail. This is only available for built_in_transfer_to_phone_number tools when use_agent_phone_number is true. */
|
|
53
55
|
detect_voicemail?: boolean;
|
|
54
|
-
/** When true, Phonic bridges the transfer and stays on the call. When false, the call is handed off with a SIP REFER and Phonic drops out, which requires the resulting use_agent_phone_number and detect_voicemail to be false, dtmf to be null and dynamic_dtmf to be false. Only applicable to built_in_transfer_to_phone_number tools. */
|
|
56
|
+
/** When true, Phonic bridges the transfer and stays on the call. When false, the call is handed off with a SIP REFER and Phonic drops out, which requires the resulting use_agent_phone_number and detect_voicemail to be false, dtmf and post_transfer_message to be null and dynamic_dtmf to be false. Only applicable to built_in_transfer_to_phone_number tools. */
|
|
55
57
|
keep_listening?: boolean;
|
|
56
58
|
/** Array of agent names that the LLM can choose from when transferring. All agents must exist in the same project as the tool. */
|
|
57
59
|
agents_to_transfer_to?: string[];
|
|
@@ -86,6 +86,8 @@ export interface Agent {
|
|
|
86
86
|
vad_threshold?: number | undefined;
|
|
87
87
|
/** When `true`, PII and PHI are redacted from text transcripts (e.g. replaced with tags like `[PHONE]`) and bleeped from audio recordings after the conversation ends. */
|
|
88
88
|
enable_redaction?: boolean | undefined;
|
|
89
|
+
/** When `true`, an inaudible watermark is embedded in the audio the agent generates. */
|
|
90
|
+
enable_watermarking?: boolean | undefined;
|
|
89
91
|
/** The URL-friendly slug of the agent. */
|
|
90
92
|
slug?: string | undefined;
|
|
91
93
|
/** When `true`, the assistant emits backchannel cues (e.g. "mm-hmm") while the user is speaking. */
|
|
@@ -71,6 +71,8 @@ export interface ConfigOptions {
|
|
|
71
71
|
template_variables?: Record<string, string> | undefined;
|
|
72
72
|
/** When `true`, PII and PHI are redacted from text transcripts (e.g. replaced with tags like `[PHONE]`) and bleeped from audio recordings after the conversation ends. */
|
|
73
73
|
enable_redaction?: boolean | undefined;
|
|
74
|
+
/** When `true`, an inaudible watermark is embedded in the audio the assistant generates. */
|
|
75
|
+
enable_watermarking?: boolean | undefined;
|
|
74
76
|
/** Names of pre-configured MCP servers to make available to the assistant. Names must be unique. */
|
|
75
77
|
mcp_servers?: string[] | undefined;
|
|
76
78
|
/** Names of observability integrations to enable for the conversation. Each must be one of the supported providers. */
|
|
@@ -94,6 +94,8 @@ export interface Conversation {
|
|
|
94
94
|
redacted_transcript?: (string | null) | undefined;
|
|
95
95
|
/** Arbitrary metadata associated with the conversation. */
|
|
96
96
|
metadata?: (Record<string, unknown> | null) | undefined;
|
|
97
|
+
/** Whether an inaudible watermark was embedded in the audio the agent generated during the conversation. */
|
|
98
|
+
enable_watermarking?: boolean | undefined;
|
|
97
99
|
/** Controls how long transcripts and audio recordings are retained before deletion. */
|
|
98
100
|
data_retention_policy?: Phonic.DataRetentionPolicy | undefined;
|
|
99
101
|
/** Information about when transcripts and audio recordings are or were scheduled to be deleted. */
|
|
@@ -88,6 +88,8 @@ export interface CreateAgentRequest {
|
|
|
88
88
|
vad_threshold?: number | undefined;
|
|
89
89
|
/** When `true`, PII and PHI are redacted from text transcripts (e.g. replaced with tags like `[PHONE]`) and bleeped from audio recordings after the conversation ends. */
|
|
90
90
|
enable_redaction?: boolean | undefined;
|
|
91
|
+
/** When `true`, an inaudible watermark is embedded in the audio the agent generates. */
|
|
92
|
+
enable_watermarking?: boolean | undefined;
|
|
91
93
|
/** Array of MCP server IDs to make available to the agent. */
|
|
92
94
|
mcp_server_ids?: string[] | undefined;
|
|
93
95
|
/** Names of observability integrations to enable for the agent. Each must be one of the supported providers. */
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as Phonic from "../index.mjs";
|
|
2
|
+
export interface GeneratedResponse {
|
|
3
|
+
/** The text the assistant would say. Empty when the response only makes tool calls. */
|
|
4
|
+
text: string;
|
|
5
|
+
/** Tool calls the assistant would make - note that the tools are not actually called. */
|
|
6
|
+
tool_calls: Phonic.GeneratedToolCall[];
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface GeneratedToolCall {
|
|
2
|
+
/** Identifier for this tool call. Send it back as the `tool_call_id` of the matching `tool_call_output` input item. */
|
|
3
|
+
tool_call_id: string;
|
|
4
|
+
/** Name of the tool to call. Always one of the `tool_definitions` from the request. */
|
|
5
|
+
tool_name: string;
|
|
6
|
+
/** Arguments the assistant produced for the request body. */
|
|
7
|
+
request_body?: Record<string, unknown> | undefined;
|
|
8
|
+
/** Arguments the assistant produced as query parameters. */
|
|
9
|
+
query_params?: Record<string, string> | undefined;
|
|
10
|
+
}
|
|
@@ -49,6 +49,8 @@ export interface OutboundCallConfig {
|
|
|
49
49
|
tools?: OutboundCallConfig.Tools.Item[] | undefined;
|
|
50
50
|
/** When `true`, PII and PHI are redacted from text transcripts (e.g. replaced with tags like `[PHONE]`) and bleeped from audio recordings after the conversation ends. */
|
|
51
51
|
enable_redaction?: boolean | undefined;
|
|
52
|
+
/** When `true`, an inaudible watermark is embedded in the audio the agent generates. */
|
|
53
|
+
enable_watermarking?: boolean | undefined;
|
|
52
54
|
/** The speech-to-speech model to use. */
|
|
53
55
|
model?: "merritt" | undefined;
|
|
54
56
|
/** The audio speed of the agent. */
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as Phonic from "../index.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* An assistant turn. Must carry `text`, `tool_calls`, or both.
|
|
4
|
+
*/
|
|
5
|
+
export interface ResponsesAssistantMessage {
|
|
6
|
+
role: "assistant";
|
|
7
|
+
/** What the assistant said. Empty when the turn only made tool calls. */
|
|
8
|
+
text: string;
|
|
9
|
+
/** Tool calls the assistant made on this turn. Each one must be followed immediately by its matching `tool_call_output` item. */
|
|
10
|
+
tool_calls?: Phonic.ResponsesToolCall[] | undefined;
|
|
11
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type * as Phonic from "../index.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* One item of conversation history - a user message, an assistant message, or the output of an assistant tool call.
|
|
4
|
+
*/
|
|
5
|
+
export type ResponsesInputItem = Phonic.ResponsesUserMessage | Phonic.ResponsesAssistantMessage | Phonic.ResponsesToolCallOutput;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tool call the assistant made earlier in the conversation.
|
|
3
|
+
*/
|
|
4
|
+
export interface ResponsesToolCall {
|
|
5
|
+
/** Identifier for this tool call, unique within `input`. */
|
|
6
|
+
tool_call_id: string;
|
|
7
|
+
/** Name of the called tool. */
|
|
8
|
+
tool_name: string;
|
|
9
|
+
/** Arguments the assistant passed in the request body. */
|
|
10
|
+
request_body?: (Record<string, unknown> | null) | undefined;
|
|
11
|
+
/** Arguments the assistant passed as query parameters. An argument cannot appear in both `request_body` and `query_params`. */
|
|
12
|
+
query_params?: (Record<string, string | null> | null) | undefined;
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The result of an assistant tool call. Must record an outcome through `response_body`, `response_status_code`, `error_message`, `timed_out`, or `interrupted`.
|
|
3
|
+
*/
|
|
4
|
+
export interface ResponsesToolCallOutput {
|
|
5
|
+
type: "tool_call_output";
|
|
6
|
+
/** The `tool_call_id` of the assistant tool call this output belongs to. */
|
|
7
|
+
tool_call_id: string;
|
|
8
|
+
/** The value the tool returned. Can be any JSON-serializable value. */
|
|
9
|
+
response_body?: (ResponsesToolCallOutput.ResponseBody | null) | undefined;
|
|
10
|
+
/** HTTP status code the tool returned, for tools called over HTTP. */
|
|
11
|
+
response_status_code?: (number | null) | undefined;
|
|
12
|
+
/** Whether the tool call timed out. */
|
|
13
|
+
timed_out?: boolean | undefined;
|
|
14
|
+
/** The error the tool call failed with. */
|
|
15
|
+
error_message?: (string | null) | undefined;
|
|
16
|
+
/** Whether the tool call was interrupted before it finished. */
|
|
17
|
+
interrupted?: boolean | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare namespace ResponsesToolCallOutput {
|
|
20
|
+
/**
|
|
21
|
+
* The value the tool returned. Can be any JSON-serializable value.
|
|
22
|
+
*/
|
|
23
|
+
type ResponseBody = Record<string, unknown> | unknown[] | string | number | boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as Phonic from "../index.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* A tool the assistant may call, defined inline for this request only.
|
|
4
|
+
*/
|
|
5
|
+
export interface ResponsesToolDefinition {
|
|
6
|
+
/** The tool name. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** What the tool does. The model uses this to decide when to call it. */
|
|
9
|
+
description: string;
|
|
10
|
+
parameters: Phonic.ToolParametersJsonSchema;
|
|
11
|
+
}
|
|
@@ -36,13 +36,15 @@ export interface Tool {
|
|
|
36
36
|
phone_number?: (string | null) | undefined;
|
|
37
37
|
/** DTMF digits to send after the transfer connects (e.g., "1234"). Defaults to null. Ignored when dynamic_dtmf is true. */
|
|
38
38
|
dtmf?: (string | null) | undefined;
|
|
39
|
+
/** Fixed line the agent speaks into the bridged call once the transfer connects. Defaults to null, meaning no announcement. Always null when keep_listening is false. Only returned for built_in_transfer_to_phone_number tools. */
|
|
40
|
+
post_transfer_message?: (string | null) | undefined;
|
|
39
41
|
/** When true, the agent determines the DTMF digits at call time (and may choose to send none); the static dtmf is ignored. Only sent when use_agent_phone_number is true (not on a SIP REFER transfer). */
|
|
40
42
|
dynamic_dtmf?: boolean | undefined;
|
|
41
43
|
/** When true, Phonic will transfer the call using the agent's phone number. When false, Phonic will transfer the call using the phone number of the party to whom the agent is connected. This is only available for built_in_transfer_to_phone_number tools. */
|
|
42
44
|
use_agent_phone_number?: boolean | undefined;
|
|
43
45
|
/** When true, Phonic will listen in and tell the user if the transfer hits voicemail. This is only available for built_in_transfer_to_phone_number tools when use_agent_phone_number is true. */
|
|
44
46
|
detect_voicemail?: boolean | undefined;
|
|
45
|
-
/** When true, Phonic bridges the transfer and stays on the call. When false, the call is handed off with a SIP REFER and Phonic drops out, so use_agent_phone_number, detect_voicemail and dynamic_dtmf are false and dtmf
|
|
47
|
+
/** When true, Phonic bridges the transfer and stays on the call. When false, the call is handed off with a SIP REFER and Phonic drops out, so use_agent_phone_number, detect_voicemail and dynamic_dtmf are false and dtmf and post_transfer_message are null. Only returned for built_in_transfer_to_phone_number tools. */
|
|
46
48
|
keep_listening?: boolean | undefined;
|
|
47
49
|
/** Array of agent names that the LLM can choose from when transferring. Required for built_in_transfer_to_agent tools. */
|
|
48
50
|
agents_to_transfer_to?: string[] | undefined;
|
|
@@ -16,6 +16,7 @@ export * from "./BuiltInToolDefinition.mjs";
|
|
|
16
16
|
export * from "./ChooseNotToRespondToolConfig.mjs";
|
|
17
17
|
export * from "./ConfigOptions.mjs";
|
|
18
18
|
export * from "./ConfigPayload.mjs";
|
|
19
|
+
export * from "./ConflictErrorBody.mjs";
|
|
19
20
|
export * from "./Conversation.mjs";
|
|
20
21
|
export * from "./ConversationAnalysis.mjs";
|
|
21
22
|
export * from "./ConversationCreatedPayload.mjs";
|
|
@@ -37,7 +38,10 @@ export * from "./ErrorPayload.mjs";
|
|
|
37
38
|
export * from "./ExternalStoragePolicy.mjs";
|
|
38
39
|
export * from "./ExtractionField.mjs";
|
|
39
40
|
export * from "./ExtractionSchema.mjs";
|
|
41
|
+
export * from "./GeneratedResponse.mjs";
|
|
42
|
+
export * from "./GeneratedToolCall.mjs";
|
|
40
43
|
export * from "./GenerateReplyPayload.mjs";
|
|
44
|
+
export * from "./GenerateResponsesResponse.mjs";
|
|
41
45
|
export * from "./InlineWebSocketTool.mjs";
|
|
42
46
|
export * from "./InputCancelledPayload.mjs";
|
|
43
47
|
export * from "./InputTextPayload.mjs";
|
|
@@ -55,6 +59,12 @@ export * from "./ReadyToStartConversationPayload.mjs";
|
|
|
55
59
|
export * from "./ReplayConversationItemResponse.mjs";
|
|
56
60
|
export * from "./ReplayToolCall.mjs";
|
|
57
61
|
export * from "./ResetPayload.mjs";
|
|
62
|
+
export * from "./ResponsesAssistantMessage.mjs";
|
|
63
|
+
export * from "./ResponsesInputItem.mjs";
|
|
64
|
+
export * from "./ResponsesToolCall.mjs";
|
|
65
|
+
export * from "./ResponsesToolCallOutput.mjs";
|
|
66
|
+
export * from "./ResponsesToolDefinition.mjs";
|
|
67
|
+
export * from "./ResponsesUserMessage.mjs";
|
|
58
68
|
export * from "./SayPayload.mjs";
|
|
59
69
|
export * from "./SetExternalIdPayload.mjs";
|
|
60
70
|
export * from "./SipCallError.mjs";
|
|
@@ -16,6 +16,7 @@ export * from "./BuiltInToolDefinition.mjs";
|
|
|
16
16
|
export * from "./ChooseNotToRespondToolConfig.mjs";
|
|
17
17
|
export * from "./ConfigOptions.mjs";
|
|
18
18
|
export * from "./ConfigPayload.mjs";
|
|
19
|
+
export * from "./ConflictErrorBody.mjs";
|
|
19
20
|
export * from "./Conversation.mjs";
|
|
20
21
|
export * from "./ConversationAnalysis.mjs";
|
|
21
22
|
export * from "./ConversationCreatedPayload.mjs";
|
|
@@ -37,7 +38,10 @@ export * from "./ErrorPayload.mjs";
|
|
|
37
38
|
export * from "./ExternalStoragePolicy.mjs";
|
|
38
39
|
export * from "./ExtractionField.mjs";
|
|
39
40
|
export * from "./ExtractionSchema.mjs";
|
|
41
|
+
export * from "./GeneratedResponse.mjs";
|
|
42
|
+
export * from "./GeneratedToolCall.mjs";
|
|
40
43
|
export * from "./GenerateReplyPayload.mjs";
|
|
44
|
+
export * from "./GenerateResponsesResponse.mjs";
|
|
41
45
|
export * from "./InlineWebSocketTool.mjs";
|
|
42
46
|
export * from "./InputCancelledPayload.mjs";
|
|
43
47
|
export * from "./InputTextPayload.mjs";
|
|
@@ -55,6 +59,12 @@ export * from "./ReadyToStartConversationPayload.mjs";
|
|
|
55
59
|
export * from "./ReplayConversationItemResponse.mjs";
|
|
56
60
|
export * from "./ReplayToolCall.mjs";
|
|
57
61
|
export * from "./ResetPayload.mjs";
|
|
62
|
+
export * from "./ResponsesAssistantMessage.mjs";
|
|
63
|
+
export * from "./ResponsesInputItem.mjs";
|
|
64
|
+
export * from "./ResponsesToolCall.mjs";
|
|
65
|
+
export * from "./ResponsesToolCallOutput.mjs";
|
|
66
|
+
export * from "./ResponsesToolDefinition.mjs";
|
|
67
|
+
export * from "./ResponsesUserMessage.mjs";
|
|
58
68
|
export * from "./SayPayload.mjs";
|
|
59
69
|
export * from "./SetExternalIdPayload.mjs";
|
|
60
70
|
export * from "./SipCallError.mjs";
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.32.
|
|
1
|
+
export declare const SDK_VERSION = "0.32.22";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.32.
|
|
1
|
+
export const SDK_VERSION = "0.32.22";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phonic",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.22",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -155,6 +155,17 @@
|
|
|
155
155
|
},
|
|
156
156
|
"default": "./dist/cjs/api/resources/projects/exports.js"
|
|
157
157
|
},
|
|
158
|
+
"./responses": {
|
|
159
|
+
"import": {
|
|
160
|
+
"types": "./dist/esm/api/resources/responses/exports.d.mts",
|
|
161
|
+
"default": "./dist/esm/api/resources/responses/exports.mjs"
|
|
162
|
+
},
|
|
163
|
+
"require": {
|
|
164
|
+
"types": "./dist/cjs/api/resources/responses/exports.d.ts",
|
|
165
|
+
"default": "./dist/cjs/api/resources/responses/exports.js"
|
|
166
|
+
},
|
|
167
|
+
"default": "./dist/cjs/api/resources/responses/exports.js"
|
|
168
|
+
},
|
|
158
169
|
"./package.json": "./package.json"
|
|
159
170
|
},
|
|
160
171
|
"files": [
|