@agent-spaces/server 0.3.64 → 0.3.65
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/dist/adapters/claude-code-runtime/index.js +68 -2
- package/dist/adapters/claude-code-runtime/message-format.js +26 -0
- package/dist/adapters/claude-code-runtime/sdk-config.js +12 -0
- package/dist/adapters/git.js +13 -6
- package/dist/agents/agent-message-parts.js +1 -1
- package/dist/agents/commit-agent.js +4 -2
- package/dist/agents/issue-task-controller.js +6 -2
- package/dist/app.js +6 -68
- package/dist/routes/agent-sse.js +1 -0
- package/dist/routes/agent.js +3 -0
- package/dist/routes/database.js +1 -0
- package/dist/routes/git.js +197 -317
- package/dist/routes/robot-account.js +68 -0
- package/dist/services/agent.js +36 -2
- package/dist/services/builtin-tools/kanban-tools.js +4 -0
- package/dist/services/git-operation-log.js +40 -0
- package/dist/services/global-wechat-qr.js +72 -0
- package/dist/services/hook-engine.js +175 -17
- package/dist/services/notification-hub/bot-agent.js +3 -1
- package/dist/services/notification-hub/service.js +12 -2
- package/dist/services/robot-account.js +34 -0
- package/dist/services/workspace.js +2 -0
- package/dist/storage/robot-account-store.js +39 -0
- package/dist/web/404.html +1 -1
- package/dist/web/__next.__PAGE__.txt +4 -4
- package/dist/web/__next._full.txt +23 -25
- package/dist/web/__next._head.txt +4 -4
- package/dist/web/__next._index.txt +13 -13
- package/dist/web/__next._tree.txt +2 -2
- package/dist/web/_next/static/chunks/{04a4vsq2wknm4.js → 0-a.-hl3wv99k.js} +1 -1
- package/dist/web/_next/static/chunks/{0ctg5qmw7uu.1.js → 0-pi.67w.ymsr.js} +3 -3
- package/dist/web/_next/static/chunks/0-v_p6j5u3_9l.js +1 -0
- package/dist/web/_next/static/chunks/0.-x29t-8gk0r.js +1 -0
- package/dist/web/_next/static/chunks/0.6b64sy0g5.3.js +3 -0
- package/dist/web/_next/static/chunks/0.l5e8~r7_0~p.js +1 -0
- package/dist/web/_next/static/chunks/00-syqzi-6zxr.js +1 -0
- package/dist/web/_next/static/chunks/02802taez976w.js +67 -0
- package/dist/web/_next/static/chunks/02j4sr9psucf-.js +1 -0
- package/dist/web/_next/static/chunks/033.awk90g6eh.js +1 -0
- package/dist/web/_next/static/chunks/06.kdsa9rr2h1.js +1 -0
- package/dist/web/_next/static/chunks/06si8l0doqe8p.js +1 -0
- package/dist/web/_next/static/chunks/08ugbvzr20drp.js +2 -0
- package/dist/web/_next/static/chunks/{0n6_4so_afuwk.js → 08x85faoz58i7.js} +2 -2
- package/dist/web/_next/static/chunks/{0v3a_x4vt42kx.js → 0_cqojbge48kq.js} +1 -1
- package/dist/web/_next/static/chunks/{0a5y-vhf4i5id.js → 0d6~~lv0-6kex.js} +1 -1
- package/dist/web/_next/static/chunks/{0vbqaynjq8ga..js → 0db14450oqzhg.js} +1 -1
- package/dist/web/_next/static/chunks/0gdwop9cnpmtu.js +1 -0
- package/dist/web/_next/static/chunks/0j-l7l_k9jt45.js +1 -0
- package/dist/web/_next/static/chunks/0kbvoxla7f751.js +1 -0
- package/dist/web/_next/static/chunks/{1442stwa0gbxe.js → 0l2w0qz1ea7ql.js} +2 -2
- package/dist/web/_next/static/chunks/0p3h-h3zj5ujg.js +30 -0
- package/dist/web/_next/static/chunks/0paaat8y96ayc.js +7 -0
- package/dist/web/_next/static/chunks/0pm-un~-sy3rl.js +1 -0
- package/dist/web/_next/static/chunks/0pq318f8xgafg.js +1 -0
- package/dist/web/_next/static/chunks/0t6s8of0qr6nc.js +1 -0
- package/dist/web/_next/static/chunks/0u6h-hqc_i52e.js +1 -0
- package/dist/web/_next/static/chunks/0uxzi~9b~k4mn.js +31 -0
- package/dist/web/_next/static/chunks/{08ckpwmmwlors.js → 0vis~lx0nxgn-.js} +2 -2
- package/dist/web/_next/static/chunks/{10l-9myrdo3x9.js → 0w7.tb29958zj.js} +1 -1
- package/dist/web/_next/static/chunks/0yd.m1afqg.2t.js +3 -0
- package/dist/web/_next/static/chunks/0yhbr8hl09b-5.js +1 -0
- package/dist/web/_next/static/chunks/0zncg76rgtbm-.js +1 -0
- package/dist/web/_next/static/chunks/0~~_ltu6dx_ch.js +1 -0
- package/dist/web/_next/static/chunks/{0iuf30t0rjsjv.js → 11cchuwoupmbf.js} +1 -1
- package/dist/web/_next/static/chunks/12oxcgyhpaxw~.js +1 -0
- package/dist/web/_next/static/chunks/1452eibz62gs6.css +1 -0
- package/dist/web/_next/static/chunks/16zlreiems5cn.js +1 -0
- package/dist/web/_next/static/chunks/18awqjk9-o5m0.js +1 -0
- package/dist/web/_next/static/chunks/18c7g84y01mj0.js +1 -0
- package/dist/web/_next/static/chunks/{turbopack-0ndm2zc_pdptk.js → turbopack-11qjwlynmfc-n.js} +1 -1
- package/dist/web/_not-found/__next._full.txt +30 -29
- package/dist/web/_not-found/__next._head.txt +4 -4
- package/dist/web/_not-found/__next._index.txt +13 -13
- package/dist/web/_not-found/__next._not-found.__PAGE__.txt +2 -2
- package/dist/web/_not-found/__next._not-found.txt +3 -3
- package/dist/web/_not-found/__next._tree.txt +2 -2
- package/dist/web/_not-found.html +1 -1
- package/dist/web/_not-found.txt +30 -29
- package/dist/web/index.html +1 -1
- package/dist/web/index.txt +23 -25
- package/dist/web/login/__next._full.txt +28 -28
- package/dist/web/login/__next._head.txt +4 -4
- package/dist/web/login/__next._index.txt +13 -13
- package/dist/web/login/__next._tree.txt +2 -2
- package/dist/web/login/__next.login.__PAGE__.txt +4 -4
- package/dist/web/login/__next.login.txt +3 -3
- package/dist/web/login.html +1 -1
- package/dist/web/login.txt +28 -28
- package/dist/web/settings/__next._full.txt +33 -32
- package/dist/web/settings/__next._head.txt +4 -4
- package/dist/web/settings/__next._index.txt +13 -13
- package/dist/web/settings/__next._tree.txt +2 -2
- package/dist/web/settings/__next.settings.__PAGE__.txt +4 -4
- package/dist/web/settings/__next.settings.txt +5 -5
- package/dist/web/settings/agents/__next._full.txt +24 -24
- package/dist/web/settings/agents/__next._head.txt +4 -4
- package/dist/web/settings/agents/__next._index.txt +13 -13
- package/dist/web/settings/agents/__next._tree.txt +2 -2
- package/dist/web/settings/agents/__next.settings.agents.__PAGE__.txt +4 -4
- package/dist/web/settings/agents/__next.settings.agents.txt +3 -3
- package/dist/web/settings/agents/__next.settings.txt +5 -5
- package/dist/web/settings/agents.html +1 -1
- package/dist/web/settings/agents.txt +24 -24
- package/dist/web/settings/mcps/__next._full.txt +24 -24
- package/dist/web/settings/mcps/__next._head.txt +4 -4
- package/dist/web/settings/mcps/__next._index.txt +13 -13
- package/dist/web/settings/mcps/__next._tree.txt +2 -2
- package/dist/web/settings/mcps/__next.settings.mcps.__PAGE__.txt +4 -4
- package/dist/web/settings/mcps/__next.settings.mcps.txt +3 -3
- package/dist/web/settings/mcps/__next.settings.txt +5 -5
- package/dist/web/settings/mcps.html +1 -1
- package/dist/web/settings/mcps.txt +24 -24
- package/dist/web/settings/models/__next._full.txt +24 -24
- package/dist/web/settings/models/__next._head.txt +4 -4
- package/dist/web/settings/models/__next._index.txt +13 -13
- package/dist/web/settings/models/__next._tree.txt +2 -2
- package/dist/web/settings/models/__next.settings.models.__PAGE__.txt +4 -4
- package/dist/web/settings/models/__next.settings.models.txt +3 -3
- package/dist/web/settings/models/__next.settings.txt +5 -5
- package/dist/web/settings/models.html +1 -1
- package/dist/web/settings/models.txt +24 -24
- package/dist/web/settings/output-styles/__next._full.txt +24 -24
- package/dist/web/settings/output-styles/__next._head.txt +4 -4
- package/dist/web/settings/output-styles/__next._index.txt +13 -13
- package/dist/web/settings/output-styles/__next._tree.txt +2 -2
- package/dist/web/settings/output-styles/__next.settings.output-styles.__PAGE__.txt +4 -4
- package/dist/web/settings/output-styles/__next.settings.output-styles.txt +3 -3
- package/dist/web/settings/output-styles/__next.settings.txt +5 -5
- package/dist/web/settings/output-styles.html +1 -1
- package/dist/web/settings/output-styles.txt +24 -24
- package/dist/web/settings/prompts/__next._full.txt +24 -24
- package/dist/web/settings/prompts/__next._head.txt +4 -4
- package/dist/web/settings/prompts/__next._index.txt +13 -13
- package/dist/web/settings/prompts/__next._tree.txt +2 -2
- package/dist/web/settings/prompts/__next.settings.prompts.__PAGE__.txt +4 -4
- package/dist/web/settings/prompts/__next.settings.prompts.txt +3 -3
- package/dist/web/settings/prompts/__next.settings.txt +5 -5
- package/dist/web/settings/prompts.html +1 -1
- package/dist/web/settings/prompts.txt +24 -24
- package/dist/web/settings/providers/__next._full.txt +24 -24
- package/dist/web/settings/providers/__next._head.txt +4 -4
- package/dist/web/settings/providers/__next._index.txt +13 -13
- package/dist/web/settings/providers/__next._tree.txt +2 -2
- package/dist/web/settings/providers/__next.settings.providers.__PAGE__.txt +4 -4
- package/dist/web/settings/providers/__next.settings.providers.txt +3 -3
- package/dist/web/settings/providers/__next.settings.txt +5 -5
- package/dist/web/settings/providers.html +1 -1
- package/dist/web/settings/providers.txt +24 -24
- package/dist/web/settings/skills/__next._full.txt +24 -24
- package/dist/web/settings/skills/__next._head.txt +4 -4
- package/dist/web/settings/skills/__next._index.txt +13 -13
- package/dist/web/settings/skills/__next._tree.txt +2 -2
- package/dist/web/settings/skills/__next.settings.skills.__PAGE__.txt +4 -4
- package/dist/web/settings/skills/__next.settings.skills.txt +3 -3
- package/dist/web/settings/skills/__next.settings.txt +5 -5
- package/dist/web/settings/skills.html +1 -1
- package/dist/web/settings/skills.txt +24 -24
- package/dist/web/settings/tools/__next._full.txt +24 -24
- package/dist/web/settings/tools/__next._head.txt +4 -4
- package/dist/web/settings/tools/__next._index.txt +13 -13
- package/dist/web/settings/tools/__next._tree.txt +2 -2
- package/dist/web/settings/tools/__next.settings.tools.__PAGE__.txt +4 -4
- package/dist/web/settings/tools/__next.settings.tools.txt +3 -3
- package/dist/web/settings/tools/__next.settings.txt +5 -5
- package/dist/web/settings/tools.html +1 -1
- package/dist/web/settings/tools.txt +24 -24
- package/dist/web/settings.html +1 -1
- package/dist/web/settings.txt +33 -32
- package/dist/web/workflows/__next._full.txt +31 -33
- package/dist/web/workflows/__next._head.txt +4 -4
- package/dist/web/workflows/__next._index.txt +13 -13
- package/dist/web/workflows/__next._tree.txt +2 -2
- package/dist/web/workflows/__next.workflows.__PAGE__.txt +4 -4
- package/dist/web/workflows/__next.workflows.txt +3 -3
- package/dist/web/workflows.html +1 -1
- package/dist/web/workflows.txt +31 -33
- package/dist/web/workspace/_/__next._full.txt +28 -29
- package/dist/web/workspace/_/__next._head.txt +4 -4
- package/dist/web/workspace/_/__next._index.txt +13 -13
- package/dist/web/workspace/_/__next._tree.txt +2 -2
- package/dist/web/workspace/_/__next.workspace.$d$id.__PAGE__.txt +3 -3
- package/dist/web/workspace/_/__next.workspace.$d$id.txt +3 -3
- package/dist/web/workspace/_/__next.workspace.txt +3 -3
- package/dist/web/workspace/_.html +1 -1
- package/dist/web/workspace/_.txt +28 -29
- package/dist/web/workspaces/__next._full.txt +29 -31
- package/dist/web/workspaces/__next._head.txt +4 -4
- package/dist/web/workspaces/__next._index.txt +13 -13
- package/dist/web/workspaces/__next._tree.txt +2 -2
- package/dist/web/workspaces/__next.workspaces.__PAGE__.txt +4 -4
- package/dist/web/workspaces/__next.workspaces.txt +3 -3
- package/dist/web/workspaces.html +1 -1
- package/dist/web/workspaces.txt +29 -31
- package/dist/ws/agent-runner.js +82 -6
- package/package.json +10 -11
- package/dist/web/_next/static/chunks/0-9194nbxy_6d.js +0 -1
- package/dist/web/_next/static/chunks/02mf61htij8g0.js +0 -31
- package/dist/web/_next/static/chunks/04dg4l4hv11q2.js +0 -3
- package/dist/web/_next/static/chunks/04fxddw-y20~-.js +0 -7
- package/dist/web/_next/static/chunks/04w7~5ooz_pwm.js +0 -1
- package/dist/web/_next/static/chunks/05oc21sj24wtq.js +0 -1
- package/dist/web/_next/static/chunks/08k~meqbd8d6v.js +0 -1
- package/dist/web/_next/static/chunks/099h96wjsdb25.js +0 -2
- package/dist/web/_next/static/chunks/09h23logvq65m.js +0 -1
- package/dist/web/_next/static/chunks/0ake2f3x2uan4.js +0 -24
- package/dist/web/_next/static/chunks/0ck8dw_9-1cdx.js +0 -1
- package/dist/web/_next/static/chunks/0ewceguykiut5.js +0 -1
- package/dist/web/_next/static/chunks/0f7cb9li~3jra.js +0 -67
- package/dist/web/_next/static/chunks/0ghs9on7wodrm.js +0 -1
- package/dist/web/_next/static/chunks/0h9cu-k6z5o08.js +0 -1
- package/dist/web/_next/static/chunks/0jb4~3qqkw2ps.js +0 -1
- package/dist/web/_next/static/chunks/0nb8.iteznuvx.js +0 -1
- package/dist/web/_next/static/chunks/0os58q93stt7j.js +0 -3
- package/dist/web/_next/static/chunks/0ppr271hz0xoq.js +0 -1
- package/dist/web/_next/static/chunks/0s9lmk8iauou3.js +0 -1
- package/dist/web/_next/static/chunks/0sp_zbx~w0am7.js +0 -1
- package/dist/web/_next/static/chunks/0tel~zsv4z8l_.js +0 -1
- package/dist/web/_next/static/chunks/0twamv4wr_dbv.js +0 -1
- package/dist/web/_next/static/chunks/0uhol5wafdbl~.js +0 -1
- package/dist/web/_next/static/chunks/0v7q4mys.mnm..css +0 -1
- package/dist/web/_next/static/chunks/0~3xm80~j9ddg.js +0 -1
- package/dist/web/_next/static/chunks/14s37n6h0_q3x.js +0 -16
- package/dist/web/_next/static/chunks/161ik5kfyuwtd.js +0 -1
- package/dist/web/_next/static/chunks/17k~zbv0_4rep.js +0 -1
- package/public/output-styles/carmack-mode.md +0 -381
- package/public/output-styles/codex-rigor-mode.md +0 -114
- package/public/output-styles/dhh-mode.md +0 -265
- package/public/output-styles/evan-you-mode.md +0 -539
- package/public/output-styles/index.json +0 -37
- package/public/output-styles/jobs-mode.md +0 -369
- package/public/output-styles/linus-mode.md +0 -135
- package/public/output-styles/uncle-bob-mode.md +0 -221
- package/public/prompt/andrej-karpathy-skills.md +0 -65
- package/public/prompt/claude-token-efficient-coding.md +0 -35
- package/public/prompt/index.json +0 -12
- package/public/skills/index.json +0 -92
- package/public/skills/planning-with-files/planning-with-files-zh/SKILL.md +0 -243
- package/public/skills/planning-with-files/planning-with-files-zh/scripts/check-complete.ps1 +0 -44
- package/public/skills/planning-with-files/planning-with-files-zh/scripts/check-complete.sh +0 -46
- package/public/skills/planning-with-files/planning-with-files-zh/scripts/init-session.ps1 +0 -124
- package/public/skills/planning-with-files/planning-with-files-zh/scripts/init-session.sh +0 -124
- package/public/skills/planning-with-files/planning-with-files-zh/scripts/session-catchup.py +0 -438
- package/public/skills/planning-with-files/planning-with-files-zh/templates/findings.md +0 -29
- package/public/skills/planning-with-files/planning-with-files-zh/templates/progress.md +0 -40
- package/public/skills/planning-with-files/planning-with-files-zh/templates/task_plan.md +0 -58
- package/public/skills/superpowers/brainstorming/SKILL.md +0 -164
- package/public/skills/superpowers/brainstorming/scripts/frame-template.html +0 -214
- package/public/skills/superpowers/brainstorming/scripts/helper.js +0 -88
- package/public/skills/superpowers/brainstorming/scripts/server.cjs +0 -354
- package/public/skills/superpowers/brainstorming/scripts/start-server.sh +0 -148
- package/public/skills/superpowers/brainstorming/scripts/stop-server.sh +0 -56
- package/public/skills/superpowers/brainstorming/spec-document-reviewer-prompt.md +0 -49
- package/public/skills/superpowers/brainstorming/visual-companion.md +0 -287
- package/public/skills/superpowers/dispatching-parallel-agents/SKILL.md +0 -182
- package/public/skills/superpowers/executing-plans/SKILL.md +0 -70
- package/public/skills/superpowers/finishing-a-development-branch/SKILL.md +0 -251
- package/public/skills/superpowers/receiving-code-review/SKILL.md +0 -213
- package/public/skills/superpowers/requesting-code-review/SKILL.md +0 -103
- package/public/skills/superpowers/requesting-code-review/code-reviewer.md +0 -168
- package/public/skills/superpowers/subagent-driven-development/SKILL.md +0 -279
- package/public/skills/superpowers/subagent-driven-development/code-quality-reviewer-prompt.md +0 -25
- package/public/skills/superpowers/subagent-driven-development/implementer-prompt.md +0 -113
- package/public/skills/superpowers/subagent-driven-development/spec-reviewer-prompt.md +0 -61
- package/public/skills/superpowers/systematic-debugging/CREATION-LOG.md +0 -119
- package/public/skills/superpowers/systematic-debugging/SKILL.md +0 -296
- package/public/skills/superpowers/systematic-debugging/condition-based-waiting-example.ts +0 -158
- package/public/skills/superpowers/systematic-debugging/condition-based-waiting.md +0 -115
- package/public/skills/superpowers/systematic-debugging/defense-in-depth.md +0 -122
- package/public/skills/superpowers/systematic-debugging/find-polluter.sh +0 -63
- package/public/skills/superpowers/systematic-debugging/root-cause-tracing.md +0 -169
- package/public/skills/superpowers/systematic-debugging/test-academic.md +0 -14
- package/public/skills/superpowers/systematic-debugging/test-pressure-1.md +0 -58
- package/public/skills/superpowers/systematic-debugging/test-pressure-2.md +0 -68
- package/public/skills/superpowers/systematic-debugging/test-pressure-3.md +0 -69
- package/public/skills/superpowers/test-driven-development/SKILL.md +0 -371
- package/public/skills/superpowers/test-driven-development/testing-anti-patterns.md +0 -299
- package/public/skills/superpowers/using-git-worktrees/SKILL.md +0 -215
- package/public/skills/superpowers/using-superpowers/SKILL.md +0 -117
- package/public/skills/superpowers/using-superpowers/references/codex-tools.md +0 -59
- package/public/skills/superpowers/using-superpowers/references/copilot-tools.md +0 -42
- package/public/skills/superpowers/using-superpowers/references/gemini-tools.md +0 -51
- package/public/skills/superpowers/verification-before-completion/SKILL.md +0 -139
- package/public/skills/superpowers/writing-plans/SKILL.md +0 -152
- package/public/skills/superpowers/writing-plans/plan-document-reviewer-prompt.md +0 -49
- package/public/skills/superpowers/writing-skills/SKILL.md +0 -655
- package/public/skills/superpowers/writing-skills/anthropic-best-practices.md +0 -1150
- package/public/skills/superpowers/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -189
- package/public/skills/superpowers/writing-skills/graphviz-conventions.dot +0 -172
- package/public/skills/superpowers/writing-skills/persuasion-principles.md +0 -187
- package/public/skills/superpowers/writing-skills/render-graphs.js +0 -168
- package/public/skills/superpowers/writing-skills/testing-skills-with-subagents.md +0 -384
- /package/dist/web/_next/static/{e8w3vd9Eov_LDYWj_0zsE → x4-CsKe6qUQyFDWVtfvUg}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{e8w3vd9Eov_LDYWj_0zsE → x4-CsKe6qUQyFDWVtfvUg}/_clientMiddlewareManifest.js +0 -0
- /package/dist/web/_next/static/{e8w3vd9Eov_LDYWj_0zsE → x4-CsKe6qUQyFDWVtfvUg}/_ssgManifest.js +0 -0
package/dist/routes/git.js
CHANGED
|
@@ -1,325 +1,205 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import { gitStatus, gitDiff, gitLog, gitCommit, gitDiscard, gitDiscardAll, gitBranches, gitCheckout, gitInit, gitGenerateCommitMsg, gitPush, gitPull, gitFetch, gitGetRemotes, gitAddRemote, gitCheckoutDetached, gitCherryPick, gitCreateBranch, gitDeleteBranch, gitCreateTag, gitCommitDiff, gitGetRemoteUrl, gitMergeBase, gitGetConfig, gitSetConfig, gitStage, gitUnstage, gitResolveFile } from '../adapters/git.js';
|
|
3
|
+
import { logGitOperation, getGitOperations } from '../services/git-operation-log.js';
|
|
3
4
|
const router = Router({ mergeParams: true });
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
13
|
-
router.get('/diff', async (req, res) => {
|
|
14
|
-
try {
|
|
15
|
-
const filePath = req.query.path;
|
|
16
|
-
const result = await gitDiff(req.params.id, filePath);
|
|
17
|
-
res.json(result);
|
|
18
|
-
}
|
|
19
|
-
catch (err) {
|
|
20
|
-
res.status(500).json({ error: err.message });
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
router.get('/log', async (req, res) => {
|
|
24
|
-
try {
|
|
25
|
-
const maxCount = parseInt(req.query.maxCount) || 50;
|
|
26
|
-
const result = await gitLog(req.params.id, maxCount);
|
|
27
|
-
res.json(result);
|
|
28
|
-
}
|
|
29
|
-
catch (err) {
|
|
30
|
-
res.status(500).json({ error: err.message });
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
router.post('/commit', async (req, res) => {
|
|
34
|
-
try {
|
|
35
|
-
const { message } = req.body;
|
|
36
|
-
if (!message) {
|
|
37
|
-
res.status(400).json({ error: 'message is required' });
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const result = await gitCommit(req.params.id, message);
|
|
41
|
-
res.json(result);
|
|
42
|
-
}
|
|
43
|
-
catch (err) {
|
|
44
|
-
res.status(500).json({ error: err.message });
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
router.post('/discard', async (req, res) => {
|
|
48
|
-
try {
|
|
49
|
-
const { path } = req.body;
|
|
50
|
-
if (!path) {
|
|
51
|
-
res.status(400).json({ error: 'path is required' });
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
await gitDiscard(req.params.id, path);
|
|
55
|
-
res.json({ ok: true });
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
res.status(500).json({ error: err.message });
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
router.post('/discard-all', async (req, res) => {
|
|
62
|
-
try {
|
|
63
|
-
await gitDiscardAll(req.params.id);
|
|
64
|
-
res.json({ ok: true });
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
res.status(500).json({ error: err.message });
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
router.post('/stage', async (req, res) => {
|
|
71
|
-
try {
|
|
72
|
-
const { path } = req.body;
|
|
73
|
-
if (!path) {
|
|
74
|
-
res.status(400).json({ error: 'path is required' });
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
await gitStage(req.params.id, path);
|
|
78
|
-
res.json({ ok: true });
|
|
79
|
-
}
|
|
80
|
-
catch (err) {
|
|
81
|
-
res.status(500).json({ error: err.message });
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
router.post('/unstage', async (req, res) => {
|
|
85
|
-
try {
|
|
86
|
-
const { path } = req.body;
|
|
87
|
-
if (!path) {
|
|
88
|
-
res.status(400).json({ error: 'path is required' });
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
await gitUnstage(req.params.id, path);
|
|
92
|
-
res.json({ ok: true });
|
|
93
|
-
}
|
|
94
|
-
catch (err) {
|
|
95
|
-
res.status(500).json({ error: err.message });
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
router.post('/resolve-file', async (req, res) => {
|
|
99
|
-
try {
|
|
100
|
-
const { path, content, stage } = req.body;
|
|
101
|
-
if (!path || typeof content !== 'string') {
|
|
102
|
-
res.status(400).json({ error: 'path and content are required' });
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
await gitResolveFile(req.params.id, path, content, stage !== false);
|
|
106
|
-
res.json({ ok: true });
|
|
107
|
-
}
|
|
108
|
-
catch (err) {
|
|
109
|
-
res.status(500).json({ error: err.message });
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
router.get('/branches', async (req, res) => {
|
|
113
|
-
try {
|
|
114
|
-
const result = await gitBranches(req.params.id);
|
|
115
|
-
res.json(result);
|
|
116
|
-
}
|
|
117
|
-
catch (err) {
|
|
118
|
-
res.status(500).json({ error: err.message });
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
router.post('/checkout', async (req, res) => {
|
|
122
|
-
try {
|
|
123
|
-
const { branch } = req.body;
|
|
124
|
-
if (!branch) {
|
|
125
|
-
res.status(400).json({ error: 'branch is required' });
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
await gitCheckout(req.params.id, branch);
|
|
129
|
-
res.json({ ok: true });
|
|
130
|
-
}
|
|
131
|
-
catch (err) {
|
|
132
|
-
res.status(500).json({ error: err.message });
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
router.post('/init', async (req, res) => {
|
|
136
|
-
try {
|
|
137
|
-
await gitInit(req.params.id);
|
|
138
|
-
res.json({ ok: true });
|
|
139
|
-
}
|
|
140
|
-
catch (err) {
|
|
141
|
-
res.status(500).json({ error: err.message });
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
router.post('/generate-commit-message', async (req, res) => {
|
|
145
|
-
try {
|
|
146
|
-
const message = await gitGenerateCommitMsg(req.params.id);
|
|
147
|
-
res.json({ message });
|
|
148
|
-
}
|
|
149
|
-
catch (err) {
|
|
150
|
-
res.status(500).json({ error: err.message });
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
router.post('/fetch', async (req, res) => {
|
|
154
|
-
try {
|
|
155
|
-
await gitFetch(req.params.id);
|
|
156
|
-
res.json({ ok: true });
|
|
157
|
-
}
|
|
158
|
-
catch (err) {
|
|
159
|
-
res.status(500).json({ error: err.message });
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
router.post('/push', async (req, res) => {
|
|
163
|
-
try {
|
|
164
|
-
await gitPush(req.params.id);
|
|
165
|
-
res.json({ ok: true });
|
|
166
|
-
}
|
|
167
|
-
catch (err) {
|
|
168
|
-
res.status(500).json({ error: err.message });
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
router.post('/pull', async (req, res) => {
|
|
172
|
-
try {
|
|
173
|
-
await gitPull(req.params.id);
|
|
174
|
-
res.json({ ok: true });
|
|
175
|
-
}
|
|
176
|
-
catch (err) {
|
|
177
|
-
res.status(500).json({ error: err.message });
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
router.get('/remotes', async (req, res) => {
|
|
181
|
-
try {
|
|
182
|
-
const remotes = await gitGetRemotes(req.params.id);
|
|
183
|
-
res.json(remotes);
|
|
184
|
-
}
|
|
185
|
-
catch (err) {
|
|
186
|
-
res.status(500).json({ error: err.message });
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
router.post('/remotes', async (req, res) => {
|
|
190
|
-
try {
|
|
191
|
-
const { name, url } = req.body;
|
|
192
|
-
if (!name || !url) {
|
|
193
|
-
res.status(400).json({ error: 'name and url are required' });
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
await gitAddRemote(req.params.id, name, url);
|
|
197
|
-
res.json({ ok: true });
|
|
198
|
-
}
|
|
199
|
-
catch (err) {
|
|
200
|
-
res.status(500).json({ error: err.message });
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
router.post('/checkout-detached', async (req, res) => {
|
|
204
|
-
try {
|
|
205
|
-
const { commitHash } = req.body;
|
|
206
|
-
if (!commitHash) {
|
|
207
|
-
res.status(400).json({ error: 'commitHash is required' });
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
await gitCheckoutDetached(req.params.id, commitHash);
|
|
211
|
-
res.json({ ok: true });
|
|
212
|
-
}
|
|
213
|
-
catch (err) {
|
|
214
|
-
res.status(500).json({ error: err.message });
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
router.post('/cherry-pick', async (req, res) => {
|
|
218
|
-
try {
|
|
219
|
-
const { commitHash } = req.body;
|
|
220
|
-
if (!commitHash) {
|
|
221
|
-
res.status(400).json({ error: 'commitHash is required' });
|
|
222
|
-
return;
|
|
5
|
+
function withLog(operation, inputFn, handler) {
|
|
6
|
+
return async (req, res) => {
|
|
7
|
+
const input = inputFn(req);
|
|
8
|
+
const start = Date.now();
|
|
9
|
+
try {
|
|
10
|
+
await handler(req, res);
|
|
11
|
+
const ok = res.statusCode < 400;
|
|
12
|
+
logGitOperation(req.params.id, operation, input, ok ? { ok: true } : { statusCode: res.statusCode }, ok ? undefined : 'request validation failed', Date.now() - start);
|
|
223
13
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
res.status(500).json({ error: err.message });
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
router.post('/create-branch', async (req, res) => {
|
|
232
|
-
try {
|
|
233
|
-
const { name, startPoint } = req.body;
|
|
234
|
-
if (!name) {
|
|
235
|
-
res.status(400).json({ error: 'name is required' });
|
|
236
|
-
return;
|
|
14
|
+
catch (err) {
|
|
15
|
+
logGitOperation(req.params.id, operation, input, undefined, err.message, Date.now() - start);
|
|
16
|
+
if (!res.headersSent)
|
|
17
|
+
res.status(500).json({ error: err.message });
|
|
237
18
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
})
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
})
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
router.get('/status', withLog('status', () => ({}), async (req, res) => {
|
|
22
|
+
const result = await gitStatus(req.params.id);
|
|
23
|
+
res.json(result);
|
|
24
|
+
}));
|
|
25
|
+
router.get('/diff', withLog('diff', (req) => ({ path: req.query.path }), async (req, res) => {
|
|
26
|
+
const filePath = req.query.path;
|
|
27
|
+
const result = await gitDiff(req.params.id, filePath);
|
|
28
|
+
res.json(result);
|
|
29
|
+
}));
|
|
30
|
+
router.get('/log', withLog('log', (req) => ({ maxCount: req.query.maxCount }), async (req, res) => {
|
|
31
|
+
const maxCount = parseInt(req.query.maxCount) || 50;
|
|
32
|
+
const result = await gitLog(req.params.id, maxCount);
|
|
33
|
+
res.json(result);
|
|
34
|
+
}));
|
|
35
|
+
router.post('/commit', withLog('commit', (req) => ({ message: req.body?.message }), async (req, res) => {
|
|
36
|
+
const { message } = req.body;
|
|
37
|
+
if (!message) {
|
|
38
|
+
res.status(400).json({ error: 'message is required' });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const result = await gitCommit(req.params.id, message);
|
|
42
|
+
res.json(result);
|
|
43
|
+
}));
|
|
44
|
+
router.post('/discard', withLog('discard', (req) => ({ path: req.body?.path }), async (req, res) => {
|
|
45
|
+
const { path } = req.body;
|
|
46
|
+
if (!path) {
|
|
47
|
+
res.status(400).json({ error: 'path is required' });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
await gitDiscard(req.params.id, path);
|
|
51
|
+
res.json({ ok: true });
|
|
52
|
+
}));
|
|
53
|
+
router.post('/discard-all', withLog('discard-all', () => ({}), async (req, res) => {
|
|
54
|
+
await gitDiscardAll(req.params.id);
|
|
55
|
+
res.json({ ok: true });
|
|
56
|
+
}));
|
|
57
|
+
router.post('/stage', withLog('stage', (req) => ({ path: req.body?.path }), async (req, res) => {
|
|
58
|
+
const { path } = req.body;
|
|
59
|
+
if (!path) {
|
|
60
|
+
res.status(400).json({ error: 'path is required' });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
await gitStage(req.params.id, path);
|
|
64
|
+
res.json({ ok: true });
|
|
65
|
+
}));
|
|
66
|
+
router.post('/unstage', withLog('unstage', (req) => ({ path: req.body?.path }), async (req, res) => {
|
|
67
|
+
const { path } = req.body;
|
|
68
|
+
if (!path) {
|
|
69
|
+
res.status(400).json({ error: 'path is required' });
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
await gitUnstage(req.params.id, path);
|
|
73
|
+
res.json({ ok: true });
|
|
74
|
+
}));
|
|
75
|
+
router.post('/resolve-file', withLog('resolve-file', (req) => ({ path: req.body?.path }), async (req, res) => {
|
|
76
|
+
const { path, content, stage } = req.body;
|
|
77
|
+
if (!path || typeof content !== 'string') {
|
|
78
|
+
res.status(400).json({ error: 'path and content are required' });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
await gitResolveFile(req.params.id, path, content, stage !== false);
|
|
82
|
+
res.json({ ok: true });
|
|
83
|
+
}));
|
|
84
|
+
router.get('/branches', withLog('branches', () => ({}), async (req, res) => {
|
|
85
|
+
const result = await gitBranches(req.params.id);
|
|
86
|
+
res.json(result);
|
|
87
|
+
}));
|
|
88
|
+
router.post('/checkout', withLog('checkout', (req) => ({ branch: req.body?.branch }), async (req, res) => {
|
|
89
|
+
const { branch } = req.body;
|
|
90
|
+
if (!branch) {
|
|
91
|
+
res.status(400).json({ error: 'branch is required' });
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
await gitCheckout(req.params.id, branch);
|
|
95
|
+
res.json({ ok: true });
|
|
96
|
+
}));
|
|
97
|
+
router.post('/init', withLog('init', () => ({}), async (req, res) => {
|
|
98
|
+
await gitInit(req.params.id);
|
|
99
|
+
res.json({ ok: true });
|
|
100
|
+
}));
|
|
101
|
+
router.post('/generate-commit-message', withLog('generate-commit-message', () => ({}), async (req, res) => {
|
|
102
|
+
const message = await gitGenerateCommitMsg(req.params.id);
|
|
103
|
+
res.json({ message });
|
|
104
|
+
}));
|
|
105
|
+
router.post('/fetch', withLog('fetch', () => ({}), async (req, res) => {
|
|
106
|
+
await gitFetch(req.params.id);
|
|
107
|
+
res.json({ ok: true });
|
|
108
|
+
}));
|
|
109
|
+
router.post('/push', withLog('push', () => ({}), async (req, res) => {
|
|
110
|
+
await gitPush(req.params.id);
|
|
111
|
+
res.json({ ok: true });
|
|
112
|
+
}));
|
|
113
|
+
router.post('/pull', withLog('pull', () => ({}), async (req, res) => {
|
|
114
|
+
await gitPull(req.params.id);
|
|
115
|
+
res.json({ ok: true });
|
|
116
|
+
}));
|
|
117
|
+
router.get('/remotes', withLog('remotes', () => ({}), async (req, res) => {
|
|
118
|
+
const remotes = await gitGetRemotes(req.params.id);
|
|
119
|
+
res.json(remotes);
|
|
120
|
+
}));
|
|
121
|
+
router.post('/remotes', withLog('add-remote', (req) => ({ name: req.body?.name, url: req.body?.url }), async (req, res) => {
|
|
122
|
+
const { name, url } = req.body;
|
|
123
|
+
if (!name || !url) {
|
|
124
|
+
res.status(400).json({ error: 'name and url are required' });
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
await gitAddRemote(req.params.id, name, url);
|
|
128
|
+
res.json({ ok: true });
|
|
129
|
+
}));
|
|
130
|
+
router.post('/checkout-detached', withLog('checkout-detached', (req) => ({ commitHash: req.body?.commitHash }), async (req, res) => {
|
|
131
|
+
const { commitHash } = req.body;
|
|
132
|
+
if (!commitHash) {
|
|
133
|
+
res.status(400).json({ error: 'commitHash is required' });
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
await gitCheckoutDetached(req.params.id, commitHash);
|
|
137
|
+
res.json({ ok: true });
|
|
138
|
+
}));
|
|
139
|
+
router.post('/cherry-pick', withLog('cherry-pick', (req) => ({ commitHash: req.body?.commitHash }), async (req, res) => {
|
|
140
|
+
const { commitHash } = req.body;
|
|
141
|
+
if (!commitHash) {
|
|
142
|
+
res.status(400).json({ error: 'commitHash is required' });
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
await gitCherryPick(req.params.id, commitHash);
|
|
146
|
+
res.json({ ok: true });
|
|
147
|
+
}));
|
|
148
|
+
router.post('/create-branch', withLog('create-branch', (req) => ({ name: req.body?.name, startPoint: req.body?.startPoint }), async (req, res) => {
|
|
149
|
+
const { name, startPoint } = req.body;
|
|
150
|
+
if (!name) {
|
|
151
|
+
res.status(400).json({ error: 'name is required' });
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
await gitCreateBranch(req.params.id, name, startPoint);
|
|
155
|
+
res.json({ ok: true });
|
|
156
|
+
}));
|
|
157
|
+
router.post('/delete-branch', withLog('delete-branch', (req) => ({ name: req.body?.name, force: req.body?.force }), async (req, res) => {
|
|
158
|
+
const { name, force } = req.body;
|
|
159
|
+
if (!name) {
|
|
160
|
+
res.status(400).json({ error: 'name is required' });
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
await gitDeleteBranch(req.params.id, name, force);
|
|
164
|
+
res.json({ ok: true });
|
|
165
|
+
}));
|
|
166
|
+
router.post('/create-tag', withLog('create-tag', (req) => ({ name: req.body?.name, commitHash: req.body?.commitHash }), async (req, res) => {
|
|
167
|
+
const { name, commitHash } = req.body;
|
|
168
|
+
if (!name) {
|
|
169
|
+
res.status(400).json({ error: 'name is required' });
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
await gitCreateTag(req.params.id, name, commitHash);
|
|
173
|
+
res.json({ ok: true });
|
|
174
|
+
}));
|
|
175
|
+
router.get('/commit-diff', withLog('commit-diff', (req) => ({ hash: req.query.hash }), async (req, res) => {
|
|
176
|
+
const hash = req.query.hash;
|
|
177
|
+
if (!hash) {
|
|
178
|
+
res.status(400).json({ error: 'hash is required' });
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const diffs = await gitCommitDiff(req.params.id, hash);
|
|
182
|
+
res.json(diffs);
|
|
183
|
+
}));
|
|
184
|
+
router.get('/remote-url', withLog('remote-url', () => ({}), async (req, res) => {
|
|
185
|
+
const url = await gitGetRemoteUrl(req.params.id);
|
|
186
|
+
res.json({ url });
|
|
187
|
+
}));
|
|
188
|
+
router.get('/merge-base', withLog('merge-base', () => ({}), async (req, res) => {
|
|
189
|
+
const hash = await gitMergeBase(req.params.id);
|
|
190
|
+
res.json({ hash });
|
|
191
|
+
}));
|
|
192
|
+
router.get('/config', withLog('config.get', () => ({}), async (req, res) => {
|
|
193
|
+
const config = await gitGetConfig('local', req.params.id);
|
|
194
|
+
res.json(config);
|
|
195
|
+
}));
|
|
196
|
+
router.post('/config', withLog('config.set', (req) => ({ name: req.body?.name, email: req.body?.email, proxy: req.body?.proxy }), async (req, res) => {
|
|
197
|
+
const { name, email, proxy } = req.body;
|
|
198
|
+
await gitSetConfig('local', { name, email, proxy }, req.params.id);
|
|
199
|
+
res.json({ ok: true });
|
|
200
|
+
}));
|
|
201
|
+
router.get('/operations', (req, res) => {
|
|
202
|
+
res.json(getGitOperations(req.params.id));
|
|
323
203
|
});
|
|
324
204
|
export default router;
|
|
325
205
|
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import { listRobotAccounts, createAccount, updateAccount, deleteRobotAccount } from '../services/robot-account.js';
|
|
3
|
+
import { getGlobalWeChatQRCode, pollGlobalWeChatQRCode } from '../services/global-wechat-qr.js';
|
|
4
|
+
const router = Router();
|
|
5
|
+
router.get('/', (_req, res) => {
|
|
6
|
+
res.json(listRobotAccounts());
|
|
7
|
+
});
|
|
8
|
+
router.post('/', (req, res) => {
|
|
9
|
+
const { name, type, lark, wechat } = req.body;
|
|
10
|
+
if (!name || !type) {
|
|
11
|
+
res.status(400).json({ error: 'name and type are required' });
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (!['lark', 'wechat'].includes(type)) {
|
|
15
|
+
res.status(400).json({ error: 'type must be lark or wechat' });
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (type === 'lark' && (!lark?.appId || !lark?.appSecret)) {
|
|
19
|
+
res.status(400).json({ error: 'lark.appId and lark.appSecret are required' });
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (type === 'wechat' && (!wechat?.token || !wechat?.accountId)) {
|
|
23
|
+
res.status(400).json({ error: 'wechat.token and wechat.accountId are required' });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const account = createAccount({ name, type, lark, wechat });
|
|
27
|
+
res.status(201).json(account);
|
|
28
|
+
});
|
|
29
|
+
router.put('/:id', (req, res) => {
|
|
30
|
+
const { id } = req.params;
|
|
31
|
+
const { name, lark, wechat } = req.body;
|
|
32
|
+
const updated = updateAccount(id, { name, lark, wechat });
|
|
33
|
+
if (!updated) {
|
|
34
|
+
res.status(404).json({ error: 'Not found' });
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
res.json(updated);
|
|
38
|
+
});
|
|
39
|
+
router.delete('/:id', (req, res) => {
|
|
40
|
+
const deleted = deleteRobotAccount(req.params.id);
|
|
41
|
+
if (!deleted) {
|
|
42
|
+
res.status(404).json({ error: 'Not found' });
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
res.json({ ok: true });
|
|
46
|
+
});
|
|
47
|
+
// Global WeChat QR login (not bound to a workspace)
|
|
48
|
+
router.post('/wechat/qr', async (_req, res) => {
|
|
49
|
+
try {
|
|
50
|
+
const result = await getGlobalWeChatQRCode();
|
|
51
|
+
res.json(result);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
res.status(400).json({ error: err instanceof Error ? err.message : 'Failed to get WeChat QR code' });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
router.post('/wechat/qr/poll', async (req, res) => {
|
|
58
|
+
try {
|
|
59
|
+
const { sessionId } = req.body;
|
|
60
|
+
const result = await pollGlobalWeChatQRCode(sessionId);
|
|
61
|
+
res.json(result);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
res.status(400).json({ error: err instanceof Error ? err.message : 'Failed to poll WeChat QR status' });
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
export default router;
|
|
68
|
+
//# sourceMappingURL=robot-account.js.map
|
package/dist/services/agent.js
CHANGED
|
@@ -3,7 +3,7 @@ import { copyFileSync, cpSync, existsSync, readFileSync, readdirSync, rmSync, st
|
|
|
3
3
|
import { basename, extname, isAbsolute, join, normalize, relative } from 'node:path';
|
|
4
4
|
import { BUILT_IN_AGENT_TOOLS } from '@agent-spaces/shared';
|
|
5
5
|
import { listAgentSessions, getAgentSession, createAgentSession, updateAgentSession, deleteAgentSession, getAgentUsageDashboard, recordAgentUsage, } from '../storage/agent-store.js';
|
|
6
|
-
import { getWorkspace } from '../storage/workspace-store.js';
|
|
6
|
+
import { getWorkspace, listWorkspaces } from '../storage/workspace-store.js';
|
|
7
7
|
import { listIssues, updateIssue } from '../storage/issue-store.js';
|
|
8
8
|
import { listChannels, updateChannel } from './channel.js';
|
|
9
9
|
import { ensureDir, getDataDir } from '../storage/json-store.js';
|
|
@@ -13,6 +13,7 @@ export const AGENT_GENERATOR_PRESET_ID = 'agent-generator';
|
|
|
13
13
|
export const AGENT_COMMIT_PRESET_ID = 'commit-agent';
|
|
14
14
|
const VALID_RUNTIME_KINDS = ['open-agent-sdk', 'claude-code', 'codex', 'langchain'];
|
|
15
15
|
const VALID_TOOL_NAMES = new Set(BUILT_IN_AGENT_TOOLS.map((tool) => tool.name));
|
|
16
|
+
const CLAUDE_BUILT_IN_DIRS = ['agents', 'commands'];
|
|
16
17
|
const ANTHROPIC_BRIDGE_PROVIDERS = [
|
|
17
18
|
'openai-responses-to-anthropic-messages',
|
|
18
19
|
'openai-chat-completions-to-anthropic-messages',
|
|
@@ -338,6 +339,20 @@ export function getAgentConfigDir(workspaceId, preset) {
|
|
|
338
339
|
ensureWorkspaceAgentCopy(preset, ws.agentspaceDir);
|
|
339
340
|
return workspaceAgentDir;
|
|
340
341
|
}
|
|
342
|
+
export function syncTemplatesToAllWorkspaces() {
|
|
343
|
+
const templates = listTemplates().filter((template) => existsSync(getGlobalAgentTemplateDir(template.id)));
|
|
344
|
+
const workspaces = listWorkspaces();
|
|
345
|
+
let agents = 0;
|
|
346
|
+
for (const workspace of workspaces) {
|
|
347
|
+
if (!workspace.agentspaceDir)
|
|
348
|
+
continue;
|
|
349
|
+
for (const template of templates) {
|
|
350
|
+
writeWorkspaceAgentCopy(template, workspace.agentspaceDir);
|
|
351
|
+
agents++;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return { workspaces: workspaces.length, agents };
|
|
355
|
+
}
|
|
341
356
|
export function getAvailableSkillNames(agentDir, skills) {
|
|
342
357
|
if (!agentDir || !Array.isArray(skills))
|
|
343
358
|
return [];
|
|
@@ -541,10 +556,29 @@ function writeWorkspaceAgentCopy(preset, agentspaceDir) {
|
|
|
541
556
|
function ensureWorkspaceAgentCopy(preset, agentspaceDir) {
|
|
542
557
|
const workspaceAgentDir = getWorkspaceAgentDir(agentspaceDir, preset.id);
|
|
543
558
|
const requiredFiles = ['agent.json', 'mcp.json'];
|
|
544
|
-
|
|
559
|
+
const sourceDir = getGlobalAgentTemplateDir(preset.id);
|
|
560
|
+
const missingRequiredFile = requiredFiles.some((file) => !existsSync(join(workspaceAgentDir, file)));
|
|
561
|
+
const missingBuiltInDir = CLAUDE_BUILT_IN_DIRS.some((dir) => {
|
|
562
|
+
const sourceBuiltInDir = join(sourceDir, dir);
|
|
563
|
+
const targetBuiltInDir = join(workspaceAgentDir, dir);
|
|
564
|
+
return existsSync(sourceBuiltInDir)
|
|
565
|
+
&& statSync(sourceBuiltInDir).isDirectory()
|
|
566
|
+
&& countFiles(sourceBuiltInDir) > countFiles(targetBuiltInDir);
|
|
567
|
+
});
|
|
568
|
+
if (!missingRequiredFile && !missingBuiltInDir)
|
|
545
569
|
return;
|
|
546
570
|
writeWorkspaceAgentCopy(preset, agentspaceDir);
|
|
547
571
|
}
|
|
572
|
+
function countFiles(dir) {
|
|
573
|
+
if (!existsSync(dir) || !statSync(dir).isDirectory())
|
|
574
|
+
return 0;
|
|
575
|
+
return readdirSync(dir, { withFileTypes: true }).reduce((count, entry) => {
|
|
576
|
+
const fullPath = join(dir, entry.name);
|
|
577
|
+
if (entry.isDirectory())
|
|
578
|
+
return count + countFiles(fullPath);
|
|
579
|
+
return entry.isFile() ? count + 1 : count;
|
|
580
|
+
}, 0);
|
|
581
|
+
}
|
|
548
582
|
export function readAgentTemplate(agentId) {
|
|
549
583
|
const filePath = join(getGlobalAgentTemplateDir(agentId), 'agent.json');
|
|
550
584
|
if (!existsSync(filePath)) {
|