@oathe/oathe 0.3.2 → 0.4.1
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 +42 -12
- package/assets/oathe-hero.png +0 -0
- package/bin/node-floor.mjs +16 -0
- package/bin/oathe.mjs +78 -134
- package/docs/PRIVACY.md +7 -6
- package/notch/Oathe Notch.app/Contents/Info.plist +1 -1
- package/notch/Oathe Notch.app/Contents/MacOS/OatheNotch +0 -0
- package/notch/README.md +33 -18
- package/package.json +9 -5
- package/plugin/.claude-plugin/plugin.json +2 -2
- package/plugin/.cursor-plugin/plugin.json +2 -2
- package/plugin/commands/verify.md +6 -5
- package/plugin/hooks/heartbeat.mjs +14 -5
- package/plugin/hooks/hooks.json +1 -1
- package/plugin/hooks/lib.mjs +7 -5
- package/plugin/hooks/render-board.mjs +3 -3
- package/plugin/skills/oathe-work/SKILL.md +4 -1
- package/src/activation.mjs +3 -0
- package/src/atif.mjs +182 -348
- package/src/board-render.mjs +46 -42
- package/src/breach-digest.mjs +183 -0
- package/src/config.mjs +15 -3
- package/src/context.mjs +1 -1
- package/src/doctor.mjs +30 -8
- package/src/evidence.mjs +153 -0
- package/src/harnesses/catalog.mjs +12 -1
- package/src/harnesses/claude-roster.mjs +49 -0
- package/src/harnesses/claude-transcript.mjs +174 -0
- package/src/harnesses/claude.mjs +35 -2
- package/src/harnesses/codex-rollout.mjs +610 -0
- package/src/harnesses/codex-roster.mjs +88 -0
- package/src/harnesses/codex.mjs +72 -2
- package/src/harnesses/cursor.mjs +10 -8
- package/src/harnesses/fidelity.mjs +123 -0
- package/src/init.mjs +5 -1
- package/src/launch-env.mjs +5 -5
- package/src/launch.mjs +5 -6
- package/src/manifest.mjs +35 -0
- package/src/mcp/connection.mjs +9 -7
- package/src/mcp/oathe-tools.mjs +135 -75
- package/src/node-floor.mjs +44 -0
- package/src/notch-frame.mjs +152 -0
- package/src/oathe-annotator.mjs +113 -0
- package/src/pager.mjs +75 -37
- package/src/runtime/provider.mjs +2 -2
- package/src/session-host.mjs +1 -1
- package/src/sessions.mjs +8 -1
- package/src/speaker.mjs +54 -26
- package/src/statements.mjs +120 -2
- package/src/substrate.mjs +3 -3
- package/src/successor.mjs +2 -3
- package/src/trace-census.mjs +96 -0
- package/src/traces.mjs +98 -6
- package/src/uninstall.mjs +4 -1
- package/src/verifier.mjs +37 -19
- package/assets/oathe-hero.svg +0 -92
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Claude's transcript-row roster — pure data, zero imports (the adapter and the projector
|
|
2
|
+
// both consume it). Every line type the projector handles, or has seen and consciously
|
|
3
|
+
// ignores (each with its reason). Measured on live transcripts 2026-08-31 (Claude Code
|
|
4
|
+
// 2.1.x); docs/traces.md carries the pinned contract. A type outside both lists quarantines
|
|
5
|
+
// visibly at projection and fails the census lane as DRIFT.
|
|
6
|
+
|
|
7
|
+
export const CLAUDE_ROSTER = Object.freeze({
|
|
8
|
+
line: Object.freeze({
|
|
9
|
+
handled: Object.freeze(['user', 'assistant', 'system', 'ai-title', 'file-history-snapshot']),
|
|
10
|
+
ignored: Object.freeze({
|
|
11
|
+
'last-prompt': 'editor bookkeeping, not conversation',
|
|
12
|
+
mode: 'UI mode marker',
|
|
13
|
+
'permission-mode': 'UI mode marker',
|
|
14
|
+
'atis-latch': 'harness-internal latch',
|
|
15
|
+
'bridge-session': 'harness-internal session bridging',
|
|
16
|
+
attachment: 'attachment bookkeeping — the message rows carry the content',
|
|
17
|
+
'queue-operation': 'queue bookkeeping',
|
|
18
|
+
'agent-name': 'agent naming bookkeeping, not conversation',
|
|
19
|
+
'agent-setting': 'agent settings bookkeeping',
|
|
20
|
+
'artifact-autoreact-ledger': 'artifact auto-reply bookkeeping',
|
|
21
|
+
'artifact-comment-monitor': 'artifact comment-watch bookkeeping',
|
|
22
|
+
'cost-state': 'usage accounting snapshot',
|
|
23
|
+
'custom-title': 'user-set display title (ai-title is the handled title row)',
|
|
24
|
+
'file-history-delta': 'incremental sibling of file-history-snapshot — inter-snapshot bookkeeping',
|
|
25
|
+
'frame-link': 'session frame linkage bookkeeping',
|
|
26
|
+
'pr-link': 'PR linkage bookkeeping',
|
|
27
|
+
}),
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Which user rows are the PERSON's and which the HARNESS's — `origin.kind`, measured over the
|
|
33
|
+
* 40 newest transcripts (2026-09-01: human 417, task-notification 262, auto-continuation 1,
|
|
34
|
+
* peer 1; absent = tool-result rows and older rows, the person's). A task-notification is the
|
|
35
|
+
* harness reporting a background task (an Agent's completion, a backgrounded command) as
|
|
36
|
+
* `<task-notification><task-id>…<tool-use-id>…`; a peer is another session's message. An
|
|
37
|
+
* unknown kind projects as the person's row AND quarantines visibly (`origin.<kind>`).
|
|
38
|
+
*/
|
|
39
|
+
export const ORIGIN_KINDS = Object.freeze({
|
|
40
|
+
human: 'user',
|
|
41
|
+
'task-notification': 'system',
|
|
42
|
+
peer: 'system',
|
|
43
|
+
'auto-continuation': 'system',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/** One parsed transcript row → its roster coordinate (the census classifier). */
|
|
47
|
+
export function claudeKindOf(row) {
|
|
48
|
+
return { channel: 'line', type: row?.type };
|
|
49
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// The Claude transcript projection — ALL Claude trace-format knowledge lives here, beside its
|
|
2
|
+
// adapter (R-HARNESS-TOUCHPOINTS), routed by the declared roster in claude-roster.mjs.
|
|
3
|
+
// Format facts, measured on live transcripts (Claude Code 2.1.x, 2026-08-31/09-01):
|
|
4
|
+
// - consecutive assistant rows are one TURN (streamed content blocks); any user row — a
|
|
5
|
+
// tool result included — ends it. Usage repeats per API response id.
|
|
6
|
+
// - a user row is the PERSON's unless origin.kind says otherwise (ORIGIN_KINDS): a
|
|
7
|
+
// task-notification is the harness reporting a background task — an Agent's completion
|
|
8
|
+
// (its task-id IS the embedded subagent's id) or a backgrounded command (its tool-use-id
|
|
9
|
+
// names the call) — never the person's words; a peer is another session's message.
|
|
10
|
+
// - subagents live in <session>/subagents/agent-<id>.jsonl (+ .meta.json with the Agent
|
|
11
|
+
// tool_use id), never inline; an Agent tool_use's result is an ASYNC launch receipt.
|
|
12
|
+
|
|
13
|
+
import { AtifProjector, textOf } from '../atif.mjs';
|
|
14
|
+
import { CLAUDE_ROSTER, ORIGIN_KINDS } from './claude-roster.mjs';
|
|
15
|
+
|
|
16
|
+
const TASK_ID = /<task-id>([^<]+)<\/task-id>/;
|
|
17
|
+
const TOOL_USE_ID = /<tool-use-id>([^<]+)<\/tool-use-id>/;
|
|
18
|
+
|
|
19
|
+
export class ClaudeAtifProjector extends AtifProjector {
|
|
20
|
+
#responses = new WeakMap(); // step → Map(message id → its usage): the API responses behind the step
|
|
21
|
+
#messageOf = new WeakMap(); // step → the message id that opened it (null: a row with no id)
|
|
22
|
+
|
|
23
|
+
map(rows, file) {
|
|
24
|
+
this.turnBroken = false;
|
|
25
|
+
this.callIds = new Set(); // every tool call this record made — a notification can name one
|
|
26
|
+
const filesTouched = new Set();
|
|
27
|
+
const subagents = this.store.subagentsFor(file);
|
|
28
|
+
this.subagentIds = new Set(subagents.map((s) => s.agent_id));
|
|
29
|
+
const { handled, ignored } = CLAUDE_ROSTER.line;
|
|
30
|
+
for (const row of rows) {
|
|
31
|
+
if (row.type === 'ai-title') {
|
|
32
|
+
this.record.session_title = row.aiTitle;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (row.type === 'file-history-snapshot') {
|
|
36
|
+
for (const touched of Object.keys(row.snapshot?.trackedFileBackups ?? {})) filesTouched.add(touched);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (ignored[row.type] !== undefined) continue; // seen, judged non-evidence — the roster says why
|
|
40
|
+
if (!handled.includes(row.type)) {
|
|
41
|
+
this.noteUnrecognized(row.type);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (row.sessionId && !this.sessionId) this.sessionId = row.sessionId;
|
|
45
|
+
if (row.version && !this.agentInfo.version) this.agentInfo.version = row.version;
|
|
46
|
+
|
|
47
|
+
if (row.type === 'assistant') {
|
|
48
|
+
this.#mapAssistant(row);
|
|
49
|
+
} else if (row.type === 'user') {
|
|
50
|
+
this.#mapUser(row, file);
|
|
51
|
+
} else if (row.type === 'system') {
|
|
52
|
+
this.pushStep({ source: 'system', message: textOf(row.message?.content ?? row.content ?? '') });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (filesTouched.size > 0) this.record.files_touched = [...filesTouched];
|
|
56
|
+
|
|
57
|
+
for (const sub of subagents) {
|
|
58
|
+
const child = new ClaudeAtifProjector({ store: this.store }).project(sub.path);
|
|
59
|
+
child.trajectory_id = sub.agent_id;
|
|
60
|
+
if (sub.meta) child.extra.record.subagent_meta = sub.meta;
|
|
61
|
+
this.addSubagent(child);
|
|
62
|
+
// The ref on the Agent call's receipt: meta.toolUseId IS the tool_use id (measured 2026-09-01).
|
|
63
|
+
if (sub.meta?.toolUseId && this.callIds.has(sub.meta.toolUseId)) {
|
|
64
|
+
this.attachRef(sub.meta.toolUseId, { trajectory_id: sub.agent_id, ...(sub.meta.agentType ? { extra: { agent_type: sub.meta.agentType } } : {}) }, { file });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#mapAssistant(row) {
|
|
70
|
+
const parts = Array.isArray(row.message?.content) ? row.message.content : [];
|
|
71
|
+
const texts = parts.filter((p) => p.type === 'text').map((p) => p.text);
|
|
72
|
+
const thinking = parts.filter((p) => p.type === 'thinking').map((p) => p.thinking);
|
|
73
|
+
const calls = parts.filter((p) => p.type === 'tool_use')
|
|
74
|
+
.map((p) => this.buildToolCall({ id: p.id, name: p.name, args: p.input }));
|
|
75
|
+
for (const call of calls) this.callIds.add(call.tool_call_id);
|
|
76
|
+
if (row.message?.model && !this.agentInfo.model_name) this.agentInfo.model_name = row.message.model;
|
|
77
|
+
|
|
78
|
+
// One API response is ONE step (the RFC's step is one inference; Harbor claude_code.py
|
|
79
|
+
// bundles by message id too): its streamed blocks arrive as consecutive rows, and a
|
|
80
|
+
// receipt the harness wrote between two of them — an async launch's, measured 2026-09-01:
|
|
81
|
+
// three Agent rows of one message, each followed by its receipt — does not end it. The
|
|
82
|
+
// message id says which response a row belongs to; a different id is a new step; a row
|
|
83
|
+
// with no id merges with the open step unless a user row ended the turn.
|
|
84
|
+
const messageId = row.message?.id ?? null;
|
|
85
|
+
const open = this.currentAgentStep();
|
|
86
|
+
const sameResponse = open !== null && messageId !== null && this.#messageOf.get(open) === messageId;
|
|
87
|
+
let step = sameResponse || (messageId === null && !this.turnBroken) ? open : null;
|
|
88
|
+
this.turnBroken = false;
|
|
89
|
+
if (!step) {
|
|
90
|
+
step = this.pushStep({ source: 'agent', message: '' });
|
|
91
|
+
this.#messageOf.set(step, messageId);
|
|
92
|
+
if (row.timestamp) step.timestamp = row.timestamp;
|
|
93
|
+
}
|
|
94
|
+
if (texts.length > 0) step.message = [step.message, ...texts].filter((t) => t !== '').join('\n');
|
|
95
|
+
if (thinking.length > 0) {
|
|
96
|
+
step.reasoning_content = [step.reasoning_content, ...thinking].filter(Boolean).join('\n');
|
|
97
|
+
}
|
|
98
|
+
if (calls.length > 0) step.tool_calls = [...(step.tool_calls ?? []), ...calls];
|
|
99
|
+
|
|
100
|
+
if (row.message?.usage) this.#addUsage(step, messageId, row.message.usage);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* One API response is one entry, keyed by message id. A response streams as several rows
|
|
105
|
+
* whose usage ACCUMULATES (Claude Code's own semantics — measured 2026-09-01 on a subagent
|
|
106
|
+
* file: the first row of a message says output_tokens 1, its last 281; Harbor claude_code.py
|
|
107
|
+
* reads the last row too), so the last row wins; a row with no id never collides. The step's
|
|
108
|
+
* metrics are the sum over its responses and llm_call_count is how many there were — a step
|
|
109
|
+
* with no usage-bearing row gets neither (nothing invented).
|
|
110
|
+
*/
|
|
111
|
+
#addUsage(step, messageId, usage) {
|
|
112
|
+
const responses = this.#responses.get(step) ?? new Map();
|
|
113
|
+
responses.set(messageId ?? Symbol('no message id'), usage);
|
|
114
|
+
this.#responses.set(step, responses);
|
|
115
|
+
const sum = { prompt_tokens: 0, completion_tokens: 0, cached_tokens: 0, creation: 0 };
|
|
116
|
+
for (const u of responses.values()) {
|
|
117
|
+
const cached = u.cache_read_input_tokens ?? 0;
|
|
118
|
+
const creation = u.cache_creation_input_tokens ?? 0;
|
|
119
|
+
sum.prompt_tokens += (u.input_tokens ?? 0) + cached + creation;
|
|
120
|
+
sum.completion_tokens += u.output_tokens ?? 0;
|
|
121
|
+
sum.cached_tokens += cached;
|
|
122
|
+
sum.creation += creation;
|
|
123
|
+
}
|
|
124
|
+
const { creation, ...metrics } = sum;
|
|
125
|
+
step.metrics = { ...metrics, ...(creation > 0 ? { extra: { cache_creation_input_tokens: creation } } : {}) };
|
|
126
|
+
step.llm_call_count = responses.size;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
#mapUser(row, file) {
|
|
130
|
+
this.turnBroken = true;
|
|
131
|
+
const content = row.message?.content;
|
|
132
|
+
if (Array.isArray(content)) {
|
|
133
|
+
const results = content.filter((p) => p.type === 'tool_result');
|
|
134
|
+
const texts = content.filter((p) => p.type === 'text').map((p) => p.text);
|
|
135
|
+
for (const result of results) this.attachResult(result.tool_use_id, result.content, { file });
|
|
136
|
+
if (texts.length > 0) this.#userText(row, texts.join('\n'));
|
|
137
|
+
} else {
|
|
138
|
+
this.#userText(row, textOf(content));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* A user row's text, by who is speaking (ORIGIN_KINDS). The person's rows are user steps.
|
|
144
|
+
* The harness's are system steps (llm_call_count 0) with the kind on the record: a
|
|
145
|
+
* task-notification carries its text as an observation — with a ref when its task-id is an
|
|
146
|
+
* embedded subagent; a notification naming neither a subagent nor a call this record made
|
|
147
|
+
* is counted unresolved. A kind we have not reviewed still projects as the person's row
|
|
148
|
+
* (dropping it would fabricate absence) and quarantines visibly as `origin.<kind>`.
|
|
149
|
+
*/
|
|
150
|
+
#userText(row, text) {
|
|
151
|
+
const kind = row.origin?.kind;
|
|
152
|
+
const source = kind === undefined ? 'user' : ORIGIN_KINDS[kind];
|
|
153
|
+
if (source === undefined) this.noteUnrecognized(`origin.${kind}`);
|
|
154
|
+
if (source !== 'system') {
|
|
155
|
+
this.pushStep({ source: 'user', message: text });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const inbound = { kind };
|
|
159
|
+
const step = { source: 'system', message: text, ...(row.timestamp ? { timestamp: row.timestamp } : {}), llm_call_count: 0, extra: { record: { inbound } } };
|
|
160
|
+
if (kind === 'task-notification') {
|
|
161
|
+
const taskId = TASK_ID.exec(text)?.[1];
|
|
162
|
+
const toolUseId = TOOL_USE_ID.exec(text)?.[1];
|
|
163
|
+
if (taskId) inbound.task_id = taskId;
|
|
164
|
+
if (toolUseId) inbound.tool_use_id = toolUseId;
|
|
165
|
+
const ref = taskId && this.subagentIds.has(taskId) ? [{ trajectory_id: taskId }] : null;
|
|
166
|
+
step.message = `[inbound task-notification${taskId ? ` ${taskId}` : ''}]`;
|
|
167
|
+
step.observation = { results: [{ content: text, ...(ref ? { subagent_trajectory_ref: ref } : {}) }] };
|
|
168
|
+
if (!ref && !(toolUseId && this.callIds.has(toolUseId))) {
|
|
169
|
+
this.record.unresolved_inbound = (this.record.unresolved_inbound ?? 0) + 1;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
this.pushStep(step);
|
|
173
|
+
}
|
|
174
|
+
}
|
package/src/harnesses/claude.mjs
CHANGED
|
@@ -8,6 +8,14 @@ import path from 'node:path';
|
|
|
8
8
|
|
|
9
9
|
import { Harness, HarnessOnboardError } from './harness.mjs';
|
|
10
10
|
import { cwdDialect } from './dialects.mjs';
|
|
11
|
+
import { CLAUDE_ROSTER, ORIGIN_KINDS, claudeKindOf } from './claude-roster.mjs';
|
|
12
|
+
import { makeFidelity } from './fidelity.mjs';
|
|
13
|
+
import { ClaudeTraceStore } from '../traces.mjs';
|
|
14
|
+
|
|
15
|
+
/** The raw tool_use parts of a transcript — the fidelity extractors' one reading of actions. */
|
|
16
|
+
const claudeToolUses = (entries) => entries
|
|
17
|
+
.filter((r) => r.type === 'assistant' && Array.isArray(r.message?.content))
|
|
18
|
+
.flatMap((r) => r.message.content.filter((p) => p.type === 'tool_use'));
|
|
11
19
|
import { JsonEntries } from '../blocks.mjs';
|
|
12
20
|
import { sha256Hex } from '../manifest.mjs';
|
|
13
21
|
|
|
@@ -38,10 +46,35 @@ export class ClaudeHarness extends Harness {
|
|
|
38
46
|
extract: (stdout) => ClaudeHarness.extractJsonResult(stdout),
|
|
39
47
|
});
|
|
40
48
|
static traces = Object.freeze({
|
|
41
|
-
store:
|
|
49
|
+
store: ({ home } = {}) => new ClaudeTraceStore({ home, harness: this.harnessName }),
|
|
42
50
|
newest: (store) => store.newestTranscript(),
|
|
43
|
-
projector: async ({ store }) => new (await import('
|
|
51
|
+
projector: async ({ store }) => new (await import('./claude-transcript.mjs')).ClaudeAtifProjector({ store }),
|
|
44
52
|
ownsPath: (file) => String(file).includes(`${path.sep}.claude${path.sep}`),
|
|
53
|
+
roster: CLAUDE_ROSTER,
|
|
54
|
+
kindOf: claudeKindOf,
|
|
55
|
+
recent: (store, { days, maxFiles }) => store.recentTranscripts({ days, maxFiles }),
|
|
56
|
+
// Harbor's converter for this harness (AgentName 'claude-code') reads a trial's transcripts
|
|
57
|
+
// from <logs_dir>/sessions/projects/<slug>/ — the mirror of ~/.claude/projects (harbor 0.22.0,
|
|
58
|
+
// measured 2026-09-01); a session's subagents/ dir rides along beside its file.
|
|
59
|
+
harbor: Object.freeze({ agent: 'claude-code', sessions: Object.freeze({ home: '.claude/projects', logs: 'sessions/projects' }) }),
|
|
60
|
+
fidelity: makeFidelity({
|
|
61
|
+
rawCalls: (entries) => claudeToolUses(entries).map((p) => ({
|
|
62
|
+
id: p.id,
|
|
63
|
+
hasSource: p.input != null && Object.keys(p.input).length > 0,
|
|
64
|
+
})),
|
|
65
|
+
hasRawTokens: (entries) => entries.some((r) => r.type === 'assistant' && r.message?.usage),
|
|
66
|
+
hasOatheActs: async (entries) => {
|
|
67
|
+
const { oatheVerbFor } = await import('../oathe-annotator.mjs');
|
|
68
|
+
return claudeToolUses(entries).some((p) => oatheVerbFor(p.name) !== null);
|
|
69
|
+
},
|
|
70
|
+
childIds: (entries, trajectory, { store, file }) => store.subagentsFor(file).map((s) => s.agent_id),
|
|
71
|
+
rawItems: () => [], // one source per action on this harness — nothing to cross-check
|
|
72
|
+
// The harness's own user rows (a task-notification, a peer's message) — never the agent's words.
|
|
73
|
+
inboundTexts: (entries) => entries
|
|
74
|
+
.filter((r) => r.type === 'user' && ORIGIN_KINDS[r.origin?.kind] === 'system')
|
|
75
|
+
.map((r) => (typeof r.message?.content === 'string' ? r.message.content
|
|
76
|
+
: (r.message?.content ?? []).map((p) => p?.text ?? '').join('\n'))),
|
|
77
|
+
}),
|
|
45
78
|
});
|
|
46
79
|
static docs = Object.freeze([
|
|
47
80
|
'claude-code/mcp', 'claude-code/plugins', 'claude-code/plugins-reference', 'claude-code/hooks',
|