conversationalist 0.0.1
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/LICENSE +21 -0
- package/README.md +369 -0
- package/dist/adapters/anthropic/index.d.ts +76 -0
- package/dist/adapters/anthropic/index.d.ts.map +1 -0
- package/dist/adapters/anthropic/index.js +147 -0
- package/dist/adapters/anthropic/index.js.map +10 -0
- package/dist/adapters/gemini/index.d.ts +79 -0
- package/dist/adapters/gemini/index.d.ts.map +1 -0
- package/dist/adapters/gemini/index.js +148 -0
- package/dist/adapters/gemini/index.js.map +10 -0
- package/dist/adapters/openai/index.d.ts +65 -0
- package/dist/adapters/openai/index.d.ts.map +1 -0
- package/dist/adapters/openai/index.js +127 -0
- package/dist/adapters/openai/index.js.map +10 -0
- package/dist/context.d.ts +35 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/conversation/append.d.ts +25 -0
- package/dist/conversation/append.d.ts.map +1 -0
- package/dist/conversation/create.d.ts +14 -0
- package/dist/conversation/create.d.ts.map +1 -0
- package/dist/conversation/index.d.ts +9 -0
- package/dist/conversation/index.d.ts.map +1 -0
- package/dist/conversation/modify.d.ts +9 -0
- package/dist/conversation/modify.d.ts.map +1 -0
- package/dist/conversation/query.d.ts +34 -0
- package/dist/conversation/query.d.ts.map +1 -0
- package/dist/conversation/serialization.d.ts +13 -0
- package/dist/conversation/serialization.d.ts.map +1 -0
- package/dist/conversation/system-messages.d.ts +31 -0
- package/dist/conversation/system-messages.d.ts.map +1 -0
- package/dist/conversation/tool-tracking.d.ts +26 -0
- package/dist/conversation/tool-tracking.d.ts.map +1 -0
- package/dist/conversation/transform.d.ts +9 -0
- package/dist/conversation/transform.d.ts.map +1 -0
- package/dist/conversation.d.ts +39 -0
- package/dist/conversation.d.ts.map +1 -0
- package/dist/environment.d.ts +23 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/errors.d.ts +67 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14378 -0
- package/dist/index.js.map +87 -0
- package/dist/message.d.ts +2 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/multi-modal.d.ts +27 -0
- package/dist/multi-modal.d.ts.map +1 -0
- package/dist/schemas.d.ts +30 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/streaming.d.ts +37 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/types.d.ts +78 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utilities.d.ts +79 -0
- package/dist/utilities.d.ts.map +1 -0
- package/dist/with-conversation.d.ts +125 -0
- package/dist/with-conversation.d.ts.map +1 -0
- package/package.json +113 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,eAAe,GAChB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports multi-modal types from @lasercat/homogenaize
|
|
3
|
+
*/
|
|
4
|
+
import type { MultiModalContent } from '@lasercat/homogenaize';
|
|
5
|
+
export type { Message, MultiModalContent } from '@lasercat/homogenaize';
|
|
6
|
+
/**
|
|
7
|
+
* TextContent and ImageContent are convenience types for discriminating MultiModalContent.
|
|
8
|
+
*/
|
|
9
|
+
export interface TextContent {
|
|
10
|
+
type: 'text';
|
|
11
|
+
text: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ImageContent {
|
|
14
|
+
type: 'image';
|
|
15
|
+
url: string;
|
|
16
|
+
mimeType?: string;
|
|
17
|
+
text?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a shallow copy of a MultiModalContent item.
|
|
21
|
+
*/
|
|
22
|
+
export declare function copyMultiModalContent(item: MultiModalContent): MultiModalContent;
|
|
23
|
+
/**
|
|
24
|
+
* Copies content, ensuring a mutable array is returned for multi-modal content.
|
|
25
|
+
*/
|
|
26
|
+
export declare function copyContent(content: string | ReadonlyArray<MultiModalContent>): string | MultiModalContent[];
|
|
27
|
+
//# sourceMappingURL=multi-modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-modal.d.ts","sourceRoot":"","sources":["../src/multi-modal.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,iBAAiB,CAWhF;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,iBAAiB,CAAC,GACjD,MAAM,GAAG,iBAAiB,EAAE,CAK9B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ConversationJSON, ConversationStatus, MessageInput, MessageJSON, MessageRole, TokenUsage, ToolCall, ToolResult } from './types';
|
|
3
|
+
export declare const multiModalContentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"text">;
|
|
5
|
+
text: z.ZodString;
|
|
6
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
7
|
+
type: z.ZodLiteral<"image">;
|
|
8
|
+
url: z.ZodString;
|
|
9
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
10
|
+
text: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>], "type">;
|
|
12
|
+
export declare const messageRoleSchema: z.ZodType<MessageRole>;
|
|
13
|
+
export declare const toolCallSchema: z.ZodType<ToolCall>;
|
|
14
|
+
export declare const toolResultSchema: z.ZodType<ToolResult>;
|
|
15
|
+
export declare const tokenUsageSchema: z.ZodType<TokenUsage>;
|
|
16
|
+
export declare const messageInputSchema: z.ZodType<MessageInput>;
|
|
17
|
+
export declare const messageJSONSchema: z.ZodType<MessageJSON>;
|
|
18
|
+
export declare const conversationStatusSchema: z.ZodType<ConversationStatus>;
|
|
19
|
+
export declare const conversationShape: {
|
|
20
|
+
readonly id: z.ZodString;
|
|
21
|
+
readonly title: z.ZodOptional<z.ZodString>;
|
|
22
|
+
readonly status: z.ZodType<ConversationStatus, unknown, z.core.$ZodTypeInternals<ConversationStatus, unknown>>;
|
|
23
|
+
readonly metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
24
|
+
readonly tags: z.ZodArray<z.ZodString>;
|
|
25
|
+
readonly messages: z.ZodArray<z.ZodType<MessageJSON, unknown, z.core.$ZodTypeInternals<MessageJSON, unknown>>>;
|
|
26
|
+
readonly createdAt: z.ZodString;
|
|
27
|
+
readonly updatedAt: z.ZodString;
|
|
28
|
+
};
|
|
29
|
+
export declare const conversationSchema: z.ZodType<ConversationJSON>;
|
|
30
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,QAAQ,EACR,UAAU,EACX,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,uBAAuB;;;;;;;;2BAQlC,CAAC;AAEH,eAAO,MAAM,iBAAiB,EAQb,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AAExC,eAAO,MAAM,cAAc,EAIV,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAErC,eAAO,MAAM,gBAAgB,EAIZ,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAEvC,eAAO,MAAM,gBAAgB,EAIZ,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAEvC,eAAO,MAAM,kBAAkB,EASd,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAEzC,eAAO,MAAM,iBAAiB,EAcC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AAEtD,eAAO,MAAM,wBAAwB,EAIpB,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAG/C,eAAO,MAAM,iBAAiB;;;;;;;;;CASpB,CAAC;AAEX,eAAO,MAAM,kBAAkB,EAEf,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { MultiModalContent } from '@lasercat/homogenaize';
|
|
2
|
+
import { type ConversationEnvironment } from './environment';
|
|
3
|
+
import type { Conversation, Message, TokenUsage } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Checks if a message is currently streaming (has the streaming metadata flag).
|
|
6
|
+
*/
|
|
7
|
+
export declare function isStreamingMessage(message: Message): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Gets the currently streaming message from a conversation, if any.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getStreamingMessage(conversation: Conversation): Message | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a pending/streaming message placeholder and appends it to the conversation.
|
|
14
|
+
* Returns both the updated conversation and the ID of the new streaming message.
|
|
15
|
+
*/
|
|
16
|
+
export declare function appendStreamingMessage(conversation: Conversation, role: 'assistant' | 'user', metadata?: Record<string, unknown>, environment?: Partial<ConversationEnvironment>): {
|
|
17
|
+
conversation: Conversation;
|
|
18
|
+
messageId: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Updates the content of a streaming message.
|
|
22
|
+
* This replaces the existing content (use for accumulating streamed tokens).
|
|
23
|
+
*/
|
|
24
|
+
export declare function updateStreamingMessage(conversation: Conversation, messageId: string, content: string | MultiModalContent[], environment?: Partial<ConversationEnvironment>): Conversation;
|
|
25
|
+
/**
|
|
26
|
+
* Marks a streaming message as complete, removing the streaming flag.
|
|
27
|
+
* Optionally adds token usage and additional metadata.
|
|
28
|
+
*/
|
|
29
|
+
export declare function finalizeStreamingMessage(conversation: Conversation, messageId: string, options?: {
|
|
30
|
+
tokenUsage?: TokenUsage;
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
}, environment?: Partial<ConversationEnvironment>): Conversation;
|
|
33
|
+
/**
|
|
34
|
+
* Cancels a streaming message by removing it from the conversation.
|
|
35
|
+
*/
|
|
36
|
+
export declare function cancelStreamingMessage(conversation: Conversation, messageId: string, environment?: Partial<ConversationEnvironment>): Conversation;
|
|
37
|
+
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../src/streaming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAKjE;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAE5D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,GAAG,SAAS,CAEnF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,WAAW,GAAG,MAAM,EAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,WAAW,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAC7C;IAAE,YAAY,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAyBnD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE,EACrC,WAAW,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAC7C,YAAY,CAiCd;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IACR,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,EACD,WAAW,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAC7C,YAAY,CA4Cd;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAC7C,YAAY,CAqCd"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { MultiModalContent } from '@lasercat/homogenaize';
|
|
2
|
+
export type MessageRole = 'user' | 'assistant' | 'system' | 'developer' | 'tool-use' | 'tool-result' | 'snapshot';
|
|
3
|
+
export interface ToolCall {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
arguments: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface ToolResult {
|
|
9
|
+
callId: string;
|
|
10
|
+
outcome: 'success' | 'error';
|
|
11
|
+
content: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface TokenUsage {
|
|
14
|
+
prompt: number;
|
|
15
|
+
completion: number;
|
|
16
|
+
total: number;
|
|
17
|
+
}
|
|
18
|
+
export interface MessageInput {
|
|
19
|
+
role: MessageRole;
|
|
20
|
+
content: string | MultiModalContent[];
|
|
21
|
+
metadata?: Record<string, unknown> | undefined;
|
|
22
|
+
hidden?: boolean | undefined;
|
|
23
|
+
toolCall?: ToolCall | undefined;
|
|
24
|
+
toolResult?: ToolResult | undefined;
|
|
25
|
+
tokenUsage?: TokenUsage | undefined;
|
|
26
|
+
/** Indicates if this message represents goal completion (assistant only) */
|
|
27
|
+
goalCompleted?: boolean | undefined;
|
|
28
|
+
}
|
|
29
|
+
export interface MessageJSON {
|
|
30
|
+
id: string;
|
|
31
|
+
role: MessageRole;
|
|
32
|
+
content: string | MultiModalContent[];
|
|
33
|
+
position: number;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
metadata: Record<string, unknown>;
|
|
36
|
+
hidden: boolean;
|
|
37
|
+
toolCall?: ToolCall | undefined;
|
|
38
|
+
toolResult?: ToolResult | undefined;
|
|
39
|
+
tokenUsage?: TokenUsage | undefined;
|
|
40
|
+
/** Indicates if this message represents goal completion (assistant only) */
|
|
41
|
+
goalCompleted?: boolean | undefined;
|
|
42
|
+
}
|
|
43
|
+
export interface Message {
|
|
44
|
+
id: string;
|
|
45
|
+
role: MessageRole;
|
|
46
|
+
content: string | ReadonlyArray<MultiModalContent>;
|
|
47
|
+
position: number;
|
|
48
|
+
createdAt: string;
|
|
49
|
+
metadata: Readonly<Record<string, unknown>>;
|
|
50
|
+
hidden: boolean;
|
|
51
|
+
toolCall?: Readonly<ToolCall> | undefined;
|
|
52
|
+
toolResult?: Readonly<ToolResult> | undefined;
|
|
53
|
+
tokenUsage?: Readonly<TokenUsage> | undefined;
|
|
54
|
+
/** Indicates if this message represents goal completion (assistant only) */
|
|
55
|
+
goalCompleted?: boolean | undefined;
|
|
56
|
+
}
|
|
57
|
+
export type ConversationStatus = 'active' | 'archived' | 'deleted';
|
|
58
|
+
export interface ConversationJSON {
|
|
59
|
+
id: string;
|
|
60
|
+
title?: string | undefined;
|
|
61
|
+
status: ConversationStatus;
|
|
62
|
+
metadata: Record<string, unknown>;
|
|
63
|
+
tags: string[];
|
|
64
|
+
messages: MessageJSON[];
|
|
65
|
+
createdAt: string;
|
|
66
|
+
updatedAt: string;
|
|
67
|
+
}
|
|
68
|
+
export interface Conversation {
|
|
69
|
+
id: string;
|
|
70
|
+
title?: string | undefined;
|
|
71
|
+
status: ConversationStatus;
|
|
72
|
+
metadata: Readonly<Record<string, unknown>>;
|
|
73
|
+
tags: ReadonlyArray<string>;
|
|
74
|
+
messages: ReadonlyArray<Message>;
|
|
75
|
+
createdAt: string;
|
|
76
|
+
updatedAt: string;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,WAAW,GACX,UAAU,GACV,aAAa,GACb,UAAU,CAAC;AAEf,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACn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MessageJSON, ToolCall, ToolResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a paired tool call with its optional result.
|
|
5
|
+
*/
|
|
6
|
+
export interface ToolCallPair {
|
|
7
|
+
/** The tool call */
|
|
8
|
+
call: ToolCall;
|
|
9
|
+
/** The corresponding result, if available */
|
|
10
|
+
result?: ToolResult | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Pairs tool calls with their corresponding results from a list of messages.
|
|
14
|
+
*
|
|
15
|
+
* This is useful for UI rendering where tool calls and their results need
|
|
16
|
+
* to be displayed together. The function performs two passes:
|
|
17
|
+
* 1. Collects all tool results into a map by their callId
|
|
18
|
+
* 2. Pairs each tool call with its matching result (if any)
|
|
19
|
+
*
|
|
20
|
+
* @param messages - Array of messages that may contain tool calls and results
|
|
21
|
+
* @returns Array of tool call pairs, preserving the order of tool calls
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const pairs = pairToolCallsWithResults(conversation.messages);
|
|
26
|
+
* // pairs: [{ call: ToolCall, result?: ToolResult }, ...]
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function pairToolCallsWithResults(messages: readonly MessageJSON[]): ToolCallPair[];
|
|
30
|
+
/**
|
|
31
|
+
* Type-safe hasOwnProperty check.
|
|
32
|
+
* Narrows the type to include the checked property.
|
|
33
|
+
*/
|
|
34
|
+
export declare function hasOwnProperty<X extends object, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Casts a value to its readonly variant.
|
|
37
|
+
* Used to enforce immutability at the type level.
|
|
38
|
+
*/
|
|
39
|
+
export declare function toReadonly<T>(value: T): Readonly<T>;
|
|
40
|
+
/**
|
|
41
|
+
* Creates an immutable Message from a JSON representation.
|
|
42
|
+
* Deep copies nested objects and arrays to ensure immutability.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createMessage(props: MessageJSON): Message;
|
|
45
|
+
/**
|
|
46
|
+
* Converts content to a multi-modal array format.
|
|
47
|
+
* Wraps strings in a text content object, normalizes single items to arrays.
|
|
48
|
+
*/
|
|
49
|
+
export declare function toMultiModalArray(input: string | MultiModalContent | MultiModalContent[]): MultiModalContent[];
|
|
50
|
+
/**
|
|
51
|
+
* Normalizes content to either a string or multi-modal array.
|
|
52
|
+
* Single MultiModalContent items are wrapped in an array.
|
|
53
|
+
*/
|
|
54
|
+
export declare function normalizeContent(content?: string | MultiModalContent | MultiModalContent[]): string | MultiModalContent[] | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Converts an immutable Message to a mutable JSON representation.
|
|
57
|
+
* Creates deep copies of all nested objects.
|
|
58
|
+
*/
|
|
59
|
+
export declare function messageToJSON(message: Message): MessageJSON;
|
|
60
|
+
/**
|
|
61
|
+
* Extracts the content parts from a message as a multi-modal array.
|
|
62
|
+
* String content is converted to a single text part.
|
|
63
|
+
*/
|
|
64
|
+
export declare function messageParts(message: Message): ReadonlyArray<MultiModalContent>;
|
|
65
|
+
/**
|
|
66
|
+
* Extracts all text content from a message, joined by the specified separator.
|
|
67
|
+
* Non-text parts are excluded from the result.
|
|
68
|
+
*/
|
|
69
|
+
export declare function messageText(message: Message, joiner?: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Checks if a message contains any image content.
|
|
72
|
+
*/
|
|
73
|
+
export declare function messageHasImages(message: Message): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Converts a message to a string representation.
|
|
76
|
+
* Images are rendered as markdown image syntax.
|
|
77
|
+
*/
|
|
78
|
+
export declare function messageToString(message: Message): string;
|
|
79
|
+
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG/D,OAAO,KAAK,EAAE,O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AM,GAAE,MAAe,GAAG,MAAM,CAM7E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAE1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CASxD"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { MultiModalContent } from '@lasercat/homogenaize';
|
|
2
|
+
import type { Conversation, Message, MessageInput, TokenUsage } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* A mutable draft wrapper around a conversation.
|
|
5
|
+
* Methods return the draft for chaining and mutate the internal state.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const result = withConversation(conversation, (draft) => {
|
|
10
|
+
* draft
|
|
11
|
+
* .appendSystemMessage('You are helpful.')
|
|
12
|
+
* .appendUserMessage('Hello!')
|
|
13
|
+
* .appendAssistantMessage('Hi there!');
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export interface ConversationDraft {
|
|
18
|
+
/** The current immutable conversation value. */
|
|
19
|
+
readonly value: Conversation;
|
|
20
|
+
/**
|
|
21
|
+
* Appends one or more messages to the conversation.
|
|
22
|
+
* @param inputs - Message inputs to append.
|
|
23
|
+
*/
|
|
24
|
+
appendMessages: (...inputs: MessageInput[]) => ConversationDraft;
|
|
25
|
+
/**
|
|
26
|
+
* Appends a user message to the conversation.
|
|
27
|
+
* @param content - Text or multi-modal content.
|
|
28
|
+
* @param metadata - Optional metadata to attach to the message.
|
|
29
|
+
*/
|
|
30
|
+
appendUserMessage: (content: MessageInput['content'], metadata?: Record<string, unknown>) => ConversationDraft;
|
|
31
|
+
/**
|
|
32
|
+
* Appends an assistant message to the conversation.
|
|
33
|
+
* @param content - Text or multi-modal content.
|
|
34
|
+
* @param metadata - Optional metadata to attach to the message.
|
|
35
|
+
*/
|
|
36
|
+
appendAssistantMessage: (content: MessageInput['content'], metadata?: Record<string, unknown>) => ConversationDraft;
|
|
37
|
+
/**
|
|
38
|
+
* Appends a system message to the conversation.
|
|
39
|
+
* @param content - The system message content.
|
|
40
|
+
* @param metadata - Optional metadata to attach to the message.
|
|
41
|
+
*/
|
|
42
|
+
appendSystemMessage: (content: string, metadata?: Record<string, unknown>) => ConversationDraft;
|
|
43
|
+
/**
|
|
44
|
+
* Prepends a system message at position 0, renumbering existing messages.
|
|
45
|
+
* @param content - The system message content.
|
|
46
|
+
* @param metadata - Optional metadata to attach to the message.
|
|
47
|
+
*/
|
|
48
|
+
prependSystemMessage: (content: string, metadata?: Record<string, unknown>) => ConversationDraft;
|
|
49
|
+
/**
|
|
50
|
+
* Replaces the first system message, or prepends if none exists.
|
|
51
|
+
* @param content - The new system message content.
|
|
52
|
+
* @param metadata - Optional metadata (uses original if not provided).
|
|
53
|
+
*/
|
|
54
|
+
replaceSystemMessage: (content: string, metadata?: Record<string, unknown>) => ConversationDraft;
|
|
55
|
+
/**
|
|
56
|
+
* Collapses all system messages into the first one, deduplicating content.
|
|
57
|
+
*/
|
|
58
|
+
collapseSystemMessages: () => ConversationDraft;
|
|
59
|
+
/**
|
|
60
|
+
* Redacts a message at the given position, replacing its content.
|
|
61
|
+
* @param position - The message position to redact.
|
|
62
|
+
* @param placeholder - Replacement text (default: '[REDACTED]').
|
|
63
|
+
*/
|
|
64
|
+
redactMessageAtPosition: (position: number, placeholder?: string) => ConversationDraft;
|
|
65
|
+
/**
|
|
66
|
+
* Appends a streaming message placeholder.
|
|
67
|
+
* Returns the draft and the new message ID for subsequent updates.
|
|
68
|
+
* @param role - The role of the streaming message ('assistant' or 'user').
|
|
69
|
+
* @param metadata - Optional metadata to attach to the message.
|
|
70
|
+
*/
|
|
71
|
+
appendStreamingMessage: (role: 'assistant' | 'user', metadata?: Record<string, unknown>) => {
|
|
72
|
+
draft: ConversationDraft;
|
|
73
|
+
messageId: string;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Updates the content of a streaming message.
|
|
77
|
+
* @param messageId - The ID of the streaming message to update.
|
|
78
|
+
* @param content - The new content (replaces existing content).
|
|
79
|
+
*/
|
|
80
|
+
updateStreamingMessage: (messageId: string, content: string | MultiModalContent[]) => ConversationDraft;
|
|
81
|
+
/**
|
|
82
|
+
* Finalizes a streaming message, removing the streaming flag.
|
|
83
|
+
* @param messageId - The ID of the streaming message to finalize.
|
|
84
|
+
* @param options - Optional token usage and additional metadata.
|
|
85
|
+
*/
|
|
86
|
+
finalizeStreamingMessage: (messageId: string, options?: {
|
|
87
|
+
tokenUsage?: TokenUsage;
|
|
88
|
+
metadata?: Record<string, unknown>;
|
|
89
|
+
}) => ConversationDraft;
|
|
90
|
+
/**
|
|
91
|
+
* Cancels a streaming message by removing it from the conversation.
|
|
92
|
+
* @param messageId - The ID of the streaming message to cancel.
|
|
93
|
+
*/
|
|
94
|
+
cancelStreamingMessage: (messageId: string) => ConversationDraft;
|
|
95
|
+
/**
|
|
96
|
+
* Truncates the conversation to keep only messages from position onwards.
|
|
97
|
+
* @param position - The starting position to keep.
|
|
98
|
+
* @param options - Options for preserving system messages.
|
|
99
|
+
*/
|
|
100
|
+
truncateFromPosition: (position: number, options?: {
|
|
101
|
+
preserveSystemMessages?: boolean;
|
|
102
|
+
}) => ConversationDraft;
|
|
103
|
+
/**
|
|
104
|
+
* Truncates the conversation to fit within a token limit.
|
|
105
|
+
* Removes oldest messages first while preserving system messages and optionally the last N messages.
|
|
106
|
+
* @param maxTokens - Maximum token count to target.
|
|
107
|
+
* @param estimateTokens - Function to estimate tokens per message.
|
|
108
|
+
* @param options - Options for preserving system messages and last N messages.
|
|
109
|
+
*/
|
|
110
|
+
truncateToTokenLimit: (maxTokens: number, estimateTokens: (message: Message) => number, options?: {
|
|
111
|
+
preserveSystemMessages?: boolean;
|
|
112
|
+
preserveLastN?: number;
|
|
113
|
+
}) => ConversationDraft;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Executes a function with a mutable draft and returns the final conversation.
|
|
117
|
+
* Supports both synchronous and asynchronous operations.
|
|
118
|
+
*/
|
|
119
|
+
export declare function withConversation(conversation: Conversation, fn: (draft: ConversationDraft) => void | Promise<void>): Conversation | Promise<Conversation>;
|
|
120
|
+
/**
|
|
121
|
+
* Applies a series of transformation functions to a conversation.
|
|
122
|
+
* Each function receives the result of the previous one.
|
|
123
|
+
*/
|
|
124
|
+
export declare function pipeConversation(conversation: Conversation, ...fns: Array<(conversation: Conversation) => Conversation>): Conversation;
|
|
125
|
+
//# sourceMappingURL=with-conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-conversation.d.ts","sourceRoot":"","sources":["../src/with-conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAmB/D,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAE7B;;;OAGG;IACH,cAAc,EAAE,CAAC,GAAG,MAAM,EAAE,YAAY,EAAE,KAAK,iBAAiB,CAAC;IAEjE;;;;OAIG;IACH,iBAAiB,EAAE,CACjB,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,EAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC/B,iBAAiB,CAAC;IAEvB;;;;OAIG;IACH,sBAAsB,EAAE,CACtB,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,EAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC/B,iBAAiB,CAAC;IAEvB;;;;OAIG;IACH,mBAAmB,EAAE,CACnB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,CAAC,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AAC,EAAE,OAAO,CAAA;KAAE,KAC3C,iBAAiB,CAAC;IAEvB;;;;;;OAMG;IACH,oBAAoB,EAAE,CACpB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,EAC5C,OAAO,CAAC,EAAE;QAAE,sBAAsB,CAAC,EAAE,OAAO,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,KACnE,iBAAiB,CAAC;CACxB;AAoFD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,YAAY,EAC1B,EAAE,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GACrD,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAWtC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,YAAY,EAC1B,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,YAAY,EAAE,YAAY,KAAK,YAAY,CAAC,GAC1D,YAAY,CAEd"}
|
package/package.json
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "conversationalist",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A TypeScript library for managing AI conversation state",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"conversation",
|
|
7
|
+
"ai",
|
|
8
|
+
"chat",
|
|
9
|
+
"llm",
|
|
10
|
+
"typescript"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/stevekinney/conversationalist#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/stevekinney/conversationalist/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/stevekinney/conversationalist.git"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "Steve Kinney <hello@stevekinney.net>",
|
|
22
|
+
"type": "module",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./openai": {
|
|
29
|
+
"types": "./dist/adapters/openai/index.d.ts",
|
|
30
|
+
"import": "./dist/adapters/openai/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./anthropic": {
|
|
33
|
+
"types": "./dist/adapters/anthropic/index.d.ts",
|
|
34
|
+
"import": "./dist/adapters/anthropic/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./gemini": {
|
|
37
|
+
"types": "./dist/adapters/gemini/index.d.ts",
|
|
38
|
+
"import": "./dist/adapters/gemini/index.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"main": "./dist/index.js",
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"LICENSE",
|
|
46
|
+
"README.md"
|
|
47
|
+
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "bun run scripts/build.ts",
|
|
50
|
+
"dev": "bun --watch run src/index.ts",
|
|
51
|
+
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
|
|
52
|
+
"format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,md}\"",
|
|
53
|
+
"lint": "eslint .",
|
|
54
|
+
"lint:fix": "eslint . --fix",
|
|
55
|
+
"prepare": "husky",
|
|
56
|
+
"prepublishOnly": "bun run validate && bun run build",
|
|
57
|
+
"start": "bun run src/index.ts",
|
|
58
|
+
"test": "bun test",
|
|
59
|
+
"test:coverage": "bun test --coverage",
|
|
60
|
+
"typecheck": "tsc --noEmit",
|
|
61
|
+
"validate": "bun run lint && bun run typecheck && bun run test"
|
|
62
|
+
},
|
|
63
|
+
"lint-staged": {
|
|
64
|
+
"src/**/*.{js,ts,tsx,jsx,mjs,cjs}": [
|
|
65
|
+
"eslint --fix",
|
|
66
|
+
"prettier --write"
|
|
67
|
+
],
|
|
68
|
+
"scripts/**/*.{js,ts,tsx,jsx,mjs,cjs}": [
|
|
69
|
+
"eslint --fix",
|
|
70
|
+
"prettier --write"
|
|
71
|
+
],
|
|
72
|
+
"**/*.{json,md,css,scss}": [
|
|
73
|
+
"prettier --write"
|
|
74
|
+
],
|
|
75
|
+
"package.json": [
|
|
76
|
+
"sort-package-json"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"dependencies": {
|
|
80
|
+
"change-case": "^5.4.4",
|
|
81
|
+
"zod": "^4.2.1"
|
|
82
|
+
},
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
85
|
+
"@eslint/js": "^9.39.2",
|
|
86
|
+
"@eslint/markdown": "^7.5.1",
|
|
87
|
+
"@lasercat/homogenaize": "^1.2.41",
|
|
88
|
+
"@types/bun": "^1.3.5",
|
|
89
|
+
"@typescript-eslint/eslint-plugin": "^8.50.0",
|
|
90
|
+
"@typescript-eslint/parser": "^8.50.0",
|
|
91
|
+
"chalk": "^5.6.2",
|
|
92
|
+
"eslint": "^9.39.2",
|
|
93
|
+
"eslint-config-prettier": "^10.1.8",
|
|
94
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
95
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
96
|
+
"eslint-plugin-import": "^2.32.0",
|
|
97
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
98
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
99
|
+
"eslint-plugin-regexp": "^2.10.0",
|
|
100
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
101
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
102
|
+
"eslint-plugin-unused-imports": "^4.3.0",
|
|
103
|
+
"globals": "^16.5.0",
|
|
104
|
+
"husky": "^9.1.7",
|
|
105
|
+
"lint-staged": "^16.2.7",
|
|
106
|
+
"prettier": "^3.7.4",
|
|
107
|
+
"sort-package-json": "^3.6.0",
|
|
108
|
+
"typescript-eslint": "^8.50.0"
|
|
109
|
+
},
|
|
110
|
+
"engines": {
|
|
111
|
+
"bun": ">=1.3.0"
|
|
112
|
+
}
|
|
113
|
+
}
|