agentfootprint 6.22.0 → 6.24.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.
Files changed (92) hide show
  1. package/AGENTS.md +17 -0
  2. package/CLAUDE.md +17 -0
  3. package/README.md +58 -0
  4. package/dist/core/Agent.js +109 -18
  5. package/dist/core/Agent.js.map +1 -1
  6. package/dist/core/agent/stages/toolCalls.js +19 -4
  7. package/dist/core/agent/stages/toolCalls.js.map +1 -1
  8. package/dist/esm/core/Agent.js +109 -18
  9. package/dist/esm/core/Agent.js.map +1 -1
  10. package/dist/esm/core/agent/stages/toolCalls.js +19 -4
  11. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/lib/influence-core/cache.js +149 -0
  14. package/dist/esm/lib/influence-core/cache.js.map +1 -0
  15. package/dist/esm/lib/influence-core/index.js +32 -0
  16. package/dist/esm/lib/influence-core/index.js.map +1 -0
  17. package/dist/esm/lib/influence-core/margin.js +110 -0
  18. package/dist/esm/lib/influence-core/margin.js.map +1 -0
  19. package/dist/esm/lib/influence-core/signals.js +232 -0
  20. package/dist/esm/lib/influence-core/signals.js.map +1 -0
  21. package/dist/esm/lib/influence-core/similarity.js +79 -0
  22. package/dist/esm/lib/influence-core/similarity.js.map +1 -0
  23. package/dist/esm/lib/influence-core/types.js +35 -0
  24. package/dist/esm/lib/influence-core/types.js.map +1 -0
  25. package/dist/esm/lib/trace-toolpack/bounded.js +76 -0
  26. package/dist/esm/lib/trace-toolpack/bounded.js.map +1 -0
  27. package/dist/esm/lib/trace-toolpack/index.js +10 -0
  28. package/dist/esm/lib/trace-toolpack/index.js.map +1 -0
  29. package/dist/esm/lib/trace-toolpack/traceToolpack.js +699 -0
  30. package/dist/esm/lib/trace-toolpack/traceToolpack.js.map +1 -0
  31. package/dist/esm/lib/trace-toolpack/types.js +24 -0
  32. package/dist/esm/lib/trace-toolpack/types.js.map +1 -0
  33. package/dist/esm/observe.js +12 -0
  34. package/dist/esm/observe.js.map +1 -1
  35. package/dist/esm/recorders/core/typedEmit.js +26 -0
  36. package/dist/esm/recorders/core/typedEmit.js.map +1 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/lib/influence-core/cache.js +155 -0
  39. package/dist/lib/influence-core/cache.js.map +1 -0
  40. package/dist/lib/influence-core/index.js +50 -0
  41. package/dist/lib/influence-core/index.js.map +1 -0
  42. package/dist/lib/influence-core/margin.js +114 -0
  43. package/dist/lib/influence-core/margin.js.map +1 -0
  44. package/dist/lib/influence-core/signals.js +242 -0
  45. package/dist/lib/influence-core/signals.js.map +1 -0
  46. package/dist/lib/influence-core/similarity.js +83 -0
  47. package/dist/lib/influence-core/similarity.js.map +1 -0
  48. package/dist/lib/influence-core/types.js +38 -0
  49. package/dist/lib/influence-core/types.js.map +1 -0
  50. package/dist/lib/trace-toolpack/bounded.js +86 -0
  51. package/dist/lib/trace-toolpack/bounded.js.map +1 -0
  52. package/dist/lib/trace-toolpack/index.js +16 -0
  53. package/dist/lib/trace-toolpack/index.js.map +1 -0
  54. package/dist/lib/trace-toolpack/traceToolpack.js +704 -0
  55. package/dist/lib/trace-toolpack/traceToolpack.js.map +1 -0
  56. package/dist/lib/trace-toolpack/types.js +28 -0
  57. package/dist/lib/trace-toolpack/types.js.map +1 -0
  58. package/dist/observe.js +31 -1
  59. package/dist/observe.js.map +1 -1
  60. package/dist/recorders/core/typedEmit.js +26 -0
  61. package/dist/recorders/core/typedEmit.js.map +1 -1
  62. package/dist/types/core/Agent.d.ts +40 -3
  63. package/dist/types/core/Agent.d.ts.map +1 -1
  64. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
  65. package/dist/types/core/agent/types.d.ts +61 -1
  66. package/dist/types/core/agent/types.d.ts.map +1 -1
  67. package/dist/types/index.d.ts +2 -1
  68. package/dist/types/index.d.ts.map +1 -1
  69. package/dist/types/lib/influence-core/cache.d.ts +95 -0
  70. package/dist/types/lib/influence-core/cache.d.ts.map +1 -0
  71. package/dist/types/lib/influence-core/index.d.ts +33 -0
  72. package/dist/types/lib/influence-core/index.d.ts.map +1 -0
  73. package/dist/types/lib/influence-core/margin.d.ts +34 -0
  74. package/dist/types/lib/influence-core/margin.d.ts.map +1 -0
  75. package/dist/types/lib/influence-core/signals.d.ts +104 -0
  76. package/dist/types/lib/influence-core/signals.d.ts.map +1 -0
  77. package/dist/types/lib/influence-core/similarity.d.ts +26 -0
  78. package/dist/types/lib/influence-core/similarity.d.ts.map +1 -0
  79. package/dist/types/lib/influence-core/types.d.ts +158 -0
  80. package/dist/types/lib/influence-core/types.d.ts.map +1 -0
  81. package/dist/types/lib/trace-toolpack/bounded.d.ts +48 -0
  82. package/dist/types/lib/trace-toolpack/bounded.d.ts.map +1 -0
  83. package/dist/types/lib/trace-toolpack/index.d.ts +10 -0
  84. package/dist/types/lib/trace-toolpack/index.d.ts.map +1 -0
  85. package/dist/types/lib/trace-toolpack/traceToolpack.d.ts +70 -0
  86. package/dist/types/lib/trace-toolpack/traceToolpack.d.ts.map +1 -0
  87. package/dist/types/lib/trace-toolpack/types.d.ts +60 -0
  88. package/dist/types/lib/trace-toolpack/types.d.ts.map +1 -0
  89. package/dist/types/observe.d.ts +2 -0
  90. package/dist/types/observe.d.ts.map +1 -1
  91. package/dist/types/recorders/core/typedEmit.d.ts.map +1 -1
  92. package/package.json +3 -3
