fix: correct Docker setup, SDK async API, and docs
- Dockerfile: use explicit uvicorn command (uv run start fails without package mode) - docker-compose: mount claude-auth volume to /root/.claude (worker runs as root) - worker: update to Claude Code SDK async iterable API (query() returns iterator, not array) - main.py: fix docs_url from /doc to /docs - README: correct login instructions (exec not run --rm), add production URLs - Add CLAUDE.md with full project documentation Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+18
-19
@@ -31,22 +31,21 @@ app.post("/process", async (req, res) => {
|
||||
options.resume = session_id;
|
||||
}
|
||||
|
||||
const messages = await query({
|
||||
prompt,
|
||||
options,
|
||||
});
|
||||
const conv = query({ prompt, options });
|
||||
const messages = [];
|
||||
for await (const msg of conv) {
|
||||
messages.push(msg);
|
||||
}
|
||||
|
||||
const resultText = messages
|
||||
.filter((m) => m.type === "text")
|
||||
.map((m) => m.text)
|
||||
.join("\n");
|
||||
|
||||
const conversationId = messages.length > 0 ? messages[0].conversationId : null;
|
||||
const resultMsg = messages.find((m) => m.type === "result");
|
||||
if (resultMsg && resultMsg.is_error) {
|
||||
return res.json({ success: false, error: resultMsg.result });
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
result: resultText,
|
||||
session_id: conversationId || session_id,
|
||||
result: resultMsg?.result || "",
|
||||
session_id: resultMsg?.session_id || session_id,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Process error:", error.message);
|
||||
@@ -76,7 +75,7 @@ app.post("/summarize", async (req, res) => {
|
||||
: `Summarize this exchange in 1-2 sentences:\n\n${exchangeText}`;
|
||||
|
||||
try {
|
||||
const messages = await query({
|
||||
const conv = query({
|
||||
prompt: summaryPrompt,
|
||||
options: {
|
||||
model: DEFAULT_MODEL,
|
||||
@@ -85,15 +84,15 @@ app.post("/summarize", async (req, res) => {
|
||||
allowedTools: [],
|
||||
},
|
||||
});
|
||||
const msgs = [];
|
||||
for await (const msg of conv) {
|
||||
msgs.push(msg);
|
||||
}
|
||||
|
||||
const summaryText = messages
|
||||
.filter((m) => m.type === "text")
|
||||
.map((m) => m.text)
|
||||
.join("\n");
|
||||
|
||||
const resultMsg = msgs.find((m) => m.type === "result");
|
||||
res.json({
|
||||
success: true,
|
||||
summary: summaryText.trim(),
|
||||
summary: (resultMsg?.result || "").trim(),
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Summarize error:", error.message);
|
||||
|
||||
Reference in New Issue
Block a user