@promptbook/node 0.89.0-9 → 0.92.0-10

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 (56) hide show
  1. package/README.md +9 -7
  2. package/esm/index.es.js +320 -97
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/servers.d.ts +40 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +14 -4
  6. package/esm/typings/src/_packages/deepseek.index.d.ts +2 -0
  7. package/esm/typings/src/_packages/google.index.d.ts +2 -0
  8. package/esm/typings/src/_packages/types.index.d.ts +18 -0
  9. package/esm/typings/src/_packages/utils.index.d.ts +6 -0
  10. package/esm/typings/src/cli/cli-commands/login.d.ts +0 -1
  11. package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +16 -3
  12. package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
  13. package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +2 -0
  14. package/esm/typings/src/config.d.ts +10 -19
  15. package/esm/typings/src/conversion/archive/loadArchive.d.ts +2 -2
  16. package/esm/typings/src/errors/0-index.d.ts +7 -4
  17. package/esm/typings/src/errors/PipelineExecutionError.d.ts +1 -1
  18. package/esm/typings/src/errors/WrappedError.d.ts +10 -0
  19. package/esm/typings/src/errors/assertsError.d.ts +11 -0
  20. package/esm/typings/src/execution/CommonToolsOptions.d.ts +4 -0
  21. package/esm/typings/src/execution/PromptbookFetch.d.ts +1 -1
  22. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +12 -0
  23. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +5 -0
  24. package/esm/typings/src/formats/csv/utils/csvParse.d.ts +12 -0
  25. package/esm/typings/src/formats/csv/utils/isValidCsvString.d.ts +9 -0
  26. package/esm/typings/src/formats/csv/utils/isValidCsvString.test.d.ts +1 -0
  27. package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +3 -0
  28. package/esm/typings/src/formats/json/utils/jsonParse.d.ts +11 -0
  29. package/esm/typings/src/formats/xml/utils/isValidXmlString.d.ts +9 -0
  30. package/esm/typings/src/formats/xml/utils/isValidXmlString.test.d.ts +1 -0
  31. package/esm/typings/src/llm-providers/_common/filterModels.d.ts +15 -0
  32. package/esm/typings/src/llm-providers/_common/register/{$provideEnvFilepath.d.ts → $provideEnvFilename.d.ts} +2 -2
  33. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
  34. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  35. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizzardOrCli.d.ts +11 -2
  36. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -1
  37. package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +43 -0
  38. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -0
  39. package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +23 -0
  40. package/esm/typings/src/llm-providers/google/google-models.d.ts +23 -0
  41. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +4 -0
  42. package/esm/typings/src/personas/preparePersona.d.ts +1 -1
  43. package/esm/typings/src/pipeline/PipelineJson/PersonaJson.d.ts +4 -2
  44. package/esm/typings/src/remote-server/openapi-types.d.ts +626 -0
  45. package/esm/typings/src/remote-server/openapi.d.ts +581 -0
  46. package/esm/typings/src/remote-server/socket-types/_subtypes/Identification.d.ts +7 -1
  47. package/esm/typings/src/remote-server/socket-types/_subtypes/identificationToPromptbookToken.d.ts +11 -0
  48. package/esm/typings/src/remote-server/socket-types/_subtypes/promptbookTokenToIdentification.d.ts +10 -0
  49. package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -2
  50. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +15 -9
  51. package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +40 -0
  52. package/esm/typings/src/types/typeAliases.d.ts +26 -0
  53. package/package.json +9 -5
  54. package/umd/index.umd.js +320 -97
  55. package/umd/index.umd.js.map +1 -1
  56. package/esm/typings/src/cli/test/ptbk2.d.ts +0 -5