@@ -0,0 +1,34 @@
1
+ import type { Embedder, MarginCandidate, MarginResult } from './types.js';
2
+ export interface ScoreMarginArgs {
3
+ /** The offered candidates (e.g. the tool catalog on `llm_start`). */
4
+ readonly candidates: readonly MarginCandidate[];
5
+ /** The choice context — the text the chooser ranked against. */
6
+ readonly contextText: string;
7
+ /** Names of the chosen candidate(s). Must exist in `candidates`. */
8
+ readonly chosen: readonly string[];
9
+ /**
10
+ * Injected embedder. Wrap in an `EmbeddingCache` so descriptions
11
+ * embed once across calls (RFC-002 §3 — the same cache the catalog
12
+ * lint already filled).
13
+ */
14
+ readonly embedder: Embedder;
15
+ /** Margins below this flag `narrow`. Default 0.05 (RFC-002 §4). */
16
+ readonly marginThreshold?: number;
17
+ /** Abort signal threaded to the embedder (network backends). */
18
+ readonly signal?: AbortSignal;
19
+ }
20
+ /**
21
+ * Rank candidates by cosine similarity to the choice context and
22
+ * measure how decisively the chosen one(s) won.
23
+ *
24
+ * Returns ranked `scores` (descending; ties keep candidate input
25
+ * order), the `topScored` name, the `margin` (undefined when every
26
+ * candidate was chosen — no competition to measure; `narrow` is false
27
+ * in that case), and the two flags.
28
+ *
29
+ * Fail-loud validation: empty candidates/chosen, duplicate candidate
30
+ * names, or a chosen name missing from the candidates throw — those
31
+ * are wiring bugs in the caller, not runtime conditions.
32
+ */
33
+ export declare function scoreMargin(args: ScoreMarginArgs): Promise<MarginResult>;
34
+ //# sourceMappingURL=margin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"margin.d.ts","sourceRoot":"","sources":["../../../../src/lib/influence-core/margin.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAkB,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1F,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,QAAQ,CAAC,UAAU,EAAE,SAAS,eAAe,EAAE,CAAC;IAChD,gEAAgE;IAChE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,gEAAgE;IAChE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC,CA6C9E"}
@@ -0,0 +1,104 @@
1
+ import type { Embedder, EvidenceInput, InfluenceScore, InfluenceWeights, SignalScores } from './types.js';
2
+ /**
3
+ * FA — Final Answer Similarity (paper Eq. 1).
4
+ *
5
+ * `FA(d) = sim(e_d, e_f)` — cosine between the evidence embedding and
6
+ * the final-answer embedding. The strongest prior: verbatim or
7
+ * paraphrased reuse of a tool result scores high. Proxy: semantic
8
+ * overlap, not provenance.
9
+ */
10
+ export declare function finalAnswerSimilarity(evidenceVec: readonly number[], finalAnswerVec: readonly number[]): number;
11
+ /**
12
+ * AVG — Average Relevancy (paper Eq. 2).
13
+ *
14
+ * Mean cosine between the evidence and each LLM reasoning ancestor;
15
+ * 0 when there are no ancestors (structurally zero — see
16
+ * `adaptWeights`). Proxy: consistent semantic closeness across the
17
+ * chain, not actual consultation.
18
+ */
19
+ export declare function averageRelevancy(evidenceVec: readonly number[], ancestorVecs: ReadonlyArray<readonly number[]>): number;
20
+ /**
21
+ * PERSIST — Persistence (paper Eq. 3).
22
+ *
23
+ * Fraction of ancestors whose similarity to the evidence EXCEEDS the
24
+ * threshold T (strict `>`, default 0.30); 0 when there are no
25
+ * ancestors. Unlike AVG it measures BREADTH: referenced in 4 of 5
26
+ * steps (0.8) beats referenced intensely in 1. Proxy: similarity
27
+ * above a tunable bar, not counted citations.
28
+ */
29
+ export declare function persistence(evidenceVec: readonly number[], ancestorVecs: ReadonlyArray<readonly number[]>, threshold?: number): number;
30
+ /**
31
+ * DEPTH — Structural Proximity (paper Eq. 4).
32
+ *
33
+ * `DEPTH(d) = 1 / (1 + n)` where n counts LLM reasoning ancestors
34
+ * ONLY (not pipeline plumbing — callers decide what counts as an
35
+ * ancestor when building `EvidenceInput.ancestorTexts`). Direct
36
+ * evidence with no intermediaries gets exactly 1.0. The only
37
+ * content-blind signal: pure trace structure.
38
+ */
39
+ export declare function structuralProximity(ancestorCount: number): number;
40
+ /**
41
+ * Adaptive weight redistribution (paper Eq. 6, §5.3).
42
+ *
43
+ * When an item has NO LLM ancestors, AVG and PERSIST are structurally
44
+ * zero — not because the evidence was uninfluential, but because there
45
+ * is nothing to measure against. Without adaptation its score is
46
+ * capped at α+δ (≈0.50 under defaults). Eq. 6 moves the β+γ mass onto
47
+ * FA and DEPTH preserving their ratio:
48
+ *
49
+ * α′ = α + (β+γ)·α/(α+δ), δ′ = δ + (β+γ)·δ/(α+δ), β′ = γ′ = 0
50
+ *
51
+ * Defaults → α′=0.80, δ′=0.20 (the 4:1 FA:DEPTH ratio kept).
52
+ * Per-evidence-item: in a multi-tool pipeline some items adapt while
53
+ * others keep standard weights; `adapted` says which (surface it — the
54
+ * paper's UI marks adapted items).
55
+ *
56
+ * Degenerate guard: if α+δ = 0 there is no defined ratio to preserve —
57
+ * weights return unchanged with `adapted: false`, and the composite is
58
+ * honestly 0 for a no-ancestor item.
59
+ */
60
+ export declare function adaptWeights(weights: InfluenceWeights, ancestorCount: number): {
61
+ weights: InfluenceWeights;
62
+ adapted: boolean;
63
+ };
64
+ /**
65
+ * Composite score S(d) (paper Eq. 5).
66
+ *
67
+ * `S = α·FA + β·AVG + γ·PERSIST + δ·DEPTH` under the given weights —
68
+ * pass the EFFECTIVE weights from `adaptWeights` for no-ancestor
69
+ * items. With weights summing to 1, S ∈ [−(α+β), 1] (FA/AVG are
70
+ * cosines and may go negative; PERSIST/DEPTH are non-negative).
71
+ */
72
+ export declare function compositeScore(signals: SignalScores, weights: InfluenceWeights): number;
73
+ export interface ScoreInfluenceArgs {
74
+ /** Evidence items (tool results / context sources) with ancestors. */
75
+ readonly evidence: readonly EvidenceInput[];
76
+ /** The final answer text the evidence is scored against. */
77
+ readonly finalAnswerText: string;
78
+ /**
79
+ * Injected embedder. Wrap in an `EmbeddingCache` to share embeddings
80
+ * with the catalog lint / margin scorer (RFC-002 §3 — one cache
81
+ * serves all three consumers).
82
+ */
83
+ readonly embedder: Embedder;
84
+ /** Composite weights. Default: paper priors 0.40/0.30/0.20/0.10. */
85
+ readonly weights?: InfluenceWeights;
86
+ /** PERSIST threshold T. Default 0.30. */
87
+ readonly persistenceThreshold?: number;
88
+ /** Abort signal threaded to the embedder (network backends). */
89
+ readonly signal?: AbortSignal;
90
+ }
91
+ /**
92
+ * Score every evidence item on the four FDL signals and rank by
93
+ * composite, descending (paper pipeline stages 4–6 in one call:
94
+ * embed → score → rank). Ties keep input order (stable sort).
95
+ *
96
+ * Deterministic for a deterministic embedder: same inputs → same
97
+ * scores. All texts are embedded in ONE deduplicated batch — with an
98
+ * `EmbeddingCache` injected, repeat calls embed nothing.
99
+ *
100
+ * Honest claim: ranked semantic-alignment proxies. NOT causal
101
+ * attribution — see module docs.
102
+ */
103
+ export declare function scoreInfluence(args: ScoreInfluenceArgs): Promise<InfluenceScore[]>;
104
+ //# sourceMappingURL=signals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../../../src/lib/influence-core/signals.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACb,MAAM,YAAY,CAAC;AAGpB;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,cAAc,EAAE,SAAS,MAAM,EAAE,GAChC,MAAM,CAER;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,YAAY,EAAE,aAAa,CAAC,SAAS,MAAM,EAAE,CAAC,GAC7C,MAAM,CAQR;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,YAAY,EAAE,aAAa,CAAC,SAAS,MAAM,EAAE,CAAC,EAC9C,SAAS,GAAE,MAAsC,GAChD,MAAM,CAQR;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAOjE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,MAAM,GACpB;IAAE,OAAO,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAcjD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAOvF;AAED,MAAM,WAAW,kBAAkB;IACjC,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IAC5C,4DAA4D;IAC5D,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,oEAAoE;IACpE,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC,yCAAyC;IACzC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC,gEAAgE;IAChE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAuCxF"}
@@ -0,0 +1,26 @@
1
+ import type { Embedder, PairwiseSimilarityResult, SimilarityItem } from './types.js';
2
+ export interface PairwiseSimilarityArgs {
3
+ /** The texts to compare — e.g. `{ id: toolName, text: description }`. */
4
+ readonly items: readonly SimilarityItem[];
5
+ /**
6
+ * Injected embedder. Wrap in an `EmbeddingCache` so catalog
7
+ * descriptions embed once across lint runs (RFC-002 §3).
8
+ */
9
+ readonly embedder: Embedder;
10
+ /** Abort signal threaded to the embedder (network backends). */
11
+ readonly signal?: AbortSignal;
12
+ }
13
+ /**
14
+ * Embed every item once (deduplicated batch) and compute the full
15
+ * cosine matrix plus ranked upper-triangle pairs (descending; ties
16
+ * keep input pair order).
17
+ *
18
+ * Invariants (pinned by property tests):
19
+ * - `matrix[i][j] === matrix[j][i]` — computed once, mirrored.
20
+ * - `matrix[i][i] === 1` EXACTLY — set by definition, so
21
+ * self-similarity is an invariant rather than a float artifact
22
+ * (and duplicate texts at different ids still compare via cosine).
23
+ * - N items → N·(N−1)/2 pairs.
24
+ */
25
+ export declare function pairwiseSimilarity(args: PairwiseSimilarityArgs): Promise<PairwiseSimilarityResult>;
26
+ //# sourceMappingURL=similarity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"similarity.d.ts","sourceRoot":"","sources":["../../../../src/lib/influence-core/similarity.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,QAAQ,EACR,wBAAwB,EACxB,cAAc,EAEf,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,sBAAsB;IACrC,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IAC1C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,gEAAgE;IAChE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,wBAAwB,CAAC,CAoCnC"}
@@ -0,0 +1,158 @@
1
+ /**
2
+ * influence-core types — the ONE embedding-based scoring contract.
3
+ *
4
+ * Pattern: Strategy seam (plug-and-play meta-pattern) — the frame and
5
+ * rule engine are the library's; the `Embedder` is consumer-
6
+ * injected, exactly like NarrativeFormatter / reliability /
7
+ * permission / commentary strategies.
8
+ * Role: `src/lib/` leaf module. Shared by the FDL paper pipeline
9
+ * (Visible Reasoning, Eq. 1–6), RFC-002's tool-catalog lint +
10
+ * margin recorder (C1/C4/C5), and RFC-003 Part B's LLM-edge
11
+ * weigher (D7). Extracted as RFC-003 block D6 so all three
12
+ * consumers share one scoring engine and one embedding cache.
13
+ *
14
+ * ## Honest claim (RFC-002 §2, the FDL discipline)
15
+ *
16
+ * Every score produced under these types is a PROXY computed from
17
+ * embedding geometry — cosine similarity over consumer-injected
18
+ * embeddings. None of it reads model internals. Scores mean "high
19
+ * semantic alignment", never "the model chose/answered BECAUSE".
20
+ * Scores are not additive across items and are not causal attribution
21
+ * — counterfactual ablation (RFC-003 stage 4) is where causal claims
22
+ * live.
23
+ */
24
+ export type { Embedder, EmbedArgs, EmbedBatchArgs } from '../../memory/embedding/types.js';
25
+ /**
26
+ * Weights for the four-signal composite (paper Eq. 5).
27
+ *
28
+ * Configurable PRIORS, not learned parameters (paper §8). Defaults
29
+ * encode: direct semantic similarity (fa) strongest, then consistency
30
+ * across reasoning (avg), breadth of reference (persist), structural
31
+ * proximity (depth).
32
+ */
33
+ export interface InfluenceWeights {
34
+ /** α — Final Answer Similarity weight. */
35
+ readonly fa: number;
36
+ /** β — Average Relevancy weight. */
37
+ readonly avg: number;
38
+ /** γ — Persistence weight. */
39
+ readonly persist: number;
40
+ /** δ — Structural Proximity weight. */
41
+ readonly depth: number;
42
+ }
43
+ /** Paper defaults: α=0.40, β=0.30, γ=0.20, δ=0.10 (sum to 1.0). */
44
+ export declare const DEFAULT_INFLUENCE_WEIGHTS: InfluenceWeights;
45
+ /** Paper default for the PERSIST threshold T (Eq. 3). */
46
+ export declare const DEFAULT_PERSISTENCE_THRESHOLD = 0.3;
47
+ /** RFC-002 §4 default: margins below this flag the choice as `narrow`. */
48
+ export declare const DEFAULT_MARGIN_THRESHOLD = 0.05;
49
+ /** The four signal values for one evidence item (paper Eq. 1–4). */
50
+ export interface SignalScores {
51
+ /** FA — cosine(evidence, finalAnswer). Range [-1, 1]. */
52
+ readonly fa: number;
53
+ /** AVG — mean cosine(evidence, ancestor_i); 0 when no ancestors. */
54
+ readonly avg: number;
55
+ /** PERSIST — fraction of ancestors with similarity > T; 0 when none. */
56
+ readonly persist: number;
57
+ /** DEPTH — 1 / (1 + ancestorCount). Range (0, 1]. */
58
+ readonly depth: number;
59
+ }
60
+ /** One evidence item to score: a tool result (or any context source)
61
+ * plus the texts of the LLM reasoning steps that referenced it. */
62
+ export interface EvidenceInput {
63
+ /** Stable identifier — e.g. a runtimeStageId or tool-call id. */
64
+ readonly id: string;
65
+ /** The evidence text (tool result content). */
66
+ readonly text: string;
67
+ /**
68
+ * Texts of the item's LLM reasoning ANCESTORS — only stages with
69
+ * model text output, not pipeline plumbing (paper §5.1, DEPTH).
70
+ * Empty array = direct evidence with no intermediaries.
71
+ */
72
+ readonly ancestorTexts: readonly string[];
73
+ }
74
+ /** Scored evidence item — the per-item output of `scoreInfluence`. */
75
+ export interface InfluenceScore {
76
+ readonly id: string;
77
+ /** The four raw signals (proxies — see module honest claim). */
78
+ readonly signals: SignalScores;
79
+ /**
80
+ * The EFFECTIVE weights used for this item — equals the configured
81
+ * weights normally; the Eq. 6 redistribution when `adapted` is true.
82
+ */
83
+ readonly weights: InfluenceWeights;
84
+ /**
85
+ * True when adaptive weight redistribution (paper Eq. 6) applied —
86
+ * the item had no LLM ancestors, so AVG/PERSIST were structurally
87
+ * zero and their weight mass moved onto FA/DEPTH. Per-item: a
88
+ * multi-tool pipeline may mix adapted and standard items.
89
+ */
90
+ readonly adapted: boolean;
91
+ /** Composite S(d) (Eq. 5) under the effective weights. */
92
+ readonly score: number;
93
+ }
94
+ /** A text item for pairwise comparison (e.g. a tool description). */
95
+ export interface SimilarityItem {
96
+ /** Stable identifier — e.g. the tool name. Must be unique. */
97
+ readonly id: string;
98
+ readonly text: string;
99
+ }
100
+ /** One ranked pair from `pairwiseSimilarity`. */
101
+ export interface SimilarityPair {
102
+ /** id of the first item (lower input index). */
103
+ readonly a: string;
104
+ /** id of the second item (higher input index). */
105
+ readonly b: string;
106
+ /** cosine(embed(a.text), embed(b.text)). */
107
+ readonly similarity: number;
108
+ }
109
+ export interface PairwiseSimilarityResult {
110
+ /** Item ids in input order — the matrix axes. */
111
+ readonly ids: readonly string[];
112
+ /**
113
+ * Full similarity matrix, `matrix[i][j] = cosine(item_i, item_j)`.
114
+ * Symmetric by construction; the diagonal is EXACTLY 1 by definition
115
+ * (self-similarity is an invariant, not a float approximation).
116
+ */
117
+ readonly matrix: ReadonlyArray<readonly number[]>;
118
+ /** Upper-triangle pairs ranked by similarity, descending. */
119
+ readonly pairs: readonly SimilarityPair[];
120
+ }
121
+ /** A candidate in a choice competition (e.g. an offered tool). */
122
+ export interface MarginCandidate {
123
+ /** Unique name — the identifier the chooser used. */
124
+ readonly name: string;
125
+ /** The text the chooser saw (the tool description). */
126
+ readonly text: string;
127
+ }
128
+ /** One candidate's proximity to the choice context, ranked. */
129
+ export interface CandidateScore {
130
+ readonly name: string;
131
+ /** cosine(embed(contextText), embed(candidate.text)). */
132
+ readonly score: number;
133
+ }
134
+ export interface MarginResult {
135
+ /** All candidates ranked by score, descending. */
136
+ readonly scores: readonly CandidateScore[];
137
+ /** The chosen candidate names, echoed from the input. */
138
+ readonly chosen: readonly string[];
139
+ /** Name of the highest-scoring candidate (by the proxy). */
140
+ readonly topScored: string;
141
+ /**
142
+ * score(best chosen) − score(best non-chosen). Small margin =
143
+ * fragile choice. `undefined` when every candidate was chosen
144
+ * (no competition to measure).
145
+ */
146
+ readonly margin: number | undefined;
147
+ readonly flags: {
148
+ /** margin < marginThreshold — the choice was a close call. */
149
+ readonly narrow: boolean;
150
+ /**
151
+ * The top-scored candidate was NOT among the chosen. Either a
152
+ * proxy miss or a genuinely surprising choice — both are exactly
153
+ * what a debugger wants surfaced (RFC-002 §4).
154
+ */
155
+ readonly proxyDisagreement: boolean;
156
+ };
157
+ }
158
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,E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M,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE;QACd,8DAA8D;QAC9D,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;QACzB;;;;WAIG;QACH,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;KACrC,CAAC;CACH"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Bounded serialization helpers for the trace toolpack.
3
+ *
4
+ * Pattern: pure functions — no state, no events.
5
+ * Role: The token-economics layer. EVERY value the toolpack serves goes
6
+ * through these: previews are capped, truncation is EXPLICIT
7
+ * (never silent), and nested-path keys round-trip between the
8
+ * engine's DELIM encoding and LLM-friendly dot notation.
9
+ */
10
+ /**
11
+ * footprintjs's canonical nested-path delimiter (ASCII unit separator,
12
+ * `src/lib/memory/utils.ts`). Internal to the engine — the toolpack
13
+ * translates it to/from dot notation so the LLM never sees a control char.
14
+ */
15
+ export declare const FP_PATH_DELIM = "\u001F";
16
+ /** Engine path → LLM-friendly dotted display form. */
17
+ export declare function displayKey(path: string): string;
18
+ /**
19
+ * LLM-supplied key → engine path. Exact keys pass through; a dotted key
20
+ * that doesn't exist verbatim but matches a known DELIM-joined path is
21
+ * translated back. `knownPaths` is the set of every path seen in the
22
+ * commit log's trace entries.
23
+ */
24
+ export declare function normalizeKey(key: string, knownPaths: ReadonlySet<string>): string;
25
+ /** Replace every DELIM in an already-formatted text block with '.' for display. */
26
+ export declare function displayText(text: string): string;
27
+ /**
28
+ * Serialize a value to compact JSON, total-function style: cycles, BigInt
29
+ * and other non-JSON values degrade to a tagged placeholder instead of
30
+ * throwing — a debugger tool must never crash on the evidence it serves.
31
+ */
32
+ export declare function safeStringify(value: unknown): string;
33
+ /** A bounded preview of a value: capped text + the TRUE total size, never silent. */
34
+ export interface BoundedPreview {
35
+ /** The (possibly truncated) serialized text. */
36
+ readonly text: string;
37
+ /** Full serialized length in chars — so the consumer knows what it's NOT seeing. */
38
+ readonly totalChars: number;
39
+ /** True when `text` is shorter than the full serialization. */
40
+ readonly truncated: boolean;
41
+ }
42
+ /** Serialize + cap at `maxChars`. Truncation is reported, never silent. */
43
+ export declare function boundedPreview(value: unknown, maxChars: number): BoundedPreview;
44
+ /** Render a preview with its honesty suffix when truncated. */
45
+ export declare function renderPreview(preview: BoundedPreview, fetchHint?: string): string;
46
+ /** Clamp an LLM-supplied numeric param into [min, hardCap], with a default. */
47
+ export declare function clampParam(requested: number | undefined, fallback: number, min: number, hardCap: number): number;
48
+ //# sourceMappingURL=bounded.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded.d.ts","sourceRoot":"","sources":["../../../../src/lib/trace-toolpack/bounded.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;GAIG;AACH,eAAO,MAAM,aAAa,WAAW,CAAC;AAEtC,sDAAsD;AACtD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAOjF;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQpD;AAED,qFAAqF;AACrF,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED,2EAA2E;AAC3E,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAM/E;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAIjF;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CACxB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GACd,MAAM,CAGR"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * trace-toolpack — RFC-003 Part C: the introspection toolpack.
3
+ *
4
+ * footprintjs trace evidence exposed as TOOLS an LLM calls: a debugging
5
+ * model navigates a COMPLETED run's evidence by runtimeStageIds instead of
6
+ * reading dumps. Bounded, honest (⚠ markers), redaction-respecting.
7
+ */
8
+ export { callTraceTool, traceToolpack } from './traceToolpack.js';
9
+ export { TOOLPACK_HARD_CAPS, type TraceToolpackArtifacts, type TraceToolpackOptions, } from './types.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/trace-toolpack/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EACL,kBAAkB,EAClB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,GAC1B,MAAM,YAAY,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * traceToolpack — footprintjs trace evidence exposed as TOOLS an LLM calls
3
+ * (RFC-003 Part C: the introspection toolpack).
4
+ *
5
+ * "The framework's internal tool for itself": after a run completes, a
6
+ * debugging LLM (a cheap model in a SEPARATE session) navigates the run's
7
+ * evidence by ids instead of reading dumps — the same just-in-time,
8
+ * token-efficient loading pattern as `read_skill`. Feed the slice, not the
9
+ * trace; the LLM ranks by navigating, so no embedder is needed.
10
+ *
11
+ * Pattern: Factory over frozen artifacts. `traceToolpack(artifacts)` returns
12
+ * plain `Tool[]` — mount them on any Agent, or drive them scripted
13
+ * via `callTraceTool` (the offline auditor pattern, like
14
+ * examples/features/20). Nothing re-runs; every tool is a bounded
15
+ * read-only VIEW over a COMPLETED run's snapshot + commit log.
16
+ *
17
+ * The toolpack's three contracts (B13 posture):
18
+ *
19
+ * 1. BOUNDED BY DEFAULT — every output is capped (previews, slice
20
+ * depth/nodes, value chars, narrative lines). Per-call params raise
21
+ * the budget only up to hard caps the LLM cannot exceed.
22
+ * 2. HONEST — truncation and incompleteness are ALWAYS marked (⚠), never
23
+ * silent: truncated slices, untracked sources (args/env/silent reads),
24
+ * missing read tracking, missing control-dependence lookup, values the
25
+ * commit log cannot see (pre-run state, closures).
26
+ * 3. REDACTION-RESPECTING — the commit log already carries redacted
27
+ * payloads (footprintjs scrubs at commit time); the toolpack passes
28
+ * placeholders through verbatim and flags redacted keys. It never
29
+ * reconstructs around a redaction.
30
+ *
31
+ * Why ids: every view names steps by `runtimeStageId`
32
+ * (`stageId#executionIndex`) — the universal key linking the commit log,
33
+ * the execution tree, and recorder events. The LLM drills like a debugger:
34
+ * overview → slice → node → value, paying only for what it opens.
35
+ */
36
+ import { type Tool } from '../../core/tools.js';
37
+ import { type TraceToolpackArtifacts, type TraceToolpackOptions } from './types.js';
38
+ /**
39
+ * Build the introspection toolpack over a COMPLETED run's artifacts.
40
+ *
41
+ * Returns plain `Tool[]`:
42
+ *
43
+ * | Tool | Question it answers |
44
+ * |------------------|-----------------------------------------------------------|
45
+ * | `run_overview` | What happened, broadly? (the entry point) |
46
+ * | `trace_node` | What did step X read/write, and where did its inputs come from? |
47
+ * | `trace_slice` | Which chain of steps produced the data at X? (causal slice) |
48
+ * | `who_wrote` | Which step last wrote key K? |
49
+ * | `get_value` | The full value of K as of step X (capped, truncation-marked) |
50
+ * | `read_narrative` | The human-readable story, paginated (only when narrative provided) |
51
+ *
52
+ * Mount on an Agent (`Agent.create({...}).tool(...tools)`) or drive scripted
53
+ * via {@link callTraceTool}. The tools NEVER throw on bad ids/keys — they
54
+ * return corrective, model-visible messages (the #9 philosophy), and their
55
+ * strict input schemas give Agent-dispatched calls free arg validation.
56
+ *
57
+ * Security note (B13 posture): trace content can carry adversarial text from
58
+ * the original run (tool results, user input). Serve these tools to a
59
+ * SEPARATE debugging session over completed runs — not to the production
60
+ * agent mid-run — and treat tool outputs as data, not instructions.
61
+ */
62
+ export declare function traceToolpack(artifacts: TraceToolpackArtifacts, options?: TraceToolpackOptions): Tool[];
63
+ /**
64
+ * Invoke a toolpack tool OUTSIDE an Agent (scripted debug sessions, tests,
65
+ * offline auditors). Mirrors the Agent's #9 boundary: args are validated
66
+ * against the tool's inputSchema first, and an invalid call returns the same
67
+ * model-visible correction string instead of executing.
68
+ */
69
+ export declare function callTraceTool(tools: readonly Tool[], name: string, args?: Record<string, unknown>): Promise<string>;
70
+ //# sourceMappingURL=traceToolpack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traceToolpack.d.ts","sourceRoot":"","sources":["../../../../src/lib/trace-toolpack/traceToolpack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAMH,OAAO,EAAc,KAAK,IAAI,EAA6B,MAAM,qBAAqB,CAAC;AAWvF,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AAiNpB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,sBAAsB,EACjC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,IAAI,EAAE,CAeR;AA8jBD;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACjC,OAAO,CAAC,MAAM,CAAC,CASjB"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Trace toolpack types — RFC-003 Part C (the introspection toolpack).
3
+ *
4
+ * Pattern: artifact bag — everything a debugging LLM needs to navigate a
5
+ * COMPLETED run, captured once and handed to `traceToolpack()`.
6
+ * Role: Input contract. The toolpack never re-runs anything; it serves
7
+ * bounded, id-addressed views over these frozen artifacts.
8
+ */
9
+ import type { RuntimeSnapshot } from 'footprintjs';
10
+ import type { ControlDepLookup } from 'footprintjs/trace';
11
+ /**
12
+ * The frozen evidence of one completed run.
13
+ *
14
+ * - `snapshot` — `executor.getSnapshot()`. Carries the commit log (what every
15
+ * step wrote, with verbs + redaction + `untrackedSources` honesty markers),
16
+ * the execution tree (per-step name/description/reads/errors), the final
17
+ * shared state, and the `commitValues` mode discriminant.
18
+ * - `controlDeps` — OPTIONAL `controlDepRecorder().asLookup()` from the run.
19
+ * With it, causal slices include `[control: <rule label>]` edges to the
20
+ * decider that routed execution. Without it, slices say so explicitly.
21
+ * - `narrative` — OPTIONAL narrative lines (e.g. rendered from
22
+ * `executor.getNarrativeEntries()`). When present, a `read_narrative` tool
23
+ * is added for bounded, paginated access to the human-readable story.
24
+ */
25
+ export interface TraceToolpackArtifacts {
26
+ readonly snapshot: RuntimeSnapshot;
27
+ readonly controlDeps?: ControlDepLookup;
28
+ readonly narrative?: readonly string[];
29
+ }
30
+ /**
31
+ * Bounding dials. Every output is bounded BY DEFAULT — these set the
32
+ * defaults; per-call params (`maxDepth`, `maxNodes`, `maxChars`, `maxLines`)
33
+ * let the LLM ask for more up to hard caps the consumer cannot exceed.
34
+ */
35
+ export interface TraceToolpackOptions {
36
+ /** Value-preview length in chars (trace_node / who_wrote). Default 160. */
37
+ readonly previewChars?: number;
38
+ /** Default causal-slice depth for trace_slice. Default 6 (hard cap 20). */
39
+ readonly sliceMaxDepth?: number;
40
+ /** Default causal-slice node budget for trace_slice. Default 25 (hard cap 100). */
41
+ readonly sliceMaxNodes?: number;
42
+ /** Default char budget for get_value. Default 2000 (hard cap 8000). */
43
+ readonly valueMaxChars?: number;
44
+ }
45
+ /** Resolved options with defaults applied (internal). */
46
+ export interface ResolvedToolpackOptions {
47
+ readonly previewChars: number;
48
+ readonly sliceMaxDepth: number;
49
+ readonly sliceMaxNodes: number;
50
+ readonly valueMaxChars: number;
51
+ }
52
+ /** Hard caps — per-call params clamp to these regardless of what the LLM asks for. */
53
+ export declare const TOOLPACK_HARD_CAPS: {
54
+ readonly sliceMaxDepth: 20;
55
+ readonly sliceMaxNodes: 100;
56
+ readonly valueMaxChars: 8000;
57
+ readonly narrativeMaxLines: 200;
58
+ };
59
+ export declare function resolveToolpackOptions(options?: TraceToolpackOptions): ResolvedToolpackOptions;
60
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/trace-toolpack/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,2EAA2E;IAC3E,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,mFAAmF;IACnF,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,uEAAuE;IACvE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,yDAAyD;AACzD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,sFAAsF;AACtF,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC;AAEX,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,uBAAuB,CAO9F"}
@@ -50,4 +50,6 @@ export { attachStatus, type StatusEvent, type StatusOptions, } from './recorders
50
50
  export { toolLineageRecorder, type ToolLineageRecorderHandle, type ToolLineageOptions, type ToolLineageGraph, type ToolLineageEdge, type ToolCallRef, } from './recorders/observability/ToolLineageRecorder.js';
