@turingfocus/chat-runtime 0.7.0 → 0.8.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/dist/cache-record.d.ts +20 -0
- package/dist/cache-record.d.ts.map +1 -0
- package/dist/cache-record.js +139 -0
- package/dist/cache-record.js.map +1 -0
- package/dist/chat-client.d.ts +18 -1
- package/dist/chat-client.d.ts.map +1 -1
- package/dist/chat-client.js +534 -6
- package/dist/chat-client.js.map +1 -1
- package/dist/composer-draft.d.ts +39 -0
- package/dist/composer-draft.d.ts.map +1 -0
- package/dist/composer-draft.js +96 -0
- package/dist/composer-draft.js.map +1 -0
- package/dist/conversation-cache.d.ts +77 -0
- package/dist/conversation-cache.d.ts.map +1 -0
- package/dist/conversation-cache.js +501 -0
- package/dist/conversation-cache.js.map +1 -0
- package/dist/conversation-workspace.d.ts.map +1 -1
- package/dist/conversation-workspace.js +5 -1
- package/dist/conversation-workspace.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/references.d.ts +17 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +29 -0
- package/dist/references.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
export { ChatClient, createChatClient, type ChatClientOptions, type ChatClientSubscription, type ChatSnapshotListener, type ChatSnapshotStateListener, type ChatClientUnhandledError, type ChatClientUnhandledErrorSource, } from "./chat-client.js";
|
|
2
2
|
export { ConversationWorkspaceController, createConversationWorkspaceController, orderConversationsByUpdatedAt, type ConversationWorkspaceControllerOptions, type ConversationWorkspaceListStatus, type ConversationWorkspaceSelectionStatus, type ConversationWorkspaceSnapshot, type ConversationWorkspaceSubscription, type CreateWorkspaceConversationInput, type RenameWorkspaceConversationInput, } from "./conversation-workspace.js";
|
|
3
|
+
export { emptyComposerDraft, rebaseComposerLongTexts, resolveComposerDraftText, type ComposerDraft, type ComposerDraftListener, type ComposerLongText, type ComposerTextEdit, type SetComposerDraftInput, } from "./composer-draft.js";
|
|
4
|
+
export type { GatewayRequestOptions, GatewayResult, UploadCancellationSignal, UploadedAttachment, } from "@turingfocus/chat-protocol";
|
|
5
|
+
export type { ChatResourcePort, ChatResourceRequest, ChatResourcePurpose, ChatResolvedResource, MessageResource, } from "@turingfocus/chat-protocol";
|
|
6
|
+
export { appendComposerReference, type ChatDocumentReference, type ChatDocumentSource, } from "./references.js";
|
|
7
|
+
export { ChatResourceError, normalizeChatResourceError, type ChatResourceFailure, type ChatResourceErrorCode, } from "@turingfocus/chat-protocol";
|
|
8
|
+
export type { ConversationCacheOptions, ConversationCacheState, ConversationCacheStorage, ConversationCacheEvent, CachedAttachmentResolver, } from "./conversation-cache.js";
|
|
9
|
+
export type { ConversationCacheRecord } from "./cache-record.js";
|
|
3
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,GACpC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,+BAA+B,EAC/B,qCAAqC,EACrC,6BAA6B,EAC7B,KAAK,sCAAsC,EAC3C,KAAK,+BAA+B,EACpC,KAAK,oCAAoC,EACzC,KAAK,6BAA6B,EAClC,KAAK,iCAAiC,EACtC,KAAK,gCAAgC,EACrC,KAAK,gCAAgC,GACtC,MAAM,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,E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.js";
|
|
2
2
|
export { ConversationWorkspaceController, createConversationWorkspaceController, orderConversationsByUpdatedAt, } from "./conversation-workspace.js";
|
|
3
|
+
export { emptyComposerDraft, rebaseComposerLongTexts, resolveComposerDraftText, } from "./composer-draft.js";
|
|
4
|
+
export { appendComposerReference, } from "./references.js";
|
|
5
|
+
export { ChatResourceError, normalizeChatResourceError, } from "@turingfocus/chat-protocol";
|
|
3
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,GAOjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,+BAA+B,EAC/B,qCAAqC,EACrC,6BAA6B,GAQ9B,MAAM,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,GAOjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,+BAA+B,EAC/B,qCAAqC,EACrC,6BAA6B,GAQ9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,GAMzB,MAAM,qBAAqB,CAAC;AAgB7B,OAAO,EACL,uBAAuB,GAGxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAG3B,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MaybePromise, UploadCancellationSignal } from "@turingfocus/chat-protocol";
|
|
2
|
+
import { type ComposerDraft } from "./composer-draft.js";
|
|
3
|
+
/** Content already authorized by the integrating application, expanded as plain text on send. */
|
|
4
|
+
export interface ChatDocumentReference {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly title: string;
|
|
7
|
+
readonly content: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ChatDocumentSource {
|
|
10
|
+
list(request: {
|
|
11
|
+
readonly query: string;
|
|
12
|
+
readonly conversationId: string;
|
|
13
|
+
readonly signal: UploadCancellationSignal;
|
|
14
|
+
}): MaybePromise<readonly ChatDocumentReference[]>;
|
|
15
|
+
}
|
|
16
|
+
export declare function appendComposerReference(draft: ComposerDraft, reference: ChatDocumentReference, anchorId: string): Pick<ComposerDraft, "text" | "longTexts" | "attachments">;
|
|
17
|
+
//# sourceMappingURL=references.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAE7B,iGAAiG;AACjG,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AACD,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,OAAO,EAAE;QACZ,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;QAChC,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC;KAC3C,GAAG,YAAY,CAAC,SAAS,qBAAqB,EAAE,CAAC,CAAC;CACpD;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,aAAa,EACpB,SAAS,EAAE,qBAAqB,EAChC,QAAQ,EAAE,MAAM,GACf,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,CA4B3D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { rebaseComposerLongTexts, } from "./composer-draft.js";
|
|
2
|
+
export function appendComposerReference(draft, reference, anchorId) {
|
|
3
|
+
if (reference.id.length === 0 ||
|
|
4
|
+
reference.title.length === 0 ||
|
|
5
|
+
anchorId.length === 0 ||
|
|
6
|
+
draft.longTexts.some((item) => item.id === anchorId))
|
|
7
|
+
throw new TypeError("Invalid or duplicate reference identity");
|
|
8
|
+
const prefix = draft.text.endsWith("/")
|
|
9
|
+
? draft.text.slice(0, -1)
|
|
10
|
+
: draft.text;
|
|
11
|
+
const separator = prefix.length === 0 || /\s$/.test(prefix) ? "" : " ";
|
|
12
|
+
const label = `[Reference: ${reference.title}]`;
|
|
13
|
+
const start = prefix.length + separator.length;
|
|
14
|
+
return {
|
|
15
|
+
attachments: draft.attachments,
|
|
16
|
+
text: `${prefix}${separator}${label}`,
|
|
17
|
+
longTexts: [
|
|
18
|
+
...rebaseComposerLongTexts(draft.text, prefix, draft.longTexts),
|
|
19
|
+
{
|
|
20
|
+
id: anchorId,
|
|
21
|
+
label,
|
|
22
|
+
start,
|
|
23
|
+
end: start + label.length,
|
|
24
|
+
content: `${reference.title}\n${reference.content}`,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,uBAAuB,GAExB,MAAM,qBAAqB,CAAC;AAgB7B,MAAM,UAAU,uBAAuB,CACrC,KAAoB,EACpB,SAAgC,EAChC,QAAgB;IAEhB,IACE,SAAS,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC;QACzB,SAAS,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;QAC5B,QAAQ,CAAC,MAAM,KAAK,CAAC;QACrB,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,QAAQ,CAAC;QAEpD,MAAM,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QACrC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACzB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;IACf,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACvE,MAAM,KAAK,GAAG,eAAe,SAAS,CAAC,KAAK,GAAG,CAAC;IAChD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAC/C,OAAO;QACL,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,IAAI,EAAE,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,EAAE;QACrC,SAAS,EAAE;YACT,GAAG,uBAAuB,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC;YAC/D;gBACE,EAAE,EAAE,QAAQ;gBACZ,KAAK;gBACL,KAAK;gBACL,GAAG,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM;gBACzB,OAAO,EAAE,GAAG,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,OAAO,EAAE;aACpD;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turingfocus/chat-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Headless, instance-scoped chat runtime",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@turingfocus/chat-protocol": "^0.
|
|
31
|
+
"@turingfocus/chat-protocol": "^0.8.1"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public",
|