worktrust 0.10.0 → 0.10.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.
package/README.md CHANGED
@@ -187,6 +187,7 @@ nothing it does not:
187
187
  | `outcomes` | outcomes of the steps: per kind of check whether its first run passed, delivery attempts that failed, a model change and a new plan after a failure each followed by a passing check; and a check whose output goes through a pipe is read from its output's words (an error fails, a pass passes, a silent type check or lint passes, anything else is unconfirmed), never from the pipe's exit code (0.9.8) |
188
188
  | `retrieval` | retrieval and grounding: searches (grep, rg, find, Grep, Glob, a web search, an MCP search tool), the same search again, a search followed by a read or a change (found) or by another search (again), searches before the first change and right after a failure, and deliveries with docs, tests or a search since the last change (grounded); counts only, nothing searched is kept (0.9.9) |
189
189
  | `window` | the context window, from the token counts the AI app writes beside each answer (input plus cached, once per message): the peak a turn carried, the turns over 100k, 200k and 500k, the growth from the first quarter of answers to the last, and compactions near the peak; counts only, nothing of what the context held (0.10.0) |
190
+ | `review` | reviewing the agent: reviews while it worked, the middle interval, subagent runs reviewed, and what a review led to (a change of course, a change, a check); counts only (0.10.1) |
190
191
  | `collector_version` | the CLI version that measured it |
191
192
  | `seq`, `prev`, `hash` | the line's place, the hash of the line before it, and its own hash |
192
193
 
