create-gentiq-app 1.0.0-beta.2 → 1.0.0-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-gentiq-app",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "license": "Apache-2.0",
5
5
  "description": "CLI to scaffold a new Gentiq application",
6
6
  "type": "module",
@@ -1,15 +1,19 @@
1
1
  # Gentiq App
2
2
 
3
- A conversational AI application built with [Gentiq](https://github.com/arxyzan/gentiq): a FastAPI + Pydantic AI backend and a React frontend, with authentication, streaming, chat history, an admin panel and per-user usage limits wired together.
3
+ A conversational AI application built with [Gentiq](https://github.com/arxyzan/gentiq): a FastAPI + Pydantic AI backend and a React frontend, with authentication, streaming, chat history, an admin panel, and optional subsystems wired together.
4
4
 
5
5
  ## What you get
6
6
 
7
- - **Streaming chat**: Pydantic AI on the backend, the Vercel AI SDK UI message stream on the wire.
8
- - **Admin panel** at `/admin`: users and their plans, chat history, analytics, and maintenance jobs.
9
- - **Usage and cost tracking**: per-user plans or credits, or no limit at all. Each turn is priced per model from the `genai-prices` rate data that ships with Pydantic AI.
10
- - **Persistence**: SQLite and the local filesystem by default; MongoDB and MinIO/S3 when you switch engines.
11
- - **Auth**: sign-up and login with JWTs, argon2id password hashing, and permission-based admin accounts.
12
- - **i18n and RTL**: Gentiq's UI ships in 13 languages, including the right-to-left Arabic, Persian and Urdu. `i18n.resources` in `src/options.ts` holds this app's own strings, in English and Persian.
7
+ - **Streaming chat**: Pydantic AI on the backend, the Vercel AI SDK UI message stream on the wire, with support for quoting earlier messages (`references`), file attachments, reasoning display, and live progress updates.
8
+ - **Admin panel** at `/admin`: users and their plans, chat history (including sub-agent transcripts, model instructions, and injected memories), analytics, user feedback, branding icons, status/watchdog, and maintenance jobs.
9
+ - **Chat modes & capabilities** (opt-in): switch models/profiles (`ChatMode`: e.g. Fast vs Deep) from the composer's trailing selector, and toggle overlays (`Capability`: e.g. Web Search, Deep Research, Thinking level, Temporary chat) from the `+` menu.
10
+ - **Cross-conversation memory** (opt-in via `Memory`): injects durable user facts in `<user_memories>`, provides `remember`/`recall`/`forget`/`search_past_chats` tools, extracts facts in the background, and adds `Settings → Memory` plus a per-thread/per-turn `Temporary chat (memory off)` toggle.
11
+ - **External connectors & MCP** (opt-in via `Connectors`): connect per-user Python toolsets, remote MCP servers, admin-managed MCP servers, or user-added HTTPS MCP servers with `@connector` composer mentions and write-approval policies.
12
+ - **Scheduled tasks** (opt-in via `Schedules`): recurring (`cron` / `interval`) and one-time (`once`) agent routines managed in `Settings → Scheduled` or by the agent itself.
13
+ - **Usage, billing & feature gating** (opt-in via `Billing`): per-user plans, credits, or unlimited usage; each turn is priced per model from the `genai-prices` rate data that ships with Pydantic AI, and modes/capabilities/tools can be gated per plan (`Feature`).
14
+ - **Voice, maintenance jobs & ops**: optional microphone dictation (`Voice`), admin-triggered Python jobs (`Jobs`), and Prometheus metrics + maintenance mode (`Ops`).
15
+ - **Persistence & auth**: SQLite and the local filesystem by default (MongoDB and MinIO/S3 for production); sign-up and login with JWTs, argon2id password hashing, and permission-based admin accounts.
16
+ - **i18n and RTL**: Gentiq's UI ships in 13 languages, including right-to-left Arabic, Persian, and Urdu. `i18n.resources` in `src/options.ts` holds this app's own strings, in English and Persian.
13
17
 
14
18
  ---
15
19
 
@@ -76,13 +80,13 @@ Visit `http://localhost:5173/admin`. On a fresh database the panel shows a one-t
76
80
 
77
81
  ```text
78
82
  ├── backend/
79
- │ ├── main.py # Agent, tools, and the GentiqApp that serves them
83
+ │ ├── main.py # Agent, tools, optional plugins, and GentiqApp
80
84
  │ ├── .env # Your secrets and provider keys; gitignored
81
85
  │ ├── .env.example # Template for the above
82
86
  │ └── pyproject.toml # Python dependencies (uv)
83
87
  ├── frontend/
84
88
  │ ├── src/App.tsx # The app: GentiqChatApp, pointed at /api, with the admin panel
85
- │ ├── src/options.ts # How it looks and behaves: name, theme, texts, sidebar, settings
89
+ │ ├── src/options.ts # Name, theme, texts, sidebar, composer overrides, settings, slots
86
90
  │ ├── src/theme.css # Gentiq's colors, radius and type, as --gentiq-* tokens
87
91
  │ ├── src/index.css # The page's own styles
88
92
  │ ├── vite.config.ts # Dev server, proxying /api to the backend
@@ -92,13 +96,16 @@ Visit `http://localhost:5173/admin`. On a fresh database the panel shows a one-t
92
96
 
93
97
  ---
94
98
 
95
- ## Where to make changes
99
+ ## Feature guide
96
100
 
97
- **Add a tool**: `backend/main.py`. Tools receive `RunContext[AgentDeps[AppContext]]`, so `ctx.deps` gives you the authenticated user, your own `AppContext`, the user's own threads (`ctx.deps.threads`), and `ctx.deps.stream(...)` for pushing progress events to the UI mid-call. `list_my_chats` is the worked example: it reads a limit from `AppContext`, lists the signed-in user's threads with `ctx.deps.threads.list(...)`, and sends progress events before and after.
101
+ Both `backend/main.py` and `frontend/src/options.ts` include commented sections you can uncomment as your app grows. Here is what each piece unlocks.
98
102
 
99
- Return only the fields the model needs. Store methods are written for the API layer, and some, `list_user_threads` among them, include the owner's contact details and metadata, none of which belongs in a prompt.
103
+ ### Tools, approvals, custom parts & sub-agents
100
104
 
101
- **Render a tool's result yourself**: `components.parts`, an option of `GentiqChatApp` (add it to `src/options.ts`), maps `tool-<name>` to a React component, which renders in place of Gentiq's generic tool card. Tools without an entry keep the generic card.
105
+ - **Tools (`backend/main.py`)**: Tools receive `RunContext[AgentDeps[AppContext]]`, giving you the authenticated user (`ctx.deps.user`), your `AppContext` (`ctx.deps.context`), the user's own threads (`ctx.deps.threads`), `ctx.deps.stream(...)` for `ProgressUpdateEvent`s, and `ctx.deps.emit(name, payload)` for custom `data-<name>` UI parts. `list_my_chats` is the worked example. Return only the fields the model needs.
106
+ - **Tool approval**: Decorate sensitive tools with `@agent.tool(requires_approval=True)` (or `@agent.tool_plain(requires_approval=True)`). The chat pauses and asks the user to approve or deny the call before it executes.
107
+ - **Sub-agent capture**: Wrap helper agent calls in `async with ctx.deps.capture_subagents(ctx):` to record their transcripts and token costs into the thread for the admin panel (hidden from end users).
108
+ - **Render a tool's result or custom data part yourself**: Map `tool-<name>` (with `defineToolUI`) or `data-<name>` (with `defineDataUI`) under `components.parts` in `frontend/src/options.ts`:
102
109
 
103
110
  ```tsx
104
111
  import { defineToolUI } from '@gentiq/react'
@@ -127,9 +134,113 @@ export function App() {
127
134
  }
128
135
  ```
129
136
 
130
- Gentiq wraps custom part components in an error boundary, so let render errors propagate; a `try`/`catch` around JSX wouldn't catch them anyway.
137
+ Gentiq wraps custom part components in an error boundary, so let render errors propagate.
131
138
 
132
- **Extend the user profile**: `app.userMetadataFields` declares extra profile fields, each persisted on `user.metadata`. A field appears on the signup form with `showInSignup: true` and in profile settings with `showInProfile: true`. Listing it under `settings.sections.profile.fields` sets how it is displayed there (`'editable'`, `'faded'` or `'hidden'`). Labels are i18n keys, so define them in `i18n.resources`.
139
+ ### Chat modes & run capabilities
140
+
141
+ Declare mutually exclusive `ChatMode`s (such as Fast vs Deep, each with its own agent/model or run policy) and toggleable `Capability` overlays (such as Web Search, Deep Research, or Thinking level) on `ChatConfig` in `backend/main.py`:
142
+
143
+ ```python
144
+ from gentiq import AgentDeps, Capability, ChatConfig, ChatMode, GentiqApp, requires_capability
145
+ from pydantic_ai import Agent, RunContext
146
+ from pydantic_ai.capabilities import WebSearch
147
+
148
+ fast_agent = Agent("openai:gpt-5-nano", deps_type=AgentDeps[None])
149
+ deep_agent = Agent("openai:gpt-5.1", deps_type=AgentDeps[None])
150
+
151
+ @deep_agent.tool(prepare=requires_capability("deep_research"))
152
+ def research_outline(ctx: RunContext[AgentDeps[None]], topic: str) -> dict:
153
+ return {"topic": topic}
154
+
155
+ app = GentiqApp(
156
+ deep_agent,
157
+ chat=ChatConfig(
158
+ modes=[
159
+ ChatMode(key="fast", name="Fast", icon="zap", agent=fast_agent, default=True),
160
+ ChatMode(key="deep", name="Deep", icon="sparkles", agent=deep_agent, show_reasoning=True),
161
+ ],
162
+ capabilities=[
163
+ Capability(
164
+ key="search",
165
+ name="Web Search",
166
+ icon="search",
167
+ agent_capabilities=(WebSearch(),),
168
+ ),
169
+ Capability(
170
+ key="deep_research",
171
+ name="Deep Research",
172
+ icon="compass",
173
+ exclusive_group="workflow",
174
+ implies=("search",),
175
+ instructions="Decompose the question into sub-questions before searching.",
176
+ ),
177
+ ],
178
+ ),
179
+ )
180
+ ```
181
+
182
+ The frontend renders modes and capabilities automatically from `/api/config`. Use `composer.modes` and `composer.capabilities` in `frontend/src/options.ts` to customize icons, labels, groups, or hide controls, and `components.ModeSelector` / `components.ComposerChip` to replace their UI.
183
+
184
+ ### Persistent cross-conversation memory (`Memory`)
185
+
186
+ Add `Memory` to `plugins=[...]` in `backend/main.py` to give users persistent cross-conversation memory (`<user_memories>` injection, `remember`/`recall`/`forget`/`search_past_chats` tools, background fact extraction, `Settings → Memory`, and the composer `+` menu's `Temporary chat (memory off)` toggle):
187
+
188
+ ```python
189
+ from gentiq import AgentDeps, GentiqApp
190
+ from gentiq.memory import Memory
191
+ from pydantic_ai import Agent
192
+
193
+ agent = Agent("openai:gpt-5.1", deps_type=AgentDeps[None])
194
+ app = GentiqApp(
195
+ agent,
196
+ plugins=[Memory(memory_model="gpt-5-nano", auto_extract=True, include_chat_history=True)],
197
+ )
198
+ ```
199
+
200
+ Set `sidebar.showMemory: true` in `frontend/src/options.ts` if you also want a direct `Memory` shortcut in the sidebar.
201
+
202
+ ### External connectors & MCP (`Connectors`)
203
+
204
+ Add `Connectors` to `plugins=[...]` in `backend/main.py` to expose per-user Python toolsets (`PythonConnector`), remote MCP servers (`MCPConnector`), admin-configured MCP servers, and optional user-added HTTPS MCP servers (`allow_user_mcp=True`):
205
+
206
+ ```python
207
+ from gentiq import AgentDeps, GentiqApp
208
+ from gentiq.connectors import ApiKeyAuth, Connectors, MCPConnector
209
+ from pydantic_ai import Agent
210
+
211
+ agent = Agent("openai:gpt-5.1", deps_type=AgentDeps[None])
212
+ app = GentiqApp(
213
+ agent,
214
+ plugins=[
215
+ Connectors(
216
+ connectors=[
217
+ MCPConnector(
218
+ key="linear",
219
+ name="Linear",
220
+ description="Search and manage Linear issues.",
221
+ url="https://mcp.linear.app/mcp",
222
+ auth=ApiKeyAuth(instructions="Paste your Linear API token."),
223
+ )
224
+ ],
225
+ allow_user_mcp=True,
226
+ )
227
+ ],
228
+ )
229
+ ```
230
+
231
+ Set `ENCRYPTION_KEY` in `backend/.env` before deploying to production so stored user API keys and OAuth tokens are encrypted with a dedicated Fernet key.
232
+
233
+ ### Scheduled tasks, billing, voice & interactive chat
234
+
235
+ - **Scheduled routines**: pass `Schedules()` from `gentiq.schedules` in `plugins=[...]` to enable `Settings → Scheduled` and conversational scheduling tools.
236
+ - **Plans, credits & feature gating**: pass `Billing(...)` from `gentiq.billing` in `plugins=[...]` to enforce per-plan limits (`messages`, `tokens`, `cost`) and gate `ChatMode`, `Capability`, `Voice`, or custom tools (`requires_feature(...)`) behind plans.
237
+ - **Voice input**: pass `Voice(OpenAITranscriber("gpt-transcribe"))` from `gentiq.voice` (or `GeminiTranscriber`) to enable the composer's microphone button.
238
+ - **Interactive UX (`ChatConfig`)**: pass `ask_user=True` (multiple-choice buttons mid-turn), `follow_up_suggestions=True` (clickable follow-up chips), and `progress_updates=True` (model-driven `<progress>...</progress>` live status notes).
239
+ - **Maintenance jobs**: pass `Jobs()` from `gentiq.jobs` and register `@jobs.job(...)` handlers runnable from `Admin → Operations`.
240
+
241
+ ### Extend the user profile
242
+
243
+ `app.userMetadataFields` in `frontend/src/options.ts` declares extra profile fields, each persisted on `user.metadata`. A field appears on the signup form with `showInSignup: true` and in profile settings with `showInProfile: true`. Listing it under `settings.sections.profile.fields` sets how it is displayed there (`'editable'`, `'faded'` or `'hidden'`). Labels are i18n keys, so define them in `i18n.resources`.
133
244
 
134
245
  ```tsx
135
246
  import { GentiqChatApp } from '@gentiq/ui'
@@ -173,15 +284,19 @@ export function App() {
173
284
 
174
285
  A field can also depend on another field's value (`condition`); the `dev` template in the Gentiq repository shows that and more of the configuration.
175
286
 
176
- **Add your own API routes**: `app.add_router(...)` in `main.py`. Depend on `get_current_user` to put a route behind the same JWT auth the chat endpoints use.
287
+ ### Add your own API routes
288
+
289
+ Use `app.add_router(...)` in `backend/main.py`. Depend on `get_current_user` to put a route behind the same JWT auth the chat endpoints use.
290
+
291
+ ### Go to production
177
292
 
178
- **Go to production**: switch `StorageConfig` in `main.py` to `StorageConfig(db="mongodb", files="minio")`, fill in the matching variables in `.env` (and set `MINIO_SECURE=true` over TLS), and set strong secrets. Gentiq installs no CORS middleware unless you pass `cors=CORSConfig(...)`. The template passes `CORSConfig(allow_origins=["http://localhost:5173"])`; replace that with the origins your frontend is served from if it is not same-origin with the API.
293
+ Switch `StorageConfig` in `backend/main.py` to `StorageConfig(db="mongodb", files="minio")`, fill in the matching variables in `.env` (including `ENCRYPTION_KEY` if using `Connectors`, and `MINIO_SECURE=true` over TLS), and set strong secrets. Gentiq installs no CORS middleware unless you pass `cors=CORSConfig(...)`. The template passes `CORSConfig(allow_origins=["http://localhost:5173"])`; replace that with the origins your frontend is served from if it is not same-origin with the API.
179
294
 
180
295
  ---
181
296
 
182
297
  ## Learn more
183
298
 
184
- - [Gentiq](https://github.com/arxyzan/gentiq): framework docs and the `dev` template, which uses more of the configuration
299
+ - [Gentiq](https://github.com/arxyzan/gentiq): framework docs and the `dev` template, which enables most plugins together
185
300
  - [Pydantic AI](https://ai.pydantic.dev/): building agents
186
301
  - [Vercel AI SDK](https://ai-sdk.dev/): the streaming protocol the UI speaks
187
302
 
@@ -11,6 +11,9 @@ __pycache__/
11
11
 
12
12
  # Local persistence written by the sqlite / filesystem engines
13
13
  *.db
14
+ *.db-wal
15
+ *.db-shm
16
+ *.db-journal
14
17
  .storage/
15
18
 
16
19
  # Node
@@ -1,6 +1,6 @@
1
1
  # Backend
2
2
 
3
- The FastAPI + [Pydantic AI](https://ai.pydantic.dev/) half of the application. `main.py` defines an agent, its tools and its context; `GentiqApp` serves them as an API with auth, chat streaming, history, attachments, plans and usage limits, and the admin endpoints.
3
+ The FastAPI + [Pydantic AI](https://ai.pydantic.dev/) half of the application. `main.py` defines an agent, its tools, and its context; `GentiqApp` serves them as an API with auth, chat streaming, history, attachments, usage pricing, and optional subsystems.
4
4
 
5
5
  ## Run it
6
6
 
@@ -20,18 +20,30 @@ uv run uvicorn main:app.api --reload --port 8000
20
20
  | --- | --- |
21
21
  | `AppContext` | Your own state, passed as `context=` to `GentiqApp` and reachable in every tool as `ctx.deps.context`. Any dataclass or Pydantic model. |
22
22
  | `Agent[AgentDeps[AppContext]]` | A normal Pydantic AI agent, typed so Gentiq can inject its dependencies. |
23
- | `@agent.tool` | Tools. `ctx.deps` carries the authenticated user, your context, the user's own threads (`ctx.deps.threads`), and `ctx.deps.stream(...)` for pushing `ProgressUpdateEvent`s to the UI while the tool runs. |
23
+ | `@agent.tool` | Tools. `ctx.deps` carries the authenticated user, your context, the user's own threads (`ctx.deps.threads`), `ctx.deps.stream(...)` for `ProgressUpdateEvent`s, and `ctx.deps.emit(...)` for custom `data-*` UI parts. |
24
24
  | `@agent.instructions` | Instructions computed per run. The template uses it to tell the model the user's name. |
25
- | `GentiqApp(...)` | Sets up persistence, file storage, JWT auth, the admin API, thread titles and usage pricing. |
25
+ | `GentiqApp(...)` | Sets up persistence, file storage, JWT auth, thread titles, usage pricing, and plugins (`AdminAPI` and `Ops` by default). |
26
26
  | `app.add_router(...)` | Your own routes, sharing Gentiq's auth through `Depends(get_current_user)`. |
27
27
 
28
28
  ## Configuration worth knowing
29
29
 
30
+ `main.py` contains ready-to-uncomment blocks for the features below:
31
+
30
32
  - **`storage=StorageConfig(db=..., files=...)`**: `"sqlite"` and `"filesystem"` by default, which need no services. Switch to `"mongodb"` and `"minio"` for production and fill in the matching `.env` variables. Both also accept a `DBEngine` / `StorageEngine` instance.
31
33
  - **`cors`**: no CORS middleware is installed unless you pass `CORSConfig(allow_origins=[...])`. In development the Vite dev server proxies `/api`, so the browser talks to one origin; you need this only when the frontend is served from another origin. The template passes `http://localhost:5173`.
32
- - **`chat=ChatConfig(title_agent=...)`**: the model that names threads. The template passes `create_title_agent(model_name="gpt-5-nano")`; leave it out and threads get no generated titles.
33
- - **`auth=AuthConfig(login_fields=...)`** (not set in the template): which of `username`, `email` and `phone` can be used to sign in. Defaults to the `LOGIN_FIELDS` env var, then `["username"]`. Enabled fields are unique; the rest are ordinary profile data.
34
- - **`ChatConfig(ask_user=...)`** (not set in the template): gives the agent Gentiq's `ask_user` tool, a multiple-choice question mid-conversation rendered as buttons; the turn carries on with the answer. Off by default. `True` uses Gentiq's default policy on when to ask; a string is your own policy instead.
35
- - **`plugins`**: optional subsystems, none by default. `Voice(transcriber)` from `gentiq.voice` adds voice input to the composer; `Jobs()` from `gentiq.jobs` adds maintenance jobs that admins run from the admin panel's Operations tab, registered with `@jobs.job(...)`.
34
+ - **`chat=ChatConfig(...)`**:
35
+ - `title_agent`: the model that names threads (`create_title_agent(model_name="gpt-5-nano")`).
36
+ - `modes` & `capabilities`: declare `ChatMode` profiles (e.g. Fast vs Deep with separate agents/models/policies) and toggleable `Capability` overlays (e.g. `WebSearch()`, `Thinking()`, Deep Research, gated tools via `requires_mode` / `requires_capability`).
37
+ - `ask_user`: gives the agent Gentiq's `ask_user` multiple-choice tool rendered as buttons (`True` or a custom policy string).
38
+ - `follow_up_suggestions`: clickable follow-up suggestion chips under replies.
39
+ - `progress_updates`: model-driven live status updates wrapped in `<progress>...</progress>` tags.
40
+ - **`auth=AuthConfig(login_fields=...)`** (commented in `main.py`): which of `username`, `email` and `phone` can be used to sign in. Defaults to the `LOGIN_FIELDS` env var, then `["username"]`. Enabled fields are unique; the rest are ordinary profile data.
41
+ - **`plugins`**: `main.py` enables `AdminAPI()` (`/api/admin`) and `Ops()` (`/metrics`, watchdog, maintenance mode). Add any of these optional plugins from `gentiq.*`:
42
+ - `Memory(...)` (`gentiq.memory`): cross-conversation `<user_memories>` injection, `remember`/`recall`/`forget`/`search_past_chats` tools, background extraction, `Settings → Memory`, and `Temporary chat (memory off)` in the composer `+` menu.
43
+ - `Connectors(...)` (`gentiq.connectors`): per-user `PythonConnector` toolsets, remote `MCPConnector` servers, admin-managed MCP servers, and optional user-added HTTPS MCP servers (`allow_user_mcp=True`). Set `ENCRYPTION_KEY` in `.env` for production.
44
+ - `Schedules(...)` (`gentiq.schedules`): recurring (`cron` / `interval`) and one-time (`once`) agent routines.
45
+ - `Billing(...)` (`gentiq.billing`): plans, credits, calendar-aligned quotas, and `Feature` gating across modes, capabilities, voice, and tools (`requires_feature`).
46
+ - `Voice(transcriber)` (`gentiq.voice`): voice dictation in the composer (`OpenAITranscriber` or `GeminiTranscriber`).
47
+ - `Jobs()` (`gentiq.jobs`): maintenance jobs triggered from `Admin → Operations`, registered with `@jobs.job(...)`.
36
48
 
37
49
  Usage is priced per model from the `genai-prices` rate data bundled with Pydantic AI. Pass `ChatConfig(usage_pricing=UsagePricing(...))` only to override specific rates.
@@ -43,8 +43,8 @@ You are a helpful AI assistant.
43
43
  agent = Agent[AgentDeps[AppContext]](name="agent", instructions=instructions, model="openai:gpt-5.1")
44
44
 
45
45
 
46
- # 3. Add custom tools. `ctx.deps` carries your context, the authenticated user
47
- # and their own threads; `ctx.deps.stream` pushes progress to the UI mid-call.
46
+ # 3. Add custom tools. `ctx.deps` carries your context, the authenticated user,
47
+ # their own threads (`ctx.deps.threads`), and `ctx.deps.stream` / `ctx.deps.emit`.
48
48
  @agent.tool
49
49
  async def list_my_chats(ctx: RunContext[AgentDeps[AppContext]]) -> dict:
50
50
  """List the titles of the user's recent chat threads."""
@@ -76,7 +76,27 @@ async def list_my_chats(ctx: RunContext[AgentDeps[AppContext]]) -> dict:
76
76
  }
77
77
 
78
78
 
79
- # 4. Add user's info in the instructions
79
+ # More tool & agent patterns you can add here:
80
+ #
81
+ # - Approval before running a sensitive tool (renders Approve / Deny buttons in chat):
82
+ # @agent.tool_plain(requires_approval=True)
83
+ # def delete_item(item_id: str) -> str:
84
+ # return f"Deleted {item_id}"
85
+ #
86
+ # - Capability- or mode-gated tools (hidden unless active on the turn):
87
+ # from gentiq import requires_capability, requires_mode
88
+ # @agent.tool(prepare=requires_capability("deep_research"))
89
+ # async def research_outline(ctx: RunContext[AgentDeps[AppContext]], topic: str) -> dict: ...
90
+ #
91
+ # - Custom UI data parts (streamed as `data-<name>`, rendered via `components.parts` in frontend):
92
+ # await ctx.deps.emit("chart", {"title": "Weekly activity", "points": [12, 18, 15]})
93
+ #
94
+ # - Sub-agent transcript & usage capture (recorded for Admin > Chats, hidden from end users):
95
+ # async with ctx.deps.capture_subagents(ctx):
96
+ # result = await helper_agent.run("...", deps=ctx.deps)
97
+
98
+
99
+ # 4. Add per-run instructions (recomputed every turn)
80
100
  @agent.instructions
81
101
  def add_user_info(ctx: RunContext[AgentDeps[AppContext]]) -> str | None:
82
102
  user_info = "Here's additional info about the current user you're talking to:\n"
@@ -84,26 +104,154 @@ def add_user_info(ctx: RunContext[AgentDeps[AppContext]]) -> str | None:
84
104
  return user_info
85
105
 
86
106
 
87
- # 5. Initialize the core backend framework application with the agent and its context
88
- # The framework automatically injects internal Stores into AgentDeps
107
+ # 5. Optional subsystems — uncomment any feature or plugin below to enable it.
108
+ #
109
+ # --- Chat Modes & Run Capabilities ------------------------------------------
110
+ # Modes switch between distinct agents/models/policies (e.g. Fast vs Deep) in the
111
+ # composer's trailing selector. Capabilities are toggleable overlays in the `+` menu
112
+ # (or inside the mode selector with `menu="mode"`).
113
+ #
114
+ # from pydantic_ai.capabilities import Thinking, WebSearch
115
+ # from gentiq import Capability, ChatMode, Feature
116
+ #
117
+ # fast_agent = Agent[AgentDeps[AppContext]](
118
+ # name="fast_agent",
119
+ # instructions=[instructions, "Keep answers concise and direct."],
120
+ # model="openai:gpt-5-nano",
121
+ # )
122
+ # chat_modes = [
123
+ # ChatMode(key="fast", name="Fast", icon="zap", agent=fast_agent, default=True, sticky="thread"),
124
+ # ChatMode(
125
+ # key="deep",
126
+ # name="Deep",
127
+ # description="Higher-reasoning model for complex tasks.",
128
+ # icon="sparkles",
129
+ # agent=agent,
130
+ # show_reasoning=True,
131
+ # sticky="thread",
132
+ # # feature=Feature(key="deep_mode", name="Deep Mode"), # gate behind a Billing plan
133
+ # ),
134
+ # ]
135
+ # chat_capabilities = [
136
+ # Capability(
137
+ # key="search",
138
+ # name="Web Search",
139
+ # description="Search live web sources.",
140
+ # icon="search",
141
+ # default=False,
142
+ # sticky="thread",
143
+ # chip="when_active",
144
+ # agent_capabilities=(WebSearch(),),
145
+ # ),
146
+ # Capability(
147
+ # key="deep_research",
148
+ # name="Deep Research",
149
+ # description="Multi-step research across sources.",
150
+ # icon="compass",
151
+ # placeholder="Ask a complex question...",
152
+ # exclusive_group="workflow",
153
+ # implies=("search",),
154
+ # instructions="Decompose the question into sub-questions, search, and synthesize.",
155
+ # ),
156
+ # Capability(
157
+ # key="thinking_high",
158
+ # name="High",
159
+ # menu="mode",
160
+ # group="Thinking level",
161
+ # exclusive_group="thinking_level",
162
+ # agent_capabilities=(Thinking("high"),),
163
+ # ),
164
+ # ]
165
+ #
166
+ # --- Persistent Cross-Conversation Memory -----------------------------------
167
+ # Injects durable facts in `<user_memories>`, gives the agent `remember`, `recall`,
168
+ # `forget` (and `search_past_chats`), extracts facts in the background, and adds
169
+ # Settings -> Memory + the composer `+` menu's `Temporary chat (memory off)` toggle.
170
+ #
171
+ # from gentiq.memory import Memory
172
+ # memory_plugin = Memory(
173
+ # memory_model="gpt-5-nano", # or pass `memory_agent=create_memory_agent(...)`
174
+ # auto_extract=True,
175
+ # include_chat_history=True,
176
+ # consolidate=False,
177
+ # )
178
+ #
179
+ # --- External Connectors & MCP Servers --------------------------------------
180
+ # Connects per-user Python toolsets (`PythonConnector`), remote MCP servers
181
+ # (`MCPConnector`), admin-managed MCP servers, and optional user-added HTTPS MCP
182
+ # servers (`allow_user_mcp=True`). Set `ENCRYPTION_KEY` in `.env` for production.
183
+ #
184
+ # from pydantic_ai.toolsets import FunctionToolset
185
+ # from gentiq.connectors import ApiKeyAuth, ConnectorContext, Connectors, MCPConnector, PythonConnector
186
+ #
187
+ # def build_notes(ctx: ConnectorContext) -> FunctionToolset[AgentDeps[AppContext]]:
188
+ # toolset: FunctionToolset[AgentDeps[AppContext]] = FunctionToolset()
189
+ # @toolset.tool_plain(metadata={"readOnlyHint": True})
190
+ # def list_notes() -> list[str]:
191
+ # return [f"Notes for {ctx.user.name}"]
192
+ # return toolset
193
+ #
194
+ # connectors_plugin = Connectors(
195
+ # connectors=[
196
+ # PythonConnector(key="notes", name="Notes", description="Personal notes.", build_toolset=build_notes),
197
+ # # MCPConnector(key="linear", name="Linear", description="Manage Linear issues.", url="https://mcp.linear.app/mcp", auth=ApiKeyAuth()),
198
+ # ],
199
+ # allow_user_mcp=True,
200
+ # )
201
+ #
202
+ # --- Scheduled Tasks, Billing, Voice & Maintenance Jobs ---------------------
203
+ # from gentiq.schedules import Schedules
204
+ # schedules_plugin = Schedules() # Settings -> Scheduled + conversational schedule tools
205
+ #
206
+ # from gentiq.billing import Billing, Limit, Plan, PlanDuration
207
+ # billing_plugin = Billing(
208
+ # plans=[
209
+ # Plan(key="free", name="Free", limits=[Limit(meter="messages", amount=50, per="day")]),
210
+ # Plan(key="pro", name="Pro", duration=PlanDuration(per="month"), limits=[Limit(meter="messages", amount=500, per="day")]),
211
+ # ],
212
+ # default_plan="free",
213
+ # )
214
+ #
215
+ # from gentiq.voice import OpenAITranscriber, Voice
216
+ # voice_plugin = Voice(OpenAITranscriber("gpt-transcribe")) # adds microphone button to composer
217
+ #
218
+ # from gentiq.jobs import JobContext, Jobs
219
+ # jobs_plugin = Jobs()
220
+ # @jobs_plugin.job(id="count_users", name="Count users", danger="safe")
221
+ # def count_users(ctx: JobContext) -> dict:
222
+ # return {"users": ctx.engine.count_documents("users", {})}
223
+
224
+
225
+ # 6. Initialize the backend application with the agent, context, config, and plugins
89
226
  app = GentiqApp[AppContext](
90
227
  agent,
91
228
  app_name="My Gentiq App",
92
229
  context=AppContext(),
93
- storage=StorageConfig(db="sqlite", files="filesystem"), # or mongodb and minio for production
94
- chat=ChatConfig(title_agent=create_title_agent(model_name="gpt-5-nano")),
230
+ storage=StorageConfig(db="sqlite", files="filesystem"), # or "mongodb" and "minio" for production
231
+ chat=ChatConfig(
232
+ title_agent=create_title_agent(model_name="gpt-5-nano"),
233
+ # ask_user=True, # interactive multiple-choice buttons mid-turn (or a custom policy string)
234
+ # follow_up_suggestions=True, # clickable follow-up suggestion chips under replies
235
+ # progress_updates=True, # model-driven `<progress>...</progress>` live status notes
236
+ # modes=chat_modes, # composer mode selector (Fast / Deep / ...)
237
+ # capabilities=chat_capabilities, # toggleable capabilities in `+` menu / mode selector
238
+ ),
239
+ # auth=AuthConfig(login_fields=["username", "email", "phone"]),
95
240
  logfire=True,
96
241
  # Cross-origin policy. Omit (or pass cors=False) and no CORS middleware is
97
242
  # installed at all — correct when the frontend is same-origin or proxied, as
98
243
  # the Vite dev server does. List every browser origin that calls this API directly.
99
244
  cors=CORSConfig(allow_origins=["http://localhost:5173"]),
100
- # The admin panel's API under /api/admin, and maintenance mode with the watchdog that can
101
- # switch it on (Admin > Operations > Status). Leave them out and the app serves chat only.
102
- plugins=[AdminAPI(), Ops()],
245
+ # Plugins: AdminAPI exposes /api/admin; Ops adds metrics, watchdog & maintenance mode.
246
+ # Add memory_plugin, connectors_plugin, schedules_plugin, billing_plugin, voice_plugin, jobs_plugin here.
247
+ plugins=[
248
+ AdminAPI(),
249
+ Ops(),
250
+ ],
103
251
  )
104
252
 
105
253
 
106
- # 6. Extend the API with custom routes protected by Gentiq's authentication
254
+ # 7. Extend the API with custom routes protected by Gentiq's authentication
107
255
  custom_router = APIRouter()
108
256
 
109
257
 
@@ -3,7 +3,7 @@
3
3
  A [Vite](https://vite.dev/) + React app built on the Gentiq React SDK (`@gentiq/ui`, `@gentiq/react`, and `@gentiq/admin`, or `gentiq` if you prefer the umbrella package).
4
4
 
5
5
  - `src/App.tsx` mounts `<GentiqChatApp url="/api" admin={<AdminPanel />} {...options} />`, which handles routing (`/chat`, `/chat/:id`, `/login`, `/shared/:id`, `/admin`), auth, streaming, history, settings, and the lazy-loaded admin panel.
6
- - `src/options.ts` holds all frontend configuration (app name, theme, `i18n.resources`, history, welcome prompts, composer attachments, settings sections).
6
+ - `src/options.ts` holds all frontend configuration (app name, theme, `i18n.resources`, history, sidebar shortcuts, welcome prompts, composer modes/capabilities/attachments/references/voice, settings sections, and UI slot overrides).
7
7
  - `src/theme.css` overrides `--gentiq-*` tokens inside `.gentiq`.
8
8
  - `src/index.css` styles the host page outside Gentiq's `.gentiq` roots (`html`, `body`, `#root`).
9
9
 
@@ -18,17 +18,18 @@ The dev server proxies `/api` to `http://localhost:8000` (see `vite.config.ts`),
18
18
 
19
19
  ## Customising
20
20
 
21
- **Theme**: `theme={{ accent, radius, typography }}` in `src/options.ts`, or `--gentiq-*` CSS variables in `src/theme.css`. Gentiq styles only inside its `.gentiq` root elements (and `GentiqChatApp` syncs document theme/direction/title on page routes).
22
-
23
- **Tool rendering**: pass `components.parts` in `src/options.ts` to map `tool-<name>` (or `data-<name>`) to a React component typed with `defineToolUI`. Tools without an entry render Gentiq's generic tool card.
24
-
25
- **Copy and languages**: every user-visible string is an i18n key. `i18n.resources` in `src/options.ts` adds to and overrides Gentiq's 13 bundled languages (including RTL support for Arabic, Persian, and Urdu).
26
-
27
- **Auth**: with no `api.authAdapter`, Gentiq keeps the JWT in `localStorage` under a key namespaced by `app.cacheNamespace`. Pass `api={{ authAdapter }}` when your session lives elsewhere (external IdP token or HttpOnly session cookie).
28
-
29
- **Math**: the SDK lazy-loads KaTeX and its stylesheet the first time a message contains `$$` math. `katex` is listed in `package.json`; remove it if your agent never emits math.
30
-
31
- **Admin panel**: `src/App.tsx` loads `AdminPanel` with `React.lazy()`, so `/admin` code is only downloaded by admins who visit `/admin`.
21
+ `src/options.ts` includes commented examples for the options below:
22
+
23
+ - **Theme**: `theme={{ accent, radius, typography }}` in `src/options.ts`, or `--gentiq-*` CSS variables in `src/theme.css`. Gentiq styles only inside its `.gentiq` root elements (and `GentiqChatApp` syncs document theme/direction/title on page routes).
24
+ - **Modes & capabilities**: backend-declared `ChatMode` and `Capability` controls render automatically from `/api/config`. Customize their icons, labels, grouping, chip behavior, or visibility with `composer.modes` and `composer.capabilities` in `src/options.ts`, or replace `components.ModeSelector` / `components.ComposerChip`.
25
+ - **Sidebar & settings tabs**: `sidebar.showSchedules`, `sidebar.showConnectors`, and `sidebar.showMemory` toggle sidebar shortcuts for active backend plugins. Use `settings.sections` (`general`, `profile`, `account`, `memory`, `connectors`, `schedules`, `feedback`), `settings.menu`, and `settings.customSections` to tailor the Settings dialog.
26
+ - **Tool & data rendering**: pass `components.parts` in `src/options.ts` to map `tool-<name>` (with `defineToolUI`) or `data-<name>` (with `defineDataUI`) to a React component. Tools without an entry render Gentiq's generic tool card.
27
+ - **Header & composer slots**: add `components.headerActions` (toggleable in Admin → Settings → Chat), `components.composerTools`, `components.ComposerFooter`, or replace `MemoryPanel`, `ConnectorsPanel`, `SchedulesPanel`, or `WelcomeLayout`.
28
+ - **Profile metadata**: `app.userMetadataFields` adds custom signup and profile fields stored on `user.metadata`.
29
+ - **Copy and languages**: every user-visible string is an i18n key. `i18n.resources` in `src/options.ts` adds to and overrides Gentiq's 13 bundled languages (including RTL support for Arabic, Persian, and Urdu).
30
+ - **Auth**: with no `api.authAdapter`, Gentiq keeps the JWT in `localStorage` under a key namespaced by `app.cacheNamespace`. Pass `api={{ authAdapter }}` when your session lives elsewhere (external IdP token or HttpOnly session cookie).
31
+ - **Math**: the SDK lazy-loads KaTeX and its stylesheet the first time a message contains `$$` math. `katex` is listed in `package.json`; remove it if your agent never emits math.
32
+ - **Admin panel**: `src/App.tsx` loads `AdminPanel` with `React.lazy()`, so `/admin` code is only downloaded by admins who visit `/admin`.
32
33
 
33
34
  ## Package manager notes
34
35
 
@@ -1,7 +1,7 @@
1
1
  import type { GentiqChatAppProps } from '@gentiq/ui'
2
2
 
3
3
  // How the app looks and behaves. Every field is optional: `<GentiqChatApp url="/api" />` alone is
4
- // a working chat. The admin panel's settings, saved on the backend, override what is set here.
4
+ // a working chat. Admin panel settings (saved on the backend) override matching fields set here.
5
5
  export const options = {
6
6
  app: {
7
7
  name: 'My Gentiq App',
@@ -10,6 +10,20 @@ export const options = {
10
10
  cacheNamespace: 'my_app_cache',
11
11
  showToolDetails: false,
12
12
  showSettings: true,
13
+ // Declare extra profile fields stored on `user.metadata` (also shown on signup if `showInSignup: true`):
14
+ // userMetadataFields: [
15
+ // {
16
+ // key: 'job_position',
17
+ // label: 'settings:profile.job_position',
18
+ // type: 'select',
19
+ // showInSignup: true,
20
+ // showInProfile: true,
21
+ // options: [
22
+ // { label: 'settings:profile.job_position_options.developer', value: 'developer' },
23
+ // { label: 'settings:profile.job_position_options.other', value: 'other' },
24
+ // ],
25
+ // },
26
+ // ],
13
27
  },
14
28
  // No `api.authAdapter` is passed, so Gentiq uses its built-in localStorage adapter, which
15
29
  // namespaces the token under `app.cacheNamespace` above. Supply your own only if the session
@@ -19,6 +33,7 @@ export const options = {
19
33
  theme: {
20
34
  typography: { fontFamily: { en: 'Lato', fa: 'Vazirmatn' } },
21
35
  accent: '#2563eb',
36
+ // radius: 12, // base border radius in px; CSS tokens live in src/theme.css
22
37
  },
23
38
  i18n: {
24
39
  resources: {
@@ -55,11 +70,15 @@ export const options = {
55
70
  },
56
71
  },
57
72
  history: { enabled: true, showDelete: true, showRename: true, showPin: true, showShare: true },
73
+ // Plugin shortcuts in the sidebar (Schedules & Connectors default to `true` when active;
74
+ // set `showMemory: true` to pin a Memory shortcut when Memory() is enabled on the backend):
75
+ // sidebar: { showSchedules: true, showConnectors: true, showMemory: true },
58
76
  welcome: {
59
77
  // A function receives the authenticated user, so the greeting can be personalised; a plain
60
78
  // i18n key works too.
61
79
  greeting: ({ firstName, t }) =>
62
80
  t(firstName ? 'chat:welcome.greeting_named' : 'chat:welcome.greeting', { firstName }),
81
+ // subtitle: 'Ask a question, connect tools, or manage your scheduled tasks.',
63
82
  // Prompts typed out in turn as the new-chat composer's placeholder.
64
83
  typingPrompts: ({ t }) => [
65
84
  t('chat:welcome.prompts.features'),
@@ -73,6 +92,20 @@ export const options = {
73
92
  // The types and the size limit are the backend's: GentiqApp(attachment_types=...) and
74
93
  // MAX_ATTACHMENT_SIZE.
75
94
  attachments: { enabled: true },
95
+ // Quoting/referencing earlier messages, tool calls, or files (`enabled: true` by default):
96
+ // references: { enabled: true, maxItems: 5 },
97
+ // Voice dictation button (shown automatically when the backend enables the `Voice` plugin):
98
+ // voice: { enabled: true, maxDuration: 300 },
99
+ // Customize backend-declared ChatModes (`ChatConfig(modes=...)`) and Capabilities
100
+ // (`ChatConfig(capabilities=...)`) without changing backend code:
101
+ // modes: {
102
+ // fast: { label: 'Fast', description: 'Quick everyday replies' },
103
+ // deep: { icon: 'sparkles', group: 'Reasoning' },
104
+ // },
105
+ // capabilities: {
106
+ // search: { icon: 'search', chip: 'when_active' },
107
+ // memory: { chipDisplay: 'icon' },
108
+ // },
76
109
  },
77
110
  disclaimer: 'chat:disclaimer',
78
111
  settings: {
@@ -82,6 +115,25 @@ export const options = {
82
115
  fields: { name: 'editable', surname: 'editable', phone: 'editable', password: 'editable' },
83
116
  },
84
117
  account: { enabled: true, fields: { usage: 'editable', logout: 'editable' } },
118
+ // Plugin settings tabs appear automatically when enabled on the backend; hide or configure them here:
119
+ // memory: { enabled: true },
120
+ // connectors: { enabled: true },
121
+ // schedules: { enabled: true },
122
+ // feedback: { enabled: true },
85
123
  },
124
+ // Control shortcuts in the floating settings popover menu:
125
+ // menu: { showProfile: false, showTheme: false, showLanguage: false },
126
+ // Add custom tabs to the Settings dialog:
127
+ // customSections: [{ id: 'preferences', label: 'Preferences', component: PreferencesTab }],
86
128
  },
129
+ // Customize built-in UI slots, custom tool cards (`tool-<name>`), and custom data parts (`data-<name>`):
130
+ // components: {
131
+ // parts: {
132
+ // 'tool-list_my_chats': ChatListCard, // build with `defineToolUI(...)` from `@gentiq/react`
133
+ // 'data-chart': ChartCard, // build with `defineDataUI(...)` from `@gentiq/react`
134
+ // },
135
+ // headerActions: [{ id: 'upgrade', component: UpgradeButton, label: 'Upgrade' }],
136
+ // composerTools: [{ id: 'surprise', component: SurpriseMe, placement: 'end' }],
137
+ // ComposerFooter: StarterPrompts,
138
+ // },
87
139
  } satisfies Omit<GentiqChatAppProps, 'url'>