@fonoster/common 0.8.25 → 0.8.27

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.
Files changed (60) hide show
  1. package/dist/assistants/LanguageModelProvider.d.ts +6 -0
  2. package/dist/assistants/LanguageModelProvider.js +27 -0
  3. package/dist/assistants/assistantSchema.d.ts +411 -0
  4. package/dist/assistants/assistantSchema.js +29 -0
  5. package/dist/assistants/conversationSettingsSchema.d.ts +98 -0
  6. package/dist/assistants/conversationSettingsSchema.js +113 -0
  7. package/dist/assistants/index.d.ts +5 -0
  8. package/dist/assistants/index.js +39 -0
  9. package/dist/assistants/languageModelConfigSchema.d.ts +198 -0
  10. package/dist/assistants/languageModelConfigSchema.js +89 -0
  11. package/dist/assistants/tools/AllowedOperations.d.ts +6 -0
  12. package/dist/assistants/tools/AllowedOperations.js +27 -0
  13. package/dist/assistants/tools/index.d.ts +1 -0
  14. package/dist/assistants/tools/index.js +35 -0
  15. package/dist/assistants/tools/propertySchema.d.ts +23 -0
  16. package/dist/assistants/tools/propertySchema.js +34 -0
  17. package/dist/assistants/tools/toolSchema.d.ts +113 -0
  18. package/dist/assistants/tools/toolSchema.js +87 -0
  19. package/dist/errors/PrismaErrorEnum.d.ts +1 -2
  20. package/dist/errors/PrismaErrorEnum.js +0 -1
  21. package/dist/errors/handleError.js +1 -5
  22. package/dist/identity/createAuthInterceptor.d.ts +15 -0
  23. package/dist/identity/createAuthInterceptor.js +79 -0
  24. package/dist/identity/decodeToken.d.ts +3 -0
  25. package/dist/identity/decodeToken.js +25 -0
  26. package/dist/identity/errors.d.ts +4 -0
  27. package/dist/identity/errors.js +35 -0
  28. package/dist/identity/getAccessKeyIdFromCall.d.ts +3 -0
  29. package/dist/identity/getAccessKeyIdFromCall.js +8 -0
  30. package/dist/identity/getPublicKey.d.ts +5 -0
  31. package/dist/identity/getPublicKey.js +77 -0
  32. package/dist/identity/getTokenFromCall.d.ts +3 -0
  33. package/dist/identity/getTokenFromCall.js +8 -0
  34. package/dist/identity/hasAccess.d.ts +3 -0
  35. package/dist/identity/hasAccess.js +9 -0
  36. package/dist/identity/index.d.ts +9 -0
  37. package/dist/identity/index.js +43 -0
  38. package/dist/identity/isValidToken.d.ts +2 -0
  39. package/dist/identity/isValidToken.js +51 -0
  40. package/dist/identity/roles.d.ts +5 -0
  41. package/dist/identity/roles.js +132 -0
  42. package/dist/identity/tokenHasAccessKeyId.d.ts +2 -0
  43. package/dist/identity/tokenHasAccessKeyId.js +28 -0
  44. package/dist/identity/types.d.ts +44 -0
  45. package/dist/identity/types.js +14 -0
  46. package/dist/index.d.ts +2 -0
  47. package/dist/index.js +2 -0
  48. package/dist/protos/applications.proto +6 -4
  49. package/dist/utils/createFetchSingleCallByCallId.d.ts +4 -0
  50. package/dist/utils/{makeFetchSingleCallByCallId.js → createFetchSingleCallByCallId.js} +9 -7
  51. package/dist/utils/findIntegrationsCredentials.d.ts +5 -0
  52. package/dist/utils/findIntegrationsCredentials.js +25 -0
  53. package/dist/utils/index.d.ts +2 -1
  54. package/dist/utils/index.js +2 -1
  55. package/dist/validators/calls.d.ts +2 -2
  56. package/dist/validators/hostOrHostPortSchema.d.ts +1 -1
  57. package/dist/validators/hostOrHostPortSchema.js +1 -4
  58. package/dist/validators/identity.d.ts +2 -2
  59. package/package.json +3 -3
  60. package/dist/utils/makeFetchSingleCallByCallId.d.ts +0 -4
