@jini-ai/chat 0.7.1 → 0.7.3-next.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/CHANGELOG.md +2 -2
- package/README.md +3 -3
- package/dist/contracts/chat-bubble-style.d.ts +1 -1
- package/dist/contracts/chat-bubble-style.js +1 -1
- package/dist/core/ag-ui/event-projection.d.ts +125 -0
- package/dist/core/ag-ui/event-projection.js +275 -0
- package/dist/core/ag-ui/event-reduction.d.ts +39 -0
- package/dist/core/ag-ui/event-reduction.js +99 -0
- package/dist/core/ag-ui/run-input.d.ts +53 -0
- package/dist/core/ag-ui/run-input.js +87 -0
- package/dist/core/agentic/chat-capabilities.d.ts +1 -1
- package/dist/core/agentic/index.d.ts +2 -4
- package/dist/core/agentic/index.js +2 -3
- package/dist/core/agents-port.d.ts +50 -0
- package/dist/core/agents-port.js +2 -0
- package/dist/core/assistant-client/ag-ui-fetch-agent.d.ts +16 -0
- package/dist/core/assistant-client/ag-ui-fetch-agent.js +24 -0
- package/dist/core/assistant-client/ag-ui-transport.d.ts +15 -1
- package/dist/core/assistant-client/ag-ui-transport.js +167 -145
- package/dist/core/assistant-client/attachment-liveness.js +13 -11
- package/dist/core/assistant-client/durable-run-subscription.d.ts +3 -2
- package/dist/core/assistant-client/durable-run-subscription.js +6 -5
- package/dist/core/assistant-client/messages.d.ts +7 -4
- package/dist/core/assistant-client/messages.js +5 -4
- package/dist/core/assistant-client/transport.d.ts +1 -1
- package/dist/core/assistant-client/transport.js +4 -4
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +1 -0
- package/dist/core/page-port.d.ts +15 -0
- package/dist/core/page-port.js +2 -0
- package/dist/core/run-activity.js +1 -1
- package/dist/core/run-events/entry.js +1 -0
- package/dist/core/user-text-redaction.d.ts +1 -3
- package/dist/core/user-text-redaction.js +3 -61
- package/dist/embed-widget/browser/agent-inventory.d.ts +37 -0
- package/dist/embed-widget/browser/agent-inventory.js +36 -0
- package/dist/embed-widget/browser/frontend-session-bridge.d.ts +2 -2
- package/dist/embed-widget/browser/frontend-session-bridge.js +17 -14
- package/dist/embed-widget/react/dialog.hooks.d.ts +16 -0
- package/dist/embed-widget/react/dialog.hooks.js +15 -0
- package/dist/embed-widget/react/embed.d.ts +7 -2
- package/dist/embed-widget/react/embed.js +6 -16
- package/dist/embed-widget/react/header.d.ts +4 -1
- package/dist/embed-widget/react/header.js +2 -2
- package/dist/embed-widget/vanilla/state.js +2 -2
- package/dist/embed-widget/vanilla/style.css +4 -4
- package/dist/react/components/A2uiSurfaceCard.d.ts +18 -4
- package/dist/react/components/A2uiSurfaceCard.hooks.d.ts +36 -0
- package/dist/react/components/A2uiSurfaceCard.hooks.js +174 -0
- package/dist/react/components/A2uiSurfaceCard.js +14 -227
- package/dist/react/components/A2uiSurfaceCard.rules.d.ts +14 -0
- package/dist/react/components/A2uiSurfaceCard.rules.js +24 -0
- package/dist/react/components/AttachmentPreviewModal.d.ts +21 -1
- package/dist/react/components/AttachmentPreviewModal.hooks.js +1 -3
- package/dist/react/components/AttachmentPreviewModal.js +11 -9
- package/dist/react/components/AttachmentTray.d.ts +11 -1
- package/dist/react/components/AttachmentTray.js +12 -8
- package/dist/react/components/ChatFab.d.ts +10 -1
- package/dist/react/components/ChatFab.js +2 -2
- package/dist/react/components/ChatSettingsDialog.d.ts +4 -3
- package/dist/react/components/ChatSettingsDialog.js +9 -6
- package/dist/react/components/ChatSettingsSegmented.d.ts +1 -1
- package/dist/react/components/ChatSettingsSegmented.js +1 -1
- package/dist/react/components/Composer.d.ts +9 -1
- package/dist/react/components/Composer.hooks.d.ts +79 -0
- package/dist/react/components/Composer.hooks.js +336 -0
- package/dist/react/components/Composer.js +40 -341
- package/dist/react/components/ComposerDiscovery.js +1 -1
- package/dist/react/components/ConversationList.d.ts +34 -1
- package/dist/react/components/ConversationList.hooks.d.ts +37 -0
- package/dist/react/components/ConversationList.hooks.js +177 -1
- package/dist/react/components/ConversationList.js +7 -174
- package/dist/react/components/ConversationTitleEditor.d.ts +17 -2
- package/dist/react/components/ConversationTitleEditor.hooks.d.ts +15 -0
- package/dist/react/components/ConversationTitleEditor.hooks.js +36 -0
- package/dist/react/components/ConversationTitleEditor.js +11 -34
- package/dist/react/components/CopyMessageButton.d.ts +6 -1
- package/dist/react/components/CopyMessageButton.js +4 -4
- package/dist/react/components/ExtEventErrorBoundary.d.ts +2 -0
- package/dist/react/components/ExtEventErrorBoundary.js +5 -3
- package/dist/react/components/FolderChips.d.ts +11 -1
- package/dist/react/components/FolderChips.hooks.d.ts +12 -0
- package/dist/react/components/FolderChips.hooks.js +10 -0
- package/dist/react/components/FolderChips.js +9 -9
- package/dist/react/components/Markdown.js +7 -5
- package/dist/react/components/McpUiSurfaceCard.d.ts +29 -5
- package/dist/react/components/McpUiSurfaceCard.js +29 -16
- package/dist/react/components/MessageList.d.ts +10 -1
- package/dist/react/components/MessageList.hooks.js +4 -2
- package/dist/react/components/MessageList.js +12 -8
- package/dist/react/components/MessageRow.d.ts +46 -2
- package/dist/react/components/MessageRow.hooks.d.ts +60 -0
- package/dist/react/components/MessageRow.hooks.js +94 -0
- package/dist/react/components/MessageRow.js +53 -113
- package/dist/react/components/MidRunUserMessage.d.ts +6 -1
- package/dist/react/components/MidRunUserMessage.js +5 -5
- package/dist/react/components/NextStepActions.d.ts +3 -1
- package/dist/react/components/NextStepActions.js +3 -3
- package/dist/react/components/QuestionForm.answers.hooks.d.ts +26 -0
- package/dist/react/components/QuestionForm.answers.hooks.js +89 -0
- package/dist/react/components/QuestionForm.d.ts +6 -0
- package/dist/react/components/QuestionForm.js +23 -261
- package/dist/react/components/QuestionForm.values.d.ts +22 -0
- package/dist/react/components/QuestionForm.values.js +58 -0
- package/dist/react/components/QuestionFormField.d.ts +17 -0
- package/dist/react/components/QuestionFormField.js +114 -0
- package/dist/react/components/QuestionsPanel.d.ts +3 -1
- package/dist/react/components/QuestionsPanel.js +7 -3
- package/dist/react/components/SentAttachment.d.ts +11 -2
- package/dist/react/components/SentAttachment.hooks.d.ts +1 -1
- package/dist/react/components/SentAttachment.hooks.js +6 -5
- package/dist/react/components/SentAttachment.js +5 -3
- package/dist/react/components/TodoCard.d.ts +3 -1
- package/dist/react/components/TodoCard.js +9 -4
- package/dist/react/components/ToolCallGroup.d.ts +11 -1
- package/dist/react/components/ToolCallGroup.js +10 -4
- package/dist/react/components/ToolCard.d.ts +6 -1
- package/dist/react/components/ToolCard.js +79 -69
- package/dist/react/components/mcp-ui-question-input.d.ts +1 -1
- package/dist/react/components/mcp-ui-question-input.js +3 -3
- package/dist/react/components/mcp-ui-surface-state.d.ts +1 -1
- package/dist/react/features/chat-pane/agent-tools.d.ts +1 -1
- package/dist/react/features/chat-pane/antigravity/model-options.d.ts +2 -0
- package/dist/react/features/chat-pane/antigravity/model-options.js +2 -0
- package/dist/react/features/chat-pane/claude/model-options.d.ts +2 -0
- package/dist/react/features/chat-pane/claude/model-options.js +2 -0
- package/dist/react/features/chat-pane/codex/model-options.d.ts +2 -0
- package/dist/react/features/chat-pane/codex/model-options.js +2 -0
- package/dist/react/features/chat-pane/components/AgentPluginUsage.d.ts +4 -1
- package/dist/react/features/chat-pane/components/AgentPluginUsage.js +2 -2
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +10 -6
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +18 -132
- package/dist/react/features/chat-pane/components/ChatPane.d.ts +24 -2
- package/dist/react/features/chat-pane/components/ChatPane.js +45 -297
- package/dist/react/features/chat-pane/components/ChatPaneComposerArea.d.ts +33 -0
- package/dist/react/features/chat-pane/components/ChatPaneComposerArea.js +119 -0
- package/dist/react/features/chat-pane/components/ChatPaneLayout.d.ts +42 -0
- package/dist/react/features/chat-pane/components/ChatPaneLayout.js +54 -0
- package/dist/react/features/chat-pane/components/ChatPaneStatus.d.ts +27 -0
- package/dist/react/features/chat-pane/components/ChatPaneStatus.js +91 -0
- package/dist/react/features/chat-pane/components/RuntimeDropUp.d.ts +6 -1
- package/dist/react/features/chat-pane/components/RuntimeDropUp.js +20 -19
- package/dist/react/features/chat-pane/components/RuntimePickerSections.d.ts +62 -0
- package/dist/react/features/chat-pane/components/RuntimePickerSections.js +122 -0
- package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts +1 -1
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +5 -3
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +78 -26
- package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js +6 -6
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts +5 -1
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js +7 -7
- package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.d.ts +7 -0
- package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.js +5 -0
- package/dist/react/features/chat-pane/model-options.js +7 -4
- package/dist/react/features/chat-pane/styles.d.ts +1 -1
- package/dist/react/features/chat-pane/styles.js +14 -14
- package/dist/react/features/chat-pane/types.d.ts +29 -1
- package/dist/react/hooks/assistant-chats-contracts.d.ts +1 -1
- package/dist/react/hooks/attachment-preview-cache.d.ts +1 -1
- package/dist/react/hooks/attachment-preview-cache.js +1 -1
- package/dist/react/hooks/fab-position.js +16 -18
- package/dist/react/hooks/useConversation.d.ts +6 -1
- package/dist/react/hooks/useConversation.js +11 -10
- package/dist/react/hooks/useRunStream.d.ts +3 -0
- package/dist/react/hooks/useRunStream.js +12 -12
- package/dist/react/hooks/useSurfaceRecovery.d.ts +1 -1
- package/dist/react/hooks/useSurfaceRecovery.js +2 -2
- package/dist/react/index.d.ts +6 -3
- package/dist/react/index.js +5 -3
- package/dist/react/styles/chat-settings.css +9 -9
- package/dist/react/surfaces.d.ts +91 -0
- package/dist/react/surfaces.js +28 -0
- package/dist/server/durable-runs/recover.d.ts +4 -3
- package/dist/server/durable-runs/recover.js +4 -3
- package/dist/store/legacy/sqlite/conversations.d.ts +1 -2
- package/dist/store/legacy/sqlite/conversations.js +1 -1
- package/dist/store/legacy/sqlite/messages.d.ts +2 -3
- package/dist/store/legacy/sqlite/messages.js +6 -6
- package/dist/store/pglite/index.d.ts +7 -7
- package/dist/store/pglite/index.js +1 -1
- package/dist/store/ports.d.ts +5 -2
- package/dist/store/postgres/index.d.ts +7 -7
- package/dist/store/postgres/index.js +1 -1
- package/dist/store/runtime/chat-expiry-sweep.js +2 -4
- package/dist/store/runtime/chat-history-store.js +2 -3
- package/dist/store/runtime/durable-run-store.js +16 -2
- package/dist/store/runtime/history-tools.js +33 -11
- package/dist/store/runtime/kernel.d.ts +3 -2
- package/dist/store/runtime/run-ledger.js +2 -2
- package/dist/store/sql/boundary.d.ts +5 -5
- package/dist/store/sql/maintenance.d.ts +3 -2
- package/dist/store/sql/store.d.ts +16 -8
- package/dist/store/sql/store.js +31 -14
- package/dist/store/sqlite/index.d.ts +11 -12
- package/dist/store/sqlite/index.js +5 -5
- package/dist/store/sqlite/schema.d.ts +1 -1
- package/package.json +46 -24
- package/dist/core/ag-ui/entry.d.ts +0 -84
- package/dist/core/ag-ui/entry.js +0 -225
package/dist/store/ports.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Owner-scoped, provider-neutral durable transcripts. See README for paging and composition. */
|
|
2
2
|
import type { ChatMessage } from '../core/messages.js';
|
|
3
|
+
import type { ListPage } from '@jini-ai/core/list-page';
|
|
3
4
|
export type ChatOwnerKind = 'user' | 'guest';
|
|
4
5
|
export type ChatTitleSource = 'fallback' | 'generated' | 'manual';
|
|
5
6
|
export interface ChatOwnerScope {
|
|
@@ -117,12 +118,14 @@ export interface ChatStore {
|
|
|
117
118
|
export type ChatHistoryStore = Pick<ChatStore, 'list' | 'get' | 'create' | 'rename' | 'touch' | 'delete' | 'messages' | 'message' | 'messagesJson' | 'messagesVersion' | 'appendMessage' | 'history'>;
|
|
118
119
|
/** Internal persistence projections. Model-facing tools redact and cap these before returning. */
|
|
119
120
|
export interface ChatHistoryReader {
|
|
121
|
+
/** Owner-scoped history, newest first; nextCursor continues after the last returned conversation. */
|
|
120
122
|
list(required: Record<string, never>, optional?: {
|
|
121
123
|
query?: string;
|
|
122
124
|
limit?: number;
|
|
123
|
-
|
|
125
|
+
cursor?: string | null;
|
|
126
|
+
}): Promise<ListPage<ChatConversation & {
|
|
124
127
|
firstUserLine: string;
|
|
125
|
-
}
|
|
128
|
+
}>>;
|
|
126
129
|
read(required: {
|
|
127
130
|
chatId: string;
|
|
128
131
|
}, optional?: {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import type { UserTextRedactionOptions } from '../../core/user-text-redaction.js';
|
|
2
2
|
/** Postgres transcript adapter. The host owns the opened, migrated kernel and its lifetime. */
|
|
3
3
|
import type { Clock } from '@jini-ai/core/primitives';
|
|
4
|
-
import type { StorageKernel } from '@jini-ai/
|
|
4
|
+
import type { StorageKernel } from '@jini-ai/core/contracts/storage';
|
|
5
5
|
import type { ChatDatabase } from '../sql/tables.js';
|
|
6
6
|
import type { ChatOwnerScope, ChatStore, ChatHistoryMaintenance } from '../ports.js';
|
|
7
|
+
import type { Kysely } from 'kysely';
|
|
7
8
|
export type { ChatDatabase, AiChatsTable, AiChatMessagesTable } from '../sql/tables.js';
|
|
8
9
|
/** Borrow an existing kernel, with no configuration, migration or connection lifecycle effects.
|
|
9
|
-
* @example createPostgresChatStore({ kernel, scope
|
|
10
|
+
* @example createPostgresChatStore({ kernel, scope, clock: { nowMs: () => 42 } })
|
|
10
11
|
* @throws ChatStoreError invalid-input for a mismatched dialect/transport or owner scope.
|
|
11
12
|
*/
|
|
12
13
|
export declare function createPostgresChatStore<DB extends ChatDatabase>(required: {
|
|
13
|
-
kernel: StorageKernel<DB>;
|
|
14
|
+
kernel: StorageKernel<Kysely<DB>, DB>;
|
|
14
15
|
scope: ChatOwnerScope;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} & UserTextRedactionOptions): ChatStore;
|
|
16
|
+
clock: Clock;
|
|
17
|
+
}, optional?: UserTextRedactionOptions): ChatStore;
|
|
18
18
|
/** Privileged bounded expiry maintenance; never hand this collaborator to request handlers. */
|
|
19
19
|
export declare function createPostgresChatMaintenance<DB extends ChatDatabase>(required: {
|
|
20
|
-
kernel: StorageKernel<DB>;
|
|
20
|
+
kernel: StorageKernel<Kysely<DB>, DB>;
|
|
21
21
|
}): ChatHistoryMaintenance;
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { createSqlChatStore } from '../sql/store.js';
|
|
|
2
2
|
import { createSqlChatMaintenance } from '../sql/maintenance.js';
|
|
3
3
|
import { validateKernel } from '../sql/boundary.js';
|
|
4
4
|
/** Borrow an existing kernel, with no configuration, migration or connection lifecycle effects.
|
|
5
|
-
* @example createPostgresChatStore({ kernel, scope
|
|
5
|
+
* @example createPostgresChatStore({ kernel, scope, clock: { nowMs: () => 42 } })
|
|
6
6
|
* @throws ChatStoreError invalid-input for a mismatched dialect/transport or owner scope.
|
|
7
7
|
*/
|
|
8
8
|
export function createPostgresChatStore(required, optional = {}) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { redactSecrets } from '@jini-ai/core';
|
|
1
|
+
import { createConsoleLogger } from '@jini-ai/core/primitives';
|
|
3
2
|
import { ChatStoreError } from "../errors.js";
|
|
4
3
|
/**
|
|
5
4
|
* @file Retention for chat history: deletes every conversation whose `expires_at` has passed.
|
|
@@ -48,8 +47,7 @@ export function startChatExpirySweep({ maintenance }, options = {}) {
|
|
|
48
47
|
const { intervalMs = CHAT_EXPIRY_SWEEP_INTERVAL_MS, now = Date.now } = options;
|
|
49
48
|
const onError = options.onError ??
|
|
50
49
|
((error) => {
|
|
51
|
-
|
|
52
|
-
console.warn('[chat-expiry-sweep] sweep failed:', redactSecrets({ input: inspect(error) }, { redactPii: false }));
|
|
50
|
+
createConsoleLogger({ prefix: '' }).warn({ message: '[chat-expiry-sweep] sweep failed:' }, { error });
|
|
53
51
|
});
|
|
54
52
|
let active;
|
|
55
53
|
const pass = () => {
|
|
@@ -40,10 +40,9 @@ function repairLegacyTurnOrder({ messages, isDaemonRunId }, _optional = {}) {
|
|
|
40
40
|
*/
|
|
41
41
|
export function createChatHistoryStore({ kernel: hostKernel, scope, isDaemonRunId }, { now = Date.now } = {}) {
|
|
42
42
|
const kernel = chatKernelTables({ kernel: hostKernel }, {});
|
|
43
|
-
const required = { kernel, scope };
|
|
44
|
-
const optional = { clock: { nowMs: now } };
|
|
43
|
+
const required = { kernel, scope, clock: { nowMs: now } };
|
|
45
44
|
const createStore = storeFactory(kernel.transport);
|
|
46
|
-
const store = createStore(required,
|
|
45
|
+
const store = createStore(required, {});
|
|
47
46
|
return { ...store,
|
|
48
47
|
// Admin reload and recovery use this full-transcript compatibility read. Preserve stored
|
|
49
48
|
// positions (and Jini's position-based page cursors); existing user databases need no migration.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sqliteReadVersion } from '../sql/read-version.js';
|
|
2
2
|
import { acceptedInputEvent, acceptedInputUserEvent } from "../../core/accepted-input.js";
|
|
3
|
-
import { redactUserMessage } from "../../core/user-text-redaction.js";
|
|
3
|
+
import { redactUserMessage, redactUserText } from "../../core/user-text-redaction.js";
|
|
4
4
|
import { recoveredRunEvents } from "../../core/index.js";
|
|
5
5
|
import { chatKernelTables } from "../sql/boundary.js";
|
|
6
6
|
import { sql } from "kysely";
|
|
@@ -74,6 +74,20 @@ function acceptedUserMessage({ request, now }, _optional = {}) {
|
|
|
74
74
|
...(message.folders ? { folders: message.folders } : {}),
|
|
75
75
|
...(message.attachments ? { attachments: message.attachments } : {}) };
|
|
76
76
|
}
|
|
77
|
+
/** The request as it is stored for recovery and replay. The user row is masked when it is written; the request carries
|
|
78
|
+
* the same text (the user message and the prompt built from it), so it is masked before it is serialized at all.
|
|
79
|
+
* A request with nothing to mask is returned as it came. */
|
|
80
|
+
function maskedRequest({ request }, _optional = {}) {
|
|
81
|
+
const context = JSON.parse(request.contextRef);
|
|
82
|
+
const mask = (text) => typeof text === "string" ? redactUserText({ text }) : null;
|
|
83
|
+
const content = mask(context.userMessage?.content);
|
|
84
|
+
const prompt = mask(context.prompt);
|
|
85
|
+
if (!content?.secretRedacted && !prompt?.secretRedacted)
|
|
86
|
+
return request;
|
|
87
|
+
return { ...request, contextRef: JSON.stringify({ ...context,
|
|
88
|
+
...(content ? { userMessage: { ...context.userMessage, content: content.text } } : {}),
|
|
89
|
+
...(prompt ? { prompt: prompt.text } : {}) }) };
|
|
90
|
+
}
|
|
77
91
|
function recoveryFields({ row, metadata }, _optional = {}) {
|
|
78
92
|
const saved = metadata ?? {};
|
|
79
93
|
return { recoveryCount: saved.recovery_count ?? 0, recoveryDeadline: saved.recovery_deadline ?? null,
|
|
@@ -344,7 +358,7 @@ export function createDurableRunStore({ kernel: hostKernel, isDaemonRunId }, _op
|
|
|
344
358
|
if (!await appendQueuedAnswer({ history, required, hasQuestion: userMessage !== null }))
|
|
345
359
|
return null;
|
|
346
360
|
await kernel.run((db) => db.insertInto("assistant_run_attempts").values({
|
|
347
|
-
message_id: required.messageId, engine: "daemon", accepted_json: JSON.stringify(required.request),
|
|
361
|
+
message_id: required.messageId, engine: "daemon", accepted_json: JSON.stringify(maskedRequest({ request: required.request }, {})),
|
|
348
362
|
recovery_count: 0, recovery_deadline: null, last_progress_at: required.now, cancel_reason: null,
|
|
349
363
|
recovery_elapsed_ms: 0, attempt_started_at: required.now,
|
|
350
364
|
session_id: null, session_confirmed: 0, child_pid: null, child_started_at: null, attempt_base_json: "[]",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Model-facing history tools over an authenticated owner-scoped store; no database handles. */
|
|
2
2
|
import { buildDomainRegistrations, indexCatalogById, requireInputRecord, ToolInputError } from '@jini-ai/core';
|
|
3
|
+
import { listPageForModel, parseListPageRequest } from '@jini-ai/core/list-page';
|
|
3
4
|
import { redactUserText } from '../../core/user-text-redaction.js';
|
|
4
5
|
import { assistantHistoryToolMetadata } from '../../core/history-tool-metadata.js';
|
|
5
6
|
export const HISTORY_MESSAGE_CHAR_CAP = 8_000;
|
|
@@ -14,6 +15,7 @@ export const assistantHistoryToolCatalog = indexCatalogById({ catalog: [
|
|
|
14
15
|
description: "Lists the CURRENT user's own conversations on this site, newest first, optionally searching titles and message content. Returns id, title, updatedAt, messageCount and firstUserLine, with redacted, capped text. When the user refers to an earlier or interrupted chat ('continue what we were doing'), list first, then assistant_chat_read to read its tail, summarise the state and continue. No other user's chats are accessible; unavailable history is an error.",
|
|
15
16
|
inputSchema: { type: 'object', additionalProperties: false, properties: {
|
|
16
17
|
query: { type: 'string', maxLength: 200 }, limit: { type: 'integer', minimum: 1, maximum: 50, default: 20 },
|
|
18
|
+
cursor: { type: 'string', description: 'nextCursor from the previous call. Omit for the first page.' },
|
|
17
19
|
} } },
|
|
18
20
|
{ name: 'assistant_chat_read', sideEffects: 'none', authorization: { permission: 'admin.assistant.use' },
|
|
19
21
|
description: "Reads one of the CURRENT user's own chats in stored message order. Omit fromPosition to read the latest tail (default 50 messages); use fromPosition and nextPosition for forward pagination. List chats first when resuming earlier work, read the tail, summarise the state, then continue. Returns redacted messages, positions, continuation and truncated flags; each serialized message is capped at 8,000 characters and the result at 40,000 characters. Tool events, when requested, contain only tool name and outcome, never payloads. Attachments are omitted. Missing and other-user chats receive the same refusal.",
|
|
@@ -102,12 +104,15 @@ async function openHistory({ ports, principalId }, _options = {}) {
|
|
|
102
104
|
throw new ToolInputError({ message: 'Chat history is unavailable on this site.' });
|
|
103
105
|
return { store, history: store.history };
|
|
104
106
|
}
|
|
107
|
+
/** Validate the model's search and page request before opening an owner-scoped store.
|
|
108
|
+
* @throws {ToolInputError} If an input field, query, limit or cursor is malformed. @complexity O(1).
|
|
109
|
+
*/
|
|
105
110
|
function listInput({ input: raw }, _options = {}) {
|
|
106
|
-
const input = inputRecord({ input: raw, keys: ['query', 'limit'] });
|
|
111
|
+
const input = inputRecord({ input: raw, keys: ['query', 'limit', 'cursor'] });
|
|
107
112
|
if (input.query !== undefined && (typeof input.query !== 'string' || input.query.length > 200))
|
|
108
113
|
throw new ToolInputError({ message: 'query must be a string of at most 200 characters.' });
|
|
109
|
-
const limit =
|
|
110
|
-
return { ...(input.query === undefined ? {} : { query: input.query }), limit };
|
|
114
|
+
const { limit, cursor } = parseListPageRequest({ value: input }, { defaultLimit: 20, maxLimit: 50 });
|
|
115
|
+
return { ...(input.query === undefined ? {} : { query: input.query }), limit, ...(cursor === null ? {} : { cursor }) };
|
|
111
116
|
}
|
|
112
117
|
function projectChatRow({ row, redact }, _options = {}) {
|
|
113
118
|
// Redact BEFORE slicing: a cap must not turn a credential into an undetectable fragment.
|
|
@@ -117,18 +122,35 @@ function projectChatRow({ row, redact }, _options = {}) {
|
|
|
117
122
|
return { truncated, chat: { id: redact({ text: row.id }).text.slice(0, 128), title: title.slice(0, 300), updatedAt: row.updatedAt,
|
|
118
123
|
messageCount: row.messageCount, firstUserLine: first.slice(0, 500) } };
|
|
119
124
|
}
|
|
125
|
+
/** Return one redacted owner-scoped history page with a cursor for every omitted conversation.
|
|
126
|
+
* Oversized escaped text can force a repeat read with a smaller page; the limit decreases on every
|
|
127
|
+
* repeat, so at most 50 bounded reads occur. Store errors and invalid input propagate.
|
|
128
|
+
* @complexity At most 50 reads of at most 51 rows, plus bounded response serialization per read.
|
|
129
|
+
*/
|
|
120
130
|
async function listChats({ ports, redact, ctx }, _options = {}) {
|
|
121
131
|
const options = listInput({ input: ctx.input });
|
|
122
132
|
const { history } = await openHistory({ ports, principalId: ctx.principal.id });
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
chats.
|
|
129
|
-
truncated =
|
|
133
|
+
let limit = options.limit;
|
|
134
|
+
let trimmed = false;
|
|
135
|
+
for (;;) {
|
|
136
|
+
const page = await history.list({}, { ...options, limit });
|
|
137
|
+
const projected = page.items.map(row => projectChatRow({ row, redact }));
|
|
138
|
+
const chats = projected.map(item => item.chat);
|
|
139
|
+
let truncated = trimmed || projected.some(item => item.truncated);
|
|
140
|
+
const { items: _items, ...continuation } = listPageForModel({ page, toolId: 'assistant_chats_list' });
|
|
141
|
+
// Escaped text may exceed the output budget. Re-read with a smaller limit so the store issues
|
|
142
|
+
// the owner-bound cursor for the last chat actually returned, rather than skipping popped rows.
|
|
143
|
+
while (chats.length > 0 && JSON.stringify({ chats, truncated, ...continuation }).length > HISTORY_TOTAL_CHAR_CAP) {
|
|
144
|
+
chats.pop();
|
|
145
|
+
truncated = true;
|
|
146
|
+
}
|
|
147
|
+
if (chats.length === projected.length)
|
|
148
|
+
return { chats, truncated, ...continuation };
|
|
149
|
+
if (chats.length === 0 || chats.length >= limit)
|
|
150
|
+
throw new ToolInputError({ message: 'Chat list exceeds its response size limit.' });
|
|
151
|
+
limit = chats.length;
|
|
152
|
+
trimmed = true;
|
|
130
153
|
}
|
|
131
|
-
return { chats, truncated };
|
|
132
154
|
}
|
|
133
155
|
function readInput({ input: raw }, _options = {}) {
|
|
134
156
|
const input = inputRecord({ input: raw, keys: ['chatId', 'fromPosition', 'limit', 'includeToolEvents'] });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { StorageKernel } from "@jini-ai/
|
|
1
|
+
import type { StorageKernel } from "@jini-ai/core/contracts/storage";
|
|
2
2
|
import type { ChatDatabase as TranscriptDatabase } from "../sql/tables.js";
|
|
3
|
+
import type { Kysely } from "kysely";
|
|
3
4
|
/** Borrowed existing chat tables; the host owns migrations and connection lifetime. */
|
|
4
5
|
export type ChatDatabase = TranscriptDatabase & {
|
|
5
6
|
assistant_agent_sessions: {
|
|
@@ -25,5 +26,5 @@ export type ChatDatabase = TranscriptDatabase & {
|
|
|
25
26
|
attempt_base_json: string;
|
|
26
27
|
};
|
|
27
28
|
};
|
|
28
|
-
export type ChatKernel<DB extends ChatDatabase = ChatDatabase> = StorageKernel<DB>;
|
|
29
|
+
export type ChatKernel<DB extends ChatDatabase = ChatDatabase> = StorageKernel<Kysely<DB>, DB>;
|
|
29
30
|
//# sourceMappingURL=kernel.d.ts.map
|
|
@@ -161,8 +161,8 @@ export function createChatRunLedger({ kernel: hostKernel, isDaemonRunId }, { now
|
|
|
161
161
|
optional.onPersisted(undefined);
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
// `run` keeps this read on the open transaction, under the write lock.
|
|
165
|
+
const receiptVersion = kernel.dialect === 'sqlite' ? (await kernel.run((db) => sql `select ${version} as version`.execute(db))).rows[0].version : nativeVersion;
|
|
166
166
|
optional.onPersisted(checkpointState({ progress, length, contentLength, version: receiptVersion }));
|
|
167
167
|
}
|
|
168
168
|
/** Full merge fallback, including identical-checkpoint write elision. One parse/stringify only. */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** SQL boundary validation and opaque driver error translation. */
|
|
2
|
-
import type { StorageKernel, StorageTransport } from '@jini-ai/
|
|
2
|
+
import type { StorageKernel, StorageTransport } from '@jini-ai/core/contracts/storage';
|
|
3
3
|
import type { Kysely } from 'kysely';
|
|
4
4
|
import type { ChatDatabase } from './tables.js';
|
|
5
5
|
import type { ChatOwnerScope } from '../ports.js';
|
|
6
6
|
/** Construction is validation-only: never query, migrate, reconfigure, open or close a kernel. */
|
|
7
7
|
export declare function validateKernel<DB>({ kernel, transports, dialect }: {
|
|
8
|
-
kernel: StorageKernel<DB>;
|
|
8
|
+
kernel: StorageKernel<Kysely<DB>, DB>;
|
|
9
9
|
transports: readonly StorageTransport[];
|
|
10
10
|
dialect: 'sqlite' | 'postgres';
|
|
11
11
|
}): void;
|
|
@@ -24,11 +24,11 @@ export declare function atStoreBoundary<T>({ operation }: {
|
|
|
24
24
|
* @complexity O(1) time and space; no wrapper, connection or transaction is created.
|
|
25
25
|
*/
|
|
26
26
|
export declare function chatKernelTables<DB extends Tables, Tables extends ChatDatabase = ChatDatabase>({ kernel }: {
|
|
27
|
-
kernel: StorageKernel<DB>;
|
|
28
|
-
}, _optional?: {}): StorageKernel<Tables>;
|
|
27
|
+
kernel: StorageKernel<Kysely<DB>, DB>;
|
|
28
|
+
}, _optional?: {}): StorageKernel<Kysely<Tables>, Tables>;
|
|
29
29
|
/** Execute a transcript query through the shared table-subset projection. */
|
|
30
30
|
export declare function runChatQuery<DB extends ChatDatabase, T>({ kernel, body }: {
|
|
31
|
-
kernel: StorageKernel<DB>;
|
|
31
|
+
kernel: StorageKernel<Kysely<DB>, DB>;
|
|
32
32
|
body: (db: Kysely<ChatDatabase>) => T | Promise<T>;
|
|
33
33
|
}): Promise<T>;
|
|
34
34
|
//# sourceMappingURL=boundary.d.ts.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/** Privileged bounded retention, kept separate from every request-scoped store. */
|
|
2
|
-
import type { StorageKernel } from '@jini-ai/
|
|
2
|
+
import type { StorageKernel } from '@jini-ai/core/contracts/storage';
|
|
3
3
|
import type { ChatDatabase } from './tables.js';
|
|
4
4
|
import type { ChatHistoryMaintenance } from '../ports.js';
|
|
5
|
+
import type { Kysely } from 'kysely';
|
|
5
6
|
/** Delete at most 500 expired parents; the host schema/foreign-key policy supplies cascades. */
|
|
6
7
|
export declare function createSqlChatMaintenance<DB extends ChatDatabase>({ kernel }: {
|
|
7
|
-
kernel: StorageKernel<DB>;
|
|
8
|
+
kernel: StorageKernel<Kysely<DB>, DB>;
|
|
8
9
|
}): ChatHistoryMaintenance;
|
|
9
10
|
//# sourceMappingURL=maintenance.d.ts.map
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/** One SQL query body upstreamed from the existing host adapter; no resource/schema ownership. */
|
|
2
|
+
/**
|
|
3
|
+
* Every read/write uses the authenticated (scope_id, owner_kind, owner_id) tuple; store construction
|
|
4
|
+
* must not turn a shared database into access to other owners' conversations. Append reads and
|
|
5
|
+
* assigns position in one transaction under the conversation lock: PostgreSQL READ COMMITTED alone
|
|
6
|
+
* cannot serialize two appends as SQLite BEGIN IMMEDIATE does. The unique conversation/position
|
|
7
|
+
* constraint remains the backstop, and nested appends join the host's existing transaction.
|
|
8
|
+
*/
|
|
9
|
+
import { type Kysely } from 'kysely';
|
|
10
|
+
import type { Clock } from '@jini-ai/core/primitives';
|
|
11
|
+
import { type StorageKernel } from '@jini-ai/core/contracts/storage';
|
|
3
12
|
import { type UserTextRedactionOptions } from '../../core/user-text-redaction.js';
|
|
4
13
|
import type { ChatMessage } from '../../core/messages.js';
|
|
5
14
|
import type { ChatStore, ChatOwnerScope } from '../ports.js';
|
|
@@ -36,15 +45,14 @@ export declare function validatedEventsJson({ row }: {
|
|
|
36
45
|
* `ON DELETE CASCADE` needs `foreign_keys = ON`, which the host must enable.
|
|
37
46
|
* @param scope the isolation predicate, resolved from the host's authentication. For a guest,
|
|
38
47
|
* `ownerId` must already be a hash of the session key (`tenant-scope.ts`).
|
|
39
|
-
* @param
|
|
48
|
+
* @param clock the host's core Clock; tests pass a fake for deterministic time.
|
|
40
49
|
* @complexity each method is one to four indexed statements; conversation summaries scan their
|
|
41
50
|
* messages and embedded events in SQL; `messages` is O(messages in the conversation).
|
|
42
51
|
*/
|
|
43
|
-
export declare function createSqlChatStore<DB extends ChatDatabase>({ kernel, scope: inputScope }: {
|
|
44
|
-
kernel: StorageKernel<DB>;
|
|
52
|
+
export declare function createSqlChatStore<DB extends ChatDatabase>({ kernel, scope: inputScope, clock }: {
|
|
53
|
+
kernel: StorageKernel<Kysely<DB>, DB>;
|
|
45
54
|
scope: ChatOwnerScope;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
} & UserTextRedactionOptions): ChatStore;
|
|
55
|
+
clock: Clock;
|
|
56
|
+
}, redactionOptions?: UserTextRedactionOptions): ChatStore;
|
|
49
57
|
export {};
|
|
50
58
|
//# sourceMappingURL=store.d.ts.map
|
package/dist/store/sql/store.js
CHANGED
|
@@ -14,8 +14,7 @@ const CONVERSATION_UPDATED_AT = 'c.updated_at';
|
|
|
14
14
|
* constraint remains the backstop, and nested appends join the host's existing transaction.
|
|
15
15
|
*/
|
|
16
16
|
import { sql } from 'kysely';
|
|
17
|
-
import {
|
|
18
|
-
import { isUniqueViolation } from '@jini-ai/db/kernel';
|
|
17
|
+
import { isUniqueViolation } from '@jini-ai/core/contracts/storage';
|
|
19
18
|
import { redactUserMessage } from '../../core/user-text-redaction.js';
|
|
20
19
|
import { MID_RUN_USER_MESSAGE_EVENT_NAME } from '../../core/turn-usage.js';
|
|
21
20
|
import { ChatStoreError } from '../errors.js';
|
|
@@ -169,6 +168,14 @@ function toHistoryMessage(row, { includeToolEvents }) {
|
|
|
169
168
|
position: Number(row.position), createdAt: Number(row.created_at),
|
|
170
169
|
...(includeToolEvents ? { events: parseJsonColumn(row.events_json) } : {}), };
|
|
171
170
|
}
|
|
171
|
+
/** @throws {ChatStoreError} `invalid-input` for an out-of-range limit or an over-long/non-string query. */
|
|
172
|
+
function assertHistoryListInputs({ limit, query }, _optional = {}) {
|
|
173
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 50)
|
|
174
|
+
throw new ChatStoreError({ code: 'invalid-input' });
|
|
175
|
+
if (query !== undefined && (typeof query !== 'string' || query.length > 200)) {
|
|
176
|
+
throw new ChatStoreError({ code: 'invalid-input' });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
172
179
|
/**
|
|
173
180
|
* Returns a {@link ChatHistoryStore} that can only ever see `scope`'s own conversations.
|
|
174
181
|
*
|
|
@@ -176,11 +183,11 @@ function toHistoryMessage(row, { includeToolEvents }) {
|
|
|
176
183
|
* `ON DELETE CASCADE` needs `foreign_keys = ON`, which the host must enable.
|
|
177
184
|
* @param scope the isolation predicate, resolved from the host's authentication. For a guest,
|
|
178
185
|
* `ownerId` must already be a hash of the session key (`tenant-scope.ts`).
|
|
179
|
-
* @param
|
|
186
|
+
* @param clock the host's core Clock; tests pass a fake for deterministic time.
|
|
180
187
|
* @complexity each method is one to four indexed statements; conversation summaries scan their
|
|
181
188
|
* messages and embedded events in SQL; `messages` is O(messages in the conversation).
|
|
182
189
|
*/
|
|
183
|
-
export function createSqlChatStore({ kernel, scope: inputScope
|
|
190
|
+
export function createSqlChatStore({ kernel, scope: inputScope, clock }, redactionOptions = {}) {
|
|
184
191
|
const scope = copyScope({ scope: inputScope });
|
|
185
192
|
const { scopeId, ownerKind, ownerId } = scope;
|
|
186
193
|
// The single subset boundary: DB must contain both required table definitions. Extra host tables
|
|
@@ -310,14 +317,14 @@ export function createSqlChatStore({ kernel, scope: inputScope }, { clock = crea
|
|
|
310
317
|
const store = {
|
|
311
318
|
history: {
|
|
312
319
|
/** Literal search uses two scoped projections, not a transcript fetch per conversation.
|
|
313
|
-
*
|
|
320
|
+
* A continuation is bound to this owner and orders by activity descending, then ID ascending.
|
|
321
|
+
* @throws {ChatStoreError} For invalid inputs or a cursor belonging to another scope.
|
|
322
|
+
* @complexity The database scans owned content for search; at most limit+1 rows are returned.
|
|
314
323
|
*/
|
|
315
|
-
async list(_required, { query, limit = 20 } = {}) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
throw new ChatStoreError({ code: 'invalid-input' });
|
|
320
|
-
}
|
|
324
|
+
async list(_required, { query, limit = 20, cursor } = {}) {
|
|
325
|
+
assertHistoryListInputs({ limit, query });
|
|
326
|
+
const anchor = decodeCursor({ cursor: cursor ?? undefined, kind: 'conversations', scope, conversation: null });
|
|
327
|
+
const id = ordinalId(kernel.dialect, 'c.id');
|
|
321
328
|
const rows = await run(db => {
|
|
322
329
|
let statement = ownedConversations(db).select(eb => eb.selectFrom('ai_chat_messages as first')
|
|
323
330
|
.select('first.content').whereRef('first.conversation_id', '=', 'c.id').where('first.role', '=', 'user')
|
|
@@ -332,9 +339,19 @@ export function createSqlChatStore({ kernel, scope: inputScope }, { clock = crea
|
|
|
332
339
|
.where(sql `lower(found.content) like ${pattern} escape '!'`)),
|
|
333
340
|
]));
|
|
334
341
|
}
|
|
335
|
-
|
|
342
|
+
if (anchor)
|
|
343
|
+
statement = statement.where(eb => eb.or([
|
|
344
|
+
eb(CONVERSATION_UPDATED_AT, '<', anchor[0]),
|
|
345
|
+
eb.and([eb(CONVERSATION_UPDATED_AT, '=', anchor[0]), eb(id, '>', anchor[1])]),
|
|
346
|
+
]));
|
|
347
|
+
return statement.orderBy(CONVERSATION_UPDATED_AT, 'desc').orderBy(id, 'asc').limit(limit + 1).execute();
|
|
336
348
|
});
|
|
337
|
-
|
|
349
|
+
const items = rows.slice(0, limit).map(row => ({ ...toConversation(row), firstUserLine: row.first_user_line ?? '' }));
|
|
350
|
+
const last = items.at(-1);
|
|
351
|
+
const nextCursor = rows.length > limit && last
|
|
352
|
+
? encodeCursor({ kind: 'conversations', scope, conversation: null, anchor: [last.updatedAt, last.id] })
|
|
353
|
+
: null;
|
|
354
|
+
return { items, nextCursor };
|
|
338
355
|
},
|
|
339
356
|
/** No attachment column is read. O(limit) rows; default tail is reversed into position order. */
|
|
340
357
|
async read({ chatId }, { fromPosition, limit = 50, includeToolEvents = false } = {}) {
|
|
@@ -378,7 +395,7 @@ export function createSqlChatStore({ kernel, scope: inputScope }, { clock = crea
|
|
|
378
395
|
.execute());
|
|
379
396
|
}
|
|
380
397
|
catch (cause) {
|
|
381
|
-
if (isUniqueViolation(cause))
|
|
398
|
+
if (isUniqueViolation({ err: cause }))
|
|
382
399
|
throw new ChatStoreError({ code: 'conflict' }, { cause });
|
|
383
400
|
throw cause;
|
|
384
401
|
}
|
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
import type { UserTextRedactionOptions } from '../../core/user-text-redaction.js';
|
|
2
2
|
/** Sqlite transcript adapter. The host owns the opened, migrated kernel and its lifetime. */
|
|
3
3
|
import type { Clock } from '@jini-ai/core/primitives';
|
|
4
|
-
import type { StorageKernel } from '@jini-ai/
|
|
4
|
+
import type { StorageKernel } from '@jini-ai/core/contracts/storage';
|
|
5
|
+
import type { Kysely } from 'kysely';
|
|
5
6
|
import type { ChatDatabase } from '../sql/tables.js';
|
|
6
7
|
import type { ChatOwnerScope, ChatStore, ChatHistoryMaintenance } from '../ports.js';
|
|
7
8
|
export type { ChatDatabase, AiChatsTable, AiChatMessagesTable } from '../sql/tables.js';
|
|
8
9
|
/** Borrow an existing kernel, with no configuration, migration or connection lifecycle effects.
|
|
9
|
-
* @example createSqliteChatStore({ kernel, scope
|
|
10
|
+
* @example createSqliteChatStore({ kernel, scope, clock: { nowMs: () => 42 } })
|
|
10
11
|
* @throws ChatStoreError invalid-input for a mismatched dialect/transport or owner scope.
|
|
11
12
|
*/
|
|
12
13
|
export declare function createSqliteChatStore<DB extends ChatDatabase>(required: {
|
|
13
|
-
kernel: StorageKernel<DB>;
|
|
14
|
+
kernel: StorageKernel<Kysely<DB>, DB>;
|
|
14
15
|
scope: ChatOwnerScope;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} & UserTextRedactionOptions): ChatStore;
|
|
16
|
+
clock: Clock;
|
|
17
|
+
}, optional?: UserTextRedactionOptions): ChatStore;
|
|
18
18
|
/** Privileged bounded expiry maintenance; never hand this collaborator to request handlers. */
|
|
19
19
|
export declare function createSqliteChatMaintenance<DB extends ChatDatabase>(required: {
|
|
20
|
-
kernel: StorageKernel<DB>;
|
|
20
|
+
kernel: StorageKernel<Kysely<DB>, DB>;
|
|
21
21
|
}): ChatHistoryMaintenance;
|
|
22
22
|
import { type SqliteConnectionSource } from '@jini-ai/db/kernel/sqlite';
|
|
23
23
|
export { CHAT_HISTORY_DDL, ensureChatHistoryTables } from './schema.js';
|
|
24
24
|
/** Compatibility wrapper over db's memoized kernel; joins the exact raw-handle kernel context.
|
|
25
|
-
* @example createChatHistoryStore({ db, scope
|
|
25
|
+
* @example createChatHistoryStore({ db, scope, clock: { nowMs: () => 42 } })
|
|
26
26
|
*/
|
|
27
|
-
export declare function createChatHistoryStore({ db, scope }: {
|
|
27
|
+
export declare function createChatHistoryStore({ db, scope, clock }: {
|
|
28
28
|
db: SqliteConnectionSource;
|
|
29
29
|
scope: ChatOwnerScope;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} & UserTextRedactionOptions): ChatStore;
|
|
30
|
+
clock: Clock;
|
|
31
|
+
}, optional?: UserTextRedactionOptions): ChatStore;
|
|
33
32
|
/** Compatibility retention wrapper; the caller still owns the handle and its configuration. */
|
|
34
33
|
export declare function createChatHistoryMaintenance({ db }: {
|
|
35
34
|
db: SqliteConnectionSource;
|
|
@@ -2,7 +2,7 @@ import { createSqlChatStore } from '../sql/store.js';
|
|
|
2
2
|
import { createSqlChatMaintenance } from '../sql/maintenance.js';
|
|
3
3
|
import { validateKernel } from '../sql/boundary.js';
|
|
4
4
|
/** Borrow an existing kernel, with no configuration, migration or connection lifecycle effects.
|
|
5
|
-
* @example createSqliteChatStore({ kernel, scope
|
|
5
|
+
* @example createSqliteChatStore({ kernel, scope, clock: { nowMs: () => 42 } })
|
|
6
6
|
* @throws ChatStoreError invalid-input for a mismatched dialect/transport or owner scope.
|
|
7
7
|
*/
|
|
8
8
|
export function createSqliteChatStore(required, optional = {}) {
|
|
@@ -17,13 +17,13 @@ export function createSqliteChatMaintenance(required) {
|
|
|
17
17
|
import { sqliteKernel } from '@jini-ai/db/kernel/sqlite';
|
|
18
18
|
export { CHAT_HISTORY_DDL, ensureChatHistoryTables } from './schema.js';
|
|
19
19
|
/** Compatibility wrapper over db's memoized kernel; joins the exact raw-handle kernel context.
|
|
20
|
-
* @example createChatHistoryStore({ db, scope
|
|
20
|
+
* @example createChatHistoryStore({ db, scope, clock: { nowMs: () => 42 } })
|
|
21
21
|
*/
|
|
22
|
-
export function createChatHistoryStore({ db, scope }, optional = {}) {
|
|
23
|
-
return createSqliteChatStore({ kernel: sqliteKernel(db), scope }, optional);
|
|
22
|
+
export function createChatHistoryStore({ db, scope, clock }, optional = {}) {
|
|
23
|
+
return createSqliteChatStore({ kernel: sqliteKernel({ source: db }), scope, clock }, optional);
|
|
24
24
|
}
|
|
25
25
|
/** Compatibility retention wrapper; the caller still owns the handle and its configuration. */
|
|
26
26
|
export function createChatHistoryMaintenance({ db }) {
|
|
27
|
-
return createSqliteChatMaintenance({ kernel: sqliteKernel(db) });
|
|
27
|
+
return createSqliteChatMaintenance({ kernel: sqliteKernel({ source: db }) });
|
|
28
28
|
}
|
|
29
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* migration statements; a fresh fixture or host without a migrator may call the explicit helper.
|
|
7
7
|
* Store construction never invokes it, chooses a file, or sets connection-wide pragmas.
|
|
8
8
|
*/
|
|
9
|
-
import type { SqliteClient } from '@jini-ai/
|
|
9
|
+
import type { SqliteClient } from '@jini-ai/core/contracts/storage';
|
|
10
10
|
/**
|
|
11
11
|
* The canonical chat-history schema.
|
|
12
12
|
*
|