worktrust 0.10.13 → 0.10.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/AGENTS.md +5 -0
- package/README.md +23 -2
- package/SECURITY.md +26 -0
- package/orchestration-contract.mjs +155 -0
- package/orchestration-evidence.mjs +59 -0
- package/orchestration-report.mjs +28 -0
- package/package.json +5 -2
- package/worktrust.mjs +9 -4
package/AGENTS.md
CHANGED
|
@@ -16,6 +16,11 @@ the variables your client sets, do not run it through another shell, and do not
|
|
|
16
16
|
The session hook and the MCP door are started by your client itself and are meant to run; leave their configuration as
|
|
17
17
|
the person set it. This does not authorize an agent to invoke `preserve` through another entry point. Even `status`
|
|
18
18
|
can inspect local evidence and check the registry; do not run it as a generic repository inventory command.
|
|
19
|
+
The new `orchestration report --file` command reads a person's explicitly selected agent metadata
|
|
20
|
+
and is person-only too. Repository maintenance tests may use synthetic recordings. Python SDK
|
|
21
|
+
events remain application reports: do not manufacture security events, verification or success,
|
|
22
|
+
and do not describe them as independently measured capability. See `docs/AGENT-OBSERVATIONS.md`
|
|
23
|
+
in the monorepo for the contract and the private Sources page.
|
|
19
24
|
|
|
20
25
|
## Do not report work you did not see
|
|
21
26
|
|
package/README.md
CHANGED
|
@@ -17,10 +17,19 @@ curl -fsSO https://app.worktrust.io/counter/worktrust.mjs && node worktrust.mjs
|
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
**Python tool runners:** this repository also builds `worktrust` for `uvx` and `pipx` from the
|
|
20
|
-
same measurement modules.
|
|
20
|
+
same measurement modules. Native wheels (0.10.13+) include a pinned official Node runtime,
|
|
21
21
|
so that route needs no separate Node/npm installation. See the
|
|
22
22
|
[Python distribution](https://github.com/fhomey/worktrust-cli/tree/main/python) for supported
|
|
23
|
-
platforms
|
|
23
|
+
platforms and installation commands, and the official [PyPI project](https://pypi.org/project/worktrust/)
|
|
24
|
+
for published versions. npm and Python versions are checked together.
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
uvx worktrust@latest preserve
|
|
28
|
+
pipx run --no-cache worktrust preserve
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Omit `preserve` to connect your computer. These runners install and invoke the same CLI;
|
|
32
|
+
they do not automatically instrument Python applications or measure different activity.
|
|
24
33
|
|
|
25
34
|
Connecting through the Python package installs the runtime and engine in an immutable directory
|
|
26
35
|
under `~/.worktrust/installations/`; client hooks use that persistent path, so clearing a tool-runner
|
|
@@ -28,6 +37,18 @@ cache does not break the coupling. Updates retain older installations for runnin
|
|
|
28
37
|
Run `worktrust disconnect` before removing an installed Python tool if you also want to remove its
|
|
29
38
|
WorkTrust coupling. Disconnect removes the key and client wiring; it leaves runtime files in place.
|
|
30
39
|
|
|
40
|
+
**Agent observations (requires 0.10.14+):** the optional Python
|
|
41
|
+
`worktrust_cli.telemetry` SDK lets an application explicitly record parent/child runs, its own
|
|
42
|
+
token counters, token budgets, checks and security events in a local file. The shared engine
|
|
43
|
+
inspects it with `worktrust orchestration report --file agent-events.jsonl`, without uploading.
|
|
44
|
+
The private platform import is Sources → Agent teams when that platform change is deployed.
|
|
45
|
+
These are application reports, not human hours or independently verified outcomes. Installing
|
|
46
|
+
through npm, uvx or pipx alone does not instrument agents. See the Python README for the opt-in
|
|
47
|
+
SDK, fixed metadata fields, consent and local deletion. Install `worktrust>=0.10.14` in the
|
|
48
|
+
agent application's own Python environment to import the SDK; a uvx/pipx tool environment
|
|
49
|
+
is separate. Check the registry for availability: a GitHub release awaiting approval is not
|
|
50
|
+
a completed npm or PyPI publication.
|
|
51
|
+
|
|
31
52
|
**No account? Keep your history anyway.** Claude Code and Gemini CLI delete their sessions after 30
|
|
32
53
|
days by default, and a deleted session can never be measured again. `npx worktrust@latest preserve` shows what
|
|
33
54
|
each AI app on this computer keeps, keeps it longer on your yes, and writes a local, metadata-only
|
package/SECURITY.md
CHANGED
|
@@ -71,3 +71,29 @@ Check the particular published version's attestation and compare its contents to
|
|
|
71
71
|
relying on those properties. A manifest flag or matching version string alone is not proof that an
|
|
72
72
|
artifact was built from reviewed source. `npm audit signatures` can inspect an installed dependency
|
|
73
73
|
tree; verification coverage and failures must be reported for that actual installation.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## Python distribution and explicit agent observations
|
|
77
|
+
|
|
78
|
+
The official [PyPI package](https://pypi.org/project/worktrust/) runs the same measurement
|
|
79
|
+
modules as npm. Supported wheels include the pinned Node runtime; invocation does not download
|
|
80
|
+
Node, fall back to PATH or relay to a newer npm version. Package-manager installation and
|
|
81
|
+
upgrades can contact registries. Use the README for platform requirements and update commands.
|
|
82
|
+
|
|
83
|
+
From 0.10.14, the optional Python recorder writes explicitly supplied UUIDs, dates, fixed event
|
|
84
|
+
categories and counts to a newly chosen local file, with `consent=True`. It makes no network
|
|
85
|
+
requests and does not discover agents or inspect their prompts, outputs, model names or code.
|
|
86
|
+
The local `orchestration report --file` command also sends nothing. Recordings are bounded;
|
|
87
|
+
existing files and symlink paths are refused. The requested file mode is 0600; Windows folder
|
|
88
|
+
ACLs and other processes running as the same user remain outside that protection.
|
|
89
|
+
|
|
90
|
+
These observations are application reports, including reported checks and security events.
|
|
91
|
+
They do not independently establish successful outcomes, prompt-injection resistance, human
|
|
92
|
+
hours or capability. Parent/child elapsed time includes waiting and must not be summed as
|
|
93
|
+
human work. Missing token coverage remains unknown; providers must supply exclusive deltas.
|
|
94
|
+
|
|
95
|
+
The separate private platform import requires a deployed platform feature and explicit browser
|
|
96
|
+
selection and consent. It is not an automatic SDK upload or an MCP submission. Deleting a local
|
|
97
|
+
recording does not erase a separately imported copy; delete that copy through the private app.
|
|
98
|
+
See the service [privacy policy](https://worktrust.io/privacy) and
|
|
99
|
+
[support](https://worktrust.io/support) for account data requests.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// GENERATED by scripts/build-orchestration-evidence.mjs; edit packages/core/src/orchestration-contract.ts.
|
|
2
|
+
/** Explicit application reports, never verified human work. No names, prompts or provider payloads. */
|
|
3
|
+
export const ORCHESTRATION_LIMITS = { bytes: 262144, lineBytes: 4096, events: 2048, runs: 64, elapsed: 604800000, tokens: 1000000000 };
|
|
4
|
+
export const AGENT_ROLES = ["orchestrator", "worker", "reviewer", "researcher", "verifier", "other"];
|
|
5
|
+
export const AGENT_TASK_KINDS = ["build", "fix", "review", "research", "decide", "other"];
|
|
6
|
+
export const SECURITY_EVENT_CODES = ["injection_candidate_seen", "injection_ignored", "injection_followed", "untrusted_instruction_escalated", "external_instruction_override_attempt", "suspicious_tool_blocked"];
|
|
7
|
+
export const INTERVENTION_CODES = ["challenge", "reframe", "alternative", "verification_request"];
|
|
8
|
+
export const USAGE_KEYS = ["input_uncached_tokens", "cache_read_tokens", "cache_write_tokens", "output_tokens"];
|
|
9
|
+
const uuid = (value) => typeof value === "string" && value.length === 36 && /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(value);
|
|
10
|
+
const integer = (value, max, min = 0) => typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
|
|
11
|
+
const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
12
|
+
const fail = () => { throw new Error("invalid_orchestration_recording"); };
|
|
13
|
+
const exact = (row, required, optional = []) => {
|
|
14
|
+
if (required.some((key) => !Object.hasOwn(row, key)) || Object.keys(row).some((key) => !required.includes(key) && !optional.includes(key)))
|
|
15
|
+
fail();
|
|
16
|
+
};
|
|
17
|
+
const includes = (list, value) => typeof value === "string" && list.includes(value);
|
|
18
|
+
const bytes = (text) => new TextEncoder().encode(text).length;
|
|
19
|
+
/** Stable identity for duplicate comparison, also independent of JSON object key order. */
|
|
20
|
+
export function orchestrationCanonical(value) {
|
|
21
|
+
if (Array.isArray(value))
|
|
22
|
+
return `[${value.map(orchestrationCanonical).join(",")}]`;
|
|
23
|
+
if (object(value))
|
|
24
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${orchestrationCanonical(value[key])}`).join(",")}}`;
|
|
25
|
+
return JSON.stringify(value) ?? fail();
|
|
26
|
+
}
|
|
27
|
+
function header(row) {
|
|
28
|
+
if (row.schema !== 1 || !uuid(row.session_id) || typeof row.started_at !== "string" || !/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(row.started_at))
|
|
29
|
+
fail();
|
|
30
|
+
const date = new Date(row.started_at);
|
|
31
|
+
if (!Number.isFinite(date.getTime()) || date.toISOString() !== row.started_at)
|
|
32
|
+
fail();
|
|
33
|
+
}
|
|
34
|
+
function event(value) {
|
|
35
|
+
if (!object(value) || bytes(JSON.stringify(value)) > ORCHESTRATION_LIMITS.lineBytes)
|
|
36
|
+
fail();
|
|
37
|
+
const row = value;
|
|
38
|
+
const base = ["event_id", "run_id", "sequence", "elapsed_ms", "kind"];
|
|
39
|
+
if (!uuid(row.event_id) || !uuid(row.run_id) || !integer(row.sequence, ORCHESTRATION_LIMITS.events, 1) || !integer(row.elapsed_ms, ORCHESTRATION_LIMITS.elapsed))
|
|
40
|
+
fail();
|
|
41
|
+
switch (row.kind) {
|
|
42
|
+
case "run_started":
|
|
43
|
+
exact(row, [...base, "agent_id", "agent_version", "role", "task_kind"], ["parent_run_id"]);
|
|
44
|
+
if (!uuid(row.agent_id) || !uuid(row.agent_version) || !includes(AGENT_ROLES, row.role) || !includes(AGENT_TASK_KINDS, row.task_kind) || (Object.hasOwn(row, "parent_run_id") && !uuid(row.parent_run_id)))
|
|
45
|
+
fail();
|
|
46
|
+
break;
|
|
47
|
+
case "run_finished":
|
|
48
|
+
exact(row, [...base, "status"]);
|
|
49
|
+
if (!includes(["succeeded", "failed", "cancelled"], row.status))
|
|
50
|
+
fail();
|
|
51
|
+
break;
|
|
52
|
+
case "usage":
|
|
53
|
+
exact(row, [...base, "scope"], USAGE_KEYS);
|
|
54
|
+
if (row.scope !== "own" || !USAGE_KEYS.some((key) => Object.hasOwn(row, key)) || USAGE_KEYS.some((key) => Object.hasOwn(row, key) && !integer(row[key], ORCHESTRATION_LIMITS.tokens)))
|
|
55
|
+
fail();
|
|
56
|
+
break;
|
|
57
|
+
case "budget":
|
|
58
|
+
exact(row, [...base, "token_limit"]);
|
|
59
|
+
if (!integer(row.token_limit, ORCHESTRATION_LIMITS.tokens, 1))
|
|
60
|
+
fail();
|
|
61
|
+
break;
|
|
62
|
+
case "security":
|
|
63
|
+
exact(row, [...base, "code", "source"]);
|
|
64
|
+
if (!includes(SECURITY_EVENT_CODES, row.code) || !includes(["client_report", "boundary_report"], row.source))
|
|
65
|
+
fail();
|
|
66
|
+
break;
|
|
67
|
+
case "verification":
|
|
68
|
+
exact(row, [...base, "result"]);
|
|
69
|
+
if (!includes(["passed", "failed"], row.result))
|
|
70
|
+
fail();
|
|
71
|
+
break;
|
|
72
|
+
case "intervention":
|
|
73
|
+
exact(row, [...base, "code"]);
|
|
74
|
+
if (!includes(INTERVENTION_CODES, row.code))
|
|
75
|
+
fail();
|
|
76
|
+
break;
|
|
77
|
+
default: fail();
|
|
78
|
+
}
|
|
79
|
+
// Reconstruct through JSON: no caller-owned references or getters reach storage/summary.
|
|
80
|
+
return JSON.parse(JSON.stringify(row));
|
|
81
|
+
}
|
|
82
|
+
/** Validates every event and graph edge. Reorders replay deterministically; repeated IDs must be identical. */
|
|
83
|
+
export function validateOrchestrationRecording(input) {
|
|
84
|
+
if (!object(input) || bytes(JSON.stringify(input)) > ORCHESTRATION_LIMITS.bytes)
|
|
85
|
+
fail();
|
|
86
|
+
const row = input;
|
|
87
|
+
exact(row, ["schema", "session_id", "started_at", "events"]);
|
|
88
|
+
header(row);
|
|
89
|
+
if (!Array.isArray(row.events) || row.events.length === 0 || row.events.length > ORCHESTRATION_LIMITS.events)
|
|
90
|
+
fail();
|
|
91
|
+
const unique = new Map();
|
|
92
|
+
for (const raw of row.events) {
|
|
93
|
+
const item = event(raw), prior = unique.get(item.event_id);
|
|
94
|
+
if (prior && orchestrationCanonical(prior) !== orchestrationCanonical(item))
|
|
95
|
+
fail();
|
|
96
|
+
unique.set(item.event_id, item);
|
|
97
|
+
}
|
|
98
|
+
const events = [...unique.values()].sort((a, b) => a.sequence - b.sequence);
|
|
99
|
+
const starts = new Map();
|
|
100
|
+
const finishes = new Set(), used = new Set(), budgets = new Set();
|
|
101
|
+
let previousSequence = 0, previousElapsed = 0;
|
|
102
|
+
for (const item of events) {
|
|
103
|
+
if (item.sequence !== previousSequence + 1 || item.elapsed_ms < previousElapsed)
|
|
104
|
+
fail();
|
|
105
|
+
previousSequence = item.sequence;
|
|
106
|
+
previousElapsed = item.elapsed_ms;
|
|
107
|
+
if (item.kind === "run_started") {
|
|
108
|
+
if (starts.has(item.run_id) || (item.parent_run_id && (!starts.has(item.parent_run_id) || finishes.has(item.parent_run_id))))
|
|
109
|
+
fail();
|
|
110
|
+
starts.set(item.run_id, item);
|
|
111
|
+
if (starts.size > ORCHESTRATION_LIMITS.runs)
|
|
112
|
+
fail();
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
if (!starts.has(item.run_id) || finishes.has(item.run_id))
|
|
116
|
+
fail();
|
|
117
|
+
if (item.kind === "run_finished") {
|
|
118
|
+
// A parent cannot finish before its active children. Interrupted recordings keep it open.
|
|
119
|
+
if ([...starts.values()].some((start) => start.parent_run_id === item.run_id && !finishes.has(start.run_id)))
|
|
120
|
+
fail();
|
|
121
|
+
finishes.add(item.run_id);
|
|
122
|
+
}
|
|
123
|
+
if (item.kind === "usage")
|
|
124
|
+
used.add(item.run_id);
|
|
125
|
+
if (item.kind === "budget") {
|
|
126
|
+
if (budgets.has(item.run_id) || used.has(item.run_id))
|
|
127
|
+
fail();
|
|
128
|
+
budgets.add(item.run_id);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return { schema: 1, session_id: row.session_id, started_at: row.started_at, events };
|
|
133
|
+
}
|
|
134
|
+
/** JSONL is an explicit opt-in file; an incomplete last line is rejected, never silently truncated. */
|
|
135
|
+
export function parseOrchestrationJsonl(text) {
|
|
136
|
+
if (typeof text !== "string" || bytes(text) > ORCHESTRATION_LIMITS.bytes)
|
|
137
|
+
fail();
|
|
138
|
+
const lines = text.replace(/\r\n/g, "\n").split("\n");
|
|
139
|
+
if (lines.at(-1) === "")
|
|
140
|
+
lines.pop();
|
|
141
|
+
if (lines.length < 2 || lines.some((line) => !line || bytes(line) > ORCHESTRATION_LIMITS.lineBytes))
|
|
142
|
+
fail();
|
|
143
|
+
let rows;
|
|
144
|
+
try {
|
|
145
|
+
rows = lines.map((line) => JSON.parse(line));
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return fail();
|
|
149
|
+
}
|
|
150
|
+
if (!object(rows[0]))
|
|
151
|
+
fail();
|
|
152
|
+
const first = rows[0];
|
|
153
|
+
exact(first, ["schema", "session_id", "started_at"]);
|
|
154
|
+
return validateOrchestrationRecording({ ...first, events: rows.slice(1) });
|
|
155
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// GENERATED by scripts/build-orchestration-evidence.mjs; edit packages/core/src/orchestration-evidence.ts.
|
|
2
|
+
/** Descriptive application telemetry. No scoring, hiring inference or autonomous-to-human time conversion. */
|
|
3
|
+
import { USAGE_KEYS, validateOrchestrationRecording } from "./orchestration-contract.mjs";
|
|
4
|
+
export * from "./orchestration-contract.mjs";
|
|
5
|
+
function summarizeRun(start, events) {
|
|
6
|
+
const end = events.find((item) => item.kind === "run_finished");
|
|
7
|
+
const usages = events.filter((item) => item.kind === "usage");
|
|
8
|
+
const completeUsage = usages.length > 0 && usages.every((item) => USAGE_KEYS.every((key) => item[key] !== undefined));
|
|
9
|
+
const counts = Object.fromEntries(USAGE_KEYS.map((key) => [key, usages.reduce((sum, item) => sum + (item[key] ?? 0), 0)]));
|
|
10
|
+
const total = completeUsage ? USAGE_KEYS.reduce((sum, key) => sum + counts[key], 0) : null;
|
|
11
|
+
const input = counts.input_uncached_tokens + counts.cache_read_tokens + counts.cache_write_tokens;
|
|
12
|
+
const budget = events.find((item) => item.kind === "budget");
|
|
13
|
+
const checks = events.filter((item) => item.kind === "verification");
|
|
14
|
+
const security = {}, interventions = {};
|
|
15
|
+
for (const item of events) {
|
|
16
|
+
if (item.kind === "security")
|
|
17
|
+
security[item.code] = (security[item.code] ?? 0) + 1;
|
|
18
|
+
if (item.kind === "intervention")
|
|
19
|
+
interventions[item.code] = (interventions[item.code] ?? 0) + 1;
|
|
20
|
+
}
|
|
21
|
+
const limit = budget?.kind === "budget" ? budget.token_limit : null;
|
|
22
|
+
return {
|
|
23
|
+
run_id: start.run_id, ...(start.parent_run_id ? { parent_run_id: start.parent_run_id } : {}), agent_id: start.agent_id, agent_version: start.agent_version,
|
|
24
|
+
role: start.role, task_kind: start.task_kind, status: end?.kind === "run_finished" ? end.status : "incomplete", elapsed_ms: end ? end.elapsed_ms - start.elapsed_ms : null,
|
|
25
|
+
tokens_total: total, cache_share: completeUsage && input > 0 ? counts.cache_read_tokens / input : null, token_limit: limit,
|
|
26
|
+
budget_exceeded: total !== null && limit !== null ? total > limit : null,
|
|
27
|
+
verification: checks.length ? { passed: checks.filter((item) => item.kind === "verification" && item.result === "passed").length, failed: checks.filter((item) => item.kind === "verification" && item.result === "failed").length } : null,
|
|
28
|
+
security, interventions,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** One engine for CLI and platform. Missing counters stay unknown; finished means reported, not accepted by a customer. */
|
|
32
|
+
export function summarizeOrchestration(input) {
|
|
33
|
+
const recording = validateOrchestrationRecording(input);
|
|
34
|
+
const starts = recording.events.filter((item) => item.kind === "run_started");
|
|
35
|
+
const runs = starts.map((start) => summarizeRun(start, recording.events.filter((item) => item.run_id === start.run_id)));
|
|
36
|
+
const allComplete = runs.every((run) => run.elapsed_ms !== null);
|
|
37
|
+
const boundaryCounts = new Map();
|
|
38
|
+
for (const item of recording.events) {
|
|
39
|
+
if (item.kind !== "run_started" && item.kind !== "run_finished")
|
|
40
|
+
continue;
|
|
41
|
+
boundaryCounts.set(item.elapsed_ms, (boundaryCounts.get(item.elapsed_ms) ?? 0) + (item.kind === "run_started" ? 1 : -1));
|
|
42
|
+
}
|
|
43
|
+
let active = 0, peak = 0, union = 0, previous = 0;
|
|
44
|
+
for (const [elapsed, delta] of [...boundaryCounts].sort((a, b) => a[0] - b[0])) {
|
|
45
|
+
if (active > 0)
|
|
46
|
+
union += elapsed - previous;
|
|
47
|
+
active += delta;
|
|
48
|
+
peak = Math.max(peak, active);
|
|
49
|
+
previous = elapsed;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
provenance: "application_reported", session_id: recording.session_id, started_at: recording.started_at, runs,
|
|
53
|
+
coverage: { runs: runs.length, complete_runs: runs.filter((run) => run.elapsed_ms !== null).length, usage_runs: runs.filter((run) => run.tokens_total !== null).length, events: recording.events.length },
|
|
54
|
+
elapsed_ms: allComplete ? union : null, agent_run_ms: allComplete ? runs.reduce((sum, run) => sum + (run.elapsed_ms ?? 0), 0) : null,
|
|
55
|
+
// A run rounded to zero milliseconds is below this clock's resolution, not proof of zero simultaneous runs.
|
|
56
|
+
peak_concurrency: allComplete && runs.every((run) => (run.elapsed_ms ?? 0) > 0) ? peak : null,
|
|
57
|
+
tokens_total: runs.every((run) => run.tokens_total !== null) ? runs.reduce((sum, run) => sum + (run.tokens_total ?? 0), 0) : null,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Explicit local metadata file only. No home discovery, credentials, uploads or clocks invented here. */
|
|
2
|
+
import { constants, openSync, closeSync, fstatSync, lstatSync, readSync } from "node:fs";
|
|
3
|
+
import { parseOrchestrationJsonl, summarizeOrchestration } from "./orchestration-evidence.mjs";
|
|
4
|
+
|
|
5
|
+
export function reportFile(args) {
|
|
6
|
+
if (args.length !== 3 || args[0] !== "report" || args[1] !== "--file" || !args[2]) {
|
|
7
|
+
process.stderr.write("Usage: worktrust orchestration report --file recording.jsonl\n");
|
|
8
|
+
process.exitCode = 1;
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
let fd;
|
|
12
|
+
try {
|
|
13
|
+
const before = lstatSync(args[2]);
|
|
14
|
+
if (!before.isFile() || before.isSymbolicLink()) throw Error("invalid");
|
|
15
|
+
fd = openSync(args[2], constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
16
|
+
const info = fstatSync(fd);
|
|
17
|
+
if (!info.isFile() || info.size > 262144 || info.dev !== before.dev || info.ino !== before.ino) throw Error("invalid");
|
|
18
|
+
const bytes = Buffer.alloc(262145);
|
|
19
|
+
let length = 0, received;
|
|
20
|
+
do { received = readSync(fd, bytes, length, bytes.length - length, null); length += received; } while (received && length < bytes.length);
|
|
21
|
+
if (length > 262144) throw Error("invalid");
|
|
22
|
+
const recording = parseOrchestrationJsonl(new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, length)));
|
|
23
|
+
process.stdout.write(JSON.stringify(summarizeOrchestration(recording), null, 2) + "\n");
|
|
24
|
+
} catch {
|
|
25
|
+
process.stderr.write("Orchestration recording refused: use a regular, bounded file with valid metadata.\n");
|
|
26
|
+
process.exitCode = 1;
|
|
27
|
+
} finally { if (fd !== undefined) closeSync(fd); }
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "worktrust",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.14",
|
|
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": {
|
|
@@ -25,7 +25,10 @@
|
|
|
25
25
|
"SECURITY.md",
|
|
26
26
|
"LICENSE",
|
|
27
27
|
"AGENTS.md",
|
|
28
|
-
"CLAUDE.md"
|
|
28
|
+
"CLAUDE.md",
|
|
29
|
+
"orchestration-contract.mjs",
|
|
30
|
+
"orchestration-evidence.mjs",
|
|
31
|
+
"orchestration-report.mjs"
|
|
29
32
|
],
|
|
30
33
|
"engines": {
|
|
31
34
|
"node": ">=18"
|
package/worktrust.mjs
CHANGED
|
@@ -83,14 +83,14 @@ const command = args.includes("--help") ? "help" : args.includes("--version") ?
|
|
|
83
83
|
const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
|
|
84
84
|
const has = (name) => args.includes(`--${name}`);
|
|
85
85
|
/** 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). */
|
|
86
|
-
const CLI_VERSION = "0.10.
|
|
86
|
+
const CLI_VERSION = "0.10.14";
|
|
87
87
|
const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.worktrust.io").replace(/\/$/, "");
|
|
88
88
|
const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
|
|
89
89
|
const HOME_DIR = join(homedir(), ".worktrust");
|
|
90
90
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
91
|
-
const SCRIPTS = ["setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "runtime-install.mjs"];
|
|
91
|
+
const SCRIPTS = ["setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs"];
|
|
92
92
|
/** The modules the scripts import by name from beside them; a download keeps that name. */
|
|
93
|
-
const IMPORTED = new Set(["transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "runtime-install.mjs"]);
|
|
93
|
+
const IMPORTED = new Set(["transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs"]);
|
|
94
94
|
const downloaded = (name) => (IMPORTED.has(name) ? name : `${name}.download.mjs`);
|
|
95
95
|
const BUNDLED = SCRIPTS.every((name) => existsSync(join(HERE, name)));
|
|
96
96
|
const PLACEHOLDER = `wt_${"0".repeat(43)}`;
|
|
@@ -1115,6 +1115,7 @@ function help() {
|
|
|
1115
1115
|
say(" days this computer's own sessions lack, reconstructed, never verified hours (asks first)");
|
|
1116
1116
|
say(" worktrust disconnect take WorkTrust out of every AI app here (asks first)");
|
|
1117
1117
|
say(" worktrust status what is coupled here");
|
|
1118
|
+
say(" worktrust orchestration report --file recording.jsonl inspect local agent metadata; sends nothing");
|
|
1118
1119
|
say(" worktrust preserve keep your AI history: the report, then the settings and a local archive, each on your yes");
|
|
1119
1120
|
say(" --apply keep them: asks per change, backs the file up first (--yes: no question)");
|
|
1120
1121
|
say(" --archive [dir] a local, metadata-only, hash-chained record of the measured days (~/AI-Evidence)");
|
|
@@ -1130,7 +1131,7 @@ function help() {
|
|
|
1130
1131
|
// before anything is read or written, --yes included. The hook and the MCP bridge are started by the agent's client
|
|
1131
1132
|
// itself and stay as they are; `status` only reads.
|
|
1132
1133
|
const AGENT_ENV = ["CLAUDECODE", "CLAUDE_CODE_ENTRYPOINT", "CODEX_SANDBOX", "CODEX_CI", "GEMINI_CLI", "CURSOR_AGENT", "OPENCODE", "CLINE_ACTIVE", "AIDER_CHAT", "ANTIGRAVITY_AGENT", "WINDSURF_AGENT"];
|
|
1133
|
-
const PERSON_ONLY = new Set(["default", "connect", "update", "history", "disconnect", "preserve", "codex", "antigravity", "sources", "web", "import"]);
|
|
1134
|
+
const PERSON_ONLY = new Set(["default", "connect", "update", "history", "disconnect", "preserve", "codex", "antigravity", "sources", "web", "import", "orchestration"]);
|
|
1134
1135
|
const agentShell = AGENT_ENV.find((name) => process.env[name] && process.env[name] !== "0");
|
|
1135
1136
|
if (agentShell && PERSON_ONLY.has(command)) {
|
|
1136
1137
|
say();
|
|
@@ -1193,4 +1194,8 @@ else if (command === "antigravity") await offerAntigravity();
|
|
|
1193
1194
|
else if (command === "disconnect") await disconnect();
|
|
1194
1195
|
else if (command === "status") await status();
|
|
1195
1196
|
else if (command === "preserve") await preserve();
|
|
1197
|
+
else if (command === "orchestration") {
|
|
1198
|
+
if (!["orchestration-report.mjs", "orchestration-evidence.mjs", "orchestration-contract.mjs"].every((name) => existsSync(join(HERE, name)))) fail("Local agent reports need the complete WorkTrust npm/Python package or preservation kit. No file was read or sent.");
|
|
1199
|
+
const { reportFile } = await import("./orchestration-report.mjs"); reportFile(args.slice(1));
|
|
1200
|
+
}
|
|
1196
1201
|
else help();
|