conversationalist 0.0.3 → 0.0.4
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 +103 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3763 -46
- package/dist/index.js.map +48 -4
- package/dist/utilities.d.ts +75 -1
- package/dist/utilities.d.ts.map +1 -1
- package/package.json +3 -2
package/dist/utilities.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MultiModalContent } from '@lasercat/homogenaize';
|
|
2
|
-
import type { Message, MessageJSON, ToolCall, ToolResult } from './types';
|
|
2
|
+
import type { Conversation, Message, MessageJSON, ToolCall, ToolResult } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Represents a paired tool call with its optional result.
|
|
5
5
|
*/
|
|
@@ -76,4 +76,78 @@ export declare function messageHasImages(message: Message): boolean;
|
|
|
76
76
|
* Images are rendered as markdown image syntax.
|
|
77
77
|
*/
|
|
78
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;
|
|
79
153
|
//# 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,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI/D,OAAO,KAAK,EACV,YAAY,EAEZ,OAAO,EACP,WAAW,EAGX,QAAQ,EACR,UAAU,EACX,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oBAAoB;IACpB,IAAI,EAAE,QAAQ,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;AAED;;;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,wB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AAY,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAW3D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "conversationalist",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "A TypeScript library for managing AI conversation state",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"conversation",
|
|
@@ -81,7 +81,8 @@
|
|
|
81
81
|
]
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"change-case": "^5.4.4"
|
|
84
|
+
"change-case": "^5.4.4",
|
|
85
|
+
"gray-matter": "^4.0.3"
|
|
85
86
|
},
|
|
86
87
|
"devDependencies": {
|
|
87
88
|
"@anthropic-ai/sdk": "^0.71.2",
|