agentfootprint 7.1.0 → 7.3.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/CLAUDE.md +2 -2
- package/dist/adapters/llm/AnthropicProvider.js +5 -1
- package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
- package/dist/debug.js +5 -2
- package/dist/debug.js.map +1 -1
- package/dist/embedders/index.js +139 -0
- package/dist/embedders/index.js.map +1 -0
- package/dist/esm/adapters/llm/AnthropicProvider.d.ts +12 -0
- package/dist/esm/adapters/llm/AnthropicProvider.js +5 -1
- package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
- package/dist/esm/debug.d.ts +1 -1
- package/dist/esm/debug.js +1 -1
- package/dist/esm/debug.js.map +1 -1
- package/dist/esm/embedders/index.d.ts +49 -0
- package/dist/esm/embedders/index.js +110 -0
- package/dist/esm/embedders/index.js.map +1 -0
- package/dist/esm/lib/context-ledger/contextLedger.d.ts +35 -0
- package/dist/esm/lib/context-ledger/contextLedger.js +309 -0
- package/dist/esm/lib/context-ledger/contextLedger.js.map +1 -0
- package/dist/esm/lib/context-ledger/gates.d.ts +63 -0
- package/dist/esm/lib/context-ledger/gates.js +105 -0
- package/dist/esm/lib/context-ledger/gates.js.map +1 -0
- package/dist/esm/lib/context-ledger/index.d.ts +10 -0
- package/dist/esm/lib/context-ledger/index.js +10 -0
- package/dist/esm/lib/context-ledger/index.js.map +1 -0
- package/dist/esm/lib/context-ledger/types.d.ts +107 -0
- package/dist/esm/lib/context-ledger/types.js +28 -0
- package/dist/esm/lib/context-ledger/types.js.map +1 -0
- package/dist/esm/lib/influence-core/attribute.d.ts +27 -0
- package/dist/esm/lib/influence-core/attribute.js +91 -0
- package/dist/esm/lib/influence-core/attribute.js.map +1 -0
- package/dist/esm/lib/influence-core/explain.d.ts +67 -0
- package/dist/esm/lib/influence-core/explain.js +80 -0
- package/dist/esm/lib/influence-core/explain.js.map +1 -0
- package/dist/esm/lib/influence-core/index.d.ts +4 -1
- package/dist/esm/lib/influence-core/index.js +3 -0
- package/dist/esm/lib/influence-core/index.js.map +1 -1
- package/dist/esm/lib/influence-core/snippets.d.ts +45 -0
- package/dist/esm/lib/influence-core/snippets.js +114 -0
- package/dist/esm/lib/influence-core/snippets.js.map +1 -0
- package/dist/esm/lib/influence-core/types.d.ts +50 -0
- package/dist/esm/observe.d.ts +2 -0
- package/dist/esm/observe.js +4 -0
- package/dist/esm/observe.js.map +1 -1
- package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +8 -2
- package/dist/esm/recorders/observability/ToolChoiceRecorder.js +24 -6
- package/dist/esm/recorders/observability/ToolChoiceRecorder.js.map +1 -1
- package/dist/lib/context-ledger/contextLedger.js +313 -0
- package/dist/lib/context-ledger/contextLedger.js.map +1 -0
- package/dist/lib/context-ledger/gates.js +111 -0
- package/dist/lib/context-ledger/gates.js.map +1 -0
- package/dist/lib/context-ledger/index.js +17 -0
- package/dist/lib/context-ledger/index.js.map +1 -0
- package/dist/lib/context-ledger/types.js +29 -0
- package/dist/lib/context-ledger/types.js.map +1 -0
- package/dist/lib/influence-core/attribute.js +95 -0
- package/dist/lib/influence-core/attribute.js.map +1 -0
- package/dist/lib/influence-core/explain.js +84 -0
- package/dist/lib/influence-core/explain.js.map +1 -0
- package/dist/lib/influence-core/index.js +7 -1
- package/dist/lib/influence-core/index.js.map +1 -1
- package/dist/lib/influence-core/snippets.js +118 -0
- package/dist/lib/influence-core/snippets.js.map +1 -0
- package/dist/observe.js +9 -1
- package/dist/observe.js.map +1 -1
- package/dist/recorders/observability/ToolChoiceRecorder.js +24 -6
- package/dist/recorders/observability/ToolChoiceRecorder.js.map +1 -1
- package/dist/types/adapters/llm/AnthropicProvider.d.ts +12 -0
- package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
- package/dist/types/debug.d.ts +1 -1
- package/dist/types/debug.d.ts.map +1 -1
- package/dist/types/embedders/index.d.ts +50 -0
- package/dist/types/embedders/index.d.ts.map +1 -0
- package/dist/types/lib/context-ledger/contextLedger.d.ts +36 -0
- package/dist/types/lib/context-ledger/contextLedger.d.ts.map +1 -0
- package/dist/types/lib/context-ledger/gates.d.ts +64 -0
- package/dist/types/lib/context-ledger/gates.d.ts.map +1 -0
- package/dist/types/lib/context-ledger/index.d.ts +11 -0
- package/dist/types/lib/context-ledger/index.d.ts.map +1 -0
- package/dist/types/lib/context-ledger/types.d.ts +108 -0
- package/dist/types/lib/context-ledger/types.d.ts.map +1 -0
- package/dist/types/lib/influence-core/attribute.d.ts +28 -0
- package/dist/types/lib/influence-core/attribute.d.ts.map +1 -0
- package/dist/types/lib/influence-core/explain.d.ts +68 -0
- package/dist/types/lib/influence-core/explain.d.ts.map +1 -0
- package/dist/types/lib/influence-core/index.d.ts +4 -1
- package/dist/types/lib/influence-core/index.d.ts.map +1 -1
- package/dist/types/lib/influence-core/snippets.d.ts +46 -0
- package/dist/types/lib/influence-core/snippets.d.ts.map +1 -0
- package/dist/types/lib/influence-core/types.d.ts +50 -0
- package/dist/types/lib/influence-core/types.d.ts.map +1 -1
- package/dist/types/observe.d.ts +2 -0
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/recorders/observability/ToolChoiceRecorder.d.ts +8 -2
- package/dist/types/recorders/observability/ToolChoiceRecorder.d.ts.map +1 -1
- package/package.json +26 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* contextLedger — the post-run bookkeeper (see types.ts for the WHY).
|
|
3
|
+
*
|
|
4
|
+
* DESIGN: a pure POST-RUN analyzer over the run's own commit log — no live
|
|
5
|
+
* recorder lifecycle, no event-order coupling. Everything it counts is
|
|
6
|
+
* already durably recorded by the engine (dogfooding: offers come from
|
|
7
|
+
* `commitValueAt` folds, answer attribution from `sliceForKey` — the same
|
|
8
|
+
* canonical queries every triage surface uses):
|
|
9
|
+
*
|
|
10
|
+
* offers — the context IN EFFECT at each LLM call. Call marker: a
|
|
11
|
+
* commit that wrote `totalInputTokens` (monotonic — never
|
|
12
|
+
* net-change-dropped) and did NOT write `userMessage` (which
|
|
13
|
+
* only the seed writes). At each call index, fold
|
|
14
|
+
* `activeInjections` + `dynamicToolSchemas`, and add the
|
|
15
|
+
* STATIC tool registry (duck-read from the runner's public
|
|
16
|
+
* `getUIGroup().extra.toolNames` — static registries live in a
|
|
17
|
+
* closure, never in scope state). NOTE offers are deliberately
|
|
18
|
+
* NOT "per context-key commit": the net-change filter drops
|
|
19
|
+
* identical re-commits, so stable context appears once in the
|
|
20
|
+
* log while still being offered (and paying tokens) per call.
|
|
21
|
+
* Static-registry tools count offers with approxTokens 0 in L1
|
|
22
|
+
* (their schema JSON isn't in the log) — earnRate, the gate
|
|
23
|
+
* signal, is unaffected; dynamicToolSchemas carries real sizes.
|
|
24
|
+
* uses — tool: assistant messages' toolCalls in the final history;
|
|
25
|
+
* skill: `activatedInjectionIds`;
|
|
26
|
+
* injection: its SLOT's write sits on the final answer's
|
|
27
|
+
* backward slice (slot-granular, labeled).
|
|
28
|
+
* outcome — consumer label per run, credited to every offered piece.
|
|
29
|
+
*
|
|
30
|
+
* The slot→slice join needs NO id conventions: for each slot key
|
|
31
|
+
* (INJECTION_KEYS.*), `findLastWriter` names the commit that fed the final
|
|
32
|
+
* LLM call; membership of that writer in the answer slice IS the signal.
|
|
33
|
+
*/
|
|
34
|
+
import type { ContextLedger } from './types.js';
|
|
35
|
+
export declare function contextLedger(): ContextLedger;
|
|
36
|
+
//# sourceMappingURL=contextLedger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextLedger.d.ts","sourceRoot":"","sources":["../../../../src/lib/context-ledger/contextLedger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAaH,OAAO,KAAK,EACV,aAAa,EAMd,MAAM,YAAY,CAAC;AAwEpB,wBAAgB,aAAa,IAAI,aAAa,CAmO7C"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* context-ledger/gates.ts — L2: the ledger's rows feed what gets included.
|
|
3
|
+
*
|
|
4
|
+
* Three gates, one policy, each hooking an EXISTING seam (no new framework
|
|
5
|
+
* surface): `gatedTools(inner, predicate)` for tools, `skillGraph().entryBy`
|
|
6
|
+
* for skills, and a rule-trigger wrapper for injections.
|
|
7
|
+
*
|
|
8
|
+
* THE POLICY PRINCIPLE — demote, never starve: a piece the ledger judges
|
|
9
|
+
* poorly is demoted, but every `refreshEvery`-th decision lets it through
|
|
10
|
+
* anyway ("parole"), so it keeps generating fresh ledger data. Without
|
|
11
|
+
* parole a piece demoted once could never earn again — a self-fulfilling
|
|
12
|
+
* verdict. And the ledger never judges a piece it barely knows: below
|
|
13
|
+
* `minOffers` everything passes.
|
|
14
|
+
*/
|
|
15
|
+
import type { EntryScorer } from '../injection-engine/entryScorer.js';
|
|
16
|
+
import type { Injection } from '../injection-engine/types.js';
|
|
17
|
+
import type { ToolGatePredicate } from '../../tool-providers/types.js';
|
|
18
|
+
import type { ContextLedger } from './types.js';
|
|
19
|
+
/**
|
|
20
|
+
* When the ledger is allowed to judge, and how harshly.
|
|
21
|
+
* Plain-named knobs — a bookkeeper's rules, not ML hyperparameters.
|
|
22
|
+
*/
|
|
23
|
+
export interface LedgerPolicy {
|
|
24
|
+
/** Don't judge a piece until it has been offered this many times. Default 5. */
|
|
25
|
+
readonly minOffers?: number;
|
|
26
|
+
/** Demote below this used÷offered rate. Default 0.05 (essentially "never used"). */
|
|
27
|
+
readonly earnRateFloor?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Parole: let a demoted piece through anyway every Nth demotion decision,
|
|
30
|
+
* so it keeps earning fresh data. Default 10. `Infinity` disables parole
|
|
31
|
+
* (NOT recommended — a starved piece can never redeem itself).
|
|
32
|
+
*/
|
|
33
|
+
readonly refreshEvery?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* TOOL GATE — plug into the existing provider combinator:
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { gatedTools, staticTools } from 'agentfootprint/tool-providers';
|
|
40
|
+
* builder.toolProvider(gatedTools(staticTools(tools), ledgerToolGate(ledger)));
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* Unused tool schemas are usually the biggest silent token cost — this is
|
|
44
|
+
* the gate to start with.
|
|
45
|
+
*/
|
|
46
|
+
export declare function ledgerToolGate(ledger: ContextLedger, policy?: LedgerPolicy): ToolGatePredicate;
|
|
47
|
+
/**
|
|
48
|
+
* SKILL GATE — an `EntryScorer` for `skillGraph().entryBy(...)` that wraps
|
|
49
|
+
* another scorer (keyword, embedding, …) and demotes candidates the ledger
|
|
50
|
+
* says never earn. Demotion multiplies the inner score toward the floor —
|
|
51
|
+
* ranking pressure, not exclusion — and parole restores full weight
|
|
52
|
+
* periodically, so a demoted skill can still win when nothing else fits.
|
|
53
|
+
*/
|
|
54
|
+
export declare function ledgerEntryScorer(ledger: ContextLedger, inner: EntryScorer, policy?: LedgerPolicy): EntryScorer;
|
|
55
|
+
/**
|
|
56
|
+
* INJECTION GATE — wrap ONE injection so the ledger's verdict joins its
|
|
57
|
+
* trigger. `always` becomes a ledger-backed rule; an existing `rule` is
|
|
58
|
+
* AND-ed with the verdict. `on-tool-return` / `llm-activated` are returned
|
|
59
|
+
* UNCHANGED (they are already demand-driven — the ledger has nothing to
|
|
60
|
+
* add). `always` pieces are exempt unless you explicitly wrap them — the
|
|
61
|
+
* safety-first default from the design.
|
|
62
|
+
*/
|
|
63
|
+
export declare function ledgerGated(injection: Injection, ledger: ContextLedger, policy?: LedgerPolicy): Injection;
|
|
64
|
+
//# sourceMappingURL=gates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../../../../src/lib/context-ledger/gates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,oCAAoC,CAAC;AACtG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,YAAY,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,oFAAoF;IACpF,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AA2BD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,iBAAiB,CAG9F;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,WAAW,EAClB,MAAM,CAAC,EAAE,YAAY,GACpB,WAAW,CAqBb;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,YAAY,GACpB,SAAS,CAeX"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* context-ledger — which context pieces EARNED their tokens?
|
|
3
|
+
*
|
|
4
|
+
* Post-run bookkeeping over the run's own commit log (offers, structural
|
|
5
|
+
* uses, consumer outcomes) whose rows feed the gating seams so future turns
|
|
6
|
+
* include less. See README.md for the honesty model and the L2 gates.
|
|
7
|
+
*/
|
|
8
|
+
export { contextLedger } from './contextLedger.js';
|
|
9
|
+
export type { ContextLedger, LedgerJSON, LedgerRow, PieceKind, RecordedRun, UsedSignal, } from './types.js';
|
|
10
|
+
export { ledgerToolGate, ledgerEntryScorer, ledgerGated, type LedgerPolicy } from './gates.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/context-ledger/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EACV,aAAa,EACb,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* context-ledger/types.ts — the bookkeeper's vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS LIBRARY EXISTS: context engineering fails in one predictable
|
|
5
|
+
* direction — "include everything to be safe". Every injection, skill and
|
|
6
|
+
* tool schema costs tokens EVERY turn, whether or not it ever mattered. The
|
|
7
|
+
* ledger keeps score across runs: which pieces EARNED their tokens (were
|
|
8
|
+
* called, activated, or sat on the answer's dependency slice) and which
|
|
9
|
+
* never did. Its rows feed the L2 gates (gatedTools predicate, skill-graph
|
|
10
|
+
* EntryScorer, injection demotion) so future turns include less — the
|
|
11
|
+
* mechanism that makes lesser models viable.
|
|
12
|
+
*
|
|
13
|
+
* HONESTY (the discipline everything here inherits):
|
|
14
|
+
* - Every counter is a STRUCTURAL fact from the run's own commit log —
|
|
15
|
+
* offers are recorded commits, uses are recorded calls/activations/slice
|
|
16
|
+
* membership. Nothing is inferred from model internals.
|
|
17
|
+
* - Each kind's `used` definition is explicit ({@link UsedSignal}) and rides
|
|
18
|
+
* every count — a consumer can always see WHY a piece counted as used.
|
|
19
|
+
* - Slice membership is slot-granular (all injections sharing a slot share
|
|
20
|
+
* its write) — the signal name says so: `'answer-slice(slot)'`.
|
|
21
|
+
* - `approxTokens*` is a serialized-length estimate (JSON chars ÷ 4), named
|
|
22
|
+
* so nobody mistakes it for a tokenizer count.
|
|
23
|
+
* - The ledger never claims causation. `earnRate` is bookkeeping;
|
|
24
|
+
* ablation (context-bisect) can upgrade individual claims when you pay
|
|
25
|
+
* for it.
|
|
26
|
+
*/
|
|
27
|
+
/** What kind of context piece a row tracks. Skills are injections with
|
|
28
|
+
* flavor 'skill' — split out because their `used` signal differs. */
|
|
29
|
+
export type PieceKind = 'injection' | 'skill' | 'tool';
|
|
30
|
+
/**
|
|
31
|
+
* The per-kind structural definition of "used" — explicit, never blended:
|
|
32
|
+
* - `'tool-called'` — an assistant message actually called the tool.
|
|
33
|
+
* - `'skill-activated'` — the run activated the skill
|
|
34
|
+
* (`activatedInjectionIds`).
|
|
35
|
+
* - `'answer-slice(slot)'` — the injection's SLOT write sits on the final
|
|
36
|
+
* answer's backward dependency slice
|
|
37
|
+
* (slot-granular by construction).
|
|
38
|
+
*/
|
|
39
|
+
export type UsedSignal = 'tool-called' | 'skill-activated' | 'answer-slice(slot)';
|
|
40
|
+
/** One context piece's accumulated bookkeeping across recorded runs. */
|
|
41
|
+
export interface LedgerRow {
|
|
42
|
+
/** Injection/skill id, or tool name. Unique within its kind. */
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly kind: PieceKind;
|
|
45
|
+
/** Offer events — once per iteration the piece was in context, across runs. */
|
|
46
|
+
readonly offered: number;
|
|
47
|
+
/** Serialized-length token ESTIMATE spent on those offers (chars ÷ 4). */
|
|
48
|
+
readonly approxTokensSpent: number;
|
|
49
|
+
/** Structural uses (per-kind definition — see breakdown in usedVia). */
|
|
50
|
+
readonly used: number;
|
|
51
|
+
/** Which signal(s) produced the `used` count, and how many each. */
|
|
52
|
+
readonly usedVia: Readonly<Partial<Record<UsedSignal, number>>>;
|
|
53
|
+
/** Distinct recorded runs in which the piece was offered at least once. */
|
|
54
|
+
readonly runsSeen: number;
|
|
55
|
+
/**
|
|
56
|
+
* Outcome labels of runs where the piece was OFFERED (label → run count).
|
|
57
|
+
* Labels are consumer-supplied via {@link ContextLedger.recordOutcome}
|
|
58
|
+
* (thumbs, eval scores bucketed by the consumer, triage verdicts).
|
|
59
|
+
* Presence-correlation bookkeeping — NOT a causal claim.
|
|
60
|
+
*/
|
|
61
|
+
readonly outcomes: Readonly<Record<string, number>>;
|
|
62
|
+
/** used ÷ offered (0 when never offered). THE headline number. */
|
|
63
|
+
readonly earnRate: number;
|
|
64
|
+
}
|
|
65
|
+
/** What `recordRun` extracted from one run — returned for inspection/tests. */
|
|
66
|
+
export interface RecordedRun {
|
|
67
|
+
/** Handle for {@link ContextLedger.recordOutcome}. */
|
|
68
|
+
readonly runRef: string;
|
|
69
|
+
/** Piece ids offered in this run (kind-qualified internal keys). */
|
|
70
|
+
readonly offeredPieces: readonly string[];
|
|
71
|
+
/** True when the answer slice could be computed (finalContent + reads). */
|
|
72
|
+
readonly sliceAvailable: boolean;
|
|
73
|
+
}
|
|
74
|
+
/** JSON-safe persisted shape (consumer owns storage). */
|
|
75
|
+
export interface LedgerJSON {
|
|
76
|
+
readonly version: 1;
|
|
77
|
+
readonly rows: readonly LedgerRow[];
|
|
78
|
+
readonly runsRecorded: number;
|
|
79
|
+
}
|
|
80
|
+
/** Minimal runner surface the ledger reads (any agentfootprint Runner). */
|
|
81
|
+
export interface RunnerLike {
|
|
82
|
+
getLastSnapshot(): unknown;
|
|
83
|
+
}
|
|
84
|
+
export interface ContextLedger {
|
|
85
|
+
/**
|
|
86
|
+
* Ingest one FINISHED run: walk its commit log for offers (activeInjections
|
|
87
|
+
* / dynamicToolSchemas per iteration), uses (assistant tool calls,
|
|
88
|
+
* activatedInjectionIds, the final answer's dependency slice), and
|
|
89
|
+
* accumulate. Accepts a runner (reads `getLastSnapshot()`) or a snapshot.
|
|
90
|
+
*/
|
|
91
|
+
recordRun(source: RunnerLike | unknown): RecordedRun | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Label a recorded run's outcome ('good'/'bad'/any consumer label —
|
|
94
|
+
* thumbs, bucketed eval score, triage verdict). Defaults to the most
|
|
95
|
+
* recently recorded run. Increments the label for every piece OFFERED in
|
|
96
|
+
* that run.
|
|
97
|
+
*/
|
|
98
|
+
recordOutcome(label: string, runRef?: string): boolean;
|
|
99
|
+
/** All rows, worst earnRate first (the review order that matters). */
|
|
100
|
+
rows(): readonly LedgerRow[];
|
|
101
|
+
/** One row (by kind + id). */
|
|
102
|
+
row(kind: PieceKind, id: string): LedgerRow | undefined;
|
|
103
|
+
/** JSON-safe export (consumer persists). */
|
|
104
|
+
exportJSON(): LedgerJSON;
|
|
105
|
+
/** Merge a previously exported ledger in (counts add). */
|
|
106
|
+
importJSON(json: LedgerJSON): void;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/context-ledger/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;sEACsE;AACtE,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAEvD;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;AAElF,wEAAwE;AACxE,MAAM,WAAW,SAAS;IACxB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0EAA0E;IAC1E,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM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AAU,GAAG,IAAI,CAAC;CACpC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ChoiceAttribution, AttributionUnit, Embedder } from './types.js';
|
|
2
|
+
export interface AttributeChoiceArgs {
|
|
3
|
+
/**
|
|
4
|
+
* The chosen tool being explained. `text` is what gets embedded — pass
|
|
5
|
+
* name + description (the name matters: rules that NAME a tool, e.g.
|
|
6
|
+
* "call report_gap", are its strongest citation).
|
|
7
|
+
*/
|
|
8
|
+
readonly tool: {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly text: string;
|
|
11
|
+
};
|
|
12
|
+
/** The context units to attribute to — the system-prompt rules, the task, … */
|
|
13
|
+
readonly units: readonly AttributionUnit[];
|
|
14
|
+
/** Injected embedder. Wrap in an `EmbeddingCache` so rule texts embed once. */
|
|
15
|
+
readonly embedder: Embedder;
|
|
16
|
+
/** Abort signal threaded to the embedder (network backends). */
|
|
17
|
+
readonly signal?: AbortSignal;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Embed the tool text and every unit once (deduplicated batch), rank the
|
|
21
|
+
* units by cosine to the tool, and report the top unit plus the per-channel
|
|
22
|
+
* share of positive similarity mass.
|
|
23
|
+
*
|
|
24
|
+
* Fail-loud validation: empty units or duplicate unit ids throw — those are
|
|
25
|
+
* caller wiring bugs, not runtime conditions.
|
|
26
|
+
*/
|
|
27
|
+
export declare function attributeChoice(args: AttributeChoiceArgs): Promise<ChoiceAttribution>;
|
|
28
|
+
//# sourceMappingURL=attribute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute.d.ts","sourceRoot":"","sources":["../../../../src/lib/influence-core/attribute.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,QAAQ,EAAa,MAAM,YAAY,CAAC;AAE1F,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAC3C,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,gEAAgE;IAChE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAmC3F"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { AttributionUnit, Embedder, UnitScore } from './types.js';
|
|
2
|
+
export interface ExplainChoiceArgs {
|
|
3
|
+
/**
|
|
4
|
+
* The chosen tool being explained. `text` is what gets embedded — pass
|
|
5
|
+
* name + description (the name matters: a data snippet that NAMES the
|
|
6
|
+
* thing the tool acts on, e.g. "id: d42", is its strongest citation).
|
|
7
|
+
*/
|
|
8
|
+
readonly tool: {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly text: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The context units, tagged by channel — e.g. `'system'` rules,
|
|
14
|
+
* the `'task'`, `'data'` snippets from `snippetUnits`. Channels are
|
|
15
|
+
* free-form strings; the verdict reports whatever labels it is given.
|
|
16
|
+
*/
|
|
17
|
+
readonly units: readonly AttributionUnit[];
|
|
18
|
+
/** Injected embedder. Wrap in an `EmbeddingCache` so rule texts embed once. */
|
|
19
|
+
readonly embedder: Embedder;
|
|
20
|
+
/** Abort signal threaded to the embedder (network backends). */
|
|
21
|
+
readonly signal?: AbortSignal;
|
|
22
|
+
}
|
|
23
|
+
/** One channel's verdict: how much of the pick's positive similarity
|
|
24
|
+
* mass it owns, and the best unit inside it to quote. */
|
|
25
|
+
export interface ChannelVerdict {
|
|
26
|
+
readonly channel: string;
|
|
27
|
+
/**
|
|
28
|
+
* 0..1 share of POSITIVE similarity mass (negatives are clamped out,
|
|
29
|
+
* same as `attributeChoice.byChannel`). Shares across all channels sum
|
|
30
|
+
* to ~1 — or are all 0 when no unit had positive similarity.
|
|
31
|
+
*/
|
|
32
|
+
readonly share: number;
|
|
33
|
+
/** The best-scoring unit IN this channel, text included for quoting.
|
|
34
|
+
* Omitted only when the channel has no units. */
|
|
35
|
+
readonly top?: UnitScore & {
|
|
36
|
+
readonly text: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** The full explanation for one tool pick — `attributeChoice` reshaped
|
|
40
|
+
* for display: text carried through, channels ranked. */
|
|
41
|
+
export interface ChoiceExplanation {
|
|
42
|
+
/** The chosen tool being explained. */
|
|
43
|
+
readonly tool: string;
|
|
44
|
+
/**
|
|
45
|
+
* One verdict per channel present in the units, sorted by share
|
|
46
|
+
* descending (ties keep first-appearance order). Zero-share channels
|
|
47
|
+
* are listed too — absence of pull is part of the verdict.
|
|
48
|
+
*/
|
|
49
|
+
readonly channels: readonly ChannelVerdict[];
|
|
50
|
+
/** The overall best unit — the citation ("picked because …"). */
|
|
51
|
+
readonly top: UnitScore & {
|
|
52
|
+
readonly text: string;
|
|
53
|
+
};
|
|
54
|
+
/** Every unit ranked descending (ties keep input order), text included. */
|
|
55
|
+
readonly units: readonly (UnitScore & {
|
|
56
|
+
readonly text: string;
|
|
57
|
+
})[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Run `attributeChoice` and reshape the result for a UI: join each unit's
|
|
61
|
+
* text back by id, pick the best unit per channel, and rank the channels
|
|
62
|
+
* by their share of positive similarity mass.
|
|
63
|
+
*
|
|
64
|
+
* Fail-loud validation is inherited from `attributeChoice`: empty units
|
|
65
|
+
* or duplicate unit ids throw — caller wiring bugs, not runtime conditions.
|
|
66
|
+
*/
|
|
67
|
+
export declare function explainChoice(args: ExplainChoiceArgs): Promise<ChoiceExplanation>;
|
|
68
|
+
//#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AAI,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;CACpE;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA8CvF"}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* embedding-geometry PROXY — semantic alignment, never model internals
|
|
25
25
|
* and never causal attribution.
|
|
26
26
|
*/
|
|
27
|
-
export type { CandidateScore, ConfidenceStrategy, EmbedArgs, EmbedBatchArgs, Embedder, EvidenceInput, InfluenceScore, InfluenceWeights, MarginCandidate, MarginResult, PairwiseSimilarityResult, RankingConfidence, SignalScores, SimilarityItem, SimilarityPair, } from './types.js';
|
|
27
|
+
export type { CandidateScore, AttributionUnit, ChoiceAttribution, ConfidenceStrategy, EmbedArgs, EmbedBatchArgs, Embedder, EvidenceInput, InfluenceScore, InfluenceWeights, MarginCandidate, MarginResult, PairwiseSimilarityResult, RankingConfidence, SignalScores, SimilarityItem, SimilarityPair, UnitScore, } from './types.js';
|
|
28
28
|
export { DEFAULT_CLEAR_WINNER_MARGIN, DEFAULT_CLEAR_WINNER_RATIO, DEFAULT_INFLUENCE_WEIGHTS, DEFAULT_MARGIN_THRESHOLD, DEFAULT_PERSISTENCE_THRESHOLD, DEFAULT_SHORTLIST_BAND, } from './types.js';
|
|
29
29
|
export { marginStrategy, rankingConfidence, ratioStrategy, type RankingConfidenceOptions, } from './attributability.js';
|
|
30
30
|
export { scoreContrastiveInfluence, type ScoreContrastiveInfluenceArgs } from './contrastive.js';
|
|
@@ -32,4 +32,7 @@ export { contentHash, EmbeddingCache, embeddingCache, type EmbeddingCacheOptions
|
|
|
32
32
|
export { adaptWeights, averageRelevancy, compositeScore, finalAnswerSimilarity, persistence, scoreInfluence, structuralProximity, type InfluenceScorer, type ScoreInfluenceArgs, } from './signals.js';
|
|
33
33
|
export { pairwiseSimilarity, type PairwiseSimilarityArgs } from './similarity.js';
|
|
34
34
|
export { scoreMargin, type ScoreMarginArgs } from './margin.js';
|
|
35
|
+
export { attributeChoice, type AttributeChoiceArgs } from './attribute.js';
|
|
36
|
+
export { explainChoice, type ChannelVerdict, type ChoiceExplanation, type ExplainChoiceArgs, } from './explain.js';
|
|
37
|
+
export { snippetUnits, type SnippetUnitsOptions } from './snippets.js';
|
|
35
38
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/influence-core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,SAAS,EACT,cAAc,EACd,QAAQ,EACR,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/influence-core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,YAAY,EACV,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,cAAc,EACd,QAAQ,EACR,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,KAAK,wBAAwB,GAC9B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,yBAAyB,EAAE,KAAK,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAEjG,OAAO,EACL,WAAW,EACX,cAAc,EACd,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,kBAAkB,EAAE,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EACL,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* snippetUnits — cut a tool result into citable AttributionUnits for the
|
|
3
|
+
* `'data'` channel.
|
|
4
|
+
*
|
|
5
|
+
* `explainChoice` can only credit the data channel with units to point
|
|
6
|
+
* at — a raw tool result (arbitrary JSON or prose) is not citable as one
|
|
7
|
+
* blob. This helper cuts it at the natural citation grain so a pick like
|
|
8
|
+
* "open dress d42" can be attributed to the exact search-result snippet
|
|
9
|
+
* that returned d42:
|
|
10
|
+
*
|
|
11
|
+
* • a string → one unit per sentence/line (non-empty, trimmed),
|
|
12
|
+
* • an array element that is an object → ONE unit summarizing it — its
|
|
13
|
+
* primitive fields joined as `key: value` pairs (a search hit, a row),
|
|
14
|
+
* • any other object → its primitive fields grouped into one unit,
|
|
15
|
+
* then the walk continues into nested objects/arrays,
|
|
16
|
+
* • null/undefined/booleans/empty strings/functions/symbols → skipped.
|
|
17
|
+
*
|
|
18
|
+
* Bounded and total: at most `max` units, each truncated to `maxLength`
|
|
19
|
+
* characters; circular references are guarded (WeakSet) — weird input
|
|
20
|
+
* yields fewer units, never a throw.
|
|
21
|
+
*
|
|
22
|
+
* Pattern: pure synchronous function, zero imports beyond the shared
|
|
23
|
+
* types — `src/lib/influence-core/` leaf. No embedding happens
|
|
24
|
+
* here; the units feed `attributeChoice` / `explainChoice`.
|
|
25
|
+
*
|
|
26
|
+
* Honest claim: this is a CUTTER, not a ranker — it decides what is
|
|
27
|
+
* quotable, not what mattered. Whether a snippet explains the pick is
|
|
28
|
+
* the (proxy) verdict of the similarity scoring downstream.
|
|
29
|
+
*/
|
|
30
|
+
import type { AttributionUnit } from './types.js';
|
|
31
|
+
export interface SnippetUnitsOptions {
|
|
32
|
+
/** Channel tag stamped on every unit. Default `'data'`. */
|
|
33
|
+
readonly channel?: string;
|
|
34
|
+
/** Unit id prefix — ids become `'<prefix>-1'`, `'<prefix>-2'`, … Default `'data'`. */
|
|
35
|
+
readonly idPrefix?: string;
|
|
36
|
+
/** Cap on units returned. Default 12. */
|
|
37
|
+
readonly max?: number;
|
|
38
|
+
/** Cap on characters per unit text (ellipsis included). Default 200. */
|
|
39
|
+
readonly maxLength?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Cut `value` (a tool result — arbitrary JSON value or prose string)
|
|
43
|
+
* into at most `max` citable units for the data channel.
|
|
44
|
+
*/
|
|
45
|
+
export declare function snippetUnits(value: unknown, options?: SnippetUnitsOptions): AttributionUnit[];
|
|
46
|
+
//# sourceMappingURL=snippets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippets.d.ts","sourceRoot":"","sources":["../../../../src/lib/influence-core/snippets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,mBAAmB;IAClC,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,sFAAsF;IACtF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,yCAAyC;IACzC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,mBAAwB,GAAG,eAAe,EAAE,CAcjG"}
|
|
@@ -250,4 +250,54 @@ export interface MarginResult {
|
|
|
250
250
|
readonly proxyDisagreement: boolean;
|
|
251
251
|
};
|
|
252
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* One piece of the context the chooser saw, tagged by which channel it
|
|
255
|
+
* came from. `scoreMargin` asks "which tool best fits ONE context";
|
|
256
|
+
* `attributeChoice` asks the transpose — "which context UNIT best explains
|
|
257
|
+
* ONE chosen tool" — so the unit is the thing being scored here.
|
|
258
|
+
*
|
|
259
|
+
* A channel groups units by origin so the attribution can report where the
|
|
260
|
+
* pull came from: `'system'` (a rule in the system prompt), `'task'` (the
|
|
261
|
+
* user's request), `'result'` (data a prior tool returned), `'history'`
|
|
262
|
+
* (an earlier turn). Channels are free-form strings — the caller decides
|
|
263
|
+
* the taxonomy; the engine only sums by whatever labels it is given.
|
|
264
|
+
*
|
|
265
|
+
* (Named `AttributionUnit`, not `ContextUnit`, to stay distinct from
|
|
266
|
+
* context-bisect's own `ContextUnit`, which is a different subsystem.)
|
|
267
|
+
*/
|
|
268
|
+
export interface AttributionUnit {
|
|
269
|
+
/** Unique id — the citation the attribution points at, e.g. `'rule-1'`. */
|
|
270
|
+
readonly id: string;
|
|
271
|
+
/** Origin group, e.g. `'system' | 'task' | 'result' | 'history'`. */
|
|
272
|
+
readonly channel: string;
|
|
273
|
+
/** The text of the unit (a rule sentence, the user task, …). */
|
|
274
|
+
readonly text: string;
|
|
275
|
+
}
|
|
276
|
+
/** One context unit's proximity to the chosen tool, ranked. */
|
|
277
|
+
export interface UnitScore {
|
|
278
|
+
readonly id: string;
|
|
279
|
+
readonly channel: string;
|
|
280
|
+
/** cosine(embed(tool text), embed(unit.text)). */
|
|
281
|
+
readonly score: number;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Which context best explains one tool choice — the transpose of a
|
|
285
|
+
* `MarginResult`. Same honesty caveat: `score` is embedding geometry
|
|
286
|
+
* between the tool text and each instruction unit, a PROXY for which
|
|
287
|
+
* instruction the pick aligns with, never proof the model used that rule.
|
|
288
|
+
*/
|
|
289
|
+
export interface ChoiceAttribution {
|
|
290
|
+
/** The chosen tool being explained. */
|
|
291
|
+
readonly tool: string;
|
|
292
|
+
/** Every unit scored against the tool, descending (ties keep input order). */
|
|
293
|
+
readonly units: readonly UnitScore[];
|
|
294
|
+
/** The single best-attributing unit — the citation ("picked because …"). */
|
|
295
|
+
readonly top: UnitScore;
|
|
296
|
+
/**
|
|
297
|
+
* Share of total POSITIVE similarity mass per channel, summing to ~1
|
|
298
|
+
* (empty when no unit had positive similarity). A pick dominated by the
|
|
299
|
+
* `system` channel is procedural; one dominated by `task` is topical.
|
|
300
|
+
*/
|
|
301
|
+
readonly byChannel: Readonly<Record<string, number>>;
|
|
302
|
+
}
|
|
253
303
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/influence-core/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAE3F;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0CAA0C;IAC1C,QAAQ,CAAC,EAA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CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;IACrC,4EAA4E;IAC5E,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACtD"}
|
package/dist/types/observe.d.ts
CHANGED
|
@@ -55,4 +55,6 @@ export { typedEmit } from './recorders/core/typedEmit.js';
|
|
|
55
55
|
export * from "./debug.js";
|
|
56
56
|
export { buildChoiceContext, toolChoiceRecorder, type OfferedTool, type ToolChoiceCall, type ToolChoiceRecorderHandle, type ToolChoiceRecorderOptions, type ToolChoiceSkipReason, type ToolChoiceSummary, } from './recorders/observability/ToolChoiceRecorder.js';
|
|
57
57
|
export { routeRecorder, formatRouteHop, type RouteRecorderHandle, type RouteRecorderOptions, type RouteHop, type RouteOutcome, type RouteTrip, type RouteTripKind, } from './recorders/observability/RouteRecorder.js';
|
|
58
|
+
export { contextLedger, ledgerToolGate, ledgerEntryScorer, ledgerGated } from './lib/context-ledger/index.js';
|
|
59
|
+
export type { ContextLedger, LedgerJSON, LedgerPolicy, LedgerRow, PieceKind, RecordedRun, UsedSignal, } from './lib/context-ledger/index.js';
|
|
58
60
|
//# sourceMappingURL=observe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../src/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM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 -69,8 +69,13 @@
|
|
|
69
69
|
*/
|
|
70
70
|
import type { EmitEvent } from 'footprintjs';
|
|
71
71
|
import { type Embedder, type MarginResult } from '../../lib/influence-core/index.js';
|
|
72
|
-
/** Minimal structural slice of footprintjs's
|
|
73
|
-
*
|
|
72
|
+
/** Minimal structural slice of footprintjs's run-boundary events — the
|
|
73
|
+
* `FlowRunEvent` (`onRunStart`/`onRunEnd`/`onRunFailed`) and the
|
|
74
|
+
* control-flow `FlowResumeEvent` (`onResume`). runId is all we read
|
|
75
|
+
* (Convention 4). The scope-channel `ResumeEvent` this recorder also
|
|
76
|
+
* receives (it lands on the scope channel via `onEmit`) carries no
|
|
77
|
+
* `traversalContext`, so `traversalContext?.runId` is `undefined` there
|
|
78
|
+
* and the handler ignores it. */
|
|
74
79
|
interface RunBoundaryEvent {
|
|
75
80
|
readonly traversalContext?: {
|
|
76
81
|
readonly runId?: string;
|
|
@@ -149,6 +154,7 @@ export interface ToolChoiceRecorderHandle {
|
|
|
149
154
|
clear(): void;
|
|
150
155
|
onEmit(event: EmitEvent): void;
|
|
151
156
|
onRunStart(event: RunBoundaryEvent): void;
|
|
157
|
+
onResume(event: RunBoundaryEvent): void;
|
|
152
158
|
onRunEnd(event: RunBoundaryEvent): void;
|
|
153
159
|
onRunFailed(event: RunBoundaryEvent): void;
|
|
154
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolChoiceRecorder.d.ts","sourceRoot":"","sources":["../../../../src/recorders/observability/ToolChoiceRecorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,YAAY,EAClB,MAAM,mCAAmC,CAAC;AAG3C
|
|
1
|
+
{"version":3,"file":"ToolChoiceRecor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