@liyang8246/dsh-codetime 0.1.18 → 0.1.19

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/lib/client.js CHANGED
@@ -16,8 +16,14 @@
16
16
  body: JSON.stringify(request),
17
17
  signal
18
18
  });
19
- const value = await response.json();
19
+ const text = await response.text();
20
20
  signal?.throwIfAborted();
21
+ let value;
22
+ try {
23
+ value = JSON.parse(text);
24
+ } catch {
25
+ throw new Error(response.ok ? "CodeTime returned an invalid JSON response" : `CodeTime HTTP ${response.status}`);
26
+ }
21
27
  if (!response.ok) throw new Error(errorText(value) ?? `HTTP ${response.status}`);
22
28
  if (!isStatus(value)) throw new Error("unexpected response");
23
29
  return value;
@@ -35,6 +41,7 @@
35
41
  subtitle: "Upload Harness coding activity to codetime.dev.",
36
42
  connected: "Connected",
37
43
  notConnected: "No token yet",
44
+ unavailable: "Unable to read connection status",
38
45
  tokenLabel: "Upload token",
39
46
  tokenPlaceholder: "Paste the token from codetime.dev/dashboard/settings",
40
47
  tokenHint: "Create an upload token on the codetime.dev dashboard, then paste it here. The Harness sends turns, tool calls, models and token usage for this machine only.",
@@ -59,6 +66,7 @@
59
66
  subtitle: "把 Harness 的 AI 编码数据上报到 codetime.dev。",
60
67
  connected: "已连接",
61
68
  notConnected: "未填写 token",
69
+ unavailable: "无法读取连接状态",
62
70
  tokenLabel: "上报 Token",
63
71
  tokenPlaceholder: "粘贴 codetime.dev/dashboard/settings 里的 token",
64
72
  tokenHint: "在 codetime.dev 后台创建一个上报 token 后粘贴到这里。只会把本机的轮次、工具调用、模型与 token 用量发出去。",
@@ -168,7 +176,7 @@
168
176
  className: "ct-settings",
169
177
  "aria-label": t("title"),
170
178
  "aria-busy": busy
171
- }, /* @__PURE__ */ React.createElement("style", null, css), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("h2", null, t("title")), /* @__PURE__ */ React.createElement("p", { className: "ct-sub" }, t("subtitle"))), /* @__PURE__ */ React.createElement("div", { className: "ct-card" }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("p", { className: "ct-state" }, configured ? t("connected") : t("notConnected"), configured && status?.maskedToken && /* @__PURE__ */ React.createElement("span", { className: "ct-badge" }, status.maskedToken)), !configured && /* @__PURE__ */ React.createElement("p", { className: "ct-muted" }, t("tokenHint"))), /* @__PURE__ */ React.createElement("form", {
179
+ }, /* @__PURE__ */ React.createElement("style", null, css), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("h2", null, t("title")), /* @__PURE__ */ React.createElement("p", { className: "ct-sub" }, t("subtitle"))), /* @__PURE__ */ React.createElement("div", { className: "ct-card" }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("p", { className: "ct-state" }, !status ? t(error ? "unavailable" : "loading") : configured ? t("connected") : t("notConnected"), configured && status?.maskedToken && /* @__PURE__ */ React.createElement("span", { className: "ct-badge" }, status.maskedToken)), status && !configured && /* @__PURE__ */ React.createElement("p", { className: "ct-muted" }, t("tokenHint"))), /* @__PURE__ */ React.createElement("form", {
172
180
  className: "ct-form",
173
181
  onSubmit: (event) => {
174
182
  event.preventDefault();
package/lib/index.js CHANGED
@@ -1457,8 +1457,8 @@ function toWireRollup(session) {
1457
1457
  // src/index.ts
1458
1458
  /** Cordis plugin name used by loader diagnostics. */
1459
1459
  const name = "codetime";
1460
- /** The Host session store feeds the fold. */
1461
- const inject = ["sessions"];
1460
+ /** Wait for both the session store and the settings route transport. */
1461
+ const inject = ["sessions", "connection"];
1462
1462
  /** Schemastery validation for {@link ConfigOptions}. */
1463
1463
  const Config = Schema.object({
1464
1464
  historyDays: Schema.number().min(0).max(3650).default(30),
@@ -1630,9 +1630,7 @@ function apply(ctx, config) {
1630
1630
  ctx.effect(() => () => {
1631
1631
  state.flush();
1632
1632
  });
1633
- const connection = ctx.get("connection");
1634
- if (!connection) return;
1635
- ctx.effect(() => connection.fetch.register({
1633
+ ctx.effect(() => ctx.connection.fetch.register({
1636
1634
  path: "/api/codetime",
1637
1635
  methods: ["POST"],
1638
1636
  requestBody: "buffered",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@liyang8246/dsh-codetime",
3
3
  "type": "module",
4
- "version": "0.1.18",
4
+ "version": "0.1.19",
5
5
  "description": "Report DeepSeek Harness coding activity to codetime.dev; set the upload token in Settings.",
6
6
  "repository": { "type": "git", "url": "https://github.com/liyang8246/dsh-zolin.git", "directory": "packages/dsh-codetime" },
7
7
  "exports": {
@@ -15,7 +15,7 @@
15
15
  "files": ["cordis.patch.yml", "icon.svg", "lib/", "locale/*.json"],
16
16
  "engines": { "node": ">=22.19.0", "dsh": ">=0.2.2-rc.1 <0.3.0" },
17
17
  "scripts": {
18
- "build": "tsdown && node scripts/build-client.ts",
18
+ "build": "tsdown && node scripts/build-client.ts && node scripts/check-settings.ts",
19
19
  "typecheck": "tsc --noEmit"
20
20
  },
21
21
  "dependencies": {