@@ -0,0 +1,581 @@
1
+ /**
2
+ * @private !!!! Decide how to expose this
3
+ */
4
+ export declare const openapiJson: {
5
+ openapi: string;
6
+ info: {
7
+ title: string;
8
+ version: string;
9
+ description: string;
10
+ };
11
+ paths: {
12
+ '/': {
13
+ get: {
14
+ summary: string;
15
+ description: string;
16
+ responses: {
17
+ '200': {
18
+ description: string;
19
+ content: {
20
+ 'text/markdown': {
21
+ schema: {
22
+ type: string;
23
+ };
24
+ };
25
+ };
26
+ };
27
+ };
28
+ };
29
+ };
30
+ '/login': {
31
+ post: {
32
+ summary: string;
33
+ description: string;
34
+ requestBody: {
35
+ required: boolean;
36
+ content: {
37
+ 'application/json': {
38
+ schema: {
39
+ type: string;
40
+ properties: {
41
+ username: {
42
+ type: string;
43
+ };
44
+ password: {
45
+ type: string;
46
+ };
47
+ appId: {
48
+ type: string;
49
+ };
50
+ };
51
+ };
52
+ };
53
+ };
54
+ };
55
+ responses: {
56
+ '201': {
57
+ description: string;
58
+ content: {
59
+ 'application/json': {
60
+ schema: {
61
+ type: string;
62
+ properties: {
63
+ isSuccess: {
64
+ type: string;
65
+ };
66
+ message: {
67
+ type: string;
68
+ };
69
+ error: {
70
+ type: string;
71
+ };
72
+ identification: {
73
+ type: string;
74
+ };
75
+ };
76
+ };
77
+ };
78
+ };
79
+ };
80
+ '400': {
81
+ description: string;
82
+ content: {
83
+ 'application/json': {
84
+ schema: {
85
+ type: string;
86
+ properties: {
87
+ error: {
88
+ type: string;
89
+ };
90
+ };
91
+ };
92
+ };
93
+ };
94
+ };
95
+ '401': {
96
+ description: string;
97
+ content: {
98
+ 'application/json': {
99
+ schema: {
100
+ type: string;
101
+ properties: {
102
+ isSuccess: {
103
+ type: string;
104
+ enum: boolean[];
105
+ };
106
+ message: {
107
+ type: string;
108
+ };
109
+ error: {
110
+ type: string;
111
+ };
112
+ };
113
+ };
114
+ };
115
+ };
116
+ };
117
+ };
118
+ };
119
+ };
120
+ '/books': {
121
+ get: {
122
+ summary: string;
123
+ description: string;
124
+ responses: {
125
+ '200': {
126
+ description: string;
127
+ content: {
128
+ 'application/json': {
129
+ schema: {
130
+ type: string;
131
+ items: {
132
+ type: string;
133
+ };
134
+ };
135
+ };
136
+ };
137
+ };
138
+ '500': {
139
+ description: string;
140
+ content: {
141
+ 'text/plain': {
142
+ schema: {
143
+ type: string;
144
+ };
145
+ };
146
+ };
147
+ };
148
+ };
149
+ };
150
+ };
151
+ '/books/{bookId}': {
152
+ get: {
153
+ summary: string;
154
+ description: string;
155
+ parameters: {
156
+ in: string;
157
+ name: string;
158
+ required: boolean;
159
+ schema: {
160
+ type: string;
161
+ };
162
+ description: string;
163
+ }[];
164
+ responses: {
165
+ '200': {
166
+ description: string;
167
+ content: {
168
+ 'text/markdown': {
169
+ schema: {
170
+ type: string;
171
+ };
172
+ };
173
+ };
174
+ };
175
+ '404': {
176
+ description: string;
177
+ content: {
178
+ 'application/json': {
179
+ schema: {
180
+ type: string;
181
+ properties: {
182
+ error: {
183
+ type: string;
184
+ };
185
+ };
186
+ };
187
+ };
188
+ };
189
+ };
190
+ '500': {
191
+ description: string;
192
+ content: {
193
+ 'text/plain': {
194
+ schema: {
195
+ type: string;
196
+ };
197
+ };
198
+ };
199
+ };
200
+ };
201
+ };
202
+ };
203
+ '/executions': {
204
+ get: {
205
+ summary: string;
206
+ description: string;
207
+ responses: {
208
+ '200': {
209
+ description: string;
210
+ content: {
211
+ 'application/json': {
212
+ schema: {
213
+ type: string;
214
+ items: {
215
+ type: string;
216
+ properties: {
217
+ nonce: {
218
+ type: string;
219
+ };
220
+ taskId: {
221
+ type: string;
222
+ };
223
+ taskType: {
224
+ type: string;
225
+ };
226
+ status: {
227
+ type: string;
228
+ };
229
+ createdAt: {
230
+ type: string;
231
+ format: string;
232
+ };
233
+ updatedAt: {
234
+ type: string;
235
+ format: string;
236
+ };
237
+ };
238
+ };
239
+ };
240
+ };
241
+ };
242
+ };
243
+ };
244
+ };
245
+ };
246
+ '/executions/last': {
247
+ get: {
248
+ summary: string;
249
+ description: string;
250
+ responses: {
251
+ '200': {
252
+ description: string;
253
+ content: {
254
+ 'application/json': {
255
+ schema: {
256
+ type: string;
257
+ properties: {
258
+ nonce: {
259
+ type: string;
260
+ };
261
+ taskId: {
262
+ type: string;
263
+ };
264
+ taskType: {
265
+ type: string;
266
+ };
267
+ status: {
268
+ type: string;
269
+ };
270
+ errors: {
271
+ type: string;
272
+ items: {
273
+ type: string;
274
+ };
275
+ };
276
+ warnings: {
277
+ type: string;
278
+ items: {
279
+ type: string;
280
+ };
281
+ };
282
+ createdAt: {
283
+ type: string;
284
+ format: string;
285
+ };
286
+ updatedAt: {
287
+ type: string;
288
+ format: string;
289
+ };
290
+ currentValue: {
291
+ type: string;
292
+ };
293
+ };
294
+ };
295
+ };
296
+ };
297
+ };
298
+ '404': {
299
+ description: string;
300
+ content: {
301
+ 'text/plain': {
302
+ schema: {
303
+ type: string;
304
+ };
305
+ };
306
+ };
307
+ };
308
+ };
309
+ };
310
+ };
311
+ '/executions/{taskId}': {
312
+ get: {
313
+ summary: string;
314
+ description: string;
315
+ parameters: {
316
+ in: string;
317
+ name: string;
318
+ required: boolean;
319
+ schema: {
320
+ type: string;
321
+ };
322
+ description: string;
323
+ }[];
324
+ responses: {
325
+ '200': {
326
+ description: string;
327
+ content: {
328
+ 'application/json': {
329
+ schema: {
330
+ type: string;
331
+ properties: {
332
+ nonce: {
333
+ type: string;
334
+ };
335
+ taskId: {
336
+ type: string;
337
+ };
338
+ taskType: {
339
+ type: string;
340
+ };
341
+ status: {
342
+ type: string;
343
+ };
344
+ errors: {
345
+ type: string;
346
+ items: {
347
+ type: string;
348
+ };
349
+ };
350
+ warnings: {
351
+ type: string;
352
+ items: {
353
+ type: string;
354
+ };
355
+ };
356
+ createdAt: {
357
+ type: string;
358
+ format: string;
359
+ };
360
+ updatedAt: {
361
+ type: string;
362
+ format: string;
363
+ };
364
+ currentValue: {
365
+ type: string;
366
+ };
367
+ };
368
+ };
369
+ };
370
+ };
371
+ };
372
+ '404': {
373
+ description: string;
374
+ content: {
375
+ 'text/plain': {
376
+ schema: {
377
+ type: string;
378
+ };
379
+ };
380
+ };
381
+ };
382
+ };
383
+ };
384
+ };
385
+ '/executions/new': {
386
+ post: {
387
+ summary: string;
388
+ description: string;
389
+ requestBody: {
390
+ required: boolean;
391
+ content: {
392
+ 'application/json': {
393
+ schema: {
394
+ type: string;
395
+ properties: {
396
+ pipelineUrl: {
397
+ type: string;
398
+ description: string;
399
+ };
400
+ book: {
401
+ type: string;
402
+ description: string;
403
+ };
404
+ inputParameters: {
405
+ type: string;
406
+ description: string;
407
+ };
408
+ identification: {
409
+ type: string;
410
+ description: string;
411
+ };
412
+ };
413
+ };
414
+ };
415
+ };
416
+ };
417
+ responses: {
418
+ '200': {
419
+ description: string;
420
+ content: {
421
+ 'application/json': {
422
+ schema: {
423
+ type: string;
424
+ };
425
+ };
426
+ };
427
+ };
428
+ '400': {
429
+ description: string;
430
+ content: {
431
+ 'application/json': {
432
+ schema: {
433
+ type: string;
434
+ properties: {
435
+ error: {
436
+ type: string;
437
+ };
438
+ };
439
+ };
440
+ };
441
+ };
442
+ };
443
+ '404': {
444
+ description: string;
445
+ content: {
446
+ 'text/plain': {
447
+ schema: {
448
+ type: string;
449
+ };
450
+ };
451
+ };
452
+ };
453
+ };
454
+ };
455
+ };
456
+ '/api-docs': {
457
+ get: {
458
+ summary: string;
459
+ description: string;
460
+ responses: {
461
+ '200': {
462
+ description: string;
463
+ };
464
+ };
465
+ };
466
+ };
467
+ '/swagger': {
468
+ get: {
469
+ summary: string;
470
+ description: string;
471
+ responses: {
472
+ '200': {
473
+ description: string;
474
+ };
475
+ };
476
+ };
477
+ };
478
+ '/openapi': {
479
+ get: {
480
+ summary: string;
481
+ description: string;
482
+ responses: {
483
+ '200': {
484
+ description: string;
485
+ content: {
486
+ 'application/json': {
487
+ schema: {
488
+ type: string;
489
+ };
490
+ };
491
+ };
492
+ };
493
+ };
494
+ };
495
+ };
496
+ };
497
+ components: {
498
+ schemas: {
499
+ Error: {
500
+ type: string;
501
+ properties: {
502
+ error: {
503
+ type: string;
504
+ };
505
+ };
506
+ };
507
+ ExecutionTaskSummary: {
508
+ type: string;
509
+ properties: {
510
+ nonce: {
511
+ type: string;
512
+ };
513
+ taskId: {
514
+ type: string;
515
+ };
516
+ taskType: {
517
+ type: string;
518
+ };
519
+ status: {
520
+ type: string;
521
+ };
522
+ createdAt: {
523
+ type: string;
524
+ format: string;
525
+ };
526
+ updatedAt: {
527
+ type: string;
528
+ format: string;
529
+ };
530
+ };
531
+ };
532
+ ExecutionTaskFull: {
533
+ type: string;
534
+ properties: {
535
+ nonce: {
536
+ type: string;
537
+ };
538
+ taskId: {
539
+ type: string;
540
+ };
541
+ taskType: {
542
+ type: string;
543
+ };
544
+ status: {
545
+ type: string;
546
+ };
547
+ errors: {
548
+ type: string;
549
+ items: {
550
+ type: string;
551
+ };
552
+ };
553
+ warnings: {
554
+ type: string;
555
+ items: {
556
+ type: string;
557
+ };
558
+ };
559
+ createdAt: {
560
+ type: string;
561
+ format: string;
562
+ };
563
+ updatedAt: {
564
+ type: string;
565
+ format: string;
566
+ };
567
+ currentValue: {
568
+ type: string;
569
+ };
570
+ };
571
+ };
572
+ };
573
+ };
574
+ tags: {
575
+ name: string;
576
+ description: string;
577
+ }[];
578
+ };
579
+ /**
580
+ * Note: [💞] Ignore a discrepancy between file name and entity name
581
+ */
@@ -1,4 +1,5 @@
1
1
  import type { LlmToolsConfiguration } from '../../../llm-providers/_common/register/LlmToolsConfiguration';
2
+ import type { string_ip_address } from '../../../types/typeAliases';
2
3
  import type { string_user_id } from '../../../types/typeAliases';
3
4
  import type { ApplicationRemoteServerClientOptions } from '../../types/RemoteServerOptions';
4
5
  /**
@@ -7,7 +8,12 @@ import type { ApplicationRemoteServerClientOptions } from '../../types/RemoteSer
7
8
  * @public exported from `@promptbook/remote-server`
8
9
  * @public exported from `@promptbook/remote-client`
9
10
  */
10
- export type Identification<TCustomOptions> = ApplicationModeIdentification<TCustomOptions> | AnonymousModeIdentification;
11
+ export type Identification<TCustomOptions> = (ApplicationModeIdentification<TCustomOptions> | AnonymousModeIdentification) & {
12
+ /**
13
+ * Identifier of the IP address of the client
14
+ */
15
+ readonly ipAddress?: string_ip_address;
16
+ };
11
17
  /**
12
18
  * Application mode is situation when you run known and well-defined books with your own api keys
13
19
  *
@@ -0,0 +1,11 @@
1
+ import type { string_promptbook_token } from '../../../types/typeAliases';
2
+ import type { really_unknown } from '../../../utils/organization/really_unknown';
3
+ import type { ApplicationModeIdentification } from './Identification';
4
+ /**
5
+ * Convert identification to Promptbook token
6
+ *
7
+ * @param identification
8
+ *
9
+ * @public exported from `@promptbook/core`
10
+ */
11
+ export declare function identificationToPromptbookToken(identification: ApplicationModeIdentification<really_unknown>): string_promptbook_token;
@@ -0,0 +1,10 @@
1
+ import type { string_promptbook_token } from '../../../types/typeAliases';
2
+ import type { ApplicationModeIdentification } from './Identification';
3
+ /**
4
+ * Convert Promptbook token to identification
5
+ *
6
+ * @param promptbookToken
7
+ *
8
+ * @public exported from `@promptbook/core`
9
+ */
10
+ export declare function promptbookTokenToIdentification(promptbookToken: string_promptbook_token): ApplicationModeIdentification<undefined>;
@@ -11,8 +11,7 @@ import type { RemoteServerOptions } from './types/RemoteServerOptions';
11
11
  */
12
12
  export declare function startRemoteServer<TCustomOptions = undefined>(options: RemoteServerOptions<TCustomOptions>): RemoteServer;
13
13
  /**
14
- * TODO: !! Add CORS and security - probbably via `helmet`
15
- * TODO: [👩🏾‍🤝‍🧑🏾] Allow to pass custom fetch function here - PromptbookFetch
14
+ * TODO: [🌡] Add CORS and security - probbably via `helmet`
16
15
  * TODO: Split this file into multiple functions - handler for each request
17
16
  * TODO: Maybe use `$exportJson`
18
17
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
@@ -3,12 +3,14 @@ import type { Promisable } from 'type-fest';
3
3
  import type { PipelineCollection } from '../../collection/PipelineCollection';
4
4
  import { AuthenticationError } from '../../errors/AuthenticationError';
5
5
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
6
+ import type { ExecutionTools } from '../../execution/ExecutionTools';
6
7
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
7
8
  import type { string_app_id } from '../../types/typeAliases';
8
9
  import type { string_email } from '../../types/typeAliases';
9
10
  import type { string_password } from '../../types/typeAliases';
10
- import type { string_uri } from '../../types/typeAliases';
11
+ import type { string_token } from '../../types/typeAliases';
11
12
  import type { string_user_id } from '../../types/typeAliases';
13
+ import type { ApplicationModeIdentification } from '../socket-types/_subtypes/Identification';
12
14
  import type { Identification } from '../socket-types/_subtypes/Identification';
13
15
  /**
14
16
  * @@@
@@ -29,14 +31,18 @@ export type RemoteServerOptions<TCustomOptions> = CommonToolsOptions & {
29
31
  */
30
32
  readonly port: number;
31
33
  /**
32
- * Root path of the server
34
+ * Creates execution tools the client
33
35
  *
34
- * Note: This is useful when you reverse proxy the server without changing the path
36
+ * This is relevant also in anonymous mode in oposition to `createLlmExecutionTools`
35
37
  *
36
- * @default '/'
37
- * @example '/api/promptbook/'
38
- */
39
- readonly rootPath?: string_uri;
38
+ * Note: You can provide only some tools and leave the rest to the default ones also llm tools are created by `createLlmExecutionTools`
39
+ * Note: This is useful when you want to provide some custom restrictions for example:
40
+ * - Limit access to certain websites for some users
41
+ * - Bind user-interface tools to email agent
42
+ * - Allow / block script execution
43
+ * - And many more
44
+ */
45
+ createExecutionTools?(options: Identification<TCustomOptions>): Promisable<Partial<Omit<ExecutionTools, 'llm'>>>;
40
46
  } & ((AnonymousRemoteServerOptions & {
41
47
  readonly isApplicationModeAllowed?: false;
42
48
  }) | ({
@@ -74,7 +80,7 @@ export type ApplicationRemoteServerOptions<TCustomOptions> = {
74
80
  /**
75
81
  * Creates llm execution tools for each client
76
82
  */
77
- createLlmExecutionTools(options: ApplicationRemoteServerClientOptions<TCustomOptions>): Promisable<LlmExecutionTools>;
83
+ createLlmExecutionTools(options: ApplicationModeIdentification<TCustomOptions>): Promisable<LlmExecutionTools>;
78
84
  };
79
85
  export type ApplicationRemoteServerClientOptions<TCustomOptions> = {
80
86
  /**
@@ -96,7 +102,7 @@ export type ApplicationRemoteServerClientOptions<TCustomOptions> = {
96
102
  *
97
103
  * Note: This is passed for example to `createLlmExecutionTools`
98
104
  */
99
- readonly userToken?: string_user_id;
105
+ readonly userToken?: string_token;
100
106
  /**
101
107
  * Additional arbitrary options to identify the client or to pass custom metadata
102
108
  */