package/config-edits.mjs CHANGED
@@ -71,14 +71,17 @@ export function takeOut(lines, path, mine) {
71
71
  /**
72
72
  * ONLY THE HOUSE'S OWN DOOR (0.6.16, audit L5; the same rule as log-session.mjs and count-behaviour.mjs): an MCP address is
73
73
  * WorkTrust's when its path is /api/mcp and its host is worktrust.io or a subdomain over https, the host WORKTRUST_MCP_URL
74
- * names, or this computer. `/api/mcp` alone is every hosted MCP server's conventional path, so another product's entry is
74
+ * names, or WorkTrust's own port on this computer. `/api/mcp` alone is every hosted MCP server's conventional path, so another product's entry is
75
75
  * never adopted as the coupling, and never taken out with it.
76
76
  */
77
+ /** WorkTrust's own local doors (the app in development, 3011; a module branch, 3021). Another product's local MCP server
78
+ * (the Advisory Board on 3007, 2026-10-09) is not one: it was offered for removal on update, and could have been adopted. */
79
+ const LOCAL_DOOR_PORTS = new Set(["3011", "3021"]);
77
80
  export const isWorkTrustDoor = (url) => {
78
81
  try {
79
82
  const parsed = new URL(String(url));
80
83
  if (!/\/api\/mcp\/?$/.test(parsed.pathname)) return false;
81
84
  const own = process.env.WORKTRUST_MCP_URL ? new URL(process.env.WORKTRUST_MCP_URL).host : null;
82
- return parsed.protocol === "https:" && (parsed.hostname === "worktrust.io" || parsed.hostname.endsWith(".worktrust.io")) || (own !== null && parsed.host === own) || parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1";
85
+ return parsed.protocol === "https:" && (parsed.hostname === "worktrust.io" || parsed.hostname.endsWith(".worktrust.io")) || (own !== null && parsed.host === own) || ((parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1") && LOCAL_DOOR_PORTS.has(parsed.port));
83
86
  } catch { return false; }
84
87
  };
@@ -485,12 +485,15 @@ if (flag("classify")) {
485
485
  * fetched a script to run from its origin. A door is WorkTrust's when its host is worktrust.io or a
486
486
  * subdomain, or a local one named by WORKTRUST_MCP_URL; nothing else is a coupling.
487
487
  */
488
+ /** WorkTrust's own local doors (the app in development, 3011; a module branch, 3021). Another product's local MCP server
489
+ * (the Advisory Board on 3007, 2026-10-09) is not one: it was offered for removal on update, and could have been adopted. */
490
+ const LOCAL_DOOR_PORTS = new Set(["3011", "3021"]);
488
491
  const isWorkTrustDoor = (url) => {
489
492
  try {
490
493
  const parsed = new URL(String(url));
491
494
  if (!/\/api\/mcp\/?$/.test(parsed.pathname)) return false;
492
495
  const own = process.env.WORKTRUST_MCP_URL ? new URL(process.env.WORKTRUST_MCP_URL).host : null;
493
- return parsed.protocol === "https:" && (parsed.hostname === "worktrust.io" || parsed.hostname.endsWith(".worktrust.io")) || (own !== null && parsed.host === own) || parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1";
496
+ return parsed.protocol === "https:" && (parsed.hostname === "worktrust.io" || parsed.hostname.endsWith(".worktrust.io")) || (own !== null && parsed.host === own) || ((parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1") && LOCAL_DOOR_PORTS.has(parsed.port));
494
497
  } catch { return false; }
495
498
  };
496
499
  function fromClientConfig() {
package/log-session.mjs CHANGED
@@ -212,12 +212,15 @@ const floorOf = (state, key) => { const at = typeof state?.[key] === "string" ?
212
212
  * fetched a script to run from its origin. A door is WorkTrust's when its host is worktrust.io or a
213
213
  * subdomain, or a local one named by WORKTRUST_MCP_URL; nothing else is a coupling.
214
214
  */
215
+ /** WorkTrust's own local doors (the app in development, 3011; a module branch, 3021). Another product's local MCP server
216
+ * (the Advisory Board on 3007, 2026-10-09) is not one: it was offered for removal on update, and could have been adopted. */
217
+ const LOCAL_DOOR_PORTS = new Set(["3011", "3021"]);
215
218
  const isWorkTrustDoor = (url) => {
216
219
  try {
217
220
  const parsed = new URL(String(url));
218
221
  if (!/\/api\/mcp\/?$/.test(parsed.pathname)) return false;
219
222
  const own = process.env.WORKTRUST_MCP_URL ? new URL(process.env.WORKTRUST_MCP_URL).host : null;
220
- return parsed.protocol === "https:" && (parsed.hostname === "worktrust.io" || parsed.hostname.endsWith(".worktrust.io")) || (own !== null && parsed.host === own) || parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1";
223
+ return parsed.protocol === "https:" && (parsed.hostname === "worktrust.io" || parsed.hostname.endsWith(".worktrust.io")) || (own !== null && parsed.host === own) || ((parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1") && LOCAL_DOOR_PORTS.has(parsed.port));
221
224
  } catch { return false; }
222
225
  };
223
226
  /** The coupling: given, or the one Claude Code already holds — the same read the counter does. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worktrust",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Couple this computer to WorkTrust: approve a code in your browser, and every AI app here reports what you built. Metadata only, no dependencies.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -157,6 +157,11 @@ export function archiveLine(entry, behaviour = null, { ids = {}, collector, salt
157
157
  const span = Object.fromEntries(WINDOW_KEYS.filter((key) => Number.isInteger(entry.window[key]) && entry.window[key] >= 0).map((key) => [key, entry.window[key]]));
158
158
  if (Object.keys(span).length > 0) line.window = span;
159
159
  }
160
+ // 0.10.1: reviewing the agent; whole counts only.
161
+ if (entry.review && typeof entry.review === "object") {
162
+ const review = Object.fromEntries(REVIEW_KEYS.filter((key) => Number.isInteger(entry.review[key]) && entry.review[key] >= 0 && entry.review[key] <= 100_000).map((key) => [key, entry.review[key]]));
163
+ if (Object.keys(review).length > 0) line.review = review;
164
+ }
160
165
  const risk = pick(entry.risk, ["proposed", "refused", "run"]);
161
166
  if (risk && risk.proposed > 0 && risk.refused + risk.run <= risk.proposed) line.risk = risk;
162
167
  const keyed = (record, keys) => { const kept = Object.entries(record && typeof record === "object" ? record : {}).filter(([key, n]) => keys.includes(key) && whole(n) && n > 0).sort(); return kept.length ? Object.fromEntries(kept) : null; };
@@ -218,6 +223,8 @@ const STAGES = ["attempted", "verified", "committed", "pushed", "pr", "deployed"
218
223
  /** How fast a stretch moved (0.9.0). */
219
224
  /** The context window (0.10.0); the peak may pass the whole-count bound of 100,000. */
220
225
  const WINDOW_KEYS = ["peak", "over_100k", "over_200k", "over_500k", "growth", "compact_near_peak"];
226
+ /** Reviewing the agent (0.10.1): counts, and the middle interval between reviews in seconds. */
227
+ const REVIEW_KEYS = ["reviews", "agent_runs", "agent_runs_reviewed", "changed_course", "changed_code", "checked", "interval_median_s"];
221
228
  /** Retrieval and grounding (0.9.9). */
222
229
  const RETRIEVAL_KEYS = ["searches", "repeated", "found", "again", "before_change", "after_failure", "deliveries", "grounded"];
223
230
  /** Outcomes of the steps (0.9.8). */
@@ -233,7 +240,7 @@ const ROUTE_KEYS = ["branches", "pushes_to_main", "commits_large", "fix_followup
233
240
  /** Risk and hygiene (0.9.1). */
234
241
  const HYGIENE_KEYS = ["rollbacks", "privileged", "bypasses", "secrets", "destructive", "destructive_checked", "guard_retried", "guard_changed", "guard_stopped"];
235
242
  const TIMING_KEYS = ["first_action_s", "first_check_s", "detect_actions", "detect_s", "recovery_calls", "resume_actions"];
236
- export const DERIVED_KEYS = ["signals", "analyzer_version", "verification", "unconfirmed", "delivery", "recovery", "delegation", "context", "routing", "steering", "tools", "complexity", "oversight", "planning", "changes", "autonomy", "authorship", "framing", "quality", "risk", "tool_mix", "reads", "context_files", "stage", "timing", "hygiene", "route", "adaptation", "reach", "outcomes", "retrieval", "window", "interrupts", "steers", "utc_offset"];
243
+ export const DERIVED_KEYS = ["signals", "analyzer_version", "verification", "unconfirmed", "delivery", "recovery", "delegation", "context", "routing", "steering", "tools", "complexity", "oversight", "planning", "changes", "autonomy", "authorship", "framing", "quality", "risk", "tool_mix", "reads", "context_files", "stage", "timing", "hygiene", "route", "adaptation", "reach", "outcomes", "retrieval", "window", "review", "interrupts", "steers", "utc_offset"];
237
244
  export function supplementFor(line, earlier) {
238
245
  const missing = DERIVED_KEYS.filter((key) => line[key] !== undefined && !earlier.some((old) => old[key] !== undefined));
239
246
  if (missing.length === 0) return null;
@@ -680,6 +680,54 @@ function windowOf(messages) {
680
680
  return Object.fromEntries(Object.entries(out).filter(([key, value]) => key === "peak" || value > 0));
681
681
  }
682
682
 
683
+ /**
684
+ * REVIEWING THE AGENT (0.10.1; Agent Oversight & Steering): a REVIEW is the person's turn while the agent was working (a
685
+ * tool call since their last turn). Counted: reviews, the middle of the time between them, subagent runs and how many the
686
+ * person reviewed before the next change or delivery, and what a review led to within three calls: the agent changing
687
+ * course (another model, a plan left, a to-do list that grew or shrank; another tool alone says nothing), a change (something found), a check. What was said is never read.
688
+ */
689
+ function reviewOf(messages, { isHumanTurn }) {
690
+ const out = { reviews: 0, agent_runs: 0, agent_runs_reviewed: 0, changed_course: 0, changed_code: 0, checked: 0 };
691
+ const times = [];
692
+ let workedSinceTurn = false, lastModel = null, lastItems = null, after = null, agentPending = 0;
693
+ for (const message of messages) {
694
+ if (message.bridge) continue;
695
+ if (message.type === "user" && !message.meta && message.kind !== "tool_result" && isHumanTurn(message.content)) {
696
+ if (workedSinceTurn) {
697
+ out.reviews += 1;
698
+ if (Number.isFinite(message.at)) times.push(message.at);
699
+ out.agent_runs_reviewed += agentPending;
700
+ after = { left: 3, changed: false, coded: false, checked: false };
701
+ }
702
+ agentPending = 0; workedSinceTurn = false;
703
+ continue;
704
+ }
705
+ if (message.type === "assistant" && message.model && after && after.left > 0 && lastModel && message.model !== lastModel && !after.changed) { after.changed = true; out.changed_course += 1; }
706
+ if (message.type === "assistant" && message.model) lastModel = message.model;
707
+ for (const call of message.calls ?? []) {
708
+ const tool = call.family.split("|")[0];
709
+ workedSinceTurn = true;
710
+ if (tool === "Agent" || tool === "Task") { out.agent_runs += 1; agentPending += 1; }
711
+ if (EDIT_TOOLS.has(tool) || call.kinds.some((kind) => DELIVERY_KINDS.includes(kind))) agentPending = 0;
712
+ if (after && after.left > 0) {
713
+ // Another model, a plan left, or a to-do list that grew or shrank: not merely another tool (after almost every turn the
714
+ // next tool differs, 84% on the owner's history) and not a ticked item.
715
+ const replanned = tool === "ExitPlanMode" || (call.plan && lastItems !== null && call.plan.items !== lastItems);
716
+ if (!after.changed && replanned) { after.changed = true; out.changed_course += 1; }
717
+ if (!after.coded && EDIT_TOOLS.has(tool)) { after.coded = true; out.changed_code += 1; }
718
+ if (!after.checked && call.kinds.some((kind) => CHECK_KINDS.includes(kind))) { after.checked = true; out.checked += 1; }
719
+ after.left -= 1;
720
+ }
721
+ if (call.plan) lastItems = call.plan.items;
722
+ }
723
+ }
724
+ if (out.reviews === 0 && out.agent_runs === 0) return null;
725
+ const gaps = times.slice(1).map((time, index) => Math.round((time - times[index]) / 1000)).filter((gap) => gap >= 0).sort((a, b) => a - b);
726
+ const kept = Object.fromEntries(Object.entries(out).filter(([, value]) => value > 0));
727
+ if (gaps.length >= 2) kept.interval_median_s = gaps[Math.floor(gaps.length / 2)];
728
+ return kept;
729
+ }
730
+
683
731
  /** The stretch's whole derived record; `helpers` are the hook's own readers of a human turn, so both read it the same way. */
684
732
  /** A piped check's outcome from its output's words: failed or passed when they say so, unknown (null) when they do not. */
685
733
  function settlePiped(messages) {
@@ -695,6 +743,6 @@ function settlePiped(messages) {
695
743
  export function deriveStretch(raw, helpers) {
696
744
  const messages = settlePiped(raw);
697
745
  const context = contextOf(messages, helpers), routing = routingOf(messages), steering = steeringOf(messages, helpers);
698
- const timing = timingOf(messages, helpers), hygiene = hygieneOf(messages), route = routeOf(messages), adaptation = adaptationOf(messages), reach = reachOf(messages), outcomes = outcomesOf(messages), retrieval = retrievalOf(messages), window = windowOf(messages), tools = toolsOf(messages), oversight = oversightOf(messages), planning = planningOf(messages), autonomy = autonomyOf(messages), practice = practiceOf(messages, helpers);
699
- return { ...(practice ?? {}), ...(oversight ? { oversight } : {}), ...(planning ? { planning } : {}), ...(autonomy ? { autonomy } : {}), ...verificationOf(messages, helpers), ...(context ? { context } : {}), ...(routing ? { routing } : {}), ...(steering ? { steering } : {}), ...(tools ? { tools } : {}), ...(timing ? { timing } : {}), ...(hygiene ? { hygiene } : {}), ...(route ? { route } : {}), ...(adaptation ? { adaptation } : {}), ...(reach ? { reach } : {}), ...(outcomes ? { outcomes } : {}), ...(retrieval ? { retrieval } : {}), ...(window ? { window } : {}) };
746
+ const timing = timingOf(messages, helpers), hygiene = hygieneOf(messages), route = routeOf(messages), adaptation = adaptationOf(messages), reach = reachOf(messages), outcomes = outcomesOf(messages), retrieval = retrievalOf(messages), window = windowOf(messages), review = reviewOf(messages, helpers), tools = toolsOf(messages), oversight = oversightOf(messages), planning = planningOf(messages), autonomy = autonomyOf(messages), practice = practiceOf(messages, helpers);
747
+ return { ...(practice ?? {}), ...(oversight ? { oversight } : {}), ...(planning ? { planning } : {}), ...(autonomy ? { autonomy } : {}), ...verificationOf(messages, helpers), ...(context ? { context } : {}), ...(routing ? { routing } : {}), ...(steering ? { steering } : {}), ...(tools ? { tools } : {}), ...(timing ? { timing } : {}), ...(hygiene ? { hygiene } : {}), ...(route ? { route } : {}), ...(adaptation ? { adaptation } : {}), ...(reach ? { reach } : {}), ...(outcomes ? { outcomes } : {}), ...(retrieval ? { retrieval } : {}), ...(window ? { window } : {}), ...(review ? { review } : {}) };
700
748
  }
package/worktrust.mjs CHANGED
@@ -73,7 +73,7 @@ const command = args.find((arg, at) => !arg.startsWith("--") && !(at > 0 && VALU
73
73
  const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
74
74
  const has = (name) => args.includes(`--${name}`);
75
75
  /** This CLI's version, said to the door so the app can tell which computer runs an old one (check-cli-package holds it equal to package.json). */
76
- const CLI_VERSION = "0.10.0";
76
+ const CLI_VERSION = "0.10.2";
77
77
  const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.worktrust.io").replace(/\/$/, "");
78
78
  const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
79
79
  const HOME_DIR = join(homedir(), ".worktrust");