@raytrace-cli/cli 0.4.0 → 0.5.0
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 +132 -126
- package/bin/raytrace.mjs +41 -20
- package/dist/dashboard/assets/dm-sans-latin-400-normal-BwCSEQnW.woff +0 -0
- package/dist/dashboard/assets/dm-sans-latin-400-normal-CW0RaeGs.woff2 +0 -0
- package/dist/dashboard/assets/dm-sans-latin-500-normal-B9HHJjqV.woff2 +0 -0
- package/dist/dashboard/assets/dm-sans-latin-500-normal-Dr3UlScf.woff +0 -0
- package/dist/dashboard/assets/dm-sans-latin-600-normal-Aqo67rzb.woff2 +0 -0
- package/dist/dashboard/assets/dm-sans-latin-600-normal-BmdmIIQ2.woff +0 -0
- package/dist/dashboard/assets/dm-sans-latin-700-normal-CUSSCpQX.woff +0 -0
- package/dist/dashboard/assets/dm-sans-latin-700-normal-DvUfVpUG.woff2 +0 -0
- package/dist/dashboard/assets/dm-sans-latin-ext-400-normal-BjWJ59Pq.woff +0 -0
- package/dist/dashboard/assets/dm-sans-latin-ext-400-normal-BtiwyxMk.woff2 +0 -0
- package/dist/dashboard/assets/dm-sans-latin-ext-500-normal-BJfUCQsA.woff2 +0 -0
- package/dist/dashboard/assets/dm-sans-latin-ext-500-normal-DR84L5F-.woff +0 -0
- package/dist/dashboard/assets/dm-sans-latin-ext-600-normal-4vooXBpG.woff2 +0 -0
- package/dist/dashboard/assets/dm-sans-latin-ext-600-normal-DRtaDpgU.woff +0 -0
- package/dist/dashboard/assets/dm-sans-latin-ext-700-normal-BLI3TTWz.woff +0 -0
- package/dist/dashboard/assets/dm-sans-latin-ext-700-normal-CJIcxD6K.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
- package/dist/dashboard/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
- package/dist/dashboard/assets/index-DtV3UdEB.css +1 -0
- package/dist/dashboard/assets/index-jyV5iYHJ.js +38 -0
- package/dist/dashboard/index.html +2 -2
- package/package.json +3 -1
- package/proxy/call-assessment.mjs +385 -0
- package/proxy/call-category.mjs +461 -0
- package/proxy/capture.mjs +31 -0
- package/proxy/claude-code-adapter.mjs +46 -3
- package/proxy/evidence-store.mjs +617 -15
- package/proxy/exec-narrative.mjs +625 -0
- package/proxy/execution-correlation.mjs +185 -0
- package/proxy/experiment-engine.mjs +7 -4
- package/proxy/failure-signature.mjs +56 -0
- package/proxy/gvisor-forwarder.mjs +454 -0
- package/proxy/init-evidence-db.mjs +136 -12
- package/proxy/local-sandboxes.mjs +94 -0
- package/proxy/playground.mjs +411 -0
- package/proxy/prompt-context.mjs +12 -7
- package/proxy/prompt-traces.mjs +6 -0
- package/proxy/raytace-proxy.mjs +460 -176
- package/proxy/run-recap.mjs +139 -0
- package/proxy/runtime-attribution.mjs +110 -0
- package/proxy/sandbox-bridge.mjs +46 -0
- package/proxy/schema/EVIDENCE_DATABASE.md +276 -0
- package/proxy/schema/auxiliary.sql +48 -1
- package/proxy/schema/classification.sql +89 -0
- package/proxy/schema/file_context.sql +53 -0
- package/proxy/schema/runtime_evidence.sql +201 -0
- package/proxy/schema/search.sql +66 -0
- package/proxy/search.mjs +418 -0
- package/proxy/step-attribution.mjs +380 -0
- package/proxy/tool-metadata.mjs +36 -0
- package/proxy/trace-view.mjs +276 -0
- package/proxy/typesafe.mjs +63 -0
- package/src/commands.mjs +73 -4
- package/src/lima.mjs +135 -0
- package/src/local-sandbox.mjs +324 -0
- package/src/proxy-process.mjs +20 -1
- package/src/sandbox.mjs +24 -6
- package/worker/sandbox/Dockerfile +8 -0
- package/worker/sandbox/SYSCALL_CATALOG.md +197 -0
- package/worker/sandbox/claude-hook.mjs +331 -0
- package/worker/sandbox/collector.py +357 -0
- package/worker/sandbox/dns_forwarder.py +255 -0
- package/worker/sandbox/engine.py +940 -0
- package/worker/sandbox/file_scan.py +491 -0
- package/worker/sandbox/lima.yaml +29 -0
- package/worker/sandbox/network.py +90 -0
- package/worker/sandbox/projects.py +678 -0
- package/worker/sandbox/setup.py +159 -0
- package/worker/sandbox/syscall_catalog.sql +985 -0
- package/worker/sandbox/viewer.py +132 -0
- package/dist/dashboard/assets/index-BQ9_JxGq.js +0 -27
- package/dist/dashboard/assets/index-L5cUAvhE.css +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""Loopback-only, read-only evidence viewer, forwarded by Lima to the Mac."""
|
|
2
|
+
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import sqlite3
|
|
6
|
+
import time
|
|
7
|
+
from urllib.parse import urlparse, parse_qs
|
|
8
|
+
|
|
9
|
+
def event_page(db, query):
|
|
10
|
+
container = query.get('container', [''])[0]
|
|
11
|
+
before = int(query.get('before', ['0'])[0])
|
|
12
|
+
# `after` is the tailing cursor used by the RayTrace proxy's gVisor
|
|
13
|
+
# forwarder: events with id > after, oldest first, so a poller can
|
|
14
|
+
# advance through the log without gaps. `before` (the UI's "older
|
|
15
|
+
# events" paging, newest first) still works on its own; `after` wins
|
|
16
|
+
# when both are given.
|
|
17
|
+
after = int(query.get('after', ['0'])[0])
|
|
18
|
+
limit = min(500, max(1, int(query.get('limit', ['100'])[0])))
|
|
19
|
+
# `since`/`until` (epoch ms, inclusive) scope a page to one agent turn --
|
|
20
|
+
# from the prompt to the answer -- so the UI is not showing every command
|
|
21
|
+
# ever run in this sandbox. Filtered on the collector's own `received_ms`
|
|
22
|
+
# column rather than the event's timestamp_ns, which lives inside the JSON
|
|
23
|
+
# body: the two differ by well under a millisecond, and a column is
|
|
24
|
+
# indexable where a json_extract is not.
|
|
25
|
+
since = int(query.get('since', ['0'])[0])
|
|
26
|
+
until = int(query.get('until', ['0'])[0])
|
|
27
|
+
clauses, params = [], []
|
|
28
|
+
if container:
|
|
29
|
+
clauses.append('container_id = ?'); params.append(container)
|
|
30
|
+
if since:
|
|
31
|
+
clauses.append('received_ms >= ?'); params.append(since)
|
|
32
|
+
if until:
|
|
33
|
+
clauses.append('received_ms <= ?'); params.append(until)
|
|
34
|
+
if after:
|
|
35
|
+
clauses.append('id > ?'); params.append(after)
|
|
36
|
+
elif before:
|
|
37
|
+
clauses.append('id < ?'); params.append(before)
|
|
38
|
+
if query.get('processes', [''])[0] == '1':
|
|
39
|
+
clauses.append("kind IN ('exec_succeeded','exec_failed','process_exit','collection_gap','collection_error','collector_disconnected')")
|
|
40
|
+
where = ' WHERE ' + ' AND '.join(clauses) if clauses else ''
|
|
41
|
+
order = 'ASC' if after else 'DESC'
|
|
42
|
+
rows = db.execute('SELECT id,body FROM runtime_events'+where+' ORDER BY id '+order+' LIMIT ?', (*params, limit+1)).fetchall()
|
|
43
|
+
events = []
|
|
44
|
+
for identifier, body in rows[:limit]:
|
|
45
|
+
event=json.loads(body); event.pop('raw_packet_base64',None)
|
|
46
|
+
event['event_id']=identifier; events.append(event)
|
|
47
|
+
page = {'events':events,'next_before':None if after else (rows[limit-1][0] if len(rows)>limit else None)}
|
|
48
|
+
if after:
|
|
49
|
+
page['next_after'] = rows[limit-1][0] if len(rows) > limit else None
|
|
50
|
+
return page
|
|
51
|
+
|
|
52
|
+
def fact_page(db, query):
|
|
53
|
+
"""Facts the engine drew (engine.py), oldest first after `after`: the
|
|
54
|
+
control plane's cursor over every sandbox of this host, or with `container`
|
|
55
|
+
over one. A fact that grew since it was read comes again under a new id, so
|
|
56
|
+
the reader replaces its copy. `latest` is the highest id ever given: a
|
|
57
|
+
reader whose cursor is past it is looking at a new database."""
|
|
58
|
+
container = query.get('container', [''])[0]
|
|
59
|
+
after = int(query.get('after', ['0'])[0])
|
|
60
|
+
limit = min(1000, max(1, int(query.get('limit', ['500'])[0])))
|
|
61
|
+
clauses, params = ['id > ?'], [after]
|
|
62
|
+
if container:
|
|
63
|
+
clauses.append('container_id = ?'); params.append(container)
|
|
64
|
+
rows = db.execute('SELECT id, body FROM facts WHERE ' + ' AND '.join(clauses) + ' ORDER BY id LIMIT ?', (*params, limit + 1)).fetchall()
|
|
65
|
+
facts = [{**json.loads(body), 'id': identifier} for identifier, body in rows[:limit]]
|
|
66
|
+
latest = db.execute("SELECT seq FROM sqlite_sequence WHERE name = 'facts'").fetchone()
|
|
67
|
+
return {'facts': facts, 'next_after': facts[-1]['id'] if len(rows) > limit else None, 'latest': latest[0] if latest else 0}
|
|
68
|
+
|
|
69
|
+
PAGE = '''<!doctype html><meta charset="utf-8"><title>RayTrace runtime evidence</title>
|
|
70
|
+
<style>body{font:15px system-ui;background:#111827;color:#e5e7eb;margin:32px}table{width:100%;border-collapse:collapse}td,th{text-align:left;padding:10px;border-bottom:1px solid #374151}code{white-space:pre-wrap}select{padding:8px} .note{color:#fbbf24}</style>
|
|
71
|
+
<h1>Runtime evidence</h1><p>Independent gVisor process events. Select a sandbox to inspect its timeline.</p>
|
|
72
|
+
<p class="note">Coverage: selected process events only. Missing evidence is not proof of non-execution. Disconnects do not certify completeness.</p>
|
|
73
|
+
<select id="jobs"><option value="">All sandboxes and collector health</option></select><p id="status"></p>
|
|
74
|
+
<table><thead><tr><th>Event</th><th>PID / parent</th><th>Executable / arguments / result</th></tr></thead><tbody id="events"></tbody></table>
|
|
75
|
+
<script>
|
|
76
|
+
const select=document.getElementById('jobs');
|
|
77
|
+
async function refresh(){try{const response=await fetch('/events');if(!response.ok)throw Error('Collector unavailable');const data=await response.json();
|
|
78
|
+
const chosen=select.value;select.replaceChildren(new Option('All sandboxes and collector health',''));for(const id of data.containers)select.add(new Option(id.slice(0,16),id));select.value=chosen;
|
|
79
|
+
const rows=data.events.filter(e=>!select.value||e.container_id===select.value);
|
|
80
|
+
document.getElementById('status').textContent='Latest '+rows.length+' events (up to 500). '+data.gaps+' recorded collection errors/gaps.';
|
|
81
|
+
const body=document.getElementById('events');body.replaceChildren();for(const e of rows){const {raw_packet_base64,...detail}=e;const tr=document.createElement('tr');for(const v of [e.kind,`${e.pid??'—'} / ${e.ppid??'—'}`,JSON.stringify(detail)]){const td=document.createElement('td');const code=document.createElement('code');code.textContent=v;td.append(code);tr.append(td);}body.append(tr);}
|
|
82
|
+
}catch(e){document.getElementById('status').textContent=e.message;}}
|
|
83
|
+
select.onchange=refresh;refresh();setInterval(refresh,1500);
|
|
84
|
+
</script>'''
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Handler(BaseHTTPRequestHandler):
|
|
88
|
+
def do_GET(self):
|
|
89
|
+
if self.headers.get('Host', '').split(':')[0] not in ('localhost', '127.0.0.1'):
|
|
90
|
+
self.send_error(403)
|
|
91
|
+
return
|
|
92
|
+
if self.path == '/':
|
|
93
|
+
body, mime = PAGE.encode(), 'text/html; charset=utf-8'
|
|
94
|
+
elif urlparse(self.path).path == '/time':
|
|
95
|
+
# The VM's realtime clock, which gVisor stamps events with. The
|
|
96
|
+
# proxy on the Mac samples this to map event times onto its own
|
|
97
|
+
# clock; the two drift apart, notably after the Mac sleeps.
|
|
98
|
+
body, mime = json.dumps({'realtime_ns': str(time.time_ns())}).encode(), 'application/json'
|
|
99
|
+
elif urlparse(self.path).path == '/facts':
|
|
100
|
+
try:
|
|
101
|
+
with sqlite3.connect('file:/var/lib/raytace/runtime.db?mode=ro', uri=True) as db:
|
|
102
|
+
body, mime = json.dumps(fact_page(db, parse_qs(urlparse(self.path).query))).encode(), 'application/json'
|
|
103
|
+
except sqlite3.OperationalError:
|
|
104
|
+
# A host whose engine has not run yet has no facts table: none, not an error.
|
|
105
|
+
body, mime = json.dumps({'facts': [], 'next_after': None, 'latest': 0}).encode(), 'application/json'
|
|
106
|
+
except (sqlite3.Error, ValueError):
|
|
107
|
+
self.send_error(503, 'Evidence database unavailable')
|
|
108
|
+
return
|
|
109
|
+
elif urlparse(self.path).path == '/events':
|
|
110
|
+
try:
|
|
111
|
+
with sqlite3.connect('file:/var/lib/raytace/runtime.db?mode=ro', uri=True) as db:
|
|
112
|
+
page = event_page(db, parse_qs(urlparse(self.path).query))
|
|
113
|
+
containers = [r[0] for r in db.execute("SELECT DISTINCT container_id FROM runtime_events WHERE container_id != ''")]
|
|
114
|
+
gaps = db.execute("SELECT COUNT(*) FROM runtime_events WHERE kind IN ('collection_error','collection_gap')").fetchone()[0]
|
|
115
|
+
body = json.dumps({**page, 'containers': containers, 'gaps': gaps, 'coverage':'Selected process events; completeness not certified'}).encode()
|
|
116
|
+
mime = 'application/json'
|
|
117
|
+
except (sqlite3.Error, ValueError):
|
|
118
|
+
self.send_error(503, 'Evidence database unavailable')
|
|
119
|
+
return
|
|
120
|
+
else:
|
|
121
|
+
self.send_error(404)
|
|
122
|
+
return
|
|
123
|
+
self.send_response(200)
|
|
124
|
+
self.send_header('Content-Type', mime)
|
|
125
|
+
self.send_header('Cache-Control', 'no-store')
|
|
126
|
+
self.send_header('X-Content-Type-Options', 'nosniff')
|
|
127
|
+
self.end_headers()
|
|
128
|
+
self.wfile.write(body)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
if __name__ == '__main__':
|
|
132
|
+
ThreadingHTTPServer(('127.0.0.1', 8798), Handler).serve_forever()
|