@promptbook/utils 0.105.0-14 → 0.105.0-15

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.
@@ -1,6 +1,7 @@
1
1
  import { Message } from '../../../types/Message';
2
+ import type { ToolCall } from '../../../types/ToolCall';
2
3
  import type { id, string_markdown } from '../../../types/typeAliases';
3
- import type { TODO_any } from '../../../utils/organization/TODO_any';
4
+ export type ChatToolCall = ToolCall;
4
5
  /**
5
6
  * Represents a single message within a chat interface.
6
7
  *
@@ -37,45 +38,17 @@ export type ChatMessage = Omit<Message<id>, 'direction' | 'recipients' | 'thread
37
38
  /**
38
39
  * Optional tool calls made during the execution
39
40
  */
40
- readonly ongoingToolCalls?: ReadonlyArray<{
41
- /**
42
- * Name of the tool
43
- */
44
- readonly name: string;
45
- /**
46
- * Arguments for the tool call
47
- */
48
- readonly arguments?: string | Record<string, TODO_any>;
49
- /**
50
- * Result of the tool call
51
- */
52
- readonly result?: TODO_any;
53
- /**
54
- * Raw tool call from the model
55
- */
56
- readonly rawToolCall?: TODO_any;
57
- }>;
41
+ readonly ongoingToolCalls?: ReadonlyArray<ChatToolCall>;
42
+ /**
43
+ * Optional tool calls used to produce this message.
44
+ */
45
+ readonly toolCalls?: ReadonlyArray<ChatToolCall>;
58
46
  /**
59
47
  * Optional tool calls that have been completed
48
+ *
49
+ * @deprecated Use `toolCalls` instead.
60
50
  */
61
- readonly completedToolCalls?: ReadonlyArray<{
62
- /**
63
- * Name of the tool
64
- */
65
- readonly name: string;
66
- /**
67
- * Arguments for the tool call
68
- */
69
- readonly arguments?: string | Record<string, TODO_any>;
70
- /**
71
- * Result of the tool call
72
- */
73
- readonly result?: TODO_any;
74
- /**
75
- * Raw tool call from the model
76
- */
77
- readonly rawToolCall?: TODO_any;
78
- }>;
51
+ readonly completedToolCalls?: ReadonlyArray<ChatToolCall>;
79
52
  /**
80
53
  * Optional file attachments
81
54
  */
@@ -1,4 +1,4 @@
1
- import type { TODO_any } from '../../../utils/organization/TODO_any';
1
+ import type { ToolCall } from '../../../types/ToolCall';
2
2
  /**
3
3
  * Utility to format tool call information for user-friendly display.
4
4
  */