@@ -0,0 +1,39 @@
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
+ /*
18
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
19
+ * http://github.com/fonoster/fonoster
20
+ *
21
+ * This file is part of Fonoster
22
+ *
23
+ * Licensed under the MIT License (the "License");
24
+ * you may not use this file except in compliance with
25
+ * the License. You may obtain a copy of the License at
26
+ *
27
+ * https://opensource.org/licenses/MIT
28
+ *
29
+ * Unless required by applicable law or agreed to in writing, software
30
+ * distributed under the License is distributed on an "AS IS" BASIS,
31
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32
+ * See the License for the specific language governing permissions and
33
+ * limitations under the License.
34
+ */
35
+ __exportStar(require("./tools"), exports);
36
+ __exportStar(require("./assistantSchema"), exports);
37
+ __exportStar(require("./LanguageModelProvider"), exports);
38
+ __exportStar(require("./conversationSettingsSchema"), exports);
39
+ __exportStar(require("./languageModelConfigSchema"), exports);
@@ -0,0 +1,198 @@
1
+ import { z } from "zod";
2
+ import { LanguageModelProvider } from "./LanguageModelProvider";
3
+ declare const languageModelConfigSchema: z.ZodObject<{
4
+ provider: z.ZodNativeEnum<typeof LanguageModelProvider>;
5
+ apiKey: z.ZodOptional<z.ZodString>;
6
+ model: z.ZodString;
7
+ temperature: z.ZodNumber;
8
+ maxTokens: z.ZodNumber;
9
+ baseUrl: z.ZodOptional<z.ZodString>;
10
+ knowledgeBase: z.ZodArray<z.ZodObject<{
11
+ type: z.ZodEnum<["s3"]>;
12
+ title: z.ZodString;
13
+ document: z.ZodString;
14
+ }, "strip", z.ZodTypeAny, {
15
+ type?: "s3";
16
+ title?: string;
17
+ document?: string;
18
+ }, {
19
+ type?: "s3";
20
+ title?: string;
21
+ document?: string;
22
+ }>, "many">;
23
+ tools: z.ZodArray<z.ZodObject<{
24
+ name: z.ZodString;
25
+ description: z.ZodString;
26
+ parameters: z.ZodObject<{
27
+ type: z.ZodEnum<["object", "array"]>;
28
+ properties: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodObject<{
29
+ type: z.ZodString;
30
+ format: z.ZodOptional<z.ZodString>;
31
+ pattern: z.ZodOptional<z.ZodString>;
32
+ }, "strip", z.ZodTypeAny, {
33
+ type?: string;
34
+ format?: string;
35
+ pattern?: string;
36
+ }, {
37
+ type?: string;
38
+ format?: string;
39
+ pattern?: string;
40
+ }>, {
41
+ type?: string;
42
+ format?: string;
43
+ pattern?: string;
44
+ }, {
45
+ type?: string;
46
+ format?: string;
47
+ pattern?: string;
48
+ }>>;
49
+ required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ type?: "object" | "array";
52
+ properties?: Record<string, {
53
+ type?: string;
54
+ format?: string;
55
+ pattern?: string;
56
+ }>;
57
+ required?: string[];
58
+ }, {
59
+ type?: "object" | "array";
60
+ properties?: Record<string, {
61
+ type?: string;
62
+ format?: string;
63
+ pattern?: string;
64
+ }>;
65
+ required?: string[];
66
+ }>;
67
+ requestStartMessage: z.ZodOptional<z.ZodString>;
68
+ operation: z.ZodEffects<z.ZodObject<{
69
+ type: z.ZodNativeEnum<typeof import("./tools/AllowedOperations").AllowedOperations>;
70
+ url: z.ZodOptional<z.ZodString>;
71
+ waitForResponse: z.ZodOptional<z.ZodBoolean>;
72
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
73
+ }, "strip", z.ZodTypeAny, {
74
+ type?: import("./tools/AllowedOperations").AllowedOperations;
75
+ url?: string;
76
+ waitForResponse?: boolean;
77
+ headers?: Record<string, string>;
78
+ }, {
79
+ type?: import("./tools/AllowedOperations").AllowedOperations;
80
+ url?: string;
81
+ waitForResponse?: boolean;
82
+ headers?: Record<string, string>;
83
+ }>, {
84
+ type?: import("./tools/AllowedOperations").AllowedOperations;
85
+ url?: string;
86
+ waitForResponse?: boolean;
87
+ headers?: Record<string, string>;
88
+ }, {
89
+ type?: import("./tools/AllowedOperations").AllowedOperations;
90
+ url?: string;
91
+ waitForResponse?: boolean;
92
+ headers?: Record<string, string>;
93
+ }>;
94
+ }, "strip", z.ZodTypeAny, {
95
+ name?: string;
96
+ description?: string;
97
+ parameters?: {
98
+ type?: "object" | "array";
99
+ properties?: Record<string, {
100
+ type?: string;
101
+ format?: string;
102
+ pattern?: string;
103
+ }>;
104
+ required?: string[];
105
+ };
106
+ requestStartMessage?: string;
107
+ operation?: {
108
+ type?: import("./tools/AllowedOperations").AllowedOperations;
109
+ url?: string;
110
+ waitForResponse?: boolean;
111
+ headers?: Record<string, string>;
112
+ };
113
+ }, {
114
+ name?: string;
115
+ description?: string;
116
+ parameters?: {
117
+ type?: "object" | "array";
118
+ properties?: Record<string, {
119
+ type?: string;
120
+ format?: string;
121
+ pattern?: string;
122
+ }>;
123
+ required?: string[];
124
+ };
125
+ requestStartMessage?: string;
126
+ operation?: {
127
+ type?: import("./tools/AllowedOperations").AllowedOperations;
128
+ url?: string;
129
+ waitForResponse?: boolean;
130
+ headers?: Record<string, string>;
131
+ };
132
+ }>, "many">;
133
+ }, "strip", z.ZodTypeAny, {
134
+ provider?: LanguageModelProvider;
135
+ apiKey?: string;
136
+ model?: string;
137
+ temperature?: number;
138
+ maxTokens?: number;
139
+ baseUrl?: string;
140
+ knowledgeBase?: {
141
+ type?: "s3";
142
+ title?: string;
143
+ document?: string;
144
+ }[];
145
+ tools?: {
146
+ name?: string;
147
+ description?: string;
148
+ parameters?: {
149
+ type?: "object" | "array";
150
+ properties?: Record<string, {
151
+ type?: string;
152
+ format?: string;
153
+ pattern?: string;
154
+ }>;
155
+ required?: string[];
156
+ };
157
+ requestStartMessage?: string;
158
+ operation?: {
159
+ type?: import("./tools/AllowedOperations").AllowedOperations;
160
+ url?: string;
161
+ waitForResponse?: boolean;
162
+ headers?: Record<string, string>;
163
+ };
164
+ }[];
165
+ }, {
166
+ provider?: LanguageModelProvider;
167
+ apiKey?: string;
168
+ model?: string;
169
+ temperature?: number;
170
+ maxTokens?: number;
171
+ baseUrl?: string;
172
+ knowledgeBase?: {
173
+ type?: "s3";
174
+ title?: string;
175
+ document?: string;
176
+ }[];
177
+ tools?: {
178
+ name?: string;
179
+ description?: string;
180
+ parameters?: {
181
+ type?: "object" | "array";
182
+ properties?: Record<string, {
183
+ type?: string;
184
+ format?: string;
185
+ pattern?: string;
186
+ }>;
187
+ required?: string[];
188
+ };
189
+ requestStartMessage?: string;
190
+ operation?: {
191
+ type?: import("./tools/AllowedOperations").AllowedOperations;
192
+ url?: string;
193
+ waitForResponse?: boolean;
194
+ headers?: Record<string, string>;
195
+ };
196
+ }[];
197
+ }>;
198
+ export { languageModelConfigSchema };
@@ -0,0 +1,89 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.languageModelConfigSchema = void 0;
37
+ /*
38
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
39
+ * http://github.com/fonoster/fonoster
40
+ *
41
+ * This file is part of Fonoster
42
+ *
43
+ * Licensed under the MIT License (the "License");
44
+ * you may not use this file except in compliance with
45
+ * the License. You may obtain a copy of the License at
46
+ *
47
+ * https://opensource.org/licenses/MIT
48
+ *
49
+ * Unless required by applicable law or agreed to in writing, software
50
+ * distributed under the License is distributed on an "AS IS" BASIS,
51
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
52
+ * See the License for the specific language governing permissions and
53
+ * limitations under the License.
54
+ */
55
+ const zod_1 = require("zod");
56
+ const tools_1 = require("./tools");
57
+ const LanguageModelProvider_1 = require("./LanguageModelProvider");
58
+ const Messages = __importStar(require("../messages"));
59
+ const NUMBER_BETWEEN_0_AND_2 = "Must be a number between 0 and 2";
60
+ const languageModelConfigSchema = zod_1.z.object({
61
+ provider: zod_1.z.nativeEnum(LanguageModelProvider_1.LanguageModelProvider, {
62
+ message: "Invalid language model provider."
63
+ }),
64
+ apiKey: zod_1.z.string().optional(),
65
+ model: zod_1.z.string(),
66
+ temperature: zod_1.z
67
+ .number()
68
+ .max(2, { message: NUMBER_BETWEEN_0_AND_2 })
69
+ .min(0, { message: NUMBER_BETWEEN_0_AND_2 }),
70
+ maxTokens: zod_1.z
71
+ .number()
72
+ .int({ message: Messages.POSITIVE_INTEGER_MESSAGE })
73
+ .positive({ message: Messages.POSITIVE_INTEGER_MESSAGE }),
74
+ baseUrl: zod_1.z
75
+ .string()
76
+ .url({
77
+ message: Messages.VALID_URL
78
+ })
79
+ .optional(),
80
+ knowledgeBase: zod_1.z.array(zod_1.z.object({
81
+ type: zod_1.z.enum(["s3"]),
82
+ title: zod_1.z.string(),
83
+ document: zod_1.z.string().regex(/\.pdf$/, {
84
+ message: "Document must be a pdf file"
85
+ })
86
+ })),
87
+ tools: zod_1.z.array(tools_1.toolSchema)
88
+ });
89
+ exports.languageModelConfigSchema = languageModelConfigSchema;
@@ -0,0 +1,6 @@
1
+ declare enum AllowedOperations {
2
+ GET = "get",
3
+ POST = "post",
4
+ BUILT_IN = "built-in"
5
+ }
6
+ export { AllowedOperations };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AllowedOperations = void 0;
4
+ /*
5
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
6
+ * http://github.com/fonoster/fonoster
7
+ *
8
+ * This file is part of Fonoster
9
+ *
10
+ * Licensed under the MIT License (the "License");
11
+ * you may not use this file except in compliance with
12
+ * the License. You may obtain a copy of the License at
13
+ *
14
+ * https://opensource.org/licenses/MIT
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ var AllowedOperations;
23
+ (function (AllowedOperations) {
24
+ AllowedOperations["GET"] = "get";
25
+ AllowedOperations["POST"] = "post";
26
+ AllowedOperations["BUILT_IN"] = "built-in";
27
+ })(AllowedOperations || (exports.AllowedOperations = AllowedOperations = {}));
@@ -0,0 +1 @@
1
+ export * from "./toolSchema";
@@ -0,0 +1,35 @@
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
+ /*
18
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
19
+ * http://github.com/fonoster/fonoster
20
+ *
21
+ * This file is part of Fonoster
22
+ *
23
+ * Licensed under the MIT License (the "License");
24
+ * you may not use this file except in compliance with
25
+ * the License. You may obtain a copy of the License at
26
+ *
27
+ * https://opensource.org/licenses/MIT
28
+ *
29
+ * Unless required by applicable law or agreed to in writing, software
30
+ * distributed under the License is distributed on an "AS IS" BASIS,
31
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32
+ * See the License for the specific language governing permissions and
33
+ * limitations under the License.
34
+ */
35
+ __exportStar(require("./toolSchema"), exports);
@@ -0,0 +1,23 @@
1
+ import { z } from "zod";
2
+ declare const propertySchema: z.ZodEffects<z.ZodObject<{
3
+ type: z.ZodString;
4
+ format: z.ZodOptional<z.ZodString>;
5
+ pattern: z.ZodOptional<z.ZodString>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ type?: string;
8
+ format?: string;
9
+ pattern?: string;
10
+ }, {
11
+ type?: string;
12
+ format?: string;
13
+ pattern?: string;
14
+ }>, {
15
+ type?: string;
16
+ format?: string;
17
+ pattern?: string;
18
+ }, {
19
+ type?: string;
20
+ format?: string;
21
+ pattern?: string;
22
+ }>;
23
+ export { propertySchema };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.propertySchema = void 0;
4
+ /*
5
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
6
+ * http://github.com/fonoster/fonoster
7
+ *
8
+ * This file is part of Fonoster
9
+ *
10
+ * Licensed under the MIT License (the "License");
11
+ * you may not use this file except in compliance with
12
+ * the License. You may obtain a copy of the License at
13
+ *
14
+ * https://opensource.org/licenses/MIT
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ const zod_1 = require("zod");
23
+ const propertySchema = zod_1.z
24
+ .object({
25
+ type: zod_1.z.string(),
26
+ format: zod_1.z.string().optional(),
27
+ pattern: zod_1.z.string().optional()
28
+ })
29
+ .refine((data) => {
30
+ return !("format" in data && "pattern" in data);
31
+ }, {
32
+ message: "Property can only have either 'format' or 'pattern', not both."
33
+ });
34
+ exports.propertySchema = propertySchema;
@@ -0,0 +1,113 @@
1
+ import { z } from "zod";
2
+ import { AllowedOperations } from "./AllowedOperations";
3
+ declare const toolSchema: z.ZodObject<{
4
+ name: z.ZodString;
5
+ description: z.ZodString;
6
+ parameters: z.ZodObject<{
7
+ type: z.ZodEnum<["object", "array"]>;
8
+ properties: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodObject<{
9
+ type: z.ZodString;
10
+ format: z.ZodOptional<z.ZodString>;
11
+ pattern: z.ZodOptional<z.ZodString>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ type?: string;
14
+ format?: string;
15
+ pattern?: string;
16
+ }, {
17
+ type?: string;
18
+ format?: string;
19
+ pattern?: string;
20
+ }>, {
21
+ type?: string;
22
+ format?: string;
23
+ pattern?: string;
24
+ }, {
25
+ type?: string;
26
+ format?: string;
27
+ pattern?: string;
28
+ }>>;
29
+ required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
30
+ }, "strip", z.ZodTypeAny, {
31
+ type?: "object" | "array";
32
+ properties?: Record<string, {
33
+ type?: string;
34
+ format?: string;
35
+ pattern?: string;
36
+ }>;
37
+ required?: string[];
38
+ }, {
39
+ type?: "object" | "array";
40
+ properties?: Record<string, {
41
+ type?: string;
42
+ format?: string;
43
+ pattern?: string;
44
+ }>;
45
+ required?: string[];
46
+ }>;
47
+ requestStartMessage: z.ZodOptional<z.ZodString>;
48
+ operation: z.ZodEffects<z.ZodObject<{
49
+ type: z.ZodNativeEnum<typeof AllowedOperations>;
50
+ url: z.ZodOptional<z.ZodString>;
51
+ waitForResponse: z.ZodOptional<z.ZodBoolean>;
52
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
53
+ }, "strip", z.ZodTypeAny, {
54
+ type?: AllowedOperations;
55
+ url?: string;
56
+ waitForResponse?: boolean;
57
+ headers?: Record<string, string>;
58
+ }, {
59
+ type?: AllowedOperations;
60
+ url?: string;
61
+ waitForResponse?: boolean;
62
+ headers?: Record<string, string>;
63
+ }>, {
64
+ type?: AllowedOperations;
65
+ url?: string;
66
+ waitForResponse?: boolean;
67
+ headers?: Record<string, string>;
68
+ }, {
69
+ type?: AllowedOperations;
70
+ url?: string;
71
+ waitForResponse?: boolean;
72
+ headers?: Record<string, string>;
73
+ }>;
74
+ }, "strip", z.ZodTypeAny, {
75
+ name?: string;
76
+ description?: string;
77
+ parameters?: {
78
+ type?: "object" | "array";
79
+ properties?: Record<string, {
80
+ type?: string;
81
+ format?: string;
82
+ pattern?: string;
83
+ }>;
84
+ required?: string[];
85
+ };
86
+ requestStartMessage?: string;
87
+ operation?: {
88
+ type?: AllowedOperations;
89
+ url?: string;
90
+ waitForResponse?: boolean;
91
+ headers?: Record<string, string>;
92
+ };
93
+ }, {
94
+ name?: string;
95
+ description?: string;
96
+ parameters?: {
97
+ type?: "object" | "array";
98
+ properties?: Record<string, {
99
+ type?: string;
100
+ format?: string;
101
+ pattern?: string;
102
+ }>;
103
+ required?: string[];
104
+ };
105
+ requestStartMessage?: string;
106
+ operation?: {
107
+ type?: AllowedOperations;
108
+ url?: string;
109
+ waitForResponse?: boolean;
110
+ headers?: Record<string, string>;
111
+ };
112
+ }>;
113
+ export { toolSchema };
@@ -0,0 +1,87 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.toolSchema = void 0;
37
+ /*
38
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
39
+ * http://github.com/fonoster/fonoster
40
+ *
41
+ * This file is part of Fonoster
42
+ *
43
+ * Licensed under the MIT License (the "License");
44
+ * you may not use this file except in compliance with
45
+ * the License. You may obtain a copy of the License at
46
+ *
47
+ * https://opensource.org/licenses/MIT
48
+ *
49
+ * Unless required by applicable law or agreed to in writing, software
50
+ * distributed under the License is distributed on an "AS IS" BASIS,
51
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
52
+ * See the License for the specific language governing permissions and
53
+ * limitations under the License.
54
+ */
55
+ const zod_1 = require("zod");
56
+ const propertySchema_1 = require("./propertySchema");
57
+ const Messages = __importStar(require("../../messages"));
58
+ const AllowedOperations_1 = require("./AllowedOperations");
59
+ const toolSchema = zod_1.z.object({
60
+ name: zod_1.z.string(),
61
+ description: zod_1.z.string(),
62
+ parameters: zod_1.z.object({
63
+ type: zod_1.z.enum(["object", "array"]),
64
+ properties: zod_1.z.record(propertySchema_1.propertySchema),
65
+ required: zod_1.z.array(zod_1.z.string()).optional()
66
+ }),
67
+ requestStartMessage: zod_1.z.string().optional(),
68
+ operation: zod_1.z
69
+ .object({
70
+ type: zod_1.z.nativeEnum(AllowedOperations_1.AllowedOperations, {
71
+ message: "Invalid operation type"
72
+ }),
73
+ // Make url required if operation type is not built-in
74
+ url: zod_1.z.string().url({ message: Messages.VALID_URL }).optional(),
75
+ waitForResponse: zod_1.z.boolean().optional(),
76
+ headers: zod_1.z.record(zod_1.z.string()).optional()
77
+ })
78
+ .superRefine(({ url, type }, ctx) => {
79
+ if (type !== AllowedOperations_1.AllowedOperations.BUILT_IN && !url) {
80
+ ctx.addIssue({
81
+ code: zod_1.z.ZodIssueCode.custom,
82
+ message: "Url is required for non built-in operations."
83
+ });
84
+ }
85
+ })
86
+ });
87
+ exports.toolSchema = toolSchema;
@@ -1,6 +1,5 @@
1
1
  declare enum PrismaErrorEnum {
2
2
  RECORD_ALREADY_EXISTS = "P2002",
3
- RECORD_NOT_FOUND = "P2025",
4
- FAILED_PRECONDITION = "P2003"
3
+ RECORD_NOT_FOUND = "P2025"
5
4
  }
6
5
  export { PrismaErrorEnum };
@@ -23,5 +23,4 @@ var PrismaErrorEnum;
23
23
  (function (PrismaErrorEnum) {
24
24
  PrismaErrorEnum["RECORD_ALREADY_EXISTS"] = "P2002";
25
25
  PrismaErrorEnum["RECORD_NOT_FOUND"] = "P2025";
26
- PrismaErrorEnum["FAILED_PRECONDITION"] = "P2003";
27
26
  })(PrismaErrorEnum || (exports.PrismaErrorEnum = PrismaErrorEnum = {}));