Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Dependencies
node_modules/
/package-lock.json
.pnpm-store/

# Turborepo
.turbo
Expand Down
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,10 @@ <h2>Documentation</h2>
<p>Complete API reference and guides</p>
</div>
<div class="docs-grid">
<a href="llms-full.md" class="doc-card doc-card-llm">
<a href="llms-full.txt" class="doc-card doc-card-llm">
<div class="doc-icon">🤖</div>
<h3>Full LLM friendly Documentation</h3>
<p>Comprehensive llms-full.md for LLMs, AI agents, and vibe coding — copy the entire file into your
<p>Comprehensive llms-full.txt for LLMs, AI agents, and vibe coding — copy the entire file into your
context</p>
</a>
<a href="https://github.com/dh7/mindcache/blob/main/packages/mindcache/src/react/README.md" class="doc-card">
Expand Down
3 changes: 0 additions & 3 deletions docs/llms-full.md → docs/llms-full.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{% raw %}
# MindCache - Complete LLM Documentation

> This document is optimized for LLMs to understand and work with MindCache. It contains comprehensive API documentation with extensive code examples.
Expand Down Expand Up @@ -2480,5 +2479,3 @@ NEXT_PUBLIC_INSTANCE_ID=your-instance-id
---

*This documentation is optimized for LLM consumption. For human-readable documentation with interactive examples, visit [mindcache.dev](https://mindcache.dev).*
{% endraw %}

4 changes: 2 additions & 2 deletions docs/llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ MindCache 3.7 provides persistent memory for AI agents with drop-in React compon
## Quick Links

- Documentation: https://mindcache.dev
- Full LLM Documentation: https://mindcache.dev/llms-full.md
- Full LLM Documentation: https://mindcache.dev/llms-full.txt
- GitHub: https://github.com/dh7/mindcache
- npm: https://www.npmjs.com/package/mindcache

Expand Down Expand Up @@ -139,5 +139,5 @@ const { status, save, load } = useLocalFirstSync({ mindcache, gitstore: { owner,

## Full Documentation

See https://mindcache.dev/llms-full.md
See https://mindcache.dev/llms-full.txt

2 changes: 1 addition & 1 deletion packages/mindcache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A TypeScript library for managing short-term memory in AI agents through an LLM-
## Documentation

* **[API Reference](./docs/mindcache-api.md)**: Detailed method signatures and type definitions. Optimized for AI agents (like Cursor, Claude, etc.) to understand the library's capabilities.
* **[Full Documentation](https://mindcache.dev/llms-full.md)**: Comprehensive guide with examples and deep dives.
* **[Full Documentation](https://mindcache.dev/llms-full.txt)**: Comprehensive guide with examples and deep dives.

## Quick Start

Expand Down
2 changes: 1 addition & 1 deletion packages/mindcache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mindcache",
"version": "3.8.0",
"version": "3.8.1",
"description": "A TypeScript library for managing short-term memory in AI agents through an LLM-friendly key-value repository",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
3 changes: 2 additions & 1 deletion packages/mindcache/src/core/MindCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,8 @@ export class MindCache {
if (!this._idbProvider) {
return resolve();
}
this._idbProvider.on('synced', () => {
// Cast needed: IndexeddbPersistence extends Observable which has 'on' method
(this._idbProvider as unknown as { on: (event: string, cb: () => void) => void }).on('synced', () => {
this._isLoaded = true;
resolve();
});
Expand Down
32 changes: 19 additions & 13 deletions packages/mindcache/src/react/useClientChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ export function useClientChat(options: UseClientChatOptions = {}): UseClientChat
setError(null);
setStreamingContent('');

// Track accumulated text for abort handling
let accumulatedText = '';

try {
// Get model from context (handles provider config automatically)
const model = context.getModel();
Expand All @@ -207,7 +210,6 @@ export function useClientChat(options: UseClientChatOptions = {}): UseClientChat

// Accumulated parts for the final message
const parts: MessagePart[] = [];
let accumulatedText = '';

// Stream the response with real-time updates
const result = await streamText({
Expand Down Expand Up @@ -250,11 +252,7 @@ export function useClientChat(options: UseClientChatOptions = {}): UseClientChat
}
}
}

// Add text from this step if any
if (step.text) {
accumulatedText += step.text;
}
// Note: Don't accumulate step.text here - it's already in textStream
}
});

Expand All @@ -264,16 +262,19 @@ export function useClientChat(options: UseClientChatOptions = {}): UseClientChat
setStreamingContent(accumulatedText);
}

// Get final text from result (authoritative, avoids any streaming duplication)
const finalText = await result.text;

// Build final message with parts
if (accumulatedText) {
parts.unshift({ type: 'text', text: accumulatedText });
if (finalText) {
parts.unshift({ type: 'text', text: finalText });
}

// Add assistant message with all parts
const assistantMessage: ChatMessage = {
id: generateId(),
role: 'assistant',
content: accumulatedText,
content: finalText,
parts: parts.length > 0 ? parts : undefined,
createdAt: new Date()
};
Expand All @@ -284,13 +285,18 @@ export function useClientChat(options: UseClientChatOptions = {}): UseClientChat
onFinish?.(assistantMessage);

} catch (err) {
if ((err as Error).name === 'AbortError') {
// If we have partial content, save it
if (streamingContent) {
const errorMessage = err instanceof Error ? err.message : String(err);
const isAborted = (err as Error).name === 'AbortError' ||
errorMessage.includes('aborted') ||
errorMessage.includes('No output generated');

if (isAborted) {
// If we have partial content from streaming, save it
if (accumulatedText) {
const partialMessage: ChatMessage = {
id: generateId(),
role: 'assistant',
content: streamingContent + ' [stopped]',
content: accumulatedText + ' [stopped]',
createdAt: new Date()
};
setMessages(prev => [...prev, partialMessage]);
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@types/ws": "^8.5.0",
"typescript": "^5.0.0",
"vitest": "^2.0.0",
"wrangler": "^4.51.0",
"wrangler": "^4.59.1",
"ws": "^8.18.0"
},
"dependencies": {
Expand Down
Loading
Loading