create-theokit 1.0.15 → 1.0.17

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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: theokit-ui
3
- description: "@theokit/ui component library — chat UI (ChatThread, ChatMessage, ChatComposer, CodeBlock), theming, providers, sidebar"
3
+ description: "@theokit/ui AI-native component library — AI-agent surfaces (ChatThread, ChatMessage, ChatComposer, ToolCallCard, AgentStream), theming, providers; generic primitives (CodeBlock, Sidebar, Button) come from @usetheo/ui"
4
4
  user-invocable: false
5
5
  paths:
6
6
  - "app/**"
@@ -12,13 +12,13 @@ paths:
12
12
  - "**/*Theme*"
13
13
  ---
14
14
 
15
- # @theokit/ui — AI Chat Component Library
15
+ # @theokit/ui — AI-native Component Library (AI-agent surfaces)
16
16
 
17
- `@theokit/ui` is an optional peer dependency. If installed, it provides ready-made components for chat UIs, theming, and layout. **Never build custom equivalents** of components `@theokit/ui` provides.
17
+ `@theokit/ui` is an optional peer dependency. If installed, it provides ready-made AI components for chat + coding-agent surfaces (chat thread, agent events, tool calls, diff viewer, build logs), plus theming. **Never build custom equivalents** of components it provides. Generic primitives (Button, Input, Card, CodeBlock, PageShell, Sidebar, Avatar, Alert, etc.) live in `@usetheo/ui`, which `@theokit/ui` depends on — import those from `@usetheo/ui`.
18
18
 
19
19
  ## Package Identity
20
20
 
21
- The published package is `@theokit/ui` (NOT `@usetheo/ui` — that was the old name).
21
+ `@theokit/ui` (AI-native, currently `1.0.0`) provides the AI-agent-surface components. Its generic foundation was split into `@usetheo/ui` in the 2026-07-03 AI-exclusive pivot; `@theokit/ui` depends on `@usetheo/ui`, so installing `@theokit/ui` pulls the foundation transitively.
22
22
 
23
23
  ```bash
24
24
  # Install from npm (preferred)
@@ -54,19 +54,19 @@ export default function Layout({ children }) {
54
54
  ### Full Chat Page (typical assembly)
55
55
 
56
56
  ```typescript
57
+ // AI-agent-surface components live in @theokit/ui
57
58
  import {
58
- PageShell,
59
- Sidebar,
60
- SessionListItem,
61
59
  ChatThread,
62
60
  ChatMessage,
63
61
  ChatMessageContent,
64
62
  ChatComposer,
65
63
  } from '@theokit/ui'
66
- import { useAgentStream } from 'theokit/client'
64
+ // Generic layout primitives moved to @usetheo/ui (2026-07-03 pivot)
65
+ import { PageShell, Sidebar, SessionListItem } from '@usetheo/ui'
66
+ import { useAgent } from 'theokit/client'
67
67
 
