conversationalist 0.0.8 → 0.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.
- package/README.md +80 -42
- package/dist/guards.d.ts +13 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/history.d.ts +17 -7
- package/dist/history.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1603 -23
- package/dist/index.js.map +7 -5
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.d.ts.map +1 -1
- package/dist/markdown/index.js +1583 -47
- package/dist/markdown/index.js.map +6 -5
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +4 -4
- package/dist/schemas/index.js.map +3 -3
- package/dist/schemas.d.ts +2 -2
- package/dist/schemas.d.ts.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -106,14 +106,9 @@ with `messages`. Use `getMessages(conversation)` for ordered arrays, or
|
|
|
106
106
|
|
|
107
107
|
### Messages
|
|
108
108
|
|
|
109
|
-
Messages have roles and can contain text or multi-modal content. Optional fields include
|
|
110
|
-
`metadata`, `hidden`, `tokenUsage`, `toolCall`, and `toolResult`. Assistant messages can also
|
|
111
|
-
include `goalCompleted` (see `AssistantMessage`).
|
|
112
|
-
Use `isAssistantMessage` to narrow when you need `goalCompleted`.
|
|
113
|
-
Metadata and tool payloads are typed as `JSONValue` so conversations remain JSON-serializable.
|
|
109
|
+
Messages have roles and can contain text or multi-modal content. Optional fields include `metadata`, `hidden`, `tokenUsage`, `toolCall`, and `toolResult`. Assistant messages can also include `goalCompleted` (see `AssistantMessage`). Use `isAssistantMessage` to narrow when you need `goalCompleted`. Metadata and tool payloads are typed as `JSONValue` so conversations remain JSON-serializable.
|
|
114
110
|
|
|
115
|
-
**Roles**: `user`, `assistant`, `system`, `developer`, `tool-use`, `tool-result`, `snapshot`.
|
|
116
|
-
The `snapshot` role is for internal state and is skipped by adapters.
|
|
111
|
+
**Roles**: `user`, `assistant`, `system`, `developer`, `tool-use`, `tool-result`, `snapshot`. The `snapshot` role is for internal state and is skipped by adapters.
|
|
117
112
|
|
|
118
113
|
```ts
|
|
119
114
|
import { appendMessages } from 'conversationalist';
|
|
@@ -127,13 +122,11 @@ conversation = appendMessages(conversation, {
|
|
|
127
122
|
});
|
|
128
123
|
```
|
|
129
124
|
|
|
130
|
-
**Hidden messages** remain in history but are skipped by default when querying or adapting to
|
|
131
|
-
providers. This is perfect for internal logging or "thinking" steps.
|
|
125
|
+
**Hidden messages** remain in history but are skipped by default when querying or adapting to providers. This is perfect for internal logging or "thinking" steps.
|
|
132
126
|
|
|
133
127
|
### Tool Calls
|
|
134
128
|
|
|
135
|
-
Tool calls are represented as paired `tool-use` and `tool-result` messages. Tool results
|
|
136
|
-
are validated to ensure the referenced call exists.
|
|
129
|
+
Tool calls are represented as paired `tool-use` and `tool-result` messages. Tool results are validated to ensure the referenced call exists.
|
|
137
130
|
|
|
138
131
|
```ts
|
|
139
132
|
conversation = appendMessages(
|
|
@@ -534,7 +527,7 @@ const firstMessage = history.get(ids[0]!);
|
|
|
534
527
|
|
|
535
528
|
### Event Subscription
|
|
536
529
|
|
|
537
|
-
`ConversationHistory` implements `EventTarget` and follows the Svelte store contract. You can listen for changes using standard DOM events or the `subscribe` method.
|
|
530
|
+
`ConversationHistory` implements `EventTarget` (and follows the Svelte store contract). You can listen for changes using standard DOM events or the `subscribe` method.
|
|
538
531
|
|
|
539
532
|
#### Using DOM Events
|
|
540
533
|
|
|
@@ -701,12 +694,15 @@ You can also convert a conversation to Markdown format for human-readable storag
|
|
|
701
694
|
|
|
702
695
|
```ts
|
|
703
696
|
import { ConversationHistory } from 'conversationalist';
|
|
704
|
-
import {
|
|
697
|
+
import {
|
|
698
|
+
conversationHistoryFromMarkdown,
|
|
699
|
+
conversationHistoryToMarkdown,
|
|
700
|
+
} from 'conversationalist/markdown';
|
|
705
701
|
|
|
706
702
|
const history = new ConversationHistory();
|
|
707
703
|
|
|
708
704
|
// Export to clean, readable Markdown
|
|
709
|
-
const markdown =
|
|
705
|
+
const markdown = conversationHistoryToMarkdown(history);
|
|
710
706
|
// ### User
|
|
711
707
|
//
|
|
712
708
|
// Hello!
|
|
@@ -716,10 +712,12 @@ const markdown = historyToMarkdown(history);
|
|
|
716
712
|
// Hi there!
|
|
717
713
|
|
|
718
714
|
// Export with full metadata (lossless round-trip)
|
|
719
|
-
const markdownWithMetadata =
|
|
715
|
+
const markdownWithMetadata = conversationHistoryToMarkdown(history, {
|
|
716
|
+
includeMetadata: true,
|
|
717
|
+
});
|
|
720
718
|
|
|
721
719
|
// Export with additional controls (redaction, transient stripping, hidden handling)
|
|
722
|
-
const markdownSafe =
|
|
720
|
+
const markdownSafe = conversationHistoryToMarkdown(history, {
|
|
723
721
|
includeMetadata: true,
|
|
724
722
|
stripTransient: true,
|
|
725
723
|
redactToolArguments: true,
|
|
@@ -728,7 +726,7 @@ const markdownSafe = historyToMarkdown(history, {
|
|
|
728
726
|
});
|
|
729
727
|
|
|
730
728
|
// Restore from Markdown
|
|
731
|
-
const restored =
|
|
729
|
+
const restored = conversationHistoryFromMarkdown(markdownWithMetadata);
|
|
732
730
|
```
|
|
733
731
|
|
|
734
732
|
### Export Helpers
|
|
@@ -779,13 +777,9 @@ For more complex applications, you can wrap the logic into a custom hook. This e
|
|
|
779
777
|
import { useState, useCallback, useEffect } from 'react';
|
|
780
778
|
import { ConversationHistory, createConversation, getMessages } from 'conversationalist';
|
|
781
779
|
|
|
782
|
-
export function useChat(
|
|
780
|
+
export function useChat() {
|
|
783
781
|
// 1. Initialize history (this could also come from context or props)
|
|
784
|
-
const [history] = useState(() =>
|
|
785
|
-
initialTitle
|
|
786
|
-
? new ConversationHistory(createConversation({ title: initialTitle }))
|
|
787
|
-
: new ConversationHistory(),
|
|
788
|
-
);
|
|
782
|
+
const [history] = useState(() => new ConversationHistory());
|
|
789
783
|
|
|
790
784
|
// 2. Sync history with local state for reactivity
|
|
791
785
|
const [conversation, setConversation] = useState(history.current);
|
|
@@ -912,24 +906,68 @@ Svelte 5's runes pair perfectly with **Conversationalist**. You can use the `Con
|
|
|
912
906
|
|
|
913
907
|
## API Overview
|
|
914
908
|
|
|
915
|
-
| Category | Key Functions
|
|
916
|
-
| :--------------- |
|
|
917
|
-
| **Creation** | `createConversation`, `deserializeConversation`
|
|
918
|
-
| **Appending** | `appendUserMessage`, `appendAssistantMessage`, `appendSystemMessage`, `appendMessages`
|
|
919
|
-
| **Streaming** | `appendStreamingMessage`, `updateStreamingMessage`, `finalizeStreamingMessage`, `cancelStreamingMessage`
|
|
920
|
-
| **Modification** | `redactMessageAtPosition`, `replaceSystemMessage`, `collapseSystemMessages`
|
|
921
|
-
| **Context** | `truncateToTokenLimit`, `getRecentMessages`, `estimateConversationTokens`
|
|
922
|
-
| **Querying** | `getMessages`, `getMessageIds`, `getMessageById`, `getStatistics`
|
|
923
|
-
| **Conversion** | `toChatMessages`, `pairToolCallsWithResults`
|
|
924
|
-
| **Markdown** | `toMarkdown`, `fromMarkdown`, `
|
|
925
|
-
| **Export** | `exportMarkdown`, `normalizeLineEndings` (from `conversationalist/export`)
|
|
926
|
-
| **Schemas** | `conversationSchema`, `
|
|
927
|
-
| **
|
|
928
|
-
| **
|
|
929
|
-
| **
|
|
930
|
-
| **
|
|
931
|
-
| **
|
|
932
|
-
| **
|
|
909
|
+
| Category | Key Functions |
|
|
910
|
+
| :--------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
911
|
+
| **Creation** | `createConversation`, `deserializeConversation` |
|
|
912
|
+
| **Appending** | `appendUserMessage`, `appendAssistantMessage`, `appendSystemMessage`, `appendMessages` |
|
|
913
|
+
| **Streaming** | `appendStreamingMessage`, `updateStreamingMessage`, `finalizeStreamingMessage`, `cancelStreamingMessage` |
|
|
914
|
+
| **Modification** | `redactMessageAtPosition`, `replaceSystemMessage`, `collapseSystemMessages` |
|
|
915
|
+
| **Context** | `truncateToTokenLimit`, `getRecentMessages`, `estimateConversationTokens` |
|
|
916
|
+
| **Querying** | `getMessages`, `getMessageIds`, `getMessageById`, `getStatistics` |
|
|
917
|
+
| **Conversion** | `toChatMessages`, `pairToolCallsWithResults` |
|
|
918
|
+
| **Markdown** | `toMarkdown`, `fromMarkdown`, `conversationHistoryToMarkdown`, `conversationHistoryFromMarkdown` (from `conversationalist/markdown`) |
|
|
919
|
+
| **Export** | `exportMarkdown`, `normalizeLineEndings` (from `conversationalist/export`) |
|
|
920
|
+
| **Schemas** | `conversationSchema`, `messageSchema`, `messageInputSchema`, `messageRoleSchema`, `multiModalContentSchema`, `jsonValueSchema`, `toolCallSchema`, `toolResultSchema`, `tokenUsageSchema` (from `conversationalist/schemas`) |
|
|
921
|
+
| **Type Guards** | `isConversation`, `isMessage`, `isMessageInput`, `isToolCall`, `isToolResult`, `isMessageRole`, `isConversationStatus`, `isJSONValue`, `isTokenUsage`, `isMultiModalContent` |
|
|
922
|
+
| **Role Labels** | `ROLE_LABELS`, `LABEL_TO_ROLE`, `getRoleLabel`, `getRoleFromLabel` (from `conversationalist/markdown`) |
|
|
923
|
+
| **Transient** | `isTransientKey`, `stripTransientFromRecord`, `stripTransientMetadata` |
|
|
924
|
+
| **Redaction** | `redactPii`, `createPIIRedactionPlugin`, `createPIIRedaction`, `DEFAULT_PII_RULES` (from `conversationalist/redaction`) |
|
|
925
|
+
| **Versioning** | `migrateConversation`, `CURRENT_SCHEMA_VERSION` (from `conversationalist/versioning`) |
|
|
926
|
+
| **Sort** | `sortObjectKeys`, `sortMessagesByPosition` (from `conversationalist/sort`) |
|
|
927
|
+
| **History** | `ConversationHistory` |
|
|
928
|
+
|
|
929
|
+
## Type Guards
|
|
930
|
+
|
|
931
|
+
Use the built-in type guards to validate unknown values before operating on them:
|
|
932
|
+
|
|
933
|
+
```ts
|
|
934
|
+
import { isConversation, isMessage } from 'conversationalist';
|
|
935
|
+
|
|
936
|
+
if (isConversation(data)) {
|
|
937
|
+
console.log(data.id);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
if (isMessage(value)) {
|
|
941
|
+
console.log(value.role);
|
|
942
|
+
}
|
|
943
|
+
```
|
|
944
|
+
|
|
945
|
+
## ConversationHistory Events
|
|
946
|
+
|
|
947
|
+
`ConversationHistory` emits typed events for every mutation. Listen to `change` for any mutation,
|
|
948
|
+
or to specific action events if you only care about a subset.
|
|
949
|
+
|
|
950
|
+
Events and payloads:
|
|
951
|
+
|
|
952
|
+
- `change`: fired after any mutation; `detail.type` is the specific action (`push`, `undo`, `redo`, `switch`)
|
|
953
|
+
- `push`: fired after a new conversation state is pushed
|
|
954
|
+
- `undo`: fired after undoing to the previous state
|
|
955
|
+
- `redo`: fired after redoing to a child state
|
|
956
|
+
- `switch`: fired after switching branches
|
|
957
|
+
|
|
958
|
+
```ts
|
|
959
|
+
import { ConversationHistory, createConversation } from 'conversationalist';
|
|
960
|
+
|
|
961
|
+
const history = new ConversationHistory(createConversation());
|
|
962
|
+
|
|
963
|
+
history.addEventListener('change', (event) => {
|
|
964
|
+
console.log(event.detail.type, event.detail.conversation.id);
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
history.addEventListener('push', (event) => {
|
|
968
|
+
console.log('pushed', event.detail.conversation.ids.length);
|
|
969
|
+
});
|
|
970
|
+
```
|
|
933
971
|
|
|
934
972
|
## Standard Schema Compliance
|
|
935
973
|
|
|
@@ -941,7 +979,7 @@ All exported Zod schemas implement the [Standard Schema](https://standardschema.
|
|
|
941
979
|
| :------------------------ | :---------------------------------- |
|
|
942
980
|
| `conversationSchema` | Complete conversation with metadata |
|
|
943
981
|
| `jsonValueSchema` | JSON-serializable values |
|
|
944
|
-
| `
|
|
982
|
+
| `messageSchema` | Serialized message format |
|
|
945
983
|
| `messageInputSchema` | Input for creating messages |
|
|
946
984
|
| `messageRoleSchema` | Valid message roles enum |
|
|
947
985
|
| `multiModalContentSchema` | Text or image content |
|
package/dist/guards.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MultiModalContent } from './multi-modal';
|
|
2
|
+
import type { Conversation, ConversationStatus, JSONValue, Message, MessageInput, MessageRole, TokenUsage, ToolCall, ToolResult } from './types';
|
|
3
|
+
export declare function isConversation(value: unknown): value is Conversation;
|
|
4
|
+
export declare function isConversationStatus(value: unknown): value is ConversationStatus;
|
|
5
|
+
export declare function isJSONValue(value: unknown): value is JSONValue;
|
|
6
|
+
export declare function isMessage(value: unknown): value is Message;
|
|
7
|
+
export declare function isMessageInput(value: unknown): value is MessageInput;
|
|
8
|
+
export declare function isMessageRole(value: unknown): value is MessageRole;
|
|
9
|
+
export declare function isMultiModalContent(value: unknown): value is MultiModalContent;
|
|
10
|
+
export declare function isTokenUsage(value: unknown): value is TokenUsage;
|
|
11
|
+
export declare function isToolCall(value: unknown): value is ToolCall;
|
|
12
|
+
export declare function isToolResult(value: unknown): value is ToolResult;
|
|
13
|
+
//# sourceMappingURL=guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAavD,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,OAAO,EACP,YAAY,EACZ,WAAW,EACX,UAAU,EACV,QAAQ,EACR,UAAU,EACX,MAAM,SAAS,CAAC;AAUjB,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAEhF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAE9E;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE"}
|
package/dist/history.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EmissionEvent } from 'event-emission';
|
|
1
2
|
import { type TruncateOptions } from './context';
|
|
2
3
|
import { type ConversationEnvironment } from './environment';
|
|
3
4
|
import type { Conversation, ConversationHistorySnapshot, JSONValue, Message, MessageInput, TokenUsage } from './types';
|
|
@@ -5,31 +6,39 @@ import type { Conversation, ConversationHistorySnapshot, JSONValue, Message, Mes
|
|
|
5
6
|
* Event detail for conversation history changes.
|
|
6
7
|
*/
|
|
7
8
|
export interface ConversationHistoryEventDetail {
|
|
8
|
-
type:
|
|
9
|
+
type: ConversationHistoryActionType;
|
|
9
10
|
conversation: Conversation;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare class ConversationHistoryEvent extends CustomEvent<ConversationHistoryEventDetail> {
|
|
15
|
-
constructor(type: string, detail: ConversationHistoryEventDetail);
|
|
16
|
-
}
|
|
12
|
+
export type ConversationHistoryEvent = EmissionEvent<ConversationHistoryEventDetail, ConversationHistoryEventType>;
|
|
13
|
+
type ConversationHistoryActionType = 'push' | 'undo' | 'redo' | 'switch';
|
|
14
|
+
type ConversationHistoryEventType = 'change' | ConversationHistoryActionType;
|
|
17
15
|
/**
|
|
18
16
|
* Manages a stack of conversation versions to support undo, redo, and branching.
|
|
19
17
|
*/
|
|
20
18
|
export declare class ConversationHistory extends EventTarget {
|
|
21
19
|
private currentNode;
|
|
22
20
|
private environment;
|
|
21
|
+
private readonly events;
|
|
23
22
|
constructor(initial?: Conversation, environment?: Partial<ConversationEnvironment>);
|
|
24
23
|
/**
|
|
25
24
|
* Dispatches a change event.
|
|
26
25
|
*/
|
|
27
26
|
private notifyChange;
|
|
27
|
+
private toAddListenerOptions;
|
|
28
|
+
private toRemoveListenerOptions;
|
|
28
29
|
/**
|
|
29
30
|
* Overrides addEventListener to optionally return an unsubscribe function.
|
|
30
31
|
* This is a convenience for modern frontend frameworks.
|
|
31
32
|
*/
|
|
32
33
|
addEventListener(type: string, callback: ((event: ConversationHistoryEvent) => void) | EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void | (() => void);
|
|
34
|
+
/**
|
|
35
|
+
* Removes a listener registered with addEventListener.
|
|
36
|
+
*/
|
|
37
|
+
removeEventListener(type: string, callback: ((event: ConversationHistoryEvent) => void) | EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void;
|
|
38
|
+
/**
|
|
39
|
+
* Dispatches a DOM-style event through the event-emission target.
|
|
40
|
+
*/
|
|
41
|
+
dispatchEvent(event: Event): boolean;
|
|
33
42
|
/**
|
|
34
43
|
* Subscribes to conversation changes.
|
|
35
44
|
* This follows the Svelte store contract, making ConversationHistory a valid Svelte store.
|
|
@@ -246,4 +255,5 @@ export declare class ConversationHistory extends EventTarget {
|
|
|
246
255
|
*/
|
|
247
256
|
[Symbol.dispose](): void;
|
|
248
257
|
}
|
|
258
|
+
export {};
|
|
249
259
|
//# sourceMappingURL=history.d.ts.map
|
package/dist/history.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAI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EAAE,MAAM,GAAG,IAAI;IAIhE;;OAEG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,UAAU,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;KAAE,GAC1E,IAAI;IAIP;;OAEG;IACH,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/C;;OAEG;IACH,QAAQ,IAAI,2BAA2B;IA2BvC;;OAEG;IACH,MAAM,CAAC,IAAI,CACT,IAAI,EAAE,2BAA2B,EACjC,WAAW,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAC7C,mBAAmB;IAoCtB;;;;OAIG;IACH,IAAI,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EACzB,EAAE,EAAE,CACF,YAAY,EAAE,YAAY,EAC1B,GAAG,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,KAC/C,CAAC,GACL,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC;IAcpB;;OAEG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAuBzB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export type { ImageContent, TextContent } from './multi-modal';
|
|
|
2
2
|
export { copyContent, copyMultiModalContent } from './multi-modal';
|
|
3
3
|
export type { Message as ExternalMessage, MultiModalContent, } from '@lasercat/homogenaize';
|
|
4
4
|
export type { AssistantMessage, Conversation, ConversationStatus, ExportOptions, JSONValue, Message, MessageInput, MessageRole, TokenUsage, ToMarkdownOptions, ToolCall, ToolResult, } from './types';
|
|
5
|
-
export { conversationSchema, conversationShape, jsonValueSchema, messageInputSchema,
|
|
5
|
+
export { conversationSchema, conversationShape, jsonValueSchema, messageInputSchema, messageRoleSchema, messageSchema, multiModalContentSchema, tokenUsageSchema, toolCallSchema, toolResultSchema, } from './schemas';
|
|
6
6
|
export type { ConversationEnvironment } from './conversation';
|
|
7
7
|
export { appendAssistantMessage, appendMessages, appendSystemMessage, appendUserMessage, collapseSystemMessages, createConversation, deserializeConversation, getFirstSystemMessage, getMessageAtPosition, getMessageById, getMessageIds, getMessages, getStatistics, getSystemMessages, hasSystemMessage, prependSystemMessage, redactMessageAtPosition, replaceSystemMessage, searchConversationMessages, toChatMessages, } from './conversation';
|
|
8
8
|
export { withEnvironment } from './environment';
|
|
@@ -11,6 +11,7 @@ export type { ConversationalistErrorCode } from './errors';
|
|
|
11
11
|
export { ConversationalistError, createDuplicateIdError, createInvalidInputError, createInvalidPositionError, createInvalidToolReferenceError, createLockedError, createNotFoundError, createSerializationError, createValidationError, } from './errors';
|
|
12
12
|
export type { ToolCallPair } from './utilities';
|
|
13
13
|
export { isTransientKey, normalizeContent, pairToolCallsWithResults, stripTransientFromRecord, stripTransientMetadata, toMultiModalArray, } from './utilities';
|
|
14
|
+
export { isConversation, isConversationStatus, isJSONValue, isMessage, isMessageInput, isMessageRole, isMultiModalContent, isTokenUsage, isToolCall, isToolResult, } from './guards';
|
|
14
15
|
export type { ConversationDraft } from './with-conversation';
|
|
15
16
|
export { pipeConversation, withConversation } from './with-conversation';
|
|
16
17
|
export { ConversationHistory } from './history';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACnE,YAAY,EACV,OAAO,IAAI,eAAe,EAC1B,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,SAAS,EACT,OAAO,EACP,YAAY,EACZ,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,UAAU,GACX,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACnE,YAAY,EACV,OAAO,IAAI,eAAe,EAC1B,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,SAAS,EACT,OAAO,EACP,YAAY,EACZ,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,UAAU,GACX,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,uBAAuB,EACvB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAGnB,YAAY,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,k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