@stll/chat 0.3.2 → 0.4.0
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/.bun/install/cache/links/@tanstack_ai-event-client@0.13.1-cfefc90983c2de00/node_modules/@tanstack/ai-event-client/dist/esm/envelope.d.ts +0 -1
- package/dist/.bun/install/cache/links/@tanstack_ai-event-client@0.13.1-cfefc90983c2de00/node_modules/@tanstack/ai-event-client/dist/esm/index.d.ts +1 -3
- package/dist/.bun/install/cache/links/@tanstack_devtools-event-client@0.4.4-700fc304f0957f2a/node_modules/@tanstack/devtools-event-client/dist/esm/plugin.d.ts +0 -1
- package/dist/composer.d.ts +1 -3
- package/dist/composer.js +1 -2
- package/dist/durable-transport.d.ts +0 -2
- package/dist/durable-transport.js +3 -4
- package/dist/html-to-markdown.d.ts +1 -3
- package/dist/html-to-markdown.js +4 -5
- package/dist/link-detection.d.ts +2 -3
- package/dist/link-detection.js +20 -15
- package/dist/link-editor.d.ts +1 -3
- package/dist/link-editor.js +1 -2
- package/dist/link-markdown.d.ts +1 -3
- package/dist/link-markdown.js +1 -2
- package/dist/link.d.ts +15 -4
- package/dist/link.js +78 -33
- package/dist/model-selector.d.ts +4 -5
- package/dist/model-selector.js +21 -21
- package/dist/resume-contract.d.ts +1 -3
- package/dist/resume-contract.js +1 -2
- package/dist/runtime.d.ts +0 -2
- package/dist/runtime.js +1 -2
- package/dist/stream.d.ts +1 -3
- package/dist/stream.js +1 -2
- package/dist/work/stella/stella/node_modules/.bun/@tanstack_ai@0.65.1_969a6d035afea0f4/node_modules/@tanstack/ai/dist/esm/interrupts.d.ts +1 -3
- package/dist/work/stella/stella/node_modules/.bun/@tanstack_ai@0.65.1_969a6d035afea0f4/node_modules/@tanstack/ai/dist/esm/types.d.ts +0 -2
- package/dist/work/stella/stella/node_modules/.bun/@tanstack_ai@0.65.1_969a6d035afea0f4/node_modules/@tanstack/ai/dist/esm/utilities/ag-ui-usage.d.ts +0 -2
- package/package.json +6 -7
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "../../../../../../@tanstack_devtools-event-client@0.4.4-700fc304f0957f2a/node_modules/@tanstack/devtools-event-client/dist/esm/index.js";
|
|
2
2
|
import "./envelope.js";
|
|
3
|
-
//#region ../../../../../.bun/install/cache/links/@tanstack+ai-event-client@0.13.1-cfefc90983c2de00/node_modules/@tanstack/ai-event-client/dist/esm/index.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Detailed breakdown of prompt/input token usage.
|
|
6
5
|
* Fields are populated based on provider support.
|
|
@@ -137,5 +136,4 @@ export interface TokenUsage<TProviderDetails = ProviderUsageDetails> {
|
|
|
137
136
|
cost?: number;
|
|
138
137
|
/** Provider-reported cost breakdown, when available. */
|
|
139
138
|
costDetails?: UsageCostBreakdown;
|
|
140
|
-
}
|
|
141
|
-
//#endregion
|
|
139
|
+
}
|
package/dist/composer.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/composer.d.ts
|
|
2
1
|
export type ChatComposerActionState = {
|
|
3
2
|
canSend: boolean;
|
|
4
3
|
isGenerating: boolean;
|
|
@@ -7,5 +6,4 @@ export type ChatComposerActionState = {
|
|
|
7
6
|
onStop?: (() => void) | undefined;
|
|
8
7
|
};
|
|
9
8
|
export type ChatComposerActionMode = "retry" | "send" | "stop";
|
|
10
|
-
export declare const resolveChatComposerAction: ({ isGenerating, onRetry, onStop }: Pick<ChatComposerActionState, "isGenerating" | "onRetry" | "onStop">) => ChatComposerActionMode;
|
|
11
|
-
//#endregion
|
|
9
|
+
export declare const resolveChatComposerAction: ({ isGenerating, onRetry, onStop }: Pick<ChatComposerActionState, "isGenerating" | "onRetry" | "onStop">) => ChatComposerActionMode;
|
package/dist/composer.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// src/composer.tsx
|
|
2
2
|
const resolveChatComposerAction = ({ isGenerating, onRetry, onStop }) => {
|
|
3
3
|
if (isGenerating && onStop !== void 0) return "stop";
|
|
4
4
|
if (!isGenerating && onRetry !== void 0) return "retry";
|
|
5
5
|
return "send";
|
|
6
6
|
};
|
|
7
|
-
//#endregion
|
|
8
7
|
export { resolveChatComposerAction };
|
|
@@ -3,7 +3,6 @@ import { AGUIEvent, ActivityDeltaEvent as ActivityDeltaEvent$1, ActivitySnapshot
|
|
|
3
3
|
import { ChatTurnResumeProbe } from "./resume-contract.js";
|
|
4
4
|
import { EventType } from "@ag-ui/core";
|
|
5
5
|
import { UIMessage } from "@tanstack/ai-client";
|
|
6
|
-
//#region src/durable-transport.d.ts
|
|
7
6
|
declare const ChatReconnectError_base: import("better-result").TaggedErrorClass<"ChatReconnectError">;
|
|
8
7
|
export declare class ChatReconnectError extends ChatReconnectError_base<{
|
|
9
8
|
cause?: unknown;
|
|
@@ -65,5 +64,4 @@ export declare const createDurableChatTransport: <TMessages extends UIMessage[]>
|
|
|
65
64
|
removeItem: () => undefined;
|
|
66
65
|
};
|
|
67
66
|
};
|
|
68
|
-
//#endregion
|
|
69
67
|
export {};
|
|
@@ -3,7 +3,7 @@ import { EventType } from "@ag-ui/core";
|
|
|
3
3
|
import { fetchServerSentEvents } from "@tanstack/ai-client";
|
|
4
4
|
import { Result, TaggedError, panic } from "better-result";
|
|
5
5
|
import * as v from "valibot";
|
|
6
|
-
|
|
6
|
+
// src/durable-transport.ts
|
|
7
7
|
var ChatReconnectError = class extends TaggedError("ChatReconnectError") {};
|
|
8
8
|
const RECONNECT_WINDOW_MS = 18e4;
|
|
9
9
|
const MAX_RECONNECT_DELAY_MS = 15e3;
|
|
@@ -44,10 +44,10 @@ const terminalChatResponse = ({ runId, resume, onTranscript, onReconnectChange }
|
|
|
44
44
|
return new Response(`data: ${JSON.stringify({
|
|
45
45
|
type: "RUN_FINISHED",
|
|
46
46
|
runId,
|
|
47
|
-
...resume?.pendingInterrupts
|
|
47
|
+
...resume?.pendingInterrupts !== void 0 ? { outcome: {
|
|
48
48
|
type: "interrupt",
|
|
49
49
|
interrupts: resume.pendingInterrupts
|
|
50
|
-
} }
|
|
50
|
+
} } : {}
|
|
51
51
|
})}\n\n`, { headers: { "Content-Type": "text/event-stream" } });
|
|
52
52
|
};
|
|
53
53
|
const createChatResumePersistence = ({ initialMessages, initialTurn, probe, onReconnectChange, onTranscript, onError, random, now, wait }) => {
|
|
@@ -235,5 +235,4 @@ const createDurableChatTransport = ({ initialMessages, initialTurn, threadId, pr
|
|
|
235
235
|
persistence
|
|
236
236
|
};
|
|
237
237
|
};
|
|
238
|
-
//#endregion
|
|
239
238
|
export { ChatReconnectError, createDurableChatTransport };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/html-to-markdown.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Convert sanitized HTML to GFM-flavored Markdown.
|
|
4
3
|
*
|
|
@@ -7,5 +6,4 @@
|
|
|
7
6
|
* (children rendered, tag dropped). Output ends with a
|
|
8
7
|
* single trailing newline when non-empty.
|
|
9
8
|
*/
|
|
10
|
-
export declare const htmlToMarkdown: (html: string) => string;
|
|
11
|
-
//#endregion
|
|
9
|
+
export declare const htmlToMarkdown: (html: string) => string;
|
package/dist/html-to-markdown.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isTag, isText } from "
|
|
3
|
-
|
|
1
|
+
import { load } from "@stll/html";
|
|
2
|
+
import { isTag, isText } from "@stll/html/nodes";
|
|
3
|
+
// src/html-to-markdown.ts
|
|
4
4
|
const INLINE_ESCAPE = /(?<ch>[\\`*_~[\]<>|])/g;
|
|
5
5
|
const escapeText = (text) => text.replace(INLINE_ESCAPE, "\\$<ch>");
|
|
6
6
|
const LINK_DESTINATION_ESCAPE = /(?<ch>[\\<>])/g;
|
|
@@ -210,9 +210,8 @@ const trimTrailingNewlines = (text) => {
|
|
|
210
210
|
*/
|
|
211
211
|
const htmlToMarkdown = (html) => {
|
|
212
212
|
if (!html.trim()) return "";
|
|
213
|
-
const $ =
|
|
213
|
+
const $ = load(html, void 0, false);
|
|
214
214
|
const body = renderChildren($.root().contents().toArray());
|
|
215
215
|
return body ? `${body}\n` : "";
|
|
216
216
|
};
|
|
217
|
-
//#endregion
|
|
218
217
|
export { htmlToMarkdown };
|
package/dist/link-detection.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/link-detection.d.ts
|
|
2
1
|
export type ChatLinkSpan = {
|
|
3
2
|
start: number;
|
|
4
3
|
end: number;
|
|
@@ -6,10 +5,10 @@ export type ChatLinkSpan = {
|
|
|
6
5
|
href: string;
|
|
7
6
|
hostname: string;
|
|
8
7
|
};
|
|
8
|
+
export declare const FILE_EXTENSION_TLDS: ReadonlySet<string>;
|
|
9
9
|
export declare const normalizeChatLink: (input: string) => {
|
|
10
10
|
href: string;
|
|
11
11
|
hostname: string;
|
|
12
12
|
} | null;
|
|
13
13
|
export declare const getChatLinkSite: (hostname: string) => string | null;
|
|
14
|
-
export declare const detectChatLinks: (text: string) => ChatLinkSpan[];
|
|
15
|
-
//#endregion
|
|
14
|
+
export declare const detectChatLinks: (text: string) => ChatLinkSpan[];
|
package/dist/link-detection.js
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import { LinkifyIt } from "linkify-it";
|
|
2
2
|
import { getDomain, parse } from "tldts";
|
|
3
|
-
|
|
3
|
+
// src/link-detection.ts
|
|
4
4
|
const HTTP_SCHEME = /^https?:\/\//iu;
|
|
5
5
|
const BARE_HOST_LABEL_START = /^[\p{L}\p{N}]/u;
|
|
6
6
|
const UNSAFE_CHARACTERS = /[\s\p{Cc}\p{Cf}\\]/u;
|
|
7
7
|
const SPECIAL_USE_SUFFIX = /(?:^|\.)(?:localhost|local|internal|invalid|test|example|onion)$/iu;
|
|
8
|
-
const
|
|
9
|
-
"
|
|
8
|
+
const FILE_EXTENSION_TLDS = /* @__PURE__ */ new Set([
|
|
9
|
+
"ai",
|
|
10
|
+
"dot",
|
|
11
|
+
"java",
|
|
12
|
+
"md",
|
|
13
|
+
"mk",
|
|
14
|
+
"mobi",
|
|
10
15
|
"mov",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
16
|
+
"one",
|
|
17
|
+
"pl",
|
|
18
|
+
"pm",
|
|
19
|
+
"ps",
|
|
20
|
+
"pub",
|
|
21
|
+
"py",
|
|
22
|
+
"rs",
|
|
23
|
+
"sh",
|
|
24
|
+
"zip"
|
|
20
25
|
]);
|
|
21
26
|
const normalizeChatLink = (input) => {
|
|
22
27
|
if (!input || UNSAFE_CHARACTERS.test(input)) return null;
|
|
@@ -32,7 +37,8 @@ const normalizeChatLink = (input) => {
|
|
|
32
37
|
if (!explicit) {
|
|
33
38
|
if (SPECIAL_USE_SUFFIX.test(url.hostname)) return null;
|
|
34
39
|
if (!domain.isIcann || !domain.domain || domain.isIp) return null;
|
|
35
|
-
|
|
40
|
+
const hasPath = url.pathname !== "/" || url.search !== "";
|
|
41
|
+
if (!/^www\./iu.test(input) && !hasPath && domain.publicSuffix && FILE_EXTENSION_TLDS.has(domain.publicSuffix)) return null;
|
|
36
42
|
}
|
|
37
43
|
return {
|
|
38
44
|
href: url.href,
|
|
@@ -65,5 +71,4 @@ const detectChatLinks = (text) => {
|
|
|
65
71
|
}
|
|
66
72
|
return spans;
|
|
67
73
|
};
|
|
68
|
-
|
|
69
|
-
export { detectChatLinks, getChatLinkSite, normalizeChatLink };
|
|
74
|
+
export { FILE_EXTENSION_TLDS, detectChatLinks, getChatLinkSite, normalizeChatLink };
|
package/dist/link-editor.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { Extension } from "@tiptap/core";
|
|
2
|
-
//#region src/link-editor.d.ts
|
|
3
2
|
/** View-only links: saved drafts and submitted HTML retain the original bytes. */
|
|
4
|
-
export declare const ChatComposerLinks: Extension<any, any>;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare const ChatComposerLinks: Extension<any, any>;
|
package/dist/link-editor.js
CHANGED
|
@@ -4,7 +4,7 @@ import { panic } from "better-result";
|
|
|
4
4
|
import { Extension } from "@tiptap/core";
|
|
5
5
|
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
6
6
|
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
7
|
-
|
|
7
|
+
// src/link-editor.ts
|
|
8
8
|
const chatLinkPluginKey = new PluginKey("stllChatLinks");
|
|
9
9
|
const decorateChatLinks = (doc) => {
|
|
10
10
|
const decorations = [];
|
|
@@ -80,5 +80,4 @@ const ChatComposerLinks = Extension.create({
|
|
|
80
80
|
})];
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
|
-
//#endregion
|
|
84
83
|
export { ChatComposerLinks };
|
package/dist/link-markdown.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { Root } from "hast";
|
|
2
|
-
//#region src/link-markdown.d.ts
|
|
3
2
|
/** Run after sanitization and source-offset anchoring; existing links keep their renderer contract. */
|
|
4
|
-
export declare const rehypeChatLinks: () => (tree: Root) => void;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare const rehypeChatLinks: () => (tree: Root) => void;
|
package/dist/link-markdown.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { detectChatLinks } from "./link-detection.js";
|
|
2
2
|
import { CHAT_LINK_ATTRIBUTES } from "./link.js";
|
|
3
|
-
|
|
3
|
+
// src/link-markdown.ts
|
|
4
4
|
const SKIPPED_ELEMENTS = /* @__PURE__ */ new Set([
|
|
5
5
|
"a",
|
|
6
6
|
"code",
|
|
@@ -54,5 +54,4 @@ const rehypeChatLinks = () => (tree) => {
|
|
|
54
54
|
};
|
|
55
55
|
visit(tree);
|
|
56
56
|
};
|
|
57
|
-
//#endregion
|
|
58
57
|
export { rehypeChatLinks };
|
package/dist/link.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { AnchorHTMLAttributes } from "react";
|
|
2
|
-
//#region src/link.d.ts
|
|
1
|
+
import { AnchorHTMLAttributes, ReactNode } from "react";
|
|
3
2
|
export declare const CHAT_LINK_ATTRIBUTES: {
|
|
4
3
|
readonly target: "_blank";
|
|
5
4
|
readonly rel: "noopener noreferrer";
|
|
@@ -15,7 +14,19 @@ type ChatLinkProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href" | "tar
|
|
|
15
14
|
appearance?: "inline" | "tray";
|
|
16
15
|
iconSource?: ChatLinkIconSource | undefined;
|
|
17
16
|
newTabLabel?: string;
|
|
17
|
+
/** A tray chip whose label is the whole point (a decision's case number and
|
|
18
|
+
* date) keeps it up to the row's width instead of the compact 20ch cap. */
|
|
19
|
+
fullLabel?: boolean | undefined;
|
|
18
20
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Gives the link rendered inside it fixed ids, so a surface that renders the
|
|
23
|
+
* same links again (a streamed answer, then the reloaded one) renders the same
|
|
24
|
+
* ids: `id` names the link's tooltip trigger and `${id}-hint` its hint.
|
|
25
|
+
* Without a scope, a link generates its ids.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ChatLinkIdScope: ({ children, id }: {
|
|
28
|
+
children: ReactNode;
|
|
29
|
+
id: string;
|
|
30
|
+
}) => import("react").JSX.Element;
|
|
31
|
+
export declare const ChatLink: ({ appearance, children, fullLabel, href, iconSource, id, newTabLabel, title, ...anchorProps }: ChatLinkProps) => import("react").JSX.Element;
|
|
21
32
|
export {};
|
package/dist/link.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { normalizeChatLink } from "./link-detection.js";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { isValidElement, useState } from "react";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, isValidElement, use, useId, useState } from "react";
|
|
4
4
|
import { GitHubLogoIcon, XLogoIcon } from "@stll/ui/brand-icons";
|
|
5
5
|
import { GlobeIcon } from "@stll/ui/icons";
|
|
6
|
-
|
|
6
|
+
import { Tooltip, TooltipPopup, TooltipTrigger } from "@stll/ui/tooltip";
|
|
7
|
+
// src/link.tsx
|
|
7
8
|
const CHAT_LINK_ATTRIBUTES = {
|
|
8
9
|
target: "_blank",
|
|
9
10
|
rel: "noopener noreferrer"
|
|
@@ -46,9 +47,42 @@ const BUNDLED_ICONS = /* @__PURE__ */ new Map([
|
|
|
46
47
|
["www.twitter.com", X_LINK_ICON]
|
|
47
48
|
]);
|
|
48
49
|
const hasBundledChatLinkIcon = (hostname) => BUNDLED_ICONS.has(hostname);
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
const ChatLinkIdContext = createContext(void 0);
|
|
51
|
+
/**
|
|
52
|
+
* Gives the link rendered inside it fixed ids, so a surface that renders the
|
|
53
|
+
* same links again (a streamed answer, then the reloaded one) renders the same
|
|
54
|
+
* ids: `id` names the link's tooltip trigger and `${id}-hint` its hint.
|
|
55
|
+
* Without a scope, a link generates its ids.
|
|
56
|
+
*/
|
|
57
|
+
const ChatLinkIdScope = ({ children, id }) => /* @__PURE__ */ jsx(ChatLinkIdContext, {
|
|
58
|
+
value: id,
|
|
59
|
+
children
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* The hover hint a link carries: the new-tab notice, or the title the source
|
|
63
|
+
* gave it. A link with neither renders bare, so a long answer does not mount
|
|
64
|
+
* a tooltip for every link it has nothing to say about. The tooltip is for the
|
|
65
|
+
* pointer; the same words reach assistive technology as the link's
|
|
66
|
+
* description, a hidden element beside the link (`hintId`), so the link's own
|
|
67
|
+
* text stays its label.
|
|
68
|
+
*/
|
|
69
|
+
const LinkHint = ({ children, hint, hintId, id }) => hint ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
70
|
+
id,
|
|
71
|
+
render: children
|
|
72
|
+
}), /* @__PURE__ */ jsx(TooltipPopup, { children: hint })] }), /* @__PURE__ */ jsx("span", {
|
|
73
|
+
hidden: true,
|
|
74
|
+
id: hintId,
|
|
75
|
+
children: hint
|
|
76
|
+
})] }) : children;
|
|
77
|
+
const ChatLink = ({ appearance = "inline", children, fullLabel = false, href, iconSource, id, newTabLabel, title, ...anchorProps }) => {
|
|
78
|
+
const hint = newTabLabel ?? title;
|
|
79
|
+
const generatedId = useId();
|
|
80
|
+
const baseId = use(ChatLinkIdContext) ?? generatedId;
|
|
81
|
+
const hintId = `${baseId}-hint`;
|
|
82
|
+
const triggerId = id ?? baseId;
|
|
83
|
+
const ownId = hint || id === void 0 ? {} : { id };
|
|
84
|
+
const className = appearance === "tray" ? "bg-muted/50 hover:bg-muted inline-flex max-w-full min-w-0 shrink-0 items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring" : CHAT_LINK_CLASS_NAME;
|
|
85
|
+
const labelClassName = appearance === "tray" ? fullLabel ? "min-w-0 truncate" : "max-w-[20ch] truncate" : void 0;
|
|
52
86
|
const target = normalizeChatLink(href);
|
|
53
87
|
if (!target) {
|
|
54
88
|
const parsed = URL.canParse(href) ? new URL(href) : null;
|
|
@@ -61,16 +95,22 @@ const ChatLink = ({ appearance = "inline", children, href, iconSource, newTabLab
|
|
|
61
95
|
children: children ?? href
|
|
62
96
|
})
|
|
63
97
|
}) : /* @__PURE__ */ jsx("span", { children: children ?? href });
|
|
64
|
-
return /* @__PURE__ */ jsx(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
className
|
|
73
|
-
|
|
98
|
+
return /* @__PURE__ */ jsx(LinkHint, {
|
|
99
|
+
hint,
|
|
100
|
+
hintId,
|
|
101
|
+
id: triggerId,
|
|
102
|
+
children: /* @__PURE__ */ jsx("a", {
|
|
103
|
+
...anchorProps,
|
|
104
|
+
...ownId,
|
|
105
|
+
"aria-describedby": hint ? hintId : anchorProps["aria-describedby"],
|
|
106
|
+
className,
|
|
107
|
+
href,
|
|
108
|
+
target: CHAT_LINK_ATTRIBUTES.target,
|
|
109
|
+
rel: CHAT_LINK_ATTRIBUTES.rel,
|
|
110
|
+
children: /* @__PURE__ */ jsx("bdi", {
|
|
111
|
+
className: labelClassName,
|
|
112
|
+
children: children ?? href
|
|
113
|
+
})
|
|
74
114
|
})
|
|
75
115
|
});
|
|
76
116
|
}
|
|
@@ -83,22 +123,27 @@ const ChatLink = ({ appearance = "inline", children, href, iconSource, newTabLab
|
|
|
83
123
|
const bundledIcon = BUNDLED_ICONS.get(target.hostname);
|
|
84
124
|
if (iconSource) icon = /* @__PURE__ */ jsx(ProxyIcon, { src: iconSource.src }, iconSource.src);
|
|
85
125
|
else if (bundledIcon) icon = bundledIcon;
|
|
86
|
-
return /* @__PURE__ */
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
126
|
+
return /* @__PURE__ */ jsx(LinkHint, {
|
|
127
|
+
hint,
|
|
128
|
+
hintId,
|
|
129
|
+
id: triggerId,
|
|
130
|
+
children: /* @__PURE__ */ jsxs("a", {
|
|
131
|
+
...anchorProps,
|
|
132
|
+
...ownId,
|
|
133
|
+
"aria-describedby": hint ? hintId : anchorProps["aria-describedby"],
|
|
134
|
+
className,
|
|
135
|
+
href: target.href,
|
|
136
|
+
target: CHAT_LINK_ATTRIBUTES.target,
|
|
137
|
+
rel: CHAT_LINK_ATTRIBUTES.rel,
|
|
138
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
139
|
+
"aria-hidden": "true",
|
|
140
|
+
className: appearance === "tray" ? "flex shrink-0" : "me-1 inline-block align-[-0.125em]",
|
|
141
|
+
children: icon
|
|
142
|
+
}), /* @__PURE__ */ jsx("bdi", {
|
|
143
|
+
className: labelClassName,
|
|
144
|
+
children: label
|
|
145
|
+
})]
|
|
146
|
+
})
|
|
101
147
|
});
|
|
102
148
|
};
|
|
103
|
-
|
|
104
|
-
export { CHAT_LINK_ATTRIBUTES, CHAT_LINK_CLASS_NAME, ChatLink, hasBundledChatLinkIcon };
|
|
149
|
+
export { CHAT_LINK_ATTRIBUTES, CHAT_LINK_CLASS_NAME, ChatLink, ChatLinkIdScope, hasBundledChatLinkIcon };
|
package/dist/model-selector.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ChatModelOption, ChatModelSelection } from "./runtime.js";
|
|
2
2
|
import { ReasoningEffort } from "@stll/ai-catalog";
|
|
3
|
-
//#region src/model-selector.d.ts
|
|
4
3
|
export declare const compactModelDisplayName: (displayName: string) => string;
|
|
5
4
|
export declare const groupReasoningEfforts: (efforts: readonly ReasoningEffort[]) => {
|
|
6
5
|
extended: ReasoningEffort[];
|
|
@@ -25,7 +24,7 @@ export type ChatModelSelectorProps = {
|
|
|
25
24
|
options: readonly ChatModelOption[];
|
|
26
25
|
selection: ChatModelSelection;
|
|
27
26
|
};
|
|
28
|
-
/**
|
|
29
|
-
* `resolveChatModelSelection` before a host
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
/** Accessible model control on the design-system select. Provider
|
|
28
|
+
* configuration is validated by `resolveChatModelSelection` before a host
|
|
29
|
+
* accepts the new selection. */
|
|
30
|
+
export declare const ChatModelSelector: ({ autoLabel, disabled, label, onSelectionChange, options, selection }: ChatModelSelectorProps) => import("react").JSX.Element;
|
package/dist/model-selector.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChatConfigurationError } from "./runtime.js";
|
|
2
|
+
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "@stll/ui/select";
|
|
2
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
+
// src/model-selector.tsx
|
|
4
5
|
const CLAUDE_FAMILY_PREFIX = /^Claude\s+/u;
|
|
5
6
|
const compactModelDisplayName = (displayName) => displayName.replace(CLAUDE_FAMILY_PREFIX, "");
|
|
6
7
|
const effortSection = {
|
|
@@ -53,25 +54,24 @@ const parseSelection = (value, options) => {
|
|
|
53
54
|
reasoningEffort: null
|
|
54
55
|
};
|
|
55
56
|
};
|
|
56
|
-
/**
|
|
57
|
-
* `resolveChatModelSelection` before a host
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
/** Accessible model control on the design-system select. Provider
|
|
58
|
+
* configuration is validated by `resolveChatModelSelection` before a host
|
|
59
|
+
* accepts the new selection. */
|
|
60
|
+
const ChatModelSelector = ({ autoLabel, disabled = false, label, onSelectionChange, options, selection }) => /* @__PURE__ */ jsxs(Select, {
|
|
61
|
+
disabled,
|
|
62
|
+
onValueChange: (value) => {
|
|
63
|
+
onSelectionChange(parseSelection(value ?? "", options));
|
|
64
|
+
},
|
|
65
|
+
value: toValue(selection),
|
|
66
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
63
67
|
"aria-label": label,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
value:
|
|
67
|
-
children:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}, `${option.provider}:${option.modelId}`))]
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
//#endregion
|
|
68
|
+
children: /* @__PURE__ */ jsx(SelectValue, {})
|
|
69
|
+
}), /* @__PURE__ */ jsxs(SelectPopup, { children: [/* @__PURE__ */ jsx(SelectItem, {
|
|
70
|
+
value: "",
|
|
71
|
+
children: autoLabel
|
|
72
|
+
}), options.map((option) => /* @__PURE__ */ jsx(SelectItem, {
|
|
73
|
+
value: `${option.provider}:${option.modelId}`,
|
|
74
|
+
children: option.displayName
|
|
75
|
+
}, `${option.provider}:${option.modelId}`))] })]
|
|
76
|
+
});
|
|
77
77
|
export { ChatModelSelector, compactModelDisplayName, groupReasoningEfforts, modelSelectionLabel };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { Interrupt } from "@ag-ui/core";
|
|
3
|
-
//#region src/resume-contract.d.ts
|
|
4
3
|
/** Keep native interrupt validation tied to the protocol's owning schema. */
|
|
5
4
|
export declare const chatResumeSnapshotSchema: v.ObjectSchema<{
|
|
6
5
|
readonly resumeState: v.ObjectSchema<{
|
|
@@ -28,5 +27,4 @@ export declare const chatTurnResumeProbeSchema: v.VariantSchema<"type", [v.Objec
|
|
|
28
27
|
readonly pendingInterrupts: v.ExactOptionalSchema<v.ArraySchema<v.CustomSchema<Interrupt, undefined>, undefined>, undefined>;
|
|
29
28
|
}, undefined>, undefined>;
|
|
30
29
|
}, undefined>], undefined>;
|
|
31
|
-
export type ChatTurnResumeProbe = v.InferOutput<typeof chatTurnResumeProbeSchema>;
|
|
32
|
-
//#endregion
|
|
30
|
+
export type ChatTurnResumeProbe = v.InferOutput<typeof chatTurnResumeProbeSchema>;
|
package/dist/resume-contract.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { InterruptSchema } from "@ag-ui/core/schemas";
|
|
3
|
-
|
|
3
|
+
// src/resume-contract.ts
|
|
4
4
|
/** Keep native interrupt validation tied to the protocol's owning schema. */
|
|
5
5
|
const chatResumeSnapshotSchema = v.object({
|
|
6
6
|
resumeState: v.object({
|
|
@@ -26,5 +26,4 @@ const chatTurnResumeProbeSchema = v.variant("type", [
|
|
|
26
26
|
resumeSnapshot: v.exactOptional(chatResumeSnapshotSchema)
|
|
27
27
|
})
|
|
28
28
|
]);
|
|
29
|
-
//#endregion
|
|
30
29
|
export { chatResumeSnapshotSchema, chatTurnResumeProbeSchema };
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AIProvider, ReasoningEffort } from "@stll/ai-catalog";
|
|
2
|
-
//#region src/runtime.d.ts
|
|
3
2
|
export type ChatModelOption = {
|
|
4
3
|
defaultReasoningEffort: ReasoningEffort | null;
|
|
5
4
|
displayName: string;
|
|
@@ -74,5 +73,4 @@ export declare const createChatRuntime: <Metadata = undefined>({ initialMessages
|
|
|
74
73
|
initialMessages?: readonly ChatMessage<Metadata>[];
|
|
75
74
|
transport: ChatTransport<Metadata>;
|
|
76
75
|
}) => ChatRuntime<Metadata>;
|
|
77
|
-
//#endregion
|
|
78
76
|
export {};
|
package/dist/runtime.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TaggedError } from "better-result";
|
|
2
2
|
import { AI_PROVIDERS } from "@stll/ai-catalog";
|
|
3
|
-
|
|
3
|
+
// src/runtime.ts
|
|
4
4
|
var ChatConfigurationError = class extends TaggedError("ChatConfigurationError") {};
|
|
5
5
|
var ChatStreamError = class extends TaggedError("ChatStreamError") {};
|
|
6
6
|
const providerSet = new Set(AI_PROVIDERS);
|
|
@@ -140,5 +140,4 @@ const createChatRuntime = ({ initialMessages = [], transport }) => {
|
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
};
|
|
143
|
-
//#endregion
|
|
144
143
|
export { ChatConfigurationError, ChatStreamError, createChatRuntime, resolveChatModelSelection };
|
package/dist/stream.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ChatMessage } from "./runtime.js";
|
|
2
2
|
import { ReactElement } from "react";
|
|
3
|
-
//#region src/stream.d.ts
|
|
4
3
|
export type ChatMessageStreamProps<Metadata> = {
|
|
5
4
|
className?: string | undefined;
|
|
6
5
|
empty?: ReactElement | undefined;
|
|
@@ -9,5 +8,4 @@ export type ChatMessageStreamProps<Metadata> = {
|
|
|
9
8
|
};
|
|
10
9
|
/** A semantic transcript container; hosts supply their own rich markdown,
|
|
11
10
|
* citation, tool-call, and attachment renderers through `renderMessage`. */
|
|
12
|
-
export declare const ChatMessageStream: <Metadata>({ className, empty, messages, renderMessage }: ChatMessageStreamProps<Metadata>) => ReactElement | null;
|
|
13
|
-
//#endregion
|
|
11
|
+
export declare const ChatMessageStream: <Metadata>({ className, empty, messages, renderMessage }: ChatMessageStreamProps<Metadata>) => ReactElement | null;
|
package/dist/stream.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
2
|
+
// src/stream.tsx
|
|
3
3
|
/** A semantic transcript container; hosts supply their own rich markdown,
|
|
4
4
|
* citation, tool-call, and attachment renderers through `renderMessage`. */
|
|
5
5
|
const ChatMessageStream = ({ className, empty, messages, renderMessage }) => {
|
|
@@ -9,5 +9,4 @@ const ChatMessageStream = ({ className, empty, messages, renderMessage }) => {
|
|
|
9
9
|
children: messages.map((message) => /* @__PURE__ */ jsx("li", { children: renderMessage(message) }, message.id))
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
|
-
//#endregion
|
|
13
12
|
export { ChatMessageStream };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "./types.js";
|
|
2
|
-
//#region ../../node_modules/.bun/@tanstack+ai@0.65.1+969a6d035afea0f4/node_modules/@tanstack/ai/dist/esm/interrupts.d.ts
|
|
3
2
|
export interface InterruptCorrelation {
|
|
4
3
|
threadId: string;
|
|
5
4
|
interruptedRunId: string;
|
|
@@ -26,5 +25,4 @@ export interface BatchInterruptError extends InterruptCorrelation {
|
|
|
26
25
|
retryable: boolean;
|
|
27
26
|
interruptIds: ReadonlyArray<string>;
|
|
28
27
|
}
|
|
29
|
-
export type InterruptSubmissionError = ItemInterruptError | BatchInterruptError;
|
|
30
|
-
//#endregion
|
|
28
|
+
export type InterruptSubmissionError = ItemInterruptError | BatchInterruptError;
|
|
@@ -4,7 +4,6 @@ import { ActivityDeltaEvent, ActivityMessage, ActivitySnapshotEvent, AudioPart,
|
|
|
4
4
|
import { BilledUsage, BillingUnit, CompletionTokensDetails, PromptTokensDetails, ProviderUsageDetails, TokenUsage, UsageCostBreakdown } from "../../../../../../../../../../../.bun/install/cache/links/@tanstack_ai-event-client@0.13.1-cfefc90983c2de00/node_modules/@tanstack/ai-event-client/dist/esm/index.js";
|
|
5
5
|
import { InterruptSubmissionError } from "./interrupts.js";
|
|
6
6
|
import { SpecTokenUsage, TokenUsageLeftover } from "./utilities/ag-ui-usage.js";
|
|
7
|
-
//#region ../../node_modules/.bun/@tanstack+ai@0.65.1+969a6d035afea0f4/node_modules/@tanstack/ai/dist/esm/types.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* Tool call states - track the lifecycle of a tool call
|
|
10
9
|
*/
|
|
@@ -540,5 +539,4 @@ interface SubagentErrorEvent$1 extends SubagentErrorEvent {}
|
|
|
540
539
|
* Uses the AG-UI protocol event format.
|
|
541
540
|
*/
|
|
542
541
|
export type StreamChunk = AGUIEvent;
|
|
543
|
-
//#endregion
|
|
544
542
|
export { ActivityDeltaEvent$1 as ActivityDeltaEvent, ActivitySnapshotEvent$1 as ActivitySnapshotEvent, AudioPart$1 as AudioPart, CustomEvent$1 as CustomEvent, DocumentPart$1 as DocumentPart, ImagePart$1 as ImagePart, MessagesSnapshotEvent$1 as MessagesSnapshotEvent, RawEvent$1 as RawEvent, ReasoningEncryptedValueEvent$1 as ReasoningEncryptedValueEvent, ReasoningEndEvent$1 as ReasoningEndEvent, ReasoningMessageChunkEvent$1 as ReasoningMessageChunkEvent, ReasoningMessageContentEvent$1 as ReasoningMessageContentEvent, ReasoningMessageEndEvent$1 as ReasoningMessageEndEvent, ReasoningMessageStartEvent$1 as ReasoningMessageStartEvent, ReasoningStartEvent$1 as ReasoningStartEvent, RunErrorEvent$1 as RunErrorEvent, RunFinishedEvent$1 as RunFinishedEvent, RunStartedEvent$1 as RunStartedEvent, StateDeltaEvent$1 as StateDeltaEvent, StateSnapshotEvent$1 as StateSnapshotEvent, StepFinishedEvent$1 as StepFinishedEvent, StepStartedEvent$1 as StepStartedEvent, SubagentErrorEvent$1 as SubagentErrorEvent, SubagentFinishedEvent$1 as SubagentFinishedEvent, SubagentStartedEvent$1 as SubagentStartedEvent, TextMessageChunkEvent$1 as TextMessageChunkEvent, TextMessageContentEvent$1 as TextMessageContentEvent, TextMessageEndEvent$1 as TextMessageEndEvent, TextMessageStartEvent$1 as TextMessageStartEvent, type TokenUsage, ToolCall$1 as ToolCall, ToolCallArgsEvent$1 as ToolCallArgsEvent, ToolCallChunkEvent$1 as ToolCallChunkEvent, ToolCallEndEvent$1 as ToolCallEndEvent, ToolCallResultEvent$1 as ToolCallResultEvent, ToolCallStartEvent$1 as ToolCallStartEvent, VideoPart$1 as VideoPart };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import "../types.js";
|
|
2
2
|
import { TokenUsage as SpecTokenUsage } from "@ag-ui/core";
|
|
3
3
|
import { TokenUsage } from "../../../../../../../../../../../../.bun/install/cache/links/@tanstack_ai-event-client@0.13.1-cfefc90983c2de00/node_modules/@tanstack/ai-event-client/dist/esm/index.js";
|
|
4
|
-
//#region ../../node_modules/.bun/@tanstack+ai@0.65.1+969a6d035afea0f4/node_modules/@tanstack/ai/dist/esm/utilities/ag-ui-usage.d.ts
|
|
5
4
|
/** TokenUsage fields that have no AG-UI `usage[]` equivalent. */
|
|
6
5
|
export type TokenUsageLeftover = Omit<TokenUsage, 'promptTokens' | 'completionTokens' | 'totalTokens'>;
|
|
7
|
-
//#endregion
|
|
8
6
|
export type { SpecTokenUsage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Typed React chat composer, message stream, model selector, and transport runtime primitives.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -90,13 +90,12 @@
|
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
92
|
"@ag-ui/core": "1.0.3",
|
|
93
|
-
"@stll/ai-catalog": "^0.
|
|
94
|
-
"@stll/
|
|
93
|
+
"@stll/ai-catalog": "^0.10.1",
|
|
94
|
+
"@stll/html": "0.1.0",
|
|
95
|
+
"@stll/ui": "^0.66.0",
|
|
95
96
|
"@tanstack/ai-client": "0.38.0",
|
|
96
97
|
"@types/hast": "^3.0.5",
|
|
97
98
|
"better-result": "3.0.1",
|
|
98
|
-
"cheerio": "^1.2.0",
|
|
99
|
-
"domhandler": "^6.0.1",
|
|
100
99
|
"linkify-it": "6.1.0",
|
|
101
100
|
"tldts": "7.4.19",
|
|
102
101
|
"valibot": "1.5.0",
|
|
@@ -116,8 +115,8 @@
|
|
|
116
115
|
},
|
|
117
116
|
"peerDependencies": {
|
|
118
117
|
"@base-ui/react": "^1.7.0",
|
|
119
|
-
"@tiptap/core": "^3.
|
|
120
|
-
"@tiptap/pm": "^3.
|
|
118
|
+
"@tiptap/core": "^3.32.0",
|
|
119
|
+
"@tiptap/pm": "^3.32.0",
|
|
121
120
|
"@types/react": ">=19",
|
|
122
121
|
"react": ">=19"
|
|
123
122
|
},
|