conversationalist 0.0.4 → 0.0.6
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 +37 -21
- package/dist/history.d.ts +7 -1
- package/dist/history.d.ts.map +1 -1
- package/dist/index.js +48 -34
- package/dist/index.js.map +9 -5
- package/dist/utilities/content.d.ts +12 -0
- package/dist/utilities/content.d.ts.map +1 -0
- package/dist/utilities/index.d.ts +8 -0
- package/dist/utilities/index.d.ts.map +1 -0
- package/dist/utilities/markdown.d.ts +76 -0
- package/dist/utilities/markdown.d.ts.map +1 -0
- package/dist/utilities/message.d.ts +32 -0
- package/dist/utilities/message.d.ts.map +1 -0
- package/dist/utilities/tool-calls.d.ts +33 -0
- package/dist/utilities/tool-calls.d.ts.map +1 -0
- package/dist/utilities/type-helpers.d.ts +11 -0
- package/dist/utilities/type-helpers.d.ts.map +1 -0
- package/dist/utilities.d.ts +15 -151
- package/dist/utilities.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MultiModalContent } from '@lasercat/homogenaize';
|
|
2
|
+
/**
|
|
3
|
+
* Converts content to a multi-modal array format.
|
|
4
|
+
* Wraps strings in a text content object, normalizes single items to arrays.
|
|
5
|
+
*/
|
|
6
|
+
export declare function toMultiModalArray(input: string | MultiModalContent | MultiModalContent[]): MultiModalContent[];
|
|
7
|
+
/**
|
|
8
|
+
* Normalizes content to either a string or multi-modal array.
|
|
9
|
+
* Single MultiModalContent items are wrapped in an array.
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeContent(content?: string | MultiModalContent | MultiModalContent[]): string | MultiModalContent[] | undefined;
|
|
12
|
+
//# sourceMappingURL=content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/utilities/content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,GAAG,iBAAiB,GAAG,iBAAiB,EAAE,GACtD,iBAAiB,EAAE,CAGrB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,iBAAiB,GAAG,iBAAiB,EAAE,GACzD,MAAM,GAAG,iBAAiB,EAAE,GAAG,SAAS,CAI1C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { normalizeContent, toMultiModalArray } from './content';
|
|
2
|
+
export type { ToMarkdownOptions } from './markdown';
|
|
3
|
+
export { fromMarkdown, MarkdownParseError, toMarkdown } from './markdown';
|
|
4
|
+
export { createMessage, messageHasImages, messageParts, messageText, messageToJSON, messageToString, } from './message';
|
|
5
|
+
export type { ToolCallPair } from './tool-calls';
|
|
6
|
+
export { pairToolCallsWithResults } from './tool-calls';
|
|
7
|
+
export { hasOwnProperty, toReadonly } from './type-helpers';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAGhE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG1E,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,eAAe,GAChB,MAAM,WAAW,CAAC;AAGnB,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Conversation } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the toMarkdown function.
|
|
4
|
+
*/
|
|
5
|
+
export interface ToMarkdownOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Whether to include metadata (YAML frontmatter with message metadata)
|
|
8
|
+
* for lossless round-trip conversion.
|
|
9
|
+
*
|
|
10
|
+
* When `true`:
|
|
11
|
+
* - Includes YAML frontmatter with conversation and message metadata
|
|
12
|
+
* - Headers include message ID: `### Role (msg-id)`
|
|
13
|
+
* - Supports lossless round-trip via `fromMarkdown`
|
|
14
|
+
*
|
|
15
|
+
* When `false` (default):
|
|
16
|
+
* - Outputs clean, human-readable markdown
|
|
17
|
+
* - Headers only include role: `### Role`
|
|
18
|
+
*
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
includeMetadata?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Converts a conversation to a Markdown string representation.
|
|
25
|
+
*
|
|
26
|
+
* By default, outputs clean, human-readable markdown with:
|
|
27
|
+
* - Each message with a header containing only the role: `### Role`
|
|
28
|
+
* - Message content rendered as markdown
|
|
29
|
+
*
|
|
30
|
+
* When `options.includeMetadata` is `true`, outputs markdown with full metadata
|
|
31
|
+
* for lossless round-trip conversion:
|
|
32
|
+
* - YAML frontmatter with conversation metadata and all message metadata keyed by message ID
|
|
33
|
+
* - Headers include message ID: `### Role (msg-id)`
|
|
34
|
+
* - Full content array preserved for multi-modal messages
|
|
35
|
+
*
|
|
36
|
+
* For multi-modal content:
|
|
37
|
+
* - Text parts are appended in order
|
|
38
|
+
* - Image parts are rendered as `` on their own line
|
|
39
|
+
*
|
|
40
|
+
* @param conversation - The conversation to convert
|
|
41
|
+
* @param options - Options for markdown output
|
|
42
|
+
* @returns A Markdown string representation of the conversation
|
|
43
|
+
*/
|
|
44
|
+
export declare function toMarkdown(conversation: Conversation, options?: ToMarkdownOptions): string;
|
|
45
|
+
/**
|
|
46
|
+
* Error thrown when markdown parsing fails.
|
|
47
|
+
*/
|
|
48
|
+
export declare class MarkdownParseError extends Error {
|
|
49
|
+
constructor(message: string);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Parses a Markdown string back into a Conversation object.
|
|
53
|
+
*
|
|
54
|
+
* This is the inverse of `toMarkdown` and supports both:
|
|
55
|
+
* - Lossless round-trip conversion when markdown includes metadata
|
|
56
|
+
* (generated by `toMarkdown` with `includeMetadata: true`)
|
|
57
|
+
* - Best-effort parsing of simple markdown without metadata
|
|
58
|
+
* (generated by `toMarkdown` with `includeMetadata: false` or hand-written)
|
|
59
|
+
*
|
|
60
|
+
* When metadata is present:
|
|
61
|
+
* - YAML frontmatter provides conversation and message metadata
|
|
62
|
+
* - Headers include message ID: `### Role (msg-id)`
|
|
63
|
+
* - Full fidelity is preserved
|
|
64
|
+
*
|
|
65
|
+
* When metadata is absent:
|
|
66
|
+
* - Conversation ID and timestamps are generated
|
|
67
|
+
* - Message IDs are generated, positions are inferred from order
|
|
68
|
+
* - Content is parsed from markdown body
|
|
69
|
+
* - Defaults: status='active', hidden=false, empty metadata/tags
|
|
70
|
+
*
|
|
71
|
+
* @param markdown - The markdown string to parse
|
|
72
|
+
* @returns A Conversation object
|
|
73
|
+
* @throws {MarkdownParseError} If the markdown format is invalid (e.g., unknown role)
|
|
74
|
+
*/
|
|
75
|
+
export declare function fromMarkdown(markdown: string): Conversation;
|
|
76
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/utilities/markdown.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EAOb,MAAM,UAAU,CAAC;AA6ElB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CACxB,YAAY,EAAE,YAAY,EAC1B,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAQR;AAqFD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AASD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAW3D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MultiModalContent } from '@lasercat/homogenaize';
|
|
2
|
+
import type { Message, MessageJSON } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Creates an immutable Message from a JSON representation.
|
|
5
|
+
* Deep copies nested objects and arrays to ensure immutability.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createMessage(props: MessageJSON): Message;
|
|
8
|
+
/**
|
|
9
|
+
* Converts an immutable Message to a mutable JSON representation.
|
|
10
|
+
* Creates deep copies of all nested objects.
|
|
11
|
+
*/
|
|
12
|
+
export declare function messageToJSON(message: Message): MessageJSON;
|
|
13
|
+
/**
|
|
14
|
+
* Extracts the content parts from a message as a multi-modal array.
|
|
15
|
+
* String content is converted to a single text part.
|
|
16
|
+
*/
|
|
17
|
+
export declare function messageParts(message: Message): ReadonlyArray<MultiModalContent>;
|
|
18
|
+
/**
|
|
19
|
+
* Extracts all text content from a message, joined by the specified separator.
|
|
20
|
+
* Non-text parts are excluded from the result.
|
|
21
|
+
*/
|
|
22
|
+
export declare function messageText(message: Message, joiner?: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if a message contains any image content.
|
|
25
|
+
*/
|
|
26
|
+
export declare function messageHasImages(message: Message): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Converts a message to a string representation.
|
|
29
|
+
* Images are rendered as markdown image syntax.
|
|
30
|
+
*/
|
|
31
|
+
export declare function messageToString(message: Message): string;
|
|
32
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/utilities/message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG/D,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGrD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAoBzD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAc3D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAO/E;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,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,33 @@
|
|
|
1
|
+
import type { MessageJSON, ToolResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a paired tool call with its optional result.
|
|
4
|
+
*/
|
|
5
|
+
export interface ToolCallPair {
|
|
6
|
+
/** The tool call */
|
|
7
|
+
call: {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
arguments: unknown;
|
|
11
|
+
};
|
|
12
|
+
/** The corresponding result, if available */
|
|
13
|
+
result?: ToolResult | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Pairs tool calls with their corresponding results from a list of messages.
|
|
17
|
+
*
|
|
18
|
+
* This is useful for UI rendering where tool calls and their results need
|
|
19
|
+
* to be displayed together. The function performs two passes:
|
|
20
|
+
* 1. Collects all tool results into a map by their callId
|
|
21
|
+
* 2. Pairs each tool call with its matching result (if any)
|
|
22
|
+
*
|
|
23
|
+
* @param messages - Array of messages that may contain tool calls and results
|
|
24
|
+
* @returns Array of tool call pairs, preserving the order of tool calls
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const pairs = pairToolCallsWithResults(conversation.messages);
|
|
29
|
+
* // pairs: [{ call: ToolCall, result?: ToolResult }, ...]
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function pairToolCallsWithResults(messages: readonly MessageJSON[]): ToolCallPair[];
|
|
33
|
+
//# sourceMappingURL=tool-calls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-calls.d.ts","sourceRoot":"","sources":["../../src/utilities/tool-calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oBAAoB;IACpB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,OAAO,CAAC;KACpB,CAAC;IACF,6CAA6C;IAC7C,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,SAAS,WAAW,EAAE,GAC/B,YAAY,EAAE,CAsBhB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-safe hasOwnProperty check.
|
|
3
|
+
* Narrows the type to include the checked property.
|
|
4
|
+
*/
|
|
5
|
+
export declare function hasOwnProperty<X extends object, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
|
|
6
|
+
/**
|
|
7
|
+
* Casts a value to its readonly variant.
|
|
8
|
+
* Used to enforce immutability at the type level.
|
|
9
|
+
*/
|
|
10
|
+
export declare function toReadonly<T>(value: T): Readonly<T>;
|
|
11
|
+
//# sourceMappingURL=type-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-helpers.d.ts","sourceRoot":"","sources":["../../src/utilities/type-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,WAAW,EACpE,GAAG,EAAE,CAAC,EACN,IAAI,EAAE,CAAC,GACN,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAE/B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAEnD"}
|
package/dist/utilities.d.ts
CHANGED
|
@@ -1,153 +1,17 @@
|
|
|
1
|
-
import type { MultiModalContent } from '@lasercat/homogenaize';
|
|
2
|
-
import type { Conversation, Message, MessageJSON, ToolCall, ToolResult } from './types';
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
/**
|
|
80
|
-
* Options for the toMarkdown function.
|
|
81
|
-
*/
|
|
82
|
-
export interface ToMarkdownOptions {
|
|
83
|
-
/**
|
|
84
|
-
* Whether to include metadata (YAML frontmatter with message metadata)
|
|
85
|
-
* for lossless round-trip conversion.
|
|
86
|
-
*
|
|
87
|
-
* When `true`:
|
|
88
|
-
* - Includes YAML frontmatter with conversation and message metadata
|
|
89
|
-
* - Headers include message ID: `### Role (msg-id)`
|
|
90
|
-
* - Supports lossless round-trip via `fromMarkdown`
|
|
91
|
-
*
|
|
92
|
-
* When `false` (default):
|
|
93
|
-
* - Outputs clean, human-readable markdown
|
|
94
|
-
* - Headers only include role: `### Role`
|
|
95
|
-
*
|
|
96
|
-
* @default false
|
|
97
|
-
*/
|
|
98
|
-
includeMetadata?: boolean;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Converts a conversation to a Markdown string representation.
|
|
102
|
-
*
|
|
103
|
-
* By default, outputs clean, human-readable markdown with:
|
|
104
|
-
* - Each message with a header containing only the role: `### Role`
|
|
105
|
-
* - Message content rendered as markdown
|
|
106
|
-
*
|
|
107
|
-
* When `options.includeMetadata` is `true`, outputs markdown with full metadata
|
|
108
|
-
* for lossless round-trip conversion:
|
|
109
|
-
* - YAML frontmatter with conversation metadata and all message metadata keyed by message ID
|
|
110
|
-
* - Headers include message ID: `### Role (msg-id)`
|
|
111
|
-
* - Full content array preserved for multi-modal messages
|
|
112
|
-
*
|
|
113
|
-
* For multi-modal content:
|
|
114
|
-
* - Text parts are appended in order
|
|
115
|
-
* - Image parts are rendered as `` on their own line
|
|
116
|
-
*
|
|
117
|
-
* @param conversation - The conversation to convert
|
|
118
|
-
* @param options - Options for markdown output
|
|
119
|
-
* @returns A Markdown string representation of the conversation
|
|
120
|
-
*/
|
|
121
|
-
export declare function toMarkdown(conversation: Conversation, options?: ToMarkdownOptions): string;
|
|
122
|
-
/**
|
|
123
|
-
* Error thrown when markdown parsing fails.
|
|
124
|
-
*/
|
|
125
|
-
export declare class MarkdownParseError extends Error {
|
|
126
|
-
constructor(message: string);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Parses a Markdown string back into a Conversation object.
|
|
130
|
-
*
|
|
131
|
-
* This is the inverse of `toMarkdown` and supports both:
|
|
132
|
-
* - Lossless round-trip conversion when markdown includes metadata
|
|
133
|
-
* (generated by `toMarkdown` with `includeMetadata: true`)
|
|
134
|
-
* - Best-effort parsing of simple markdown without metadata
|
|
135
|
-
* (generated by `toMarkdown` with `includeMetadata: false` or hand-written)
|
|
136
|
-
*
|
|
137
|
-
* When metadata is present:
|
|
138
|
-
* - YAML frontmatter provides conversation and message metadata
|
|
139
|
-
* - Headers include message ID: `### Role (msg-id)`
|
|
140
|
-
* - Full fidelity is preserved
|
|
141
|
-
*
|
|
142
|
-
* When metadata is absent:
|
|
143
|
-
* - Conversation ID and timestamps are generated
|
|
144
|
-
* - Message IDs are generated, positions are inferred from order
|
|
145
|
-
* - Content is parsed from markdown body
|
|
146
|
-
* - Defaults: status='active', hidden=false, empty metadata/tags
|
|
147
|
-
*
|
|
148
|
-
* @param markdown - The markdown string to parse
|
|
149
|
-
* @returns A Conversation object
|
|
150
|
-
* @throws {MarkdownParseError} If the markdown format is invalid (e.g., unknown role)
|
|
151
|
-
*/
|
|
152
|
-
export declare function fromMarkdown(markdown: string): Conversation;
|
|
2
|
+
* This file re-exports all utilities from the utilities/ directory.
|
|
3
|
+
* For new code, prefer importing directly from the specific modules:
|
|
4
|
+
* - './utilities/content' for content normalization
|
|
5
|
+
* - './utilities/markdown' for markdown conversion
|
|
6
|
+
* - './utilities/message' for message utilities
|
|
7
|
+
* - './utilities/tool-calls' for tool call pairing
|
|
8
|
+
* - './utilities/type-helpers' for type guard helpers
|
|
9
|
+
*/
|
|
10
|
+
export { normalizeContent, toMultiModalArray } from './utilities/content';
|
|
11
|
+
export type { ToMarkdownOptions } from './utilities/markdown';
|
|
12
|
+
export { fromMarkdown, MarkdownParseError, toMarkdown } from './utilities/markdown';
|
|
13
|
+
export { createMessage, messageHasImages, messageParts, messageText, messageToJSON, messageToString, } from './utilities/message';
|
|
14
|
+
export type { ToolCallPair } from './utilities/tool-calls';
|
|
15
|
+
export { pairToolCallsWithResults } from './utilities/tool-calls';
|
|
16
|
+
export { hasOwnProperty, toReadonly } from './utilities/type-helpers';
|
|
153
17
|
//# sourceMappingURL=utilities.d.ts.map
|
package/dist/utilities.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG1E,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGpF,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGlE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC"}
|