agentfootprint 7.17.0 → 7.19.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/AGENTS.md +1 -1
- package/CLAUDE.md +2 -2
- package/ai-instructions/claude-code/SKILL.md +1 -1
- package/dist/adapters/hosting/agentcore.js +23 -9
- package/dist/adapters/hosting/agentcore.js.map +1 -1
- package/dist/core/Agent.js +57 -2
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/RunnerBase.js +16 -1
- package/dist/core/RunnerBase.js.map +1 -1
- package/dist/core/agent/AgentBuilder.js +117 -1
- package/dist/core/agent/AgentBuilder.js.map +1 -1
- package/dist/core/agent/middleware/errors.js +54 -0
- package/dist/core/agent/middleware/errors.js.map +1 -0
- package/dist/core/agent/middleware/index.js +23 -0
- package/dist/core/agent/middleware/index.js.map +1 -0
- package/dist/core/agent/middleware/ledger.js +61 -0
- package/dist/core/agent/middleware/ledger.js.map +1 -0
- package/dist/core/agent/middleware/outcomes.js +66 -0
- package/dist/core/agent/middleware/outcomes.js.map +1 -0
- package/dist/core/agent/middleware/runChain.js +144 -0
- package/dist/core/agent/middleware/runChain.js.map +1 -0
- package/dist/core/agent/middleware/types.js +41 -0
- package/dist/core/agent/middleware/types.js.map +1 -0
- package/dist/core/agent/stages/prepareFinal.js +10 -0
- package/dist/core/agent/stages/prepareFinal.js.map +1 -1
- package/dist/core/agent/stages/route.js +62 -1
- package/dist/core/agent/stages/route.js.map +1 -1
- package/dist/core/agent/stages/seed.js +130 -85
- package/dist/core/agent/stages/seed.js.map +1 -1
- package/dist/core/agent/stages/toolCalls.js +208 -8
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/core/durabilityBarrier.js +68 -0
- package/dist/core/durabilityBarrier.js.map +1 -0
- package/dist/core/pause.js +19 -1
- package/dist/core/pause.js.map +1 -1
- package/dist/esm/adapters/hosting/agentcore.d.ts +4 -4
- package/dist/esm/adapters/hosting/agentcore.js +24 -10
- package/dist/esm/adapters/hosting/agentcore.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +9 -1
- package/dist/esm/core/Agent.js +58 -3
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/RunnerBase.js +16 -1
- package/dist/esm/core/RunnerBase.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.d.ts +97 -0
- package/dist/esm/core/agent/AgentBuilder.js +117 -1
- package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
- package/dist/esm/core/agent/buildAgentChart.d.ts +2 -2
- package/dist/esm/core/agent/middleware/errors.d.ts +51 -0
- package/dist/esm/core/agent/middleware/errors.js +50 -0
- package/dist/esm/core/agent/middleware/errors.js.map +1 -0
- package/dist/esm/core/agent/middleware/index.d.ts +16 -0
- package/dist/esm/core/agent/middleware/index.js +16 -0
- package/dist/esm/core/agent/middleware/index.js.map +1 -0
- package/dist/esm/core/agent/middleware/ledger.d.ts +40 -0
- package/dist/esm/core/agent/middleware/ledger.js +57 -0
- package/dist/esm/core/agent/middleware/ledger.js.map +1 -0
- package/dist/esm/core/agent/middleware/outcomes.d.ts +45 -0
- package/dist/esm/core/agent/middleware/outcomes.js +60 -0
- package/dist/esm/core/agent/middleware/outcomes.js.map +1 -0
- package/dist/esm/core/agent/middleware/runChain.d.ts +104 -0
- package/dist/esm/core/agent/middleware/runChain.js +139 -0
- package/dist/esm/core/agent/middleware/runChain.js.map +1 -0
- package/dist/esm/core/agent/middleware/types.d.ts +191 -0
- package/dist/esm/core/agent/middleware/types.js +40 -0
- package/dist/esm/core/agent/middleware/types.js.map +1 -0
- package/dist/esm/core/agent/stages/prepareFinal.d.ts +10 -0
- package/dist/esm/core/agent/stages/prepareFinal.js +10 -0
- package/dist/esm/core/agent/stages/prepareFinal.js.map +1 -1
- package/dist/esm/core/agent/stages/route.d.ts +29 -0
- package/dist/esm/core/agent/stages/route.js +60 -0
- package/dist/esm/core/agent/stages/route.js.map +1 -1
- package/dist/esm/core/agent/stages/seed.d.ts +16 -1
- package/dist/esm/core/agent/stages/seed.js +130 -85
- package/dist/esm/core/agent/stages/seed.js.map +1 -1
- package/dist/esm/core/agent/stages/toolCalls.d.ts +44 -0
- package/dist/esm/core/agent/stages/toolCalls.js +208 -8
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +18 -0
- package/dist/esm/core/durabilityBarrier.d.ts +61 -0
- package/dist/esm/core/durabilityBarrier.js +63 -0
- package/dist/esm/core/durabilityBarrier.js.map +1 -0
- package/dist/esm/core/pause.d.ts +42 -0
- package/dist/esm/core/pause.js +17 -0
- package/dist/esm/core/pause.js.map +1 -1
- package/dist/esm/events/dispatcher.d.ts +1 -1
- package/dist/esm/events/dispatcher.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +26 -0
- package/dist/esm/events/registry.d.ts +5 -1
- package/dist/esm/events/registry.js +4 -0
- package/dist/esm/events/registry.js.map +1 -1
- package/dist/esm/hosting/durability.d.ts +92 -0
- package/dist/esm/hosting/durability.js +174 -0
- package/dist/esm/hosting/durability.js.map +1 -0
- package/dist/esm/hosting/envelope.d.ts +75 -14
- package/dist/esm/hosting/envelope.js +141 -16
- package/dist/esm/hosting/envelope.js.map +1 -1
- package/dist/esm/hosting/errors.d.ts +60 -11
- package/dist/esm/hosting/errors.js +92 -18
- package/dist/esm/hosting/errors.js.map +1 -1
- package/dist/esm/hosting/httpHost.d.ts +17 -1
- package/dist/esm/hosting/httpHost.js +42 -6
- package/dist/esm/hosting/httpHost.js.map +1 -1
- package/dist/esm/hosting/index.d.ts +7 -4
- package/dist/esm/hosting/index.js +6 -3
- package/dist/esm/hosting/index.js.map +1 -1
- package/dist/esm/hosting/nodeHost.d.ts +4 -2
- package/dist/esm/hosting/nodeHost.js +14 -3
- package/dist/esm/hosting/nodeHost.js.map +1 -1
- package/dist/esm/hosting/standingAgent.d.ts +22 -7
- package/dist/esm/hosting/standingAgent.js +144 -32
- package/dist/esm/hosting/standingAgent.js.map +1 -1
- package/dist/esm/hosting/types.d.ts +193 -19
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +13 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/mcp/mcpServe.js +39 -6
- package/dist/esm/lib/mcp/mcpServe.js.map +1 -1
- package/dist/esm/lib/mcp/types.d.ts +16 -0
- package/dist/events/dispatcher.js.map +1 -1
- package/dist/events/registry.js +4 -0
- package/dist/events/registry.js.map +1 -1
- package/dist/hosting/durability.js +178 -0
- package/dist/hosting/durability.js.map +1 -0
- package/dist/hosting/envelope.js +146 -18
- package/dist/hosting/envelope.js.map +1 -1
- package/dist/hosting/errors.js +95 -19
- package/dist/hosting/errors.js.map +1 -1
- package/dist/hosting/httpHost.js +42 -6
- package/dist/hosting/httpHost.js.map +1 -1
- package/dist/hosting/index.js +10 -2
- package/dist/hosting/index.js.map +1 -1
- package/dist/hosting/nodeHost.js +14 -3
- package/dist/hosting/nodeHost.js.map +1 -1
- package/dist/hosting/standingAgent.js +142 -30
- package/dist/hosting/standingAgent.js.map +1 -1
- package/dist/index.js +31 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/mcp/mcpServe.js +39 -6
- package/dist/lib/mcp/mcpServe.js.map +1 -1
- package/dist/types/adapters/hosting/agentcore.d.ts +4 -4
- package/dist/types/adapters/hosting/agentcore.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +9 -1
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/RunnerBase.d.ts.map +1 -1
- package/dist/types/core/agent/AgentBuilder.d.ts +97 -0
- package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts +2 -2
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/middleware/errors.d.ts +52 -0
- package/dist/types/core/agent/middleware/errors.d.ts.map +1 -0
- package/dist/types/core/agent/middleware/index.d.ts +17 -0
- package/dist/types/core/agent/middleware/index.d.ts.map +1 -0
- package/dist/types/core/agent/middleware/ledger.d.ts +41 -0
- package/dist/types/core/agent/middleware/ledger.d.ts.map +1 -0
- package/dist/types/core/agent/middleware/outcomes.d.ts +46 -0
- package/dist/types/core/agent/middleware/outcomes.d.ts.map +1 -0
- package/dist/types/core/agent/middleware/runChain.d.ts +105 -0
- package/dist/types/core/agent/middleware/runChain.d.ts.map +1 -0
- package/dist/types/core/agent/middleware/types.d.ts +192 -0
- package/dist/types/core/agent/middleware/types.d.ts.map +1 -0
- package/dist/types/core/agent/stages/prepareFinal.d.ts +10 -0
- package/dist/types/core/agent/stages/prepareFinal.d.ts.map +1 -1
- package/dist/types/core/agent/stages/route.d.ts +29 -0
- package/dist/types/core/agent/stages/route.d.ts.map +1 -1
- package/dist/types/core/agent/stages/seed.d.ts +16 -1
- package/dist/types/core/agent/stages/seed.d.ts.map +1 -1
- package/dist/types/core/agent/stages/toolCalls.d.ts +44 -0
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +18 -0
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/durabilityBarrier.d.ts +62 -0
- package/dist/types/core/durabilityBarrier.d.ts.map +1 -0
- package/dist/types/core/pause.d.ts +42 -0
- package/dist/types/core/pause.d.ts.map +1 -1
- package/dist/types/events/dispatcher.d.ts +1 -1
- package/dist/types/events/dispatcher.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +26 -0
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/registry.d.ts +5 -1
- package/dist/types/events/registry.d.ts.map +1 -1
- package/dist/types/hosting/durability.d.ts +93 -0
- package/dist/types/hosting/durability.d.ts.map +1 -0
- package/dist/types/hosting/envelope.d.ts +75 -14
- package/dist/types/hosting/envelope.d.ts.map +1 -1
- package/dist/types/hosting/errors.d.ts +60 -11
- package/dist/types/hosting/errors.d.ts.map +1 -1
- package/dist/types/hosting/httpHost.d.ts +17 -1
- package/dist/types/hosting/httpHost.d.ts.map +1 -1
- package/dist/types/hosting/index.d.ts +7 -4
- package/dist/types/hosting/index.d.ts.map +1 -1
- package/dist/types/hosting/nodeHost.d.ts +4 -2
- package/dist/types/hosting/nodeHost.d.ts.map +1 -1
- package/dist/types/hosting/standingAgent.d.ts +22 -7
- package/dist/types/hosting/standingAgent.d.ts.map +1 -1
- package/dist/types/hosting/types.d.ts +193 -19
- package/dist/types/hosting/types.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/lib/mcp/mcpServe.d.ts.map +1 -1
- package/dist/types/lib/mcp/types.d.ts +16 -0
- package/dist/types/lib/mcp/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* middleware — PUBLIC barrel. The governance chain family.
|
|
3
|
+
*
|
|
4
|
+
* Two chains, one vocabulary:
|
|
5
|
+
*
|
|
6
|
+
* `.toolMiddleware(...)` wraps every tool dispatch
|
|
7
|
+
* `.messageMiddleware(...)` wraps the message boundary — the input
|
|
8
|
+
* before the model sees it, the output before
|
|
9
|
+
* the caller receives it
|
|
10
|
+
*
|
|
11
|
+
* Three verbs: `allow`, `deny`, `ask`. There is no fourth, and in
|
|
12
|
+
* particular there is no way to return a result — see `types.ts`.
|
|
13
|
+
*/
|
|
14
|
+
export { allow, ask, deny } from './outcomes.js';
|
|
15
|
+
export { MessageDeniedError, type MessageDeniedContext } from './errors.js';
|
|
16
|
+
export type { AllowOutcome, AskOutcome, AskPayload, DenyOutcome, MessageMiddleware, MessageMiddlewareContext, MessageOutcome, MiddlewareDecision, ToolMiddleware, ToolMiddlewareContext, ToolOutcome, } from './types.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* middleware — PUBLIC barrel. The governance chain family.
|
|
3
|
+
*
|
|
4
|
+
* Two chains, one vocabulary:
|
|
5
|
+
*
|
|
6
|
+
* `.toolMiddleware(...)` wraps every tool dispatch
|
|
7
|
+
* `.messageMiddleware(...)` wraps the message boundary — the input
|
|
8
|
+
* before the model sees it, the output before
|
|
9
|
+
* the caller receives it
|
|
10
|
+
*
|
|
11
|
+
* Three verbs: `allow`, `deny`, `ask`. There is no fourth, and in
|
|
12
|
+
* particular there is no way to return a result — see `types.ts`.
|
|
13
|
+
*/
|
|
14
|
+
export { allow, ask, deny } from './outcomes.js';
|
|
15
|
+
export { MessageDeniedError } from './errors.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/agent/middleware/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAA6B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* middleware/ledger — INTERNAL. Where a chain's decisions become record.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: one writer for one committed key.
|
|
5
|
+
* Role: core/ layer. `runChain` decides; this file is the only thing
|
|
6
|
+
* that commits what it decided and emits the matching event, so
|
|
7
|
+
* the three call sites cannot record the same fact three
|
|
8
|
+
* different ways.
|
|
9
|
+
* Emits: `agentfootprint.middleware.decision`, one per row.
|
|
10
|
+
*
|
|
11
|
+
* ## Why the original value is committed too
|
|
12
|
+
*
|
|
13
|
+
* A transform makes the trace and the wire disagree — the model saw one
|
|
14
|
+
* string, the run remembers another. Committing the pair, with the
|
|
15
|
+
* middleware's name and its `why` beside it, is what turns that
|
|
16
|
+
* disagreement from a lie into a record. Every slice taken afterwards can
|
|
17
|
+
* then find the moment the value changed and who changed it.
|
|
18
|
+
*
|
|
19
|
+
* This is not a redaction layer, and it is not trying to be one. For the
|
|
20
|
+
* `'input'` phase in particular, the ledger row is the ONLY copy of the
|
|
21
|
+
* pre-scrub text anywhere in the run — the seed stage commits the
|
|
22
|
+
* transformed message and nothing else ever holds the original. If your
|
|
23
|
+
* threat model says the original must not survive in the commit log,
|
|
24
|
+
* configure footprintjs redaction over this key; it scrubs `before` /
|
|
25
|
+
* `after` at write time and the row itself survives, so the run still says
|
|
26
|
+
* a scrub happened and who did it.
|
|
27
|
+
*/
|
|
28
|
+
import type { MiddlewareDecision } from './types.js';
|
|
29
|
+
/** The scope surface this file needs. Structurally a `TypedScope<AgentState>`. */
|
|
30
|
+
export interface LedgerScope {
|
|
31
|
+
middlewareDecisions?: readonly MiddlewareDecision[];
|
|
32
|
+
$emit(name: string, payload?: unknown): void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Append decision rows to the run's ledger and emit one event per row.
|
|
36
|
+
*
|
|
37
|
+
* No-op on an empty list, so an agent with no middleware never writes the
|
|
38
|
+
* key at all and its commit log is the one it always had.
|
|
39
|
+
*/
|
|
40
|
+
export declare function recordDecisions(scope: LedgerScope, rows: readonly MiddlewareDecision[]): void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* middleware/ledger — INTERNAL. Where a chain's decisions become record.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: one writer for one committed key.
|
|
5
|
+
* Role: core/ layer. `runChain` decides; this file is the only thing
|
|
6
|
+
* that commits what it decided and emits the matching event, so
|
|
7
|
+
* the three call sites cannot record the same fact three
|
|
8
|
+
* different ways.
|
|
9
|
+
* Emits: `agentfootprint.middleware.decision`, one per row.
|
|
10
|
+
*
|
|
11
|
+
* ## Why the original value is committed too
|
|
12
|
+
*
|
|
13
|
+
* A transform makes the trace and the wire disagree — the model saw one
|
|
14
|
+
* string, the run remembers another. Committing the pair, with the
|
|
15
|
+
* middleware's name and its `why` beside it, is what turns that
|
|
16
|
+
* disagreement from a lie into a record. Every slice taken afterwards can
|
|
17
|
+
* then find the moment the value changed and who changed it.
|
|
18
|
+
*
|
|
19
|
+
* This is not a redaction layer, and it is not trying to be one. For the
|
|
20
|
+
* `'input'` phase in particular, the ledger row is the ONLY copy of the
|
|
21
|
+
* pre-scrub text anywhere in the run — the seed stage commits the
|
|
22
|
+
* transformed message and nothing else ever holds the original. If your
|
|
23
|
+
* threat model says the original must not survive in the commit log,
|
|
24
|
+
* configure footprintjs redaction over this key; it scrubs `before` /
|
|
25
|
+
* `after` at write time and the row itself survives, so the run still says
|
|
26
|
+
* a scrub happened and who did it.
|
|
27
|
+
*/
|
|
28
|
+
import { typedEmit } from '../../../recorders/core/typedEmit.js';
|
|
29
|
+
/**
|
|
30
|
+
* Append decision rows to the run's ledger and emit one event per row.
|
|
31
|
+
*
|
|
32
|
+
* No-op on an empty list, so an agent with no middleware never writes the
|
|
33
|
+
* key at all and its commit log is the one it always had.
|
|
34
|
+
*/
|
|
35
|
+
export function recordDecisions(scope, rows) {
|
|
36
|
+
if (rows.length === 0)
|
|
37
|
+
return;
|
|
38
|
+
const prev = scope.middlewareDecisions ?? [];
|
|
39
|
+
// Spread into a plain local array first: a TypedScope array read is a live
|
|
40
|
+
// deep-proxy view, and both the commit and the event payloads below must be
|
|
41
|
+
// detached plain data (RFC-001 'clone' capture under deferred delivery).
|
|
42
|
+
scope.middlewareDecisions = [...prev, ...rows];
|
|
43
|
+
for (const row of rows) {
|
|
44
|
+
typedEmit(scope, 'agentfootprint.middleware.decision', {
|
|
45
|
+
middleware: row.middleware,
|
|
46
|
+
at: row.at,
|
|
47
|
+
...(row.phase !== undefined && { phase: row.phase }),
|
|
48
|
+
...(row.toolName !== undefined && { toolName: row.toolName }),
|
|
49
|
+
...(row.toolCallId !== undefined && { toolCallId: row.toolCallId }),
|
|
50
|
+
iteration: row.iteration,
|
|
51
|
+
outcome: row.outcome,
|
|
52
|
+
changed: row.changed,
|
|
53
|
+
...(row.why !== undefined && { why: row.why }),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=ledger.js.map
|
|
@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ACH,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* middleware/outcomes — PUBLIC. The three verbs a middleware speaks.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: Smart constructors over a closed union.
|
|
5
|
+
* Role: core/ layer. `allow` / `deny` / `ask` are the entire vocabulary
|
|
6
|
+
* of both chains, which is why they are short: they are written
|
|
7
|
+
* inside every middleware body, several times, and a governance
|
|
8
|
+
* rule reads better as `deny('writes to prod need a ticket')` than
|
|
9
|
+
* as a namespaced ceremony.
|
|
10
|
+
* Emits: N/A.
|
|
11
|
+
*
|
|
12
|
+
* The `allow` overloads carry a rule: you can pass the value through
|
|
13
|
+
* untouched with no explanation, but you cannot CHANGE it without one. A
|
|
14
|
+
* transform is the only thing here that makes the trace and the wire
|
|
15
|
+
* disagree, so it is the only thing required to say why.
|
|
16
|
+
*/
|
|
17
|
+
import type { AllowOutcome, AskOutcome, AskPayload, DenyOutcome } from './types.js';
|
|
18
|
+
/** Pass the value through untouched. */
|
|
19
|
+
export declare function allow(): AllowOutcome<never>;
|
|
20
|
+
/**
|
|
21
|
+
* Replace the value and say why.
|
|
22
|
+
*
|
|
23
|
+
* The `why` is mandatory and lands in the ledger next to the before/after
|
|
24
|
+
* pair, so a run that was scrubbed can be read back as a run that was
|
|
25
|
+
* scrubbed rather than as a run whose input was always that way.
|
|
26
|
+
*/
|
|
27
|
+
export declare function allow<T>(value: T, why: string): AllowOutcome<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Refuse the call.
|
|
30
|
+
*
|
|
31
|
+
* For a tool the reason reaches the model verbatim, as the tool's result,
|
|
32
|
+
* and the loop continues — the agent gets to adapt. For a message it
|
|
33
|
+
* surfaces as a `MessageDeniedError`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function deny(reason: string): DenyOutcome;
|
|
36
|
+
/**
|
|
37
|
+
* Suspend the run and put the question to a person. Tool dispatch only —
|
|
38
|
+
* `MessageOutcome` has no `ask` arm, so this cannot be returned from a
|
|
39
|
+
* message middleware.
|
|
40
|
+
*
|
|
41
|
+
* The answer is a decision, not a result: approve and the chain continues
|
|
42
|
+
* and the REAL tool runs; decline and it becomes a denial the model reads.
|
|
43
|
+
* A middleware never gets to write the answer itself.
|
|
44
|
+
*/
|
|
45
|
+
export declare function ask(payload: AskPayload): AskOutcome;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* middleware/outcomes — PUBLIC. The three verbs a middleware speaks.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: Smart constructors over a closed union.
|
|
5
|
+
* Role: core/ layer. `allow` / `deny` / `ask` are the entire vocabulary
|
|
6
|
+
* of both chains, which is why they are short: they are written
|
|
7
|
+
* inside every middleware body, several times, and a governance
|
|
8
|
+
* rule reads better as `deny('writes to prod need a ticket')` than
|
|
9
|
+
* as a namespaced ceremony.
|
|
10
|
+
* Emits: N/A.
|
|
11
|
+
*
|
|
12
|
+
* The `allow` overloads carry a rule: you can pass the value through
|
|
13
|
+
* untouched with no explanation, but you cannot CHANGE it without one. A
|
|
14
|
+
* transform is the only thing here that makes the trace and the wire
|
|
15
|
+
* disagree, so it is the only thing required to say why.
|
|
16
|
+
*/
|
|
17
|
+
export function allow(value, why) {
|
|
18
|
+
if (value === undefined)
|
|
19
|
+
return { kind: 'allow' };
|
|
20
|
+
if (typeof why !== 'string' || why.length === 0) {
|
|
21
|
+
throw new Error('allow(value, why): a transform must say why. Pass a short reason — it is what the ' +
|
|
22
|
+
'ledger shows next to the before/after pair. To pass the value through unchanged, ' +
|
|
23
|
+
'call allow() with no arguments.');
|
|
24
|
+
}
|
|
25
|
+
return { kind: 'allow', value, why };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Refuse the call.
|
|
29
|
+
*
|
|
30
|
+
* For a tool the reason reaches the model verbatim, as the tool's result,
|
|
31
|
+
* and the loop continues — the agent gets to adapt. For a message it
|
|
32
|
+
* surfaces as a `MessageDeniedError`.
|
|
33
|
+
*/
|
|
34
|
+
export function deny(reason) {
|
|
35
|
+
if (typeof reason !== 'string' || reason.length === 0) {
|
|
36
|
+
throw new Error('deny(reason): a refusal must carry a reason. For a tool it is the text the model ' +
|
|
37
|
+
'reads and adapts to, so write it for the model, not for a log line.');
|
|
38
|
+
}
|
|
39
|
+
return { kind: 'deny', reason };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Suspend the run and put the question to a person. Tool dispatch only —
|
|
43
|
+
* `MessageOutcome` has no `ask` arm, so this cannot be returned from a
|
|
44
|
+
* message middleware.
|
|
45
|
+
*
|
|
46
|
+
* The answer is a decision, not a result: approve and the chain continues
|
|
47
|
+
* and the REAL tool runs; decline and it becomes a denial the model reads.
|
|
48
|
+
* A middleware never gets to write the answer itself.
|
|
49
|
+
*/
|
|
50
|
+
export function ask(payload) {
|
|
51
|
+
if (payload === null ||
|
|
52
|
+
typeof payload !== 'object' ||
|
|
53
|
+
typeof payload.question !== 'string' ||
|
|
54
|
+
payload.question.length === 0) {
|
|
55
|
+
throw new Error('ask(payload): expected { question, detail? } with a non-empty question. The question ' +
|
|
56
|
+
'is what a person is shown when the run pauses.');
|
|
57
|
+
}
|
|
58
|
+
return { kind: 'ask', payload };
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=outcomes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcomes.js","sourceRoot":"","sources":["../../../../../src/core/agent/middleware/outcomes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAcH,MAAM,UAAU,KAAK,CAAI,KAAS,EAAE,GAAY;IAC9C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAClD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CACb,oFAAoF;YAClF,mFAAmF;YACnF,iCAAiC,CACpC,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AACvC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,MAAc;IACjC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CACb,mFAAmF;YACjF,qEAAqE,CACxE,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAClC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG,CAAC,OAAmB;IACrC,IACE,OAAO,KAAK,IAAI;QAChB,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ;QACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAC7B,CAAC;QACD,MAAM,IAAI,KAAK,CACb,uFAAuF;YACrF,gDAAgD,CACnD,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* middleware/runChain — INTERNAL. The one place a chain is walked.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: Chain of Responsibility driver.
|
|
5
|
+
* Role: core/ layer. Both stages (tool dispatch, message boundary) and
|
|
6
|
+
* the MCP server call in here, so the ordering law, the
|
|
7
|
+
* throw-is-a-denial law and the ledger row shape are written once
|
|
8
|
+
* and cannot drift between the three callers.
|
|
9
|
+
* Emits: N/A — it RETURNS rows; the caller commits and emits them, so a
|
|
10
|
+
* middleware still never touches scope.
|
|
11
|
+
*
|
|
12
|
+
* ## The rules this file implements
|
|
13
|
+
*
|
|
14
|
+
* **Order is declaration order.** The chain is walked front to back, and
|
|
15
|
+
* each link is handed the previous link's output — so a scrubber placed
|
|
16
|
+
* first is a scrubber every later rule sees the effect of.
|
|
17
|
+
*
|
|
18
|
+
* **The first non-allow answer wins.** A deny or an ask stops the walk;
|
|
19
|
+
* the links behind it do not run. There is no "second opinion" pass,
|
|
20
|
+
* because a refusal that a later middleware could overturn is not a
|
|
21
|
+
* refusal.
|
|
22
|
+
*
|
|
23
|
+
* **A middleware that throws is a denial, never a pass.** The thrown
|
|
24
|
+
* message becomes the reason. This is the same deny-by-default the
|
|
25
|
+
* permission gate has always applied to a checker that throws: a
|
|
26
|
+
* governance layer whose failure mode is "allow" is not a governance
|
|
27
|
+
* layer.
|
|
28
|
+
*/
|
|
29
|
+
import type { LLMMessage } from '../../../adapters/types.js';
|
|
30
|
+
import type { MemoryIdentity } from '../../../memory/identity/types.js';
|
|
31
|
+
import type { AskPayload, MessageMiddleware, MiddlewareDecision, ToolMiddleware } from './types.js';
|
|
32
|
+
/** Tool args, as they travel the chain. */
|
|
33
|
+
export type ToolArgs = Readonly<Record<string, unknown>>;
|
|
34
|
+
/**
|
|
35
|
+
* What to do when a middleware answers `ask` somewhere that cannot pause.
|
|
36
|
+
*
|
|
37
|
+
* `'pause'` — the caller will checkpoint (the normal dispatch path).
|
|
38
|
+
* `'refuse'` — the ask is converted into a deny naming the middleware. Used
|
|
39
|
+
* on the resume path (footprintjs's `PausableHandler.resume` returns void,
|
|
40
|
+
* so a resumed dispatch cannot suspend a second time) and by `mcpServe`
|
|
41
|
+
* (MCP is request/response — there is no pause to carry the ask).
|
|
42
|
+
*/
|
|
43
|
+
export type AskPolicy = 'pause' | 'refuse';
|
|
44
|
+
export type ToolChainResult = {
|
|
45
|
+
readonly kind: 'allow';
|
|
46
|
+
readonly args: ToolArgs;
|
|
47
|
+
readonly decisions: MiddlewareDecision[];
|
|
48
|
+
} | {
|
|
49
|
+
readonly kind: 'deny';
|
|
50
|
+
readonly reason: string;
|
|
51
|
+
readonly middleware: string;
|
|
52
|
+
readonly args: ToolArgs;
|
|
53
|
+
readonly decisions: MiddlewareDecision[];
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: 'ask';
|
|
56
|
+
readonly payload: AskPayload;
|
|
57
|
+
readonly middleware: string;
|
|
58
|
+
/** Index of the link that asked — resume continues from `index + 1`. */
|
|
59
|
+
readonly index: number;
|
|
60
|
+
/** Args as transformed up to the ask. These ride the checkpoint. */
|
|
61
|
+
readonly args: ToolArgs;
|
|
62
|
+
readonly decisions: MiddlewareDecision[];
|
|
63
|
+
};
|
|
64
|
+
export interface ToolChainInput {
|
|
65
|
+
readonly toolName: string;
|
|
66
|
+
readonly toolCallId: string;
|
|
67
|
+
readonly iteration: number;
|
|
68
|
+
readonly args: ToolArgs;
|
|
69
|
+
readonly history: readonly LLMMessage[];
|
|
70
|
+
readonly identity?: MemoryIdentity;
|
|
71
|
+
readonly signal?: AbortSignal;
|
|
72
|
+
/**
|
|
73
|
+
* Where to start walking. `0` for a fresh dispatch; `n` on resume, to
|
|
74
|
+
* continue the chain AFTER the link that asked without re-running the
|
|
75
|
+
* links whose decisions the checkpoint already carries.
|
|
76
|
+
*/
|
|
77
|
+
readonly startIndex?: number;
|
|
78
|
+
readonly askPolicy?: AskPolicy;
|
|
79
|
+
}
|
|
80
|
+
/** Walk the tool chain. Never throws — a throwing link becomes a denial. */
|
|
81
|
+
export declare function runToolChain(chain: readonly ToolMiddleware[], input: ToolChainInput): Promise<ToolChainResult>;
|
|
82
|
+
export type MessageChainResult = {
|
|
83
|
+
readonly kind: 'allow';
|
|
84
|
+
readonly content: string;
|
|
85
|
+
readonly decisions: MiddlewareDecision[];
|
|
86
|
+
} | {
|
|
87
|
+
readonly kind: 'deny';
|
|
88
|
+
readonly reason: string;
|
|
89
|
+
readonly middleware: string;
|
|
90
|
+
/** Content as transformed by the links BEFORE the refusal. */
|
|
91
|
+
readonly content: string;
|
|
92
|
+
readonly decisions: MiddlewareDecision[];
|
|
93
|
+
};
|
|
94
|
+
export interface MessageChainInput {
|
|
95
|
+
readonly phase: 'input' | 'output';
|
|
96
|
+
readonly content: string;
|
|
97
|
+
readonly history: readonly LLMMessage[];
|
|
98
|
+
/** ReAct iteration for the ledger row. `0` at `'input'` (before iter 1). */
|
|
99
|
+
readonly iteration: number;
|
|
100
|
+
readonly identity?: MemoryIdentity;
|
|
101
|
+
readonly signal?: AbortSignal;
|
|
102
|
+
}
|
|
103
|
+
/** Walk the message chain. Never throws — a throwing link becomes a denial. */
|
|
104
|
+
export declare function runMessageChain(chain: readonly MessageMiddleware[], input: MessageChainInput): Promise<MessageChainResult>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* middleware/runChain — INTERNAL. The one place a chain is walked.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: Chain of Responsibility driver.
|
|
5
|
+
* Role: core/ layer. Both stages (tool dispatch, message boundary) and
|
|
6
|
+
* the MCP server call in here, so the ordering law, the
|
|
7
|
+
* throw-is-a-denial law and the ledger row shape are written once
|
|
8
|
+
* and cannot drift between the three callers.
|
|
9
|
+
* Emits: N/A — it RETURNS rows; the caller commits and emits them, so a
|
|
10
|
+
* middleware still never touches scope.
|
|
11
|
+
*
|
|
12
|
+
* ## The rules this file implements
|
|
13
|
+
*
|
|
14
|
+
* **Order is declaration order.** The chain is walked front to back, and
|
|
15
|
+
* each link is handed the previous link's output — so a scrubber placed
|
|
16
|
+
* first is a scrubber every later rule sees the effect of.
|
|
17
|
+
*
|
|
18
|
+
* **The first non-allow answer wins.** A deny or an ask stops the walk;
|
|
19
|
+
* the links behind it do not run. There is no "second opinion" pass,
|
|
20
|
+
* because a refusal that a later middleware could overturn is not a
|
|
21
|
+
* refusal.
|
|
22
|
+
*
|
|
23
|
+
* **A middleware that throws is a denial, never a pass.** The thrown
|
|
24
|
+
* message becomes the reason. This is the same deny-by-default the
|
|
25
|
+
* permission gate has always applied to a checker that throws: a
|
|
26
|
+
* governance layer whose failure mode is "allow" is not a governance
|
|
27
|
+
* layer.
|
|
28
|
+
*/
|
|
29
|
+
/** Walk the tool chain. Never throws — a throwing link becomes a denial. */
|
|
30
|
+
export async function runToolChain(chain, input) {
|
|
31
|
+
const decisions = [];
|
|
32
|
+
const askPolicy = input.askPolicy ?? 'pause';
|
|
33
|
+
let args = input.args;
|
|
34
|
+
for (let i = input.startIndex ?? 0; i < chain.length; i++) {
|
|
35
|
+
const mw = chain[i];
|
|
36
|
+
const row = (extra) => ({
|
|
37
|
+
middleware: mw.name,
|
|
38
|
+
at: 'tool',
|
|
39
|
+
toolName: input.toolName,
|
|
40
|
+
toolCallId: input.toolCallId,
|
|
41
|
+
iteration: input.iteration,
|
|
42
|
+
outcome: 'allow',
|
|
43
|
+
changed: false,
|
|
44
|
+
...extra,
|
|
45
|
+
});
|
|
46
|
+
let outcome;
|
|
47
|
+
try {
|
|
48
|
+
outcome = await mw.onToolCall({
|
|
49
|
+
toolName: input.toolName,
|
|
50
|
+
toolCallId: input.toolCallId,
|
|
51
|
+
iteration: input.iteration,
|
|
52
|
+
args,
|
|
53
|
+
history: input.history,
|
|
54
|
+
...(input.identity && { identity: input.identity }),
|
|
55
|
+
...(input.signal && { signal: input.signal }),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
const reason = `middleware '${mw.name}' threw: ${err instanceof Error ? err.message : String(err)}`;
|
|
60
|
+
decisions.push(row({ outcome: 'deny', why: reason }));
|
|
61
|
+
return { kind: 'deny', reason, middleware: mw.name, args, decisions };
|
|
62
|
+
}
|
|
63
|
+
if (outcome.kind === 'deny') {
|
|
64
|
+
decisions.push(row({ outcome: 'deny', why: outcome.reason }));
|
|
65
|
+
return { kind: 'deny', reason: outcome.reason, middleware: mw.name, args, decisions };
|
|
66
|
+
}
|
|
67
|
+
if (outcome.kind === 'ask') {
|
|
68
|
+
if (askPolicy === 'refuse') {
|
|
69
|
+
const reason = `middleware '${mw.name}' asked a person to decide, and there is no pause here to ` +
|
|
70
|
+
`carry that ask: ${outcome.payload.question}`;
|
|
71
|
+
decisions.push(row({ outcome: 'deny', why: reason }));
|
|
72
|
+
return { kind: 'deny', reason, middleware: mw.name, args, decisions };
|
|
73
|
+
}
|
|
74
|
+
decisions.push(row({ outcome: 'ask', why: outcome.payload.question }));
|
|
75
|
+
return {
|
|
76
|
+
kind: 'ask',
|
|
77
|
+
payload: outcome.payload,
|
|
78
|
+
middleware: mw.name,
|
|
79
|
+
index: i,
|
|
80
|
+
args,
|
|
81
|
+
decisions,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (outcome.value !== undefined) {
|
|
85
|
+
const before = args;
|
|
86
|
+
args = outcome.value;
|
|
87
|
+
decisions.push(row({ changed: true, ...(outcome.why && { why: outcome.why }), before, after: args }));
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
decisions.push(row({}));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return { kind: 'allow', args, decisions };
|
|
94
|
+
}
|
|
95
|
+
/** Walk the message chain. Never throws — a throwing link becomes a denial. */
|
|
96
|
+
export async function runMessageChain(chain, input) {
|
|
97
|
+
const decisions = [];
|
|
98
|
+
let content = input.content;
|
|
99
|
+
for (const mw of chain) {
|
|
100
|
+
const row = (extra) => ({
|
|
101
|
+
middleware: mw.name,
|
|
102
|
+
at: 'message',
|
|
103
|
+
phase: input.phase,
|
|
104
|
+
iteration: input.iteration,
|
|
105
|
+
outcome: 'allow',
|
|
106
|
+
changed: false,
|
|
107
|
+
...extra,
|
|
108
|
+
});
|
|
109
|
+
let outcome;
|
|
110
|
+
try {
|
|
111
|
+
outcome = await mw.onMessage({
|
|
112
|
+
phase: input.phase,
|
|
113
|
+
content,
|
|
114
|
+
history: input.history,
|
|
115
|
+
...(input.identity && { identity: input.identity }),
|
|
116
|
+
...(input.signal && { signal: input.signal }),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
const reason = `middleware '${mw.name}' threw: ${err instanceof Error ? err.message : String(err)}`;
|
|
121
|
+
decisions.push(row({ outcome: 'deny', why: reason }));
|
|
122
|
+
return { kind: 'deny', reason, middleware: mw.name, content, decisions };
|
|
123
|
+
}
|
|
124
|
+
if (outcome.kind === 'deny') {
|
|
125
|
+
decisions.push(row({ outcome: 'deny', why: outcome.reason }));
|
|
126
|
+
return { kind: 'deny', reason: outcome.reason, middleware: mw.name, content, decisions };
|
|
127
|
+
}
|
|
128
|
+
if (outcome.value !== undefined) {
|
|
129
|
+
const before = content;
|
|
130
|
+
content = outcome.value;
|
|
131
|
+
decisions.push(row({ changed: true, ...(outcome.why && { why: outcome.why }), before, after: content }));
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
decisions.push(row({}));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return { kind: 'allow', content, decisions };
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=runChain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runChain.js","sourceRoot":"","sources":["../../../../../src/core/agent/middleware/runChain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAgEH,4EAA4E;AAC5E,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,KAAgC,EAChC,KAAqB;IAErB,MAAM,SAAS,GAAyB,EAAE,CAAC;IAC3C,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,OAAO,CAAC;IAC7C,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IAEtB,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,UAAU,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1D,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACrB,MAAM,GAAG,GAAG,CAAC,KAAkC,EAAsB,EAAE,CAAC,CAAC;YACvE,UAAU,EAAE,EAAE,CAAC,IAAI;YACnB,EAA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