agentfootprint-lens 0.53.2 → 0.53.4
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/dist/{chunk-OUYJGQWK.js → chunk-KGDSDNJI.js} +3 -3
- package/dist/chunk-KGDSDNJI.js.map +1 -0
- package/dist/{chunk-45QIXKMD.js → chunk-S4KD5E4C.js} +12 -3
- package/dist/chunk-S4KD5E4C.js.map +1 -0
- package/dist/context.cjs +13 -4
- package/dist/context.cjs.map +1 -1
- package/dist/context.d.cts +9 -1
- package/dist/context.d.ts +9 -1
- package/dist/context.js +2 -2
- package/dist/core.cjs +15 -6
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +1 -1
- package/dist/index.cjs +24 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-45QIXKMD.js.map +0 -1
- package/dist/chunk-OUYJGQWK.js.map +0 -1
- package/dist/{contextAt-BNGrqZ5F.d.cts → contextAt-CTUNun-q.d.cts} +49 -49
- package/dist/{contextAt-KuZiV-ld.d.ts → contextAt-CzaCZP4b.d.ts} +49 -49
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
contextAt
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-S4KD5E4C.js";
|
|
4
4
|
import {
|
|
5
5
|
Badge
|
|
6
6
|
} from "./chunk-35DQLVDZ.js";
|
|
@@ -80,7 +80,7 @@ function ContextView(props) {
|
|
|
80
80
|
const [mode, setMode] = useState(props.initialMode ?? "keys");
|
|
81
81
|
const context = useMemo(
|
|
82
82
|
() => contextAt(snapshot, servedCursorOf(cursor), {
|
|
83
|
-
previous: previousOf(cursor, ownPositions),
|
|
83
|
+
previous: props.previous ?? previousOf(cursor, ownPositions),
|
|
84
84
|
events
|
|
85
85
|
}),
|
|
86
86
|
[snapshot, cursor.at.runtimeStageId, cursor.at.commitIdx, cursor.at.step, ownPositions, events]
|
|
@@ -315,4 +315,4 @@ export {
|
|
|
315
315
|
MILESTONE_AXIS,
|
|
316
316
|
ContextView
|
|
317
317
|
};
|
|
318
|
-
//# sourceMappingURL=chunk-
|
|
318
|
+
//# sourceMappingURL=chunk-KGDSDNJI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react/components/ContextView.tsx"],"sourcesContent":["/**\n * <ContextView> — the context object at the cursor, key by key: who wrote\n * each, what moved since the previous stop, what was served beside it.\n *\n * Standalone, like the Skill Graph: mount it anywhere with a recording and it\n * walks its own milestone axis; or hand it the ONE cursor (`cursor` from\n * `<Lens>`'s detail slot, or `lensCursorFrom`) and it never makes a second.\n *\n * <ContextView runner={recording} /> // its own cursor\n * <ContextView runner={recording} cursor={p.cursor} /> // the Lens's\n *\n * Everything printed is the record: key paths, values, stage ids, commit\n * indices, event names, the Served row's verdict badge. `LABELS` is every\n * string this view owns — names for things on the screen, never a sentence\n * about the run (test/served/no-own-claims.test.ts walks this file).\n */\nimport React, { useMemo, useState } from 'react';\n\nimport { contextAt, type ContextAt, type ContextKey } from '../../core/context/contextAt.js';\nimport type { LensCursor } from '../../core/cursor/lensCursor.js';\nimport { lensCursorFrom } from '../../core/cursor/lensCursor.js';\nimport type { CursorPosition } from '../../core/group/cursorPositionsAtDrill.js';\nimport type { ServedCursor } from '../../core/served/types.js';\nimport { tagAxisPositions } from '../../core/tags/tagAxis.js';\nimport type { EventLogEntry } from '../../core/types.js';\nimport { snapshotLogKey, snapshotOfRunner } from '../../core/utils/snapshotOfRunner.js';\nimport { Badge } from './ServedBadge.js';\n\nexport const LABELS = Object.freeze({\n view: 'Context',\n keys: 'keys',\n wroteBy: 'wrote by',\n at: 'at',\n entered: 'entered',\n changed: 'changed',\n unchanged: 'unchanged',\n left: 'left',\n unattributed: 'unattributed',\n rows: 'rows',\n served: 'served',\n why: 'why',\n epoch: 'epoch',\n system: 'system',\n tools: 'tools',\n redacted: 'redacted',\n skipped: 'skipped',\n foldError: 'fold error',\n servedError: 'served error',\n previous: 'previous',\n next: 'next',\n json: 'JSON',\n empty: '{ }',\n});\n\n/** The milestone kinds a standalone view walks — the library's own tag vocabulary. */\nexport const MILESTONE_AXIS: readonly string[] = Object.freeze([\n 'milestone:iteration',\n 'milestone:slot',\n 'milestone:llm-turn',\n 'milestone:tool-call',\n 'milestone:decision',\n]);\n\nexport interface ContextViewProps {\n /** The recording or a runner with `getLastSnapshot()` — the same input the Served tab takes. */\n readonly runner: unknown;\n /** THE cursor, when a host holds it. Absent: the view walks its own milestone axis. */\n readonly cursor?: LensCursor;\n /**\n * The previous stop on the HOST's axis, when it hands `cursor` (0.53.3) —\n * what `since` (entered / changed / unchanged) and `left` are measured\n * against. A standalone view knows its own previous stop; a slotted one\n * cannot, and without this it claims no direction.\n */\n readonly previous?: ServedCursor;\n /** The recording's event stream, for the `why` band (a replay's `getEntries()`). */\n readonly events?: readonly EventLogEntry[];\n /** Show the fold as JSON instead of the key table. */\n readonly initialMode?: 'keys' | 'json';\n}\n\nfunction positionsOf(snapshot: unknown): readonly CursorPosition[] {\n return tagAxisPositions(snapshot, MILESTONE_AXIS, []) ?? [];\n}\n\nfunction servedCursorOf(cursor: LensCursor): ServedCursor {\n return {\n runtimeStageId: cursor.at.runtimeStageId,\n commitIdx: cursor.at.commitIdx,\n };\n}\n\nfunction previousOf(\n cursor: LensCursor,\n positions: readonly CursorPosition[] | undefined,\n): ServedCursor | undefined {\n if (cursor.at.step <= 0) return undefined;\n const p = positions?.[cursor.at.step - 1];\n return p !== undefined ? { runtimeStageId: p.runtimeStageId, commitIdx: p.commitIdx } : undefined;\n}\n\nexport function ContextView(props: ContextViewProps): React.ReactElement {\n const { runner, events } = props;\n const fresh = snapshotOfRunner(runner);\n const logKey = snapshotLogKey(fresh);\n const snapshot = useMemo(() => fresh, [runner, logKey]);\n const ownPositions = useMemo(\n () => (props.cursor === undefined ? positionsOf(snapshot) : undefined),\n [snapshot, props.cursor],\n );\n const [ownStep, setOwnStep] = useState(0);\n const cursor: LensCursor =\n props.cursor ??\n lensCursorFrom(\n ownPositions ?? [],\n Math.min(ownStep, Math.max(0, (ownPositions?.length ?? 1) - 1)),\n setOwnStep,\n );\n const [mode, setMode] = useState<'keys' | 'json'>(props.initialMode ?? 'keys');\n\n const context = useMemo(\n () =>\n contextAt(snapshot, servedCursorOf(cursor), {\n previous: props.previous ?? previousOf(cursor, ownPositions),\n events,\n }),\n [snapshot, cursor.at.runtimeStageId, cursor.at.commitIdx, cursor.at.step, ownPositions, events],\n );\n\n return (\n <div\n style={panel}\n data-testid=\"context-view\"\n data-step={cursor.at.step}\n data-commit={cursor.at.commitIdx}\n >\n <div style={header}>\n <span style={title}>{LABELS.view}</span>\n <span style={dim}>\n {cursor.at.label} · {cursor.at.step + 1}/{cursor.total}\n </span>\n <span style={{ marginLeft: 'auto', display: 'flex', gap: 6 }}>\n {props.cursor === undefined && (\n <>\n <button\n type=\"button\"\n style={btn}\n disabled={cursor.at.step <= 0}\n onClick={() => cursor.moveTo(cursor.at.step - 1)}\n data-testid=\"context-prev\"\n >\n {LABELS.previous}\n </button>\n <button\n type=\"button\"\n style={btn}\n disabled={cursor.at.step >= cursor.total - 1}\n onClick={() => cursor.moveTo(cursor.at.step + 1)}\n data-testid=\"context-next\"\n >\n {LABELS.next}\n </button>\n </>\n )}\n <button\n type=\"button\"\n style={btn}\n aria-pressed={mode === 'keys'}\n onClick={() => setMode('keys')}\n data-testid=\"context-mode-keys\"\n >\n {LABELS.keys}\n </button>\n <button\n type=\"button\"\n style={btn}\n aria-pressed={mode === 'json'}\n onClick={() => setMode('json')}\n data-testid=\"context-mode-json\"\n >\n {LABELS.json}\n </button>\n </span>\n </div>\n <Facts context={context} />\n {mode === 'json' ? <JsonPane context={context} /> : <KeyTable context={context} />}\n <ServedBand context={context} />\n <WhyBand context={context} />\n </div>\n );\n}\n\nfunction Facts({ context }: { readonly context: ContextAt }): React.ReactElement | null {\n const facts: string[] = [];\n if (context.redacted) facts.push(LABELS.redacted);\n if (context.skipped !== undefined) facts.push(`${LABELS.skipped} ${context.skipped.join(',')}`);\n if (context.foldError !== undefined) facts.push(`${LABELS.foldError}: ${context.foldError}`);\n if (context.servedError !== undefined) facts.push(`${LABELS.servedError}: ${context.servedError}`);\n if (facts.length === 0) return null;\n return (\n <div style={dim} data-testid=\"context-facts\">\n {facts.join(' · ')}\n </div>\n );\n}\n\nfunction KeyTable({ context }: { readonly context: ContextAt }): React.ReactElement {\n if (context.keys.length === 0 && context.left.length === 0) {\n return (\n <div style={mono} data-testid=\"context-empty\">\n {LABELS.empty}\n </div>\n );\n }\n return (\n <table style={table} data-testid=\"context-keys\">\n <tbody>\n {context.keys.map((k) => (\n <KeyRow key={k.path} k={k} />\n ))}\n {context.left.map((path) => (\n <tr key={`left:${path}`} data-testid=\"context-key\" data-since=\"left\" style={{ opacity: 0.6 }}>\n <td style={cell}>\n <code>{path}</code>\n </td>\n <td style={cell}>{LABELS.left}</td>\n <td style={cell} />\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n\nfunction KeyRow({ k }: { readonly k: ContextKey }): React.ReactElement {\n const since = k.since === undefined ? undefined : LABELS[k.since];\n return (\n <tr\n data-testid=\"context-key\"\n data-path={k.path}\n data-since={k.since ?? ''}\n style={k.since === 'unchanged' ? { opacity: 0.6 } : undefined}\n >\n <td style={cell}>\n <code>{k.path}</code>\n {since !== undefined && <span style={pill}>{since}</span>}\n </td>\n <td style={cell} data-testid=\"context-wrote-by\">\n {k.wroteBy !== undefined ? (\n <>\n <span style={dim}>{LABELS.wroteBy} </span>\n <code>{k.wroteBy}</code>\n <span style={dim}>\n {' '}\n {LABELS.at} #{k.wroteAt} · {k.verb}\n </span>\n </>\n ) : (\n <span style={dim}>{LABELS.unattributed}</span>\n )}\n </td>\n <td style={{ ...cell, ...mono }}>\n <ValueCell value={k.value} />\n </td>\n </tr>\n );\n}\n\nfunction ValueCell({ value }: { readonly value: unknown }): React.ReactElement {\n const text = JSON.stringify(value);\n const short = text === undefined ? '' : text.length > 160 ? `${text.slice(0, 157)}…` : text;\n return <span title={text}>{short}</span>;\n}\n\nfunction JsonPane({ context }: { readonly context: ContextAt }): React.ReactElement {\n const object: Record<string, unknown> = {};\n for (const k of context.keys) object[k.path] = k.value;\n return (\n <pre style={{ ...mono, ...pre }} data-testid=\"context-json\">\n {JSON.stringify(object, null, 2)}\n </pre>\n );\n}\n\nfunction ServedBand({ context }: { readonly context: ContextAt }): React.ReactElement | null {\n const served = context.served;\n if (served === undefined) return null;\n const { row, checks } = served;\n return (\n <div style={band} data-testid=\"context-served\" data-epoch={row.view.epoch}>\n <span style={dim}>\n {LABELS.served} · {LABELS.epoch} {row.view.epoch} · {LABELS.system}\n </span>{' '}\n <Badge check={checks.system} /> <span style={dim}>{LABELS.tools}</span>{' '}\n <Badge check={checks.toolNames} />\n </div>\n );\n}\n\nfunction WhyBand({ context }: { readonly context: ContextAt }): React.ReactElement | null {\n if (context.why.length === 0) return null;\n return (\n <div style={band} data-testid=\"context-why\">\n <span style={dim}>{LABELS.why}</span>\n <ul style={list}>\n {context.why.map((w) => (\n <li key={w.seq} style={mono}>\n <code>{w.name}</code> <span style={dim}>#{w.seq}</span>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n\nconst panel: React.CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n gap: 8,\n padding: 10,\n fontSize: 13,\n};\nconst header: React.CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n gap: 10,\n};\nconst title: React.CSSProperties = { fontWeight: 600 };\nconst dim: React.CSSProperties = { opacity: 0.7 };\nconst mono: React.CSSProperties = {\n fontFamily: 'monospace',\n fontSize: 12,\n};\nconst pre: React.CSSProperties = {\n margin: 0,\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n};\nconst table: React.CSSProperties = {\n borderCollapse: 'collapse',\n width: '100%',\n};\nconst cell: React.CSSProperties = {\n padding: '4px 6px',\n verticalAlign: 'top',\n borderTop: '1px solid',\n borderTopColor: 'currentColor',\n};\nconst pill: React.CSSProperties = {\n marginLeft: 6,\n padding: '0 6px',\n borderRadius: 8,\n fontSize: 11,\n border: '1px solid',\n borderColor: 'currentColor',\n};\nconst band: React.CSSProperties = {\n paddingTop: 6,\n borderTop: '1px solid',\n borderTopColor: 'currentColor',\n};\nconst list: React.CSSProperties = { margin: '4px 0 0', paddingLeft: 18 };\nconst btn: React.CSSProperties = { fontSize: 12, padding: '2px 8px' };\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAgB,SAAS,gBAAgB;AAyHjC,SAMI,UANJ,KACA,YADA;AA7GD,IAAM,SAAS,OAAO,OAAO;AAAA,EAClC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AAAA,EACX,MAAM;AAAA,EACN,cAAc;AAAA,EACd,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa;AAAA,EACb,UAAU;AAAA,EACV,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT,CAAC;AAGM,IAAM,iBAAoC,OAAO,OAAO;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAoBD,SAAS,YAAY,UAA8C;AACjE,SAAO,iBAAiB,UAAU,gBAAgB,CAAC,CAAC,KAAK,CAAC;AAC5D;AAEA,SAAS,eAAe,QAAkC;AACxD,SAAO;AAAA,IACL,gBAAgB,OAAO,GAAG;AAAA,IAC1B,WAAW,OAAO,GAAG;AAAA,EACvB;AACF;AAEA,SAAS,WACP,QACA,WAC0B;AAC1B,MAAI,OA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,SAA8B;AAAA,EAClC,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,KAAK;AACP;AACA,IAAM,QAA6B,EAAE,YAAY,IAAI;AACrD,IAAM,MAA2B,EAAE,SAAS,IAAI;AAChD,IAAM,OAA4B;AAAA,EAChC,YAAY;AAAA,EACZ,UAAU;AACZ;AACA,IAAM,MAA2B;AAAA,EAC/B,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,WAAW;AACb;AACA,IAAM,QAA6B;AAAA,EACjC,gBAAgB;AAAA,EAChB,OAAO;AACT;AACA,IAAM,OAA4B;AAAA,EAChC,SAAS;AAAA,EACT,eAAe;AAAA,EACf,WAAW;AAAA,EACX,gBAAgB;AAClB;AACA,IAAM,OAA4B;AAAA,EAChC,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,cAAc;AAAA,EACd,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,aAAa;AACf;AACA,IAAM,OAA4B;AAAA,EAChC,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,gBAAgB;AAClB;AACA,IAAM,OAA4B,EAAE,QAAQ,WAAW,aAAa,GAAG;AACvE,IAAM,MAA2B,EAAE,UAAU,IAAI,SAAS,UAAU;","names":[]}
|
|
@@ -6,7 +6,16 @@ import {
|
|
|
6
6
|
} from "./chunk-47W3TQT6.js";
|
|
7
7
|
|
|
8
8
|
// src/core/context/contextAt.ts
|
|
9
|
-
import
|
|
9
|
+
import * as trace from "footprintjs/trace";
|
|
10
|
+
import { stateAt } from "footprintjs/trace";
|
|
11
|
+
function firstSegment(path) {
|
|
12
|
+
const helper = trace.pathSegments;
|
|
13
|
+
if (typeof helper === "function") return helper(path)[0];
|
|
14
|
+
const unit = path.indexOf("");
|
|
15
|
+
if (unit >= 0) return path.slice(0, unit);
|
|
16
|
+
const dot = path.indexOf(".");
|
|
17
|
+
return dot >= 0 ? path.slice(0, dot) : path;
|
|
18
|
+
}
|
|
10
19
|
function logOf(snapshot) {
|
|
11
20
|
const s = snapshot;
|
|
12
21
|
return Array.isArray(s?.commitLog) ? s.commitLog : [];
|
|
@@ -19,7 +28,7 @@ function writersUpTo(log, commitIdx) {
|
|
|
19
28
|
if (bundle === void 0 || typeof bundle.runtimeStageId !== "string" || !Array.isArray(bundle.trace))
|
|
20
29
|
continue;
|
|
21
30
|
for (const row of bundle.trace) {
|
|
22
|
-
const key =
|
|
31
|
+
const key = firstSegment(row.path);
|
|
23
32
|
if (key === void 0) continue;
|
|
24
33
|
const prior = out.get(key);
|
|
25
34
|
out.set(key, {
|
|
@@ -130,4 +139,4 @@ function contextAt(recording, cursor, options = {}) {
|
|
|
130
139
|
export {
|
|
131
140
|
contextAt
|
|
132
141
|
};
|
|
133
|
-
//# sourceMappingURL=chunk-
|
|
142
|
+
//# sourceMappingURL=chunk-S4KD5E4C.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/context/contextAt.ts"],"sourcesContent":["/**\n * core/context/contextAt — the context object at a stop, with who wrote each\n * key, what moved since the previous stop, and what was served beside it.\n *\n * THE JOIN, nothing more. Three records already exist and this file writes\n * none of its own:\n *\n * 1. the COMMIT LOG — `stateAt(snapshot, commitIdx)` is the object at the\n * stop; the trace rows of the bundles up to it name, per top-level key,\n * the stage that last wrote it (`runtimeStageId`) and the first that\n * did; the bundle's own rows are the DELTA of the stop;\n * 2. the RECEIPT at the stop's epoch — `servedRowAt` (the Served tab's own\n * core) says what crossed into the model call and what the catalogue\n * withheld; it is handed through untouched, never re-derived;\n * 3. the EVENT STREAM — entries stamped with the stages that wrote this\n * stop's delta, or with the stop's own stage, are the \"why\" beside the\n * keys; names only, no sentence.\n *\n * Join keys: `runtimeStageId` (commit log ⟂ events), `epoch` (commit log ⟂\n * receipt, through `servedRowAt`). A key the fold holds with no writer row —\n * the run's initial state, or a row the log lost — is `wroteBy: undefined`:\n * UNATTRIBUTED, never guessed (the reads law: omit, never deny). Owners are\n * stage ids, because that is what the record says; a word like \"host\" or\n * \"model\" is a reader's mapping, not this file's.\n *\n * Pure; frozen returns; no React. Consumers with their own UI read this.\n */\nimport * as trace from 'footprintjs/trace';\nimport { stateAt } from 'footprintjs/trace';\nimport type { FoldSource, FoldedState } from 'footprintjs/trace';\n\nimport type { EventLogEntry } from '../types.js';\nimport { servedRowAt, servedRowForEpoch } from '../served/servedRowAt.js';\nimport { sincePrevious, type SincePrevious } from '../served/sincePrevious.js';\nimport { verify, type ServedVerification } from '../served/verify.js';\nimport type { ServedCursor, ServedRow } from '../served/types.js';\n\n/** The slice of a footprintjs commit bundle this file reads — narrowed per row, never trusted whole. */\ninterface TraceRow {\n readonly path: string;\n readonly verb: string;\n}\ninterface CommitBundle {\n readonly idx?: number;\n readonly runtimeStageId: string;\n readonly trace?: readonly TraceRow[];\n}\n\n/** One top-level key of the context object at the stop. */\nexport interface ContextKey {\n readonly path: string;\n readonly value: unknown;\n /** The stage that LAST wrote the key, from its trace row; absent = unattributed. */\n readonly wroteBy?: string;\n /** The commit index of that last write. */\n readonly wroteAt?: number;\n /** The first commit that wrote the key — when it ENTERED the context. */\n readonly enteredAt?: number;\n /** The verb of the last write, from the trace row. */\n readonly verb?: string;\n /** How the key moved since the previous stop (absent when no previous stop was given). */\n readonly since?: 'entered' | 'changed' | 'unchanged';\n}\n\n/** What is served beside the object at this stop — the Served tab's own row, handed through. */\nexport interface ContextServed {\n readonly row: ServedRow;\n readonly checks: ServedVerification;\n readonly since?: SincePrevious;\n}\n\nexport interface ContextAt {\n readonly cursor: ServedCursor;\n /** Every top-level key of the fold at the stop, in the fold's key order. */\n readonly keys: readonly ContextKey[];\n /** Keys the previous stop held that this one does not (only with a previous stop). */\n readonly left: readonly string[];\n /** The trace rows the stop's own bundle wrote — its delta as the log spells it. */\n readonly rows: readonly { readonly path: string; readonly verb: string }[];\n /** The fold's honesty facts, as `stateAt` reports them. */\n readonly basis?: FoldedState['basis'];\n readonly redacted: boolean;\n readonly skipped?: readonly number[];\n readonly foldError?: string;\n /** The served side at this stop's epoch, when the stop is at or after a model call. */\n readonly served?: ContextServed;\n /** The Served core refused this snapshot — its message, verbatim; `served` is then absent. */\n readonly servedError?: string;\n /** Event names raised by the stages that wrote this stop's delta, or by its own stage. */\n readonly why: readonly {\n readonly seq: number;\n readonly name: string;\n readonly runtimeStageId: string;\n }[];\n}\n\nexport interface ContextAtOptions {\n /** The previous stop on the reader's axis — enables `since` and `left`. */\n readonly previous?: ServedCursor;\n /** The recording's event stream, when the reader has one (a replay's `getEntries()`). */\n readonly events?: readonly EventLogEntry[];\n}\n\n/**\n * The top-level key a trace-row path names. footprintjs 9.22.0 exports\n * `pathSegments` (its paths are joined with U+001F since then); the lens's\n * peer floor is 9.17.0, whose paths are dotted and which has no such export —\n * so the helper is read at call time, the way `tagStops` is, and a floor\n * substrate gets the split it used (0.53.4: a consumer on 9.21.1 could not\n * even bundle the lens while this was a static import).\n */\nexport function firstSegment(path: string): string | undefined {\n const helper = (trace as { pathSegments?: (p: string) => string[] }).pathSegments;\n if (typeof helper === 'function') return helper(path)[0];\n const unit = path.indexOf('\\u001F');\n if (unit >= 0) return path.slice(0, unit);\n const dot = path.indexOf('.');\n return dot >= 0 ? path.slice(0, dot) : path;\n}\n\ninterface WriterFacts {\n readonly wroteBy: string;\n readonly wroteAt: number;\n readonly enteredAt: number;\n readonly verb: string;\n}\n\nfunction logOf(snapshot: unknown): readonly CommitBundle[] {\n const s = snapshot as { commitLog?: unknown } | null | undefined;\n return Array.isArray(s?.commitLog) ? (s.commitLog as CommitBundle[]) : [];\n}\n\n/** Per top-level key, the first and last trace rows up to `commitIdx` (inclusive). */\nfunction writersUpTo(log: readonly CommitBundle[], commitIdx: number): ReadonlyMap<string, WriterFacts> {\n const out = new Map<string, WriterFacts>();\n const last = Math.min(commitIdx, log.length - 1);\n for (let i = 0; i <= last; i++) {\n const bundle = log[i];\n if (bundle === undefined || typeof bundle.runtimeStageId !== 'string' || !Array.isArray(bundle.trace))\n continue;\n for (const row of bundle.trace) {\n const key = firstSegment(row.path);\n if (key === undefined) continue;\n const prior = out.get(key);\n out.set(key, {\n wroteBy: bundle.runtimeStageId,\n wroteAt: i,\n enteredAt: prior?.enteredAt ?? i,\n verb: row.verb,\n });\n }\n }\n return out;\n}\n\nfunction foldAt(snapshot: unknown, commitIdx: number): FoldedState | { readonly error: string } {\n const source: FoldSource | undefined =\n typeof snapshot === 'object' && snapshot !== null ? (snapshot as FoldSource) : undefined;\n try {\n return stateAt(source, commitIdx);\n } catch (e) {\n return { error: e instanceof Error ? e.message : String(e) };\n }\n}\n\nconst same = (a: unknown, b: unknown): boolean => JSON.stringify(a) === JSON.stringify(b);\n\nfunction servedFor(\n snapshot: unknown,\n cursor: ServedCursor,\n): { readonly served?: ContextServed; readonly servedError?: string } {\n try {\n const row = servedRowAt(snapshot, cursor);\n if (row === undefined) return {};\n const checks = verify(row.view, row.receipt, row.receipt?.basis.runId ?? '', row.receiptCause);\n const previous =\n row.previousEpoch !== undefined ? servedRowForEpoch(snapshot, row.previousEpoch) : undefined;\n const since = previous !== undefined ? sincePrevious(row, previous) : undefined;\n return {\n served: Object.freeze({\n row,\n checks,\n ...(since !== undefined ? { since } : {}),\n }),\n };\n } catch (e) {\n return { servedError: e instanceof Error ? e.message : String(e) };\n }\n}\n\nfunction whyFor(events: readonly EventLogEntry[] | undefined, stages: ReadonlySet<string>): ContextAt['why'] {\n if (events === undefined || stages.size === 0) return Object.freeze([]);\n const out: { seq: number; name: string; runtimeStageId: string }[] = [];\n for (const entry of events) {\n const id = entry.runtimeStageId;\n if (id === undefined || !stages.has(id)) continue;\n out.push({ seq: entry.seq, name: entry.event.type, runtimeStageId: id });\n }\n return Object.freeze(out);\n}\n\n/**\n * The context at `cursor`: the fold's keys with their writers, the delta\n * since `options.previous`, the served side at this epoch, and the events\n * beside the delta. Returns a frozen object; a fold that cannot be replayed\n * reports `foldError` with no keys rather than an empty object pretending to\n * be one.\n */\nexport function contextAt(\n recording: unknown,\n cursor: ServedCursor,\n options: ContextAtOptions = {},\n): ContextAt {\n const log = logOf(recording);\n const folded = foldAt(recording, cursor.commitIdx);\n if ('error' in folded) {\n return Object.freeze({\n cursor,\n keys: Object.freeze([]),\n left: Object.freeze([]),\n rows: Object.freeze([]),\n redacted: false,\n foldError: folded.error,\n why: Object.freeze([]),\n });\n }\n const writers = writersUpTo(log, cursor.commitIdx);\n const previous = options.previous !== undefined ? foldAt(recording, options.previous.commitIdx) : undefined;\n const previousState = previous !== undefined && !('error' in previous) ? previous.state : undefined;\n\n const keys: ContextKey[] = [];\n for (const [path, value] of Object.entries(folded.state)) {\n const w = writers.get(path);\n const since: ContextKey['since'] | undefined =\n previousState === undefined\n ? undefined\n : !(path in previousState)\n ? 'entered'\n : same(previousState[path], value)\n ? 'unchanged'\n : 'changed';\n keys.push(\n Object.freeze({\n path,\n value,\n ...(w !== undefined\n ? {\n wroteBy: w.wroteBy,\n wroteAt: w.wroteAt,\n enteredAt: w.enteredAt,\n verb: w.verb,\n }\n : {}),\n ...(since !== undefined ? { since } : {}),\n }),\n );\n }\n const left =\n previousState === undefined ? [] : Object.keys(previousState).filter((k) => !(k in folded.state));\n\n const bundle = log[cursor.commitIdx];\n const rows = Array.isArray(bundle?.trace)\n ? bundle.trace.map((r: TraceRow) => Object.freeze({ path: r.path, verb: r.verb }))\n : [];\n\n const stages = new Set<string>();\n if (bundle !== undefined && typeof bundle.runtimeStageId === 'string') stages.add(bundle.runtimeStageId);\n for (const k of keys)\n if (k.since !== undefined && k.since !== 'unchanged' && k.wroteBy !== undefined) stages.add(k.wroteBy);\n\n const skipped =\n folded.skipped !== undefined && folded.skipped.length > 0\n ? folded.skipped.map((g) => g.index)\n : undefined;\n const { served, servedError } = servedFor(recording, cursor);\n\n return Object.freeze({\n cursor,\n keys: Object.freeze(keys),\n left: Object.freeze(left),\n rows: Object.freeze(rows),\n basis: folded.basis,\n redacted: folded.redacted,\n ...(skipped !== undefined ? { skipped: Object.freeze(skipped) } : {}),\n ...(served !== undefined ? { served } : {}),\n ...(servedError !== undefined ? { servedError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,CAAC,MAAgB,OAAO,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,EAAE,KAAK,CAAC,CAAC,IAC/E,CAAC;AAEL,QAAM,SAAS,oBAAI,IAAY;AAC/B,MAAI,WAAW,UAAa,OAAO,OAAO,mBAAmB,SAAU,QAAO,IAAI,OAAO,cAAc;AACvG,aAAW,KAAK;AACd,QAAI,EAAE,UAAU,UAAa,EAAE,UAAU,eAAe,EAAE,YAAY,OAAW,QAAO,IAAI,EAAE,OAAO;AAEvG,QAAM,UACJ,OAAO,YAAY,UAAa,OAAO,QAAQ,SAAS,IACpD,OAAO,QAAQ,IAAI,CAAC,MAAM,EAAE,KAAK,IACjC;AACN,QAAM,EAAE,QAAQ,YAAY,IAAI,UAAU,WAAW,MAAM;AAE3D,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,MAAM,OAAO,OAAO,IAAI;AAAA,IACxB,MAAM,OAAO,OAAO,IAAI;AAAA,IACxB,MAAM,OAAO,OAAO,IAAI;AAAA,IACxB,OAAO,OAAO;AAAA,IACd,UAAU,OAAO;AAAA,IACjB,GAAI,YAAY,SAAY,EAAE,SAAS,OAAO,OAAO,OAAO,EAAE,IAAI,CAAC;AAAA,IACnE,GAAI,WAAW,SAAY,EAAE,OAAO,IAAI,CAAC;AAAA,IACzC,GAAI,gBAAgB,SAAY,EAAE,YAAY,IAAI,CAAC;AAAA,IACnD,KAAK,OAAO,QAAQ,QAAQ,MAAM;AAAA,EACpC,CAAC;AACH;","names":[]}
|
package/dist/context.cjs
CHANGED
|
@@ -41,6 +41,7 @@ module.exports = __toCommonJS(context_exports);
|
|
|
41
41
|
var import_react = require("react");
|
|
42
42
|
|
|
43
43
|
// src/core/context/contextAt.ts
|
|
44
|
+
var trace = __toESM(require("footprintjs/trace"), 1);
|
|
44
45
|
var import_trace = require("footprintjs/trace");
|
|
45
46
|
|
|
46
47
|
// src/core/served/servedRowAt.ts
|
|
@@ -526,6 +527,14 @@ function verify(view, receipt, runId, cause) {
|
|
|
526
527
|
}
|
|
527
528
|
|
|
528
529
|
// src/core/context/contextAt.ts
|
|
530
|
+
function firstSegment(path) {
|
|
531
|
+
const helper = trace.pathSegments;
|
|
532
|
+
if (typeof helper === "function") return helper(path)[0];
|
|
533
|
+
const unit = path.indexOf("");
|
|
534
|
+
if (unit >= 0) return path.slice(0, unit);
|
|
535
|
+
const dot = path.indexOf(".");
|
|
536
|
+
return dot >= 0 ? path.slice(0, dot) : path;
|
|
537
|
+
}
|
|
529
538
|
function logOf(snapshot) {
|
|
530
539
|
const s = snapshot;
|
|
531
540
|
return Array.isArray(s?.commitLog) ? s.commitLog : [];
|
|
@@ -538,7 +547,7 @@ function writersUpTo(log, commitIdx) {
|
|
|
538
547
|
if (bundle === void 0 || typeof bundle.runtimeStageId !== "string" || !Array.isArray(bundle.trace))
|
|
539
548
|
continue;
|
|
540
549
|
for (const row of bundle.trace) {
|
|
541
|
-
const key = (
|
|
550
|
+
const key = firstSegment(row.path);
|
|
542
551
|
if (key === void 0) continue;
|
|
543
552
|
const prior = out.get(key);
|
|
544
553
|
out.set(key, {
|
|
@@ -763,10 +772,10 @@ function lensCursorFrom(positions, step, moveTo) {
|
|
|
763
772
|
}
|
|
764
773
|
|
|
765
774
|
// src/core/tags/tagAxis.ts
|
|
766
|
-
var
|
|
775
|
+
var trace2 = __toESM(require("footprintjs/trace"), 1);
|
|
767
776
|
var agentfootprint2 = __toESM(require("agentfootprint"), 1);
|
|
768
777
|
function tagStopsStrategy() {
|
|
769
|
-
const fn =
|
|
778
|
+
const fn = trace2.tagStops;
|
|
770
779
|
return typeof fn === "function" ? fn : void 0;
|
|
771
780
|
}
|
|
772
781
|
function milestoneOf(meta) {
|
|
@@ -1110,7 +1119,7 @@ function ContextView(props) {
|
|
|
1110
1119
|
const [mode, setMode] = (0, import_react.useState)(props.initialMode ?? "keys");
|
|
1111
1120
|
const context = (0, import_react.useMemo)(
|
|
1112
1121
|
() => contextAt(snapshot, servedCursorOf(cursor), {
|
|
1113
|
-
previous: previousOf(cursor, ownPositions),
|
|
1122
|
+
previous: props.previous ?? previousOf(cursor, ownPositions),
|
|
1114
1123
|
events
|
|
1115
1124
|
}),
|
|
1116
1125
|
[snapshot, cursor.at.runtimeStageId, cursor.at.commitIdx, cursor.at.step, ownPositions, events]
|