create-theokit 0.2.1 → 0.2.2
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 +1 -1
- package/templates/api-only/package.json.tmpl +1 -1
- package/templates/dashboard/package.json.tmpl +1 -1
- package/templates/dashboard/server/crons/cleanup-conversations.ts +15 -6
- package/templates/default/package.json.tmpl +3 -3
- package/templates/postgres/package.json.tmpl +1 -1
- package/templates/saas/package.json.tmpl +2 -2
- package/templates/services/agent-node/README.md +1 -1
- package/templates/services/agent-python/README.md +1 -1
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineCron } from 'theokit/server/cron'
|
|
2
2
|
import { readdir, stat, rm } from 'node:fs/promises'
|
|
3
|
+
import type { Dirent } from 'node:fs'
|
|
3
4
|
import { join, resolve } from 'node:path'
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -15,21 +16,21 @@ const AGENTS_DIR = '.theokit/agents'
|
|
|
15
16
|
|
|
16
17
|
export default defineCron('cleanup-conversations', {
|
|
17
18
|
schedule: '0 4 * * *', // Daily 04:00 UTC
|
|
18
|
-
handler: async ({
|
|
19
|
+
handler: async ({ traceId }) => {
|
|
19
20
|
const root = resolve(process.cwd(), AGENTS_DIR)
|
|
20
21
|
const cutoff = Date.now() - MAX_AGE_DAYS * 24 * 60 * 60 * 1000
|
|
21
22
|
let removed = 0
|
|
22
23
|
let kept = 0
|
|
23
|
-
let entries:
|
|
24
|
+
let entries: Dirent[]
|
|
24
25
|
try {
|
|
25
|
-
entries = await readdir(root, { withFileTypes: true })
|
|
26
|
+
entries = (await readdir(root, { withFileTypes: true })) as unknown as Dirent[]
|
|
26
27
|
} catch {
|
|
27
|
-
|
|
28
|
+
console.info(JSON.stringify({ msg: 'No agents dir yet — first run', dir: root, traceId }))
|
|
28
29
|
return
|
|
29
30
|
}
|
|
30
31
|
for (const entry of entries) {
|
|
31
32
|
if (!entry.isDirectory()) continue
|
|
32
|
-
const agentDir = join(root, entry.name)
|
|
33
|
+
const agentDir = join(root, String(entry.name))
|
|
33
34
|
const messagesFile = join(agentDir, 'messages.jsonl')
|
|
34
35
|
try {
|
|
35
36
|
const s = await stat(messagesFile)
|
|
@@ -45,6 +46,14 @@ export default defineCron('cleanup-conversations', {
|
|
|
45
46
|
removed++
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
console.info(
|
|
50
|
+
JSON.stringify({
|
|
51
|
+
msg: 'cleanup-conversations complete',
|
|
52
|
+
removed,
|
|
53
|
+
kept,
|
|
54
|
+
maxAgeDays: MAX_AGE_DAYS,
|
|
55
|
+
traceId,
|
|
56
|
+
}),
|
|
57
|
+
)
|
|
49
58
|
},
|
|
50
59
|
})
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"typecheck": "tsc --noEmit"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"theokit": "^0.2.
|
|
14
|
-
"@usetheo/sdk": "^1.
|
|
15
|
-
"@usetheo/ui": "^0.
|
|
13
|
+
"theokit": "^0.2.1",
|
|
14
|
+
"@usetheo/sdk": "^1.4.1",
|
|
15
|
+
"@usetheo/ui": "^0.13.0",
|
|
16
16
|
"lucide-react": "^0.469.0",
|
|
17
17
|
"react": "^19.0.0",
|
|
18
18
|
"react-dom": "^19.0.0",
|
|
@@ -26,7 +26,7 @@ pnpm dev
|
|
|
26
26
|
|
|
27
27
|
## What is wired
|
|
28
28
|
|
|
29
|
-
- Native fetch handler via Hono (works on
|
|
29
|
+
- Native fetch handler via Hono (works on TheoCloud and local)
|
|
30
30
|
- JSON-line stdout logs
|
|
31
31
|
- W3C `traceparent` propagation from incoming headers
|
|
32
32
|
- TheoKit injects `THEOKIT_SERVICE_NAME` + `THEOKIT_SERVICE_PORT` env vars
|
|
@@ -26,7 +26,7 @@ uv run uvicorn main:app --reload --port 8001
|
|
|
26
26
|
|
|
27
27
|
## What is wired
|
|
28
28
|
|
|
29
|
-
- ASGI fetch-handler (works on
|
|
29
|
+
- ASGI fetch-handler (works on TheoCloud K8s and local uvicorn)
|
|
30
30
|
- JSON-line stdout logs
|
|
31
31
|
- W3C `traceparent` propagation from incoming headers
|
|
32
32
|
- TheoKit injects `THEOKIT_SERVICE_NAME` + `THEOKIT_SERVICE_PORT` env vars
|