graphlit-client 1.0.20250625001 → 1.0.20250627001
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 +235 -5
- package/dist/client.d.ts +21 -1
- package/dist/client.js +265 -55
- package/dist/generated/graphql-documents.d.ts +16 -0
- package/dist/generated/graphql-documents.js +1116 -0
- package/dist/generated/graphql-types.d.ts +1884 -85
- package/dist/generated/graphql-types.js +51 -0
- package/dist/streaming/llm-formatters.js +68 -5
- package/dist/streaming/providers.d.ts +18 -13
- package/dist/streaming/providers.js +690 -167
- package/dist/streaming/ui-event-adapter.d.ts +7 -0
- package/dist/streaming/ui-event-adapter.js +55 -0
- package/dist/types/internal.d.ts +11 -0
- package/dist/types/ui-events.d.ts +9 -0
- package/package.json +1 -1
@@ -75,6 +75,8 @@ export var AssemblyAiModels;
|
|
75
75
|
/** Authentication service type */
|
76
76
|
export var AuthenticationServiceTypes;
|
77
77
|
(function (AuthenticationServiceTypes) {
|
78
|
+
/** Arcade authentication service */
|
79
|
+
AuthenticationServiceTypes["Arcade"] = "ARCADE";
|
78
80
|
/** Auth0 authentication service */
|
79
81
|
AuthenticationServiceTypes["Auth0"] = "AUTH0";
|
80
82
|
/** Clerk authentication service */
|
@@ -501,6 +503,8 @@ export var DeepgramModels;
|
|
501
503
|
DeepgramModels["Nova2Voicemail"] = "NOVA2_VOICEMAIL";
|
502
504
|
/** Nova 3 (General) */
|
503
505
|
DeepgramModels["Nova3"] = "NOVA3";
|
506
|
+
/** Nova 3 (Medical) */
|
507
|
+
DeepgramModels["Nova3Medical"] = "NOVA3_MEDICAL";
|
504
508
|
/** Whisper (Base) */
|
505
509
|
DeepgramModels["WhisperBase"] = "WHISPER_BASE";
|
506
510
|
/** Whisper (Large) */
|
@@ -737,6 +741,8 @@ export var EntityTypes;
|
|
737
741
|
EntityTypes["Specification"] = "SPECIFICATION";
|
738
742
|
/** User */
|
739
743
|
EntityTypes["User"] = "USER";
|
744
|
+
/** View */
|
745
|
+
EntityTypes["View"] = "VIEW";
|
740
746
|
/** Workflow */
|
741
747
|
EntityTypes["Workflow"] = "WORKFLOW";
|
742
748
|
})(EntityTypes || (EntityTypes = {}));
|
@@ -953,11 +959,34 @@ export var FileTypes;
|
|
953
959
|
/** Video file */
|
954
960
|
FileTypes["Video"] = "VIDEO";
|
955
961
|
})(FileTypes || (FileTypes = {}));
|
962
|
+
export var GitHubAuthenticationTypes;
|
963
|
+
(function (GitHubAuthenticationTypes) {
|
964
|
+
GitHubAuthenticationTypes["Connector"] = "CONNECTOR";
|
965
|
+
GitHubAuthenticationTypes["OAuth"] = "O_AUTH";
|
966
|
+
GitHubAuthenticationTypes["PersonalAccessToken"] = "PERSONAL_ACCESS_TOKEN";
|
967
|
+
})(GitHubAuthenticationTypes || (GitHubAuthenticationTypes = {}));
|
968
|
+
export var GitHubIssueAuthenticationTypes;
|
969
|
+
(function (GitHubIssueAuthenticationTypes) {
|
970
|
+
GitHubIssueAuthenticationTypes["Connector"] = "CONNECTOR";
|
971
|
+
GitHubIssueAuthenticationTypes["OAuth"] = "O_AUTH";
|
972
|
+
GitHubIssueAuthenticationTypes["PersonalAccessToken"] = "PERSONAL_ACCESS_TOKEN";
|
973
|
+
})(GitHubIssueAuthenticationTypes || (GitHubIssueAuthenticationTypes = {}));
|
974
|
+
export var GoogleCalendarAuthenticationTypes;
|
975
|
+
(function (GoogleCalendarAuthenticationTypes) {
|
976
|
+
GoogleCalendarAuthenticationTypes["Connector"] = "CONNECTOR";
|
977
|
+
GoogleCalendarAuthenticationTypes["User"] = "USER";
|
978
|
+
})(GoogleCalendarAuthenticationTypes || (GoogleCalendarAuthenticationTypes = {}));
|
956
979
|
export var GoogleDriveAuthenticationTypes;
|
957
980
|
(function (GoogleDriveAuthenticationTypes) {
|
981
|
+
GoogleDriveAuthenticationTypes["Connector"] = "CONNECTOR";
|
958
982
|
GoogleDriveAuthenticationTypes["ServiceAccount"] = "SERVICE_ACCOUNT";
|
959
983
|
GoogleDriveAuthenticationTypes["User"] = "USER";
|
960
984
|
})(GoogleDriveAuthenticationTypes || (GoogleDriveAuthenticationTypes = {}));
|
985
|
+
export var GoogleEmailAuthenticationTypes;
|
986
|
+
(function (GoogleEmailAuthenticationTypes) {
|
987
|
+
GoogleEmailAuthenticationTypes["Connector"] = "CONNECTOR";
|
988
|
+
GoogleEmailAuthenticationTypes["User"] = "USER";
|
989
|
+
})(GoogleEmailAuthenticationTypes || (GoogleEmailAuthenticationTypes = {}));
|
961
990
|
/** Google model type */
|
962
991
|
export var GoogleModels;
|
963
992
|
(function (GoogleModels) {
|
@@ -1334,6 +1363,16 @@ export var MetadataTypes;
|
|
1334
1363
|
/** Content metadata */
|
1335
1364
|
MetadataTypes["Content"] = "CONTENT";
|
1336
1365
|
})(MetadataTypes || (MetadataTypes = {}));
|
1366
|
+
export var MicrosoftCalendarAuthenticationTypes;
|
1367
|
+
(function (MicrosoftCalendarAuthenticationTypes) {
|
1368
|
+
MicrosoftCalendarAuthenticationTypes["Connector"] = "CONNECTOR";
|
1369
|
+
MicrosoftCalendarAuthenticationTypes["User"] = "USER";
|
1370
|
+
})(MicrosoftCalendarAuthenticationTypes || (MicrosoftCalendarAuthenticationTypes = {}));
|
1371
|
+
export var MicrosoftEmailAuthenticationTypes;
|
1372
|
+
(function (MicrosoftEmailAuthenticationTypes) {
|
1373
|
+
MicrosoftEmailAuthenticationTypes["Connector"] = "CONNECTOR";
|
1374
|
+
MicrosoftEmailAuthenticationTypes["User"] = "USER";
|
1375
|
+
})(MicrosoftEmailAuthenticationTypes || (MicrosoftEmailAuthenticationTypes = {}));
|
1337
1376
|
/** Mistral model type */
|
1338
1377
|
export var MistralModels;
|
1339
1378
|
(function (MistralModels) {
|
@@ -1459,6 +1498,11 @@ export var OccurrenceTypes;
|
|
1459
1498
|
OccurrenceTypes["Text"] = "TEXT";
|
1460
1499
|
OccurrenceTypes["Time"] = "TIME";
|
1461
1500
|
})(OccurrenceTypes || (OccurrenceTypes = {}));
|
1501
|
+
export var OneDriveAuthenticationTypes;
|
1502
|
+
(function (OneDriveAuthenticationTypes) {
|
1503
|
+
OneDriveAuthenticationTypes["Connector"] = "CONNECTOR";
|
1504
|
+
OneDriveAuthenticationTypes["User"] = "USER";
|
1505
|
+
})(OneDriveAuthenticationTypes || (OneDriveAuthenticationTypes = {}));
|
1462
1506
|
/** OpenAI Image model type */
|
1463
1507
|
export var OpenAiImageModels;
|
1464
1508
|
(function (OpenAiImageModels) {
|
@@ -1871,6 +1915,7 @@ export var SearchTypes;
|
|
1871
1915
|
export var SharePointAuthenticationTypes;
|
1872
1916
|
(function (SharePointAuthenticationTypes) {
|
1873
1917
|
SharePointAuthenticationTypes["Application"] = "APPLICATION";
|
1918
|
+
SharePointAuthenticationTypes["Connector"] = "CONNECTOR";
|
1874
1919
|
SharePointAuthenticationTypes["User"] = "USER";
|
1875
1920
|
})(SharePointAuthenticationTypes || (SharePointAuthenticationTypes = {}));
|
1876
1921
|
/** Site type */
|
@@ -2120,6 +2165,12 @@ export var UserTypes;
|
|
2120
2165
|
/** Human user */
|
2121
2166
|
UserTypes["Human"] = "HUMAN";
|
2122
2167
|
})(UserTypes || (UserTypes = {}));
|
2168
|
+
/** View type */
|
2169
|
+
export var ViewTypes;
|
2170
|
+
(function (ViewTypes) {
|
2171
|
+
/** Content view */
|
2172
|
+
ViewTypes["Content"] = "CONTENT";
|
2173
|
+
})(ViewTypes || (ViewTypes = {}));
|
2123
2174
|
/** Voyage model type */
|
2124
2175
|
export var VoyageModels;
|
2125
2176
|
(function (VoyageModels) {
|
@@ -108,9 +108,49 @@ export function formatMessagesForAnthropic(messages) {
|
|
108
108
|
systemPrompt = trimmedMessage;
|
109
109
|
break;
|
110
110
|
case ConversationRoleTypes.Assistant:
|
111
|
-
const content = [];
|
112
|
-
//
|
113
|
-
if (trimmedMessage) {
|
111
|
+
const content = []; // Use any[] to allow thinking blocks
|
112
|
+
// Handle thinking blocks for extended thinking preservation
|
113
|
+
if (trimmedMessage && trimmedMessage.includes('<thinking')) {
|
114
|
+
// Extract thinking content and signature if present
|
115
|
+
const thinkingMatch = trimmedMessage.match(/<thinking(?:\s+signature="([^"]*)")?>([\s\S]*?)<\/thinking>/);
|
116
|
+
if (thinkingMatch) {
|
117
|
+
const signature = thinkingMatch[1]; // Optional signature
|
118
|
+
const thinkingContent = thinkingMatch[2].trim();
|
119
|
+
// Add thinking block for conversation history preservation
|
120
|
+
if (thinkingContent) {
|
121
|
+
const thinkingBlock = {
|
122
|
+
type: "thinking",
|
123
|
+
thinking: thinkingContent,
|
124
|
+
};
|
125
|
+
// Add signature if present (required by Anthropic API)
|
126
|
+
if (signature) {
|
127
|
+
thinkingBlock.signature = signature;
|
128
|
+
}
|
129
|
+
else {
|
130
|
+
// Provide a default signature if none captured
|
131
|
+
thinkingBlock.signature = "";
|
132
|
+
}
|
133
|
+
content.push(thinkingBlock);
|
134
|
+
}
|
135
|
+
// Remove thinking tags from the main text and add remaining content
|
136
|
+
const textWithoutThinking = trimmedMessage.replace(/<thinking(?:\s+[^>]*)?>[\s\S]*?<\/thinking>/g, '').trim();
|
137
|
+
if (textWithoutThinking) {
|
138
|
+
content.push({
|
139
|
+
type: "text",
|
140
|
+
text: textWithoutThinking,
|
141
|
+
});
|
142
|
+
}
|
143
|
+
}
|
144
|
+
else {
|
145
|
+
// No valid thinking blocks found, add as regular text
|
146
|
+
content.push({
|
147
|
+
type: "text",
|
148
|
+
text: trimmedMessage,
|
149
|
+
});
|
150
|
+
}
|
151
|
+
}
|
152
|
+
else if (trimmedMessage) {
|
153
|
+
// Add regular text content
|
114
154
|
content.push({
|
115
155
|
type: "text",
|
116
156
|
text: trimmedMessage,
|
@@ -341,6 +381,12 @@ export function formatMessagesForCohere(messages) {
|
|
341
381
|
* Format GraphQL conversation messages for Mistral SDK
|
342
382
|
*/
|
343
383
|
export function formatMessagesForMistral(messages) {
|
384
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
385
|
+
console.log(`[Mistral Formatter] Input: ${messages.length} messages`);
|
386
|
+
messages.forEach((msg, idx) => {
|
387
|
+
console.log(` Input ${idx}: role=${msg.role}, hasToolCalls=${!!msg.toolCalls}, toolCallId=${msg.toolCallId}`);
|
388
|
+
});
|
389
|
+
}
|
344
390
|
const formattedMessages = [];
|
345
391
|
for (const message of messages) {
|
346
392
|
if (!message.role)
|
@@ -360,7 +406,7 @@ export function formatMessagesForMistral(messages) {
|
|
360
406
|
case ConversationRoleTypes.Assistant:
|
361
407
|
const assistantMessage = {
|
362
408
|
role: "assistant",
|
363
|
-
content: trimmedMessage,
|
409
|
+
content: trimmedMessage || "", // Mistral expects string, not null
|
364
410
|
};
|
365
411
|
// Add tool calls if present
|
366
412
|
if (message.toolCalls && message.toolCalls.length > 0) {
|
@@ -368,6 +414,7 @@ export function formatMessagesForMistral(messages) {
|
|
368
414
|
.filter((tc) => tc !== null)
|
369
415
|
.map((toolCall) => ({
|
370
416
|
id: toolCall.id,
|
417
|
+
type: "function",
|
371
418
|
function: {
|
372
419
|
name: toolCall.name,
|
373
420
|
arguments: toolCall.arguments,
|
@@ -377,10 +424,16 @@ export function formatMessagesForMistral(messages) {
|
|
377
424
|
formattedMessages.push(assistantMessage);
|
378
425
|
break;
|
379
426
|
case ConversationRoleTypes.Tool:
|
427
|
+
if (!message.toolCallId) {
|
428
|
+
console.warn(`[Mistral] Tool message missing toolCallId, skipping`);
|
429
|
+
break;
|
430
|
+
}
|
431
|
+
// Mistral expects tool_call_id (snake_case) and a name field
|
380
432
|
formattedMessages.push({
|
381
433
|
role: "tool",
|
434
|
+
name: message.toolName || "unknown", // Access toolName from extended message
|
382
435
|
content: trimmedMessage,
|
383
|
-
tool_call_id: message.toolCallId
|
436
|
+
tool_call_id: message.toolCallId, // Mistral uses snake_case!
|
384
437
|
});
|
385
438
|
break;
|
386
439
|
default: // User messages
|
@@ -415,6 +468,16 @@ export function formatMessagesForMistral(messages) {
|
|
415
468
|
break;
|
416
469
|
}
|
417
470
|
}
|
471
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
472
|
+
console.log(`[Mistral Formatter] Output: ${formattedMessages.length} messages`);
|
473
|
+
formattedMessages.forEach((msg, idx) => {
|
474
|
+
const msgWithTools = msg;
|
475
|
+
console.log(` Output ${idx}: role=${msg.role}, hasToolCalls=${!!msgWithTools.tool_calls}, toolCallId=${msgWithTools.tool_call_id}`);
|
476
|
+
if (msgWithTools.tool_calls) {
|
477
|
+
console.log(` Tool calls: ${JSON.stringify(msgWithTools.tool_calls)}`);
|
478
|
+
}
|
479
|
+
});
|
480
|
+
}
|
418
481
|
return formattedMessages;
|
419
482
|
}
|
420
483
|
/**
|
@@ -1,48 +1,53 @@
|
|
1
|
-
import { ConversationToolCall, Specification, ToolDefinitionInput } from "../generated/graphql-types.js";
|
2
|
-
import { OpenAIMessage, AnthropicMessage, GoogleMessage,
|
1
|
+
import { ConversationToolCall, Specification, ToolDefinitionInput, ConversationMessage } from "../generated/graphql-types.js";
|
2
|
+
import { OpenAIMessage, AnthropicMessage, GoogleMessage, MistralMessage, BedrockMessage } from "./llm-formatters.js";
|
3
3
|
import { StreamEvent } from "../types/internal.js";
|
4
4
|
/**
|
5
5
|
* Stream with OpenAI SDK
|
6
6
|
*/
|
7
7
|
export declare function streamWithOpenAI(specification: Specification, messages: OpenAIMessage[], tools: ToolDefinitionInput[] | undefined, openaiClient: any, // OpenAI client instance
|
8
|
-
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
|
8
|
+
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void, abortSignal?: AbortSignal): Promise<void>;
|
9
9
|
/**
|
10
10
|
* Stream with Anthropic SDK
|
11
11
|
*/
|
12
|
-
|
13
|
-
|
12
|
+
type AnthropicClient = import("@anthropic-ai/sdk").default;
|
13
|
+
export declare function streamWithAnthropic(specification: Specification, messages: AnthropicMessage[], systemPrompt: string | undefined, tools: ToolDefinitionInput[] | undefined, anthropicClient: AnthropicClient, // Properly typed Anthropic client
|
14
|
+
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void, abortSignal?: AbortSignal, thinkingConfig?: {
|
15
|
+
type: "enabled";
|
16
|
+
budget_tokens: number;
|
17
|
+
}): Promise<void>;
|
14
18
|
/**
|
15
19
|
* Stream with Google SDK
|
16
20
|
*/
|
17
21
|
export declare function streamWithGoogle(specification: Specification, messages: GoogleMessage[], systemPrompt: string | undefined, tools: ToolDefinitionInput[] | undefined, googleClient: any, // Google GenerativeAI client instance
|
18
|
-
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
|
22
|
+
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void, abortSignal?: AbortSignal): Promise<void>;
|
19
23
|
/**
|
20
24
|
* Stream with Groq SDK (OpenAI-compatible)
|
21
25
|
*/
|
22
26
|
export declare function streamWithGroq(specification: Specification, messages: OpenAIMessage[], tools: ToolDefinitionInput[] | undefined, groqClient: any, // Groq client instance (OpenAI-compatible)
|
23
|
-
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
|
27
|
+
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void, abortSignal?: AbortSignal): Promise<void>;
|
24
28
|
/**
|
25
29
|
* Stream with Cerebras SDK (OpenAI-compatible)
|
26
30
|
*/
|
27
31
|
export declare function streamWithCerebras(specification: Specification, messages: OpenAIMessage[], tools: ToolDefinitionInput[] | undefined, cerebrasClient: any, // OpenAI client instance configured for Cerebras
|
28
|
-
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
|
32
|
+
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void, abortSignal?: AbortSignal): Promise<void>;
|
29
33
|
/**
|
30
34
|
* Stream with Deepseek SDK (OpenAI-compatible)
|
31
35
|
*/
|
32
36
|
export declare function streamWithDeepseek(specification: Specification, messages: OpenAIMessage[], tools: ToolDefinitionInput[] | undefined, deepseekClient: any, // OpenAI client instance configured for Deepseek
|
33
|
-
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
|
37
|
+
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void, abortSignal?: AbortSignal): Promise<void>;
|
34
38
|
/**
|
35
39
|
* Stream with Cohere SDK
|
36
40
|
*/
|
37
|
-
export declare function streamWithCohere(specification: Specification, messages:
|
38
|
-
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
|
41
|
+
export declare function streamWithCohere(specification: Specification, messages: ConversationMessage[], tools: ToolDefinitionInput[] | undefined, cohereClient: any, // CohereClient instance
|
42
|
+
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void, abortSignal?: AbortSignal): Promise<void>;
|
39
43
|
/**
|
40
44
|
* Stream with Mistral SDK
|
41
45
|
*/
|
42
46
|
export declare function streamWithMistral(specification: Specification, messages: MistralMessage[], tools: ToolDefinitionInput[] | undefined, mistralClient: any, // Mistral client instance
|
43
|
-
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
|
47
|
+
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void, abortSignal?: AbortSignal): Promise<void>;
|
44
48
|
/**
|
45
49
|
* Stream with Bedrock SDK (for Claude models)
|
46
50
|
*/
|
47
51
|
export declare function streamWithBedrock(specification: Specification, messages: BedrockMessage[], systemPrompt: string | undefined, tools: ToolDefinitionInput[] | undefined, bedrockClient: any, // BedrockRuntimeClient instance
|
48
|
-
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
|
52
|
+
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void, abortSignal?: AbortSignal): Promise<void>;
|
53
|
+
export {};
|