@intentface/chat 0.1.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/LICENSE +21 -0
- package/README.md +108 -0
- package/dist/ask-user/ask-user.d.ts +104 -0
- package/dist/ask-user/ask-user.js +226 -0
- package/dist/ask-user/index.d.ts +3 -0
- package/dist/ask-user/index.js +3 -0
- package/dist/ask-user/index.parts.d.ts +1 -0
- package/dist/ask-user/index.parts.js +5 -0
- package/dist/attachments/attachments.d.ts +41 -0
- package/dist/attachments/attachments.js +91 -0
- package/dist/attachments/index.d.ts +3 -0
- package/dist/attachments/index.js +3 -0
- package/dist/attachments/index.parts.d.ts +1 -0
- package/dist/attachments/index.parts.js +5 -0
- package/dist/chip/chip.d.ts +25 -0
- package/dist/chip/chip.js +25 -0
- package/dist/chip/index.d.ts +2 -0
- package/dist/chip/index.js +2 -0
- package/dist/chip/index.parts.d.ts +1 -0
- package/dist/chip/index.parts.js +5 -0
- package/dist/chip-markdown.d.ts +25 -0
- package/dist/chip-markdown.js +52 -0
- package/dist/composer/actions.d.ts +35 -0
- package/dist/composer/actions.js +75 -0
- package/dist/composer/ask-user-machine.d.ts +52 -0
- package/dist/composer/ask-user-machine.js +164 -0
- package/dist/composer/attachments-machine.d.ts +34 -0
- package/dist/composer/attachments-machine.js +91 -0
- package/dist/composer/attachments.d.ts +16 -0
- package/dist/composer/attachments.js +32 -0
- package/dist/composer/command-list.d.ts +49 -0
- package/dist/composer/command-list.js +357 -0
- package/dist/composer/commands.d.ts +28 -0
- package/dist/composer/commands.js +56 -0
- package/dist/composer/container.d.ts +3 -0
- package/dist/composer/container.js +32 -0
- package/dist/composer/controller.d.ts +3 -0
- package/dist/composer/controller.js +6 -0
- package/dist/composer/editor-dom.d.ts +55 -0
- package/dist/composer/editor-dom.js +431 -0
- package/dist/composer/fuzzy.d.ts +4 -0
- package/dist/composer/fuzzy.js +49 -0
- package/dist/composer/index.d.ts +25 -0
- package/dist/composer/index.js +13 -0
- package/dist/composer/index.parts.d.ts +11 -0
- package/dist/composer/index.parts.js +15 -0
- package/dist/composer/internals.d.ts +29 -0
- package/dist/composer/internals.js +102 -0
- package/dist/composer/keyboard.d.ts +61 -0
- package/dist/composer/keyboard.js +75 -0
- package/dist/composer/panel.d.ts +28 -0
- package/dist/composer/panel.js +80 -0
- package/dist/composer/placeholder.d.ts +10 -0
- package/dist/composer/placeholder.js +8 -0
- package/dist/composer/popover.d.ts +12 -0
- package/dist/composer/popover.js +63 -0
- package/dist/composer/prefix-detection.d.ts +23 -0
- package/dist/composer/prefix-detection.js +58 -0
- package/dist/composer/root.d.ts +21 -0
- package/dist/composer/root.js +107 -0
- package/dist/composer/segments.d.ts +108 -0
- package/dist/composer/segments.js +366 -0
- package/dist/composer/store.d.ts +97 -0
- package/dist/composer/store.js +451 -0
- package/dist/composer/textarea.d.ts +39 -0
- package/dist/composer/textarea.js +64 -0
- package/dist/composer/trigger-tracker.d.ts +12 -0
- package/dist/composer/trigger-tracker.js +90 -0
- package/dist/composer/types.d.ts +126 -0
- package/dist/composer/types.js +4 -0
- package/dist/composer/use-composer-editor.d.ts +43 -0
- package/dist/composer/use-composer-editor.js +649 -0
- package/dist/internal/collapsible.d.ts +22 -0
- package/dist/internal/collapsible.js +90 -0
- package/dist/internal/primitive-props.d.ts +4 -0
- package/dist/internal/primitive-props.js +4 -0
- package/dist/internal/render/baseTypes.d.ts +18 -0
- package/dist/internal/render/baseTypes.js +4 -0
- package/dist/internal/render/empty.d.ts +3 -0
- package/dist/internal/render/empty.js +5 -0
- package/dist/internal/render/getReactElementRef.d.ts +5 -0
- package/dist/internal/render/getReactElementRef.js +15 -0
- package/dist/internal/render/getStateAttributesProps.d.ts +4 -0
- package/dist/internal/render/getStateAttributesProps.js +23 -0
- package/dist/internal/render/mergeObjects.d.ts +1 -0
- package/dist/internal/render/mergeObjects.js +14 -0
- package/dist/internal/render/mergeProps.d.ts +55 -0
- package/dist/internal/render/mergeProps.js +183 -0
- package/dist/internal/render/positioning.d.ts +22 -0
- package/dist/internal/render/positioning.js +78 -0
- package/dist/internal/render/reactVersion.d.ts +3 -0
- package/dist/internal/render/reactVersion.js +7 -0
- package/dist/internal/render/resolveClassName.d.ts +8 -0
- package/dist/internal/render/resolveClassName.js +12 -0
- package/dist/internal/render/resolveStyle.d.ts +8 -0
- package/dist/internal/render/resolveStyle.js +12 -0
- package/dist/internal/render/transition.d.ts +48 -0
- package/dist/internal/render/transition.js +203 -0
- package/dist/internal/render/types.d.ts +74 -0
- package/dist/internal/render/types.js +3 -0
- package/dist/internal/render/useMergedRefs.d.ts +21 -0
- package/dist/internal/render/useMergedRefs.js +102 -0
- package/dist/internal/render/useRefWithInit.d.ts +10 -0
- package/dist/internal/render/useRefWithInit.js +12 -0
- package/dist/internal/render/useRender.d.ts +71 -0
- package/dist/internal/render/useRender.js +12 -0
- package/dist/internal/render/useRenderElement.d.ts +62 -0
- package/dist/internal/render/useRenderElement.js +157 -0
- package/dist/internal/render/warn.d.ts +1 -0
- package/dist/internal/render/warn.js +15 -0
- package/dist/internal/state-mappings.d.ts +8 -0
- package/dist/internal/state-mappings.js +17 -0
- package/dist/message/index.d.ts +3 -0
- package/dist/message/index.js +3 -0
- package/dist/message/index.parts.d.ts +1 -0
- package/dist/message/index.parts.js +5 -0
- package/dist/message/message.d.ts +43 -0
- package/dist/message/message.js +78 -0
- package/dist/message-utils.d.ts +55 -0
- package/dist/message-utils.js +79 -0
- package/dist/reasoning/index.d.ts +3 -0
- package/dist/reasoning/index.js +3 -0
- package/dist/reasoning/index.parts.d.ts +1 -0
- package/dist/reasoning/index.parts.js +5 -0
- package/dist/reasoning/reasoning.d.ts +20 -0
- package/dist/reasoning/reasoning.js +49 -0
- package/dist/steps/index.d.ts +2 -0
- package/dist/steps/index.js +2 -0
- package/dist/steps/index.parts.d.ts +1 -0
- package/dist/steps/index.parts.js +5 -0
- package/dist/steps/steps.d.ts +53 -0
- package/dist/steps/steps.js +79 -0
- package/dist/thread/geometry.d.ts +18 -0
- package/dist/thread/geometry.js +59 -0
- package/dist/thread/index.d.ts +4 -0
- package/dist/thread/index.js +3 -0
- package/dist/thread/index.parts.d.ts +1 -0
- package/dist/thread/index.parts.js +5 -0
- package/dist/thread/stores.d.ts +21 -0
- package/dist/thread/stores.js +63 -0
- package/dist/thread/thread.d.ts +66 -0
- package/dist/thread/thread.js +639 -0
- package/dist/types.d.ts +58 -0
- package/dist/types.js +17 -0
- package/package.json +106 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The minimal part contract. Every part has a `type`; parts this package does
|
|
3
|
+
* not understand (e.g. `step-start`, `dynamic-tool`, future additions) are
|
|
4
|
+
* carried through untouched.
|
|
5
|
+
*/
|
|
6
|
+
export type UnknownPart = {
|
|
7
|
+
type: string;
|
|
8
|
+
};
|
|
9
|
+
export type TextPart = {
|
|
10
|
+
type: "text";
|
|
11
|
+
text: string;
|
|
12
|
+
state?: "streaming" | "done";
|
|
13
|
+
};
|
|
14
|
+
export type ReasoningPart = {
|
|
15
|
+
type: "reasoning";
|
|
16
|
+
text: string;
|
|
17
|
+
state?: "streaming" | "done";
|
|
18
|
+
};
|
|
19
|
+
export type FilePart = {
|
|
20
|
+
type: "file";
|
|
21
|
+
mediaType: string;
|
|
22
|
+
url: string;
|
|
23
|
+
filename?: string;
|
|
24
|
+
};
|
|
25
|
+
export type SourceUrlPart = {
|
|
26
|
+
type: "source-url";
|
|
27
|
+
sourceId: string;
|
|
28
|
+
url: string;
|
|
29
|
+
title?: string;
|
|
30
|
+
};
|
|
31
|
+
export type ToolPartState = "input-streaming" | "input-available" | "output-available" | "output-error";
|
|
32
|
+
export type ToolPart<Input = unknown, Output = unknown> = {
|
|
33
|
+
type: `tool-${string}`;
|
|
34
|
+
toolCallId: string;
|
|
35
|
+
state: ToolPartState;
|
|
36
|
+
input?: Input;
|
|
37
|
+
output?: Output;
|
|
38
|
+
errorText?: string;
|
|
39
|
+
};
|
|
40
|
+
export type DataPart = {
|
|
41
|
+
type: `data-${string}`;
|
|
42
|
+
id?: string;
|
|
43
|
+
data?: unknown;
|
|
44
|
+
};
|
|
45
|
+
export type MessagePart = TextPart | ReasoningPart | FilePart | SourceUrlPart | ToolPart | DataPart | UnknownPart;
|
|
46
|
+
export type ChatMessage<Metadata = unknown, Part extends UnknownPart = MessagePart> = {
|
|
47
|
+
id: string;
|
|
48
|
+
role: string;
|
|
49
|
+
metadata?: Metadata;
|
|
50
|
+
parts: Part[];
|
|
51
|
+
};
|
|
52
|
+
/** Structurally identical to the AI SDK's `ChatStatus`. */
|
|
53
|
+
export type ChatStatus = "submitted" | "streaming" | "ready" | "error";
|
|
54
|
+
export declare const isTextPart: (part: UnknownPart) => part is TextPart;
|
|
55
|
+
export declare const isReasoningPart: (part: UnknownPart) => part is ReasoningPart;
|
|
56
|
+
export declare const isFilePart: (part: UnknownPart) => part is FilePart;
|
|
57
|
+
export declare const isSourceUrlPart: (part: UnknownPart) => part is SourceUrlPart;
|
|
58
|
+
export declare const isToolPart: (part: UnknownPart) => part is ToolPart;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Structural message contract. These types are deliberately framework- and
|
|
2
|
+
// SDK-agnostic: an AI SDK `UIMessage` satisfies `ChatMessage` structurally, so
|
|
3
|
+
// no adapter or translation layer is needed. Extend via the generics.
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Ask-user contract
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// Part guards
|
|
9
|
+
//
|
|
10
|
+
// `UnknownPart` sits in the `MessagePart` union, so a raw discriminant check
|
|
11
|
+
// (`part.type === "text"`) cannot narrow. Use these guards instead.
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
export const isTextPart = (part) => part.type === "text";
|
|
14
|
+
export const isReasoningPart = (part) => part.type === "reasoning";
|
|
15
|
+
export const isFilePart = (part) => part.type === "file";
|
|
16
|
+
export const isSourceUrlPart = (part) => part.type === "source-url";
|
|
17
|
+
export const isToolPart = (part) => part.type.startsWith("tool-") && "state" in part && "toolCallId" in part;
|
package/package.json
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intentface/chat",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Headless chat UI primitives — unstyled compound components, hooks, and wire formats for building AI chat interfaces.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"author": "Intentface",
|
|
9
|
+
"homepage": "https://intentface.dev",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/Intentface/intentface-chat.git",
|
|
13
|
+
"directory": "packages/chat"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/Intentface/intentface-chat/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react",
|
|
20
|
+
"chat",
|
|
21
|
+
"ai",
|
|
22
|
+
"headless",
|
|
23
|
+
"ui",
|
|
24
|
+
"components",
|
|
25
|
+
"composer",
|
|
26
|
+
"ai-sdk"
|
|
27
|
+
],
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"LICENSE",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"exports": {
|
|
34
|
+
"./types": {
|
|
35
|
+
"types": "./dist/types.d.ts",
|
|
36
|
+
"default": "./dist/types.js"
|
|
37
|
+
},
|
|
38
|
+
"./composer": {
|
|
39
|
+
"types": "./dist/composer/index.d.ts",
|
|
40
|
+
"default": "./dist/composer/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./chip": {
|
|
43
|
+
"types": "./dist/chip/index.d.ts",
|
|
44
|
+
"default": "./dist/chip/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./thread": {
|
|
47
|
+
"types": "./dist/thread/index.d.ts",
|
|
48
|
+
"default": "./dist/thread/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./reasoning": {
|
|
51
|
+
"types": "./dist/reasoning/index.d.ts",
|
|
52
|
+
"default": "./dist/reasoning/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./steps": {
|
|
55
|
+
"types": "./dist/steps/index.d.ts",
|
|
56
|
+
"default": "./dist/steps/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./attachments": {
|
|
59
|
+
"types": "./dist/attachments/index.d.ts",
|
|
60
|
+
"default": "./dist/attachments/index.js"
|
|
61
|
+
},
|
|
62
|
+
"./ask-user": {
|
|
63
|
+
"types": "./dist/ask-user/index.d.ts",
|
|
64
|
+
"default": "./dist/ask-user/index.js"
|
|
65
|
+
},
|
|
66
|
+
"./message": {
|
|
67
|
+
"types": "./dist/message/index.d.ts",
|
|
68
|
+
"default": "./dist/message/index.js"
|
|
69
|
+
},
|
|
70
|
+
"./message-utils": {
|
|
71
|
+
"types": "./dist/message-utils.d.ts",
|
|
72
|
+
"default": "./dist/message-utils.js"
|
|
73
|
+
},
|
|
74
|
+
"./chip-markdown": {
|
|
75
|
+
"types": "./dist/chip-markdown.d.ts",
|
|
76
|
+
"default": "./dist/chip-markdown.js"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"scripts": {
|
|
80
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && node scripts/add-dist-extensions.mjs",
|
|
81
|
+
"test": "bun test",
|
|
82
|
+
"typecheck": "tsc --noEmit",
|
|
83
|
+
"prepack": "bun run build && node scripts/swap-exports.mjs pre",
|
|
84
|
+
"postpack": "node scripts/swap-exports.mjs post"
|
|
85
|
+
},
|
|
86
|
+
"dependencies": {
|
|
87
|
+
"@floating-ui/dom": "^1.7.6",
|
|
88
|
+
"nanoid": "^5.1.11"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"react": "^19.0.0",
|
|
92
|
+
"react-dom": "^19.0.0"
|
|
93
|
+
},
|
|
94
|
+
"devDependencies": {
|
|
95
|
+
"@happy-dom/global-registrator": "^20.10.6",
|
|
96
|
+
"@testing-library/react": "^16.3.2",
|
|
97
|
+
"@types/bun": "^1",
|
|
98
|
+
"@types/react": "^19",
|
|
99
|
+
"@types/react-dom": "^19",
|
|
100
|
+
"axe-core": "^4.12.1",
|
|
101
|
+
"typescript": "^5"
|
|
102
|
+
},
|
|
103
|
+
"publishConfig": {
|
|
104
|
+
"access": "public"
|
|
105
|
+
}
|
|
106
|
+
}
|