@stll/chat 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # `@stll/chat`
2
2
 
3
- Portable React chat primitives: a rich-editor composer shell, message stream,
4
- model selector, and observable streaming runtime.
3
+ Portable React chat primitives: message streams, model selectors, composer
4
+ action resolution, and observable streaming runtimes.
5
5
 
6
6
  The host owns authentication, endpoint selection, persistence, provider
7
7
  credentials, translations, and rich-message rendering. It supplies a typed
@@ -9,18 +9,9 @@ credentials, translations, and rich-message rendering. It supplies a typed
9
9
  selects a provider.
10
10
 
11
11
  ```tsx
12
- import { ChatComposer, ChatMessageStream, createChatRuntime } from "@stll/chat";
12
+ import { ChatMessageStream, createChatRuntime } from "@stll/chat";
13
13
 
14
14
  const runtime = createChatRuntime({ transport });
15
-
16
- <ChatComposer
17
- canSend={draft.length > 0}
18
- isGenerating={runtime.getSnapshot().isStreaming}
19
- labels={{ retry: "Retry", send: "Send", stop: "Stop" }}
20
- onSend={sendDraft}
21
- >
22
- <RichEditor />
23
- </ChatComposer>;
24
15
  ```
25
16
 
26
17
  Validate every explicit provider/model selection with
@@ -1,4 +1,3 @@
1
- import { ReactNode } from "react";
2
1
  //#region src/composer.d.ts
3
2
  export type ChatComposerActionState = {
4
3
  canSend: boolean;
@@ -9,22 +8,4 @@ export type ChatComposerActionState = {
9
8
  };
10
9
  export type ChatComposerActionMode = "retry" | "send" | "stop";
11
10
  export declare const resolveChatComposerAction: ({ isGenerating, onRetry, onStop }: Pick<ChatComposerActionState, "isGenerating" | "onRetry" | "onStop">) => ChatComposerActionMode;
12
- export type ChatComposerLabels = Record<ChatComposerActionMode, string>;
13
- export declare const ChatComposerAction: ({ canSend, className, isGenerating, labels, onRetry, onSend, onStop }: ChatComposerActionState & {
14
- className?: string | undefined;
15
- labels: ChatComposerLabels;
16
- }) => import("react").JSX.Element;
17
- export type ChatComposerProps = ChatComposerActionState & {
18
- children: ReactNode;
19
- className?: string | undefined;
20
- labels: ChatComposerLabels;
21
- leading?: ReactNode | undefined;
22
- status?: ReactNode | undefined;
23
- };
24
- /**
25
- * Layout-only composer shell for rich editors. `children` is deliberately a
26
- * host-owned editor slot, so TipTap, ProseMirror, native inputs, and mobile
27
- * editors can share send/stop/retry behavior without copying shell chrome.
28
- */
29
- export declare const ChatComposer: ({ children, className, labels, leading, status, ...action }: ChatComposerProps) => import("react").JSX.Element;
30
11
  //#endregion
package/dist/composer.js CHANGED
@@ -1,80 +1,8 @@
1
- import { panic } from "better-result";
2
- import { Button } from "@stll/ui/button";
3
- import { ArrowUpIcon, RotateCcwIcon, SquareIcon } from "@stll/ui/icons";
4
- import { cn } from "@stll/ui/utils";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
1
  //#region src/composer.tsx
7
2
  const resolveChatComposerAction = ({ isGenerating, onRetry, onStop }) => {
8
3
  if (isGenerating && onStop !== void 0) return "stop";
9
4
  if (!isGenerating && onRetry !== void 0) return "retry";
10
5
  return "send";
11
6
  };
12
- const ChatComposerAction = ({ canSend, className, isGenerating, labels, onRetry, onSend, onStop }) => {
13
- const mode = resolveChatComposerAction({
14
- isGenerating,
15
- onRetry,
16
- onStop
17
- });
18
- const disabled = mode === "send" && !canSend;
19
- const onClick = () => {
20
- switch (mode) {
21
- case "send":
22
- onSend();
23
- return;
24
- case "stop":
25
- onStop?.();
26
- return;
27
- case "retry":
28
- onRetry?.();
29
- return;
30
- default: panic(`Unhandled mode: ${String(mode)}`);
31
- }
32
- };
33
- return /* @__PURE__ */ jsxs(Button, {
34
- "aria-label": labels[mode],
35
- className: cn("bg-foreground text-background hover:bg-foreground/90 size-7 shrink-0 rounded-full", className),
36
- disabled,
37
- onClick,
38
- size: "icon-sm",
39
- tooltip: false,
40
- type: "button",
41
- children: [
42
- mode === "send" && /* @__PURE__ */ jsx(ArrowUpIcon, {
43
- "aria-hidden": "true",
44
- className: "size-3.5"
45
- }),
46
- mode === "stop" && /* @__PURE__ */ jsx(SquareIcon, {
47
- "aria-hidden": "true",
48
- className: "size-3.5"
49
- }),
50
- mode === "retry" && /* @__PURE__ */ jsx(RotateCcwIcon, {
51
- "aria-hidden": "true",
52
- className: "size-3.5"
53
- })
54
- ]
55
- });
56
- };
57
- /**
58
- * Layout-only composer shell for rich editors. `children` is deliberately a
59
- * host-owned editor slot, so TipTap, ProseMirror, native inputs, and mobile
60
- * editors can share send/stop/retry behavior without copying shell chrome.
61
- */
62
- const ChatComposer = ({ children, className, labels, leading, status, ...action }) => /* @__PURE__ */ jsxs("section", {
63
- className: cn("flex flex-col gap-1.5", className),
64
- children: [/* @__PURE__ */ jsxs("div", {
65
- className: "border-input bg-background flex min-w-0 items-end gap-2 rounded-xl border p-2",
66
- children: [
67
- leading,
68
- /* @__PURE__ */ jsx("div", {
69
- className: "min-w-0 flex-1",
70
- children
71
- }),
72
- /* @__PURE__ */ jsx(ChatComposerAction, {
73
- ...action,
74
- labels
75
- })
76
- ]
77
- }), status]
78
- });
79
7
  //#endregion
80
- export { ChatComposer, ChatComposerAction, resolveChatComposerAction };
8
+ export { resolveChatComposerAction };
@@ -1,7 +1,7 @@
1
1
  import { chatTurnResumeProbeSchema } from "./resume-contract.js";
2
- import { Result, TaggedError, panic } from "better-result";
3
2
  import { EventType } from "@ag-ui/core";
4
3
  import { fetchServerSentEvents } from "@tanstack/ai-client";
4
+ import { Result, TaggedError, panic } from "better-result";
5
5
  import * as v from "valibot";
6
6
  //#region src/durable-transport.ts
7
7
  var ChatReconnectError = class extends TaggedError("ChatReconnectError") {};
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ChatComposer, ChatComposerAction, ChatComposerActionMode, ChatComposerActionState, ChatComposerLabels, ChatComposerProps, resolveChatComposerAction } from "./composer.js";
1
+ import { ChatComposerActionMode, ChatComposerActionState, resolveChatComposerAction } from "./composer.js";
2
2
  import { ChatConfigurationError, ChatMessage, ChatModelOption, ChatModelSelection, ChatProviderConfiguration, ChatRuntime, ChatRuntimeSnapshot, ChatStreamError, ChatStreamEvent, ChatTransport, createChatRuntime, resolveChatModelSelection } from "./runtime.js";
