phonic 0.30.20 → 0.30.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/Client.d.ts +3 -0
- package/dist/cjs/Client.js +9 -4
- package/dist/cjs/api/resources/auth/client/Client.d.ts +52 -0
- package/dist/cjs/api/resources/auth/client/Client.js +146 -0
- package/dist/cjs/api/resources/auth/client/index.d.ts +2 -0
- package/dist/cjs/api/resources/auth/client/index.js +17 -0
- package/dist/cjs/api/resources/auth/client/requests/CreateSessionTokenRequest.d.ts +13 -0
- package/dist/cjs/api/resources/auth/client/requests/CreateSessionTokenRequest.js +5 -0
- package/dist/cjs/api/resources/auth/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/auth/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/auth/index.d.ts +2 -0
- package/dist/cjs/api/resources/auth/index.js +18 -0
- package/dist/cjs/api/resources/auth/types/AuthCreateSessionTokenResponse.d.ts +9 -0
- package/dist/cjs/api/resources/auth/types/AuthCreateSessionTokenResponse.js +5 -0
- package/dist/cjs/api/resources/auth/types/index.d.ts +1 -0
- package/dist/cjs/api/resources/auth/types/index.js +17 -0
- package/dist/cjs/api/resources/index.d.ts +3 -0
- package/dist/cjs/api/resources/index.js +4 -1
- package/dist/cjs/api/resources/tools/client/Client.d.ts +2 -0
- package/dist/cjs/api/resources/tools/client/Client.js +2 -0
- package/dist/cjs/api/resources/tools/client/requests/CreateToolRequest.d.ts +4 -0
- package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.d.ts +2 -0
- package/dist/cjs/api/types/Tool.d.ts +2 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.d.mts +3 -0
- package/dist/esm/Client.mjs +7 -2
- package/dist/esm/api/resources/auth/client/Client.d.mts +52 -0
- package/dist/esm/api/resources/auth/client/Client.mjs +109 -0
- package/dist/esm/api/resources/auth/client/index.d.mts +2 -0
- package/dist/esm/api/resources/auth/client/index.mjs +1 -0
- package/dist/esm/api/resources/auth/client/requests/CreateSessionTokenRequest.d.mts +13 -0
- package/dist/esm/api/resources/auth/client/requests/CreateSessionTokenRequest.mjs +4 -0
- package/dist/esm/api/resources/auth/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/auth/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/auth/index.d.mts +2 -0
- package/dist/esm/api/resources/auth/index.mjs +2 -0
- package/dist/esm/api/resources/auth/types/AuthCreateSessionTokenResponse.d.mts +9 -0
- package/dist/esm/api/resources/auth/types/AuthCreateSessionTokenResponse.mjs +4 -0
- package/dist/esm/api/resources/auth/types/index.d.mts +1 -0
- package/dist/esm/api/resources/auth/types/index.mjs +1 -0
- package/dist/esm/api/resources/index.d.mts +3 -0
- package/dist/esm/api/resources/index.mjs +3 -0
- package/dist/esm/api/resources/tools/client/Client.d.mts +2 -0
- package/dist/esm/api/resources/tools/client/Client.mjs +2 -0
- package/dist/esm/api/resources/tools/client/requests/CreateToolRequest.d.mts +4 -0
- package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.d.mts +2 -0
- package/dist/esm/api/types/Tool.d.mts +2 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +67 -0
package/dist/cjs/Client.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Tools } from "./api/resources/tools/client/Client.js";
|
|
|
8
8
|
import { ExtractionSchemas } from "./api/resources/extractionSchemas/client/Client.js";
|
|
9
9
|
import { Voices } from "./api/resources/voices/client/Client.js";
|
|
10
10
|
import { Conversations } from "./api/resources/conversations/client/Client.js";
|
|
11
|
+
import { Auth } from "./api/resources/auth/client/Client.js";
|
|
11
12
|
import { Projects } from "./api/resources/projects/client/Client.js";
|
|
12
13
|
export declare namespace PhonicClient {
|
|
13
14
|
interface Options {
|
|
@@ -39,6 +40,7 @@ export declare class PhonicClient {
|
|
|
39
40
|
protected _extractionSchemas: ExtractionSchemas | undefined;
|
|
40
41
|
protected _voices: Voices | undefined;
|
|
41
42
|
protected _conversations: Conversations | undefined;
|
|
43
|
+
protected _auth: Auth | undefined;
|
|
42
44
|
protected _projects: Projects | undefined;
|
|
43
45
|
constructor(_options?: PhonicClient.Options);
|
|
44
46
|
get agents(): Agents;
|
|
@@ -46,5 +48,6 @@ export declare class PhonicClient {
|
|
|
46
48
|
get extractionSchemas(): ExtractionSchemas;
|
|
47
49
|
get voices(): Voices;
|
|
48
50
|
get conversations(): Conversations;
|
|
51
|
+
get auth(): Auth;
|
|
49
52
|
get projects(): Projects;
|
|
50
53
|
}
|
package/dist/cjs/Client.js
CHANGED
|
@@ -44,14 +44,15 @@ const Client_js_2 = require("./api/resources/tools/client/Client.js");
|
|
|
44
44
|
const Client_js_3 = require("./api/resources/extractionSchemas/client/Client.js");
|
|
45
45
|
const Client_js_4 = require("./api/resources/voices/client/Client.js");
|
|
46
46
|
const Client_js_5 = require("./api/resources/conversations/client/Client.js");
|
|
47
|
-
const Client_js_6 = require("./api/resources/
|
|
47
|
+
const Client_js_6 = require("./api/resources/auth/client/Client.js");
|
|
48
|
+
const Client_js_7 = require("./api/resources/projects/client/Client.js");
|
|
48
49
|
class PhonicClient {
|
|
49
50
|
constructor(_options = {}) {
|
|
50
51
|
this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
|
|
51
52
|
"X-Fern-Language": "JavaScript",
|
|
52
53
|
"X-Fern-SDK-Name": "phonic",
|
|
53
|
-
"X-Fern-SDK-Version": "0.30.
|
|
54
|
-
"User-Agent": "phonic/0.30.
|
|
54
|
+
"X-Fern-SDK-Version": "0.30.22",
|
|
55
|
+
"User-Agent": "phonic/0.30.22",
|
|
55
56
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
56
57
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
57
58
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -76,9 +77,13 @@ class PhonicClient {
|
|
|
76
77
|
var _a;
|
|
77
78
|
return ((_a = this._conversations) !== null && _a !== void 0 ? _a : (this._conversations = new Client_js_5.Conversations(this._options)));
|
|
78
79
|
}
|
|
80
|
+
get auth() {
|
|
81
|
+
var _a;
|
|
82
|
+
return ((_a = this._auth) !== null && _a !== void 0 ? _a : (this._auth = new Client_js_6.Auth(this._options)));
|
|
83
|
+
}
|
|
79
84
|
get projects() {
|
|
80
85
|
var _a;
|
|
81
|
-
return ((_a = this._projects) !== null && _a !== void 0 ? _a : (this._projects = new
|
|
86
|
+
return ((_a = this._projects) !== null && _a !== void 0 ? _a : (this._projects = new Client_js_7.Projects(this._options)));
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
89
|
exports.PhonicClient = PhonicClient;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as environments from "../../../../environments.js";
|
|
5
|
+
import * as core from "../../../../core/index.js";
|
|
6
|
+
import * as Phonic from "../../../index.js";
|
|
7
|
+
export declare namespace Auth {
|
|
8
|
+
interface Options {
|
|
9
|
+
environment?: core.Supplier<environments.PhonicEnvironment | environments.PhonicEnvironmentUrls>;
|
|
10
|
+
/** Specify a custom URL to connect the client to. */
|
|
11
|
+
baseUrl?: core.Supplier<string>;
|
|
12
|
+
apiKey?: core.Supplier<core.BearerToken | undefined>;
|
|
13
|
+
/** Additional headers to include in requests. */
|
|
14
|
+
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
15
|
+
fetcher?: core.FetchFunction;
|
|
16
|
+
}
|
|
17
|
+
interface RequestOptions {
|
|
18
|
+
/** The maximum time to wait for a response in seconds. */
|
|
19
|
+
timeoutInSeconds?: number;
|
|
20
|
+
/** The number of times to retry the request. Defaults to 2. */
|
|
21
|
+
maxRetries?: number;
|
|
22
|
+
/** A hook to abort the request. */
|
|
23
|
+
abortSignal?: AbortSignal;
|
|
24
|
+
/** Additional query string parameters to include in the request. */
|
|
25
|
+
queryParams?: Record<string, unknown>;
|
|
26
|
+
/** Additional headers to include in the request. */
|
|
27
|
+
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export declare class Auth {
|
|
31
|
+
protected readonly _options: Auth.Options;
|
|
32
|
+
constructor(_options?: Auth.Options);
|
|
33
|
+
/**
|
|
34
|
+
* Creates a short-lived session token that can be used to authenticate WebSocket connections. Session tokens are useful for client-side applications where you don't want to expose your API key.
|
|
35
|
+
*
|
|
36
|
+
* @param {Phonic.CreateSessionTokenRequest} request
|
|
37
|
+
* @param {Auth.RequestOptions} requestOptions - Request-specific configuration.
|
|
38
|
+
*
|
|
39
|
+
* @throws {@link Phonic.BadRequestError}
|
|
40
|
+
* @throws {@link Phonic.UnauthorizedError}
|
|
41
|
+
* @throws {@link Phonic.ForbiddenError}
|
|
42
|
+
* @throws {@link Phonic.InternalServerError}
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* await client.auth.createSessionToken({
|
|
46
|
+
* ttl_seconds: 300
|
|
47
|
+
* })
|
|
48
|
+
*/
|
|
49
|
+
createSessionToken(request?: Phonic.CreateSessionTokenRequest, requestOptions?: Auth.RequestOptions): core.HttpResponsePromise<Phonic.AuthCreateSessionTokenResponse>;
|
|
50
|
+
private __createSessionToken;
|
|
51
|
+
protected _getAuthorizationHeader(): Promise<string | undefined>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
39
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
40
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
41
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
42
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
43
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
44
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.Auth = void 0;
|
|
49
|
+
const environments = __importStar(require("../../../../environments.js"));
|
|
50
|
+
const core = __importStar(require("../../../../core/index.js"));
|
|
51
|
+
const Phonic = __importStar(require("../../../index.js"));
|
|
52
|
+
const headers_js_1 = require("../../../../core/headers.js");
|
|
53
|
+
const errors = __importStar(require("../../../../errors/index.js"));
|
|
54
|
+
class Auth {
|
|
55
|
+
constructor(_options = {}) {
|
|
56
|
+
this._options = _options;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates a short-lived session token that can be used to authenticate WebSocket connections. Session tokens are useful for client-side applications where you don't want to expose your API key.
|
|
60
|
+
*
|
|
61
|
+
* @param {Phonic.CreateSessionTokenRequest} request
|
|
62
|
+
* @param {Auth.RequestOptions} requestOptions - Request-specific configuration.
|
|
63
|
+
*
|
|
64
|
+
* @throws {@link Phonic.BadRequestError}
|
|
65
|
+
* @throws {@link Phonic.UnauthorizedError}
|
|
66
|
+
* @throws {@link Phonic.ForbiddenError}
|
|
67
|
+
* @throws {@link Phonic.InternalServerError}
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* await client.auth.createSessionToken({
|
|
71
|
+
* ttl_seconds: 300
|
|
72
|
+
* })
|
|
73
|
+
*/
|
|
74
|
+
createSessionToken(request = {}, requestOptions) {
|
|
75
|
+
return core.HttpResponsePromise.fromPromise(this.__createSessionToken(request, requestOptions));
|
|
76
|
+
}
|
|
77
|
+
__createSessionToken() {
|
|
78
|
+
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
|
|
79
|
+
var _a, _b, _c, _d;
|
|
80
|
+
let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
81
|
+
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
82
|
+
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)
|
|
83
|
+
.base, "auth/session_token"),
|
|
84
|
+
method: "POST",
|
|
85
|
+
headers: _headers,
|
|
86
|
+
contentType: "application/json",
|
|
87
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
88
|
+
requestType: "json",
|
|
89
|
+
body: request,
|
|
90
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
91
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
92
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
93
|
+
});
|
|
94
|
+
if (_response.ok) {
|
|
95
|
+
return {
|
|
96
|
+
data: _response.body,
|
|
97
|
+
rawResponse: _response.rawResponse,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (_response.error.reason === "status-code") {
|
|
101
|
+
switch (_response.error.statusCode) {
|
|
102
|
+
case 400:
|
|
103
|
+
throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
|
|
104
|
+
case 401:
|
|
105
|
+
throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
106
|
+
case 403:
|
|
107
|
+
throw new Phonic.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
108
|
+
case 500:
|
|
109
|
+
throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
|
|
110
|
+
default:
|
|
111
|
+
throw new errors.PhonicError({
|
|
112
|
+
statusCode: _response.error.statusCode,
|
|
113
|
+
body: _response.error.body,
|
|
114
|
+
rawResponse: _response.rawResponse,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
switch (_response.error.reason) {
|
|
119
|
+
case "non-json":
|
|
120
|
+
throw new errors.PhonicError({
|
|
121
|
+
statusCode: _response.error.statusCode,
|
|
122
|
+
body: _response.error.rawBody,
|
|
123
|
+
rawResponse: _response.rawResponse,
|
|
124
|
+
});
|
|
125
|
+
case "timeout":
|
|
126
|
+
throw new errors.PhonicTimeoutError("Timeout exceeded when calling POST /auth/session_token.");
|
|
127
|
+
case "unknown":
|
|
128
|
+
throw new errors.PhonicError({
|
|
129
|
+
message: _response.error.errorMessage,
|
|
130
|
+
rawResponse: _response.rawResponse,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
_getAuthorizationHeader() {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
var _a;
|
|
138
|
+
const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env["PHONIC_API_KEY"];
|
|
139
|
+
if (bearer != null) {
|
|
140
|
+
return `Bearer ${bearer}`;
|
|
141
|
+
}
|
|
142
|
+
return undefined;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.Auth = Auth;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./requests/index.js"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @example
|
|
6
|
+
* {
|
|
7
|
+
* ttl_seconds: 300
|
|
8
|
+
* }
|
|
9
|
+
*/
|
|
10
|
+
export interface CreateSessionTokenRequest {
|
|
11
|
+
/** Time-to-live for the session token in seconds. */
|
|
12
|
+
ttl_seconds?: number;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type CreateSessionTokenRequest } from "./CreateSessionTokenRequest.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types/index.js"), exports);
|
|
18
|
+
__exportStar(require("./client/index.js"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
export interface AuthCreateSessionTokenResponse {
|
|
5
|
+
/** The session token to use for authentication. */
|
|
6
|
+
session_token: string;
|
|
7
|
+
/** When the session token expires. */
|
|
8
|
+
expires_at: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AuthCreateSessionTokenResponse.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AuthCreateSessionTokenResponse.js"), exports);
|
|
@@ -8,6 +8,8 @@ export * as voices from "./voices/index.js";
|
|
|
8
8
|
export * from "./voices/types/index.js";
|
|
9
9
|
export * as conversations from "./conversations/index.js";
|
|
10
10
|
export * from "./conversations/types/index.js";
|
|
11
|
+
export * as auth from "./auth/index.js";
|
|
12
|
+
export * from "./auth/types/index.js";
|
|
11
13
|
export * as projects from "./projects/index.js";
|
|
12
14
|
export * from "./projects/types/index.js";
|
|
13
15
|
export * from "./agents/client/requests/index.js";
|
|
@@ -15,4 +17,5 @@ export * from "./tools/client/requests/index.js";
|
|
|
15
17
|
export * from "./extractionSchemas/client/requests/index.js";
|
|
16
18
|
export * from "./voices/client/requests/index.js";
|
|
17
19
|
export * from "./conversations/client/requests/index.js";
|
|
20
|
+
export * from "./auth/client/requests/index.js";
|
|
18
21
|
export * from "./projects/client/requests/index.js";
|
|
@@ -36,7 +36,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
36
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.projects = exports.conversations = exports.voices = exports.extractionSchemas = exports.tools = exports.agents = void 0;
|
|
39
|
+
exports.projects = exports.auth = exports.conversations = exports.voices = exports.extractionSchemas = exports.tools = exports.agents = void 0;
|
|
40
40
|
exports.agents = __importStar(require("./agents/index.js"));
|
|
41
41
|
__exportStar(require("./agents/types/index.js"), exports);
|
|
42
42
|
exports.tools = __importStar(require("./tools/index.js"));
|
|
@@ -47,6 +47,8 @@ exports.voices = __importStar(require("./voices/index.js"));
|
|
|
47
47
|
__exportStar(require("./voices/types/index.js"), exports);
|
|
48
48
|
exports.conversations = __importStar(require("./conversations/index.js"));
|
|
49
49
|
__exportStar(require("./conversations/types/index.js"), exports);
|
|
50
|
+
exports.auth = __importStar(require("./auth/index.js"));
|
|
51
|
+
__exportStar(require("./auth/types/index.js"), exports);
|
|
50
52
|
exports.projects = __importStar(require("./projects/index.js"));
|
|
51
53
|
__exportStar(require("./projects/types/index.js"), exports);
|
|
52
54
|
__exportStar(require("./agents/client/requests/index.js"), exports);
|
|
@@ -54,4 +56,5 @@ __exportStar(require("./tools/client/requests/index.js"), exports);
|
|
|
54
56
|
__exportStar(require("./extractionSchemas/client/requests/index.js"), exports);
|
|
55
57
|
__exportStar(require("./voices/client/requests/index.js"), exports);
|
|
56
58
|
__exportStar(require("./conversations/client/requests/index.js"), exports);
|
|
59
|
+
__exportStar(require("./auth/client/requests/index.js"), exports);
|
|
57
60
|
__exportStar(require("./projects/client/requests/index.js"), exports);
|
|
@@ -100,6 +100,7 @@ export declare class Tools {
|
|
|
100
100
|
* },
|
|
101
101
|
* endpoint_timeout_ms: 5000,
|
|
102
102
|
* require_speech_before_tool_call: false,
|
|
103
|
+
* wait_for_speech_before_tool_call: false,
|
|
103
104
|
* forbid_speech_after_tool_call: false
|
|
104
105
|
* })
|
|
105
106
|
*
|
|
@@ -118,6 +119,7 @@ export declare class Tools {
|
|
|
118
119
|
* }],
|
|
119
120
|
* tool_call_output_timeout_ms: 5000,
|
|
120
121
|
* require_speech_before_tool_call: false,
|
|
122
|
+
* wait_for_speech_before_tool_call: false,
|
|
121
123
|
* forbid_speech_after_tool_call: false
|
|
122
124
|
* })
|
|
123
125
|
*
|
|
@@ -188,6 +188,7 @@ class Tools {
|
|
|
188
188
|
* },
|
|
189
189
|
* endpoint_timeout_ms: 5000,
|
|
190
190
|
* require_speech_before_tool_call: false,
|
|
191
|
+
* wait_for_speech_before_tool_call: false,
|
|
191
192
|
* forbid_speech_after_tool_call: false
|
|
192
193
|
* })
|
|
193
194
|
*
|
|
@@ -206,6 +207,7 @@ class Tools {
|
|
|
206
207
|
* }],
|
|
207
208
|
* tool_call_output_timeout_ms: 5000,
|
|
208
209
|
* require_speech_before_tool_call: false,
|
|
210
|
+
* wait_for_speech_before_tool_call: false,
|
|
209
211
|
* forbid_speech_after_tool_call: false
|
|
210
212
|
* })
|
|
211
213
|
*
|
|
@@ -48,6 +48,7 @@ import * as Phonic from "../../../../index.js";
|
|
|
48
48
|
* },
|
|
49
49
|
* endpoint_timeout_ms: 5000,
|
|
50
50
|
* require_speech_before_tool_call: false,
|
|
51
|
+
* wait_for_speech_before_tool_call: false,
|
|
51
52
|
* forbid_speech_after_tool_call: false
|
|
52
53
|
* }
|
|
53
54
|
*
|
|
@@ -66,6 +67,7 @@ import * as Phonic from "../../../../index.js";
|
|
|
66
67
|
* }],
|
|
67
68
|
* tool_call_output_timeout_ms: 5000,
|
|
68
69
|
* require_speech_before_tool_call: false,
|
|
70
|
+
* wait_for_speech_before_tool_call: false,
|
|
69
71
|
* forbid_speech_after_tool_call: false
|
|
70
72
|
* }
|
|
71
73
|
*
|
|
@@ -128,6 +130,8 @@ export interface CreateToolRequest {
|
|
|
128
130
|
agents_to_transfer_to?: string[];
|
|
129
131
|
/** When true, forces the agent to speak before executing the tool. */
|
|
130
132
|
require_speech_before_tool_call?: boolean;
|
|
133
|
+
/** If true, the agent will wait to finish speaking before executing the tool. This is only available for custom_webhook and custom_websocket tools. */
|
|
134
|
+
wait_for_speech_before_tool_call?: boolean;
|
|
131
135
|
/** When true, forbids the agent from speaking after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
|
|
132
136
|
forbid_speech_after_tool_call?: boolean;
|
|
133
137
|
}
|
|
@@ -45,6 +45,8 @@ export interface UpdateToolRequest {
|
|
|
45
45
|
agents_to_transfer_to?: string[];
|
|
46
46
|
/** When true, forces the agent to speak before executing the tool. */
|
|
47
47
|
require_speech_before_tool_call?: boolean;
|
|
48
|
+
/** If true, the agent will wait to finish speaking before executing the tool. This is only available for custom_webhook and custom_websocket tools. */
|
|
49
|
+
wait_for_speech_before_tool_call?: boolean;
|
|
48
50
|
/** When true, forbids the agent from speaking after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
|
|
49
51
|
forbid_speech_after_tool_call?: boolean;
|
|
50
52
|
}
|
|
@@ -34,6 +34,8 @@ export interface Tool {
|
|
|
34
34
|
agents_to_transfer_to?: string[];
|
|
35
35
|
/** When true, forces the agent to speak before executing the tool. */
|
|
36
36
|
require_speech_before_tool_call?: boolean;
|
|
37
|
+
/** If true, the agent will wait to finish speaking before executing the tool. This is only available for custom_webhook and custom_websocket tools. */
|
|
38
|
+
wait_for_speech_before_tool_call?: boolean;
|
|
37
39
|
/** When true, forbids the agent from speaking after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
|
|
38
40
|
forbid_speech_after_tool_call?: boolean;
|
|
39
41
|
}
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.30.
|
|
1
|
+
export declare const SDK_VERSION = "0.30.22";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/Client.d.mts
CHANGED
|
@@ -8,6 +8,7 @@ import { Tools } from "./api/resources/tools/client/Client.mjs";
|
|
|
8
8
|
import { ExtractionSchemas } from "./api/resources/extractionSchemas/client/Client.mjs";
|
|
9
9
|
import { Voices } from "./api/resources/voices/client/Client.mjs";
|
|
10
10
|
import { Conversations } from "./api/resources/conversations/client/Client.mjs";
|
|
11
|
+
import { Auth } from "./api/resources/auth/client/Client.mjs";
|
|
11
12
|
import { Projects } from "./api/resources/projects/client/Client.mjs";
|
|
12
13
|
export declare namespace PhonicClient {
|
|
13
14
|
interface Options {
|
|
@@ -39,6 +40,7 @@ export declare class PhonicClient {
|
|
|
39
40
|
protected _extractionSchemas: ExtractionSchemas | undefined;
|
|
40
41
|
protected _voices: Voices | undefined;
|
|
41
42
|
protected _conversations: Conversations | undefined;
|
|
43
|
+
protected _auth: Auth | undefined;
|
|
42
44
|
protected _projects: Projects | undefined;
|
|
43
45
|
constructor(_options?: PhonicClient.Options);
|
|
44
46
|
get agents(): Agents;
|
|
@@ -46,5 +48,6 @@ export declare class PhonicClient {
|
|
|
46
48
|
get extractionSchemas(): ExtractionSchemas;
|
|
47
49
|
get voices(): Voices;
|
|
48
50
|
get conversations(): Conversations;
|
|
51
|
+
get auth(): Auth;
|
|
49
52
|
get projects(): Projects;
|
|
50
53
|
}
|
package/dist/esm/Client.mjs
CHANGED
|
@@ -8,14 +8,15 @@ import { Tools } from "./api/resources/tools/client/Client.mjs";
|
|
|
8
8
|
import { ExtractionSchemas } from "./api/resources/extractionSchemas/client/Client.mjs";
|
|
9
9
|
import { Voices } from "./api/resources/voices/client/Client.mjs";
|
|
10
10
|
import { Conversations } from "./api/resources/conversations/client/Client.mjs";
|
|
11
|
+
import { Auth } from "./api/resources/auth/client/Client.mjs";
|
|
11
12
|
import { Projects } from "./api/resources/projects/client/Client.mjs";
|
|
12
13
|
export class PhonicClient {
|
|
13
14
|
constructor(_options = {}) {
|
|
14
15
|
this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
|
|
15
16
|
"X-Fern-Language": "JavaScript",
|
|
16
17
|
"X-Fern-SDK-Name": "phonic",
|
|
17
|
-
"X-Fern-SDK-Version": "0.30.
|
|
18
|
-
"User-Agent": "phonic/0.30.
|
|
18
|
+
"X-Fern-SDK-Version": "0.30.22",
|
|
19
|
+
"User-Agent": "phonic/0.30.22",
|
|
19
20
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
20
21
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
21
22
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -40,6 +41,10 @@ export class PhonicClient {
|
|
|
40
41
|
var _a;
|
|
41
42
|
return ((_a = this._conversations) !== null && _a !== void 0 ? _a : (this._conversations = new Conversations(this._options)));
|
|
42
43
|
}
|
|
44
|
+
get auth() {
|
|
45
|
+
var _a;
|
|
46
|
+
return ((_a = this._auth) !== null && _a !== void 0 ? _a : (this._auth = new Auth(this._options)));
|
|
47
|
+
}
|
|
43
48
|
get projects() {
|
|
44
49
|
var _a;
|
|
45
50
|
return ((_a = this._projects) !== null && _a !== void 0 ? _a : (this._projects = new Projects(this._options)));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as environments from "../../../../environments.mjs";
|
|
5
|
+
import * as core from "../../../../core/index.mjs";
|
|
6
|
+
import * as Phonic from "../../../index.mjs";
|
|
7
|
+
export declare namespace Auth {
|
|
8
|
+
interface Options {
|
|
9
|
+
environment?: core.Supplier<environments.PhonicEnvironment | environments.PhonicEnvironmentUrls>;
|
|
10
|
+
/** Specify a custom URL to connect the client to. */
|
|
11
|
+
baseUrl?: core.Supplier<string>;
|
|
12
|
+
apiKey?: core.Supplier<core.BearerToken | undefined>;
|
|
13
|
+
/** Additional headers to include in requests. */
|
|
14
|
+
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
15
|
+
fetcher?: core.FetchFunction;
|
|
16
|
+
}
|
|
17
|
+
interface RequestOptions {
|
|
18
|
+
/** The maximum time to wait for a response in seconds. */
|
|
19
|
+
timeoutInSeconds?: number;
|
|
20
|
+
/** The number of times to retry the request. Defaults to 2. */
|
|
21
|
+
maxRetries?: number;
|
|
22
|
+
/** A hook to abort the request. */
|
|
23
|
+
abortSignal?: AbortSignal;
|
|
24
|
+
/** Additional query string parameters to include in the request. */
|
|
25
|
+
queryParams?: Record<string, unknown>;
|
|
26
|
+
/** Additional headers to include in the request. */
|
|
27
|
+
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export declare class Auth {
|
|
31
|
+
protected readonly _options: Auth.Options;
|
|
32
|
+
constructor(_options?: Auth.Options);
|
|
33
|
+
/**
|
|
34
|
+
* Creates a short-lived session token that can be used to authenticate WebSocket connections. Session tokens are useful for client-side applications where you don't want to expose your API key.
|
|
35
|
+
*
|
|
36
|
+
* @param {Phonic.CreateSessionTokenRequest} request
|
|
37
|
+
* @param {Auth.RequestOptions} requestOptions - Request-specific configuration.
|
|
38
|
+
*
|
|
39
|
+
* @throws {@link Phonic.BadRequestError}
|
|
40
|
+
* @throws {@link Phonic.UnauthorizedError}
|
|
41
|
+
* @throws {@link Phonic.ForbiddenError}
|
|
42
|
+
* @throws {@link Phonic.InternalServerError}
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* await client.auth.createSessionToken({
|
|
46
|
+
* ttl_seconds: 300
|
|
47
|
+
* })
|
|
48
|
+
*/
|
|
49
|
+
createSessionToken(request?: Phonic.CreateSessionTokenRequest, requestOptions?: Auth.RequestOptions): core.HttpResponsePromise<Phonic.AuthCreateSessionTokenResponse>;
|
|
50
|
+
private __createSessionToken;
|
|
51
|
+
protected _getAuthorizationHeader(): Promise<string | undefined>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
import * as environments from "../../../../environments.mjs";
|
|
14
|
+
import * as core from "../../../../core/index.mjs";
|
|
15
|
+
import * as Phonic from "../../../index.mjs";
|
|
16
|
+
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
|
|
17
|
+
import * as errors from "../../../../errors/index.mjs";
|
|
18
|
+
export class Auth {
|
|
19
|
+
constructor(_options = {}) {
|
|
20
|
+
this._options = _options;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a short-lived session token that can be used to authenticate WebSocket connections. Session tokens are useful for client-side applications where you don't want to expose your API key.
|
|
24
|
+
*
|
|
25
|
+
* @param {Phonic.CreateSessionTokenRequest} request
|
|
26
|
+
* @param {Auth.RequestOptions} requestOptions - Request-specific configuration.
|
|
27
|
+
*
|
|
28
|
+
* @throws {@link Phonic.BadRequestError}
|
|
29
|
+
* @throws {@link Phonic.UnauthorizedError}
|
|
30
|
+
* @throws {@link Phonic.ForbiddenError}
|
|
31
|
+
* @throws {@link Phonic.InternalServerError}
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* await client.auth.createSessionToken({
|
|
35
|
+
* ttl_seconds: 300
|
|
36
|
+
* })
|
|
37
|
+
*/
|
|
38
|
+
createSessionToken(request = {}, requestOptions) {
|
|
39
|
+
return core.HttpResponsePromise.fromPromise(this.__createSessionToken(request, requestOptions));
|
|
40
|
+
}
|
|
41
|
+
__createSessionToken() {
|
|
42
|
+
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
|
|
43
|
+
var _a, _b, _c, _d;
|
|
44
|
+
let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
45
|
+
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
46
|
+
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)
|
|
47
|
+
.base, "auth/session_token"),
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: _headers,
|
|
50
|
+
contentType: "application/json",
|
|
51
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
52
|
+
requestType: "json",
|
|
53
|
+
body: request,
|
|
54
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
55
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
56
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
57
|
+
});
|
|
58
|
+
if (_response.ok) {
|
|
59
|
+
return {
|
|
60
|
+
data: _response.body,
|
|
61
|
+
rawResponse: _response.rawResponse,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (_response.error.reason === "status-code") {
|
|
65
|
+
switch (_response.error.statusCode) {
|
|
66
|
+
case 400:
|
|
67
|
+
throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
|
|
68
|
+
case 401:
|
|
69
|
+
throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
70
|
+
case 403:
|
|
71
|
+
throw new Phonic.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
72
|
+
case 500:
|
|
73
|
+
throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
|
|
74
|
+
default:
|
|
75
|
+
throw new errors.PhonicError({
|
|
76
|
+
statusCode: _response.error.statusCode,
|
|
77
|
+
body: _response.error.body,
|
|
78
|
+
rawResponse: _response.rawResponse,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
switch (_response.error.reason) {
|
|
83
|
+
case "non-json":
|
|
84
|
+
throw new errors.PhonicError({
|
|
85
|
+
statusCode: _response.error.statusCode,
|
|
86
|
+
body: _response.error.rawBody,
|
|
87
|
+
rawResponse: _response.rawResponse,
|
|
88
|
+
});
|
|
89
|
+
case "timeout":
|
|
90
|
+
throw new errors.PhonicTimeoutError("Timeout exceeded when calling POST /auth/session_token.");
|
|
91
|
+
case "unknown":
|
|
92
|
+
throw new errors.PhonicError({
|
|
93
|
+
message: _response.error.errorMessage,
|
|
94
|
+
rawResponse: _response.rawResponse,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
_getAuthorizationHeader() {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
var _a;
|
|
102
|
+
const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env["PHONIC_API_KEY"];
|
|
103
|
+
if (bearer != null) {
|
|
104
|
+
return `Bearer ${bearer}`;
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.mjs";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @example
|
|
6
|
+
* {
|
|
7
|
+
* ttl_seconds: 300
|
|
8
|
+
* }
|
|
9
|
+
*/
|
|
10
|
+
export interface CreateSessionTokenRequest {
|
|
11
|
+
/** Time-to-live for the session token in seconds. */
|
|
12
|
+
ttl_seconds?: number;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type CreateSessionTokenRequest } from "./CreateSessionTokenRequest.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
export interface AuthCreateSessionTokenResponse {
|
|
5
|
+
/** The session token to use for authentication. */
|
|
6
|
+
session_token: string;
|
|
7
|
+
/** When the session token expires. */
|
|
8
|
+
expires_at: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AuthCreateSessionTokenResponse.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AuthCreateSessionTokenResponse.mjs";
|
|
@@ -8,6 +8,8 @@ export * as voices from "./voices/index.mjs";
|
|
|
8
8
|
export * from "./voices/types/index.mjs";
|
|
9
9
|
export * as conversations from "./conversations/index.mjs";
|
|
10
10
|
export * from "./conversations/types/index.mjs";
|
|
11
|
+
export * as auth from "./auth/index.mjs";
|
|
12
|
+
export * from "./auth/types/index.mjs";
|
|
11
13
|
export * as projects from "./projects/index.mjs";
|
|
12
14
|
export * from "./projects/types/index.mjs";
|
|
13
15
|
export * from "./agents/client/requests/index.mjs";
|
|
@@ -15,4 +17,5 @@ export * from "./tools/client/requests/index.mjs";
|
|
|
15
17
|
export * from "./extractionSchemas/client/requests/index.mjs";
|
|
16
18
|
export * from "./voices/client/requests/index.mjs";
|
|
17
19
|
export * from "./conversations/client/requests/index.mjs";
|
|
20
|
+
export * from "./auth/client/requests/index.mjs";
|
|
18
21
|
export * from "./projects/client/requests/index.mjs";
|
|
@@ -8,6 +8,8 @@ export * as voices from "./voices/index.mjs";
|
|
|
8
8
|
export * from "./voices/types/index.mjs";
|
|
9
9
|
export * as conversations from "./conversations/index.mjs";
|
|
10
10
|
export * from "./conversations/types/index.mjs";
|
|
11
|
+
export * as auth from "./auth/index.mjs";
|
|
12
|
+
export * from "./auth/types/index.mjs";
|
|
11
13
|
export * as projects from "./projects/index.mjs";
|
|
12
14
|
export * from "./projects/types/index.mjs";
|
|
13
15
|
export * from "./agents/client/requests/index.mjs";
|
|
@@ -15,4 +17,5 @@ export * from "./tools/client/requests/index.mjs";
|
|
|
15
17
|
export * from "./extractionSchemas/client/requests/index.mjs";
|
|
16
18
|
export * from "./voices/client/requests/index.mjs";
|
|
17
19
|
export * from "./conversations/client/requests/index.mjs";
|
|
20
|
+
export * from "./auth/client/requests/index.mjs";
|
|
18
21
|
export * from "./projects/client/requests/index.mjs";
|
|
@@ -100,6 +100,7 @@ export declare class Tools {
|
|
|
100
100
|
* },
|
|
101
101
|
* endpoint_timeout_ms: 5000,
|
|
102
102
|
* require_speech_before_tool_call: false,
|
|
103
|
+
* wait_for_speech_before_tool_call: false,
|
|
103
104
|
* forbid_speech_after_tool_call: false
|
|
104
105
|
* })
|
|
105
106
|
*
|
|
@@ -118,6 +119,7 @@ export declare class Tools {
|
|
|
118
119
|
* }],
|
|
119
120
|
* tool_call_output_timeout_ms: 5000,
|
|
120
121
|
* require_speech_before_tool_call: false,
|
|
122
|
+
* wait_for_speech_before_tool_call: false,
|
|
121
123
|
* forbid_speech_after_tool_call: false
|
|
122
124
|
* })
|
|
123
125
|
*
|
|
@@ -152,6 +152,7 @@ export class Tools {
|
|
|
152
152
|
* },
|
|
153
153
|
* endpoint_timeout_ms: 5000,
|
|
154
154
|
* require_speech_before_tool_call: false,
|
|
155
|
+
* wait_for_speech_before_tool_call: false,
|
|
155
156
|
* forbid_speech_after_tool_call: false
|
|
156
157
|
* })
|
|
157
158
|
*
|
|
@@ -170,6 +171,7 @@ export class Tools {
|
|
|
170
171
|
* }],
|
|
171
172
|
* tool_call_output_timeout_ms: 5000,
|
|
172
173
|
* require_speech_before_tool_call: false,
|
|
174
|
+
* wait_for_speech_before_tool_call: false,
|
|
173
175
|
* forbid_speech_after_tool_call: false
|
|
174
176
|
* })
|
|
175
177
|
*
|
|
@@ -48,6 +48,7 @@ import * as Phonic from "../../../../index.mjs";
|
|
|
48
48
|
* },
|
|
49
49
|
* endpoint_timeout_ms: 5000,
|
|
50
50
|
* require_speech_before_tool_call: false,
|
|
51
|
+
* wait_for_speech_before_tool_call: false,
|
|
51
52
|
* forbid_speech_after_tool_call: false
|
|
52
53
|
* }
|
|
53
54
|
*
|
|
@@ -66,6 +67,7 @@ import * as Phonic from "../../../../index.mjs";
|
|
|
66
67
|
* }],
|
|
67
68
|
* tool_call_output_timeout_ms: 5000,
|
|
68
69
|
* require_speech_before_tool_call: false,
|
|
70
|
+
* wait_for_speech_before_tool_call: false,
|
|
69
71
|
* forbid_speech_after_tool_call: false
|
|
70
72
|
* }
|
|
71
73
|
*
|
|
@@ -128,6 +130,8 @@ export interface CreateToolRequest {
|
|
|
128
130
|
agents_to_transfer_to?: string[];
|
|
129
131
|
/** When true, forces the agent to speak before executing the tool. */
|
|
130
132
|
require_speech_before_tool_call?: boolean;
|
|
133
|
+
/** If true, the agent will wait to finish speaking before executing the tool. This is only available for custom_webhook and custom_websocket tools. */
|
|
134
|
+
wait_for_speech_before_tool_call?: boolean;
|
|
131
135
|
/** When true, forbids the agent from speaking after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
|
|
132
136
|
forbid_speech_after_tool_call?: boolean;
|
|
133
137
|
}
|
|
@@ -45,6 +45,8 @@ export interface UpdateToolRequest {
|
|
|
45
45
|
agents_to_transfer_to?: string[];
|
|
46
46
|
/** When true, forces the agent to speak before executing the tool. */
|
|
47
47
|
require_speech_before_tool_call?: boolean;
|
|
48
|
+
/** If true, the agent will wait to finish speaking before executing the tool. This is only available for custom_webhook and custom_websocket tools. */
|
|
49
|
+
wait_for_speech_before_tool_call?: boolean;
|
|
48
50
|
/** When true, forbids the agent from speaking after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
|
|
49
51
|
forbid_speech_after_tool_call?: boolean;
|
|
50
52
|
}
|
|
@@ -34,6 +34,8 @@ export interface Tool {
|
|
|
34
34
|
agents_to_transfer_to?: string[];
|
|
35
35
|
/** When true, forces the agent to speak before executing the tool. */
|
|
36
36
|
require_speech_before_tool_call?: boolean;
|
|
37
|
+
/** If true, the agent will wait to finish speaking before executing the tool. This is only available for custom_webhook and custom_websocket tools. */
|
|
38
|
+
wait_for_speech_before_tool_call?: boolean;
|
|
37
39
|
/** When true, forbids the agent from speaking after executing the tool. Available for custom_context, custom_webhook and custom_websocket tools. */
|
|
38
40
|
forbid_speech_after_tool_call?: boolean;
|
|
39
41
|
}
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.30.
|
|
1
|
+
export declare const SDK_VERSION = "0.30.22";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.30.
|
|
1
|
+
export const SDK_VERSION = "0.30.22";
|
package/package.json
CHANGED
package/reference.md
CHANGED
|
@@ -2056,6 +2056,73 @@ await client.conversations.sipOutboundCall({
|
|
|
2056
2056
|
</dl>
|
|
2057
2057
|
</details>
|
|
2058
2058
|
|
|
2059
|
+
## Auth
|
|
2060
|
+
|
|
2061
|
+
<details><summary><code>client.auth.<a href="/src/api/resources/auth/client/Client.ts">createSessionToken</a>({ ...params }) -> Phonic.AuthCreateSessionTokenResponse</code></summary>
|
|
2062
|
+
<dl>
|
|
2063
|
+
<dd>
|
|
2064
|
+
|
|
2065
|
+
#### 📝 Description
|
|
2066
|
+
|
|
2067
|
+
<dl>
|
|
2068
|
+
<dd>
|
|
2069
|
+
|
|
2070
|
+
<dl>
|
|
2071
|
+
<dd>
|
|
2072
|
+
|
|
2073
|
+
Creates a short-lived session token that can be used to authenticate WebSocket connections. Session tokens are useful for client-side applications where you don't want to expose your API key.
|
|
2074
|
+
|
|
2075
|
+
</dd>
|
|
2076
|
+
</dl>
|
|
2077
|
+
</dd>
|
|
2078
|
+
</dl>
|
|
2079
|
+
|
|
2080
|
+
#### 🔌 Usage
|
|
2081
|
+
|
|
2082
|
+
<dl>
|
|
2083
|
+
<dd>
|
|
2084
|
+
|
|
2085
|
+
<dl>
|
|
2086
|
+
<dd>
|
|
2087
|
+
|
|
2088
|
+
```typescript
|
|
2089
|
+
await client.auth.createSessionToken({
|
|
2090
|
+
ttl_seconds: 300,
|
|
2091
|
+
});
|
|
2092
|
+
```
|
|
2093
|
+
|
|
2094
|
+
</dd>
|
|
2095
|
+
</dl>
|
|
2096
|
+
</dd>
|
|
2097
|
+
</dl>
|
|
2098
|
+
|
|
2099
|
+
#### ⚙️ Parameters
|
|
2100
|
+
|
|
2101
|
+
<dl>
|
|
2102
|
+
<dd>
|
|
2103
|
+
|
|
2104
|
+
<dl>
|
|
2105
|
+
<dd>
|
|
2106
|
+
|
|
2107
|
+
**request:** `Phonic.CreateSessionTokenRequest`
|
|
2108
|
+
|
|
2109
|
+
</dd>
|
|
2110
|
+
</dl>
|
|
2111
|
+
|
|
2112
|
+
<dl>
|
|
2113
|
+
<dd>
|
|
2114
|
+
|
|
2115
|
+
**requestOptions:** `Auth.RequestOptions`
|
|
2116
|
+
|
|
2117
|
+
</dd>
|
|
2118
|
+
</dl>
|
|
2119
|
+
</dd>
|
|
2120
|
+
</dl>
|
|
2121
|
+
|
|
2122
|
+
</dd>
|
|
2123
|
+
</dl>
|
|
2124
|
+
</details>
|
|
2125
|
+
|
|
2059
2126
|
## Projects
|
|
2060
2127
|
|
|
2061
2128
|
<details><summary><code>client.projects.<a href="/src/api/resources/projects/client/Client.ts">list</a>() -> Phonic.ProjectsListResponse</code></summary>
|