@@ -16,7 +16,4 @@ export declare const TOOL_TITLES: Record<string, {
16
16
  *
17
17
  * @private [🧠] Maybe public?
18
18
  */
19
- export declare function getToolCallChipletText(toolCall: {
20
- name: string;
21
- arguments?: string | Record<string, TODO_any>;
22
- }): string;
19
+ export declare function getToolCallChipletText(toolCall: ToolCall): string;
@@ -0,0 +1,41 @@
1
+ import type { ToolCall } from '../../../types/ToolCall';
2
+ import type { TODO_any } from '../../../utils/organization/TODO_any';
3
+ /**
4
+ * @@@
5
+ *
6
+ * @private utility of `<Chat/>` component
7
+ */
8
+ export declare function parseToolCallArguments(toolCall: Pick<ToolCall, 'arguments'>): Record<string, TODO_any>;
9
+ /**
10
+ * @@@
11
+ *
12
+ * @private utility of `<Chat/>` component
13
+ */
14
+ export declare function parseToolCallResult(result: ToolCall['result']): TODO_any;
15
+ type SearchResultsExtraction = {
16
+ results: Array<TODO_any>;
17
+ rawText: string | null;
18
+ };
19
+ /**
20
+ * @@@
21
+ *
22
+ * @private utility of `<Chat/>` component
23
+ */
24
+ export declare function extractSearchResults(resultRaw: TODO_any): SearchResultsExtraction;
25
+ /**
26
+ * @@@
27
+ *
28
+ * @private utility of `<Chat/>` component
29
+ */
30
+ export declare function getToolCallTimestamp(toolCall: Pick<ToolCall, 'createdAt'>): Date | null;
31
+ /**
32
+ * @@@
33
+ *
34
+ * @private utility of `<Chat/>` component
35
+ */
36
+ export declare function getToolCallResultDate(result: ToolCall['result']): Date | null;
37
+ export {};
38
+ /**
39
+ * Note: [💞] Ignore a discrepancy between file name and entity name
40
+ * <- TODO: But maybe split into multiple files later?
41
+ */
@@ -21,6 +21,7 @@ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
21
21
  */
22
22
  export declare class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition<'USE SEARCH ENGINE'> {
23
23
  constructor();
24
+ get requiresContent(): boolean;
24
25
  /**
25
26
  * Short one-line description of USE SEARCH ENGINE.
26
27
  */
@@ -11,12 +11,14 @@ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
11
11
  *
12
12
  * ```book
13
13
  * USE TIME
14
+ * USE TIME Prefer the user's local timezone.
14
15
  * ```
15
16
  *
16
17
  * @private [🪔] Maybe export the commitments through some package
17
18
  */
18
19
  export declare class UseTimeCommitmentDefinition extends BaseCommitmentDefinition<'USE TIME'> {
19
20
  constructor();
21
+ get requiresContent(): boolean;
20
22
  /**
21
23
  * Short one-line description of USE TIME.
22
24
  */
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @@@
3
+ *
4
+ * @private utility for commitments
5
+ */
6
+ export declare function formatOptionalInstructionBlock(label: string, content: string): string;
@@ -71,6 +71,131 @@ export declare const RESERVED_PARAMETER_RESTRICTED: string;
71
71
  * @public exported from `@promptbook/core`
72
72
  */
73
73
  export declare const RESERVED_PARAMETER_NAMES: readonly ["content", "context", "knowledge", "examples", "modelName", "currentDate"];
74
+ /**
75
+ * Limits for IDs, names, and other strings
76
+ *
77
+ * @public exported from `@promptbook/core`
78
+ */
79
+ export declare const LIMITS: {
80
+ /**
81
+ * Minimum length of a name (e.g. agent name, persona name)
82
+ */
83
+ readonly NAME_MIN_LENGTH: 3;
84
+ /**
85
+ * Recommended maximum length of a name
86
+ */
87
+ readonly NAME_MAX_LENGTH: 20;
88
+ /**
89
+ * Maximum length of a short description or a hash
90
+ */
91
+ readonly SHORT_TEXT_MAX_LENGTH: 30;
92
+ /**
93
+ * Gone
94
+ */
95
+ readonly GONE: 410;
96
+ /**
97
+ * Gateway timeout
98
+ */
99
+ readonly GATEWAY_TIMEOUT: 504;
100
+ /**
101
+ * Too many requests
102
+ */
103
+ readonly TOO_MANY_REQUESTS: 429;
104
+ /**
105
+ * Maximum length of a file path segment
106
+ */
107
+ readonly FILE_PATH_SEGMENT_MAX_LENGTH: 8;
108
+ /**
109
+ * Default length of a short name (e.g. for default agent names)
110
+ */
111
+ readonly SHORT_NAME_LENGTH: 6;
112
+ };
113
+ /**
114
+ * Common time intervals in milliseconds
115
+ *
116
+ * @public exported from `@promptbook/core`
117
+ */
118
+ export declare const TIME_INTERVALS: {
119
+ /**
120
+ * One second in milliseconds
121
+ */
122
+ readonly SECOND: 1000;
123
+ /**
124
+ * Two seconds in milliseconds
125
+ */
126
+ readonly TWO_SECONDS: 2000;
127
+ /**
128
+ * One minute in milliseconds
129
+ */
130
+ readonly MINUTE: 60000;
131
+ /**
132
+ * Thirty seconds in milliseconds
133
+ */
134
+ readonly THIRTY_SECONDS: 30000;
135
+ /**
136
+ * Five seconds in milliseconds
137
+ */
138
+ readonly FIVE_SECONDS: 5000;
139
+ };
140
+ /**
141
+ * Common ports and network limits
142
+ *
143
+ * @public exported from `@promptbook/core`
144
+ */
145
+ export declare const NETWORK_LIMITS: {
146
+ /**
147
+ * Maximum valid port number
148
+ */
149
+ readonly MAX_PORT: 65535;
150
+ };
151
+ /**
152
+ * Common color and image constants
153
+ *
154
+ * @public exported from `@promptbook/core`
155
+ */
156
+ export declare const COLOR_CONSTANTS: {
157
+ /**
158
+ * Maximum value for a color channel (0-255)
159
+ */
160
+ readonly MAX_CHANNEL_VALUE: 255;
161
+ /**
162
+ * Number of possible colors in 24-bit color (0xFFFFFF)
163
+ */
164
+ readonly MAX_24BIT_COLOR: 16777215;
165
+ /**
166
+ * Base for hexadecimal strings
167
+ */
168
+ readonly HEX_BASE: 16;
169
+ /**
170
+ * Length of a hex color without alpha (e.g. "FF0000")
171
+ */
172
+ readonly HEX_COLOR_LENGTH: 6;
173
+ /**
174
+ * Full circle in degrees
175
+ */
176
+ readonly FULL_CIRCLE_DEGREES: 360;
177
+ /**
178
+ * Half circle in degrees
179
+ */
180
+ readonly HALF_CIRCLE_DEGREES: 180;
181
+ };
182
+ /**
183
+ * HTTP Status Codes
184
+ *
185
+ * @public exported from `@promptbook/core`
186
+ */
187
+ export declare const HTTP_STATUS_CODES: {
188
+ readonly OK: 200;
189
+ readonly CREATED: 201;
190
+ readonly BAD_REQUEST: 400;
191
+ readonly UNAUTHORIZED: 401;
192
+ readonly NOT_FOUND: 404;
193
+ readonly INTERNAL_SERVER_ERROR: 500;
194
+ readonly BAD_GATEWAY: 502;
195
+ readonly SERVICE_UNAVAILABLE: 503;
196
+ readonly GATEWAY_TIMEOUT: 504;
197
+ readonly TOO_MANY_REQUESTS: 429;
198
+ };
74
199
  /**
75
200
  * Note: [💞] Ignore a discrepancy between file name and entity name
76
201
  */
@@ -1,5 +1,5 @@
1
+ import type { ToolCall } from '../types/ToolCall';
1
2
  import type { string_date_iso8601, string_model_name, string_prompt } from '../types/typeAliases';
2
- import type { TODO_any } from '../utils/organization/TODO_any';
3
3
  import type { TODO_object } from '../utils/organization/TODO_object';
4
4
  import type { EmbeddingVector } from './EmbeddingVector';
5
5
  import type { Usage } from './Usage';
@@ -26,24 +26,7 @@ export type ChatPromptResult = CommonPromptResult & {
26
26
  /**
27
27
  * Optional tool calls made during the execution
28
28
  */
29
- readonly toolCalls?: ReadonlyArray<{
30
- /**
31
- * Name of the tool
32
- */
33
- readonly name: string;
34
- /**
35
- * Arguments of the tool call
36
- */
37
- readonly arguments: string;
38
- /**
39
- * Result of the tool call
40
- */
41
- readonly result: string;
42
- /**
43
- * Raw tool call from the model
44
- */
45
- readonly rawToolCall: TODO_any;
46
- }>;
29
+ readonly toolCalls?: ReadonlyArray<ToolCall>;
47
30
  };
48
31
  /**
49
32
  * Image prompt result
@@ -0,0 +1,37 @@
1
+ import type { string_date_iso8601 } from './typeAliases';
2
+ import type { TODO_any } from '../utils/organization/TODO_any';
3
+ /**
4
+ * Represents a single tool call with its inputs, outputs, and timing.
5
+ *
6
+ * Note: This is fully serializable as JSON.
7
+ */
8
+ export type ToolCall = {
9
+ /**
10
+ * Name of the tool.
11
+ */
12
+ readonly name: string;
13
+ /**
14
+ * Arguments for the tool call.
15
+ */
16
+ readonly arguments?: string | Record<string, TODO_any>;
17
+ /**
18
+ * Result of the tool call.
19
+ */
20
+ readonly result?: TODO_any;
21
+ /**
22
+ * Raw tool call payload from the model.
23
+ */
24
+ readonly rawToolCall?: TODO_any;
25
+ /**
26
+ * Timestamp when the tool call was initiated.
27
+ */
28
+ readonly createdAt?: string_date_iso8601;
29
+ /**
30
+ * Errors thrown during tool execution.
31
+ */
32
+ readonly errors?: ReadonlyArray<TODO_any>;
33
+ /**
34
+ * Warnings reported during tool execution.
35
+ */
36
+ readonly warnings?: ReadonlyArray<TODO_any>;
37
+ };
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.105.0-13`).
18
+ * It follows semantic versioning (e.g., `0.105.0-14`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/utils",
3
- "version": "0.105.0-14",
3
+ "version": "0.105.0-15",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.105.0-14';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.105.0-15';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name