51
51
  export { agentThinkingTrace, type AgentThinkingTraceHandle, type AgentThinkingTraceOptions, type AttTrace, type AttStep, type AttCost, type AttAnswer, type AttToolSeen, } from './recorders/observability/AgentThinkingTraceRecorder.js';
52
52
  export { typedEmit } from './recorders/core/typedEmit.js';
53
+ export { adaptWeights, averageRelevancy, compositeScore, contentHash, DEFAULT_INFLUENCE_WEIGHTS, DEFAULT_MARGIN_THRESHOLD, DEFAULT_PERSISTENCE_THRESHOLD, EmbeddingCache, embeddingCache, finalAnswerSimilarity, pairwiseSimilarity, persistence, scoreInfluence, scoreMargin, structuralProximity, type CandidateScore, type Embedder, type EmbeddingCacheOptions, type EmbeddingCacheStats, type EvidenceInput, type InfluenceScore, type InfluenceWeights, type MarginCandidate, type MarginResult, type PairwiseSimilarityArgs, type PairwiseSimilarityResult, type ScoreInfluenceArgs, type ScoreMarginArgs, type SignalScores, type SimilarityItem, type SimilarityPair, } from './lib/influence-core/index.js';
54
+ export { callTraceTool, TOOLPACK_HARD_CAPS, traceToolpack, type TraceToolpackArtifacts, type TraceToolpackOptions, } from './lib/trace-toolpack/index.js';
53
55
  //# sourceMappingURL=observe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"observe.d.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X,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,EAC7B,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,+BAA+B,CAAC;AAIvC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,GAC1B,MAAM,+BAA+B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"typedEmit.d.ts","sourceRoot":"","sources":["../../../../src/recorders/core/typedEmit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEhG;;;;GAIG;AACH,UAAU,aAAa;IACrB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,uBAAuB,EACzD,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAC5C,IAAI,CAEN"}
