@marktrue/dsh-mobile-remote 3.2.4-alpha.13 → 3.2.4-alpha.14
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/CHANGELOG.md +29 -0
- package/docs/03-api.md +17 -11
- package/lib/endpoint-registry.js +17 -11
- package/lib/git-read-bundled-provider.js +8 -4
- package/lib/git-read-service.js +177 -31
- package/lib/index.js +80 -12
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v3.2.4-alpha.14(build 46,issues #83 / #84 / #85 / #86 / #88)— 交互修复与分支图上限
|
|
4
|
+
|
|
5
|
+
> 插件 `3.2.4-alpha.14` / App `3.2.4+46` / 载体 `3.2.4-alpha.14-app`。
|
|
6
|
+
|
|
7
|
+
### Git 分支图上限(#86)
|
|
8
|
+
|
|
9
|
+
- 新增 **5 / 10 / 不限** 三档(默认 5,设置页全局偏好);筛选面板显示已选/上限,达上限一键改档;降档保留前 N + 提示;
|
|
10
|
+
- 服务端 `GET /git/graph` 保留 1–32 tips,新增 **POST `/git/graph` 1–128 tips**;capability `graphTips:{max:128,getMax:32}`,旧宿主回退 5/5;
|
|
11
|
+
- HEAD 200 不建快照;批量 tips 解析;25s absolute deadline + 504;snapshot 生命周期(已交付 timeout 保留 TTL、同 cursor 可重试、真 stale 才 409);POST body 256KiB/name 1024B → 413;
|
|
12
|
+
- App GET/POST 阈值、URL 预算、431→POST 回退、分页 504 保留整图 + 页级重试;各档 `min(档位, host max)`;>128 事前阻止;全选 union 仅当前搜索 + 即时反馈;
|
|
13
|
+
- 16 色 palette;不持久化已选分支(退出重置,已确认)。
|
|
14
|
+
|
|
15
|
+
### 交互修复
|
|
16
|
+
|
|
17
|
+
- **行内绝对路径预览(#83/PR #50)**:未命中本轮记录时,绝对路径可点;确认后按 `/api/files` 打开,取消/复制不读取;
|
|
18
|
+
- **待上传图片预览(#85/PR #52)**:点击缩略图全屏预览,多图页码/缩放/关闭;
|
|
19
|
+
- **活动条真实可见性(#84/PR #55)**:只有过程工具行与视口相交才去重;分批/手收组/离屏时保留运行提醒;
|
|
20
|
+
- **绝对路径精确匹配(#88/PR #54)**:不再用唯一 basename 误打开另一条记录;相对路径兜底保持。
|
|
21
|
+
|
|
22
|
+
### 文档
|
|
23
|
+
|
|
24
|
+
- ADR 0009/0005、docs/03-api §6.19、mobile-git 同步 POST graph/capability/413/504/431 与选择集语义。
|
|
25
|
+
|
|
26
|
+
### 验证
|
|
27
|
+
|
|
28
|
+
- flutter test **1295 全绿**;analyze 0 error/warning;timeline-contract 179;account-usage 15/15;Kotlin PASS;
|
|
29
|
+
- reviewer 独立真实 service 场景与 #84 负向变异通过;真机 5/10/不限、大仓库、320/深色待本版验收。
|
|
30
|
+
|
|
31
|
+
|
|
3
32
|
## v3.2.4-alpha.13(build 45,issues #80 / #81)— 轮次导航手势与窄屏可读性
|
|
4
33
|
|
|
5
34
|
> 插件 `3.2.4-alpha.13` / App `3.2.4+45` / 载体 `3.2.4-alpha.13-app`。
|
package/docs/03-api.md
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
| GET | `/m/api/changes/summary` | 本轮改动文件摘要(按轮查询,宿主内存态,v3.3) | 是 |
|
|
50
50
|
| GET | `/m/api/changes/diff` | 本轮单文件对比(最小闭环 diff,v3.3) | 是 |
|
|
51
51
|
| GET | `/m/api/turn-file` | 按轮末记录坐标读取文件(预览/下载,v3.3) | 是 |
|
|
52
|
-
|
|
|
52
|
+
| GET/POST | `/m/api/git/*` | Git 只读/写接口(v3.3 已实现,见「Git API」节) | 是 |
|
|
53
53
|
| GET | `/m/api/balance` | DeepSeek 官方余额 | 是 |
|
|
54
54
|
| GET | `/m/api/account-usage` | 用量与额度(DeepSeek / Codex / OpenCode Go) | 是 |
|
|
55
55
|
| GET | `/m/api/qr-config` | 桌面二维码数据(loopback only) | 否(loopback) |
|
|
@@ -312,7 +312,7 @@
|
|
|
312
312
|
| `mobile/frame` | 内核瞬态帧(问询/审批)。`frame` 字段为 `question/requested`(含 `rpcId`、`questions[]`)、`question/resolved`(`questionRpcId`)、`approval/requested`(`rpcId`、`approvalId`、`toolName`、`reason?`)、`approval/resolved`(`approvalId`)。**`approvalId` 标识一次实际审批请求**:同一 `callId` 的 pre-execute 与 sandbox escalation 是两个不同 `approvalId`,`callId` 仅作关联(issue #60 R16);`$events` 路径的 `rpcId` 使用稳定的 `eventId`。**App 断线重连时服务端补发挂起的待答帧**(`pendingFrames` 回放) |
|
|
313
313
|
| `mobile/queue` | `{ sessionId, rows: [{ id, text, placement }] }`——内核队列快照(`agent/inbox/spliced` 即时镜像,v3.0.2):认领/删除/编辑实时反映,App 端 dock 以此为权威源(`placement`: `queued` / `steering` / `context`,与 GET /queue 同款形状);断线重连时 mux 回放当前队列 |
|
|
314
314
|
| `attention/snapshot` | `{ version: 1, pending: [{ kind, sessionId, identity }] }`——在断线重连的 `mobile/frame` 挂起帧回放**之后**、同一有序 SSE 流上追加的**完整待办快照边界**(v3.3)。App 只据此撤销该宿主已不在 pending 中的业务通知,不得凭超时猜测待办已结束;旧宿主无此帧时保留既有行为 |
|
|
315
|
-
| `git/changed
|
|
315
|
+
| `git/changed`(v3.3) | Git 改动通知帧:至少包含 `{ repositoryId }`,可带 `changeKinds`(`index`/`head`) |
|
|
316
316
|
|
|
317
317
|
客户端应按 `type` 分派;未知 type 使用通用事件卡保留顺序(前向兼容)。当前服务端故意不给未知 type 详情指针,按需详情端点对其返回 `404 event-not-found`,避免未经审查地暴露事件载荷。
|
|
318
318
|
### 3.7 GET /m/qr.png
|
|
@@ -696,9 +696,9 @@
|
|
|
696
696
|
- `commands.execute` 外层套 `AbortSignal.timeout(15000)`:15s 是**整个命令**的上限。`/compact` 之类会等一次完整的 LLM 摘要,长会话可能超时 → `504 commands-execute-failed`;客户端此时**不能断言失败**(结果未知)
|
|
697
697
|
- `result` 为内核 settle 对象(`commandId` + `result.{kind,text}`),与 PC 端一致
|
|
698
698
|
|
|
699
|
-
### Git API
|
|
699
|
+
### Git API(v3.3 已实现)
|
|
700
700
|
|
|
701
|
-
>
|
|
701
|
+
> `/m/api/git/*` 已注册并可用;以下为当前契约。设计背景见 `docs/design/mobile-git.md` 与 `docs/adr/` 中相关 ADR。
|
|
702
702
|
|
|
703
703
|
Git 接口计划由项目自有 provider 提供,执行通过 DSH `subprocess`,仓库必须位于
|
|
704
704
|
`workspaceRegistry` 已注册工作区内。`repositoryId` 为 provider 分配的不透明仓库标识,客户端不得自行拼接
|
|
@@ -709,7 +709,7 @@ shell 命令。Slice A 是只读基础;B1/B2 提供受保护的 stage/commit
|
|
|
709
709
|
`GET /m/api/git/context?sessionId=…` 返回不透明的稳定 `repositoryId`、仓库名称和能力,不返回主机路径。
|
|
710
710
|
其余接口均要求 `repositoryId`:`status` 返回分支与文件状态,`branches` 返回本地/远端分支。
|
|
711
711
|
客户端不得将主机路径当作 B1 写操作的 `repositoryId`;服务端仅接受由 `context` 返回、并在授权工作区内解析的仓库标识。
|
|
712
|
-
`graph` 支持 `limit/cursor` 和可选 JSON `refs
|
|
712
|
+
`graph` 支持 `limit/cursor` 和可选 JSON `refs`(GET 最多 32 个、POST 最多 128 个 `{name,tipOid}` 引用对;本地与远程引用合计);首次请求返回
|
|
713
713
|
`snapshotId`、绑定的 `tips`、提交页和 `nextCursor`,后续请求必须使用同一快照的不透明游标。
|
|
714
714
|
引用移动、删除、tip 不匹配、仓库变化、游标上下文错误或快照过期返回 `409 graph-stale`,客户端不得
|
|
715
715
|
静默回退到全量图。`commit` 要求 `oid`,`diff` 支持 `kind=working|staged|commit`、`oid/path`。
|
|
@@ -961,7 +961,8 @@ fetch/push 序列化 common domain,pull/sync/abort 同时序列化 common 与
|
|
|
961
961
|
| GET | `/m/api/git/capabilities` | Git 只读能力与契约版本 |
|
|
962
962
|
| GET | `/m/api/git/repository` | 当前会话 cwd 解析出的仓库标识 |
|
|
963
963
|
| GET | `/m/api/git/branches` | 本地/远程分支列表 |
|
|
964
|
-
| GET | `/m/api/git/graph` |
|
|
964
|
+
| GET | `/m/api/git/graph` | 1–32 tip 的提交拓扑(分页) |
|
|
965
|
+
| POST | `/m/api/git/graph` | 1–128 tip 的提交拓扑(JSON body,分页/续页) |
|
|
965
966
|
| GET | `/m/api/git/commit` | 提交详情 + 变更文件(分页) |
|
|
966
967
|
| GET | `/m/api/git/worktree` | 工作区快照(已暂存/未暂存/未跟踪) |
|
|
967
968
|
| GET | `/m/api/git/preview` | 单文件文本差异预览(有界) |
|
|
@@ -980,6 +981,7 @@ fetch/push 序列化 common domain,pull/sync/abort 同时序列化 common 与
|
|
|
980
981
|
"readOnly": true,
|
|
981
982
|
"provider": "bundled",
|
|
982
983
|
"features": {
|
|
984
|
+
"graphTips": { "max": 128, "getMax": 32 },
|
|
983
985
|
"repository": true, "branches": true, "graph": true, "commit": true,
|
|
984
986
|
"worktree": true, "preview": true, "refsDetail": true, "fileHistory": true
|
|
985
987
|
}
|
|
@@ -1044,15 +1046,17 @@ graph 的每个提交与 commit 详情都**保留旧的** `refs: string[]`(dep
|
|
|
1044
1046
|
|
|
1045
1047
|
`branches` 响应:`{ ok, repositoryId, branches: [{ name, displayName, oid, kind, current, tracking, ahead, behind }] }`,`kind` 为 `local` / `remote`,`name` 为完整 ref 名。
|
|
1046
1048
|
|
|
1047
|
-
#### 6.19.4 GET /m/api/git/graph
|
|
1049
|
+
#### 6.19.4 GET/POST /m/api/git/graph
|
|
1048
1050
|
|
|
1049
1051
|
| 参数 | 说明 |
|
|
1050
1052
|
|---|---|
|
|
1051
|
-
| `tips` | JSON
|
|
1053
|
+
| `tips` | GET:JSON 数组字符串 `1–32` 个;POST:body `tips` 数组 `1–128` 个。元素 `{"name":"refs/heads/main"\|"HEAD"\|"refs/remotes/origin/main","tipOid":"<可选>"}`,不重复 |
|
|
1052
1054
|
| `snapshotId` / `cursor` | 翻页时成对提交:首次请求省略,响应返回 `snapshotId` 与 `nextCursor` |
|
|
1053
1055
|
| `limit` | 每页条数,1–200,默认 100 |
|
|
1054
1056
|
|
|
1055
|
-
|
|
1057
|
+
POST 请求体:`{"sessionId","repositoryId","tips":[...],"limit"?,"snapshotId"?,"cursor"?}`;续页可省略 `tips`,`snapshotId/cursor` 与 GET 互通(传输方式不参与快照身份)。POST body ≤256 KiB、每个 `name` ≤1024 B,超限 `413 payload-too-large`。`HEAD /git/graph` 返回 200 无 body,不创建快照。
|
|
1058
|
+
|
|
1059
|
+
响应:`{ ok, repositoryId, snapshotId, tips, commits, nextCursor }`,`commits[]` 含 `oid` / `parents` / `author` / `timestamp` / `subject` / `refs` / `refsDetail` / `tagsDetail`。引用在翻页期间移动、tip 失效、快照过期或游标非法返回 `409 graph-stale`;非法 tip 返回 `409 graph-tip-invalid`;GET 超过 32 / POST 超过 128 返回 `400 graph-too-many-tips`(detail 声明对应上限);服务端 25s deadline 返回 `504 graph-timeout`。
|
|
1056
1060
|
|
|
1057
1061
|
#### 6.19.5 GET /m/api/git/commit
|
|
1058
1062
|
|
|
@@ -1130,12 +1134,14 @@ graph 的每个提交与 commit 详情都**保留旧的** `refs: string[]`(dep
|
|
|
1130
1134
|
| 400 | `invalid-oid` / `invalid-files-cursor` / `invalid-history-cursor` | 非法 OID / 文件分页游标 / 历史分页游标 |
|
|
1131
1135
|
| 400 | `path-invalid` | `/git/file-history` 传入目录路径 |
|
|
1132
1136
|
| 400 | `preview-invalid` | 预览参数非法 |
|
|
1133
|
-
| 400 | `graph-tip-invalid` / `graph-too-many-tips` | 非法 tip / 超过
|
|
1137
|
+
| 400 | `graph-tip-invalid` / `graph-too-many-tips` | 非法 tip / GET 超过 32、POST 超过 128 tips |
|
|
1134
1138
|
| 401 | `auth-required` / `bad-token` | 未鉴权(同 §1) |
|
|
1135
1139
|
| 403 | `repository-not-authorized` / `workspace-not-allowed` | 会话/仓库不匹配或路径不在已注册工作区 |
|
|
1136
1140
|
| 404 | `session-not-found` / `not-git-repository` / `preview-file-not-found` | 会话不存在 / cwd 不是仓库 / 提交中无该文件 |
|
|
1137
1141
|
| 409 | `graph-stale` / `graph-tip-invalid` | 快照或 tip 已变化 |
|
|
1138
|
-
| 413 | `git-output-too-large` | Git
|
|
1142
|
+
| 413 | `git-output-too-large` / `payload-too-large` | Git 输出超过宿主上限;POST graph body 超过 256 KiB 或单个 ref name 超过 1024 B |
|
|
1143
|
+
| 504 | `graph-timeout` | graph 25s deadline(任意阶段) |
|
|
1144
|
+
| 431 | —(HTTP) | GET URL 过长;新 App 在能力允许时自动改 POST 重试一次 |
|
|
1139
1145
|
| 503 | `git-provider-unavailable` / `provider-incompatible` | provider 不可用 / 旧 provider 不支持所需方法 |
|
|
1140
1146
|
|
|
1141
1147
|
#### 6.19.10 兼容与降级
|
package/lib/endpoint-registry.js
CHANGED
|
@@ -39,9 +39,15 @@ export function extractEndpointDetails(source) {
|
|
|
39
39
|
let methods = "GET/POST";
|
|
40
40
|
// issue #60 recheck-2(R02):头部显式 `(method === "GET" || method === "HEAD")`
|
|
41
41
|
// 必须抽成 GET/HEAD——HEAD 是真实分派语义,不能被默认成 GET/POST。
|
|
42
|
-
const allowsHead = /method\s*===\s*['"]GET['"]\s*\|\|\s*method\s*===\s*['"]HEAD['"]/.test(header)
|
|
42
|
+
const allowsHead = /method\s*===\s*['"]GET['"]\s*\|\|\s*method\s*===\s*['"]HEAD['"]/.test(header)
|
|
43
|
+
// 只读端点也可写成「GET/HEAD 之外 405」;排除紧跟 POST 的三方法形态。
|
|
44
|
+
|| /method\s*!==\s*['"]GET['"]\s*&&\s*method\s*!==\s*['"]HEAD['"](?!\s*&&\s*method\s*!==\s*['"]POST['"])/.test(header);
|
|
43
45
|
const allowsPost = /method\s*===\s*['"]POST['"]/.test(segment) || /requirePost\(method,\s*res\)/.test(segment);
|
|
44
|
-
|
|
46
|
+
// re-review P1-1:图端点用「GET/HEAD/POST 之外的都 405」显式三分派;
|
|
47
|
+
// 只认这一种精确形态,避免把 GET/HEAD + 块内 POST(真实 GET/POST)误判成三方法。
|
|
48
|
+
const explicitHeadPost = /method\s*!==\s*['"]GET['"]\s*&&\s*method\s*!==\s*['"]HEAD['"]\s*&&\s*method\s*!==\s*['"]POST['"]/.test(header);
|
|
49
|
+
if (explicitHeadPost) methods = "GET/HEAD/POST";
|
|
50
|
+
else if (allowsHead && !allowsPost) methods = "GET/HEAD";
|
|
45
51
|
else if (/requireGet\(method,\s*res\)/.test(segment) || /method\s*!==\s*['"]GET['"]/.test(segment)) methods = "GET";
|
|
46
52
|
else if (/method\s*!==\s*['"]POST['"]/.test(segment)) methods = "POST";
|
|
47
53
|
out.set(path, methods);
|
|
@@ -129,15 +135,15 @@ export const REGISTERED_ENDPOINTS = Object.freeze([
|
|
|
129
135
|
{ path: "/feedback", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
130
136
|
{ path: "/files", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
131
137
|
{ path: "/files/upload", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
132
|
-
{ path: "/git/branches", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
133
|
-
{ path: "/git/capabilities", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
134
|
-
{ path: "/git/commit", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
135
|
-
{ path: "/git/file-history", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
136
|
-
{ path: "/git/files", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
137
|
-
{ path: "/git/graph", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
138
|
-
{ path: "/git/preview", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
139
|
-
{ path: "/git/repository", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
140
|
-
{ path: "/git/worktree", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
138
|
+
{ path: "/git/branches", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
139
|
+
{ path: "/git/capabilities", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
140
|
+
{ path: "/git/commit", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
141
|
+
{ path: "/git/file-history", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
142
|
+
{ path: "/git/files", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
143
|
+
{ path: "/git/graph", methods: "GET/HEAD/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
144
|
+
{ path: "/git/preview", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
145
|
+
{ path: "/git/repository", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
146
|
+
{ path: "/git/worktree", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
141
147
|
{ path: "/goal", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
142
148
|
{ path: "/history", methods: "GET", capability: "eventTimeline" },
|
|
143
149
|
{ path: "/jobs", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
@@ -209,9 +209,11 @@ export function createBundledGitReadProvider(ctx) {
|
|
|
209
209
|
async resolveTip(root, ref) {
|
|
210
210
|
return (await run(root, ["rev-parse", "--verify", `${ref}^{commit}`])).trim();
|
|
211
211
|
},
|
|
212
|
-
async graph(root, { refs, offset, limit }) {
|
|
212
|
+
async graph(root, { refs, offset, limit, timeoutMs = 0 }) {
|
|
213
213
|
if (refs.length === 0) return [];
|
|
214
|
-
const
|
|
214
|
+
const graphResult = await spawnGit(root, ["log", "--topo-order", "--date-order", `--skip=${offset}`, `--max-count=${limit}`, "--decorate=full", "--format=%H%x1f%P%x1f%an%x1f%at%x1f%s%x1f%D%x00", ...refs], { timeoutMs });
|
|
215
|
+
if (graphResult.timedOut) throw gitError("graph-timeout", 504);
|
|
216
|
+
const text = graphResult.stdout;
|
|
215
217
|
return text.split("\0").map((record) => record.replace(/^[\r\n]+|[\r\n]+$/g, "")).filter(Boolean).map((record) => {
|
|
216
218
|
const [oid, parents, author, timestamp, subject, decorations] = record.split("\x1f");
|
|
217
219
|
return { oid, parents: parents ? parents.split(" ") : [], author, timestamp: Number(timestamp) || 0, subject, refs: decorations ? decorations.split(",").map((value) => value.trim()).filter(Boolean) : [] };
|
|
@@ -261,11 +263,13 @@ export function createBundledGitReadProvider(ctx) {
|
|
|
261
263
|
* annotated-tag metadata. Non-commit and nested tag targets carry a hint
|
|
262
264
|
* instead of failing the whole read.
|
|
263
265
|
*/
|
|
264
|
-
async refs(root) {
|
|
266
|
+
async refs(root, { timeoutMs = 0 } = {}) {
|
|
265
267
|
const records = [];
|
|
266
268
|
// NUL/US-delimited fields keep tagger names and tag subjects that contain
|
|
267
269
|
// tabs intact; a tab-delimited line format would corrupt such records.
|
|
268
|
-
const
|
|
270
|
+
const refsResult = await spawnGit(root, ["for-each-ref", "--format=%(refname)%1f%(objectname)%1f%(objecttype)%1f%(HEAD)%1f%(taggername)%1f%(taggerdate:unix)%1f%(subject)%1f%(*objectname)%1f%(*objecttype)%1f%(type)%00", "refs/heads", "refs/remotes", "refs/tags"], { timeoutMs });
|
|
271
|
+
if (refsResult.timedOut) throw gitError("graph-timeout", 504);
|
|
272
|
+
const text = refsResult.stdout;
|
|
269
273
|
for (const raw of text.split("\0")) {
|
|
270
274
|
const record = raw.replace(/^[\r\n]+|[\r\n]+$/g, "");
|
|
271
275
|
if (!record) continue;
|
package/lib/git-read-service.js
CHANGED
|
@@ -3,7 +3,10 @@ import { basename, dirname, isAbsolute, relative, resolve, sep } from "node:path
|
|
|
3
3
|
import { lstat, realpath } from "node:fs/promises";
|
|
4
4
|
import { createBundledGitReadProvider } from "./git-read-bundled-provider.js";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// task-28(issue #86 方案 B):GET 仍 ≤32;POST 支持 ≤128(URL 16KB 限制解除)。
|
|
7
|
+
const MAX_GRAPH_TIPS_GET = 32;
|
|
8
|
+
const MAX_GRAPH_TIPS_POST = 128;
|
|
9
|
+
const GRAPH_DEADLINE_MS = 25_000;
|
|
7
10
|
const MAX_TRACKED_FILES = 200;
|
|
8
11
|
const FILE_HISTORY_DEFAULT_LIMIT = 20;
|
|
9
12
|
const FILE_HISTORY_MAX_LIMIT = 100;
|
|
@@ -151,7 +154,7 @@ const historyStatus = (value) => {
|
|
|
151
154
|
};
|
|
152
155
|
|
|
153
156
|
/** Session-authorized read facade over an optional external or bundled provider. */
|
|
154
|
-
export function createGitReadService(ctx, { bundledProvider, now = () => Date.now(), snapshotTtlMs = 5 * 60_000, pollIntervalMs = 30_000, onChanged } = {}) {
|
|
157
|
+
export function createGitReadService(ctx, { bundledProvider, now = () => Date.now(), snapshotTtlMs = 5 * 60_000, pollIntervalMs = 30_000, onChanged, graphDeadlineMs = GRAPH_DEADLINE_MS, onSnapshotDisposed } = {}) {
|
|
155
158
|
const get = (name) => { try { return ctx.get?.(name); } catch { return undefined; } };
|
|
156
159
|
const external = get("gitReadProvider");
|
|
157
160
|
let externalAvailable = false;
|
|
@@ -239,12 +242,108 @@ export function createGitReadService(ctx, { bundledProvider, now = () => Date.no
|
|
|
239
242
|
return Array.isArray(records) ? records : null;
|
|
240
243
|
} catch { return null; }
|
|
241
244
|
};
|
|
245
|
+
const graphTimeout = () => failure("graph-timeout", 504);
|
|
246
|
+
/** 单次 provider 调用的 25s 硬截止(provider 自身超时/挂起兜底)。 */
|
|
247
|
+
const graphRace = async (factory, deadline) => {
|
|
248
|
+
const remaining = Math.max(1, deadline - Date.now());
|
|
249
|
+
const call = Promise.resolve().then(factory);
|
|
250
|
+
let timer = null;
|
|
251
|
+
const timeout = new Promise((_, reject) => {
|
|
252
|
+
timer = setTimeout(() => reject(graphTimeout()), remaining);
|
|
253
|
+
});
|
|
254
|
+
try {
|
|
255
|
+
return await Promise.race([call, timeout]);
|
|
256
|
+
} finally {
|
|
257
|
+
if (timer) clearTimeout(timer);
|
|
258
|
+
// 超时后底层 promise 仍可能 settle:吞掉,避免 unhandledRejection。
|
|
259
|
+
void call.catch(() => {});
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
/** provider.refs 一次映射(name → commit oid);无 refs 能力/调用失败返回 null → 逐 tip 回退。 */
|
|
263
|
+
const graphRefsByName = async (root, deadline) => {
|
|
264
|
+
if (typeof provider.refs !== "function") return null;
|
|
265
|
+
try {
|
|
266
|
+
const records = await graphRace(
|
|
267
|
+
() => provider.refs(root, { timeoutMs: Math.max(1, deadline - Date.now()) }),
|
|
268
|
+
deadline,
|
|
269
|
+
);
|
|
270
|
+
if (!Array.isArray(records)) return null;
|
|
271
|
+
const byName = new Map();
|
|
272
|
+
for (const record of records) {
|
|
273
|
+
if (!record || typeof record.name !== "string") continue;
|
|
274
|
+
byName.set(record.name, validOid(record.commitOid) ? String(record.commitOid) : null);
|
|
275
|
+
}
|
|
276
|
+
return byName;
|
|
277
|
+
} catch (error) {
|
|
278
|
+
if (error?.code === "graph-timeout") throw error;
|
|
279
|
+
return null; // 外部 provider 无 refs/调用失败 → 逐 tip(兼容旧契约)
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
/** 批量解析新快照 tips:一次 refs 映射优先,缺项才逐 tip resolveTip。 */
|
|
283
|
+
const resolveGraphTips = async (root, selected, deadline) => {
|
|
284
|
+
const byName = await graphRefsByName(root, deadline);
|
|
285
|
+
const resolved = [];
|
|
286
|
+
for (const tip of selected) {
|
|
287
|
+
let oid;
|
|
288
|
+
if (byName && byName.has(tip.name)) {
|
|
289
|
+
oid = byName.get(tip.name);
|
|
290
|
+
if (!validOid(oid)) throw failure("graph-tip-invalid", 409);
|
|
291
|
+
} else {
|
|
292
|
+
try {
|
|
293
|
+
oid = await graphRace(() => provider.resolveTip(root, tip.name), deadline);
|
|
294
|
+
} catch (error) {
|
|
295
|
+
if (error?.code === "graph-timeout") throw error;
|
|
296
|
+
if (tip.name === "HEAD" && error?.code === "git-command-failed") continue;
|
|
297
|
+
throw failure("graph-tip-invalid", 409);
|
|
298
|
+
}
|
|
299
|
+
if (!validOid(oid)) throw failure("graph-tip-invalid", 409);
|
|
300
|
+
}
|
|
301
|
+
if (tip.tipOid != null && tip.tipOid.toLowerCase() !== oid.toLowerCase()) throw failure("graph-tip-invalid", 409);
|
|
302
|
+
resolved.push({ name: tip.name, tipOid: oid });
|
|
303
|
+
if (Date.now() > deadline) throw graphTimeout();
|
|
304
|
+
}
|
|
305
|
+
return resolved;
|
|
306
|
+
};
|
|
307
|
+
/** 续页/前后校验:一次 refs 映射比对 tips 未移动;失败抛 graph-stale。 */
|
|
308
|
+
const verifyGraphTips = async (root, tips, deadline) => {
|
|
309
|
+
const byName = await graphRefsByName(root, deadline);
|
|
310
|
+
for (const tip of tips) {
|
|
311
|
+
let current;
|
|
312
|
+
if (byName && byName.has(tip.name)) current = byName.get(tip.name);
|
|
313
|
+
else {
|
|
314
|
+
try {
|
|
315
|
+
current = await graphRace(() => provider.resolveTip(root, tip.name), deadline);
|
|
316
|
+
} catch (error) {
|
|
317
|
+
if (error?.code === "graph-timeout") throw error;
|
|
318
|
+
throw stale();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (!validOid(current) || current.toLowerCase() !== tip.tipOid.toLowerCase()) throw stale();
|
|
322
|
+
if (Date.now() > deadline) throw graphTimeout();
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
/** graph 专用:readRefRecords 纳入同一 absolute deadline(挂起→504,不返回半页)。 */
|
|
326
|
+
const readRefRecordsWithin = async (root, deadline) => {
|
|
327
|
+
if (typeof provider.refs !== "function") return null;
|
|
328
|
+
try {
|
|
329
|
+
const records = await graphRace(
|
|
330
|
+
() => provider.refs(root, { timeoutMs: Math.max(1, deadline - Date.now()) }),
|
|
331
|
+
deadline,
|
|
332
|
+
);
|
|
333
|
+
return Array.isArray(records) ? records : null;
|
|
334
|
+
} catch (error) {
|
|
335
|
+
if (error?.code === "graph-timeout") throw error;
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
242
339
|
const capabilities = () => {
|
|
243
340
|
const base = provider.capabilities?.() ?? { available: true, reason: null };
|
|
244
341
|
return {
|
|
245
342
|
contractVersion: "1.1.0", available: base.available !== false,
|
|
246
343
|
reason: ["git-provider-unavailable", "workspace-registry-unavailable"].includes(base.reason) ? base.reason : null,
|
|
247
344
|
readOnly: true, provider: provider === external ? "external" : "bundled",
|
|
345
|
+
// task-28:POST graph 的 tips 上限(旧宿主缺该字段,App 回退 5/5)。
|
|
346
|
+
graphTips: { max: MAX_GRAPH_TIPS_POST, getMax: MAX_GRAPH_TIPS_GET },
|
|
248
347
|
features: {
|
|
249
348
|
repository: true, branches: true, graph: true, commit: true, worktree: true, preview: true,
|
|
250
349
|
// Both flags are independent and additive: refsDetail can be
|
|
@@ -427,11 +526,18 @@ export function createGitReadService(ctx, { bundledProvider, now = () => Date.no
|
|
|
427
526
|
stats, files: { items, total: allFiles.length, nextCursor },
|
|
428
527
|
};
|
|
429
528
|
},
|
|
430
|
-
|
|
529
|
+
/**
|
|
530
|
+
* 图分页。task-28:`maxTips` 由 HTTP 层按传输方式传入(GET=32 / POST=128),
|
|
531
|
+
* 续页可省略 tips;snapshotId/cursor 与传输方式无关(GET/POST 互通)。
|
|
532
|
+
*/
|
|
533
|
+
async graph(sessionId, repositoryId, { tips, snapshotId, cursor, limit = 100, maxTips = MAX_GRAPH_TIPS_GET } = {}) {
|
|
431
534
|
const authorized = await binding(sessionId, repositoryId);
|
|
432
535
|
prune();
|
|
536
|
+
const deadline = Date.now() + graphDeadlineMs;
|
|
537
|
+
const tipCap = maxTips === MAX_GRAPH_TIPS_POST ? MAX_GRAPH_TIPS_POST : MAX_GRAPH_TIPS_GET;
|
|
433
538
|
const pageSize = Math.max(1, Math.min(200, Number(limit) || 100));
|
|
434
539
|
let snapshot, offset = 0;
|
|
540
|
+
let snapshotCreatedNow = false;
|
|
435
541
|
if (snapshotId !== undefined || cursor !== undefined) {
|
|
436
542
|
if (!snapshotId || !cursor) throw stale();
|
|
437
543
|
snapshot = snapshots.get(snapshotId);
|
|
@@ -440,47 +546,87 @@ export function createGitReadService(ctx, { bundledProvider, now = () => Date.no
|
|
|
440
546
|
if (!Number.isInteger(offset)) throw stale();
|
|
441
547
|
} else {
|
|
442
548
|
const selected = tips === undefined ? [{ name: "HEAD", tipOid: null }] : tips;
|
|
443
|
-
if (!Array.isArray(selected) || selected.length >
|
|
549
|
+
if (!Array.isArray(selected) || selected.length > tipCap) throw failure("graph-too-many-tips", 400, `tips limit is ${tipCap}`);
|
|
444
550
|
if (selected.length === 0) throw failure("graph-tip-invalid", 400);
|
|
445
551
|
const names = selected.map((tip) => tip?.name);
|
|
446
552
|
if (new Set(names).size !== names.length || names.some((name) => !validRef(name)) || selected.some((tip) => tip?.tipOid != null && !validOid(tip.tipOid))) throw failure("graph-tip-invalid", 400);
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
let oid;
|
|
450
|
-
try { oid = await provider.resolveTip(authorized.root, tip.name); }
|
|
451
|
-
catch (error) {
|
|
452
|
-
if (tip.name === "HEAD" && error?.code === "git-command-failed") continue;
|
|
453
|
-
throw failure("graph-tip-invalid", 409);
|
|
454
|
-
}
|
|
455
|
-
if (!validOid(oid)) throw failure("graph-tip-invalid", 409);
|
|
456
|
-
if (tip.tipOid != null && tip.tipOid.toLowerCase() !== oid.toLowerCase()) throw failure("graph-tip-invalid", 409);
|
|
457
|
-
resolved.push({ name: tip.name, tipOid: oid });
|
|
458
|
-
}
|
|
553
|
+
// P0 批量解析:128 tips 只做一次 provider.refs(外部 provider 无 refs 才逐 tip)。
|
|
554
|
+
const resolved = await resolveGraphTips(authorized.root, selected, deadline);
|
|
459
555
|
snapshot = { id: randomUUID(), sessionId, repositoryId, root: authorized.root, tips: resolved, expiresAt: now() + snapshotTtlMs, cursors: new Map() };
|
|
556
|
+
snapshotCreatedNow = true;
|
|
460
557
|
snapshots.set(snapshot.id, snapshot);
|
|
461
558
|
keepBounded(snapshots, 128);
|
|
462
559
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
560
|
+
// 统一 snapshot 清理策略(re-review P1):
|
|
561
|
+
// - 纯 graph-timeout:本次请求**新建且尚未交付**的 initial 快照可删;
|
|
562
|
+
// 已交付/续页快照保留至 TTL,同 cursor 可重试;
|
|
563
|
+
// - graph-stale / ref 变化 / 鉴权失败等确定性失效:立即删除。
|
|
564
|
+
// 该策略覆盖 pre/post verify、provider.graph、装饰 readRefRecords 所有阶段。
|
|
565
|
+
const disposeSnapshot = () => {
|
|
566
|
+
if (snapshots.delete(snapshot.id)) onSnapshotDisposed?.(snapshot.id);
|
|
567
|
+
};
|
|
568
|
+
const disposeOnGraphFailure = (error) => {
|
|
569
|
+
if (error?.code === "graph-timeout") {
|
|
570
|
+
if (snapshotCreatedNow) disposeSnapshot();
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
disposeSnapshot();
|
|
574
|
+
};
|
|
575
|
+
try {
|
|
576
|
+
await verifyGraphTips(authorized.root, snapshot.tips, deadline);
|
|
577
|
+
} catch (error) {
|
|
578
|
+
disposeOnGraphFailure(error);
|
|
579
|
+
throw error;
|
|
467
580
|
}
|
|
468
581
|
let rawCommits;
|
|
469
|
-
try {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
582
|
+
try {
|
|
583
|
+
rawCommits = await graphRace(
|
|
584
|
+
() => provider.graph(authorized.root, {
|
|
585
|
+
refs: snapshot.tips.map((tip) => tip.tipOid),
|
|
586
|
+
offset,
|
|
587
|
+
limit: pageSize,
|
|
588
|
+
timeoutMs: Math.max(1, deadline - Date.now()),
|
|
589
|
+
}),
|
|
590
|
+
deadline,
|
|
591
|
+
);
|
|
592
|
+
// provider 自报 timedOut(不得把半页当完整页返回)。
|
|
593
|
+
if (rawCommits && rawCommits.timedOut === true) throw graphTimeout();
|
|
594
|
+
} catch (error) {
|
|
595
|
+
// 超时是明确失败(504 graph-timeout),不做 stale 转换(否则面板看不到)。
|
|
596
|
+
// 已交付续页快照保留;非确定性 provider 错误保留快照供重试(verify 失败才 stale)。
|
|
597
|
+
if (error?.code === "graph-timeout") {
|
|
598
|
+
disposeOnGraphFailure(error);
|
|
599
|
+
throw error;
|
|
600
|
+
}
|
|
601
|
+
try {
|
|
602
|
+
await verifyGraphTips(authorized.root, snapshot.tips, deadline);
|
|
603
|
+
} catch (verifyError) {
|
|
604
|
+
// 混合错误:provider.graph 先抛临时 503,随后为判 stale 的二次
|
|
605
|
+
// verify 因 deadline 挂起 —— 必须原样透传 504,并按统一策略
|
|
606
|
+
// (已交付保留 / 未交付新建清理),不能误判成 ref 真变化的 stale。
|
|
607
|
+
if (verifyError?.code === "graph-timeout") {
|
|
608
|
+
disposeOnGraphFailure(verifyError);
|
|
609
|
+
throw verifyError;
|
|
610
|
+
}
|
|
611
|
+
disposeSnapshot();
|
|
612
|
+
throw stale();
|
|
475
613
|
}
|
|
476
614
|
throw error;
|
|
477
615
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
616
|
+
try {
|
|
617
|
+
await verifyGraphTips(authorized.root, snapshot.tips, deadline);
|
|
618
|
+
} catch (error) {
|
|
619
|
+
disposeOnGraphFailure(error);
|
|
620
|
+
throw error;
|
|
621
|
+
}
|
|
622
|
+
let records;
|
|
623
|
+
try {
|
|
624
|
+
records = await readRefRecordsWithin(authorized.root, deadline);
|
|
625
|
+
} catch (error) {
|
|
626
|
+
// 装饰(refs 记录)阶段超时同样按统一策略处理:已交付快照可重试。
|
|
627
|
+
disposeOnGraphFailure(error);
|
|
628
|
+
throw error;
|
|
482
629
|
}
|
|
483
|
-
const records = await readRefRecords(authorized.root);
|
|
484
630
|
const commits = (Array.isArray(rawCommits) ? rawCommits : []).map((row) => {
|
|
485
631
|
const oid = String(row.oid ?? "");
|
|
486
632
|
const legacy = Array.isArray(row.refs) ? row.refs.map(String) : [];
|
package/lib/index.js
CHANGED
|
@@ -7333,8 +7333,85 @@ export function apply(ctx, config, runtime = {}) {
|
|
|
7333
7333
|
return sendJson(res, result.status, result.body);
|
|
7334
7334
|
}
|
|
7335
7335
|
|
|
7336
|
-
|
|
7337
|
-
|
|
7336
|
+
// task-28 / re-review P1-1:/git/graph 独立分派,允许 GET/HEAD/POST;其余 Git 只读
|
|
7337
|
+
// 端点单独分支保持 GET/HEAD(POST 405)。endpoint-registry 按真实方法登记。
|
|
7338
|
+
if (rest === "/git/graph") {
|
|
7339
|
+
if (method !== "GET" && method !== "HEAD" && method !== "POST") return error(res, 405, "method-not-allowed");
|
|
7340
|
+
// HEAD = 能力探测:200 无 body,且不创建 snapshot。
|
|
7341
|
+
if (method === "HEAD") {
|
|
7342
|
+
res.writeHead(200, { "content-type": "application/json; charset=utf-8" });
|
|
7343
|
+
res.end();
|
|
7344
|
+
return;
|
|
7345
|
+
}
|
|
7346
|
+
const GRAPH_POST_BODY_LIMIT = 256 * 1024;
|
|
7347
|
+
const GRAPH_TIP_NAME_LIMIT = 1024;
|
|
7348
|
+
let postBody = null;
|
|
7349
|
+
if (method === "POST") {
|
|
7350
|
+
const declared = Number(req.headers?.["content-length"]);
|
|
7351
|
+
if (Number.isFinite(declared) && declared > GRAPH_POST_BODY_LIMIT) return error(res, 413, "payload-too-large");
|
|
7352
|
+
let text;
|
|
7353
|
+
try { text = await readBody(req, GRAPH_POST_BODY_LIMIT); }
|
|
7354
|
+
catch (err) { return bodyError(err, res); }
|
|
7355
|
+
try { postBody = text ? JSON.parse(text) : {}; }
|
|
7356
|
+
catch { return error(res, 400, "bad-request", "body must be JSON"); }
|
|
7357
|
+
if (!postBody || typeof postBody !== "object" || Array.isArray(postBody)) return error(res, 400, "bad-request");
|
|
7358
|
+
const tips = postBody.tips;
|
|
7359
|
+
if (tips !== undefined) {
|
|
7360
|
+
if (!Array.isArray(tips)) return error(res, 400, "bad-request", "tips must be an array");
|
|
7361
|
+
for (const tip of tips) {
|
|
7362
|
+
const name = tip?.name;
|
|
7363
|
+
if (typeof name !== "string" || Buffer.byteLength(name, "utf8") > GRAPH_TIP_NAME_LIMIT) {
|
|
7364
|
+
return error(res, 413, "payload-too-large");
|
|
7365
|
+
}
|
|
7366
|
+
}
|
|
7367
|
+
}
|
|
7368
|
+
if (postBody.snapshotId === undefined && postBody.cursor === undefined && !Array.isArray(tips)) {
|
|
7369
|
+
return error(res, 400, "bad-request", "tips is required");
|
|
7370
|
+
}
|
|
7371
|
+
}
|
|
7372
|
+
const source = postBody ?? {};
|
|
7373
|
+
const sessionId = (method === "POST" ? source.sessionId : null) ?? url.searchParams.get("sessionId") ?? "";
|
|
7374
|
+
if (!sessionId) return error(res, 400, "bad-request", "sessionId is required");
|
|
7375
|
+
const repositoryId = (method === "POST" ? source.repositoryId : null) ?? url.searchParams.get("repositoryId") ?? "";
|
|
7376
|
+
if (!repositoryId) return error(res, 400, "bad-request", "repositoryId is required");
|
|
7377
|
+
try {
|
|
7378
|
+
let value;
|
|
7379
|
+
if (method === "POST") {
|
|
7380
|
+
value = await gitRead.graph(sessionId, repositoryId, {
|
|
7381
|
+
tips: source.tips,
|
|
7382
|
+
snapshotId: source.snapshotId,
|
|
7383
|
+
cursor: source.cursor,
|
|
7384
|
+
limit: source.limit,
|
|
7385
|
+
maxTips: 128,
|
|
7386
|
+
});
|
|
7387
|
+
} else {
|
|
7388
|
+
let tips;
|
|
7389
|
+
const rawTips = url.searchParams.get("tips");
|
|
7390
|
+
if (rawTips !== null) {
|
|
7391
|
+
try { tips = JSON.parse(rawTips); } catch { return error(res, 400, "bad-request", "tips must be JSON"); }
|
|
7392
|
+
}
|
|
7393
|
+
value = await gitRead.graph(sessionId, repositoryId, {
|
|
7394
|
+
tips,
|
|
7395
|
+
snapshotId: url.searchParams.get("snapshotId") ?? undefined,
|
|
7396
|
+
cursor: url.searchParams.get("cursor") ?? undefined,
|
|
7397
|
+
limit: url.searchParams.get("limit") ?? undefined,
|
|
7398
|
+
maxTips: 32,
|
|
7399
|
+
});
|
|
7400
|
+
}
|
|
7401
|
+
sendJson(res, 200, { ok: true, ...value });
|
|
7402
|
+
} catch (err) {
|
|
7403
|
+
const known = new Set(["session-not-found", "workspace-not-allowed", "not-git-repository", "git-provider-unavailable", "repository-not-authorized", "graph-stale", "graph-tip-invalid", "graph-too-many-tips", "graph-timeout", "invalid-oid", "git-command-failed", "git-output-too-large", "provider-incompatible"]);
|
|
7404
|
+
const code = known.has(err?.code) ? err.code : "git-provider-unavailable";
|
|
7405
|
+
const status = Number(err?.status);
|
|
7406
|
+
ctx.logger.warn?.(`mobile-remote: Git graph failed (${code}): ${err?.message ?? err}`);
|
|
7407
|
+
return error(res, Number.isInteger(status) && status >= 400 && status <= 599 ? status : 503, code);
|
|
7408
|
+
}
|
|
7409
|
+
return;
|
|
7410
|
+
}
|
|
7411
|
+
|
|
7412
|
+
if (new Set(["/git/capabilities", "/git/repository", "/git/branches", "/git/commit", "/git/worktree", "/git/preview", "/git/files", "/git/file-history"]).has(rest)) {
|
|
7413
|
+
// 只读 Git 端点:GET/HEAD;POST 等一律 405(与登记表 GET/HEAD 一致)。
|
|
7414
|
+
if (method !== "GET" && method !== "HEAD") return error(res, 405, "method-not-allowed");
|
|
7338
7415
|
const sessionId = url.searchParams.get("sessionId") ?? "";
|
|
7339
7416
|
if (!sessionId) return error(res, 400, "bad-request", "sessionId is required");
|
|
7340
7417
|
try {
|
|
@@ -7352,21 +7429,12 @@ export function apply(ctx, config, runtime = {}) {
|
|
|
7352
7429
|
const path = url.searchParams.get("path");
|
|
7353
7430
|
if (path === null || path === "") return error(res, 400, "bad-request", "path is required");
|
|
7354
7431
|
value = await gitRead.fileHistory(sessionId, repositoryId, { path, cursor: url.searchParams.get("cursor") ?? undefined, limit: url.searchParams.get("limit") ?? undefined });
|
|
7355
|
-
} else if (rest === "/git/graph") {
|
|
7356
|
-
let tips;
|
|
7357
|
-
const rawTips = url.searchParams.get("tips");
|
|
7358
|
-
if (rawTips !== null) {
|
|
7359
|
-
try { tips = JSON.parse(rawTips); } catch { return error(res, 400, "bad-request", "tips must be JSON"); }
|
|
7360
|
-
}
|
|
7361
|
-
value = await gitRead.graph(sessionId, repositoryId, { tips, snapshotId: url.searchParams.get("snapshotId") ?? undefined, cursor: url.searchParams.get("cursor") ?? undefined, limit: url.searchParams.get("limit") ?? undefined });
|
|
7362
7432
|
} else if (rest === "/git/commit") value = await gitRead.commit(sessionId, repositoryId, url.searchParams.get("oid") ?? "", { filesCursor: url.searchParams.get("filesCursor") ?? undefined, filesLimit: url.searchParams.get("filesLimit") ?? undefined });
|
|
7363
7433
|
else return error(res, 404, "not-found");
|
|
7364
7434
|
}
|
|
7365
7435
|
sendJson(res, 200, { ok: true, ...value });
|
|
7366
7436
|
} catch (err) {
|
|
7367
|
-
|
|
7368
|
-
// only expose stable mobile error codes, never raw provider details.
|
|
7369
|
-
const known = new Set(["session-not-found", "workspace-not-allowed", "not-git-repository", "git-provider-unavailable", "repository-not-authorized", "graph-stale", "graph-tip-invalid", "graph-too-many-tips", "invalid-oid", "invalid-files-cursor", "invalid-history-cursor", "path-invalid", "git-command-failed", "git-output-too-large", "provider-incompatible", "preview-invalid", "preview-file-not-found"]);
|
|
7437
|
+
const known = new Set(["session-not-found", "workspace-not-allowed", "not-git-repository", "git-provider-unavailable", "repository-not-authorized", "invalid-oid", "invalid-files-cursor", "invalid-history-cursor", "path-invalid", "git-command-failed", "git-output-too-large", "provider-incompatible", "preview-invalid", "preview-file-not-found"]);
|
|
7370
7438
|
const code = known.has(err?.code) ? err.code : "git-provider-unavailable";
|
|
7371
7439
|
const status = Number(err?.status);
|
|
7372
7440
|
ctx.logger.warn?.(`mobile-remote: Git read failed (${code}): ${err?.message ?? err}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marktrue/dsh-mobile-remote",
|
|
3
|
-
"version": "3.2.4-alpha.
|
|
3
|
+
"version": "3.2.4-alpha.14",
|
|
4
4
|
"description": "DSH Mobile:把 DeepSeek Harness 变成随身控制台——手机远程发消息派活、看进度、收通知、审批决策、管理会话;配套 Flutter App(当前 Android 端,iOS 未开发)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"qrcode"
|
|
53
53
|
],
|
|
54
54
|
"optionalDependencies": {
|
|
55
|
-
"@marktrue/dsh-mobile-remote-app": "npm:@marktrue/dsh-mobile-remote@3.2.4-alpha.
|
|
55
|
+
"@marktrue/dsh-mobile-remote-app": "npm:@marktrue/dsh-mobile-remote@3.2.4-alpha.14-app"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@deepseek-ai/dsh-credentials": ">=0.1.0-rc.6 <=0.2.2 || >=0.2.0-0 <0.2.0 || >=0.2.1-0 <0.2.1 || >=0.2.2-0 <0.2.2",
|