hob-bot 1.0.4 → 1.2.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/README.md +76 -6
- package/README.zh-CN.md +76 -6
- package/dist/web/assets/DesktopView-CEBJFAIN.js +5 -0
- package/dist/web/assets/index-Di5lyTHO.css +1 -0
- package/dist/web/assets/index-y09i1RGd.js +267 -0
- package/dist/web/assets/{math-zZ4JA8eM.js → math-weKGDUmL.js} +2 -2
- package/dist/web/index.html +2 -2
- package/dist/web/mock/desktop.jpg +0 -0
- package/dist/web/mock/photo.jpg +0 -0
- package/dist/web/mock/photo2.jpg +0 -0
- package/dist/web/mock/sunset.html +90 -0
- package/package.json +7 -1
- package/server/src/actions.ts +16 -56
- package/server/src/assistant-skills.ts +215 -0
- package/server/src/boot.ts +1 -0
- package/server/src/claude-status.ts +47 -0
- package/server/src/config.ts +3 -1
- package/server/src/delegations.ts +21 -11
- package/server/src/desktop-control.ts +152 -0
- package/server/src/desktop-events.ts +63 -0
- package/server/src/desktop-public.ts +43 -0
- package/server/src/desktop-tools.ts +161 -0
- package/server/src/desktop.ts +76 -0
- package/server/src/embedding.ts +52 -0
- package/server/src/files.ts +63 -43
- package/server/src/http.ts +325 -13
- package/server/src/job-view.ts +52 -0
- package/server/src/jobs.ts +326 -44
- package/server/src/knowledge-index.ts +123 -0
- package/server/src/knowledge-tools.ts +94 -0
- package/server/src/knowledge.ts +451 -0
- package/server/src/lore-entry.ts +10 -0
- package/server/src/main.ts +6 -0
- package/server/src/mcp.ts +745 -0
- package/server/src/memory.ts +11 -4
- package/server/src/now.ts +33 -0
- package/server/src/overview.ts +4 -4
- package/server/src/pages.ts +1 -1
- package/server/src/pi.ts +92 -16
- package/server/src/prompt.ts +51 -156
- package/server/src/providers.ts +3 -2
- package/server/src/push.ts +39 -5
- package/server/src/router-activity.ts +6 -0
- package/server/src/router-tools.ts +184 -39
- package/server/src/router.ts +154 -17
- package/server/src/routines.ts +14 -4
- package/server/src/runtime.ts +15 -0
- package/server/src/settings.ts +43 -1
- package/server/src/store.ts +4 -3
- package/server/src/transcript.ts +57 -4
- package/server/src/worker-tools.ts +14 -12
- package/shared/knowledge.ts +92 -0
- package/shared/mcp.ts +91 -0
- package/shared/skills.ts +18 -0
- package/shared/types.ts +104 -20
- package/vendor/claude-bridge/HOB-PATCH.md +10 -0
- package/vendor/claude-bridge/LICENSE +21 -0
- package/vendor/claude-bridge/package.json +62 -0
- package/vendor/claude-bridge/src/agents-md.ts +14 -0
- package/vendor/claude-bridge/src/askclaude-schema.ts +92 -0
- package/vendor/claude-bridge/src/askclaude-ui.ts +90 -0
- package/vendor/claude-bridge/src/attachments.ts +135 -0
- package/vendor/claude-bridge/src/config.ts +105 -0
- package/vendor/claude-bridge/src/convert.ts +222 -0
- package/vendor/claude-bridge/src/extract-tool-results.ts +47 -0
- package/vendor/claude-bridge/src/index.ts +2503 -0
- package/vendor/claude-bridge/src/log-paths.ts +19 -0
- package/vendor/claude-bridge/src/mcp-server.ts +169 -0
- package/vendor/claude-bridge/src/models.ts +164 -0
- package/vendor/claude-bridge/src/prompt-capture.ts +420 -0
- package/vendor/claude-bridge/src/prompt-stream.ts +102 -0
- package/vendor/claude-bridge/src/query-state.ts +118 -0
- package/vendor/claude-bridge/src/rate-limit.ts +48 -0
- package/vendor/claude-bridge/src/session-cwd.ts +38 -0
- package/vendor/claude-bridge/src/session-verify.ts +38 -0
- package/vendor/claude-bridge/src/skills.ts +20 -0
- package/vendor/claude-bridge/src/transcript.ts +86 -0
- package/vendor/claude-bridge/src/usage.ts +53 -0
- package/vendor/lore-pi-extension/package.json +1 -1
- package/vendor/lore-pi-extension/tools.ts +8 -5
- package/dist/web/assets/index-BCGEZvgg.css +0 -1
- package/dist/web/assets/index-BqkIAlk9.js +0 -258
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Approval, Job, JobStatus, JobStep } from "../../shared/types.ts";
|
|
2
|
+
import type { AssistantSkill } from "../../shared/skills.ts";
|
|
3
|
+
|
|
4
|
+
const statusText: Record<JobStatus, string> = { queued: "排队中", running: "进行中", waiting: "等用户确认", done: "已完成", stuck: "受阻", failed: "失败", stopped: "已停止" };
|
|
5
|
+
|
|
6
|
+
export function duration(ms: number): string {
|
|
7
|
+
const seconds = Math.max(0, Math.floor(ms / 1000));
|
|
8
|
+
if (seconds < 60) return `${seconds} 秒`;
|
|
9
|
+
const minutes = Math.floor(seconds / 60);
|
|
10
|
+
return minutes < 60 ? `${minutes} 分钟` : `${Math.floor(minutes / 60)} 小时 ${minutes % 60} 分钟`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** 任务过程按时间倒序,供任务查看和超时通知共用。 */
|
|
14
|
+
export function jobProcessLines(steps: JobStep[], timezone: string, now = new Date()): string[] {
|
|
15
|
+
const visible = steps.filter((step) => step.kind === "tool" || (step.kind === "text" && (step.from === "assistant" || step.from === "user")));
|
|
16
|
+
const format = new Intl.DateTimeFormat("sv-SE", { timeZone: timezone, year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", hour12: false });
|
|
17
|
+
const today = format.format(now).slice(0, 10);
|
|
18
|
+
return visible.reverse().map((step) => {
|
|
19
|
+
const time = format.format(new Date(step.at));
|
|
20
|
+
const clock = time.slice(0, 10) === today ? time.slice(11) : time.slice(5);
|
|
21
|
+
const detail = step.kind === "tool"
|
|
22
|
+
? `${step.title ?? step.name ?? "工具"}${step.running ? ` · 还在跑,${Math.max(0, Math.floor((now.getTime() - Date.parse(step.at)) / 60000))} 分钟` : ""}${step.isError ? " · 出错" : ""}`
|
|
23
|
+
: `${step.from === "user" ? "收到" : "说"}:${step.text ?? ""}`;
|
|
24
|
+
const line = `${clock} ${detail}`.replace(/\s+/g, " ").trim();
|
|
25
|
+
const chars = [...line];
|
|
26
|
+
return chars.length > 160 ? `${chars.slice(0, 159).join("")}…` : line;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function jobView(job: Job, steps: JobStep[], approvals: Approval[], skills: AssistantSkill[], timezone: string, now = new Date()): string {
|
|
31
|
+
const ended = !["queued", "running", "waiting"].includes(job.status);
|
|
32
|
+
const elapsed = Math.max(0, now.getTime() - Date.parse(job.startedAt ?? job.createdAt));
|
|
33
|
+
const state = job.status === "queued" ? "排队中" : ended
|
|
34
|
+
? `${statusText[job.status]},用时 ${duration(job.durationMs ?? (job.endedAt ? Date.parse(job.endedAt) - Date.parse(job.startedAt ?? job.createdAt) : 0))}`
|
|
35
|
+
: `${statusText[job.status]},已运行 ${elapsed < 60000 ? "不到 1 分钟" : `${Math.floor(elapsed / 60000)} 分钟`}`;
|
|
36
|
+
const lines = [`任务「${job.title}」(${job.id}):${state}${job.rounds?.length ? `(第 ${job.rounds.length + 1} 轮)` : ""}`];
|
|
37
|
+
if (job.statusReason) lines.push(`原因:${job.statusReason}`);
|
|
38
|
+
for (const approval of approvals.filter((item) => item.jobId === job.id && item.status === "pending")) lines.push(`在等用户回答:${approval.title}`);
|
|
39
|
+
if (job.skillsUsed?.length) lines.push(`用到的技能:${job.skillsUsed.map((name) => { const skill = skills.find((item) => item.name === name); return skill ? `${skill.title}(第 ${skill.version} 版)` : name; }).join("、")}`);
|
|
40
|
+
if (ended) {
|
|
41
|
+
if (job.summary) {
|
|
42
|
+
const chars = [...job.summary];
|
|
43
|
+
lines.push(chars.length > 1000 ? `结果(共 ${chars.length} 字,全文:${job.reportPath ?? "无"}):${chars.slice(0, 1000).join("")}` : `结果:${job.summary}`);
|
|
44
|
+
}
|
|
45
|
+
if (job.reportPath) lines.push(`报告:${job.reportPath}`);
|
|
46
|
+
}
|
|
47
|
+
if (job.rounds?.length) lines.push(`之前的轮次:${job.rounds.map((round, i) => `第 ${i + 1} 轮 ${statusText[round.status]},用时 ${duration(round.durationMs ?? (round.startedAt && round.endedAt ? Date.parse(round.endedAt) - Date.parse(round.startedAt) : 0))}`).join(";")}`);
|
|
48
|
+
lines.push(`工作目录:${job.cwd ?? "未指定"}`);
|
|
49
|
+
const process = jobProcessLines(steps, timezone, now);
|
|
50
|
+
lines.push(`过程(新的在前,共 ${process.length} 步):`, ...process);
|
|
51
|
+
return lines.join("\n");
|
|
52
|
+
}
|