@dreamorosi/agent-timekeeper-claude-code 0.2.0 → 0.2.2

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-timekeeper",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Claude Code plugin for Agent Timekeeper: records Sessions, Runs, tool calls and Interactions as Signals, and uploads them to your own endpoint",
5
5
  "author": {
6
6
  "name": "Andrea Amorosi"
package/hooks/register.js CHANGED
@@ -358,6 +358,8 @@ var createUploaderCore = (host, options) => {
358
358
  let pid = 0;
359
359
  let quarantined = 0;
360
360
  let dropped = 0;
361
+ let quarantinedSinceWrite = 0;
362
+ let droppedSinceWrite = 0;
361
363
  let lastSuccessAt;
362
364
  let lastProblem;
363
365
  let config2;
@@ -418,7 +420,7 @@ var createUploaderCore = (host, options) => {
418
420
  `${lines.join("\n")}
419
421
  `
420
422
  );
421
- quarantined += lines.length;
423
+ quarantinedSinceWrite += lines.length;
422
424
  return {
423
425
  kind: "invalid",
424
426
  message: `${lines.length} Signals were ${reason} and kept in ${quarantineDirectory}: update the producer, then inspect or delete them`
@@ -451,7 +453,7 @@ var createUploaderCore = (host, options) => {
451
453
  continue;
452
454
  }
453
455
  total -= segment.size;
454
- dropped += lines;
456
+ droppedSinceWrite += lines;
455
457
  }
456
458
  }
457
459
  function* split(base, lines, queue2) {
@@ -568,7 +570,14 @@ var createUploaderCore = (host, options) => {
568
570
  }
569
571
  return problem ? { outcome: "done", problem } : { outcome: "done" };
570
572
  }
573
+ const latest = (a, b) => a === void 0 ? b : b === void 0 || a >= b ? a : b;
571
574
  function* snapshot() {
575
+ const written = yield* readStatusTask(directory);
576
+ if (written) {
577
+ quarantined = Math.max(quarantined, written.quarantined);
578
+ dropped = Math.max(dropped, written.dropped);
579
+ lastSuccessAt = latest(lastSuccessAt, written.lastSuccessAt);
580
+ }
572
581
  const segments = yield* listSegments(directory);
573
582
  const status = {
574
583
  updatedAt: now().toISOString(),
@@ -576,8 +585,8 @@ var createUploaderCore = (host, options) => {
576
585
  pendingSignals: yield* linesOf(segments),
577
586
  spoolBytes: segments.reduce((sum, segment) => sum + segment.size, 0),
578
587
  paused,
579
- quarantined,
580
- dropped
588
+ quarantined: quarantined + quarantinedSinceWrite,
589
+ dropped: dropped + droppedSinceWrite
581
590
  };
582
591
  if (config2) {
583
592
  status.machineId = config2.machineId;
@@ -593,6 +602,10 @@ var createUploaderCore = (host, options) => {
593
602
  function* writeStatus() {
594
603
  try {
595
604
  yield* writeAtomically(path(STATUS_FILE), serializeStatus(current));
605
+ quarantined = current.quarantined;
606
+ dropped = current.dropped;
607
+ quarantinedSinceWrite = 0;
608
+ droppedSinceWrite = 0;
596
609
  } catch {
597
610
  }
598
611
  }
@@ -21669,6 +21682,20 @@ var placeLookup = (host, {
21669
21682
  };
21670
21683
  };
21671
21684
 
21685
+ // src/toast.ts
21686
+ var toastText = (problem, pending) => {
21687
+ switch (problem.id) {
21688
+ case "config":
21689
+ return "The config can't be used: run /timekeeper for the fix";
21690
+ case "unauthorized":
21691
+ return "The endpoint rejected the token: run /timekeeper for the fix";
21692
+ case "stalled":
21693
+ return `No upload for a day, ${pending} Signals waiting: run /timekeeper`;
21694
+ case "quarantined":
21695
+ return "The endpoint rejected some Signals: run /timekeeper for details";
21696
+ }
21697
+ };
21698
+
21672
21699
  // src/translate.ts
21673
21700
  var ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
21674
21701
  var id = (value) => typeof value === "string" && ID.test(value) ? value : void 0;
@@ -22019,7 +22046,8 @@ async function checkStatus($, state) {
22019
22046
  if (!state.interactive) return;
22020
22047
  const at = /* @__PURE__ */ new Date();
22021
22048
  const config2 = await loadModConfig(state.host);
22022
- const problem = findProblem(config2, await readModStatus(state.host), at);
22049
+ const status = await readModStatus(state.host);
22050
+ const problem = findProblem(config2, status, at);
22023
22051
  if (problem === void 0) return;
22024
22052
  const shared = await quietly(async () => {
22025
22053
  const text = await $.fs.read(state.toastFile);
@@ -22029,10 +22057,9 @@ async function checkStatus($, state) {
22029
22057
  return;
22030
22058
  }
22031
22059
  state.lastToastHere = at.toISOString();
22032
- $.ui.toast(
22033
- `Agent Timekeeper: ${redact(problem.message, config2.ok ? config2.config.token : void 0)}`,
22034
- { timeoutMs: 1e4 }
22035
- );
22060
+ $.ui.toast(toastText(problem, status?.pendingSignals ?? 0), {
22061
+ timeoutMs: 1e4
22062
+ });
22036
22063
  await quietly(
22037
22064
  () => $.fs.write(
22038
22065
  state.toastFile,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamorosi/agent-timekeeper-claude-code",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Claude Code plugin for Agent Timekeeper: records Sessions, Runs, tool calls and Interactions as Signals, and uploads them to your own endpoint",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {