agentfootprint 2.11.5 → 2.12.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/README.md +57 -79
- package/dist/core/Agent.js +59 -3
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/stages/toolCalls.js +91 -22
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/core/slots/buildToolsSlot.js +101 -33
- package/dist/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/esm/core/Agent.js +59 -3
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/stages/toolCalls.js +91 -22
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/core/slots/buildToolsSlot.js +101 -33
- package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/esm/events/registry.js +8 -0
- package/dist/esm/events/registry.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/recorders/core/ToolsRecorder.js +23 -0
- package/dist/esm/recorders/core/ToolsRecorder.js.map +1 -0
- package/dist/esm/security/PolicyHaltError.js +61 -0
- package/dist/esm/security/PolicyHaltError.js.map +1 -0
- package/dist/esm/security/extractSequence.js +101 -0
- package/dist/esm/security/extractSequence.js.map +1 -0
- package/dist/esm/security/index.js +2 -0
- package/dist/esm/security/index.js.map +1 -1
- package/dist/esm/tool-providers/gatedTools.js +8 -3
- package/dist/esm/tool-providers/gatedTools.js.map +1 -1
- package/dist/events/registry.js +8 -0
- package/dist/events/registry.js.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/recorders/core/ToolsRecorder.js +27 -0
- package/dist/recorders/core/ToolsRecorder.js.map +1 -0
- package/dist/security/PolicyHaltError.js +65 -0
- package/dist/security/PolicyHaltError.js.map +1 -0
- package/dist/security/extractSequence.js +105 -0
- package/dist/security/extractSequence.js.map +1 -0
- package/dist/security/index.js +6 -1
- package/dist/security/index.js.map +1 -1
- package/dist/tool-providers/gatedTools.js +8 -3
- package/dist/tool-providers/gatedTools.js.map +1 -1
- package/dist/types/adapters/types.d.ts +89 -2
- package/dist/types/adapters/types.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/stages/toolCalls.d.ts +8 -0
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +17 -0
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/slots/buildToolsSlot.d.ts +24 -4
- package/dist/types/core/slots/buildToolsSlot.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +62 -1
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/registry.d.ts +9 -1
- package/dist/types/events/registry.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/recorders/core/ToolsRecorder.d.ts +19 -0
- package/dist/types/recorders/core/ToolsRecorder.d.ts.map +1 -0
- package/dist/types/security/PolicyHaltError.d.ts +73 -0
- package/dist/types/security/PolicyHaltError.d.ts.map +1 -0
- package/dist/types/security/extractSequence.d.ts +47 -0
- package/dist/types/security/extractSequence.d.ts.map +1 -0
- package/dist/types/security/index.d.ts +5 -1
- package/dist/types/security/index.d.ts.map +1 -1
- package/dist/types/tool-providers/gatedTools.d.ts.map +1 -1
- package/dist/types/tool-providers/types.d.ts +43 -7
- package/dist/types/tool-providers/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { flowChart } from 'footprintjs';
|
|
14
14
|
import { INJECTION_KEYS } from '../../conventions.js';
|
|
15
15
|
import { COMPOSITION_KEYS } from '../../recorders/core/types.js';
|
|
16
|
+
import { typedEmit } from '../../recorders/core/typedEmit.js';
|
|
16
17
|
import { composeSlot, fnv1a, truncate } from './helpers.js';
|
|
17
18
|
/**
|
|
18
19
|
* Build the Tools slot subflow.
|
|
@@ -27,16 +28,94 @@ export function buildToolsSlot(config) {
|
|
|
27
28
|
const budgetCap = config.budgetCap ?? 2000;
|
|
28
29
|
const tools = config.tools;
|
|
29
30
|
const toolProvider = config.toolProvider;
|
|
30
|
-
|
|
31
|
+
const providerToolCache = config.providerToolCache;
|
|
32
|
+
// Stage 1 — Discover: consult the external ToolProvider (if any) and
|
|
33
|
+
// resolve its Tool[] for this iteration. ALWAYS runs (even when no
|
|
34
|
+
// provider) so the trace shape is consistent across agents — the
|
|
35
|
+
// no-provider path early-returns in microseconds. When a provider IS
|
|
36
|
+
// set, this stage owns the entire async-discovery boundary:
|
|
37
|
+
//
|
|
38
|
+
// • own runtimeStageId (e.g., `sf-tools/discover#7`) so KeyedRecorder
|
|
39
|
+
// and SequenceRecorder can scope per-discovery latency / errors
|
|
40
|
+
// • own InOutRecorder boundary (entry/exit pair)
|
|
41
|
+
// • own narrative entry separating "I called the hub" from "I built
|
|
42
|
+
// the slot"
|
|
43
|
+
// • emits `tools.discovery_started`, `tools.discovery_completed` (or
|
|
44
|
+
// `tools.discovery_failed`) with timing + provider id
|
|
45
|
+
//
|
|
46
|
+
// Sync providers still pay zero microtask overhead — the dynamic
|
|
47
|
+
// `instanceof Promise` check skips await for non-Promise returns.
|
|
48
|
+
const discoverStage = async (scope) => {
|
|
49
|
+
if (!toolProvider)
|
|
50
|
+
return; // No-op fast path: keeps trace shape consistent.
|
|
51
|
+
const args = scope.$getArgs();
|
|
52
|
+
const iteration = args.iteration ?? 1;
|
|
53
|
+
const env = scope.$getEnv();
|
|
54
|
+
const activatedIds = scope.$getValue('activatedInjectionIds') ?? [];
|
|
55
|
+
const identity = scope.$getValue('runIdentity');
|
|
56
|
+
const ctx = {
|
|
57
|
+
iteration,
|
|
58
|
+
...(activatedIds.length > 0 && { activeSkillId: activatedIds[activatedIds.length - 1] }),
|
|
59
|
+
...(identity && { identity }),
|
|
60
|
+
...(env.signal && { signal: env.signal }),
|
|
61
|
+
};
|
|
62
|
+
typedEmit(scope, 'agentfootprint.tools.discovery_started', {
|
|
63
|
+
providerId: toolProvider.id,
|
|
64
|
+
iteration,
|
|
65
|
+
});
|
|
66
|
+
const startMs = Date.now();
|
|
67
|
+
let visibleTools;
|
|
68
|
+
try {
|
|
69
|
+
// Dynamic check — sync providers skip the await microtask.
|
|
70
|
+
const result = toolProvider.list(ctx);
|
|
71
|
+
visibleTools = result instanceof Promise ? await result : result;
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
// Discovery failure is loud by design. Emit the typed event
|
|
75
|
+
// with the providerId so consumers can route alerts; then
|
|
76
|
+
// re-throw so a configured `reliability` rule decides whether
|
|
77
|
+
// to retry / fall back / fail-fast. Silently dropping tools
|
|
78
|
+
// mid-conversation creates non-deterministic agent behavior
|
|
79
|
+
// harder to debug than a crash.
|
|
80
|
+
const errMessage = err instanceof Error ? err.message : String(err);
|
|
81
|
+
const errName = err instanceof Error ? err.name : 'Error';
|
|
82
|
+
typedEmit(scope, 'agentfootprint.tools.discovery_failed', {
|
|
83
|
+
providerId: toolProvider.id,
|
|
84
|
+
error: errMessage,
|
|
85
|
+
errorName: errName,
|
|
86
|
+
iteration,
|
|
87
|
+
durationMs: Date.now() - startMs,
|
|
88
|
+
});
|
|
89
|
+
throw err;
|
|
90
|
+
}
|
|
91
|
+
typedEmit(scope, 'agentfootprint.tools.discovery_completed', {
|
|
92
|
+
providerId: toolProvider.id,
|
|
93
|
+
iteration,
|
|
94
|
+
durationMs: Date.now() - startMs,
|
|
95
|
+
toolCount: visibleTools.length,
|
|
96
|
+
});
|
|
97
|
+
// Cache the resolved Tool[] in the closure-shared ProviderToolCache.
|
|
98
|
+
// The Compose stage reads providerSchemas from here; the toolCalls
|
|
99
|
+
// handler reads the executable Tool objects on dispatch. Both share
|
|
100
|
+
// ONE list() call per iteration. The cache lives outside scope
|
|
101
|
+
// because Tool objects carry `execute` functions that can't be
|
|
102
|
+
// `structuredClone`d into the transactional memory layer.
|
|
103
|
+
if (providerToolCache)
|
|
104
|
+
providerToolCache.current = visibleTools;
|
|
105
|
+
};
|
|
106
|
+
// Stage 2 — Compose: merges static + provider + per-skill schemas
|
|
107
|
+
// into the tool slot. Pure compute, sync, fast. Reads provider tools
|
|
108
|
+
// from `providerToolCache.current` populated by the Discover stage.
|
|
109
|
+
const composeStage = (scope) => {
|
|
31
110
|
const args = scope.$getArgs();
|
|
32
111
|
const iteration = args.iteration ?? 1;
|
|
33
112
|
const injections = tools.map((t, i) => {
|
|
34
113
|
const summary = `${t.name}: ${t.description}`;
|
|
35
114
|
// `source: 'registry'` — tools configured at build time via
|
|
36
|
-
// `.tool(...)` are baseline API flow (the static tool list
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
115
|
+
// `.tool(...)` are baseline API flow (the static tool list sent
|
|
116
|
+
// to the LLM), NOT context engineering. Skills / Instructions
|
|
117
|
+
// that gate tools dynamically tag their injections with their
|
|
118
|
+
// flavor below.
|
|
40
119
|
return {
|
|
41
120
|
contentSummary: truncate(summary, 80),
|
|
42
121
|
contentHash: fnv1a(`tool:${t.name}:${t.description}`),
|
|
@@ -48,23 +127,9 @@ export function buildToolsSlot(config) {
|
|
|
48
127
|
position: i,
|
|
49
128
|
};
|
|
50
129
|
});
|
|
51
|
-
// Block A5/Neo follow-up: when an external `ToolProvider` is
|
|
52
|
-
// configured, consult it per iteration. Closure-held in
|
|
53
|
-
// `toolProvider` since scope can't carry functions. The provider
|
|
54
|
-
// sees `{ iteration, activeSkillId, identity }` so dynamic
|
|
55
|
-
// chains (`gatedTools`, `skillScopedTools`) react to the
|
|
56
|
-
// current activation state.
|
|
57
130
|
const providerSchemas = [];
|
|
58
|
-
if (toolProvider) {
|
|
59
|
-
const
|
|
60
|
-
const identity = scope.$getValue('runIdentity');
|
|
61
|
-
const ctx = {
|
|
62
|
-
iteration,
|
|
63
|
-
...(activatedIds.length > 0 && { activeSkillId: activatedIds[activatedIds.length - 1] }),
|
|
64
|
-
...(identity && { identity }),
|
|
65
|
-
};
|
|
66
|
-
const visibleTools = toolProvider.list(ctx);
|
|
67
|
-
for (const t of visibleTools) {
|
|
131
|
+
if (toolProvider && providerToolCache) {
|
|
132
|
+
for (const t of providerToolCache.current) {
|
|
68
133
|
const schema = t.schema;
|
|
69
134
|
providerSchemas.push(schema);
|
|
70
135
|
const summary = `${schema.name}: ${schema.description}`;
|
|
@@ -80,8 +145,8 @@ export function buildToolsSlot(config) {
|
|
|
80
145
|
});
|
|
81
146
|
}
|
|
82
147
|
}
|
|
83
|
-
// Active Injections targeting the tools slot (Skills with
|
|
84
|
-
//
|
|
148
|
+
// Active Injections targeting the tools slot (Skills with tools=[…]).
|
|
149
|
+
// Filter activeInjections by `inject.tools`.
|
|
85
150
|
const activeInjections = scope.$getValue('activeInjections') ?? [];
|
|
86
151
|
const dynamicSchemas = [];
|
|
87
152
|
for (const inj of activeInjections) {
|
|
@@ -106,17 +171,17 @@ export function buildToolsSlot(config) {
|
|
|
106
171
|
}
|
|
107
172
|
scope.$setValue(INJECTION_KEYS.TOOLS, injections);
|
|
108
173
|
// Merge schemas from all three sources, deduping by tool name.
|
|
109
|
-
// Order: static .tool() registry FIRST (auto-attached read_skill
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
174
|
+
// Order: static .tool() registry FIRST (auto-attached read_skill /
|
|
175
|
+
// list_skills land here when `.skills(registry)` is wired), then
|
|
176
|
+
// external `.toolProvider()` output, then per-skill inject.tools.
|
|
177
|
+
// First occurrence wins.
|
|
113
178
|
//
|
|
114
179
|
// Why dedupe matters: Neo wires `gatedTools(staticTools([listSkills,
|
|
115
|
-
// readSkill]), policy.isAllowed)` AND calls `.skills(registry)`
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
180
|
+
// readSkill]), policy.isAllowed)` AND calls `.skills(registry)` —
|
|
181
|
+
// the framework auto-attaches its own `read_skill` from the skill
|
|
182
|
+
// registry, AND the consumer's toolProvider emits one too. Without
|
|
183
|
+
// dedupe both reach the LLM and Anthropic rejects the request:
|
|
184
|
+
// "tools: Tool names must be unique."
|
|
120
185
|
const seen = new Set();
|
|
121
186
|
const merged = [];
|
|
122
187
|
for (const t of [...tools, ...providerSchemas, ...dynamicSchemas]) {
|
|
@@ -127,6 +192,9 @@ export function buildToolsSlot(config) {
|
|
|
127
192
|
}
|
|
128
193
|
scope.toolSchemas = merged;
|
|
129
194
|
scope.$setValue(COMPOSITION_KEYS.SLOT_COMPOSED, composeSlot('tools', iteration, injections, budgetCap, toolProvider ? 'registry+provider+injections' : 'registry+injections'));
|
|
130
|
-
}
|
|
195
|
+
};
|
|
196
|
+
return flowChart('Discover', discoverStage, 'discover', undefined, 'Discover provider tools')
|
|
197
|
+
.addFunction('Compose', composeStage, 'compose', 'Compose tools slot')
|
|
198
|
+
.build();
|
|
131
199
|
}
|
|
132
200
|
//# sourceMappingURL=buildToolsSlot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildToolsSlot.js","sourceRoot":"","sources":["../../../../src/core/slots/buildToolsSlot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"buildToolsSlot.js","sourceRoot":"","sources":["../../../../src/core/slots/buildToolsSlot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAG9D,OAAO,EAAE,WAAW,EAAE,KAA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B,KAAK,CAAC,SAAS,CACb,gBAAgB,CAAC,aAAa,EAC9B,WAAW,CACT,OAAO,EACP,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,qBAAqB,CACtE,CACF,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,SAAS,CACd,UAAU,EACV,aAAa,EACb,UAAU,EACV,SAAS,EACT,yBAAyB,CAC1B;SACE,WAAW,CAAC,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,oBAAoB,CAAC;SACrE,KAAK,EAAE,CAAC;AACb,CAAC"}
|
|
@@ -58,6 +58,9 @@ export const EVENT_NAMES = {
|
|
|
58
58
|
offered: 'agentfootprint.tools.offered',
|
|
59
59
|
activated: 'agentfootprint.tools.activated',
|
|
60
60
|
deactivated: 'agentfootprint.tools.deactivated',
|
|
61
|
+
discoveryStarted: 'agentfootprint.tools.discovery_started',
|
|
62
|
+
discoveryCompleted: 'agentfootprint.tools.discovery_completed',
|
|
63
|
+
discoveryFailed: 'agentfootprint.tools.discovery_failed',
|
|
61
64
|
},
|
|
62
65
|
skill: {
|
|
63
66
|
activated: 'agentfootprint.skill.activated',
|
|
@@ -67,6 +70,7 @@ export const EVENT_NAMES = {
|
|
|
67
70
|
check: 'agentfootprint.permission.check',
|
|
68
71
|
gateOpened: 'agentfootprint.permission.gate_opened',
|
|
69
72
|
gateClosed: 'agentfootprint.permission.gate_closed',
|
|
73
|
+
halt: 'agentfootprint.permission.halt',
|
|
70
74
|
},
|
|
71
75
|
risk: {
|
|
72
76
|
flagged: 'agentfootprint.risk.flagged',
|
|
@@ -130,11 +134,15 @@ export const ALL_EVENT_TYPES = [
|
|
|
130
134
|
'agentfootprint.tools.offered',
|
|
131
135
|
'agentfootprint.tools.activated',
|
|
132
136
|
'agentfootprint.tools.deactivated',
|
|
137
|
+
'agentfootprint.tools.discovery_started',
|
|
138
|
+
'agentfootprint.tools.discovery_completed',
|
|
139
|
+
'agentfootprint.tools.discovery_failed',
|
|
133
140
|
'agentfootprint.skill.activated',
|
|
134
141
|
'agentfootprint.skill.deactivated',
|
|
135
142
|
'agentfootprint.permission.check',
|
|
136
143
|
'agentfootprint.permission.gate_opened',
|
|
137
144
|
'agentfootprint.permission.gate_closed',
|
|
145
|
+
'agentfootprint.permission.halt',
|
|
138
146
|
'agentfootprint.risk.flagged',
|
|
139
147
|
'agentfootprint.fallback.triggered',
|
|
140
148
|
'agentfootprint.cost.tick',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/events/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/events/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAyDH,yEAAyE;AACzE,sEAAsE;AACtE,wEAAwE;AACxE,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,WAAW,EAAE;QACX,KAAK,EAAE,kCAAkC;QACzC,IAAI,EAAE,iCAAiC;QACvC,SAAS,EAAE,uCAAuC;QAClD,cAAc,EAAE,4CAA4C;QAC5D,QAAQ,EAAE,sCAAsC;QAChD,YAAY,EAAE,0CAA0C;QACxD,cAAc,EAAE,4CAA4C;QAC5D,aAAa,EAAE,2CAA2C;KAC3D;IACD,KAAK,EAAE;QACL,SAAS,EAAE,iCAAiC;QAC5C,OAAO,EAAE,+BAA+B;QACxC,cAAc,EAAE,sCAAsC;QACtD,YAAY,EAAE,oCAAoC;QAClD,YAAY,EAAE,oCAAoC;QAClD,OAAO,EAAE,8BAA8B;KACxC;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,iCAAiC;QAC3C,MAAM,EAAE,+BAA+B;QACvC,KAAK,EAAE,6BAA6B;QACpC,SAAS,EAAE,kCAAkC;QAC7C,OAAO,EAAE,gCAAgC;KAC1C;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,iC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AsC;IACtC,0CAA0C;IAC1C,4CAA4C;IAC5C,2CAA2C;IAC3C,iCAAiC;IACjC,+BAA+B;IAC/B,sCAAsC;IACtC,oCAAoC;IACpC,oCAAoC;IACpC,8BAA8B;IAC9B,iCAAiC;IACjC,+BAA+B;IAC/B,6BAA6B;IAC7B,kCAAkC;IAClC,gCAAgC;IAChC,iCAAiC;IACjC,gCAAgC;IAChC,sCAAsC;IACtC,wCAAwC;IACxC,wCAAwC;IACxC,gCAAgC;IAChC,gCAAgC;IAChC,+BAA+B;IAC/B,8BAA8B;IAC9B,gCAAgC;IAChC,kCAAkC;IAClC,wCAAwC;IACxC,0CAA0C;IAC1C,uCAAuC;IACvC,gCAAgC;IAChC,kCAAkC;IAClC,iCAAiC;IACjC,uCAAuC;IACvC,uCAAuC;IACvC,gCAAgC;IAChC,6BAA6B;IAC7B,mCAAmC;IACnC,0BAA0B;IAC1B,+BAA+B;IAC/B,2BAA2B;IAC3B,uCAAuC;IACvC,8BAA8B;IAC9B,gCAAgC;IAChC,4BAA4B;IAC5B,8BAA8B;IAC9B,6BAA6B;IAC7B,oCAAoC;CAC5B,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -45,6 +45,7 @@ export { permissionRecorder, } from './recorders/core/PermissionRecorder.js';
|
|
|
45
45
|
export { evalRecorder } from './recorders/core/EvalRecorder.js';
|
|
46
46
|
export { memoryRecorder } from './recorders/core/MemoryRecorder.js';
|
|
47
47
|
export { skillRecorder } from './recorders/core/SkillRecorder.js';
|
|
48
|
+
export { toolsRecorder } from './recorders/core/ToolsRecorder.js';
|
|
48
49
|
export { typedEmit } from './recorders/core/typedEmit.js';
|
|
49
50
|
export { RunnerBase, makeRunId } from './core/RunnerBase.js';
|
|
50
51
|
// Pause/Resume primitives — consumer API for human-in-the-loop tools.
|
|
@@ -162,7 +163,7 @@ export { staticTools, gatedTools, skillScopedTools, } from './tool-providers/ind
|
|
|
162
163
|
// Cross-cutting authorization (v2.5+). `agentfootprint/security` is the
|
|
163
164
|
// dedicated subpath; the root barrel also re-exports `PermissionPolicy`
|
|
164
165
|
// so existing v2.4 consumers find it at the top level.
|
|
165
|
-
export { PermissionPolicy, } from './security/index.js';
|
|
166
|
+
export { PermissionPolicy, PolicyHaltError, } from './security/index.js';
|
|
166
167
|
// Message Catalog Pattern (v2.5+). `agentfootprint/locales` is the
|
|
167
168
|
// dedicated subpath; the root barrel also re-exports the helpers so
|
|
168
169
|
// existing v2.4 consumers find them at the top level.
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oEAAoE;AACpE,8DAA8D;AAC9D,uEAAuE;AACvE,kEAAkE;AAClE,sEAAsE;AACtE,sDAAsD;AACtD,OAAO,8CAA8C,CAAC;AACtD,OAAO,2CAA2C,CAAC;AACnD,OAAO,4CAA4C,CAAC;AAsCpD,qCAAqC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EACL,WAAW,EACX,eAAe,GAIhB,MAAM,sBAAsB,CAAC;AAE9B,aAAa;AACb,OAAO,EACL,eAAe,GAQhB,MAAM,wBAAwB,CAAC;AAEhC,6BAA6B;AAC7B,cAAc,qBAAqB,CAAC;AAEpC,yEAAyE;AACzE,uDAAuD;AACvD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,GAEf,MAAM,kBAAkB,CAAC;AAC1B,oEAAoE;AACpE,yEAAyE;AACzE,wEAAwE;AACxE,qEAAqE;AACrE,kDAAkD;AAClD,OAAO,EACL,gBAAgB,GAMjB,MAAM,2BAA2B,CAAC;AAEnC,gBAAgB;AAChB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAmB,MAAM,uBAAuB,CAAC;AAE1F,iBAAiB;AACjB,OAAO,EAAE,eAAe,EAA+B,MAAM,qCAAqC,CAAC;AACnG,OAAO,EACL,k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AAwE;AACxE,sEAAsE;AACtE,sEAAsE;AACtE,OAAO,EACL,SAAS,EAET,cAAc,GAGf,MAAM,oBAAoB,CAAC;AAE5B,kEAAkE;AAClE,sEAAsE;AACtE,sEAAsE;AACtE,6BAA6B;AAC7B,OAAO,EACL,SAAS,EACT,aAAa,GASd,MAAM,oBAAoB,CAAC;AAE5B,wEAAwE;AACxE,qEAAqE;AACrE,mEAAmE;AACnE,sEAAsE;AACtE,sEAAsE;AACtE,OAAO,EACL,WAAW,EACX,UAAU,EACV,gBAAgB,GAIjB,MAAM,2BAA2B,CAAC;AAEnC,wEAAwE;AACxE,wEAAwE;AACxE,uDAAuD;AACvD,OAAO,EACL,gBAAgB,EAChB,eAAe,GAIhB,MAAM,qBAAqB,CAAC;AAE7B,mEAAmE;AACnE,oEAAoE;AACpE,sDAAsD;AACtD,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,GAEjB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolsRecorder — forwards `agentfootprint.tools.*` emits to the dispatcher.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: Factory over EmitBridge.
|
|
5
|
+
* Role: Bridges tool-domain events. Today: discovery_failed (emitted by
|
|
6
|
+
* buildToolsSlot when an external `ToolProvider.list(ctx)` throws
|
|
7
|
+
* or rejects). The other tools.* events (offered/activated/
|
|
8
|
+
* deactivated) are declared in the registry for consumer code
|
|
9
|
+
* that wants to emit them; the same prefix bridge forwards all
|
|
10
|
+
* of them.
|
|
11
|
+
* Emits: agentfootprint.tools.offered / tools.activated / tools.deactivated
|
|
12
|
+
* / tools.discovery_failed
|
|
13
|
+
*/
|
|
14
|
+
import { EmitBridge } from './EmitBridge.js';
|
|
15
|
+
export function toolsRecorder(options) {
|
|
16
|
+
return new EmitBridge({
|
|
17
|
+
id: options.id ?? 'agentfootprint.tools-recorder',
|
|
18
|
+
prefix: 'agentfootprint.tools.',
|
|
19
|
+
dispatcher: options.dispatcher,
|
|
20
|
+
getRunContext: options.getRunContext,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=ToolsRecorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolsRecorder.js","sourceRoot":"","sources":["../../../../src/recorders/core/ToolsRecorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAMrE,MAAM,UAAU,aAAa,CAAC,OAA6B;IACzD,OAAO,IAAI,UAAU,CAAC;QACpB,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,+BAA+B;QACjD,MAAM,EAAE,uBAAuB;QAC/B,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,aAAa,EAAE,OAAO,CAAC,aAAa;KACrC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PolicyHaltError — typed error thrown by `Agent.run()` when a
|
|
3
|
+
* `PermissionChecker.check()` returns `{ result: 'halt', ... }`.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: Typed Error (parallel to `ReliabilityFailFastError`).
|
|
6
|
+
* Role: Surface layer for sequence governance / security halts —
|
|
7
|
+
* terminates the run cleanly with full forensic context so
|
|
8
|
+
* callers can route alerts (PagerDuty / Slack / dashboard)
|
|
9
|
+
* based on the rule that fired.
|
|
10
|
+
* Emits: N/A (this file DEFINES the error class; the corresponding
|
|
11
|
+
* observability event `agentfootprint.permission.halt` fires
|
|
12
|
+
* from the toolCalls handler at the moment the halt resolves).
|
|
13
|
+
*
|
|
14
|
+
* Strict ordering on halt — the framework guarantees:
|
|
15
|
+
* 1. Synthetic `tool_result` (with `tellLLM` content) appended to
|
|
16
|
+
* `scope.history` so the Anthropic / OpenAI tool_use ↔ tool_result
|
|
17
|
+
* pairing protocol is satisfied.
|
|
18
|
+
* 2. `agentfootprint.permission.halt` event emitted.
|
|
19
|
+
* 3. Stage commits (commitLog has the entry; runtimeStageId is
|
|
20
|
+
* complete).
|
|
21
|
+
* 4. THEN this error is thrown by `Agent.run()`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* try {
|
|
25
|
+
* await agent.run({ message: 'help me with order #42' });
|
|
26
|
+
* } catch (e) {
|
|
27
|
+
* if (e instanceof PolicyHaltError) {
|
|
28
|
+
* console.log(`HALT: rule='${e.reason}' iteration=${e.iteration}`);
|
|
29
|
+
* console.log(`Sequence: ${e.sequence.map(c => c.name).join(' → ')}`);
|
|
30
|
+
* if (e.reason.startsWith('security:')) {
|
|
31
|
+
* await pagerDuty.notify(e);
|
|
32
|
+
* }
|
|
33
|
+
* } else {
|
|
34
|
+
* throw e;
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
*/
|
|
38
|
+
export class PolicyHaltError extends Error {
|
|
39
|
+
code = 'ERR_POLICY_HALT';
|
|
40
|
+
reason;
|
|
41
|
+
tellLLM;
|
|
42
|
+
sequence;
|
|
43
|
+
iteration;
|
|
44
|
+
history;
|
|
45
|
+
proposed;
|
|
46
|
+
checkerId;
|
|
47
|
+
constructor(ctx) {
|
|
48
|
+
super(`Policy halt: ${ctx.reason} (tool='${ctx.proposed.name}', iteration=${ctx.iteration})`);
|
|
49
|
+
this.name = 'PolicyHaltError';
|
|
50
|
+
this.reason = ctx.reason;
|
|
51
|
+
if (ctx.tellLLM !== undefined)
|
|
52
|
+
this.tellLLM = ctx.tellLLM;
|
|
53
|
+
this.sequence = ctx.sequence;
|
|
54
|
+
this.iteration = ctx.iteration;
|
|
55
|
+
this.history = ctx.history;
|
|
56
|
+
this.proposed = ctx.proposed;
|
|
57
|
+
if (ctx.checkerId !== undefined)
|
|
58
|
+
this.checkerId = ctx.checkerId;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=PolicyHaltError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PolicyHaltError.js","sourceRoot":"","sources":["../../../src/security/PolicyHaltError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAsBH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,GAAG,iBAA0B,CAAC;IAClC,MAAM,CAAS;IACf,OAAO,CAAqB;IAC5B,QAAQ,CAA2B;IACnC,SAAS,CAAS;IAClB,OAAO,CAAwB;IAC/B,QAAQ,CAAoD;IAC5D,SAAS,CAAU;IAE5B,YAAY,GAAsB;QAChC,KAAK,CAAC,gBAAgB,GAAG,CAAC,MAAM,WAAW,GAAG,CAAC,QAAQ,CAAC,IAAI,gBAAgB,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC;QAC9F,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QACzB,IAAI,GAAG,CAAC,OAAO,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC1D,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC7B,IAAI,GAAG,CAAC,SAAS,KAAK,SAAS;YAAE,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAClE,CAAC;CACF"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* extractSequence — derive the in-flight tool-call sequence from
|
|
3
|
+
* `scope.history` for `PermissionChecker.check()`.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: Pure function over conversation history.
|
|
6
|
+
* Role: Single source of truth — sequence is reconstructed on
|
|
7
|
+
* demand from `LLMMessage[]` instead of maintained as
|
|
8
|
+
* parallel state in scope. Survives `agent.resumeOnError`
|
|
9
|
+
* correctly because the history IS the durable artifact.
|
|
10
|
+
* Emits: N/A (pure compute).
|
|
11
|
+
*
|
|
12
|
+
* The sequence reads the assistant turns' `toolCalls` blocks in order.
|
|
13
|
+
* Calls that were denied at the gate (synthetic tool_results in history
|
|
14
|
+
* but no `tool.execute()` invocation) are NOT included — the sequence
|
|
15
|
+
* reflects what actually dispatched, not what was attempted.
|
|
16
|
+
*
|
|
17
|
+
* Detection of "did this call dispatch?" — we look at the matching
|
|
18
|
+
* `tool` message and check its content. Synthetic deny messages match
|
|
19
|
+
* a known prefix; everything else is a real dispatch. This pairs the
|
|
20
|
+
* sender (assistant.toolCalls[i].id) with the receiver (tool.toolCallId).
|
|
21
|
+
*/
|
|
22
|
+
/** Prefix the framework writes on synthetic deny tool_results. Used to
|
|
23
|
+
* distinguish "denied but in history" from "actually dispatched". */
|
|
24
|
+
export const SYNTHETIC_DENY_PREFIX = '[permission denied:';
|
|
25
|
+
/**
|
|
26
|
+
* Walk `history` in order, collect each dispatched tool call into the
|
|
27
|
+
* sequence. Only calls that produced a non-denied tool_result are
|
|
28
|
+
* included.
|
|
29
|
+
*
|
|
30
|
+
* @param history Conversation history at check time.
|
|
31
|
+
* @param iteration Current ReAct iteration (used to tag the proposed
|
|
32
|
+
* call's iteration if you append it).
|
|
33
|
+
* @param options Optional resolver for `providerId`.
|
|
34
|
+
* @returns The dispatched-call sequence, in chronological order.
|
|
35
|
+
*/
|
|
36
|
+
export function extractSequence(history, iteration, options = {}) {
|
|
37
|
+
const sequence = [];
|
|
38
|
+
const resolveProviderId = options.resolveProviderId;
|
|
39
|
+
// Walk history once and map every tool message by toolCallId so we
|
|
40
|
+
// know:
|
|
41
|
+
// • which proposed calls actually dispatched (have a tool_result
|
|
42
|
+
// in history) vs are still in-flight from the current turn
|
|
43
|
+
// (no tool_result yet)
|
|
44
|
+
// • which dispatches were synthetic denies (filtered out — they
|
|
45
|
+
// never executed)
|
|
46
|
+
// A call is in the sequence only if BOTH a tool_result exists AND
|
|
47
|
+
// it isn't a synthetic deny.
|
|
48
|
+
const toolMsgsByCallId = new Map();
|
|
49
|
+
for (const msg of history) {
|
|
50
|
+
if (msg.role === 'tool' && msg.toolCallId) {
|
|
51
|
+
const content = typeof msg.content === 'string' ? msg.content : '';
|
|
52
|
+
toolMsgsByCallId.set(msg.toolCallId, content);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Track iteration as we walk: each assistant turn with toolCalls
|
|
56
|
+
// increments the iteration counter for the entries it produces. The
|
|
57
|
+
// exact iteration mapping is approximate because we don't store it
|
|
58
|
+
// per-message, but the sequence ORDER is what matters for governance
|
|
59
|
+
// — iteration is an informational hint.
|
|
60
|
+
let iterCounter = 1;
|
|
61
|
+
for (const msg of history) {
|
|
62
|
+
if (msg.role !== 'assistant' || !msg.toolCalls || msg.toolCalls.length === 0)
|
|
63
|
+
continue;
|
|
64
|
+
for (const tc of msg.toolCalls) {
|
|
65
|
+
if (!tc.id)
|
|
66
|
+
continue;
|
|
67
|
+
const toolMsg = toolMsgsByCallId.get(tc.id);
|
|
68
|
+
if (toolMsg === undefined)
|
|
69
|
+
continue; // no tool_result yet → in-flight
|
|
70
|
+
if (toolMsg.startsWith(SYNTHETIC_DENY_PREFIX))
|
|
71
|
+
continue; // denied, never ran
|
|
72
|
+
const entry = {
|
|
73
|
+
name: tc.name,
|
|
74
|
+
args: tc.args,
|
|
75
|
+
iteration: iterCounter,
|
|
76
|
+
...(resolveProviderId && {
|
|
77
|
+
providerId: resolveProviderId(tc.name) ?? 'local',
|
|
78
|
+
}),
|
|
79
|
+
};
|
|
80
|
+
sequence.push(entry);
|
|
81
|
+
}
|
|
82
|
+
iterCounter += 1;
|
|
83
|
+
}
|
|
84
|
+
// The iteration we report on the LAST entries should reflect the
|
|
85
|
+
// current ReAct iteration so policies that key on iteration count
|
|
86
|
+
// see consistent values.
|
|
87
|
+
if (sequence.length > 0 && iteration > iterCounter - 1) {
|
|
88
|
+
// Patch the last batch's iteration to current. Approximation —
|
|
89
|
+
// good enough for sequence-pattern matching, which is the use case.
|
|
90
|
+
const lastEntry = sequence[sequence.length - 1];
|
|
91
|
+
const lastIter = lastEntry ? lastEntry.iteration : 0;
|
|
92
|
+
for (let i = sequence.length - 1; i >= 0; i--) {
|
|
93
|
+
const entry = sequence[i];
|
|
94
|
+
if (!entry || entry.iteration !== lastIter)
|
|
95
|
+
break;
|
|
96
|
+
entry.iteration = iteration;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return sequence;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=extractSequence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractSequence.js","sourceRoot":"","sources":["../../../src/security/extractSequence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH;sEACsE;AACtE,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AAY3D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC7B,OAA8B,EAC9B,SAAiB,EACjB,UAAkC,EAAE;IAEpC,MAAM,QAAQ,GAAoB,EAAE,CAAC;IACrC,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAEpD,mEAAmE;IACnE,QAAQ;IACR,mEAAmE;IACnE,+DAA+D;IAC/D,2BAA2B;IAC3B,kEAAkE;IAClE,sBAAsB;IACtB,kEAAkE;IAClE,6BAA6B;IAC7B,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;IACnD,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;YAC1C,MAAM,OAAO,GAAG,OAAO,GAAG,CA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AAG,CAAC,IAAI,SAAS,GAAG,WAAW,GAAG,CAAC,EAAE,CAAC;QACvD,+DAA+D;QAC/D,oEAAoE;QACpE,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9C,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,KAAK,QAAQ;gBAAE,MAAM;YACjD,KAA+C,CAAC,SAAS,GAAG,SAAS,CAAC;QACzE,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -35,4 +35,6 @@
|
|
|
35
35
|
* const agent = Agent.create({ provider, model, permissionChecker: policy }).build();
|
|
36
36
|
*/
|
|
37
37
|
export { PermissionPolicy } from './PermissionPolicy.js';
|
|
38
|
+
export { PolicyHaltError } from './PolicyHaltError.js';
|
|
39
|
+
export { extractSequence, SYNTHETIC_DENY_PREFIX } from './extractSequence.js';
|
|
38
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -38,13 +38,18 @@ export function gatedTools(inner, predicate) {
|
|
|
38
38
|
id: 'gated',
|
|
39
39
|
list(ctx) {
|
|
40
40
|
// Pull from the inner provider first; each recomputation sees
|
|
41
|
-
// the freshest state from any nested gates.
|
|
42
|
-
|
|
41
|
+
// the freshest state from any nested gates. Inner may be sync
|
|
42
|
+
// or async — we mirror what we get back so a sync chain stays
|
|
43
|
+
// sync (zero microtask overhead) and an async chain stays
|
|
44
|
+
// async (no premature `Promise.resolve` wrapping).
|
|
45
|
+
const innerResult = inner.list(ctx);
|
|
46
|
+
const filter = (innerTools) =>
|
|
43
47
|
// Filter by predicate — tool name from `tool.schema.name`.
|
|
44
48
|
// Predicates throwing escape: a buggy predicate should crash
|
|
45
49
|
// loudly, not silently allow tools through. Per the
|
|
46
50
|
// permission-as-defense-in-depth principle.
|
|
47
|
-
|
|
51
|
+
innerTools.filter((t) => predicate(t.schema.name, ctx));
|
|
52
|
+
return innerResult instanceof Promise ? innerResult.then(filter) : filter(innerResult);
|
|
48
53
|
},
|
|
49
54
|
};
|
|
50
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gatedTools.js","sourceRoot":"","sources":["../../../src/tool-providers/gatedTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;
|
|
1
|
+
{"version":3,"file":"gatedTools.js","sourceRoot":"","sources":["../../../src/tool-providers/gatedTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAKH,qBAAqB;AACrB,MAAM,UAAU,UAAU,CAAC,KAAmB,EAAE,SAA4B;IAC1E,OAAO;QACL,EAAE,EAAE,OAAO;QACX,IAAI,CAAC,GAAwB;YAC3B,8DAA8D;YAC9D,8DAA8D;YAC9D,8DAA8D;YAC9D,0DAA0D;YAC1D,mDAAmD;YACnD,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACpC,MAAM,MAAM,GAAG,CAAC,UAA2B,EAAmB,EAAE;YAC9D,2DAA2D;YAC3D,6DAA6D;YAC7D,oDAAoD;YACpD,4CAA4C;YAC5C,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YAC1D,OAAO,WAAW,YAAY,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACzF,CAAC;KACF,CAAC;AACJ,CAAC;AACD,wBAAwB"}
|
package/dist/events/registry.js
CHANGED
|
@@ -61,6 +61,9 @@ exports.EVENT_NAMES = {
|
|
|
61
61
|
offered: 'agentfootprint.tools.offered',
|
|
62
62
|
activated: 'agentfootprint.tools.activated',
|
|
63
63
|
deactivated: 'agentfootprint.tools.deactivated',
|
|
64
|
+
discoveryStarted: 'agentfootprint.tools.discovery_started',
|
|
65
|
+
discoveryCompleted: 'agentfootprint.tools.discovery_completed',
|
|
66
|
+
discoveryFailed: 'agentfootprint.tools.discovery_failed',
|
|
64
67
|
},
|
|
65
68
|
skill: {
|
|
66
69
|
activated: 'agentfootprint.skill.activated',
|
|
@@ -70,6 +73,7 @@ exports.EVENT_NAMES = {
|
|
|
70
73
|
check: 'agentfootprint.permission.check',
|
|
71
74
|
gateOpened: 'agentfootprint.permission.gate_opened',
|
|
72
75
|
gateClosed: 'agentfootprint.permission.gate_closed',
|
|
76
|
+
halt: 'agentfootprint.permission.halt',
|
|
73
77
|
},
|
|
74
78
|
risk: {
|
|
75
79
|
flagged: 'agentfootprint.risk.flagged',
|
|
@@ -133,11 +137,15 @@ exports.ALL_EVENT_TYPES = [
|
|
|
133
137
|
'agentfootprint.tools.offered',
|
|
134
138
|
'agentfootprint.tools.activated',
|
|
135
139
|
'agentfootprint.tools.deactivated',
|
|
140
|
+
'agentfootprint.tools.discovery_started',
|
|
141
|
+
'agentfootprint.tools.discovery_completed',
|
|
142
|
+
'agentfootprint.tools.discovery_failed',
|
|
136
143
|
'agentfootprint.skill.activated',
|
|
137
144
|
'agentfootprint.skill.deactivated',
|
|
138
145
|
'agentfootprint.permission.check',
|
|
139
146
|
'agentfootprint.permission.gate_opened',
|
|
140
147
|
'agentfootprint.permission.gate_closed',
|
|
148
|
+
'agentfootprint.permission.halt',
|
|
141
149
|
'agentfootprint.risk.flagged',
|
|
142
150
|
'agentfootprint.fallback.triggered',
|
|
143
151
|
'agentfootprint.cost.tick',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/events/registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/events/registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAyDH,yEAAyE;AACzE,sEAAsE;AACtE,wEAAwE;AAC3D,QAAA,WAAW,GAAG;IACzB,WAAW,EAAE;QACX,KAAK,EAAE,kCAAkC;QACzC,IAAI,EAAE,iCAAiC;QACvC,SAAS,EAAE,uCAAuC;QAClD,cAAc,EAAE,4CAA4C;QAC5D,QAAQ,EAAE,sCAAsC;QAChD,YAAY,EAAE,0CAA0C;QACxD,cAAc,EAAE,4CAA4C;QAC5D,aAAa,EAAE,2CAA2C;KAC3D;IACD,KAAK,EAAE;QACL,SAAS,EAAE,iCAAiC;QAC5C,OAAO,EAAE,+BAA+B;QACxC,cAAc,EAAE,sCAAsC;QACtD,YAAY,EAAE,oCAAoC;QAClD,YAAY,EAAE,oCAAo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