68
68
  function ChatPage() {
69
- const { status, events, send } = useAgentStream('/api/agents/assistant')
69
+ const { messages, status, send } = useAgent('/api/agents/assistant')
70
70
 
71
71
  return (
72
72
  <PageShell sidebar={
@@ -77,9 +77,13 @@ function ChatPage() {
77
77
  </Sidebar>
78
78
  }>
79
79
  <ChatThread>
80
- {messages.map(m => (
81
- <ChatMessage key={m.id} role={m.role}>
82
- <ChatMessageContent markdown={m.content} />
80
+ {messages.map(message => (
81
+ <ChatMessage key={message.id} role={message.role}>
82
+ {message.parts.map((part, i) =>
83
+ part.type === 'text'
84
+ ? <ChatMessageContent key={i} markdown={part.text} />
85
+ : null
86
+ )}
83
87
  </ChatMessage>
84
88
  ))}
85
89
  </ChatThread>
@@ -93,29 +97,29 @@ function ChatPage() {
93
97
  }
94
98
  ```
95
99
 
96
- ### Individual Components
100
+ ### AI-agent-surface components (from `@theokit/ui`)
97
101
 
98
102
  | Component | Purpose | Key Props |
99
103
  |-----------|---------|-----------|
100
104
  | `ChatThread` | Scrollable message container | `children` (ChatMessage elements) |
101
105
  | `ChatMessage` | Single message bubble | `role: 'user' \| 'assistant'`, `children` |
102
106
  | `ChatMessageContent` | Markdown + code rendering | `markdown: string` (handles streaming partial) |
103
- | `CodeBlock` | Syntax-highlighted code | `code: string`, `language?: string` (uses shiki, lazy-loaded) |
104
107
  | `ChatComposer` | Message input + submit | `onSubmit: (text) => void`, `disabled?: boolean` |
105
- | `PageShell` | App layout with sidebar slot | `sidebar?: ReactNode`, `children` |
106
- | `Sidebar` | Collapsible side panel | `children` |
107
- | `SessionListItem` | Session entry in sidebar | `title: string`, `onClick`, `active?: boolean` |
108
+ | `ToolCallCard` | Display agent tool invocations | — |
109
+ | `AgentStream` | Lower-level stream renderer | — |
108
110
 
109
- ### Other Useful Components
111
+ ### Generic primitives (from `@usetheo/ui`)
110
112
 
111
- | Component | Purpose |
112
- |-----------|---------|
113
- | `Button`, `Input`, `Textarea` | Form primitives (themed) |
114
- | `ToolCallCard` | Display agent tool invocations |
115
- | `AgentStream` | Lower-level stream renderer |
116
- | `ThemeSwitcher` | Light/dark mode toggle |
117
- | `Avatar` | User/agent avatar |
118
- | `Alert` | Status messages |
113
+ Moved out of `@theokit/ui` in the 2026-07-03 AI-exclusive pivot. Import these from `@usetheo/ui`.
114
+
115
+ | Component | Purpose | Key Props |
116
+ |-----------|---------|-----------|
117
+ | `CodeBlock` | Syntax-highlighted code | `code: string`, `language?: string` (uses shiki, lazy-loaded) |
118
+ | `PageShell` | App layout with sidebar slot | `sidebar?: ReactNode`, `children` |
119
+ | `Sidebar` | Collapsible side panel | `children` |
120
+ | `Button`, `Input`, `Textarea` | Form primitives (themed) | — |
121
+ | `Avatar` | User/agent avatar | — |
122
+ | `Alert` | Status messages | — |
119
123
 
120
124
  ## Peer Dependencies (install only what you use)
121
125
 
@@ -154,8 +158,8 @@ const myTheme = defineTheme({
154
158
 
155
159
  - NEVER build a custom chat message component — use `ChatMessage` + `ChatMessageContent`
156
160
  - NEVER build a custom markdown renderer — `ChatMessageContent` handles it (including streaming partial fences)
157
- - NEVER build a custom code highlighter — `CodeBlock` uses shiki (lazy-loaded)
158
- - NEVER import from `@usetheo/ui` — that's the deprecated package name; use `@theokit/ui`
161
+ - NEVER build a custom code highlighter — `CodeBlock` (from `@usetheo/ui`) uses shiki (lazy-loaded)
162
+ - Import AI-agent-surface components (ChatThread, ChatMessage, ToolCallCard, etc.) from `@theokit/ui`; import generic primitives (Button, Input, CodeBlock, PageShell, Sidebar, Avatar, Alert) from `@usetheo/ui` — both are live packages since the 2026-07-03 pivot (`@theokit/ui` depends on `@usetheo/ui`)
159
163
  - NEVER use `npm link` or `file:../theo-ui` to install — causes dual-React (use tarball or npm registry)
160
164
  - NEVER install ALL peer deps — only install the peers for components you actually use
161
165
  - NEVER use components without wrapping in `TheoUIProvider` + `ThemeProvider` first
@@ -15,9 +15,11 @@
15
15
  "typecheck": "tsc --noEmit"
16
16
  },
17
17
  "dependencies": {
18
- "theokit": "^0.6.0",
19
- "@theokit/sdk": "^1.1.0",
20
- "@theokit/ui": "^0.14.0",
18
+ "theokit": "^0.15.2",
19
+ "@theokit/agents": "^0.30.2",
20
+ "@theokit/sdk": "^2.13.0",
21
+ "@theokit/ui": "^1.0.0",
22
+ "@usetheo/ui": "^0.14.0",
21
23
  "lucide-react": "^0.469.0",
22
24
  "react": "^19.0.0",
23
25
  "react-dom": "^19.0.0",
@@ -25,8 +27,11 @@
25
27
  "zod": "^4.0.0"
26
28
  },
27
29
  "devDependencies": {
30
+ "@testing-library/react": "^16.0.0",
31
+ "@types/node": "^22.0.0",
28
32
  "@types/react": "^19.0.0",
29
33
  "@types/react-dom": "^19.0.0",
34
+ "jsdom": "^25.0.0",
30
35
  "tailwindcss": "^4.0.0",
31
36
  "@tailwindcss/vite": "^4.0.0",
32
37
  "eslint": "^9.0.0",
@@ -37,6 +42,10 @@
37
42
  "vitest": "^3.0.0"
38
43
  },
39
44
  "pnpm": {
40
- "onlyBuiltDependencies": ["esbuild", "better-sqlite3", "workerd"]
45
+ "onlyBuiltDependencies": [
46
+ "esbuild",
47
+ "better-sqlite3",
48
+ "workerd"
49
+ ]
41
50
  }
42
51
  }
@@ -9,7 +9,9 @@
9
9
  "skipLibCheck": true,
10
10
  "jsx": "react-jsx",
11
11
  "isolatedModules": true,
12
- "resolveJsonModule": true
12
+ "resolveJsonModule": true,
13
+ "experimentalDecorators": true,
14
+ "emitDecoratorMetadata": true
13
15
  },
14
- "include": ["app/**/*.ts", "app/**/*.tsx", "server/**/*.ts"]
16
+ "include": ["app/**/*.ts", "app/**/*.tsx", "server/**/*.ts", "agents/**/*.ts"]
15
17
  }
@@ -1,69 +0,0 @@
1
- import { z } from 'zod'
2
- import {
3
- defineAgentEndpoint,
4
- defineAgentTool,
5
- streamAgentRun,
6
- createConversationHistory,
7
- type AgentEvent,
8
- } from 'theokit/server'
9
-
10
- /**
11
- * Chat agent endpoint — persistent conversation via createConversationHistory.
12
- *
13
- * Each browser tab gets a stable conversation id cookie on first visit;
14
- * subsequent requests resume the same agent. Conversation turns auto-persist
15
- * in `<cwd>/.theokit/agents/<conversationId>/messages.jsonl` (SDK owns
16
- * storage). Tools: current_time example. Memory facts: opt-in via
17
- * options.memory (off by default).
18
- *
19
- * Provider: OPENROUTER_API_KEY (preferred — gateway to many models) OR
20
- * ANTHROPIC_API_KEY (direct Anthropic).
21
- */
22
-
23
- const currentTime = defineAgentTool({
24
- name: 'current_time',
25
- description: 'Get the current ISO timestamp on the server.',
26
- inputSchema: z.object({}),
27
- handler: () => new Date().toISOString(),
28
- })
29
-
30
- export const POST = defineAgentEndpoint({
31
- async *handler({ body, request, cookieHeaders, signal }): AsyncGenerator<AgentEvent> {
32
- const safeBody =
33
- body !== null && typeof body === 'object' && !Array.isArray(body)
34
- ? (body as { message?: string })
35
- : {}
36
- const { message = '' } = safeBody
37
- // Provider resolution centralizada (Strategy pattern) — theokit/server resolve
38
- // apiKey + baseUrl + provider automático via OPENROUTER_API_KEY / OPENAI_API_KEY /
39
- // ANTHROPIC_API_KEY presente no env. Wire protocol: OpenAI Chat Completions
40
- // (universal — todos os providers implementam essa API). Consumer NÃO tem
41
- // conditionals sobre provider — é responsabilidade do framework.
42
- // Wrap full agent lifecycle in try/catch — provider errors (invalid KEY,
43
- // 401, rate-limit, model-not-found, 5xx) MUST surface as AgentEvent
44
- // 'error' so the client renders an actionable message instead of a
45
- // silent SSE closure. Dogfood chaos Phase 12 validates this contract.
46
- try {
47
- const { agent } = await createConversationHistory({
48
- request,
49
- response: { headers: cookieHeaders },
50
- options: {
51
- // Model id is prefixed with the provider namespace. When using
52
- // OPENROUTER_API_KEY (default), prefixes route to the correct
53
- // upstream — `openai/`, `anthropic/`, `google/`, `meta-llama/`,
54
- // `mistralai/`, `groq/`, etc. See https://openrouter.ai/models.
55
- // Without the prefix the SDK falls back to a stub response.
56
- model: { id: 'openai/gpt-4o-mini' },
57
- tools: [currentTime],
58
- },
59
- })
60
- const run = await agent.send(message, { signal })
61
- yield* streamAgentRun(run)
62
- // Intentionally NO agent.dispose() — the agent stays registered so the
63
- // next request from the same conversation resumes it (continuity).
64
- } catch (err) {
65
- const msg = err instanceof Error ? err.message : String(err)
66
- yield { type: 'error', message: `Agent error: ${msg}` }
67
- }
68
- },
69
- })