@promptbook/wizard 0.105.0-3 → 0.105.0-5
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/README.md +36 -77
- package/esm/index.es.js +122 -12
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/browser.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +12 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +3 -6
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +9 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +3 -1
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +7 -0
- package/esm/typings/src/search-engines/_index.d.ts +6 -0
- package/esm/typings/src/search-engines/google/GoogleSearchEngine.d.ts +18 -0
- package/esm/typings/src/search-engines/serp/SerpSearchEngine.d.ts +15 -0
- package/esm/typings/src/speech-recognition/BrowserSpeechRecognition.d.ts +21 -0
- package/esm/typings/src/speech-recognition/OpenAiSpeechRecognition.d.ts +32 -0
- package/esm/typings/src/types/SpeechRecognition.d.ts +58 -0
- package/esm/typings/src/types/typeAliases.d.ts +4 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +122 -12
- package/umd/index.umd.js.map +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
2
2
|
import { SimplePromptInterfaceTools } from '../dialogs/simple-prompt/SimplePromptInterfaceTools';
|
|
3
3
|
import { $provideScrapersForBrowser } from '../scrapers/_common/register/$provideScrapersForBrowser';
|
|
4
|
+
import { BrowserSpeechRecognition } from '../speech-recognition/BrowserSpeechRecognition';
|
|
4
5
|
import { getIndexedDbStorage } from '../storage/local-storage/getIndexedDbStorage';
|
|
5
6
|
import { getLocalStorage } from '../storage/local-storage/getLocalStorage';
|
|
6
7
|
import { getSessionStorage } from '../storage/local-storage/getSessionStorage';
|
|
@@ -10,6 +11,7 @@ import { ObjectUrl } from '../utils/files/ObjectUrl';
|
|
|
10
11
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
11
12
|
export { SimplePromptInterfaceTools };
|
|
12
13
|
export { $provideScrapersForBrowser };
|
|
14
|
+
export { BrowserSpeechRecognition };
|
|
13
15
|
export { getIndexedDbStorage };
|
|
14
16
|
export { getLocalStorage };
|
|
15
17
|
export { getSessionStorage };
|
|
@@ -183,6 +183,7 @@ import type { PostprocessingFunction } from '../scripting/javascript/JavascriptE
|
|
|
183
183
|
import type { ToolFunction } from '../scripting/javascript/JavascriptExecutionToolsOptions';
|
|
184
184
|
import type { SearchEngine } from '../search-engines/SearchEngine';
|
|
185
185
|
import type { SearchResult } from '../search-engines/SearchResult';
|
|
186
|
+
import type { OpenAiSpeechRecognitionOptions } from '../speech-recognition/OpenAiSpeechRecognition';
|
|
186
187
|
import type { PromptbookStorage } from '../storage/_common/PromptbookStorage';
|
|
187
188
|
import type { FileCacheStorageOptions } from '../storage/file-cache-storage/FileCacheStorageOptions';
|
|
188
189
|
import type { IndexedDbStorageOptions } from '../storage/local-storage/utils/IndexedDbStorageOptions';
|
|
@@ -207,6 +208,10 @@ import type { ImagePrompt } from '../types/Prompt';
|
|
|
207
208
|
import type { EmbeddingPrompt } from '../types/Prompt';
|
|
208
209
|
import type { ScriptLanguage } from '../types/ScriptLanguage';
|
|
209
210
|
import type { SectionType } from '../types/SectionType';
|
|
211
|
+
import type { SpeechRecognition } from '../types/SpeechRecognition';
|
|
212
|
+
import type { SpeechRecognitionStartOptions } from '../types/SpeechRecognition';
|
|
213
|
+
import type { SpeechRecognitionState } from '../types/SpeechRecognition';
|
|
214
|
+
import type { SpeechRecognitionEvent } from '../types/SpeechRecognition';
|
|
210
215
|
import type { TaskType } from '../types/TaskType';
|
|
211
216
|
import type { string_char_emoji } from '../types/typeAliasEmoji';
|
|
212
217
|
import type { string_business_category_name } from '../types/typeAliases';
|
|
@@ -316,6 +321,7 @@ import type { string_license_token } from '../types/typeAliases';
|
|
|
316
321
|
import type { string_password } from '../types/typeAliases';
|
|
317
322
|
import type { string_ssh_key } from '../types/typeAliases';
|
|
318
323
|
import type { string_pgp_key } from '../types/typeAliases';
|
|
324
|
+
import type { string_language } from '../types/typeAliases';
|
|
319
325
|
import type { string_date_iso8601 } from '../types/typeAliases';
|
|
320
326
|
import type { number_usd } from '../types/typeAliases';
|
|
321
327
|
import type { number_id } from '../types/typeAliases';
|
|
@@ -557,6 +563,7 @@ export type { PostprocessingFunction };
|
|
|
557
563
|
export type { ToolFunction };
|
|
558
564
|
export type { SearchEngine };
|
|
559
565
|
export type { SearchResult };
|
|
566
|
+
export type { OpenAiSpeechRecognitionOptions };
|
|
560
567
|
export type { PromptbookStorage };
|
|
561
568
|
export type { FileCacheStorageOptions };
|
|
562
569
|
export type { IndexedDbStorageOptions };
|
|
@@ -581,6 +588,10 @@ export type { ImagePrompt };
|
|
|
581
588
|
export type { EmbeddingPrompt };
|
|
582
589
|
export type { ScriptLanguage };
|
|
583
590
|
export type { SectionType };
|
|
591
|
+
export type { SpeechRecognition };
|
|
592
|
+
export type { SpeechRecognitionStartOptions };
|
|
593
|
+
export type { SpeechRecognitionState };
|
|
594
|
+
export type { SpeechRecognitionEvent };
|
|
584
595
|
export type { TaskType };
|
|
585
596
|
export type { string_char_emoji };
|
|
586
597
|
export type { string_business_category_name };
|
|
@@ -690,6 +701,7 @@ export type { string_license_token };
|
|
|
690
701
|
export type { string_password };
|
|
691
702
|
export type { string_ssh_key };
|
|
692
703
|
export type { string_pgp_key };
|
|
704
|
+
export type { string_language };
|
|
693
705
|
export type { string_date_iso8601 };
|
|
694
706
|
export type { number_usd };
|
|
695
707
|
export type { number_id };
|
|
@@ -31,7 +31,7 @@ export type AgentCapability = {
|
|
|
31
31
|
/**
|
|
32
32
|
* The type of the capability
|
|
33
33
|
*/
|
|
34
|
-
type: 'browser' | 'search-engine' | 'knowledge' | 'time';
|
|
34
|
+
type: 'browser' | 'search-engine' | 'knowledge' | 'time' | 'inheritance' | 'import';
|
|
35
35
|
/**
|
|
36
36
|
* The label to display for this capability
|
|
37
37
|
*/
|
|
@@ -40,6 +40,11 @@ export type AgentCapability = {
|
|
|
40
40
|
* The name of the icon to display for this capability
|
|
41
41
|
*/
|
|
42
42
|
iconName: string;
|
|
43
|
+
/**
|
|
44
|
+
* Optional link to another agent
|
|
45
|
+
* This is used for 'inheritance' and 'import' types
|
|
46
|
+
*/
|
|
47
|
+
agentUrl?: string_agent_url;
|
|
43
48
|
};
|
|
44
49
|
export type AgentBasicInformation = {
|
|
45
50
|
/**
|
|
@@ -5,6 +5,7 @@ import type { ChatMessage } from '../types/ChatMessage';
|
|
|
5
5
|
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
6
6
|
import { string_color } from '../../../types/typeAliases';
|
|
7
7
|
import { Color } from '../../../_packages/color.index';
|
|
8
|
+
import { SpeechRecognition } from '../../../types/SpeechRecognition';
|
|
8
9
|
/**
|
|
9
10
|
* @public exported from `@promptbook/components`
|
|
10
11
|
*/
|
|
@@ -47,13 +48,9 @@ export type ChatProps = {
|
|
|
47
48
|
*/
|
|
48
49
|
readonly isVoiceRecognitionButtonShown?: boolean;
|
|
49
50
|
/**
|
|
50
|
-
*
|
|
51
|
+
* Speech recognition provider
|
|
51
52
|
*/
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* The language code to use for voice recognition
|
|
55
|
-
*/
|
|
56
|
-
readonly voiceLanguage?: string;
|
|
53
|
+
readonly speechRecognition?: SpeechRecognition;
|
|
57
54
|
/**
|
|
58
55
|
* Optional placeholder message for the textarea
|
|
59
56
|
*
|
|
@@ -33,6 +33,15 @@ export type ChatMessage = Omit<Message<id>, 'direction' | 'recipients' | 'thread
|
|
|
33
33
|
* Indicates if the message was sent via a voice call
|
|
34
34
|
*/
|
|
35
35
|
isVoiceCall?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Optional tool calls made during the execution
|
|
38
|
+
*/
|
|
39
|
+
readonly ongoingToolCalls?: ReadonlyArray<{
|
|
40
|
+
/**
|
|
41
|
+
* Name of the tool
|
|
42
|
+
*/
|
|
43
|
+
readonly name: string;
|
|
44
|
+
}>;
|
|
36
45
|
/**
|
|
37
46
|
* Optional file attachments
|
|
38
47
|
*/
|
|
@@ -56,7 +56,9 @@ export type LlmExecutionTools = {
|
|
|
56
56
|
/**
|
|
57
57
|
* Calls a chat model with streaming
|
|
58
58
|
*/
|
|
59
|
-
callChatModelStream?(prompt: Prompt, onProgress: (chunk: ChatPromptResult
|
|
59
|
+
callChatModelStream?(prompt: Prompt, onProgress: (chunk: ChatPromptResult & {
|
|
60
|
+
isFinished?: boolean;
|
|
61
|
+
}) => void): Promise<ChatPromptResult>;
|
|
60
62
|
/**
|
|
61
63
|
* Calls a voice chat model
|
|
62
64
|
*/
|
|
@@ -39,10 +39,17 @@ export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecu
|
|
|
39
39
|
* List all available OpenAI compatible models that can be used
|
|
40
40
|
*/
|
|
41
41
|
listModels(): Promise<ReadonlyArray<AvailableModel>>;
|
|
42
|
+
/**
|
|
43
|
+
* Calls OpenAI compatible API to use a chat model.
|
|
44
|
+
*/
|
|
42
45
|
/**
|
|
43
46
|
* Calls OpenAI compatible API to use a chat model.
|
|
44
47
|
*/
|
|
45
48
|
callChatModel(prompt: Prompt): Promise<ChatPromptResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Calls OpenAI compatible API to use a chat model with streaming.
|
|
51
|
+
*/
|
|
52
|
+
callChatModelStream(prompt: Prompt, onProgress: (chunk: ChatPromptResult) => void): Promise<ChatPromptResult>;
|
|
46
53
|
/**
|
|
47
54
|
* Internal method that handles parameter retry for chat model calls
|
|
48
55
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Promisable } from 'type-fest';
|
|
2
|
+
import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
|
|
3
|
+
import type { SearchEngine } from '../SearchEngine';
|
|
4
|
+
import type { SearchResult } from '../SearchResult';
|
|
5
|
+
/**
|
|
6
|
+
* A search engine implementation that uses the Google Custom Search JSON API.
|
|
7
|
+
*
|
|
8
|
+
* @private <- TODO: !!!! Export via some package
|
|
9
|
+
*/
|
|
10
|
+
export declare class GoogleSearchEngine implements SearchEngine {
|
|
11
|
+
get title(): string_title & string_markdown_text;
|
|
12
|
+
get description(): string_markdown;
|
|
13
|
+
/**
|
|
14
|
+
* @see https://developers.google.com/custom-search/v1/overview
|
|
15
|
+
*/
|
|
16
|
+
checkConfiguration(): Promisable<void>;
|
|
17
|
+
search(query: string): Promise<SearchResult[]>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Promisable } from 'type-fest';
|
|
2
|
+
import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
|
|
3
|
+
import type { SearchEngine } from '../SearchEngine';
|
|
4
|
+
import type { SearchResult } from '../SearchResult';
|
|
5
|
+
/**
|
|
6
|
+
* A search engine implementation that uses the SerpApi to fetch Google search results.
|
|
7
|
+
*
|
|
8
|
+
* @private <- TODO: !!!! Export via some package
|
|
9
|
+
*/
|
|
10
|
+
export declare class SerpSearchEngine implements SearchEngine {
|
|
11
|
+
get title(): string_title & string_markdown_text;
|
|
12
|
+
get description(): string_markdown;
|
|
13
|
+
checkConfiguration(): Promisable<void>;
|
|
14
|
+
search(query: string): Promise<SearchResult[]>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SpeechRecognition, SpeechRecognitionEvent, SpeechRecognitionStartOptions, SpeechRecognitionState } from '../types/SpeechRecognition';
|
|
2
|
+
/**
|
|
3
|
+
* Speech recognition using Web Speech API `SpeechRecognition` available in modern browsers
|
|
4
|
+
*
|
|
5
|
+
* @public exported from `@promptbook/browser`
|
|
6
|
+
*/
|
|
7
|
+
export declare class BrowserSpeechRecognition implements SpeechRecognition {
|
|
8
|
+
private recognition;
|
|
9
|
+
private callbacks;
|
|
10
|
+
private _state;
|
|
11
|
+
get state(): SpeechRecognitionState;
|
|
12
|
+
constructor();
|
|
13
|
+
$start(options?: SpeechRecognitionStartOptions): void;
|
|
14
|
+
$stop(): void;
|
|
15
|
+
subscribe(callback: (event: SpeechRecognitionEvent) => void): () => void;
|
|
16
|
+
private emit;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* TODO: !!!! Search ACRY for `window` and put -> [🔵]
|
|
20
|
+
* Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
|
|
21
|
+
*/
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SpeechRecognition, SpeechRecognitionEvent, SpeechRecognitionStartOptions, SpeechRecognitionState } from '../types/SpeechRecognition';
|
|
2
|
+
/**
|
|
3
|
+
* Options for OpenAiSpeechRecognition
|
|
4
|
+
*/
|
|
5
|
+
export type OpenAiSpeechRecognitionOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* OpenAI API base URL or proxy endpoint
|
|
8
|
+
* @default '/api/openai/v1'
|
|
9
|
+
*/
|
|
10
|
+
readonly baseUrl?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Speech recognition using OpenAI Whisper API to transcribe audio into text
|
|
14
|
+
*
|
|
15
|
+
* @private because it requires server-client communication with a proxy endpoint
|
|
16
|
+
*
|
|
17
|
+
* Note: This implementation uses a server-side proxy to avoid exposing the OpenAI API key on the client.
|
|
18
|
+
*/
|
|
19
|
+
export declare class OpenAiSpeechRecognition implements SpeechRecognition {
|
|
20
|
+
private readonly options;
|
|
21
|
+
private mediaRecorder;
|
|
22
|
+
private audioChunks;
|
|
23
|
+
private callbacks;
|
|
24
|
+
private _state;
|
|
25
|
+
get state(): SpeechRecognitionState;
|
|
26
|
+
constructor(options?: OpenAiSpeechRecognitionOptions);
|
|
27
|
+
$start(options?: SpeechRecognitionStartOptions): Promise<void>;
|
|
28
|
+
$stop(): void;
|
|
29
|
+
private transcribe;
|
|
30
|
+
subscribe(callback: (event: SpeechRecognitionEvent) => void): () => void;
|
|
31
|
+
private emit;
|
|
32
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { string_language } from './typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for speech-to-text recognition
|
|
4
|
+
*
|
|
5
|
+
* @🚉 fully serializable as JSON
|
|
6
|
+
*/
|
|
7
|
+
export type SpeechRecognition = {
|
|
8
|
+
/**
|
|
9
|
+
* Start the speech recognition
|
|
10
|
+
*/
|
|
11
|
+
$start(options: SpeechRecognitionStartOptions): void;
|
|
12
|
+
/**
|
|
13
|
+
* Stop the speech recognition
|
|
14
|
+
*/
|
|
15
|
+
$stop(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Current state of the speech recognition
|
|
18
|
+
*/
|
|
19
|
+
readonly state: SpeechRecognitionState;
|
|
20
|
+
/**
|
|
21
|
+
* Subscribe to speech recognition events
|
|
22
|
+
*/
|
|
23
|
+
subscribe(callback: (event: SpeechRecognitionEvent) => void): () => void;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Options for starting speech recognition
|
|
27
|
+
*/
|
|
28
|
+
export type SpeechRecognitionStartOptions = {
|
|
29
|
+
/**
|
|
30
|
+
* Language for speech recognition
|
|
31
|
+
* @default 'en-US'
|
|
32
|
+
*/
|
|
33
|
+
readonly language?: string_language;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to return interim results
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
readonly interimResults?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Current state of the speech recognition
|
|
42
|
+
*/
|
|
43
|
+
export type SpeechRecognitionState = 'IDLE' | 'STARTING' | 'RECORDING' | 'TRANSCRIBING' | 'ERROR';
|
|
44
|
+
/**
|
|
45
|
+
* Event emitted by speech recognition
|
|
46
|
+
*/
|
|
47
|
+
export type SpeechRecognitionEvent = {
|
|
48
|
+
readonly type: 'START';
|
|
49
|
+
} | {
|
|
50
|
+
readonly type: 'RESULT';
|
|
51
|
+
readonly text: string;
|
|
52
|
+
readonly isFinal: boolean;
|
|
53
|
+
} | {
|
|
54
|
+
readonly type: 'ERROR';
|
|
55
|
+
readonly message: string;
|
|
56
|
+
} | {
|
|
57
|
+
readonly type: 'STOP';
|
|
58
|
+
};
|
|
@@ -668,6 +668,10 @@ export type string_license_token = string_token;
|
|
|
668
668
|
export type string_password = string;
|
|
669
669
|
export type string_ssh_key = string;
|
|
670
670
|
export type string_pgp_key = string;
|
|
671
|
+
/**
|
|
672
|
+
* Language as a string, e.g. 'en-US', 'cs-CZ', 'en'
|
|
673
|
+
*/
|
|
674
|
+
export type string_language = string;
|
|
671
675
|
/**
|
|
672
676
|
* Semantic helper for `Date.toISOString()` result
|
|
673
677
|
*
|
|
@@ -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-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.105.0-4`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/wizard",
|
|
3
|
-
"version": "0.105.0-
|
|
3
|
+
"version": "0.105.0-5",
|
|
4
4
|
"description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"module": "./esm/index.es.js",
|
|
96
96
|
"typings": "./esm/typings/src/_packages/wizard.index.d.ts",
|
|
97
97
|
"peerDependencies": {
|
|
98
|
-
"@promptbook/core": "0.105.0-
|
|
98
|
+
"@promptbook/core": "0.105.0-5"
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"@ai-sdk/deepseek": "0.1.17",
|
package/umd/index.umd.js
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
* @generated
|
|
49
49
|
* @see https://github.com/webgptorg/promptbook
|
|
50
50
|
*/
|
|
51
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-
|
|
51
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-5';
|
|
52
52
|
/**
|
|
53
53
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
54
54
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -5844,20 +5844,29 @@
|
|
|
5844
5844
|
});
|
|
5845
5845
|
return availableModels;
|
|
5846
5846
|
}
|
|
5847
|
+
/**
|
|
5848
|
+
* Calls OpenAI compatible API to use a chat model.
|
|
5849
|
+
*/
|
|
5847
5850
|
/**
|
|
5848
5851
|
* Calls OpenAI compatible API to use a chat model.
|
|
5849
5852
|
*/
|
|
5850
5853
|
async callChatModel(prompt) {
|
|
5854
|
+
return this.callChatModelStream(prompt, () => { });
|
|
5855
|
+
}
|
|
5856
|
+
/**
|
|
5857
|
+
* Calls OpenAI compatible API to use a chat model with streaming.
|
|
5858
|
+
*/
|
|
5859
|
+
async callChatModelStream(prompt, onProgress) {
|
|
5851
5860
|
// Deep clone prompt and modelRequirements to avoid mutation across calls
|
|
5852
5861
|
const clonedPrompt = JSON.parse(JSON.stringify(prompt));
|
|
5853
5862
|
// Use local Set for retried parameters to ensure independence and thread safety
|
|
5854
5863
|
const retriedUnsupportedParameters = new Set();
|
|
5855
|
-
return this.callChatModelWithRetry(clonedPrompt, clonedPrompt.modelRequirements, [], retriedUnsupportedParameters);
|
|
5864
|
+
return this.callChatModelWithRetry(clonedPrompt, clonedPrompt.modelRequirements, [], retriedUnsupportedParameters, onProgress);
|
|
5856
5865
|
}
|
|
5857
5866
|
/**
|
|
5858
5867
|
* Internal method that handles parameter retry for chat model calls
|
|
5859
5868
|
*/
|
|
5860
|
-
async callChatModelWithRetry(prompt, currentModelRequirements, attemptStack = [], retriedUnsupportedParameters = new Set()) {
|
|
5869
|
+
async callChatModelWithRetry(prompt, currentModelRequirements, attemptStack = [], retriedUnsupportedParameters = new Set(), onProgress) {
|
|
5861
5870
|
var _a;
|
|
5862
5871
|
if (this.options.isVerbose) {
|
|
5863
5872
|
console.info(`💬 ${this.title} callChatModel call`, { prompt, currentModelRequirements });
|
|
@@ -5963,6 +5972,23 @@
|
|
|
5963
5972
|
const usage = this.computeUsage(content || '', responseMessage.content || '', rawResponse);
|
|
5964
5973
|
totalUsage = addUsage(totalUsage, usage);
|
|
5965
5974
|
if (responseMessage.tool_calls && responseMessage.tool_calls.length > 0) {
|
|
5975
|
+
if (onProgress) {
|
|
5976
|
+
onProgress({
|
|
5977
|
+
content: responseMessage.content || '',
|
|
5978
|
+
modelName: rawResponse.model || modelName,
|
|
5979
|
+
timing: { start, complete: $getCurrentDate() },
|
|
5980
|
+
usage: totalUsage,
|
|
5981
|
+
toolCalls: responseMessage.tool_calls.map((toolCall) => ({
|
|
5982
|
+
name: toolCall.function.name,
|
|
5983
|
+
arguments: toolCall.function.arguments,
|
|
5984
|
+
result: '',
|
|
5985
|
+
rawToolCall: toolCall,
|
|
5986
|
+
})),
|
|
5987
|
+
rawPromptContent,
|
|
5988
|
+
rawRequest,
|
|
5989
|
+
rawResponse,
|
|
5990
|
+
});
|
|
5991
|
+
}
|
|
5966
5992
|
await forEachAsync(responseMessage.tool_calls, {}, async (toolCall) => {
|
|
5967
5993
|
const functionName = toolCall.function.name;
|
|
5968
5994
|
const functionArgs = toolCall.function.arguments;
|
|
@@ -5984,7 +6010,7 @@
|
|
|
5984
6010
|
const args = ${functionArgs};
|
|
5985
6011
|
return await ${functionName}(args);
|
|
5986
6012
|
`,
|
|
5987
|
-
parameters:
|
|
6013
|
+
parameters: prompt.parameters,
|
|
5988
6014
|
});
|
|
5989
6015
|
}
|
|
5990
6016
|
catch (error) {
|
|
@@ -6090,7 +6116,7 @@
|
|
|
6090
6116
|
});
|
|
6091
6117
|
// Remove the unsupported parameter and retry
|
|
6092
6118
|
const modifiedModelRequirements = removeUnsupportedModelRequirement(currentModelRequirements, unsupportedParameter);
|
|
6093
|
-
return this.callChatModelWithRetry(prompt, modifiedModelRequirements, attemptStack, retriedUnsupportedParameters);
|
|
6119
|
+
return this.callChatModelWithRetry(prompt, modifiedModelRequirements, attemptStack, retriedUnsupportedParameters, onProgress);
|
|
6094
6120
|
}
|
|
6095
6121
|
}
|
|
6096
6122
|
throw new PipelineExecutionError(`Tool calling loop did not return a result from ${this.title}`);
|
|
@@ -8204,6 +8230,15 @@
|
|
|
8204
8230
|
// [🐱🚀] When tools are present, we need to use the non-streaming Runs API
|
|
8205
8231
|
// because streaming doesn't support tool execution flow properly
|
|
8206
8232
|
if (hasTools) {
|
|
8233
|
+
onProgress({
|
|
8234
|
+
content: '',
|
|
8235
|
+
modelName: 'assistant',
|
|
8236
|
+
timing: { start, complete: $getCurrentDate() },
|
|
8237
|
+
usage: UNCERTAIN_USAGE,
|
|
8238
|
+
rawPromptContent,
|
|
8239
|
+
rawRequest: null,
|
|
8240
|
+
rawResponse: null,
|
|
8241
|
+
});
|
|
8207
8242
|
const rawRequest = {
|
|
8208
8243
|
assistant_id: this.assistantId,
|
|
8209
8244
|
thread: {
|
|
@@ -8227,6 +8262,23 @@
|
|
|
8227
8262
|
if (toolCall.type === 'function') {
|
|
8228
8263
|
const functionName = toolCall.function.name;
|
|
8229
8264
|
const functionArgs = JSON.parse(toolCall.function.arguments);
|
|
8265
|
+
onProgress({
|
|
8266
|
+
content: '',
|
|
8267
|
+
modelName: 'assistant',
|
|
8268
|
+
timing: { start, complete: $getCurrentDate() },
|
|
8269
|
+
usage: UNCERTAIN_USAGE,
|
|
8270
|
+
rawPromptContent,
|
|
8271
|
+
rawRequest: null,
|
|
8272
|
+
rawResponse: null,
|
|
8273
|
+
toolCalls: [
|
|
8274
|
+
{
|
|
8275
|
+
name: functionName,
|
|
8276
|
+
arguments: toolCall.function.arguments,
|
|
8277
|
+
result: '',
|
|
8278
|
+
rawToolCall: toolCall,
|
|
8279
|
+
},
|
|
8280
|
+
],
|
|
8281
|
+
});
|
|
8230
8282
|
if (this.options.isVerbose) {
|
|
8231
8283
|
console.info(`🔧 Executing tool: ${functionName}`, functionArgs);
|
|
8232
8284
|
}
|
|
@@ -8249,7 +8301,7 @@
|
|
|
8249
8301
|
const args = ${JSON.stringify(functionArgs)};
|
|
8250
8302
|
return await ${functionName}(args);
|
|
8251
8303
|
`,
|
|
8252
|
-
parameters:
|
|
8304
|
+
parameters: prompt.parameters,
|
|
8253
8305
|
});
|
|
8254
8306
|
if (this.options.isVerbose) {
|
|
8255
8307
|
console.info(`✅ Tool ${functionName} executed:`, functionResponse);
|
|
@@ -17838,7 +17890,12 @@
|
|
|
17838
17890
|
description: 'Get the current date and time in ISO 8601 format.',
|
|
17839
17891
|
parameters: {
|
|
17840
17892
|
type: 'object',
|
|
17841
|
-
properties: {
|
|
17893
|
+
properties: {
|
|
17894
|
+
timezone: {
|
|
17895
|
+
type: 'string',
|
|
17896
|
+
description: 'Optional timezone name (e.g. "Europe/Prague", "UTC", "America/New_York").',
|
|
17897
|
+
},
|
|
17898
|
+
},
|
|
17842
17899
|
required: [],
|
|
17843
17900
|
},
|
|
17844
17901
|
},
|
|
@@ -17858,9 +17915,36 @@
|
|
|
17858
17915
|
*/
|
|
17859
17916
|
getToolFunctions() {
|
|
17860
17917
|
return {
|
|
17861
|
-
async get_current_time() {
|
|
17862
|
-
|
|
17863
|
-
|
|
17918
|
+
async get_current_time(args) {
|
|
17919
|
+
var _a;
|
|
17920
|
+
console.log('!!!! [Tool] get_current_time called', { args });
|
|
17921
|
+
const { timezone } = args;
|
|
17922
|
+
if (!timezone) {
|
|
17923
|
+
return new Date().toISOString();
|
|
17924
|
+
}
|
|
17925
|
+
try {
|
|
17926
|
+
// Note: Returning ISO 8601 string but in the requested timezone
|
|
17927
|
+
const formatter = new Intl.DateTimeFormat('en-CA', {
|
|
17928
|
+
timeZone: timezone,
|
|
17929
|
+
year: 'numeric',
|
|
17930
|
+
month: '2-digit',
|
|
17931
|
+
day: '2-digit',
|
|
17932
|
+
hour: '2-digit',
|
|
17933
|
+
minute: '2-digit',
|
|
17934
|
+
second: '2-digit',
|
|
17935
|
+
hour12: false,
|
|
17936
|
+
timeZoneName: 'shortOffset',
|
|
17937
|
+
});
|
|
17938
|
+
const parts = formatter.formatToParts(new Date());
|
|
17939
|
+
const part = (type) => { var _a; return (_a = parts.find((p) => p.type === type)) === null || _a === void 0 ? void 0 : _a.value; };
|
|
17940
|
+
// en-CA format is YYYY-MM-DD
|
|
17941
|
+
const isoString = `${part('year')}-${part('month')}-${part('day')}T${part('hour')}:${part('minute')}:${part('second')}${(_a = part('timeZoneName')) === null || _a === void 0 ? void 0 : _a.replace('GMT', '')}`;
|
|
17942
|
+
return isoString;
|
|
17943
|
+
}
|
|
17944
|
+
catch (error) {
|
|
17945
|
+
// Fallback to UTC if timezone is invalid
|
|
17946
|
+
return new Date().toISOString();
|
|
17947
|
+
}
|
|
17864
17948
|
},
|
|
17865
17949
|
};
|
|
17866
17950
|
}
|
|
@@ -18727,26 +18811,52 @@
|
|
|
18727
18811
|
});
|
|
18728
18812
|
continue;
|
|
18729
18813
|
}
|
|
18814
|
+
if (commitment.type === 'FROM') {
|
|
18815
|
+
const content = spaceTrim__default["default"](commitment.content).split('\n')[0] || '';
|
|
18816
|
+
if (content === 'Adam' || content === '' /* <- Note: Adam is implicit */) {
|
|
18817
|
+
continue;
|
|
18818
|
+
}
|
|
18819
|
+
let label = content;
|
|
18820
|
+
let iconName = 'SquareArrowOutUpRight'; // Inheritance remote
|
|
18821
|
+
if (content.startsWith('./') || content.startsWith('../') || content.startsWith('/')) {
|
|
18822
|
+
label = content.split('/').pop() || content;
|
|
18823
|
+
iconName = 'SquareArrowUpRight'; // Inheritance local
|
|
18824
|
+
}
|
|
18825
|
+
if (content === 'VOID') {
|
|
18826
|
+
label = 'VOID';
|
|
18827
|
+
iconName = 'ShieldAlert'; // [🧠] Or some other icon for VOID
|
|
18828
|
+
}
|
|
18829
|
+
capabilities.push({
|
|
18830
|
+
type: 'inheritance',
|
|
18831
|
+
label,
|
|
18832
|
+
iconName,
|
|
18833
|
+
agentUrl: content,
|
|
18834
|
+
});
|
|
18835
|
+
continue;
|
|
18836
|
+
}
|
|
18730
18837
|
if (commitment.type === 'IMPORT') {
|
|
18731
18838
|
const content = spaceTrim__default["default"](commitment.content).split('\n')[0] || '';
|
|
18732
18839
|
let label = content;
|
|
18733
|
-
|
|
18840
|
+
let iconName = 'ExternalLink'; // Import remote
|
|
18734
18841
|
try {
|
|
18735
18842
|
if (content.startsWith('http://') || content.startsWith('https://')) {
|
|
18736
18843
|
const url = new URL(content);
|
|
18737
18844
|
label = url.hostname.replace(/^www\./, '') + '.../' + url.pathname.split('/').pop();
|
|
18845
|
+
iconName = 'ExternalLink';
|
|
18738
18846
|
}
|
|
18739
18847
|
else if (content.startsWith('./') || content.startsWith('../') || content.startsWith('/')) {
|
|
18740
18848
|
label = content.split('/').pop() || content;
|
|
18849
|
+
iconName = 'Link'; // Import local
|
|
18741
18850
|
}
|
|
18742
18851
|
}
|
|
18743
18852
|
catch (e) {
|
|
18744
18853
|
// Invalid URL or path, keep default label
|
|
18745
18854
|
}
|
|
18746
18855
|
capabilities.push({
|
|
18747
|
-
type: '
|
|
18856
|
+
type: 'import',
|
|
18748
18857
|
label,
|
|
18749
18858
|
iconName,
|
|
18859
|
+
agentUrl: content,
|
|
18750
18860
|
});
|
|
18751
18861
|
continue;
|
|
18752
18862
|
}
|