create-theokit 0.4.0-beta.0 → 0.5.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/package.json +8 -4
- package/templates/default/.env.example +5 -0
- package/templates/default/README.md.tmpl +71 -57
- package/templates/default/_gitignore +2 -3
- package/templates/default/app/layout.tsx +51 -82
- package/templates/default/app/page.tsx +169 -271
- package/templates/default/app.ts +23 -0
- package/templates/default/package.json.tmpl +10 -23
- package/templates/default/server/agents/assistant.agent.ts +46 -0
- package/templates/default/server/controllers/tasks.controller.ts +70 -0
- package/templates/default/server/filters/http-error.filter.ts +20 -0
- package/templates/default/server/guards/auth.guard.ts +47 -0
- package/templates/default/server/interceptors/timing.interceptor.ts +14 -0
- package/templates/default/server/middleware/logger.middleware.ts +12 -0
- package/templates/default/server/store.ts +46 -0
- package/templates/default/server/toolboxes/task.tools.ts +58 -0
- package/templates/default/tsconfig.json +7 -7
- package/LICENSE +0 -201
- package/templates/api-only/.nvmrc +0 -1
- package/templates/api-only/README.md.tmpl +0 -78
- package/templates/api-only/_gitignore +0 -5
- package/templates/api-only/app/page.tsx +0 -3
- package/templates/api-only/index.html +0 -12
- package/templates/api-only/package.json.tmpl +0 -28
- package/templates/api-only/public/.gitkeep +0 -0
- package/templates/api-only/public/favicon.ico +0 -0
- package/templates/api-only/server/routes/health.ts +0 -5
- package/templates/api-only/server/routes/users.ts +0 -27
- package/templates/api-only/server/routes/webhooks/echo.ts +0 -34
- package/templates/api-only/theo.config.ts +0 -3
- package/templates/api-only/tsconfig.json +0 -15
- package/templates/dashboard/.nvmrc +0 -1
- package/templates/dashboard/README.md.tmpl +0 -76
- package/templates/dashboard/_gitignore +0 -5
- package/templates/dashboard/app/about/page.tsx +0 -3
- package/templates/dashboard/app/dashboard/layout.tsx +0 -10
- package/templates/dashboard/app/dashboard/page.tsx +0 -3
- package/templates/dashboard/app/layout.tsx +0 -14
- package/templates/dashboard/app/page.tsx +0 -8
- package/templates/dashboard/index.html +0 -12
- package/templates/dashboard/package.json.tmpl +0 -28
- package/templates/dashboard/public/.gitkeep +0 -0
- package/templates/dashboard/public/favicon.ico +0 -0
- package/templates/dashboard/server/crons/cleanup-conversations.ts +0 -59
- package/templates/dashboard/server/routes/health.ts +0 -5
- package/templates/dashboard/theo.config.ts +0 -3
- package/templates/dashboard/tsconfig.json +0 -15
- package/templates/default/.nvmrc +0 -1
- package/templates/default/index.html +0 -12
- package/templates/default/public/.gitkeep +0 -0
- package/templates/default/public/favicon.ico +0 -0
- package/templates/default/server/crons/cleanup-conversations.ts +0 -59
- package/templates/default/server/routes/chat.ts +0 -69
- package/templates/default/server/routes/health.ts +0 -5
- package/templates/default/theo.config.ts +0 -3
- package/templates/default/types/jobs.d.ts +0 -25
- package/templates/postgres/.env.example +0 -5
- package/templates/postgres/.nvmrc +0 -1
- package/templates/postgres/README.md.tmpl +0 -83
- package/templates/postgres/_gitignore +0 -5
- package/templates/postgres/app/layout.tsx +0 -14
- package/templates/postgres/app/page.tsx +0 -8
- package/templates/postgres/db/index.ts +0 -7
- package/templates/postgres/db/schema.ts +0 -8
- package/templates/postgres/drizzle.config.ts +0 -10
- package/templates/postgres/index.html +0 -12
- package/templates/postgres/package.json.tmpl +0 -36
- package/templates/postgres/public/.gitkeep +0 -0
- package/templates/postgres/public/favicon.ico +0 -0
- package/templates/postgres/server/context.ts +0 -5
- package/templates/postgres/server/jobs/log-message.ts +0 -26
- package/templates/postgres/server/routes/health.ts +0 -5
- package/templates/postgres/server/routes/users.ts +0 -22
- package/templates/postgres/theo.config.ts +0 -3
- package/templates/postgres/tsconfig.json +0 -15
- package/templates/saas/.env.example +0 -7
- package/templates/saas/.nvmrc +0 -1
- package/templates/saas/README.md.tmpl +0 -103
- package/templates/saas/_gitignore +0 -5
- package/templates/saas/app/layout.tsx +0 -5
- package/templates/saas/app/page.tsx +0 -104
- package/templates/saas/db/index.ts +0 -6
- package/templates/saas/db/schema.ts +0 -20
- package/templates/saas/drizzle.config.ts +0 -10
- package/templates/saas/index.html +0 -12
- package/templates/saas/package.json.tmpl +0 -38
- package/templates/saas/public/.gitkeep +0 -0
- package/templates/saas/public/favicon.ico +0 -0
- package/templates/saas/server/context.ts +0 -37
- package/templates/saas/server/routes/agent.ts +0 -49
- package/templates/saas/server/routes/billing/stripe-webhook.ts +0 -49
- package/templates/saas/server/routes/login.ts +0 -25
- package/templates/saas/server/routes/logout.ts +0 -10
- package/templates/saas/server/routes/me.ts +0 -10
- package/templates/saas/theo.config.ts +0 -5
- package/templates/saas/tsconfig.json +0 -15
- package/templates/services/agent-node/Dockerfile.tmpl +0 -20
- package/templates/services/agent-node/README.md +0 -38
- package/templates/services/agent-node/package.json.tmpl +0 -18
- package/templates/services/agent-node/src/index.ts +0 -58
- package/templates/services/agent-node/tsconfig.json +0 -13
- package/templates/services/agent-python/Dockerfile.tmpl +0 -20
- package/templates/services/agent-python/README.md +0 -37
- package/templates/services/agent-python/main.py +0 -77
- package/templates/services/agent-python/pyproject.toml.tmpl +0 -16
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# Agent service (Node / Hono)
|
|
2
|
-
|
|
3
|
-
This is a TheoKit polyglot sidecar generated by `create-theokit --backend node`.
|
|
4
|
-
|
|
5
|
-
## Requirements
|
|
6
|
-
|
|
7
|
-
- **Node.js 22+** (matches TheoKit's floor)
|
|
8
|
-
- **pnpm** or **npm** (TheoKit's CLI prefers pnpm)
|
|
9
|
-
|
|
10
|
-
## Run it
|
|
11
|
-
|
|
12
|
-
The TheoKit app boots this service automatically via `pnpm dev` (per `theo.config.ts > services`).
|
|
13
|
-
|
|
14
|
-
To run standalone:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
cd services/agent-node
|
|
18
|
-
pnpm install
|
|
19
|
-
pnpm dev
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Endpoints
|
|
23
|
-
|
|
24
|
-
- `GET /health` — healthcheck (returns `{"status":"ok"}`)
|
|
25
|
-
- `POST /echo` — example: `{ "message": "..." }` → `{ "echo": "..." }`
|
|
26
|
-
|
|
27
|
-
## What is wired
|
|
28
|
-
|
|
29
|
-
- Native fetch handler via Hono (works on TheoCloud and local)
|
|
30
|
-
- JSON-line stdout logs
|
|
31
|
-
- W3C `traceparent` propagation from incoming headers
|
|
32
|
-
- TheoKit injects `THEOKIT_SERVICE_NAME` + `THEOKIT_SERVICE_PORT` env vars
|
|
33
|
-
|
|
34
|
-
## Add a tool the TheoKit agent can call
|
|
35
|
-
|
|
36
|
-
Add another `app.post('/tool/<name>', ...)` handler. From the TheoKit TS side,
|
|
37
|
-
`services.worker.<name>({...})` is auto-typed when an OpenAPI URL is reachable
|
|
38
|
-
(Hey API integration — Phase 5).
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "{{name}}-agent-node",
|
|
3
|
-
"private": true,
|
|
4
|
-
"type": "module",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "tsx watch src/index.ts",
|
|
7
|
-
"start": "tsx src/index.ts",
|
|
8
|
-
"build": "echo 'no build step; tsx runs TS directly'"
|
|
9
|
-
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"hono": "^4.6.0",
|
|
12
|
-
"@hono/node-server": "^1.13.0"
|
|
13
|
-
},
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"tsx": "^4.19.0",
|
|
16
|
-
"typescript": "^5.7.0"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TheoKit polyglot agent service — Hono sidecar.
|
|
3
|
-
*
|
|
4
|
-
* Conforms to the Like-Vercel runtime contract (ADR-0015):
|
|
5
|
-
* - Fetch-handler entry (native fetch handler from Hono)
|
|
6
|
-
* - GET /health convention (200 / 503)
|
|
7
|
-
* - JSON-line stdout logs
|
|
8
|
-
* - W3C traceparent propagation
|
|
9
|
-
* - Env vars at runtime
|
|
10
|
-
*
|
|
11
|
-
* Generated by `create-theokit --backend node`.
|
|
12
|
-
*/
|
|
13
|
-
import { Hono } from 'hono'
|
|
14
|
-
import { serve } from '@hono/node-server'
|
|
15
|
-
|
|
16
|
-
const SERVICE_NAME = process.env.THEOKIT_SERVICE_NAME ?? 'agent-node'
|
|
17
|
-
const SERVICE_PORT = Number.parseInt(process.env.THEOKIT_SERVICE_PORT ?? '8002', 10)
|
|
18
|
-
|
|
19
|
-
function log(
|
|
20
|
-
level: 'info' | 'warn' | 'error',
|
|
21
|
-
message: string,
|
|
22
|
-
extra: Record<string, unknown> = {},
|
|
23
|
-
) {
|
|
24
|
-
// eslint-disable-next-line no-console -- structured stdout per ADR-0015 invariant #5
|
|
25
|
-
console.log(
|
|
26
|
-
JSON.stringify({
|
|
27
|
-
timestamp: new Date().toISOString(),
|
|
28
|
-
level,
|
|
29
|
-
message,
|
|
30
|
-
service: SERVICE_NAME,
|
|
31
|
-
...extra,
|
|
32
|
-
}),
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const app = new Hono()
|
|
37
|
-
|
|
38
|
-
// ADR-0015 invariant #6 — W3C traceparent propagation
|
|
39
|
-
app.use(async (c, next) => {
|
|
40
|
-
const tp = c.req.header('traceparent')
|
|
41
|
-
if (tp) {
|
|
42
|
-
log('info', 'request', { traceparent: tp, path: c.req.path })
|
|
43
|
-
}
|
|
44
|
-
await next()
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
// ADR-0015 invariant #4 — healthcheck convention
|
|
48
|
-
app.get('/health', (c) => c.json({ status: 'ok' }))
|
|
49
|
-
|
|
50
|
-
// Example endpoint — TheoKit proxies /api/worker/* to this service.
|
|
51
|
-
app.post('/echo', async (c) => {
|
|
52
|
-
const body = (await c.req.json()) as { message: string }
|
|
53
|
-
return c.json({ echo: body.message })
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
serve({ fetch: app.fetch, port: SERVICE_PORT }, () => {
|
|
57
|
-
log('info', `agent-node listening on :${String(SERVICE_PORT)}`)
|
|
58
|
-
})
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
FROM python:3.12-slim
|
|
2
|
-
|
|
3
|
-
WORKDIR /app
|
|
4
|
-
|
|
5
|
-
# Install uv (fast pip replacement)
|
|
6
|
-
RUN pip install --no-cache-dir uv
|
|
7
|
-
|
|
8
|
-
# Copy dependency manifest first (cache layer)
|
|
9
|
-
COPY pyproject.toml ./
|
|
10
|
-
RUN uv sync --no-dev --frozen || uv sync --no-dev
|
|
11
|
-
|
|
12
|
-
# Copy source
|
|
13
|
-
COPY . .
|
|
14
|
-
|
|
15
|
-
EXPOSE 8001
|
|
16
|
-
|
|
17
|
-
HEALTHCHECK --interval=10s --timeout=5s --retries=3 \
|
|
18
|
-
CMD curl -f http://localhost:8001/health || exit 1
|
|
19
|
-
|
|
20
|
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8001", "--workers", "4"]
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# Agent service (Python / FastAPI)
|
|
2
|
-
|
|
3
|
-
This is a TheoKit polyglot sidecar generated by `create-theokit --backend python`.
|
|
4
|
-
|
|
5
|
-
## Requirements
|
|
6
|
-
|
|
7
|
-
- **Python 3.11+** (`pyproject.toml` requires it)
|
|
8
|
-
- **uv** in PATH (https://github.com/astral-sh/uv)
|
|
9
|
-
|
|
10
|
-
## Run it
|
|
11
|
-
|
|
12
|
-
The TheoKit app boots this service automatically via `pnpm dev` (per `theo.config.ts > services`).
|
|
13
|
-
|
|
14
|
-
To run standalone:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
cd services/agent-python
|
|
18
|
-
uv sync
|
|
19
|
-
uv run uvicorn main:app --reload --port 8001
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Endpoints
|
|
23
|
-
|
|
24
|
-
- `GET /health` — healthcheck (returns `{"status":"ok"}`)
|
|
25
|
-
- `POST /echo` — example: `{ "message": "..." }` → `{ "echo": "..." }`
|
|
26
|
-
|
|
27
|
-
## What is wired
|
|
28
|
-
|
|
29
|
-
- ASGI fetch-handler (works on TheoCloud K8s and local uvicorn)
|
|
30
|
-
- JSON-line stdout logs
|
|
31
|
-
- W3C `traceparent` propagation from incoming headers
|
|
32
|
-
- TheoKit injects `THEOKIT_SERVICE_NAME` + `THEOKIT_SERVICE_PORT` env vars
|
|
33
|
-
|
|
34
|
-
## Add a tool the TheoKit agent can call
|
|
35
|
-
|
|
36
|
-
Add another `@app.post("/tool/<name>")` endpoint. From the TheoKit TS side,
|
|
37
|
-
`services.agent.<name>({...})` is auto-typed when the OpenAPI URL is reachable.
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
TheoKit polyglot agent service — FastAPI sidecar.
|
|
3
|
-
|
|
4
|
-
Conforms to the Like-Vercel runtime contract (ADR-0015):
|
|
5
|
-
- Fetch-handler entry (ASGI via uvicorn)
|
|
6
|
-
- GET /health convention (200 / 503)
|
|
7
|
-
- JSON-line stdout logs
|
|
8
|
-
- W3C traceparent propagation
|
|
9
|
-
- Env vars at runtime (not bundled)
|
|
10
|
-
|
|
11
|
-
Generated by `create-theokit --backend python`.
|
|
12
|
-
"""
|
|
13
|
-
import json
|
|
14
|
-
import logging
|
|
15
|
-
import os
|
|
16
|
-
import sys
|
|
17
|
-
from datetime import datetime, timezone
|
|
18
|
-
|
|
19
|
-
from fastapi import FastAPI, Request
|
|
20
|
-
from pydantic import BaseModel
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
SERVICE_NAME = os.environ.get("THEOKIT_SERVICE_NAME", "agent-python")
|
|
24
|
-
SERVICE_PORT = os.environ.get("THEOKIT_SERVICE_PORT", "8001")
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class JsonFormatter(logging.Formatter):
|
|
28
|
-
"""ADR-0015 invariant #5 — JSON-line stdout logging."""
|
|
29
|
-
|
|
30
|
-
def format(self, record: logging.LogRecord) -> str:
|
|
31
|
-
log_obj = {
|
|
32
|
-
"timestamp": datetime.now(tz=timezone.utc).isoformat(),
|
|
33
|
-
"level": record.levelname.lower(),
|
|
34
|
-
"message": record.getMessage(),
|
|
35
|
-
"service": SERVICE_NAME,
|
|
36
|
-
}
|
|
37
|
-
if hasattr(record, "traceparent"):
|
|
38
|
-
log_obj["traceparent"] = getattr(record, "traceparent")
|
|
39
|
-
return json.dumps(log_obj)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
handler = logging.StreamHandler(sys.stdout)
|
|
43
|
-
handler.setFormatter(JsonFormatter())
|
|
44
|
-
logging.basicConfig(level=logging.INFO, handlers=[handler])
|
|
45
|
-
log = logging.getLogger("theokit.service")
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
app = FastAPI(title=f"{SERVICE_NAME} agent service")
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
@app.middleware("http")
|
|
52
|
-
async def trace_middleware(request: Request, call_next):
|
|
53
|
-
"""ADR-0015 invariant #6 — W3C traceparent propagation."""
|
|
54
|
-
traceparent = request.headers.get("traceparent")
|
|
55
|
-
if traceparent:
|
|
56
|
-
log.info(
|
|
57
|
-
"request",
|
|
58
|
-
extra={"traceparent": traceparent, "path": request.url.path},
|
|
59
|
-
)
|
|
60
|
-
response = await call_next(request)
|
|
61
|
-
return response
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@app.get("/health")
|
|
65
|
-
async def health() -> dict[str, str]:
|
|
66
|
-
"""ADR-0015 invariant #4 — healthcheck convention."""
|
|
67
|
-
return {"status": "ok"}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
class EchoRequest(BaseModel):
|
|
71
|
-
message: str
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
@app.post("/echo")
|
|
75
|
-
async def echo(req: EchoRequest) -> dict[str, str]:
|
|
76
|
-
"""Example endpoint — TheoKit proxies /api/agent/* to this service."""
|
|
77
|
-
return {"echo": req.message}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
[project]
|
|
2
|
-
name = "{{name}}-agent-python"
|
|
3
|
-
version = "0.1.0"
|
|
4
|
-
description = "TheoKit polyglot agent service (FastAPI sidecar)"
|
|
5
|
-
requires-python = ">=3.11"
|
|
6
|
-
dependencies = [
|
|
7
|
-
"fastapi>=0.115",
|
|
8
|
-
"uvicorn[standard]>=0.32",
|
|
9
|
-
"pydantic>=2.9",
|
|
10
|
-
]
|
|
11
|
-
|
|
12
|
-
[tool.uv]
|
|
13
|
-
dev-dependencies = [
|
|
14
|
-
"pytest>=8.0",
|
|
15
|
-
"httpx>=0.28",
|
|
16
|
-
]
|