3
3
  import { ChatModelSelector, ChatModelSelectorProps, compactModelDisplayName, groupReasoningEfforts, modelSelectionLabel } from "./model-selector.js";
4
4
  import { ChatMessageStream, ChatMessageStreamProps } from "./stream.js";
5
- export { ChatComposer, ChatComposerAction, type ChatComposerActionMode, type ChatComposerActionState, type ChatComposerLabels, type ChatComposerProps, ChatConfigurationError, type ChatMessage, ChatMessageStream, type ChatMessageStreamProps, type ChatModelOption, type ChatModelSelection, ChatModelSelector, type ChatModelSelectorProps, type ChatProviderConfiguration, type ChatRuntime, type ChatRuntimeSnapshot, ChatStreamError, type ChatStreamEvent, type ChatTransport, compactModelDisplayName, createChatRuntime, groupReasoningEfforts, modelSelectionLabel, resolveChatComposerAction, resolveChatModelSelection };
5
+ export { type ChatComposerActionMode, type ChatComposerActionState, ChatConfigurationError, type ChatMessage, ChatMessageStream, type ChatMessageStreamProps, type ChatModelOption, type ChatModelSelection, ChatModelSelector, type ChatModelSelectorProps, type ChatProviderConfiguration, type ChatRuntime, type ChatRuntimeSnapshot, ChatStreamError, type ChatStreamEvent, type ChatTransport, compactModelDisplayName, createChatRuntime, groupReasoningEfforts, modelSelectionLabel, resolveChatComposerAction, resolveChatModelSelection };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ChatComposer, ChatComposerAction, resolveChatComposerAction } from "./composer.js";
1
+ import { resolveChatComposerAction } from "./composer.js";
2
2
  import { ChatConfigurationError, ChatStreamError, createChatRuntime, resolveChatModelSelection } from "./runtime.js";
3
3
  import { ChatModelSelector, compactModelDisplayName, groupReasoningEfforts, modelSelectionLabel } from "./model-selector.js";
4
4
  import { ChatMessageStream } from "./stream.js";
5
- export { ChatComposer, ChatComposerAction, ChatConfigurationError, ChatMessageStream, ChatModelSelector, ChatStreamError, compactModelDisplayName, createChatRuntime, groupReasoningEfforts, modelSelectionLabel, resolveChatComposerAction, resolveChatModelSelection };
5
+ export { ChatConfigurationError, ChatMessageStream, ChatModelSelector, ChatStreamError, compactModelDisplayName, createChatRuntime, groupReasoningEfforts, modelSelectionLabel, resolveChatComposerAction, resolveChatModelSelection };
package/dist/link.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { normalizeChatLink } from "./link-detection.js";
2
- import { GlobeIcon } from "@stll/ui/icons";
3
2
  import { jsx, jsxs } from "react/jsx-runtime";
4
3
  import { isValidElement, useState } from "react";
5
4
  import { GitHubLogoIcon, XLogoIcon } from "@stll/ui/brand-icons";
5
+ import { GlobeIcon } from "@stll/ui/icons";
6
6
  //#region src/link.tsx
7
7
  const CHAT_LINK_ATTRIBUTES = {
8
8
  target: "_blank",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/chat",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Typed React chat composer, message stream, model selector, and transport runtime primitives.",
5
5
  "keywords": [
6
6
  "ai",
@@ -88,7 +88,7 @@
88
88
  "dependencies": {
89
89
  "@ag-ui/core": "1.0.2",
90
90
  "@stll/ai-catalog": "^0.8.0",
91
- "@stll/ui": "^0.47.0",
91
+ "@stll/ui": "^0.47.1",
92
92
  "@tanstack/ai-client": "0.38.0",
93
93
  "@types/hast": "^3.0.5",
94
94
  "better-result": "3.0.1",