@adia-ai/agent 0.8.28 → 0.8.30
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/CHANGELOG.md +45 -0
- package/README.md +384 -11
- package/agent.d.ts +44 -3
- package/agent.d.ts.map +1 -1
- package/agent.js +172 -8
- package/agent.js.map +1 -1
- package/events.d.ts +46 -2
- package/events.d.ts.map +1 -1
- package/events.js +30 -1
- package/events.js.map +1 -1
- package/guardrail.d.ts +68 -0
- package/guardrail.d.ts.map +1 -0
- package/guardrail.js +79 -0
- package/guardrail.js.map +1 -0
- package/index.d.ts +15 -7
- package/index.d.ts.map +1 -1
- package/index.js +7 -3
- package/index.js.map +1 -1
- package/integrations.d.ts +19 -2
- package/integrations.d.ts.map +1 -1
- package/integrations.js +6 -1
- package/integrations.js.map +1 -1
- package/loop.d.ts +19 -8
- package/loop.d.ts.map +1 -1
- package/loop.js +176 -9
- package/loop.js.map +1 -1
- package/mcp-transport.d.ts +128 -0
- package/mcp-transport.d.ts.map +1 -0
- package/mcp-transport.js +361 -0
- package/mcp-transport.js.map +1 -0
- package/mcp.d.ts +120 -0
- package/mcp.d.ts.map +1 -0
- package/mcp.js +264 -0
- package/mcp.js.map +1 -0
- package/package.json +1 -1
- package/resource.d.ts +28 -3
- package/resource.d.ts.map +1 -1
- package/resource.js +43 -5
- package/resource.js.map +1 -1
- package/session.d.ts +18 -0
- package/session.d.ts.map +1 -1
- package/session.js +40 -0
- package/session.js.map +1 -1
- package/stub.d.ts +8 -0
- package/stub.d.ts.map +1 -1
- package/stub.js +13 -0
- package/stub.js.map +1 -1
- package/tools.d.ts +6 -0
- package/tools.d.ts.map +1 -1
- package/tools.js.map +1 -1
- package/trace.d.ts +50 -0
- package/trace.d.ts.map +1 -0
- package/trace.js +60 -0
- package/trace.js.map +1 -0
- package/workflow.d.ts +113 -11
- package/workflow.d.ts.map +1 -1
- package/workflow.js +93 -15
- package/workflow.js.map +1 -1
package/agent.js
CHANGED
|
@@ -19,7 +19,11 @@ import { composeSystem } from './prompt.js';
|
|
|
19
19
|
import { attachLayers, resourceTools } from './resource.js';
|
|
20
20
|
import { createSession } from './session.js';
|
|
21
21
|
import { frameClientMessage, shouldRunTurn } from './frame.js';
|
|
22
|
+
import { defineGuardrail } from './guardrail.js';
|
|
22
23
|
import { runLoop } from './loop.js';
|
|
24
|
+
import { assertUniqueToolNames, connectMcpSource, } from './mcp.js';
|
|
25
|
+
import { McpConnectionError } from './mcp-transport.js';
|
|
26
|
+
import { createTracer } from './trace.js';
|
|
23
27
|
import { runWorkflow } from './workflow.js';
|
|
24
28
|
const DEFAULT_MAX_TOOL_ROUNDS = 8;
|
|
25
29
|
export function createAgent(config) {
|
|
@@ -43,12 +47,107 @@ export function createAgent(config) {
|
|
|
43
47
|
return _resolved;
|
|
44
48
|
}
|
|
45
49
|
const layers = config.prompt ?? [];
|
|
46
|
-
const
|
|
47
|
-
const
|
|
50
|
+
const declaredResources = config.resources ?? [];
|
|
51
|
+
const declaredTools = [...(config.tools ?? []), ...resourceTools(declaredResources)];
|
|
48
52
|
const workflows = new Map((config.workflows ?? []).map(w => [w.name, w]));
|
|
49
53
|
const maxToolRounds = config.maxToolRounds ?? DEFAULT_MAX_TOOL_ROUNDS;
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
// MCP sources: one memoized connect for the agent's lifetime. A rejection
|
|
55
|
+
// is NOT cached as a permanent verdict — the next turn retries, because a
|
|
56
|
+
// server that was down at 10:00 may be up at 10:01 and an agent that
|
|
57
|
+
// poisoned itself over one failed fetch is worse than one that retries.
|
|
58
|
+
const sources = config.integrations ?? [];
|
|
59
|
+
let connected = [];
|
|
60
|
+
let connecting = null;
|
|
61
|
+
// Bumped by close(). A connect that finishes after its generation went
|
|
62
|
+
// stale must not install itself: otherwise close() returns, the sessions
|
|
63
|
+
// look shut, and a moment later a late resolve quietly reopens the agent
|
|
64
|
+
// with connections nobody is going to close.
|
|
65
|
+
let generation = 0;
|
|
66
|
+
async function closeAll(servers) {
|
|
67
|
+
await Promise.all(servers.map(server => server.connection.close().catch(() => { })));
|
|
68
|
+
}
|
|
69
|
+
// Trace records produced while connecting, waiting for a turn to carry
|
|
70
|
+
// them onto the event stream. The SINK already saw them at record time;
|
|
71
|
+
// this is only about the second consumer, the stream.
|
|
72
|
+
const pendingTrace = [];
|
|
73
|
+
async function ensureConnected(sessionId, signal) {
|
|
74
|
+
if (!sources.length)
|
|
75
|
+
return [];
|
|
76
|
+
if (connected.length === sources.length)
|
|
77
|
+
return connected;
|
|
78
|
+
if (!connecting) {
|
|
79
|
+
const tracer = createTracer(config.trace, sessionId);
|
|
80
|
+
const note = (name, data) => {
|
|
81
|
+
const record = tracer.record('mcp', name, data);
|
|
82
|
+
if (record)
|
|
83
|
+
pendingTrace.push(record);
|
|
84
|
+
};
|
|
85
|
+
const startedGeneration = generation;
|
|
86
|
+
connecting = (async () => {
|
|
87
|
+
const results = [];
|
|
88
|
+
try {
|
|
89
|
+
for (const source of sources) {
|
|
90
|
+
const startedAt = Date.now();
|
|
91
|
+
try {
|
|
92
|
+
const server = await connectMcpSource(source, signal ? { signal } : {});
|
|
93
|
+
results.push(server);
|
|
94
|
+
note('connect', {
|
|
95
|
+
url: server.url,
|
|
96
|
+
server: server.serverInfo.name,
|
|
97
|
+
protocol: server.protocolVersion,
|
|
98
|
+
tools: server.tools.length,
|
|
99
|
+
resources: server.resources.length,
|
|
100
|
+
ms: Date.now() - startedAt,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
note('connect:failed', {
|
|
105
|
+
url: source.url,
|
|
106
|
+
error: err.message,
|
|
107
|
+
ms: Date.now() - startedAt,
|
|
108
|
+
});
|
|
109
|
+
throw err;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
assertUniqueToolNames([...declaredTools, ...results.flatMap(s => s.toolDefs)]);
|
|
113
|
+
if (startedGeneration !== generation) {
|
|
114
|
+
// close() ran while we were connecting. Nobody wants these.
|
|
115
|
+
throw new McpConnectionError('the agent was closed while connecting');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
// Source B failed after source A shook hands: A's session is open,
|
|
120
|
+
// referenced by nothing, and about to be forgotten. Shut it.
|
|
121
|
+
await closeAll(results);
|
|
122
|
+
throw err;
|
|
123
|
+
}
|
|
124
|
+
connected = results;
|
|
125
|
+
return results;
|
|
126
|
+
})().finally(() => { connecting = null; });
|
|
127
|
+
}
|
|
128
|
+
return connecting;
|
|
129
|
+
}
|
|
130
|
+
function assembledTools(servers) {
|
|
131
|
+
if (!servers.length)
|
|
132
|
+
return declaredTools;
|
|
133
|
+
const mcpResources = servers.flatMap(s => s.resourceDefs);
|
|
134
|
+
return [...declaredTools, ...servers.flatMap(s => s.toolDefs), ...resourceTools(mcpResources)];
|
|
135
|
+
}
|
|
136
|
+
// `onToolCall` IS a guardrail — one of the `toolCall` kind, first in the
|
|
137
|
+
// chain so its verdict keeps precedence over anything declared later.
|
|
138
|
+
const guardrails = [
|
|
139
|
+
...(config.onToolCall
|
|
140
|
+
? [defineGuardrail({
|
|
141
|
+
name: 'onToolCall',
|
|
142
|
+
toolCall: async (call, toolCtx) => (await config.onToolCall(call, toolCtx)) === false
|
|
143
|
+
? { action: 'deny', reason: 'denied by onToolCall' }
|
|
144
|
+
: { action: 'allow' },
|
|
145
|
+
})]
|
|
146
|
+
: []),
|
|
147
|
+
...(config.guardrails ?? []),
|
|
148
|
+
];
|
|
149
|
+
async function chatOverrides(provider, resources, signal) {
|
|
150
|
+
const allLayers = [...layers, ...(await attachLayers(resources, signal ? { signal } : undefined))];
|
|
52
151
|
if (!allLayers.length)
|
|
53
152
|
return {};
|
|
54
153
|
const composed = composeSystem(allLayers);
|
|
@@ -59,21 +158,71 @@ export function createAgent(config) {
|
|
|
59
158
|
return { system: composed.text };
|
|
60
159
|
}
|
|
61
160
|
return {
|
|
62
|
-
tools
|
|
161
|
+
get tools() {
|
|
162
|
+
return assembledTools(connected);
|
|
163
|
+
},
|
|
63
164
|
createSession(id) {
|
|
64
165
|
return createSession(id);
|
|
65
166
|
},
|
|
167
|
+
async connect() {
|
|
168
|
+
const servers = await ensureConnected();
|
|
169
|
+
return servers.map(({ url, serverInfo, protocolVersion, tools: names, resources: reported }) => ({
|
|
170
|
+
url, serverInfo, protocolVersion, tools: names, resources: reported,
|
|
171
|
+
}));
|
|
172
|
+
},
|
|
173
|
+
async close() {
|
|
174
|
+
generation++;
|
|
175
|
+
const open = connected;
|
|
176
|
+
const inFlight = connecting;
|
|
177
|
+
connected = [];
|
|
178
|
+
// Wait out a connect already in the air: it sees the stale generation,
|
|
179
|
+
// closes whatever it opened, and rejects. Its rejection belongs to
|
|
180
|
+
// whoever asked for it, not to close().
|
|
181
|
+
if (inFlight)
|
|
182
|
+
await inFlight.catch(() => { });
|
|
183
|
+
await closeAll(open);
|
|
184
|
+
},
|
|
66
185
|
async *send(session, text, opts = {}) {
|
|
67
186
|
yield { type: 'message', role: 'user', text };
|
|
68
187
|
const { client, provider } = await resolveClient();
|
|
188
|
+
// Connect-time failure throws out of the generator: an unreachable
|
|
189
|
+
// server is a configuration/infrastructure fault, the same class as a
|
|
190
|
+
// missing @adia-ai/llm — not something the model can be told about and
|
|
191
|
+
// work around. A tool call that fails once the session is up IS
|
|
192
|
+
// model-visible, and comes back as an isError tool_result.
|
|
193
|
+
const servers = await ensureConnected(session.id, opts.signal);
|
|
194
|
+
while (pendingTrace.length)
|
|
195
|
+
yield { type: 'trace', record: pendingTrace.shift() };
|
|
196
|
+
const tools = assembledTools(servers);
|
|
197
|
+
const resources = [...declaredResources, ...servers.flatMap(s => s.resourceDefs)];
|
|
69
198
|
const messages = [...session.messages, { role: 'user', content: text }];
|
|
70
199
|
const ctx = { sessionId: session.id, ...(opts.signal ? { signal: opts.signal } : {}) };
|
|
200
|
+
const tracer = createTracer(config.trace, session.id);
|
|
201
|
+
// An attach-mode resource is READ here, during assembly. A read that
|
|
202
|
+
// fails throws out of send() (McpCallError for an MCP one) — there is
|
|
203
|
+
// no turn to degrade into: the prompt the model was going to see is
|
|
204
|
+
// the thing that could not be built.
|
|
205
|
+
const chat = await chatOverrides(provider, resources, opts.signal);
|
|
206
|
+
if (tracer.enabled) {
|
|
207
|
+
const record = tracer.record('prompt', 'assembled', {
|
|
208
|
+
layers: layers.length,
|
|
209
|
+
attachResources: resources.filter(r => r.mode === 'attach').length,
|
|
210
|
+
cached: Array.isArray(chat.system) ? chat.system.filter(b => 'cache_control' in b).length : 0,
|
|
211
|
+
chars: Array.isArray(chat.system)
|
|
212
|
+
? chat.system.reduce((n, b) => n + b.text.length, 0)
|
|
213
|
+
: (chat.system?.length ?? 0),
|
|
214
|
+
tools: tools.length,
|
|
215
|
+
});
|
|
216
|
+
if (record)
|
|
217
|
+
yield { type: 'trace', record };
|
|
218
|
+
}
|
|
71
219
|
yield* runLoop(messages, {
|
|
72
220
|
client,
|
|
73
|
-
chat
|
|
221
|
+
chat,
|
|
74
222
|
tools,
|
|
75
223
|
maxToolRounds,
|
|
76
|
-
...(
|
|
224
|
+
...(guardrails.length ? { guardrails } : {}),
|
|
225
|
+
...(tracer.enabled ? { tracer } : {}),
|
|
77
226
|
ctx,
|
|
78
227
|
});
|
|
79
228
|
},
|
|
@@ -83,15 +232,30 @@ export function createAgent(config) {
|
|
|
83
232
|
const text = frameClientMessage(msg);
|
|
84
233
|
yield* this.send(session, text, opts);
|
|
85
234
|
},
|
|
86
|
-
async run(session, workflowName, input,
|
|
235
|
+
async run(session, workflowName, input, opts) {
|
|
87
236
|
const workflow = workflows.get(workflowName);
|
|
88
237
|
if (!workflow) {
|
|
89
238
|
throw new Error(`Unknown workflow "${workflowName}". Declared: ${[...workflows.keys()].join(', ') || '(none)'}`);
|
|
90
239
|
}
|
|
240
|
+
const runOpts = typeof opts === 'function' ? { onEvent: opts } : (opts ?? {});
|
|
241
|
+
const onEvent = runOpts.onEvent;
|
|
242
|
+
const tracer = createTracer(config.trace, session.id);
|
|
243
|
+
const services = { ...(config.services ?? {}), ...(runOpts.services ?? {}) };
|
|
91
244
|
return runWorkflow(workflow, {
|
|
92
245
|
input,
|
|
246
|
+
services,
|
|
93
247
|
sessionId: session.id,
|
|
248
|
+
...(runOpts.signal ? { signal: runOpts.signal } : {}),
|
|
94
249
|
...(onEvent ? { emit: (e) => onEvent(e) } : {}),
|
|
250
|
+
...(tracer.enabled
|
|
251
|
+
? {
|
|
252
|
+
trace: (phase, name, data) => {
|
|
253
|
+
const record = tracer.record(phase, name, data);
|
|
254
|
+
if (record && onEvent)
|
|
255
|
+
onEvent({ type: 'trace', record });
|
|
256
|
+
},
|
|
257
|
+
}
|
|
258
|
+
: {}),
|
|
95
259
|
});
|
|
96
260
|
},
|
|
97
261
|
};
|
package/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["src/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,IAAI,IAAI,GAAqC,IAAI,CAAC;AAClD,SAAS,SAAS;IAChB,IAAI,CAAC,IAAI;QAAE,IAAI,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAC3D,OAAO,IAAI,CAAC;AACd,CAAC;AACD,OAAO,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAoB,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAsB,MAAM,YAAY,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAsC,MAAM,eAAe,CAAC;AAEhF,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAsClC,MAAM,UAAU,WAAW,CAAC,MAAmB;IAC7C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AG,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;YACtD,MAAM,QAAQ,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC;YAC7E,OAAO,WAAW,CAAC,QAAQ,EAAE;gBAC3B,KAAK;gBACL,QAAQ;gBACR,SAAS,EAAE,OAAO,CAAC,EAAE;gBACrB,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACrD,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/C,GAAG,CAAC,MAAM,CAAC,OAAO;oBAChB,CAAC,CAAC;wBACE,KAAK,EAAE,CAAC,KAAa,EAAE,IAAY,EAAE,IAA8B,EAAE,EAAE;4BACrE,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAmB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;4BAC9D,IAAI,MAAM,IAAI,OAAO;gCAAE,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;wBAC5D,CAAC;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR,CAAqC,CAAC;QACzC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/events.d.ts
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* but never touches the caller's Session — reduce is the single writer.
|
|
10
10
|
*/
|
|
11
11
|
import type { AdapterUsage } from '@adia-ai/llm';
|
|
12
|
-
import type
|
|
12
|
+
import { type JsonValue, type Msg, type Session } from './session.js';
|
|
13
|
+
import type { TraceRecord } from './trace.js';
|
|
13
14
|
/** CHAT-HARNESS law 3 — the closed, code-owned progress vocabulary. Every
|
|
14
15
|
* reader that renders labels does so from its OWN table keyed on these
|
|
15
16
|
* strings — never from model text — and drops anything not in this array
|
|
@@ -37,6 +38,18 @@ export type AgentEvent = {
|
|
|
37
38
|
id: string;
|
|
38
39
|
name: string;
|
|
39
40
|
input: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
/** A fragment of a tool call's arguments as the provider streams them
|
|
43
|
+
* (Anthropic `input_json_delta`, OpenAI partial argument strings).
|
|
44
|
+
* `snapshot` is the raw JSON text so far — it is NOT parseable until the
|
|
45
|
+
* matching `tool_use` arrives, and NOTHING may execute off it. Render
|
|
46
|
+
* progress from it; act only on `tool_use`. Render-only in reduce(). */
|
|
47
|
+
| {
|
|
48
|
+
type: 'tool_input_delta';
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
partial: string;
|
|
52
|
+
snapshot: string;
|
|
40
53
|
} | {
|
|
41
54
|
type: 'tool_result';
|
|
42
55
|
id: string;
|
|
@@ -71,6 +84,31 @@ export type AgentEvent = {
|
|
|
71
84
|
type: 'surface';
|
|
72
85
|
surfaceId: string;
|
|
73
86
|
line: string;
|
|
87
|
+
}
|
|
88
|
+
/** A guardrail vetoed or rewrote something. Render-only: the effect is
|
|
89
|
+
* already in the tool_result / done event that follows. */
|
|
90
|
+
| {
|
|
91
|
+
type: 'guardrail';
|
|
92
|
+
name: string;
|
|
93
|
+
target: 'tool_call' | 'output';
|
|
94
|
+
action: 'deny' | 'rewrite';
|
|
95
|
+
reason?: string;
|
|
96
|
+
/** Tool-call interventions name the call they acted on. */
|
|
97
|
+
toolName?: string;
|
|
98
|
+
toolUseId?: string;
|
|
99
|
+
}
|
|
100
|
+
/** One structured trace record (see trace.ts). Present only when tracing
|
|
101
|
+
* is enabled; render-only. */
|
|
102
|
+
| {
|
|
103
|
+
type: 'trace';
|
|
104
|
+
record: TraceRecord;
|
|
105
|
+
}
|
|
106
|
+
/** The ONLY way session memory changes. A null value deletes the key.
|
|
107
|
+
* Emitted by a tool through `ctx.remember`, or constructed directly with
|
|
108
|
+
* `remember()` and folded by the caller. */
|
|
109
|
+
| {
|
|
110
|
+
type: 'memory';
|
|
111
|
+
patch: Record<string, JsonValue | null>;
|
|
74
112
|
};
|
|
75
113
|
/** Fold one event into a Session. Message-building rules:
|
|
76
114
|
* - `message` → append the user message.
|
|
@@ -81,11 +119,17 @@ export type AgentEvent = {
|
|
|
81
119
|
* (consecutive results merge into ONE tool msg — the
|
|
82
120
|
* Anthropic wire requires alternating roles).
|
|
83
121
|
* - `done` → close any remaining draft as the final assistant msg.
|
|
84
|
-
* - `
|
|
122
|
+
* - `memory` → merge the patch into `session.memory` (null deletes);
|
|
123
|
+
* the patch must be JSON-safe or the write throws.
|
|
124
|
+
* - `thinking`/`step`/`error`/`progress`/`surface`/`tool_input_delta`/
|
|
125
|
+
* `guardrail`/`trace` → no session effect
|
|
85
126
|
* (render-only events — `progress`/`surface` included by the same rule:
|
|
86
127
|
* they narrate the turn in flight, they don't alter the transcript).
|
|
87
128
|
*/
|
|
88
129
|
export declare function reduce(session: Session, event: AgentEvent): Session;
|
|
130
|
+
/** Build a memory write. Validated here so a bad patch fails where it was
|
|
131
|
+
* authored, not later inside a reduce() the author never sees. */
|
|
132
|
+
export declare function remember(patch: Record<string, JsonValue | null>): AgentEvent;
|
|
89
133
|
/** Convenience for the loop and tests: fold a whole event array. */
|
|
90
134
|
export declare function reduceAll(session: Session, events: AgentEvent[]): Session;
|
|
91
135
|
export type { Msg, Session };
|
package/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAQ,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO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;GAeG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAwFnE;AAED;mEACmE;AACnE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC,GAAG,UAAU,CAG5E;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAIzE;AAED,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC"}
|
package/events.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* reduce() is pure: (session, event) → new session. The loop emits events
|
|
9
9
|
* but never touches the caller's Session — reduce is the single writer.
|
|
10
10
|
*/
|
|
11
|
+
import { assertJsonSafe } from './session.js';
|
|
11
12
|
/** CHAT-HARNESS law 3 — the closed, code-owned progress vocabulary. Every
|
|
12
13
|
* reader that renders labels does so from its OWN table keyed on these
|
|
13
14
|
* strings — never from model text — and drops anything not in this array
|
|
@@ -31,7 +32,10 @@ export function isProgressStage(value) {
|
|
|
31
32
|
* (consecutive results merge into ONE tool msg — the
|
|
32
33
|
* Anthropic wire requires alternating roles).
|
|
33
34
|
* - `done` → close any remaining draft as the final assistant msg.
|
|
34
|
-
* - `
|
|
35
|
+
* - `memory` → merge the patch into `session.memory` (null deletes);
|
|
36
|
+
* the patch must be JSON-safe or the write throws.
|
|
37
|
+
* - `thinking`/`step`/`error`/`progress`/`surface`/`tool_input_delta`/
|
|
38
|
+
* `guardrail`/`trace` → no session effect
|
|
35
39
|
* (render-only events — `progress`/`surface` included by the same rule:
|
|
36
40
|
* they narrate the turn in flight, they don't alter the transcript).
|
|
37
41
|
*/
|
|
@@ -92,16 +96,41 @@ export function reduce(session, event) {
|
|
|
92
96
|
delete next.draft;
|
|
93
97
|
return next;
|
|
94
98
|
}
|
|
99
|
+
case 'memory': {
|
|
100
|
+
assertJsonSafe(event.patch);
|
|
101
|
+
const memory = { ...(session.memory ?? {}) };
|
|
102
|
+
for (const [key, value] of Object.entries(event.patch)) {
|
|
103
|
+
if (value === null)
|
|
104
|
+
delete memory[key];
|
|
105
|
+
else
|
|
106
|
+
memory[key] = value;
|
|
107
|
+
}
|
|
108
|
+
if (!Object.keys(memory).length) {
|
|
109
|
+
const next = { ...session };
|
|
110
|
+
delete next.memory;
|
|
111
|
+
return next;
|
|
112
|
+
}
|
|
113
|
+
return { ...session, memory };
|
|
114
|
+
}
|
|
95
115
|
case 'thinking':
|
|
96
116
|
case 'step':
|
|
97
117
|
case 'error':
|
|
98
118
|
case 'progress':
|
|
99
119
|
case 'surface':
|
|
120
|
+
case 'tool_input_delta':
|
|
121
|
+
case 'guardrail':
|
|
122
|
+
case 'trace':
|
|
100
123
|
return session;
|
|
101
124
|
default:
|
|
102
125
|
return session;
|
|
103
126
|
}
|
|
104
127
|
}
|
|
128
|
+
/** Build a memory write. Validated here so a bad patch fails where it was
|
|
129
|
+
* authored, not later inside a reduce() the author never sees. */
|
|
130
|
+
export function remember(patch) {
|
|
131
|
+
assertJsonSafe(patch);
|
|
132
|
+
return { type: 'memory', patch };
|
|
133
|
+
}
|
|
105
134
|
/** Convenience for the loop and tests: fold a whole event array. */
|
|
106
135
|
export function reduceAll(session, events) {
|
|
107
136
|
let next = session;
|
package/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,cAAc,EAA0C,MAAM,cAAc,CAAC;AAGtF;;;;8CAI8C;AAC9C,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,O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-0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guardrails — the deterministic layer between the model and the world.
|
|
3
|
+
*
|
|
4
|
+
* A guardrail is code that runs OUTSIDE the model's context and cannot be
|
|
5
|
+
* talked past: prompted guidance is missed on a real fraction of turns, a
|
|
6
|
+
* check in the loop is not. Two attach points, both declared once at
|
|
7
|
+
* `createAgent`:
|
|
8
|
+
*
|
|
9
|
+
* - `toolCall` — sees every tool call BEFORE it executes; may allow, deny
|
|
10
|
+
* (the model gets an isError tool_result naming the guardrail, the loop
|
|
11
|
+
* continues), or rewrite the call's input (clamp a limit, strip a field,
|
|
12
|
+
* force a scope).
|
|
13
|
+
* - `output` — sees the model's completed text for a round; may allow,
|
|
14
|
+
* rewrite (redaction), or deny (the turn ends with the synthetic
|
|
15
|
+
* stopReason `guardrail_denied` and no model text).
|
|
16
|
+
*
|
|
17
|
+
* Order is declaration order, and it is a CHAIN: a rewrite feeds the next
|
|
18
|
+
* guardrail, the first deny wins and short-circuits. `AgentConfig.onToolCall`
|
|
19
|
+
* is now exactly one guardrail of the `toolCall` kind (adapted in agent.ts),
|
|
20
|
+
* kept for source compatibility.
|
|
21
|
+
*
|
|
22
|
+
* A guardrail decides from the CALL and the harness's own context — never
|
|
23
|
+
* from text the model produced asking to be trusted. Tool output, resource
|
|
24
|
+
* text, and model text are data.
|
|
25
|
+
*/
|
|
26
|
+
import type { ToolUse } from '@adia-ai/llm';
|
|
27
|
+
import type { ToolContext } from './tools.js';
|
|
28
|
+
export type GuardrailDecision = {
|
|
29
|
+
action: 'allow';
|
|
30
|
+
} | {
|
|
31
|
+
action: 'deny';
|
|
32
|
+
reason: string;
|
|
33
|
+
}
|
|
34
|
+
/** Tool-call rewrite carries `input`; output rewrite carries `text`. */
|
|
35
|
+
| {
|
|
36
|
+
action: 'rewrite';
|
|
37
|
+
input?: Record<string, unknown>;
|
|
38
|
+
text?: string;
|
|
39
|
+
reason?: string;
|
|
40
|
+
};
|
|
41
|
+
/** A guardrail may also return nothing — the common "I have no opinion on
|
|
42
|
+
* this one" case — which reads as `allow`. */
|
|
43
|
+
export type GuardrailReturn = GuardrailDecision | void | undefined;
|
|
44
|
+
export interface Guardrail {
|
|
45
|
+
name: string;
|
|
46
|
+
toolCall?: (call: ToolUse, ctx: ToolContext) => GuardrailReturn | Promise<GuardrailReturn>;
|
|
47
|
+
output?: (text: string, ctx: ToolContext) => GuardrailReturn | Promise<GuardrailReturn>;
|
|
48
|
+
}
|
|
49
|
+
export declare function defineGuardrail(guardrail: Guardrail): Guardrail;
|
|
50
|
+
/** What the loop needs to know after running a chain. */
|
|
51
|
+
export interface GuardrailOutcome<T> {
|
|
52
|
+
value: T;
|
|
53
|
+
denied?: {
|
|
54
|
+
name: string;
|
|
55
|
+
reason: string;
|
|
56
|
+
};
|
|
57
|
+
/** Names of guardrails that rewrote, in application order. */
|
|
58
|
+
rewrittenBy: string[];
|
|
59
|
+
}
|
|
60
|
+
/** Run the toolCall chain: each guardrail sees the call as the previous one
|
|
61
|
+
* left it; the first deny stops the chain. */
|
|
62
|
+
export declare function guardToolCall(guardrails: Guardrail[], call: ToolUse, ctx: ToolContext): Promise<GuardrailOutcome<ToolUse>>;
|
|
63
|
+
/** Run the output chain over one round's completed text. */
|
|
64
|
+
export declare function guardOutput(guardrails: Guardrail[], text: string, ctx: ToolContext): Promise<GuardrailOutcome<string>>;
|
|
65
|
+
/** True when any declared guardrail has an output opinion — lets the loop
|
|
66
|
+
* skip the whole output path (and its events) when nobody is listening. */
|
|
67
|
+
export declare function hasOutputGuardrail(guardrails: Guardrail[]): boolean;
|
|
68
|
+
//# sourceMappingURL=guardrail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guardrail.d.ts","sourceRoot":"","sources":["src/guardrail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OA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CAAC,CAepC;AAED,4DAA4D;AAC5D,wBAAsB,WAAW,CAC/B,UAAU,EAAE,SAAS,EAAE,EACvB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAenC;AAED;4EAC4E;AAC5E,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAEnE"}
|
package/guardrail.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guardrails — the deterministic layer between the model and the world.
|
|
3
|
+
*
|
|
4
|
+
* A guardrail is code that runs OUTSIDE the model's context and cannot be
|
|
5
|
+
* talked past: prompted guidance is missed on a real fraction of turns, a
|
|
6
|
+
* check in the loop is not. Two attach points, both declared once at
|
|
7
|
+
* `createAgent`:
|
|
8
|
+
*
|
|
9
|
+
* - `toolCall` — sees every tool call BEFORE it executes; may allow, deny
|
|
10
|
+
* (the model gets an isError tool_result naming the guardrail, the loop
|
|
11
|
+
* continues), or rewrite the call's input (clamp a limit, strip a field,
|
|
12
|
+
* force a scope).
|
|
13
|
+
* - `output` — sees the model's completed text for a round; may allow,
|
|
14
|
+
* rewrite (redaction), or deny (the turn ends with the synthetic
|
|
15
|
+
* stopReason `guardrail_denied` and no model text).
|
|
16
|
+
*
|
|
17
|
+
* Order is declaration order, and it is a CHAIN: a rewrite feeds the next
|
|
18
|
+
* guardrail, the first deny wins and short-circuits. `AgentConfig.onToolCall`
|
|
19
|
+
* is now exactly one guardrail of the `toolCall` kind (adapted in agent.ts),
|
|
20
|
+
* kept for source compatibility.
|
|
21
|
+
*
|
|
22
|
+
* A guardrail decides from the CALL and the harness's own context — never
|
|
23
|
+
* from text the model produced asking to be trusted. Tool output, resource
|
|
24
|
+
* text, and model text are data.
|
|
25
|
+
*/
|
|
26
|
+
export function defineGuardrail(guardrail) {
|
|
27
|
+
if (!guardrail.name)
|
|
28
|
+
throw new Error('defineGuardrail: name is required');
|
|
29
|
+
if (!guardrail.toolCall && !guardrail.output) {
|
|
30
|
+
throw new Error(`defineGuardrail "${guardrail.name}": declare toolCall, output, or both`);
|
|
31
|
+
}
|
|
32
|
+
return guardrail;
|
|
33
|
+
}
|
|
34
|
+
function normalize(decision) {
|
|
35
|
+
return decision ?? { action: 'allow' };
|
|
36
|
+
}
|
|
37
|
+
/** Run the toolCall chain: each guardrail sees the call as the previous one
|
|
38
|
+
* left it; the first deny stops the chain. */
|
|
39
|
+
export async function guardToolCall(guardrails, call, ctx) {
|
|
40
|
+
let current = call;
|
|
41
|
+
const rewrittenBy = [];
|
|
42
|
+
for (const guardrail of guardrails) {
|
|
43
|
+
if (!guardrail.toolCall)
|
|
44
|
+
continue;
|
|
45
|
+
const decision = normalize(await guardrail.toolCall(current, ctx));
|
|
46
|
+
if (decision.action === 'deny') {
|
|
47
|
+
return { value: current, denied: { name: guardrail.name, reason: decision.reason }, rewrittenBy };
|
|
48
|
+
}
|
|
49
|
+
if (decision.action === 'rewrite' && decision.input) {
|
|
50
|
+
current = { ...current, input: decision.input };
|
|
51
|
+
rewrittenBy.push(guardrail.name);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return { value: current, rewrittenBy };
|
|
55
|
+
}
|
|
56
|
+
/** Run the output chain over one round's completed text. */
|
|
57
|
+
export async function guardOutput(guardrails, text, ctx) {
|
|
58
|
+
let current = text;
|
|
59
|
+
const rewrittenBy = [];
|
|
60
|
+
for (const guardrail of guardrails) {
|
|
61
|
+
if (!guardrail.output)
|
|
62
|
+
continue;
|
|
63
|
+
const decision = normalize(await guardrail.output(current, ctx));
|
|
64
|
+
if (decision.action === 'deny') {
|
|
65
|
+
return { value: current, denied: { name: guardrail.name, reason: decision.reason }, rewrittenBy };
|
|
66
|
+
}
|
|
67
|
+
if (decision.action === 'rewrite' && typeof decision.text === 'string') {
|
|
68
|
+
current = decision.text;
|
|
69
|
+
rewrittenBy.push(guardrail.name);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { value: current, rewrittenBy };
|
|
73
|
+
}
|
|
74
|
+
/** True when any declared guardrail has an output opinion — lets the loop
|
|
75
|
+
* skip the whole output path (and its events) when nobody is listening. */
|
|
76
|
+
export function hasOutputGuardrail(guardrails) {
|
|
77
|
+
return guardrails.some(g => !!g.output);
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=guardrail.js.map
|
package/guardrail.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guardrail.js","sourceRoot":"","sources":["src/guardrail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAqBH,MAAM,UAAU,eAAe,CAAC,SAAoB;IAClD,IAAI,CAAC,SAAS,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IAC1E,IAAI,CAAC,SAAS,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,oBAAoB,SAAS,CAAC,IAAI,sCAAsC,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAUD,SAAS,SAAS,CAAC,QAAyB;IAC1C,OAAO,QAAQ,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACzC,CAAC;AAED;+CAC+C;AAC/C,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAuB,EACvB,IAAa,EACb,GAAgB;IAEhB,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC,SAAS,CAAC,QAAQ;YAAE,SAAS;QAClC,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;QACnE,IAAI,QAA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AG,QAAQ,CAAC,IAAI,CAAC;YACxB,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACzC,CAAC;AAED;4EAC4E;AAC5E,MAAM,UAAU,kBAAkB,CAAC,UAAuB;IACxD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC"}
|
package/index.d.ts
CHANGED
|
@@ -6,20 +6,28 @@
|
|
|
6
6
|
* the serializable Session, and the one shared event reducer.
|
|
7
7
|
*/
|
|
8
8
|
export { createAgent } from './agent.js';
|
|
9
|
-
export type { Agent, AgentConfig, SendOpts } from './agent.js';
|
|
9
|
+
export type { Agent, AgentConfig, SendOpts, RunOpts } from './agent.js';
|
|
10
10
|
export { promptLayer, composeSystem } from './prompt.js';
|
|
11
11
|
export type { PromptLayer, ComposedSystem } from './prompt.js';
|
|
12
12
|
export { defineTool, executeTool, checkInput, toSpecs } from './tools.js';
|
|
13
13
|
export type { ToolDef, ToolContext, ToolOutcome } from './tools.js';
|
|
14
|
-
export { defineWorkflow, runWorkflow } from './workflow.js';
|
|
15
|
-
export type { Workflow, WorkflowStep, WorkflowContext, WorkflowResult } from './workflow.js';
|
|
14
|
+
export { defineWorkflow, runWorkflow, toVerdict } from './workflow.js';
|
|
15
|
+
export type { Workflow, WorkflowStep, WorkflowContext, WorkflowResult, WorkflowAttempt, WorkflowOptions, WorkflowInvocation, Verdict, StepDecision, } from './workflow.js';
|
|
16
|
+
export { defineGuardrail } from './guardrail.js';
|
|
17
|
+
export type { Guardrail, GuardrailDecision, GuardrailReturn } from './guardrail.js';
|
|
18
|
+
export { createTracer, consoleSink, TRACE_PHASES, isTracePhase } from './trace.js';
|
|
19
|
+
export type { TraceRecord, TraceSink, TracePhase, TraceConfig, Tracer } from './trace.js';
|
|
16
20
|
export { defineResource } from './resource.js';
|
|
17
|
-
export type { ResourceDef } from './resource.js';
|
|
21
|
+
export type { ResourceDef, ResourceContext } from './resource.js';
|
|
22
|
+
export { mcpServer, connectMcpSource } from './mcp.js';
|
|
23
|
+
export type { McpSource, McpServerOptions, McpServerReport, ConnectedMcpServer } from './mcp.js';
|
|
24
|
+
export { connectStreamableHttp, McpError, McpConnectionError, McpCallError, DEFAULT_MCP_TIMEOUT_MS, } from './mcp-transport.js';
|
|
25
|
+
export type { McpConnection, McpTransportOptions, McpRequestOptions } from './mcp-transport.js';
|
|
18
26
|
export { createIntegrationRegistry, resolveIntegrations, buildToolDispatch, MAX_INTEGRATIONS } from './integrations.js';
|
|
19
27
|
export type { IntegrationManifest, IntegrationRegistry, IntegrationContext, ResolvedIntegrations } from './integrations.js';
|
|
20
|
-
export { createSession, toJSON, fromJSON } from './session.js';
|
|
21
|
-
export type { Session, Msg, Draft } from './session.js';
|
|
22
|
-
export { reduce, reduceAll, PROGRESS_STAGES, isProgressStage } from './events.js';
|
|
28
|
+
export { createSession, toJSON, fromJSON, assertJsonSafe } from './session.js';
|
|
29
|
+
export type { Session, Msg, Draft, JsonValue } from './session.js';
|
|
30
|
+
export { reduce, reduceAll, remember, PROGRESS_STAGES, isProgressStage } from './events.js';
|
|
23
31
|
export type { AgentEvent, ProgressStage } from './events.js';
|
|
24
32
|
export { frameClientMessage, shouldRunTurn } from './frame.js';
|
|
25
33
|
export type { ClientMessage } from './frame.js';
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":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