1
+ {"version":3,"file":"typedEmit.d.ts","sourceRoot":"","sources":["../../../../src/recorders/core/typedEmit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEhG;;;;GAIG;AACH,UAAU,aAAa;IACrB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9C;AA4BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,uBAAuB,EACzD,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAC5C,IAAI,CAGN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentfootprint",
3
- "version": "6.22.0",
3
+ "version": "6.24.0",
4
4
  "description": "The explainable agent framework — build AI agents you can explain, audit, and trust. Built on footprintjs.",
5
5
  "license": "MIT",
6
6
  "author": "Sanjay Krishna Anbalagan",
@@ -184,7 +184,7 @@
184
184
  "@aws-sdk/client-xray": "*",
185
185
  "@modelcontextprotocol/sdk": "*",
186
186
  "@opentelemetry/api": "*",
187
- "footprintjs": "^9.1.0",
187
+ "footprintjs": "^9.8.0",
188
188
  "ioredis": "*",
189
189
  "openai": "*",
190
190
  "zod": "*"
@@ -229,7 +229,7 @@
229
229
  "esbuild": "^0.28.0",
230
230
  "eslint": "^8.44.0",
231
231
  "eslint-config-prettier": "^6.15.0",
232
- "footprintjs": "^9.1.0",
232
+ "footprintjs": "^9.8.0",
233
233
  "prettier": "^2.8.1",
234
234
  "typedoc": "^0.28.19",
235
235
  "typedoc-plugin-markdown": "^4.11.0",