@slipstream-ui/ai 0.0.0-stage → 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/LICENSE +25 -0
- package/dist/index.d.mts +579 -0
- package/dist/index.d.ts +579 -0
- package/dist/index.js +1778 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1706 -0
- package/dist/index.mjs.map +1 -0
- package/dist/manifests/attachment.manifest.json +33 -0
- package/dist/manifests/branch.manifest.json +65 -0
- package/dist/manifests/chain-thought.manifest.json +39 -0
- package/dist/manifests/code-block.manifest.json +50 -0
- package/dist/manifests/command-palette.manifest.json +80 -0
- package/dist/manifests/confirmation.manifest.json +143 -0
- package/dist/manifests/conversation.manifest.json +290 -0
- package/dist/manifests/inline-citation.manifest.json +46 -0
- package/dist/manifests/message-actions.manifest.json +35 -0
- package/dist/manifests/message.manifest.json +235 -0
- package/dist/manifests/prompt-input.manifest.json +334 -0
- package/dist/manifests/reasoning.manifest.json +177 -0
- package/dist/manifests/response.manifest.json +51 -0
- package/dist/manifests/source.manifest.json +78 -0
- package/dist/manifests/streaming-indicator.manifest.json +39 -0
- package/dist/manifests/suggestions.manifest.json +45 -0
- package/dist/manifests/tool-call.manifest.json +158 -0
- package/package.json +61 -3
- package/src/adapter/adapter.test.tsx +83 -0
- package/src/adapter/hooks.ts +82 -0
- package/src/adapter/index.ts +3 -0
- package/src/adapter/messages.ts +49 -0
- package/src/adapter/types.ts +24 -0
- package/src/components/attachment/Attachment.test.tsx +72 -0
- package/src/components/attachment/Attachment.tsx +84 -0
- package/src/components/attachment/AttachmentList.tsx +30 -0
- package/src/components/attachment/index.ts +5 -0
- package/src/components/branch/Branch.test.tsx +52 -0
- package/src/components/branch/Branch.tsx +77 -0
- package/src/components/branch/index.ts +2 -0
- package/src/components/chainthought/ChainThought.test.tsx +34 -0
- package/src/components/chainthought/ChainThought.tsx +45 -0
- package/src/components/chainthought/index.ts +2 -0
- package/src/components/code-block/CodeBlock.test.tsx +46 -0
- package/src/components/code-block/CodeBlock.tsx +95 -0
- package/src/components/code-block/index.ts +2 -0
- package/src/components/command-palette/CommandPalette.test.tsx +74 -0
- package/src/components/command-palette/CommandPalette.tsx +156 -0
- package/src/components/command-palette/index.ts +2 -0
- package/src/components/confirmation/Confirmation.test.tsx +97 -0
- package/src/components/confirmation/Confirmation.tsx +146 -0
- package/src/components/confirmation/index.ts +2 -0
- package/src/components/conversation/Conversation.test.tsx +49 -0
- package/src/components/conversation/Conversation.tsx +301 -0
- package/src/components/conversation/Conversation.welcome.test.tsx +73 -0
- package/src/components/conversation/index.ts +2 -0
- package/src/components/inline-citation/InlineCitation.test.tsx +42 -0
- package/src/components/inline-citation/InlineCitation.tsx +56 -0
- package/src/components/inline-citation/index.ts +2 -0
- package/src/components/message/Message.error-edit.test.tsx +60 -0
- package/src/components/message/Message.test.tsx +80 -0
- package/src/components/message/Message.tsx +205 -0
- package/src/components/message/index.ts +2 -0
- package/src/components/message-actions/MessageActions.test.tsx +77 -0
- package/src/components/message-actions/MessageActions.tsx +134 -0
- package/src/components/message-actions/index.ts +2 -0
- package/src/components/prompt-input/PromptInput.compound.test.tsx +150 -0
- package/src/components/prompt-input/PromptInput.test.tsx +74 -0
- package/src/components/prompt-input/PromptInput.tsx +584 -0
- package/src/components/prompt-input/index.ts +21 -0
- package/src/components/reasoning/Reasoning.duration.test.tsx +35 -0
- package/src/components/reasoning/Reasoning.test.tsx +58 -0
- package/src/components/reasoning/Reasoning.tsx +85 -0
- package/src/components/reasoning/index.ts +2 -0
- package/src/components/response/Response.test.tsx +69 -0
- package/src/components/response/Response.tsx +75 -0
- package/src/components/response/close-incomplete-markdown.ts +47 -0
- package/src/components/response/index.ts +3 -0
- package/src/components/source/Source.tsx +51 -0
- package/src/components/source/Sources.tsx +42 -0
- package/src/components/source/index.ts +5 -0
- package/src/components/source/source.test.tsx +72 -0
- package/src/components/streaming/StreamingIndicator.test.tsx +26 -0
- package/src/components/streaming/StreamingIndicator.tsx +46 -0
- package/src/components/streaming/index.ts +2 -0
- package/src/components/suggestion/Suggestion.test.tsx +43 -0
- package/src/components/suggestion/Suggestion.tsx +47 -0
- package/src/components/suggestion/index.ts +2 -0
- package/src/components/tool-call/ToolCall.test.tsx +45 -0
- package/src/components/tool-call/ToolCall.tsx +101 -0
- package/src/components/tool-call/index.ts +2 -0
- package/src/index.ts +29 -0
- package/src/manifests/attachment.manifest.json +33 -0
- package/src/manifests/branch.manifest.json +65 -0
- package/src/manifests/chain-thought.manifest.json +39 -0
- package/src/manifests/code-block.manifest.json +50 -0
- package/src/manifests/command-palette.manifest.json +80 -0
- package/src/manifests/confirmation.manifest.json +143 -0
- package/src/manifests/conversation.manifest.json +290 -0
- package/src/manifests/inline-citation.manifest.json +46 -0
- package/src/manifests/message-actions.manifest.json +35 -0
- package/src/manifests/message.manifest.json +235 -0
- package/src/manifests/prompt-input.manifest.json +334 -0
- package/src/manifests/reasoning.manifest.json +177 -0
- package/src/manifests/response.manifest.json +51 -0
- package/src/manifests/source.manifest.json +78 -0
- package/src/manifests/streaming-indicator.manifest.json +39 -0
- package/src/manifests/suggestions.manifest.json +45 -0
- package/src/manifests/tool-call.manifest.json +158 -0
- package/src/test/jest-axe.d.ts +16 -0
- package/src/test/setup.ts +18 -0
- package/src/test/vitest-matchers.d.ts +10 -0
- package/src/types/index.ts +40 -0
- package/README.md +0 -3
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "suggestions",
|
|
3
|
+
"name": "Suggestions",
|
|
4
|
+
"tier": "molecule",
|
|
5
|
+
"description": "Displays clickable follow-up prompts for AI interactions.",
|
|
6
|
+
"designIntent": "Help users discover useful next actions without composing every prompt from scratch.",
|
|
7
|
+
"props": [
|
|
8
|
+
{
|
|
9
|
+
"name": "suggestions",
|
|
10
|
+
"type": "Suggestion[]",
|
|
11
|
+
"required": true,
|
|
12
|
+
"description": "Suggestions to display."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "onSelect",
|
|
16
|
+
"type": "(suggestion: Suggestion) => void",
|
|
17
|
+
"required": false,
|
|
18
|
+
"description": "Called when a suggestion is selected."
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "maxDisplay",
|
|
22
|
+
"required": false,
|
|
23
|
+
"defaultValue": "4",
|
|
24
|
+
"type": "number",
|
|
25
|
+
"description": "Maximum number of suggestions to display before truncating"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"examples": [
|
|
29
|
+
{
|
|
30
|
+
"title": "Follow-up prompts",
|
|
31
|
+
"code": "<Suggestions suggestions={[{ id: '1', text: 'Show me an example' }]} />"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"accessibility": [
|
|
35
|
+
{
|
|
36
|
+
"feature": "Keyboard activation",
|
|
37
|
+
"implementation": "Suggestions are native buttons."
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"package": "@slipstream-ui/ai",
|
|
41
|
+
"importPath": "@slipstream-ui/ai",
|
|
42
|
+
"version": "0.0.1",
|
|
43
|
+
"sourceDir": "suggestion",
|
|
44
|
+
"exportName": "Suggestions"
|
|
45
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "tool-call",
|
|
3
|
+
"name": "ToolCall",
|
|
4
|
+
"tier": "molecule",
|
|
5
|
+
"description": "A component for displaying AI tool/function calls with status, arguments, and results",
|
|
6
|
+
"designIntent": "The ToolCall component visualizes when an AI agent uses tools or functions. It shows the tool name, status (pending, running, completed, failed), arguments passed, and the result returned. This provides transparency into the AI's actions.",
|
|
7
|
+
"props": [
|
|
8
|
+
{
|
|
9
|
+
"name": "toolCall",
|
|
10
|
+
"type": "ToolCall",
|
|
11
|
+
"required": true,
|
|
12
|
+
"description": "The tool call object containing name, arguments, status, and result",
|
|
13
|
+
"examples": [
|
|
14
|
+
"{ id: '1', name: 'search', arguments: { query: 'React' }, status: 'completed' }"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "showResult",
|
|
19
|
+
"type": "boolean",
|
|
20
|
+
"defaultValue": "true",
|
|
21
|
+
"required": false,
|
|
22
|
+
"description": "Whether to display the tool result",
|
|
23
|
+
"examples": [
|
|
24
|
+
true,
|
|
25
|
+
false
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "className",
|
|
30
|
+
"type": "string",
|
|
31
|
+
"required": false,
|
|
32
|
+
"description": "Additional CSS classes to apply"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"examples": [
|
|
36
|
+
{
|
|
37
|
+
"title": "Completed tool call",
|
|
38
|
+
"code": "<ToolCall \n toolCall={{\n id: '1',\n name: 'search',\n arguments: { query: 'React components' },\n status: 'completed',\n result: { results: [...] }\n }}\n/>",
|
|
39
|
+
"description": "Tool call that completed successfully with result"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"title": "Running tool call",
|
|
43
|
+
"code": "<ToolCall \n toolCall={{\n id: '2',\n name: 'calculate',\n arguments: { expression: '2 + 2' },\n status: 'running'\n }}\n/>",
|
|
44
|
+
"description": "Tool call currently in progress"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"title": "Failed tool call",
|
|
48
|
+
"code": "<ToolCall \n toolCall={{\n id: '3',\n name: 'api_request',\n arguments: { endpoint: '/users' },\n status: 'failed',\n result: { error: 'Timeout' }\n }}\n/>",
|
|
49
|
+
"description": "Tool call that failed with error message"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"title": "Without result",
|
|
53
|
+
"code": "<ToolCall \n toolCall={toolCall}\n showResult={false}\n/>",
|
|
54
|
+
"description": "Tool call with result hidden"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"antiPatterns": [
|
|
58
|
+
{
|
|
59
|
+
"title": "Don't show tool calls for simple operations",
|
|
60
|
+
"explanation": "Tool calls should be shown for meaningful operations, not trivial ones.",
|
|
61
|
+
"example": "// Avoid: Showing trivial tool calls\n<ToolCall toolCall={{ name: 'echo', arguments: { text: 'hello' }, status: 'completed' }} />\n\n// Prefer: Only show meaningful tool usage\n<ToolCall toolCall={{ name: 'search_database', arguments: { query: complexQuery }, status: 'completed' }} />"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"title": "Don't expose sensitive data in arguments",
|
|
65
|
+
"explanation": "Never display sensitive credentials or personal data in tool call arguments.",
|
|
66
|
+
"example": "// Avoid: Including sensitive data\n<ToolCall toolCall={{ \n name: 'api_call', \n arguments: { apiKey: 'secret-key' }, \n status: 'completed' \n}} />\n\n// Prefer: Redact sensitive information\n<ToolCall toolCall={{ \n name: 'api_call', \n arguments: { apiKey: '[REDACTED]' }, \n status: 'completed' \n}} />"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"title": "Don't ignore failed tool calls",
|
|
70
|
+
"explanation": "Failed tool calls should be clearly indicated with error information.",
|
|
71
|
+
"example": "// Avoid: Not addressing failures\n<ToolCall toolCall={{ name: 'save', status: 'failed' }} />\n\n// Prefer: Handle and display failures appropriately\n<ToolCall toolCall={{ name: 'save', status: 'failed', result: { error: 'Permission denied' } }} />"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"accessibility": [
|
|
75
|
+
{
|
|
76
|
+
"feature": "Status indication",
|
|
77
|
+
"implementation": "Status is shown with both color and text label for clarity",
|
|
78
|
+
"userRequirements": "Ensure status colors have sufficient contrast in both light and dark modes"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"feature": "Code readability",
|
|
82
|
+
"implementation": "Arguments and results are displayed in pre/code blocks with proper formatting",
|
|
83
|
+
"userRequirements": "Test JSON display with screen readers for complex nested structures"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"feature": "Structure",
|
|
87
|
+
"implementation": "Tool call information is organized in clear sections (header, arguments, result)",
|
|
88
|
+
"userRequirements": "Use semantic headings for screen reader navigation"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"contentGuidelines": [
|
|
92
|
+
{
|
|
93
|
+
"contentType": "Tool names",
|
|
94
|
+
"guidelines": [
|
|
95
|
+
"Use clear, descriptive tool names",
|
|
96
|
+
"Use snake_case or camelCase consistently",
|
|
97
|
+
"Names should indicate what the tool does",
|
|
98
|
+
"Avoid abbreviations unless universally understood",
|
|
99
|
+
"Prefix related tools with a common namespace"
|
|
100
|
+
],
|
|
101
|
+
"goodExamples": [
|
|
102
|
+
"search_database",
|
|
103
|
+
"calculate_expression",
|
|
104
|
+
"send_email",
|
|
105
|
+
"weather_api.get_current"
|
|
106
|
+
],
|
|
107
|
+
"badExamples": [
|
|
108
|
+
"tool1",
|
|
109
|
+
"proc",
|
|
110
|
+
"do_it",
|
|
111
|
+
"wthr.get"
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"contentType": "Status messages",
|
|
116
|
+
"guidelines": [
|
|
117
|
+
"Use standard status terminology (pending, running, completed, failed)",
|
|
118
|
+
"Be consistent with status labels across the application",
|
|
119
|
+
"For failed states, include error information when available",
|
|
120
|
+
"Use color coding to reinforce status meaning"
|
|
121
|
+
],
|
|
122
|
+
"goodExamples": [
|
|
123
|
+
"Completed",
|
|
124
|
+
"Failed: Timeout",
|
|
125
|
+
"Running",
|
|
126
|
+
"Pending"
|
|
127
|
+
],
|
|
128
|
+
"badExamples": [
|
|
129
|
+
"Done",
|
|
130
|
+
"Bad",
|
|
131
|
+
"Working",
|
|
132
|
+
"Waiting"
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
"compositionRules": [
|
|
137
|
+
{
|
|
138
|
+
"component": "Message",
|
|
139
|
+
"relationship": "ToolCall components are typically displayed within assistant messages to show tool usage",
|
|
140
|
+
"example": "Message component can contain ToolCall to show when the AI used tools during its response"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"component": "Reasoning",
|
|
144
|
+
"relationship": "Reasoning often precedes ToolCall to explain why a tool is being invoked",
|
|
145
|
+
"example": "Reasoning explains the decision to use a tool, ToolCall shows the actual invocation"
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
"relatedComponents": [
|
|
149
|
+
"Message",
|
|
150
|
+
"Reasoning",
|
|
151
|
+
"Conversation"
|
|
152
|
+
],
|
|
153
|
+
"package": "@slipstream-ui/ai",
|
|
154
|
+
"importPath": "@slipstream-ui/ai",
|
|
155
|
+
"version": "0.0.1",
|
|
156
|
+
"sourceDir": "tool-call",
|
|
157
|
+
"exportName": "ToolCall"
|
|
158
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare module 'jest-axe' {
|
|
2
|
+
export interface AxeResult {
|
|
3
|
+
violations: unknown[];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Run axe-core against rendered HTML or an element.
|
|
8
|
+
* Returns a promise compatible with the toHaveNoViolations matcher.
|
|
9
|
+
*/
|
|
10
|
+
export function axe(html: string | Element): Promise<AxeResult>;
|
|
11
|
+
|
|
12
|
+
/** Matcher extension object for expect(). */
|
|
13
|
+
export const toHaveNoViolations: {
|
|
14
|
+
toHaveNoViolations: () => { pass: boolean; message: () => string };
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
|
2
|
+
import * as jestAxe from 'jest-axe';
|
|
3
|
+
import { cleanup } from '@testing-library/react';
|
|
4
|
+
import { afterEach, beforeAll, expect, vi } from 'vitest';
|
|
5
|
+
|
|
6
|
+
expect.extend(jestAxe.toHaveNoViolations);
|
|
7
|
+
|
|
8
|
+
// jsdom does not implement scroll layout APIs used by auto-scrolling components.
|
|
9
|
+
beforeAll(() => {
|
|
10
|
+
Element.prototype.scrollIntoView = vi.fn();
|
|
11
|
+
// Container-scoped scrolling (Conversation) uses Element.scrollTo, which
|
|
12
|
+
// jsdom also lacks — without this mock the auto-scroll effect throws.
|
|
13
|
+
Element.prototype.scrollTo = vi.fn();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
cleanup();
|
|
18
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Component Types
|
|
3
|
+
*
|
|
4
|
+
* Shared types for AI interaction components like Message, Conversation, etc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type MessageRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
8
|
+
|
|
9
|
+
export type Message = {
|
|
10
|
+
id: string;
|
|
11
|
+
role: MessageRole;
|
|
12
|
+
content: string;
|
|
13
|
+
timestamp?: Date;
|
|
14
|
+
metadata?: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ToolCall = {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
arguments: Record<string, unknown>;
|
|
21
|
+
result?: string | number | boolean | Record<string, unknown> | unknown[];
|
|
22
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
23
|
+
/** Error detail rendered when status is failed. */
|
|
24
|
+
error?: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type ReasoningStep = {
|
|
28
|
+
id: string;
|
|
29
|
+
content: string;
|
|
30
|
+
timestamp?: Date;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/** A single citation or reference attached to an AI response. */
|
|
35
|
+
export type SourceItem = {
|
|
36
|
+
id: string;
|
|
37
|
+
title: string;
|
|
38
|
+
url?: string;
|
|
39
|
+
snippet?: string;
|
|
40
|
+
};
|
package/README.md
DELETED