agentfootprint 6.1.0 → 6.2.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/dist/esm/observe.js +6 -0
- package/dist/esm/observe.js.map +1 -1
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.js +190 -0
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.js.map +1 -0
- package/dist/esm/recorders/observability/ToolLineageRecorder.js +0 -0
- package/dist/esm/recorders/observability/ToolLineageRecorder.js.map +1 -0
- package/dist/observe.js +9 -1
- package/dist/observe.js.map +1 -1
- package/dist/recorders/observability/AgentThinkingTraceRecorder.js +194 -0
- package/dist/recorders/observability/AgentThinkingTraceRecorder.js.map +1 -0
- package/dist/recorders/observability/ToolLineageRecorder.js +0 -0
- package/dist/recorders/observability/ToolLineageRecorder.js.map +1 -0
- package/dist/types/observe.d.ts +2 -0
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/recorders/observability/AgentThinkingTraceRecorder.d.ts +101 -0
- package/dist/types/recorders/observability/AgentThinkingTraceRecorder.d.ts.map +1 -0
- package/dist/types/recorders/observability/ToolLineageRecorder.d.ts +72 -0
- package/dist/types/recorders/observability/ToolLineageRecorder.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/esm/observe.js
CHANGED
|
@@ -50,6 +50,12 @@ export { permissionRecorder, } from './recorders/core/PermissionRecorder.js';
|
|
|
50
50
|
export { skillRecorder } from './recorders/core/SkillRecorder.js';
|
|
51
51
|
export { attachLogging, LoggingDomains, } from './recorders/observability/LoggingRecorder.js';
|
|
52
52
|
export { attachStatus, } from './recorders/observability/StatusRecorder.js';
|
|
53
|
+
// Tool→tool DATA-FLOW graph, derived by value provenance from the tool emit
|
|
54
|
+
// stream (see finding 2: causalChain can't see LLM-mediated tool dependencies).
|
|
55
|
+
export { toolLineageRecorder, } from './recorders/observability/ToolLineageRecorder.js';
|
|
56
|
+
// AgentThinkingUI Trace (run → the "watch it think" beat list, collected during
|
|
57
|
+
// traversal). Lets any agentfootprint run drive AgentThinkingUI / domain views.
|
|
58
|
+
export { agentThinkingTrace, } from './recorders/observability/AgentThinkingTraceRecorder.js';
|
|
53
59
|
// Emit primitive — used by every Tier-3 source-domain.
|
|
54
60
|
export { typedEmit } from './recorders/core/typedEmit.js';
|
|
55
61
|
//# sourceMappingURL=observe.js.map
|
package/dist/esm/observe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe.js","sourceRoot":"","sources":["../../src/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,4BAA4B;AAC5B,OAAO,EAAE,eAAe,EAA+B,MAAM,qCAAqC,CAAC;AACnG,OAAO,EAAE,cAAc,EAA8B,MAAM,oCAAoC,CAAC;AAEhG,+BAA+B;AAC/B,OAAO,EACL,mBAAmB,GAEpB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,aAAa,EAA6B,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GAgBjB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,GAQhB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,eAAe,EACf,cAAc,GAQf,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,oBAAoB,GAKrB,MAAM,gDAAgD,CAAC;AAExD,6BAA6B;AAC7B,OAAO,EAAE,YAAY,EAA4B,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,aAAa,EAA6B,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EACL,wBAAwB,GAEzB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,YAAY,EAA4B,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,cAAc,EAA8B,MAAM,oCAAoC,CAAC;AAChG,OA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EAA6B,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EACL,aAAa,EACb,cAAc,GAIf,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,YAAY,GAGb,MAAM,6CAA6C,CAAC;AACrD,4EAA4E;AAC5E,gFAAgF;AAChF,OAAO,EACL,mBAAmB,GAMpB,MAAM,kDAAkD,CAAC;AAC1D,gFAAgF;AAChF,gFAAgF;AAChF,OAAO,EACL,kBAAkB,GAOnB,MAAM,yDAAyD,CAAC;AAEjE,uDAAuD;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentThinkingTraceRecorder — produce an AgentThinkingUI `Trace` from a run.
|
|
3
|
+
*
|
|
4
|
+
* AgentThinkingUI (the "watch it think" player) consumes a framework-agnostic
|
|
5
|
+
* `Trace` — a list of beats: `prompt → ask → return → answer`, where a tool
|
|
6
|
+
* reply is `data` (reason) or an `instruction` (a skill that says how to act).
|
|
7
|
+
* This recorder builds that `Trace` from agentfootprint's emit stream AS THE RUN
|
|
8
|
+
* TRAVERSES (no post-processing) — so any agentfootprint agent gets the
|
|
9
|
+
* domain-expert view for free, and AgentThinkingUI stays vendor-agnostic (it
|
|
10
|
+
* just renders the `Trace` JSON, exactly as it renders the OTLP adapter's output).
|
|
11
|
+
*
|
|
12
|
+
* Mapping (from the events already on the stream):
|
|
13
|
+
* stream.llm_end (toolCalls>0) → the brain reasoned; content + usage become
|
|
14
|
+
* the upcoming ask's `brain` + `cost`.
|
|
15
|
+
* stream.llm_end (toolCalls==0) → the final `answer`.
|
|
16
|
+
* stream.tool_start → `ask` (read_skill → reaching for a skill).
|
|
17
|
+
* stream.tool_end → `return` (read_skill → replyType:'instruction'
|
|
18
|
+
* + skill; any other tool → replyType:'data').
|
|
19
|
+
*
|
|
20
|
+
* Commentary (each beat's `brain`): filled from agentfootprint's OWN commentary
|
|
21
|
+
* engine — the SAME `selectCommentaryKey`/`extractCommentaryVars`/`renderCommentary`
|
|
22
|
+
* the Lens uses — so AgentThinkingUI's Notepad / bottom caption read identically
|
|
23
|
+
* to the Lens commentary panel (one engine, consumer-overridable via
|
|
24
|
+
* `commentaryTemplates`). The LLM's own reasoning still wins on the first ask of
|
|
25
|
+
* an iteration; the engine fills every other beat so no line is ever blank.
|
|
26
|
+
*
|
|
27
|
+
* Convention 1 (one purpose) + Convention 4 (run-scoped — resets per run).
|
|
28
|
+
*/
|
|
29
|
+
import { defaultCommentaryTemplates, selectCommentaryKey, extractCommentaryVars, renderCommentary, } from './commentary/commentaryTemplates.js';
|
|
30
|
+
const LLM_END = 'agentfootprint.stream.llm_end';
|
|
31
|
+
const TOOL_START = 'agentfootprint.stream.tool_start';
|
|
32
|
+
const TOOL_END = 'agentfootprint.stream.tool_end';
|
|
33
|
+
function asObject(x) {
|
|
34
|
+
if (x != null && typeof x === 'object' && !Array.isArray(x))
|
|
35
|
+
return x;
|
|
36
|
+
return { value: x };
|
|
37
|
+
}
|
|
38
|
+
function headlineOf(s) {
|
|
39
|
+
const line = (s ?? '').split('\n').find((l) => l.trim().length > 0) ?? '';
|
|
40
|
+
return line.length > 140 ? line.slice(0, 140) + '…' : line || 'Done';
|
|
41
|
+
}
|
|
42
|
+
/** `EmitEvent.subflowPath` may arrive as a `/`-joined string or already split;
|
|
43
|
+
* normalize to the array shape the commentary engine's `extractAgentName` reads. */
|
|
44
|
+
function splitPath(p) {
|
|
45
|
+
if (Array.isArray(p))
|
|
46
|
+
return p;
|
|
47
|
+
if (typeof p === 'string' && p.length > 0)
|
|
48
|
+
return p.split('/');
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
export function agentThinkingTrace(options = {}) {
|
|
52
|
+
let lastPipelineId;
|
|
53
|
+
let task = '';
|
|
54
|
+
let steps = [];
|
|
55
|
+
// The most recent reasoning + its cost, awaiting the iteration's ask step(s).
|
|
56
|
+
let pendingBrain = '';
|
|
57
|
+
let pendingCost = { ms: 0, tokens: 0 };
|
|
58
|
+
let pendingCostUsed = false;
|
|
59
|
+
const byId = new Map();
|
|
60
|
+
// Commentary engine — the SAME one the Lens uses. Merged once: consumer
|
|
61
|
+
// overrides spread over the bundled defaults.
|
|
62
|
+
const templates = options.commentaryTemplates
|
|
63
|
+
? { ...defaultCommentaryTemplates, ...options.commentaryTemplates }
|
|
64
|
+
: defaultCommentaryTemplates;
|
|
65
|
+
const appName = options.agent ?? 'Agent';
|
|
66
|
+
/** Narrate one emit event into a prose `brain` line via agentfootprint's
|
|
67
|
+
* commentary engine. The raw `EmitEvent` is adapted to the typed
|
|
68
|
+
* `AgentfootprintEvent` shape the engine reads (`type`/`payload`/`meta`).
|
|
69
|
+
* Returns '' for events the engine deliberately skips. */
|
|
70
|
+
function narrate(e) {
|
|
71
|
+
const ev = {
|
|
72
|
+
type: e.name,
|
|
73
|
+
payload: e.payload,
|
|
74
|
+
meta: { subflowPath: splitPath(e.subflowPath) },
|
|
75
|
+
};
|
|
76
|
+
const key = selectCommentaryKey(ev);
|
|
77
|
+
if (!key)
|
|
78
|
+
return '';
|
|
79
|
+
const vars = extractCommentaryVars(ev, { appName }, templates);
|
|
80
|
+
return renderCommentary(templates[key] ?? '', vars);
|
|
81
|
+
}
|
|
82
|
+
function reset() {
|
|
83
|
+
task = '';
|
|
84
|
+
steps = [];
|
|
85
|
+
pendingBrain = '';
|
|
86
|
+
pendingCost = { ms: 0, tokens: 0 };
|
|
87
|
+
pendingCostUsed = false;
|
|
88
|
+
byId.clear();
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
id: options.id ?? 'agent-thinking-trace',
|
|
92
|
+
onEmit(e) {
|
|
93
|
+
if (lastPipelineId !== undefined && e.pipelineId !== lastPipelineId)
|
|
94
|
+
reset();
|
|
95
|
+
lastPipelineId = e.pipelineId;
|
|
96
|
+
if (e.name === LLM_END) {
|
|
97
|
+
const p = e.payload;
|
|
98
|
+
const cost = {
|
|
99
|
+
ms: p.durationMs ?? 0,
|
|
100
|
+
tokens: (p.usage?.input ?? 0) + (p.usage?.output ?? 0),
|
|
101
|
+
tokensIn: p.usage?.input,
|
|
102
|
+
tokensOut: p.usage?.output,
|
|
103
|
+
tokensCached: p.usage?.cacheRead,
|
|
104
|
+
};
|
|
105
|
+
if ((p.toolCallCount ?? 0) === 0) {
|
|
106
|
+
// No tool calls → this is the final answer.
|
|
107
|
+
const content = p.content ?? '';
|
|
108
|
+
steps.push({
|
|
109
|
+
kind: 'answer',
|
|
110
|
+
to: options.asker ?? 'you',
|
|
111
|
+
brain: content,
|
|
112
|
+
answer: { headline: headlineOf(content), text: content },
|
|
113
|
+
cost,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// Reasoning that will drive the upcoming ask step(s) this iteration.
|
|
118
|
+
pendingBrain = p.content ?? '';
|
|
119
|
+
pendingCost = cost;
|
|
120
|
+
pendingCostUsed = false;
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (e.name === TOOL_START) {
|
|
125
|
+
const p = e.payload;
|
|
126
|
+
if (!p?.toolCallId)
|
|
127
|
+
return;
|
|
128
|
+
const isSkill = p.toolName === 'read_skill';
|
|
129
|
+
const skillId = isSkill
|
|
130
|
+
? p.args?.id ?? undefined
|
|
131
|
+
: undefined;
|
|
132
|
+
byId.set(p.toolCallId, { toolName: p.toolName ?? '(tool)', isSkill, skillId });
|
|
133
|
+
steps.push({
|
|
134
|
+
kind: 'ask',
|
|
135
|
+
tool: isSkill ? skillId ?? 'skill' : p.toolName ?? '(tool)',
|
|
136
|
+
toolName: p.toolName,
|
|
137
|
+
input: asObject(p.args),
|
|
138
|
+
// First ask of the iteration carries the LLM's own reasoning; later
|
|
139
|
+
// asks (and the reasoning-less ones) fall back to engine commentary so
|
|
140
|
+
// the Notepad never shows a blank line.
|
|
141
|
+
brain: pendingCostUsed ? narrate(e) : pendingBrain || narrate(e),
|
|
142
|
+
cost: pendingCostUsed ? { ms: 0, tokens: 0 } : pendingCost, // attribute the LLM cost to the first ask of the iteration
|
|
143
|
+
});
|
|
144
|
+
pendingCostUsed = true;
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (e.name === TOOL_END) {
|
|
148
|
+
const p = e.payload;
|
|
149
|
+
const started = p?.toolCallId ? byId.get(p.toolCallId) : undefined;
|
|
150
|
+
if (!started)
|
|
151
|
+
return;
|
|
152
|
+
byId.delete(p.toolCallId);
|
|
153
|
+
steps.push({
|
|
154
|
+
kind: 'return',
|
|
155
|
+
tool: started.isSkill ? started.skillId ?? 'skill' : started.toolName,
|
|
156
|
+
toolName: started.toolName,
|
|
157
|
+
replyType: started.isSkill ? 'instruction' : 'data',
|
|
158
|
+
output: asObject(p.result),
|
|
159
|
+
// The tool-result beat has no LLM reasoning of its own — narrate the
|
|
160
|
+
// mechanics via the commentary engine (matches the Lens).
|
|
161
|
+
brain: narrate(e),
|
|
162
|
+
brainMode: started.isSkill ? 'act' : 'reason',
|
|
163
|
+
...(started.isSkill && started.skillId ? { skill: started.skillId } : {}),
|
|
164
|
+
cost: { ms: p.durationMs ?? 0, tokens: 0 },
|
|
165
|
+
...(p.error ? { error: 'tool failed' } : {}),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
getTrace(overrides = {}) {
|
|
170
|
+
const prompt = {
|
|
171
|
+
kind: 'prompt',
|
|
172
|
+
brain: overrides.task ?? task,
|
|
173
|
+
cost: { ms: 0, tokens: 0 },
|
|
174
|
+
};
|
|
175
|
+
return {
|
|
176
|
+
task: overrides.task ?? task,
|
|
177
|
+
...(overrides.title ? { title: overrides.title } : {}),
|
|
178
|
+
agent: overrides.agent ?? options.agent ?? 'Agent',
|
|
179
|
+
model: overrides.model ?? options.model ?? 'model',
|
|
180
|
+
asker: overrides.asker ?? options.asker ?? 'you',
|
|
181
|
+
steps: [prompt, ...steps],
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
clear() {
|
|
185
|
+
reset();
|
|
186
|
+
lastPipelineId = undefined;
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=AgentThinkingTraceRecorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentThinkingTraceRecorder.js","sourceRoot":"","sources":["../../../../src/recorders/observability/AgentThinkingTraceRecorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,GAEjB,MAAM,qCAAqC,CAAC;AAuE7C,MAAM,OAAO,GAAG,+BAA+B,CAAC;AAChD,MAAM,UAAU,GAAG,kCAAkC,CAAC;AACtD,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AAElD,SAAS,QAAQ,CAAC,CAAU;IAC1B,IAAI,CAAC,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAA4B,CAAC;IACjG,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AACtB,CAAC;AACD,SAAS,UAAU,CAAC,CAAS;IAC3B,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1E,OAAO,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC;AACvE,CAAC;AACD;qFACqF;AACrF,SAAS,SAAS,CAAC,CAAU;IAC3B,IAAI,KAAK,C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,CAAC,EAAE,UAAU;oBAAE,OAAO;gBAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;gBACnC,IAAI,CAAC,GAAG;oBAAE,OAAO;gBACjB,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;gBAClC,aAAa,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;gBACpC,KAAK,MAAM,CAAC,IAAI,OAAO;oBAAE,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,gCAAgC;YAClF,CAAC;QACH,CAAC;QAED,UAAU;YACR,OAAO,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC;QAClD,CAAC;QAED,KAAK;YACH,KAAK,EAAE,CAAC;YACR,cAAc,GAAG,SAAS,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/observe.js
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* directly; Tier 3 dashboards are opt-in.
|
|
33
33
|
*/
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.typedEmit = exports.attachStatus = exports.LoggingDomains = exports.attachLogging = exports.skillRecorder = exports.permissionRecorder = exports.memoryRecorder = exports.evalRecorder = exports.contextEvaluatedRecorder = exports.toolsRecorder = exports.costRecorder = exports.LiveAgentTurnTracker = exports.LiveToolTracker = exports.LiveLLMTracker = exports.LiveStateRecorder = exports.liveStateRecorder = exports.buildStepGraph = exports.attachFlowchart = exports.runStepRecorder = exports.RunStepRecorder = exports.buildRunSteps = exports.BoundaryRecorder = exports.boundaryRecorder = exports.agentRecorder = exports.compositionRecorder = exports.streamRecorder = exports.ContextRecorder = void 0;
|
|
35
|
+
exports.typedEmit = exports.agentThinkingTrace = exports.toolLineageRecorder = exports.attachStatus = exports.LoggingDomains = exports.attachLogging = exports.skillRecorder = exports.permissionRecorder = exports.memoryRecorder = exports.evalRecorder = exports.contextEvaluatedRecorder = exports.toolsRecorder = exports.costRecorder = exports.LiveAgentTurnTracker = exports.LiveToolTracker = exports.LiveLLMTracker = exports.LiveStateRecorder = exports.liveStateRecorder = exports.buildStepGraph = exports.attachFlowchart = exports.runStepRecorder = exports.RunStepRecorder = exports.buildRunSteps = exports.BoundaryRecorder = exports.boundaryRecorder = exports.agentRecorder = exports.compositionRecorder = exports.streamRecorder = exports.ContextRecorder = void 0;
|
|
36
36
|
// Tier 1 — context + stream
|
|
37
37
|
var ContextRecorder_js_1 = require("./recorders/core/ContextRecorder.js");
|
|
38
38
|
Object.defineProperty(exports, "ContextRecorder", { enumerable: true, get: function () { return ContextRecorder_js_1.ContextRecorder; } });
|
|
@@ -79,6 +79,14 @@ Object.defineProperty(exports, "attachLogging", { enumerable: true, get: functio
|
|
|
79
79
|
Object.defineProperty(exports, "LoggingDomains", { enumerable: true, get: function () { return LoggingRecorder_js_1.LoggingDomains; } });
|
|
80
80
|
var StatusRecorder_js_1 = require("./recorders/observability/StatusRecorder.js");
|
|
81
81
|
Object.defineProperty(exports, "attachStatus", { enumerable: true, get: function () { return StatusRecorder_js_1.attachStatus; } });
|
|
82
|
+
// Tool→tool DATA-FLOW graph, derived by value provenance from the tool emit
|
|
83
|
+
// stream (see finding 2: causalChain can't see LLM-mediated tool dependencies).
|
|
84
|
+
var ToolLineageRecorder_js_1 = require("./recorders/observability/ToolLineageRecorder.js");
|
|
85
|
+
Object.defineProperty(exports, "toolLineageRecorder", { enumerable: true, get: function () { return ToolLineageRecorder_js_1.toolLineageRecorder; } });
|
|
86
|
+
// AgentThinkingUI Trace (run → the "watch it think" beat list, collected during
|
|
87
|
+
// traversal). Lets any agentfootprint run drive AgentThinkingUI / domain views.
|
|
88
|
+
var AgentThinkingTraceRecorder_js_1 = require("./recorders/observability/AgentThinkingTraceRecorder.js");
|
|
89
|
+
Object.defineProperty(exports, "agentThinkingTrace", { enumerable: true, get: function () { return AgentThinkingTraceRecorder_js_1.agentThinkingTrace; } });
|
|
82
90
|
// Emit primitive — used by every Tier-3 source-domain.
|
|
83
91
|
var typedEmit_js_1 = require("./recorders/core/typedEmit.js");
|
|
84
92
|
Object.defineProperty(exports, "typedEmit", { enumerable: true, get: function () { return typedEmit_js_1.typedEmit; } });
|
package/dist/observe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe.js","sourceRoot":"","sources":["../src/observe.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;AAEH,4BAA4B;AAC5B,0EAAmG;AAA1F,qHAAA,eAAe,OAAA;AACxB,wEAAgG;AAAvF,mHAAA,cAAc,OAAA;AAEvB,+BAA+B;AAC/B,kFAGiD;AAF/C,6HAAA,mBAAmB,OAAA;AAGrB,sEAA6F;AAApF,iHAAA,aAAa,OAAA;AACtB,qFAkBuD;AAjBrD,uHAAA,gBAAgB,OAAA;AAChB,uHAAA,gBAAgB,OAAA;AAiBlB,mFAWsD;AAVpD,mHAAA,aAAa,OAAA;AACb,qHAAA,eAAe,OAAA;AACf,qHAAA,eAAe,OAAA;AASjB,uFAUwD;AATtD,uHAAA,eAAe,OAAA;AACf,sHAAA,cAAc,OAAA;AAShB,uFAUwD;AATtD,yHAAA,iBAAiB,OAAA;AACjB,yHAAA,iBAAiB,OAAA;AACjB,sHAAA,cAAc,OAAA;AACd,uHAAA,eAAe,OAAA;AACf,4HAAA,oBAAoB,OAAA;AAOtB,6BAA6B;AAC7B,oEAA0F;AAAjF,+GAAA,YAAY,OAAA;AACrB,sEAA6F;AAApF,iHAAA,aAAa,OAAA;AACtB,4FAGsD;AAFpD,uIAAA,wBAAwB,OAAA;AAG1B,oEAA0F;AAAjF,+GAAA,YAAY,OAAA;AACrB,wEAAgG;AAAvF,mHAAA,cAAc,OAAA;AACvB,gFAGgD;AAF9C,2HAAA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AKhB,iFAIqD;AAHnD,iHAAA,YAAY,OAAA;AAId,4EAA4E;AAC5E,gFAAgF;AAChF,2FAO0D;AANxD,6HAAA,mBAAmB,OAAA;AAOrB,gFAAgF;AAChF,gFAAgF;AAChF,yGAQiE;AAP/D,mIAAA,kBAAkB,OAAA;AASpB,uDAAuD;AACvD,8DAA0D;AAAjD,yGAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentThinkingTraceRecorder — produce an AgentThinkingUI `Trace` from a run.
|
|
4
|
+
*
|
|
5
|
+
* AgentThinkingUI (the "watch it think" player) consumes a framework-agnostic
|
|
6
|
+
* `Trace` — a list of beats: `prompt → ask → return → answer`, where a tool
|
|
7
|
+
* reply is `data` (reason) or an `instruction` (a skill that says how to act).
|
|
8
|
+
* This recorder builds that `Trace` from agentfootprint's emit stream AS THE RUN
|
|
9
|
+
* TRAVERSES (no post-processing) — so any agentfootprint agent gets the
|
|
10
|
+
* domain-expert view for free, and AgentThinkingUI stays vendor-agnostic (it
|
|
11
|
+
* just renders the `Trace` JSON, exactly as it renders the OTLP adapter's output).
|
|
12
|
+
*
|
|
13
|
+
* Mapping (from the events already on the stream):
|
|
14
|
+
* stream.llm_end (toolCalls>0) → the brain reasoned; content + usage become
|
|
15
|
+
* the upcoming ask's `brain` + `cost`.
|
|
16
|
+
* stream.llm_end (toolCalls==0) → the final `answer`.
|
|
17
|
+
* stream.tool_start → `ask` (read_skill → reaching for a skill).
|
|
18
|
+
* stream.tool_end → `return` (read_skill → replyType:'instruction'
|
|
19
|
+
* + skill; any other tool → replyType:'data').
|
|
20
|
+
*
|
|
21
|
+
* Commentary (each beat's `brain`): filled from agentfootprint's OWN commentary
|
|
22
|
+
* engine — the SAME `selectCommentaryKey`/`extractCommentaryVars`/`renderCommentary`
|
|
23
|
+
* the Lens uses — so AgentThinkingUI's Notepad / bottom caption read identically
|
|
24
|
+
* to the Lens commentary panel (one engine, consumer-overridable via
|
|
25
|
+
* `commentaryTemplates`). The LLM's own reasoning still wins on the first ask of
|
|
26
|
+
* an iteration; the engine fills every other beat so no line is ever blank.
|
|
27
|
+
*
|
|
28
|
+
* Convention 1 (one purpose) + Convention 4 (run-scoped — resets per run).
|
|
29
|
+
*/
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.agentThinkingTrace = void 0;
|
|
32
|
+
const commentaryTemplates_js_1 = require("./commentary/commentaryTemplates.js");
|
|
33
|
+
const LLM_END = 'agentfootprint.stream.llm_end';
|
|
34
|
+
const TOOL_START = 'agentfootprint.stream.tool_start';
|
|
35
|
+
const TOOL_END = 'agentfootprint.stream.tool_end';
|
|
36
|
+
function asObject(x) {
|
|
37
|
+
if (x != null && typeof x === 'object' && !Array.isArray(x))
|
|
38
|
+
return x;
|
|
39
|
+
return { value: x };
|
|
40
|
+
}
|
|
41
|
+
function headlineOf(s) {
|
|
42
|
+
const line = (s ?? '').split('\n').find((l) => l.trim().length > 0) ?? '';
|
|
43
|
+
return line.length > 140 ? line.slice(0, 140) + '…' : line || 'Done';
|
|
44
|
+
}
|
|
45
|
+
/** `EmitEvent.subflowPath` may arrive as a `/`-joined string or already split;
|
|
46
|
+
* normalize to the array shape the commentary engine's `extractAgentName` reads. */
|
|
47
|
+
function splitPath(p) {
|
|
48
|
+
if (Array.isArray(p))
|
|
49
|
+
return p;
|
|
50
|
+
if (typeof p === 'string' && p.length > 0)
|
|
51
|
+
return p.split('/');
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
function agentThinkingTrace(options = {}) {
|
|
55
|
+
let lastPipelineId;
|
|
56
|
+
let task = '';
|
|
57
|
+
let steps = [];
|
|
58
|
+
// The most recent reasoning + its cost, awaiting the iteration's ask step(s).
|
|
59
|
+
let pendingBrain = '';
|
|
60
|
+
let pendingCost = { ms: 0, tokens: 0 };
|
|
61
|
+
let pendingCostUsed = false;
|
|
62
|
+
const byId = new Map();
|
|
63
|
+
// Commentary engine — the SAME one the Lens uses. Merged once: consumer
|
|
64
|
+
// overrides spread over the bundled defaults.
|
|
65
|
+
const templates = options.commentaryTemplates
|
|
66
|
+
? { ...commentaryTemplates_js_1.defaultCommentaryTemplates, ...options.commentaryTemplates }
|
|
67
|
+
: commentaryTemplates_js_1.defaultCommentaryTemplates;
|
|
68
|
+
const appName = options.agent ?? 'Agent';
|
|
69
|
+
/** Narrate one emit event into a prose `brain` line via agentfootprint's
|
|
70
|
+
* commentary engine. The raw `EmitEvent` is adapted to the typed
|
|
71
|
+
* `AgentfootprintEvent` shape the engine reads (`type`/`payload`/`meta`).
|
|
72
|
+
* Returns '' for events the engine deliberately skips. */
|
|
73
|
+
function narrate(e) {
|
|
74
|
+
const ev = {
|
|
75
|
+
type: e.name,
|
|
76
|
+
payload: e.payload,
|
|
77
|
+
meta: { subflowPath: splitPath(e.subflowPath) },
|
|
78
|
+
};
|
|
79
|
+
const key = (0, commentaryTemplates_js_1.selectCommentaryKey)(ev);
|
|
80
|
+
if (!key)
|
|
81
|
+
return '';
|
|
82
|
+
const vars = (0, commentaryTemplates_js_1.extractCommentaryVars)(ev, { appName }, templates);
|
|
83
|
+
return (0, commentaryTemplates_js_1.renderCommentary)(templates[key] ?? '', vars);
|
|
84
|
+
}
|
|
85
|
+
function reset() {
|
|
86
|
+
task = '';
|
|
87
|
+
steps = [];
|
|
88
|
+
pendingBrain = '';
|
|
89
|
+
pendingCost = { ms: 0, tokens: 0 };
|
|
90
|
+
pendingCostUsed = false;
|
|
91
|
+
byId.clear();
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
id: options.id ?? 'agent-thinking-trace',
|
|
95
|
+
onEmit(e) {
|
|
96
|
+
if (lastPipelineId !== undefined && e.pipelineId !== lastPipelineId)
|
|
97
|
+
reset();
|
|
98
|
+
lastPipelineId = e.pipelineId;
|
|
99
|
+
if (e.name === LLM_END) {
|
|
100
|
+
const p = e.payload;
|
|
101
|
+
const cost = {
|
|
102
|
+
ms: p.durationMs ?? 0,
|
|
103
|
+
tokens: (p.usage?.input ?? 0) + (p.usage?.output ?? 0),
|
|
104
|
+
tokensIn: p.usage?.input,
|
|
105
|
+
tokensOut: p.usage?.output,
|
|
106
|
+
tokensCached: p.usage?.cacheRead,
|
|
107
|
+
};
|
|
108
|
+
if ((p.toolCallCount ?? 0) === 0) {
|
|
109
|
+
// No tool calls → this is the final answer.
|
|
110
|
+
const content = p.content ?? '';
|
|
111
|
+
steps.push({
|
|
112
|
+
kind: 'answer',
|
|
113
|
+
to: options.asker ?? 'you',
|
|
114
|
+
brain: content,
|
|
115
|
+
answer: { headline: headlineOf(content), text: content },
|
|
116
|
+
cost,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// Reasoning that will drive the upcoming ask step(s) this iteration.
|
|
121
|
+
pendingBrain = p.content ?? '';
|
|
122
|
+
pendingCost = cost;
|
|
123
|
+
pendingCostUsed = false;
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (e.name === TOOL_START) {
|
|
128
|
+
const p = e.payload;
|
|
129
|
+
if (!p?.toolCallId)
|
|
130
|
+
return;
|
|
131
|
+
const isSkill = p.toolName === 'read_skill';
|
|
132
|
+
const skillId = isSkill
|
|
133
|
+
? p.args?.id ?? undefined
|
|
134
|
+
: undefined;
|
|
135
|
+
byId.set(p.toolCallId, { toolName: p.toolName ?? '(tool)', isSkill, skillId });
|
|
136
|
+
steps.push({
|
|
137
|
+
kind: 'ask',
|
|
138
|
+
tool: isSkill ? skillId ?? 'skill' : p.toolName ?? '(tool)',
|
|
139
|
+
toolName: p.toolName,
|
|
140
|
+
input: asObject(p.args),
|
|
141
|
+
// First ask of the iteration carries the LLM's own reasoning; later
|
|
142
|
+
// asks (and the reasoning-less ones) fall back to engine commentary so
|
|
143
|
+
// the Notepad never shows a blank line.
|
|
144
|
+
brain: pendingCostUsed ? narrate(e) : pendingBrain || narrate(e),
|
|
145
|
+
cost: pendingCostUsed ? { ms: 0, tokens: 0 } : pendingCost, // attribute the LLM cost to the first ask of the iteration
|
|
146
|
+
});
|
|
147
|
+
pendingCostUsed = true;
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (e.name === TOOL_END) {
|
|
151
|
+
const p = e.payload;
|
|
152
|
+
const started = p?.toolCallId ? byId.get(p.toolCallId) : undefined;
|
|
153
|
+
if (!started)
|
|
154
|
+
return;
|
|
155
|
+
byId.delete(p.toolCallId);
|
|
156
|
+
steps.push({
|
|
157
|
+
kind: 'return',
|
|
158
|
+
tool: started.isSkill ? started.skillId ?? 'skill' : started.toolName,
|
|
159
|
+
toolName: started.toolName,
|
|
160
|
+
replyType: started.isSkill ? 'instruction' : 'data',
|
|
161
|
+
output: asObject(p.result),
|
|
162
|
+
// The tool-result beat has no LLM reasoning of its own — narrate the
|
|
163
|
+
// mechanics via the commentary engine (matches the Lens).
|
|
164
|
+
brain: narrate(e),
|
|
165
|
+
brainMode: started.isSkill ? 'act' : 'reason',
|
|
166
|
+
...(started.isSkill && started.skillId ? { skill: started.skillId } : {}),
|
|
167
|
+
cost: { ms: p.durationMs ?? 0, tokens: 0 },
|
|
168
|
+
...(p.error ? { error: 'tool failed' } : {}),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
getTrace(overrides = {}) {
|
|
173
|
+
const prompt = {
|
|
174
|
+
kind: 'prompt',
|
|
175
|
+
brain: overrides.task ?? task,
|
|
176
|
+
cost: { ms: 0, tokens: 0 },
|
|
177
|
+
};
|
|
178
|
+
return {
|
|
179
|
+
task: overrides.task ?? task,
|
|
180
|
+
...(overrides.title ? { title: overrides.title } : {}),
|
|
181
|
+
agent: overrides.agent ?? options.agent ?? 'Agent',
|
|
182
|
+
model: overrides.model ?? options.model ?? 'model',
|
|
183
|
+
asker: overrides.asker ?? options.asker ?? 'you',
|
|
184
|
+
steps: [prompt, ...steps],
|
|
185
|
+
};
|
|
186
|
+
},
|
|
187
|
+
clear() {
|
|
188
|
+
reset();
|
|
189
|
+
lastPipelineId = undefined;
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
exports.agentThinkingTrace = agentThinkingTrace;
|
|
194
|
+
//# sourceMappingURL=AgentThinkingTraceRecorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentThinkingTraceRecorder.js","sourceRoot":"","sources":["../../../src/recorders/observability/AgentThinkingTraceRecorder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AAIH,gFAM6C;AAuE7C,MAAM,OAAO,GAAG,+BAA+B,CAAC;AAChD,MAAM,UAAU,GAAG,kCAAkC,CAAC;AACtD,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AAElD,SAAS,QAAQ,CAAC,CAAU;IAC1B,IAAI,CAAC,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAA4B,CAAC;IACjG,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AACtB,CAAC;AACD,SAAS,UAAU,CAAC,CAAS;IAC3B,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1E,OAAO,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC;AACvE,CAAC;AACD;qFACqF;AACrF,SAAS,SAAS,CAAC,CAAU;IAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,C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I,CAAC,CAAC,EAAE,UAAU;oBAAE,OAAO;gBAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;gBACnC,IAAI,CAAC,GAAG;oBAAE,OAAO;gBACjB,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;gBAClC,aAAa,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;gBACpC,KAAK,MAAM,CAAC,IAAI,OAAO;oBAAE,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,gCAAgC;YAClF,CAAC;QACH,CAAC;QAED,UAAU;YACR,OAAO,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC;QAClD,CAAC;QAED,KAAK;YACH,KAAK,EAAE,CAAC;YACR,cAAc,GAAG,SAAS,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC;AArGD,kDAqGC"}
|
package/dist/types/observe.d.ts
CHANGED
|
@@ -47,5 +47,7 @@ export { permissionRecorder, type PermissionRecorderOptions, } from './recorders
|
|
|
47
47
|
export { skillRecorder, type SkillRecorderOptions } from './recorders/core/SkillRecorder.js';
|
|
48
48
|
export { attachLogging, LoggingDomains, type LoggingLogger, type LoggingDomain, type LoggingOptions, } from './recorders/observability/LoggingRecorder.js';
|
|
49
49
|
export { attachStatus, type StatusEvent, type StatusOptions, } from './recorders/observability/StatusRecorder.js';
|
|
50
|
+
export { toolLineageRecorder, type ToolLineageRecorderHandle, type ToolLineageOptions, type ToolLineageGraph, type ToolLineageEdge, type ToolCallRef, } from './recorders/observability/ToolLineageRecorder.js';
|
|
51
|
+
export { agentThinkingTrace, type AgentThinkingTraceHandle, type AgentThinkingTraceOptions, type AttTrace, type AttStep, type AttCost, type AttAnswer, } from './recorders/observability/AgentThinkingTraceRecorder.js';
|
|
50
52
|
export { typedEmit } from './recorders/core/typedEmit.js';
|
|
51
53
|
//# 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,oCAAoC,CAAC;AAGhG,OAAO,EACL,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,GACxB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,GACvB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,eAAe,EACf,cAAc,EACd,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK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C,CAAC;AAC7F,OAAO,EACL,wBAAwB,EACxB,KAAK,+BAA+B,GACrC,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,GAC/B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,aAAa,GACnB,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EACL,mBAAmB,EACnB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,MAAM,kDAAkD,CAAC;AAG1D,OAAO,EACL,kBAAkB,EAClB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,SAAS,GACf,MAAM,yDAAyD,CAAC;AAGjE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentThinkingTraceRecorder — produce an AgentThinkingUI `Trace` from a run.
|
|
3
|
+
*
|
|
4
|
+
* AgentThinkingUI (the "watch it think" player) consumes a framework-agnostic
|
|
5
|
+
* `Trace` — a list of beats: `prompt → ask → return → answer`, where a tool
|
|
6
|
+
* reply is `data` (reason) or an `instruction` (a skill that says how to act).
|
|
7
|
+
* This recorder builds that `Trace` from agentfootprint's emit stream AS THE RUN
|
|
8
|
+
* TRAVERSES (no post-processing) — so any agentfootprint agent gets the
|
|
9
|
+
* domain-expert view for free, and AgentThinkingUI stays vendor-agnostic (it
|
|
10
|
+
* just renders the `Trace` JSON, exactly as it renders the OTLP adapter's output).
|
|
11
|
+
*
|
|
12
|
+
* Mapping (from the events already on the stream):
|
|
13
|
+
* stream.llm_end (toolCalls>0) → the brain reasoned; content + usage become
|
|
14
|
+
* the upcoming ask's `brain` + `cost`.
|
|
15
|
+
* stream.llm_end (toolCalls==0) → the final `answer`.
|
|
16
|
+
* stream.tool_start → `ask` (read_skill → reaching for a skill).
|
|
17
|
+
* stream.tool_end → `return` (read_skill → replyType:'instruction'
|
|
18
|
+
* + skill; any other tool → replyType:'data').
|
|
19
|
+
*
|
|
20
|
+
* Commentary (each beat's `brain`): filled from agentfootprint's OWN commentary
|
|
21
|
+
* engine — the SAME `selectCommentaryKey`/`extractCommentaryVars`/`renderCommentary`
|
|
22
|
+
* the Lens uses — so AgentThinkingUI's Notepad / bottom caption read identically
|
|
23
|
+
* to the Lens commentary panel (one engine, consumer-overridable via
|
|
24
|
+
* `commentaryTemplates`). The LLM's own reasoning still wins on the first ask of
|
|
25
|
+
* an iteration; the engine fills every other beat so no line is ever blank.
|
|
26
|
+
*
|
|
27
|
+
* Convention 1 (one purpose) + Convention 4 (run-scoped — resets per run).
|
|
28
|
+
*/
|
|
29
|
+
import type { EmitRecorder } from 'footprintjs';
|
|
30
|
+
import { type CommentaryTemplates } from './commentary/commentaryTemplates.js';
|
|
31
|
+
export interface AttCost {
|
|
32
|
+
ms: number;
|
|
33
|
+
tokens: number;
|
|
34
|
+
tokensIn?: number;
|
|
35
|
+
tokensOut?: number;
|
|
36
|
+
tokensCached?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface AttAnswer {
|
|
39
|
+
headline: string;
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
}
|
|
42
|
+
export type AttStep = {
|
|
43
|
+
kind: 'prompt';
|
|
44
|
+
brain: string;
|
|
45
|
+
cost: AttCost;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'ask';
|
|
48
|
+
tool: string;
|
|
49
|
+
toolName?: string;
|
|
50
|
+
input: Record<string, unknown>;
|
|
51
|
+
brain: string;
|
|
52
|
+
cost: AttCost;
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'return';
|
|
55
|
+
tool: string;
|
|
56
|
+
toolName?: string;
|
|
57
|
+
replyType: 'data' | 'instruction' | 'both';
|
|
58
|
+
output: Record<string, unknown>;
|
|
59
|
+
brain: string;
|
|
60
|
+
cost: AttCost;
|
|
61
|
+
brainMode?: 'reason' | 'act';
|
|
62
|
+
skill?: string;
|
|
63
|
+
error?: string;
|
|
64
|
+
} | {
|
|
65
|
+
kind: 'answer';
|
|
66
|
+
to: string;
|
|
67
|
+
brain: string;
|
|
68
|
+
answer: AttAnswer;
|
|
69
|
+
cost: AttCost;
|
|
70
|
+
error?: string;
|
|
71
|
+
};
|
|
72
|
+
export interface AttTrace {
|
|
73
|
+
task: string;
|
|
74
|
+
title?: string;
|
|
75
|
+
agent: string;
|
|
76
|
+
model: string;
|
|
77
|
+
asker: string;
|
|
78
|
+
steps: AttStep[];
|
|
79
|
+
}
|
|
80
|
+
export interface AgentThinkingTraceOptions {
|
|
81
|
+
readonly id?: string;
|
|
82
|
+
readonly agent?: string;
|
|
83
|
+
readonly model?: string;
|
|
84
|
+
readonly asker?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Override agentfootprint's bundled commentary templates — the SAME shape as
|
|
87
|
+
* the Lens's `commentaryTemplates` prop (partial; spread over the defaults).
|
|
88
|
+
* Drives each beat's `brain` narration, so AgentThinkingUI's Notepad / bottom
|
|
89
|
+
* caption read like the Lens commentary panel — one engine, one voice,
|
|
90
|
+
* consumer-overridable. Omit to use the bundled English defaults.
|
|
91
|
+
*/
|
|
92
|
+
readonly commentaryTemplates?: Partial<CommentaryTemplates>;
|
|
93
|
+
}
|
|
94
|
+
export interface AgentThinkingTraceHandle extends EmitRecorder {
|
|
95
|
+
/** The AgentThinkingUI `Trace` for the run so far. `task` (the headline of the
|
|
96
|
+
* replay pill) defaults to the captured user message; override any field. */
|
|
97
|
+
getTrace(overrides?: Partial<Pick<AttTrace, 'task' | 'title' | 'agent' | 'model' | 'asker'>>): AttTrace;
|
|
98
|
+
clear(): void;
|
|
99
|
+
}
|
|
100
|
+
export declare function agentThinkingTrace(options?: AgentThinkingTraceOptions): AgentThinkingTraceHandle;
|
|
101
|
+
//# sourceMappingURL=AgentThinkingTraceRecorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentThinkingTraceRecorder.d.ts","sourceRoot":"","sources":["../../../../src/recorders/observability/AgentThinkingTraceRecorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAa,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAKL,KAAK,mBAAmB,EACzB,MAAM,qCAAqC,CAAC;AAI7C,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AACD,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AACD,MAAM,MAAM,OAAO,GACf;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAChD;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,E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ED,MAAM,WAAW,wBAAyB,SAAQ,YAAY;IAC5D;kFAC8E;IAC9E,QAAQ,CACN,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,GAClF,QAAQ,CAAC;IACZ,KAAK,IAAI,IAAI,CAAC;CACf;AAsBD,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,yBAA8B,GACtC,wBAAwB,CAyJ1B"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolLineageRecorder — derives the tool→tool DATA-FLOW graph of a run.
|
|
3
|
+
*
|
|
4
|
+
* Why this exists: in a ReAct agent a tool's output flows back to the LLM as
|
|
5
|
+
* text, and the LLM decides the NEXT tool's arguments — so the data dependency
|
|
6
|
+
* between tools (e.g. FLOGI's FCID reused as io_profile's `initiator_id`) never
|
|
7
|
+
* touches footprintjs's shared scope, and `causalChain` can't reconstruct it.
|
|
8
|
+
* This recorder rebuilds that graph from the tool emit stream by VALUE
|
|
9
|
+
* PROVENANCE: when a tool call's argument value equals a distinctive value
|
|
10
|
+
* produced by an EARLIER iteration's tool result, it records an edge
|
|
11
|
+
* (producer → consumer).
|
|
12
|
+
*
|
|
13
|
+
* It is a HEURISTIC, not ground truth — it matches by value, so it is accurate
|
|
14
|
+
* for distinctive identifiers (FCIDs, WWPNs, ids, NAAs, hostnames) and
|
|
15
|
+
* deliberately conservative:
|
|
16
|
+
* - short / common values (below `minValueLength`) are ignored,
|
|
17
|
+
* - numbers are ignored by default (coincidental matches are likely),
|
|
18
|
+
* - same-iteration (parallel) tool calls never link to each other — the LLM
|
|
19
|
+
* chose all their args from the same prior context, before any of them ran.
|
|
20
|
+
*
|
|
21
|
+
* No core changes: it consumes the existing `agentfootprint.stream.tool_start`
|
|
22
|
+
* (args) and `agentfootprint.stream.tool_end` (result) emits. Attach via
|
|
23
|
+
* `.recorder(toolLineageRecorder())` and read `getLineage()` after the run; the
|
|
24
|
+
* lens (or any consumer) can render the returned graph.
|
|
25
|
+
*
|
|
26
|
+
* Convention 1 — one purpose: it derives ONE artifact (the lineage graph) from
|
|
27
|
+
* the emit channel. Convention 4 — run-scoped: it resets when a new run starts
|
|
28
|
+
* (the `pipelineId` changes).
|
|
29
|
+
*/
|
|
30
|
+
import type { EmitRecorder } from 'footprintjs';
|
|
31
|
+
/** A single tool invocation in the run. */
|
|
32
|
+
export interface ToolCallRef {
|
|
33
|
+
/** The execution-step id this tool call ran under. */
|
|
34
|
+
readonly runtimeStageId: string;
|
|
35
|
+
/** The provider tool-call id (stable per call). */
|
|
36
|
+
readonly toolCallId: string;
|
|
37
|
+
/** The tool's name. */
|
|
38
|
+
readonly toolName: string;
|
|
39
|
+
/** The ReAct iteration the call belongs to (0-based). */
|
|
40
|
+
readonly iteration: number;
|
|
41
|
+
}
|
|
42
|
+
/** A value-derived data dependency: `from`'s result value reappeared in `to`'s args. */
|
|
43
|
+
export interface ToolLineageEdge {
|
|
44
|
+
readonly from: ToolCallRef;
|
|
45
|
+
readonly to: ToolCallRef;
|
|
46
|
+
/** The distinctive value that links them. */
|
|
47
|
+
readonly value: string;
|
|
48
|
+
}
|
|
49
|
+
/** The tool→tool data-flow graph for one run. */
|
|
50
|
+
export interface ToolLineageGraph {
|
|
51
|
+
readonly nodes: readonly ToolCallRef[];
|
|
52
|
+
readonly edges: readonly ToolLineageEdge[];
|
|
53
|
+
}
|
|
54
|
+
export interface ToolLineageOptions {
|
|
55
|
+
/** Recorder id (idempotent-by-id when attached). Default `'tool-lineage'`. */
|
|
56
|
+
readonly id?: string;
|
|
57
|
+
/** Minimum string length for a value to be matchable. Default 4. */
|
|
58
|
+
readonly minValueLength?: number;
|
|
59
|
+
/** Also match numeric values. Default false (coincidental matches likely). */
|
|
60
|
+
readonly matchNumbers?: boolean;
|
|
61
|
+
/** Max recursion depth when flattening args/results. Default 6. */
|
|
62
|
+
readonly maxDepth?: number;
|
|
63
|
+
}
|
|
64
|
+
/** An EmitRecorder that also exposes the derived lineage graph. */
|
|
65
|
+
export interface ToolLineageRecorderHandle extends EmitRecorder {
|
|
66
|
+
/** The tool→tool data-flow graph derived so far. Safe to call during or after a run. */
|
|
67
|
+
getLineage(): ToolLineageGraph;
|
|
68
|
+
/** Reset all accumulated state. */
|
|
69
|
+
clear(): void;
|
|
70
|
+
}
|
|
71
|
+
export declare function toolLineageRecorder(options?: ToolLineageOptions): ToolLineageRecorderHandle;
|
|
72
|
+
//# sourceMappingURL=ToolLineageRecorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolLineageRecorder.d.ts","sourceRoot":"","sources":["../../../../src/recorders/observability/ToolLineageRecorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAa,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3D,2CAA2C;AAC3C,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,mDAAmD;IACnD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,uBAAuB;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,yDAAyD;IACzD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,wFAAwF;AACxF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC;IACzB,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;CAC5C;AAED,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,mEAAmE;AACnE,MAAM,WAAW,yBAA0B,SAAQ,YAAY;IAC7D,wFAAwF;IACxF,UAAU,IAAI,gBAAgB,CAAC;IAC/B,mCAAmC;IACnC,KAAK,IAAI,IAAI,CAAC;CACf;AAMD,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,kBAAuB,GAAG,yBAAyB,CAqG/F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentfootprint",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.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",
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
"@aws-sdk/client-xray": "*",
|
|
179
179
|
"@modelcontextprotocol/sdk": "*",
|
|
180
180
|
"@opentelemetry/api": "*",
|
|
181
|
-
"footprintjs": "^7.0.0",
|
|
181
|
+
"footprintjs": "^7.0.0 || ^8.0.0",
|
|
182
182
|
"ioredis": "*",
|
|
183
183
|
"openai": "*",
|
|
184
184
|
"zod": "*"
|
|
@@ -223,7 +223,7 @@
|
|
|
223
223
|
"esbuild": "^0.28.0",
|
|
224
224
|
"eslint": "^8.44.0",
|
|
225
225
|
"eslint-config-prettier": "^6.15.0",
|
|
226
|
-
"footprintjs": "^7.0.0",
|
|
226
|
+
"footprintjs": "^7.0.0 || ^8.0.0",
|
|
227
227
|
"prettier": "^2.8.1",
|
|
228
228
|
"typedoc": "^0.28.19",
|
|
229
229
|
"typedoc-plugin-markdown": "^4.11.0",
|