create-theokit 0.1.0-alpha.14 → 0.1.0-alpha.16
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/default/package.json.tmpl +1 -1
- package/templates/default/server/routes/chat.ts +23 -14
- package/templates/postgres/package.json.tmpl +1 -1
- package/templates/saas/package.json.tmpl +1 -1
package/package.json
CHANGED
|
@@ -39,19 +39,28 @@ export const POST = defineAgentEndpoint({
|
|
|
39
39
|
// ANTHROPIC_API_KEY presente no env. Wire protocol: OpenAI Chat Completions
|
|
40
40
|
// (universal — todos os providers implementam essa API). Consumer NÃO tem
|
|
41
41
|
// conditionals sobre provider — é responsabilidade do framework.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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 literal — provider resolution NÃO depende de prefix inference.
|
|
52
|
+
// Stranger pode trocar livremente sem mexer em routing.
|
|
53
|
+
model: { id: 'gpt-4o-mini' },
|
|
54
|
+
tools: [currentTime],
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
const run = await agent.send(message, { signal })
|
|
58
|
+
yield* streamAgentRun(run)
|
|
59
|
+
// Intentionally NO agent.dispose() — the agent stays registered so the
|
|
60
|
+
// next request from the same conversation resumes it (continuity).
|
|
61
|
+
} catch (err) {
|
|
62
|
+
const msg = err instanceof Error ? err.message : String(err)
|
|
63
|
+
yield { type: 'error', message: `Agent error: ${msg}` }
|
|
64
|
+
}
|
|
56
65
|
},
|
|
57
66
|
})
|