agentfootprint 6.23.0 → 6.25.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 (111) hide show
  1. package/README.md +31 -0
  2. package/bin/agentfootprint-lint-tools.mjs +14 -0
  3. package/dist/esm/lib/influence-core/cache.js +149 -0
  4. package/dist/esm/lib/influence-core/cache.js.map +1 -0
  5. package/dist/esm/lib/influence-core/index.js +32 -0
  6. package/dist/esm/lib/influence-core/index.js.map +1 -0
  7. package/dist/esm/lib/influence-core/margin.js +110 -0
  8. package/dist/esm/lib/influence-core/margin.js.map +1 -0
  9. package/dist/esm/lib/influence-core/signals.js +232 -0
  10. package/dist/esm/lib/influence-core/signals.js.map +1 -0
  11. package/dist/esm/lib/influence-core/similarity.js +79 -0
  12. package/dist/esm/lib/influence-core/similarity.js.map +1 -0
  13. package/dist/esm/lib/influence-core/types.js +35 -0
  14. package/dist/esm/lib/influence-core/types.js.map +1 -0
  15. package/dist/esm/lib/tool-lint/analyze.js +235 -0
  16. package/dist/esm/lib/tool-lint/analyze.js.map +1 -0
  17. package/dist/esm/lib/tool-lint/cli.js +198 -0
  18. package/dist/esm/lib/tool-lint/cli.js.map +1 -0
  19. package/dist/esm/lib/tool-lint/format.js +61 -0
  20. package/dist/esm/lib/tool-lint/format.js.map +1 -0
  21. package/dist/esm/lib/tool-lint/index.js +23 -0
  22. package/dist/esm/lib/tool-lint/index.js.map +1 -0
  23. package/dist/esm/lib/tool-lint/rules.js +249 -0
  24. package/dist/esm/lib/tool-lint/rules.js.map +1 -0
  25. package/dist/esm/lib/tool-lint/types.js +25 -0
  26. package/dist/esm/lib/tool-lint/types.js.map +1 -0
  27. package/dist/esm/lib/trace-toolpack/bounded.js +76 -0
  28. package/dist/esm/lib/trace-toolpack/bounded.js.map +1 -0
  29. package/dist/esm/lib/trace-toolpack/index.js +10 -0
  30. package/dist/esm/lib/trace-toolpack/index.js.map +1 -0
  31. package/dist/esm/lib/trace-toolpack/traceToolpack.js +699 -0
  32. package/dist/esm/lib/trace-toolpack/traceToolpack.js.map +1 -0
  33. package/dist/esm/lib/trace-toolpack/types.js +24 -0
  34. package/dist/esm/lib/trace-toolpack/types.js.map +1 -0
  35. package/dist/esm/observe.js +25 -0
  36. package/dist/esm/observe.js.map +1 -1
  37. package/dist/esm/recorders/observability/ToolChoiceRecorder.js +261 -0
  38. package/dist/esm/recorders/observability/ToolChoiceRecorder.js.map +1 -0
  39. package/dist/lib/influence-core/cache.js +155 -0
  40. package/dist/lib/influence-core/cache.js.map +1 -0
  41. package/dist/lib/influence-core/index.js +50 -0
  42. package/dist/lib/influence-core/index.js.map +1 -0
  43. package/dist/lib/influence-core/margin.js +114 -0
  44. package/dist/lib/influence-core/margin.js.map +1 -0
  45. package/dist/lib/influence-core/signals.js +242 -0
  46. package/dist/lib/influence-core/signals.js.map +1 -0
  47. package/dist/lib/influence-core/similarity.js +83 -0
  48. package/dist/lib/influence-core/similarity.js.map +1 -0
  49. package/dist/lib/influence-core/types.js +38 -0
  50. package/dist/lib/influence-core/types.js.map +1 -0
  51. package/dist/lib/tool-lint/analyze.js +242 -0
  52. package/dist/lib/tool-lint/analyze.js.map +1 -0
  53. package/dist/lib/tool-lint/cli.js +203 -0
  54. package/dist/lib/tool-lint/cli.js.map +1 -0
  55. package/dist/lib/tool-lint/format.js +65 -0
  56. package/dist/lib/tool-lint/format.js.map +1 -0
  57. package/dist/lib/tool-lint/index.js +43 -0
  58. package/dist/lib/tool-lint/index.js.map +1 -0
  59. package/dist/lib/tool-lint/rules.js +256 -0
  60. package/dist/lib/tool-lint/rules.js.map +1 -0
  61. package/dist/lib/tool-lint/types.js +26 -0
  62. package/dist/lib/tool-lint/types.js.map +1 -0
  63. package/dist/lib/trace-toolpack/bounded.js +86 -0
  64. package/dist/lib/trace-toolpack/bounded.js.map +1 -0
  65. package/dist/lib/trace-toolpack/index.js +16 -0
  66. package/dist/lib/trace-toolpack/index.js.map +1 -0
  67. package/dist/lib/trace-toolpack/traceToolpack.js +704 -0
  68. package/dist/lib/trace-toolpack/traceToolpack.js.map +1 -0
  69. package/dist/lib/trace-toolpack/types.js +28 -0
  70. package/dist/lib/trace-toolpack/types.js.map +1 -0
  71. package/dist/observe.js +64 -1
  72. package/dist/observe.js.map +1 -1
  73. package/dist/recorders/observability/ToolChoiceRecorder.js +266 -0
  74. package/dist/recorders/observability/ToolChoiceRecorder.js.map +1 -0
  75. package/dist/types/lib/influence-core/cache.d.ts +95 -0
  76. package/dist/types/lib/influence-core/cache.d.ts.map +1 -0
  77. package/dist/types/lib/influence-core/index.d.ts +33 -0
  78. package/dist/types/lib/influence-core/index.d.ts.map +1 -0
  79. package/dist/types/lib/influence-core/margin.d.ts +34 -0
  80. package/dist/types/lib/influence-core/margin.d.ts.map +1 -0
  81. package/dist/types/lib/influence-core/signals.d.ts +104 -0
  82. package/dist/types/lib/influence-core/signals.d.ts.map +1 -0
  83. package/dist/types/lib/influence-core/similarity.d.ts +26 -0
  84. package/dist/types/lib/influence-core/similarity.d.ts.map +1 -0
  85. package/dist/types/lib/influence-core/types.d.ts +158 -0
  86. package/dist/types/lib/influence-core/types.d.ts.map +1 -0
  87. package/dist/types/lib/tool-lint/analyze.d.ts +84 -0
  88. package/dist/types/lib/tool-lint/analyze.d.ts.map +1 -0
  89. package/dist/types/lib/tool-lint/cli.d.ts +44 -0
  90. package/dist/types/lib/tool-lint/cli.d.ts.map +1 -0
  91. package/dist/types/lib/tool-lint/format.d.ts +19 -0
  92. package/dist/types/lib/tool-lint/format.d.ts.map +1 -0
  93. package/dist/types/lib/tool-lint/index.d.ts +24 -0
  94. package/dist/types/lib/tool-lint/index.d.ts.map +1 -0
  95. package/dist/types/lib/tool-lint/rules.d.ts +86 -0
  96. package/dist/types/lib/tool-lint/rules.d.ts.map +1 -0
  97. package/dist/types/lib/tool-lint/types.d.ts +156 -0
  98. package/dist/types/lib/tool-lint/types.d.ts.map +1 -0
  99. package/dist/types/lib/trace-toolpack/bounded.d.ts +48 -0
  100. package/dist/types/lib/trace-toolpack/bounded.d.ts.map +1 -0
  101. package/dist/types/lib/trace-toolpack/index.d.ts +10 -0
  102. package/dist/types/lib/trace-toolpack/index.d.ts.map +1 -0
  103. package/dist/types/lib/trace-toolpack/traceToolpack.d.ts +70 -0
  104. package/dist/types/lib/trace-toolpack/traceToolpack.d.ts.map +1 -0
  105. package/dist/types/lib/trace-toolpack/types.d.ts +60 -0
  106. package/dist/types/lib/trace-toolpack/types.d.ts.map +1 -0
  107. package/dist/types/observe.d.ts +4 -0
  108. package/dist/types/observe.d.ts.map +1 -1
  109. package/dist/types/recorders/observability/ToolChoiceRecorder.d.ts +165 -0
  110. package/dist/types/recorders/observability/ToolChoiceRecorder.d.ts.map +1 -0
  111. package/package.json +6 -4
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ /**
3
+ * Structural lint rules (RFC-002 block C2) — the PLUGGABLE RULE PACK.
4
+ *
5
+ * Pattern: Strategy list — each rule is a plain `{ id, check }` object;
6
+ * `defaultStructuralRules` is OUR pack, and consumers add /
7
+ * remove / replace freely via `AnalyzeToolCatalogOptions.rules`.
8
+ * Parameterizable rules ship as FACTORIES (`descriptionRule`,
9
+ * `saysWhatNotWhenRule`, …) returning a configured `LintRule`.
10
+ * Role: `src/lib/tool-lint/` leaf. Pure functions over `CatalogTool`;
11
+ * no embedder, no I/O.
12
+ *
13
+ * Every rule encodes a FIELD FINDING from real catalogs (the Neo SAN
14
+ * triage agent's 29-tool catalog was the seed corpus):
15
+ *
16
+ * 1. description-missing-or-short — the model can only guess from a name.
17
+ * 2. says-what-not-when — describes WHAT the tool returns but gives the
18
+ * model no cue for WHEN to pick it over a sibling (the #1 cause of
19
+ * twin-tool confusion: 'get_fcns_database' vs 'influx_get_fcns_database').
20
+ * 3. enum-in-prose — string params whose legal values are listed in prose
21
+ * ("avg_iops | peak_iops | mbps") instead of a JSON-Schema `enum` the
22
+ * model (and validators, see #9 tool-args validation) can act on.
23
+ * 4. optional-param-undocumented — optional params whose omission has
24
+ * meaning (fabric-wide sweep vs one switch) but whose schema never
25
+ * says so; the model can't reason about leaving them out.
26
+ *
27
+ * Honest claim: these are token/regex HEURISTICS. They flag review
28
+ * prompts, not certainties — expect (rare) false positives and tune via
29
+ * the factory options instead of deleting the rule.
30
+ */
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.defaultStructuralRules = exports.optionalParamRule = exports.DEFAULT_OMISSION_CUES = exports.enumInProseRule = exports.saysWhatNotWhenRule = exports.DEFAULT_WHEN_CUES = exports.descriptionRule = void 0;
33
+ /** Read `properties` / `required` out of a JSON-Schema-ish inputSchema,
34
+ * tolerating absent or malformed shapes (rules must never throw). */
35
+ function readObjectSchema(tool) {
36
+ const schema = tool.inputSchema;
37
+ const props = schema?.properties;
38
+ const properties = props !== null && typeof props === 'object'
39
+ ? Object.entries(props).filter((entry) => entry[1] !== null && typeof entry[1] === 'object')
40
+ : [];
41
+ const required = new Set(Array.isArray(schema?.required) ? schema.required.filter((r) => typeof r === 'string') : []);
42
+ return { properties, required };
43
+ }
44
+ function hasWholeWord(text, word) {
45
+ return new RegExp(`(?:^|[^a-z0-9])${escapeRegExp(word.toLowerCase())}(?:[^a-z0-9]|$)`).test(text.toLowerCase());
46
+ }
47
+ function escapeRegExp(s) {
48
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
49
+ }
50
+ /**
51
+ * Missing description → `error` (the model can only guess from the
52
+ * name). Present but shorter than `minChars` → `warn` (too short to
53
+ * differentiate from siblings).
54
+ */
55
+ function descriptionRule(options = {}) {
56
+ const minChars = options.minChars ?? 40;
57
+ return {
58
+ id: 'description-missing-or-short',
59
+ check(tool) {
60
+ const description = tool.description?.trim() ?? '';
61
+ if (description.length === 0) {
62
+ return [
63
+ {
64
+ rule: 'description-missing-or-short',
65
+ tool: tool.name,
66
+ severity: 'error',
67
+ message: 'tool has no description — the model can only guess from the name',
68
+ },
69
+ ];
70
+ }
71
+ if (description.length < minChars) {
72
+ return [
73
+ {
74
+ rule: 'description-missing-or-short',
75
+ tool: tool.name,
76
+ severity: 'warn',
77
+ message: `description is ${description.length} chars (< ${minChars}) — too short to differentiate this tool from its siblings`,
78
+ },
79
+ ];
80
+ }
81
+ return [];
82
+ },
83
+ };
84
+ }
85
+ exports.descriptionRule = descriptionRule;
86
+ // ── Rule 2 — says WHAT, not WHEN ─────────────────────────────────────
87
+ /** RFC-002 C2 heuristic cue list — temporal/conditional words whose
88
+ * presence suggests the description says WHEN to use the tool. */
89
+ exports.DEFAULT_WHEN_CUES = [
90
+ 'for',
91
+ 'when',
92
+ 'after',
93
+ 'first',
94
+ 'fallback',
95
+ 'only',
96
+ ];
97
+ /**
98
+ * A description with NO temporal/conditional cue token usually describes
99
+ * WHAT the tool returns but never WHEN to pick it — the #1 cause of
100
+ * twin-tool confusion. Heuristic by design: tune `cueTokens` rather than
101
+ * dropping the rule. Skips tools with no description (rule 1's finding).
102
+ */
103
+ function saysWhatNotWhenRule(options = {}) {
104
+ const cues = options.cueTokens ?? exports.DEFAULT_WHEN_CUES;
105
+ return {
106
+ id: 'says-what-not-when',
107
+ check(tool) {
108
+ const description = tool.description?.trim() ?? '';
109
+ if (description.length === 0)
110
+ return [];
111
+ if (cues.some((cue) => hasWholeWord(description, cue)))
112
+ return [];
113
+ return [
114
+ {
115
+ rule: 'says-what-not-when',
116
+ tool: tool.name,
117
+ severity: 'warn',
118
+ message: 'description says WHAT the tool returns but gives no cue for WHEN to use it ' +
119
+ `(no ${cues.map((c) => `'${c}'`).join('/')}) — add the choice condition, ` +
120
+ 'e.g. "Use when …" / "Call FIRST" / "FALLBACK if …"',
121
+ },
122
+ ];
123
+ },
124
+ };
125
+ }
126
+ exports.saysWhatNotWhenRule = saysWhatNotWhenRule;
127
+ // ── Rule 3 — enum described in prose ─────────────────────────────────
128
+ const IDENT = '[A-Za-z][A-Za-z0-9_.-]*';
129
+ /** `avg_iops | peak_iops | mbps` — two or more pipe-separated literals. */
130
+ const PIPE_LIST = new RegExp(`(${IDENT})(?:\\s*\\|\\s*(?:${IDENT}))+`);
131
+ /** `one of: red, green, blue` — comma lists only behind an explicit
132
+ * values marker, so free-form examples ("e.g. 1h, 24h") don't flag. */
133
+ const COMMA_LIST = new RegExp(`(?:one of|allowed values?|valid values?|options|values)\\s*:?\\s*(${IDENT}(?:\\s*,\\s*${IDENT})+)`, 'i');
134
+ /**
135
+ * A string param whose description enumerates its legal values in prose
136
+ * (pipe-separated literals, or comma lists behind "one of"/"allowed
137
+ * values") should declare a JSON-Schema `enum` instead — the model picks
138
+ * reliably from enums, and arg validators (#9) can enforce them. The
139
+ * field case: Neo's `influx_get_port_ranking.metric` =
140
+ * `"avg_iops | peak_iops | mbps"`.
141
+ */
142
+ function enumInProseRule() {
143
+ return {
144
+ id: 'enum-in-prose',
145
+ check(tool) {
146
+ const findings = [];
147
+ const { properties } = readObjectSchema(tool);
148
+ for (const [param, prop] of properties) {
149
+ if (prop.enum !== undefined)
150
+ continue;
151
+ if (prop.type !== undefined && prop.type !== 'string')
152
+ continue;
153
+ const description = typeof prop.description === 'string' ? prop.description : '';
154
+ if (description.length === 0)
155
+ continue;
156
+ const literals = extractProseLiterals(description);
157
+ if (literals === undefined)
158
+ continue;
159
+ findings.push({
160
+ rule: 'enum-in-prose',
161
+ tool: tool.name,
162
+ severity: 'warn',
163
+ param,
164
+ message: `param '${param}' lists its legal values in prose ("${description.slice(0, 80)}") — declare them as a JSON-Schema enum so the model picks reliably`,
165
+ suggestion: `"enum": ${JSON.stringify(literals)}`,
166
+ });
167
+ }
168
+ return findings;
169
+ },
170
+ };
171
+ }
172
+ exports.enumInProseRule = enumInProseRule;
173
+ function extractProseLiterals(description) {
174
+ const pipe = PIPE_LIST.exec(description);
175
+ if (pipe) {
176
+ return pipe[0].split('|').map((v) => v.trim());
177
+ }
178
+ const comma = COMMA_LIST.exec(description);
179
+ if (comma) {
180
+ return comma[1].split(',').map((v) => v.trim());
181
+ }
182
+ return undefined;
183
+ }
184
+ // ── Rule 4 — optional param whose omission is undocumented ───────────
185
+ /** Words that signal the description DOES say what omission means. */
186
+ exports.DEFAULT_OMISSION_CUES = [
187
+ 'optional',
188
+ 'default',
189
+ 'defaults',
190
+ 'omit',
191
+ 'omitted',
192
+ 'if not',
193
+ 'when not',
194
+ 'absent',
195
+ 'all',
196
+ 'entire',
197
+ 'every',
198
+ 'fallback',
199
+ ];
200
+ /**
201
+ * An optional param's omission usually MEANS something (Neo:
202
+ * `influx_get_interface_counters` without `switch_name` = fabric-wide
203
+ * sweep) — but the model can only reason about leaving a param out if
204
+ * the description says so. No description at all, or one with no
205
+ * omission cue, gets a `warn`.
206
+ */
207
+ function optionalParamRule(options = {}) {
208
+ const cues = options.omissionCues ?? exports.DEFAULT_OMISSION_CUES;
209
+ return {
210
+ id: 'optional-param-undocumented',
211
+ check(tool) {
212
+ const findings = [];
213
+ const { properties, required } = readObjectSchema(tool);
214
+ for (const [param, prop] of properties) {
215
+ if (required.has(param))
216
+ continue;
217
+ const description = typeof prop.description === 'string' ? prop.description.trim() : '';
218
+ if (description.length === 0) {
219
+ findings.push({
220
+ rule: 'optional-param-undocumented',
221
+ tool: tool.name,
222
+ severity: 'warn',
223
+ param,
224
+ message: `optional param '${param}' has no description — say what happens when it is omitted (a default? a broader scope?)`,
225
+ });
226
+ }
227
+ else if (!cues.some((cue) => hasWholeWord(description, cue))) {
228
+ findings.push({
229
+ rule: 'optional-param-undocumented',
230
+ tool: tool.name,
231
+ severity: 'warn',
232
+ param,
233
+ message: `optional param '${param}' is described but never says what omission means — add e.g. "optional — defaults to …" / "omit for all …"`,
234
+ });
235
+ }
236
+ }
237
+ return findings;
238
+ },
239
+ };
240
+ }
241
+ exports.optionalParamRule = optionalParamRule;
242
+ // ── The default pack ─────────────────────────────────────────────────
243
+ /**
244
+ * OUR rule pack, built with default options. Compose your own:
245
+ *
246
+ * rules: [...defaultStructuralRules, myRule] // add
247
+ * rules: defaultStructuralRules.filter(r => r.id !== '…') // remove
248
+ * rules: [descriptionRule({ minChars: 80 }), …] // re-tune
249
+ */
250
+ exports.defaultStructuralRules = [
251
+ descriptionRule(),
252
+ saysWhatNotWhenRule(),
253
+ enumInProseRule(),
254
+ optionalParamRule(),
255
+ ];
256
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../src/lib/tool-lint/rules.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAYH;sEACsE;AACtE,SAAS,gBAAgB,CAAC,IAAiB;IAIzC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;IAChC,MAAM,KAAK,GAAG,MAAM,EAAE,UAAU,CAAC;IACjC,MAAM,UAAU,GACd,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QACzC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,CAAC,MAAM,CACrD,CAAC,KAAK,EAAqC,EAAE,CAC3C,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CACpD;QACH,CAAC,CAAC,EAAE,CAAC;IACT,MAAM,QAAQ,GAAG,IAAI,GAAG,CACtB,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAC5F,CAAC;IACF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;AAClC,CAAC;AAED,SAAS,YAAY,CAAC,IAAY,EAAE,IAAY;IAC9C,OAAO,IAAI,MAAM,CAAC,kBAAkB,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,iBAAiB,CAAC,CAAC,IAAI,CACzF,IAAI,CAAC,WAAW,EAAE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IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;oBAC/D,QAAQ,CAAC,IAAI,CAAC;wBACZ,IAAI,EAAE,6BAA6B;wBACnC,IAAI,EAAE,IAAI,CAAC,IAAI;wBACf,QAAQ,EAAE,MAAM;wBAChB,KAAK;wBACL,OAAO,EAAE,mBAAmB,KAAK,4GAA4G;qBAC9I,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC;AA/BD,8CA+BC;AAED,wEAAwE;AAExE;;;;;;GAMG;AACU,QAAA,sBAAsB,GAAwB;IACzD,eAAe,EAAE;IACjB,mBAAmB,EAAE;IACrB,eAAe,EAAE;IACjB,iBAAiB,EAAE;CACpB,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ /**
3
+ * tool-lint types — the tool-catalog confusability lint contract
4
+ * (RFC-002 tier 1, blocks C1–C3).
5
+ *
6
+ * Pattern: Strategy seam (the plug-and-play meta-pattern) — the frame
7
+ * and rule engine are the library's; the embedder, thresholds,
8
+ * and structural rule pack are all consumer-injected, with our
9
+ * defaults. Exactly like NarrativeFormatter / reliability /
10
+ * permission / commentary strategies.
11
+ * Role: `src/lib/` leaf module. ZERO stack buy-in: input is a plain
12
+ * `{ name, description?, inputSchema? }[]` — any OpenAI /
13
+ * Anthropic / LangChain / MCP tool list normalizes to it
14
+ * (see `coerceCatalog`). The library's own `Tool[]` adapts via
15
+ * `catalogFromTools`.
16
+ *
17
+ * ## Honest claim (RFC-002 §2)
18
+ *
19
+ * Confusability here is embedding geometry over what the model READS
20
+ * (tool name + description) — a deterministic heuristic for "could the
21
+ * model mix these up", never a measurement of any model's actual
22
+ * selection function. Tier 3 (choice-entropy sampling) validates the
23
+ * proxy; until then treat verdicts as review prompts, not ground truth.
24
+ */
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/tool-lint/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ /**
3
+ * Bounded serialization helpers for the trace toolpack.
4
+ *
5
+ * Pattern: pure functions — no state, no events.
6
+ * Role: The token-economics layer. EVERY value the toolpack serves goes
7
+ * through these: previews are capped, truncation is EXPLICIT
8
+ * (never silent), and nested-path keys round-trip between the
9
+ * engine's DELIM encoding and LLM-friendly dot notation.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.clampParam = exports.renderPreview = exports.boundedPreview = exports.safeStringify = exports.displayText = exports.normalizeKey = exports.displayKey = exports.FP_PATH_DELIM = void 0;
13
+ /**
14
+ * footprintjs's canonical nested-path delimiter (ASCII unit separator,
15
+ * `src/lib/memory/utils.ts`). Internal to the engine — the toolpack
16
+ * translates it to/from dot notation so the LLM never sees a control char.
17
+ */
18
+ exports.FP_PATH_DELIM = '\u001F';
19
+ /** Engine path → LLM-friendly dotted display form. */
20
+ function displayKey(path) {
21
+ return path.includes(exports.FP_PATH_DELIM) ? path.split(exports.FP_PATH_DELIM).join('.') : path;
22
+ }
23
+ exports.displayKey = displayKey;
24
+ /**
25
+ * LLM-supplied key → engine path. Exact keys pass through; a dotted key
26
+ * that doesn't exist verbatim but matches a known DELIM-joined path is
27
+ * translated back. `knownPaths` is the set of every path seen in the
28
+ * commit log's trace entries.
29
+ */
30
+ function normalizeKey(key, knownPaths) {
31
+ if (knownPaths.has(key))
32
+ return key;
33
+ if (key.includes('.')) {
34
+ const delimForm = key.split('.').join(exports.FP_PATH_DELIM);
35
+ if (knownPaths.has(delimForm))
36
+ return delimForm;
37
+ }
38
+ return key;
39
+ }
40
+ exports.normalizeKey = normalizeKey;
41
+ /** Replace every DELIM in an already-formatted text block with '.' for display. */
42
+ function displayText(text) {
43
+ return text.split(exports.FP_PATH_DELIM).join('.');
44
+ }
45
+ exports.displayText = displayText;
46
+ /**
47
+ * Serialize a value to compact JSON, total-function style: cycles, BigInt
48
+ * and other non-JSON values degrade to a tagged placeholder instead of
49
+ * throwing — a debugger tool must never crash on the evidence it serves.
50
+ */
51
+ function safeStringify(value) {
52
+ if (value === undefined)
53
+ return 'undefined';
54
+ try {
55
+ const json = JSON.stringify(value);
56
+ return json === undefined ? String(value) : json;
57
+ }
58
+ catch {
59
+ return '[unserializable value]';
60
+ }
61
+ }
62
+ exports.safeStringify = safeStringify;
63
+ /** Serialize + cap at `maxChars`. Truncation is reported, never silent. */
64
+ function boundedPreview(value, maxChars) {
65
+ const full = safeStringify(value);
66
+ if (full.length <= maxChars) {
67
+ return { text: full, totalChars: full.length, truncated: false };
68
+ }
69
+ return { text: `${full.slice(0, maxChars)}…`, totalChars: full.length, truncated: true };
70
+ }
71
+ exports.boundedPreview = boundedPreview;
72
+ /** Render a preview with its honesty suffix when truncated. */
73
+ function renderPreview(preview, fetchHint) {
74
+ if (!preview.truncated)
75
+ return preview.text;
76
+ const hint = fetchHint ? ` — ${fetchHint}` : '';
77
+ return `${preview.text} (${preview.totalChars} chars total${hint})`;
78
+ }
79
+ exports.renderPreview = renderPreview;
80
+ /** Clamp an LLM-supplied numeric param into [min, hardCap], with a default. */
81
+ function clampParam(requested, fallback, min, hardCap) {
82
+ const value = typeof requested === 'number' && Number.isFinite(requested) ? requested : fallback;
83
+ return Math.max(min, Math.min(Math.floor(value), hardCap));
84
+ }
85
+ exports.clampParam = clampParam;
86
+ //# sourceMappingURL=bounded.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded.js","sourceRoot":"","sources":["../../../src/lib/trace-toolpack/bounded.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH;;;;GAIG;AACU,QAAA,aAAa,GAAG,QAAQ,CAAC;AAEtC,sDAAsD;AACtD,SAAgB,UA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
5
+ * footprintjs trace evidence exposed as TOOLS an LLM calls: a debugging
6
+ * model navigates a COMPLETED run's evidence by runtimeStageIds instead of
7
+ * reading dumps. Bounded, honest (⚠ markers), redaction-respecting.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.TOOLPACK_HARD_CAPS = exports.traceToolpack = exports.callTraceTool = void 0;
11
+ var traceToolpack_js_1 = require("./traceToolpack.js");
12
+ Object.defineProperty(exports, "callTraceTool", { enumerable: true, get: function () { return traceToolpack_js_1.callTraceTool; } });
13
+ Object.defineProperty(exports, "traceToolpack", { enumerable: true, get: function () { return traceToolpack_js_1.traceToolpack; } });
14
+ var types_js_1 = require("./types.js");
15
+ Object.defineProperty(exports, "TOOLPACK_HARD_CAPS", { enumerable: true, get: function () { return types_js_1.TOOLPACK_HARD_CAPS; } });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/trace-toolpack/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uDAAkE;AAAzD,iHAAA,aAAa,OAAA;AAAE,iHAAA,aAAa,OAAA;AACrC,uCAIoB;AAHlB,8GAAA,kBAAkB,OAAA"}