agentfootprint 7.20.0 → 7.22.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 +10 -3
- package/README.md +1 -1
- package/ai-instructions/claude-code/SKILL.md +10 -3
- package/dist/adapters/hosting/agentcore.js +12 -2
- package/dist/adapters/hosting/agentcore.js.map +1 -1
- package/dist/adapters/llm/AnthropicProvider.js +12 -0
- package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
- package/dist/adapters/llm/BedrockProvider.js +12 -0
- package/dist/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/adapters/llm/BrowserAnthropicProvider.js +45 -6
- package/dist/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
- package/dist/adapters/llm/BrowserOpenAIProvider.js +13 -0
- package/dist/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
- package/dist/adapters/llm/MockProvider.js +10 -0
- package/dist/adapters/llm/MockProvider.js.map +1 -1
- package/dist/adapters/llm/OpenAIProvider.js +15 -0
- package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/adapters/types.js +10 -0
- package/dist/adapters/types.js.map +1 -1
- package/dist/cache/CacheDecisionSubflow.js +67 -3
- package/dist/cache/CacheDecisionSubflow.js.map +1 -1
- package/dist/conventions.js +8 -0
- package/dist/conventions.js.map +1 -1
- package/dist/core/Agent.js +47 -0
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/AgentBuilder.js +13 -6
- package/dist/core/agent/AgentBuilder.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +17 -1
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +49 -4
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/delivery/rules.js +121 -0
- package/dist/core/agent/delivery/rules.js.map +1 -0
- package/dist/core/agent/delivery/types.js +12 -0
- package/dist/core/agent/delivery/types.js.map +1 -0
- package/dist/core/agent/stages/callLLM.js +27 -1
- package/dist/core/agent/stages/callLLM.js.map +1 -1
- package/dist/core/agent/stages/deliver.js +155 -0
- package/dist/core/agent/stages/deliver.js.map +1 -0
- package/dist/core/agent/stages/seed.js +4 -0
- package/dist/core/agent/stages/seed.js.map +1 -1
- package/dist/core/slots/buildMessagesSlot.js +43 -48
- package/dist/core/slots/buildMessagesSlot.js.map +1 -1
- package/dist/esm/adapters/hosting/agentcore.d.ts +27 -0
- package/dist/esm/adapters/hosting/agentcore.js +12 -2
- package/dist/esm/adapters/hosting/agentcore.js.map +1 -1
- package/dist/esm/adapters/llm/AnthropicProvider.d.ts +2 -1
- package/dist/esm/adapters/llm/AnthropicProvider.js +12 -0
- package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +2 -1
- package/dist/esm/adapters/llm/BedrockProvider.js +12 -0
- package/dist/esm/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +2 -1
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.js +45 -6
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +3 -1
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +13 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
- package/dist/esm/adapters/llm/MockProvider.d.ts +2 -1
- package/dist/esm/adapters/llm/MockProvider.js +10 -0
- package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +2 -1
- package/dist/esm/adapters/llm/OpenAIProvider.js +15 -0
- package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/esm/adapters/types.d.ts +69 -0
- package/dist/esm/adapters/types.js +9 -1
- package/dist/esm/adapters/types.js.map +1 -1
- package/dist/esm/cache/CacheDecisionSubflow.d.ts +11 -0
- package/dist/esm/cache/CacheDecisionSubflow.js +67 -3
- package/dist/esm/cache/CacheDecisionSubflow.js.map +1 -1
- package/dist/esm/conventions.d.ts +8 -0
- package/dist/esm/conventions.js +8 -0
- package/dist/esm/conventions.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +16 -0
- package/dist/esm/core/Agent.js +47 -0
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.d.ts +9 -4
- package/dist/esm/core/agent/AgentBuilder.js +14 -7
- package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
- package/dist/esm/core/agent/buildAgentChart.d.ts +14 -0
- package/dist/esm/core/agent/buildAgentChart.js +17 -1
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js +49 -4
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/delivery/rules.d.ts +79 -0
- package/dist/esm/core/agent/delivery/rules.js +113 -0
- package/dist/esm/core/agent/delivery/rules.js.map +1 -0
- package/dist/esm/core/agent/delivery/types.d.ts +51 -0
- package/dist/esm/core/agent/delivery/types.js +11 -0
- package/dist/esm/core/agent/delivery/types.js.map +1 -0
- package/dist/esm/core/agent/stages/callLLM.js +27 -1
- package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
- package/dist/esm/core/agent/stages/deliver.d.ts +59 -0
- package/dist/esm/core/agent/stages/deliver.js +150 -0
- package/dist/esm/core/agent/stages/deliver.js.map +1 -0
- package/dist/esm/core/agent/stages/seed.js +4 -0
- package/dist/esm/core/agent/stages/seed.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +14 -0
- package/dist/esm/core/slots/buildMessagesSlot.d.ts +23 -8
- package/dist/esm/core/slots/buildMessagesSlot.js +43 -48
- package/dist/esm/core/slots/buildMessagesSlot.js.map +1 -1
- package/dist/esm/hosting/httpHost.d.ts +62 -3
- package/dist/esm/hosting/httpHost.js +73 -9
- package/dist/esm/hosting/httpHost.js.map +1 -1
- package/dist/esm/hosting/index.d.ts +3 -1
- package/dist/esm/hosting/index.js +3 -1
- package/dist/esm/hosting/index.js.map +1 -1
- package/dist/esm/hosting/nodeHost.d.ts +21 -2
- package/dist/esm/hosting/nodeHost.js +10 -0
- package/dist/esm/hosting/nodeHost.js.map +1 -1
- package/dist/esm/hosting/types.d.ts +6 -0
- package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +38 -10
- package/dist/esm/lib/injection-engine/factories/defineFact.js +20 -8
- package/dist/esm/lib/injection-engine/factories/defineFact.js.map +1 -1
- package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +42 -15
- package/dist/esm/lib/injection-engine/factories/defineInstruction.js +17 -6
- package/dist/esm/lib/injection-engine/factories/defineInstruction.js.map +1 -1
- package/dist/esm/lib/injection-engine/messagesSlotRefusal.d.ts +70 -27
- package/dist/esm/lib/injection-engine/messagesSlotRefusal.js +91 -34
- package/dist/esm/lib/injection-engine/messagesSlotRefusal.js.map +1 -1
- package/dist/esm/lib/injection-engine/types.d.ts +35 -9
- package/dist/esm/lib/injection-engine/types.js +6 -0
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/memory/asRoleRefusal.d.ts +15 -11
- package/dist/esm/memory/asRoleRefusal.js +21 -15
- package/dist/esm/memory/asRoleRefusal.js.map +1 -1
- package/dist/esm/resilience/withCircuitBreaker.js +6 -0
- package/dist/esm/resilience/withCircuitBreaker.js.map +1 -1
- package/dist/esm/resilience/withFallback.js +18 -0
- package/dist/esm/resilience/withFallback.js.map +1 -1
- package/dist/esm/resilience/withRetry.js +8 -0
- package/dist/esm/resilience/withRetry.js.map +1 -1
- package/dist/hosting/httpHost.js +73 -9
- package/dist/hosting/httpHost.js.map +1 -1
- package/dist/hosting/index.js +3 -1
- package/dist/hosting/index.js.map +1 -1
- package/dist/hosting/nodeHost.js +10 -0
- package/dist/hosting/nodeHost.js.map +1 -1
- package/dist/lib/injection-engine/factories/defineFact.js +19 -7
- package/dist/lib/injection-engine/factories/defineFact.js.map +1 -1
- package/dist/lib/injection-engine/factories/defineInstruction.js +16 -5
- package/dist/lib/injection-engine/factories/defineInstruction.js.map +1 -1
- package/dist/lib/injection-engine/messagesSlotRefusal.js +95 -36
- package/dist/lib/injection-engine/messagesSlotRefusal.js.map +1 -1
- package/dist/lib/injection-engine/types.js +6 -0
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/memory/asRoleRefusal.js +21 -15
- package/dist/memory/asRoleRefusal.js.map +1 -1
- package/dist/resilience/withCircuitBreaker.js +6 -0
- package/dist/resilience/withCircuitBreaker.js.map +1 -1
- package/dist/resilience/withFallback.js +18 -0
- package/dist/resilience/withFallback.js.map +1 -1
- package/dist/resilience/withRetry.js +8 -0
- package/dist/resilience/withRetry.js.map +1 -1
- package/dist/types/adapters/hosting/agentcore.d.ts +27 -0
- package/dist/types/adapters/hosting/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/llm/AnthropicProvider.d.ts +2 -1
- package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/BedrockProvider.d.ts +2 -1
- package/dist/types/adapters/llm/BedrockProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts +2 -1
- package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts +3 -1
- package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/MockProvider.d.ts +2 -1
- package/dist/types/adapters/llm/MockProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/OpenAIProvider.d.ts +2 -1
- package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
- package/dist/types/adapters/types.d.ts +69 -0
- package/dist/types/adapters/types.d.ts.map +1 -1
- package/dist/types/cache/CacheDecisionSubflow.d.ts +11 -0
- package/dist/types/cache/CacheDecisionSubflow.d.ts.map +1 -1
- package/dist/types/conventions.d.ts +8 -0
- package/dist/types/conventions.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +16 -0
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/AgentBuilder.d.ts +9 -4
- package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts +14 -0
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/delivery/rules.d.ts +80 -0
- package/dist/types/core/agent/delivery/rules.d.ts.map +1 -0
- package/dist/types/core/agent/delivery/types.d.ts +52 -0
- package/dist/types/core/agent/delivery/types.d.ts.map +1 -0
- package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
- package/dist/types/core/agent/stages/deliver.d.ts +60 -0
- package/dist/types/core/agent/stages/deliver.d.ts.map +1 -0
- package/dist/types/core/agent/types.d.ts +14 -0
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/slots/buildMessagesSlot.d.ts +23 -8
- package/dist/types/core/slots/buildMessagesSlot.d.ts.map +1 -1
- package/dist/types/hosting/httpHost.d.ts +62 -3
- package/dist/types/hosting/httpHost.d.ts.map +1 -1
- package/dist/types/hosting/index.d.ts +3 -1
- package/dist/types/hosting/index.d.ts.map +1 -1
- package/dist/types/hosting/nodeHost.d.ts +21 -2
- package/dist/types/hosting/nodeHost.d.ts.map +1 -1
- package/dist/types/hosting/types.d.ts +6 -0
- package/dist/types/hosting/types.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/factories/defineFact.d.ts +38 -10
- package/dist/types/lib/injection-engine/factories/defineFact.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/factories/defineInstruction.d.ts +42 -15
- package/dist/types/lib/injection-engine/factories/defineInstruction.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/messagesSlotRefusal.d.ts +70 -27
- package/dist/types/lib/injection-engine/messagesSlotRefusal.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +35 -9
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/memory/asRoleRefusal.d.ts +15 -11
- package/dist/types/memory/asRoleRefusal.d.ts.map +1 -1
- package/dist/types/resilience/withCircuitBreaker.d.ts.map +1 -1
- package/dist/types/resilience/withFallback.d.ts.map +1 -1
- package/dist/types/resilience/withRetry.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/hosting/httpHost.js
CHANGED
|
@@ -26,6 +26,15 @@
|
|
|
26
26
|
* `HostRequest` and `HostReply` say exactly what they said before. The gap was
|
|
27
27
|
* in the first adapter, which had no seam, not in the port, which needed none.
|
|
28
28
|
*
|
|
29
|
+
* ── The second thing a deployment gets to re-decide: who owns the socket ─────
|
|
30
|
+
* By default this file creates a server and listens on it. Pass `server` and it
|
|
31
|
+
* attaches to yours instead — because a container is sometimes given exactly
|
|
32
|
+
* one port, and an agent that privately owns the socket cannot share it with a
|
|
33
|
+
* WebSocket upgrade or with routes that were there first. Attached, the host
|
|
34
|
+
* answers its two paths, writes nothing on anyone else's, and `close()`
|
|
35
|
+
* detaches and drains without closing a socket it never opened. That is the
|
|
36
|
+
* whole difference; every other law on this page is the same either way.
|
|
37
|
+
*
|
|
29
38
|
* Pattern: Template method via configuration (Strategy on the wire format).
|
|
30
39
|
* Everything HTTP lives here and in the wires; `types.ts` knows none of it.
|
|
31
40
|
*/
|
|
@@ -90,6 +99,17 @@ const DEFAULT_CAPABILITIES = ['streaming'];
|
|
|
90
99
|
*/
|
|
91
100
|
function httpHost(options) {
|
|
92
101
|
const { name, wire, invokePath, healthPath } = options;
|
|
102
|
+
const ownServer = options.server;
|
|
103
|
+
// Refused at construction, not ignored at serve time: a `port` next to a
|
|
104
|
+
// server this host does not bind is a caller who believes something untrue
|
|
105
|
+
// about where their agent will answer, and silently dropping it is how they
|
|
106
|
+
// stay believing it.
|
|
107
|
+
if (ownServer && (options.port !== undefined || options.hostname !== undefined)) {
|
|
108
|
+
throw new Error(`[hosting] httpHost('${name}') was given both a caller-owned 'server' and a ` +
|
|
109
|
+
`'${options.port !== undefined ? 'port' : 'hostname'}'. A server you own already has ` +
|
|
110
|
+
`an address, and this host binds nothing when you pass one. Drop the port/hostname, ` +
|
|
111
|
+
`or drop the server and let this host bind its own socket.`);
|
|
112
|
+
}
|
|
93
113
|
const port = options.port ?? 8080;
|
|
94
114
|
const hostname = options.hostname ?? '0.0.0.0';
|
|
95
115
|
const capabilities = options.capabilities ?? DEFAULT_CAPABILITIES;
|
|
@@ -97,18 +117,26 @@ function httpHost(options) {
|
|
|
97
117
|
name,
|
|
98
118
|
capabilities,
|
|
99
119
|
async serve(handler) {
|
|
100
|
-
const { createServer } = await Promise.resolve().then(() => __importStar(require('node:http')));
|
|
101
120
|
const startedAt = Date.now();
|
|
102
121
|
const inFlight = new Set();
|
|
103
122
|
let accepting = true;
|
|
104
123
|
let closing;
|
|
105
|
-
const
|
|
124
|
+
const onRequest = (req, res) => {
|
|
125
|
+
// On a shared server an earlier listener may already have answered.
|
|
126
|
+
// Writing again would corrupt its reply; there is nothing to add.
|
|
127
|
+
if (res.headersSent)
|
|
128
|
+
return;
|
|
106
129
|
const path = (req.url ?? '').split('?')[0];
|
|
107
130
|
if (req.method === 'GET' && path === healthPath) {
|
|
108
131
|
sendJson(res, 200, wire.health(Date.now() - startedAt));
|
|
109
132
|
return;
|
|
110
133
|
}
|
|
111
134
|
if (req.method !== 'POST' || path !== invokePath) {
|
|
135
|
+
// On a server we own, an unmatched path is nobody else's, so saying
|
|
136
|
+
// so is the honest answer. On a server the CALLER owns it is theirs,
|
|
137
|
+
// and a 404 from us would answer for their application.
|
|
138
|
+
if (ownServer)
|
|
139
|
+
return;
|
|
112
140
|
sendJson(res, 404, wire.failure(`no route for ${req.method ?? '?'} ${path}`));
|
|
113
141
|
return;
|
|
114
142
|
}
|
|
@@ -120,14 +148,40 @@ function httpHost(options) {
|
|
|
120
148
|
const served = serveOne(req, res, handler, wire);
|
|
121
149
|
inFlight.add(served);
|
|
122
150
|
void served.finally(() => inFlight.delete(served));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
server
|
|
127
|
-
|
|
151
|
+
};
|
|
152
|
+
let server;
|
|
153
|
+
if (ownServer) {
|
|
154
|
+
server = ownServer;
|
|
155
|
+
if (!server.listening) {
|
|
156
|
+
throw new Error(`[hosting] httpHost('${name}') was handed a server that is not listening yet. ` +
|
|
157
|
+
`This handle promises the url and port it is answering on, and a server with ` +
|
|
158
|
+
`no address has neither. Call server.listen(...) first, then serve() — ` +
|
|
159
|
+
`attaching after listen() is safe and is the intended order.`);
|
|
160
|
+
}
|
|
161
|
+
server.on('request', onRequest);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
const { createServer } = await Promise.resolve().then(() => __importStar(require('node:http')));
|
|
165
|
+
server = createServer(onRequest);
|
|
166
|
+
await new Promise((resolve, reject) => {
|
|
167
|
+
server.once('error', reject);
|
|
168
|
+
server.listen(port, hostname, resolve);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
128
171
|
const address = server.address();
|
|
129
|
-
const
|
|
130
|
-
|
|
172
|
+
const tcp = typeof address === 'object' && address !== null ? address : undefined;
|
|
173
|
+
if (ownServer && !tcp) {
|
|
174
|
+
server.off('request', onRequest);
|
|
175
|
+
throw new Error(`[hosting] httpHost('${name}') was handed a server bound to ${JSON.stringify(address)}` +
|
|
176
|
+
` — a pipe or socket path, which has no port. This handle promises a url and a ` +
|
|
177
|
+
`port, and inventing one would be worse than refusing. Serve on a TCP server, or ` +
|
|
178
|
+
`drive the handler yourself.`);
|
|
179
|
+
}
|
|
180
|
+
const boundPort = tcp ? tcp.port : port;
|
|
181
|
+
// With our own socket the requested hostname IS the answer; with the
|
|
182
|
+
// caller's we ask the socket, because we never chose it.
|
|
183
|
+
const boundHost = ownServer ? tcp?.address ?? '127.0.0.1' : hostname;
|
|
184
|
+
const displayHost = boundHost === '0.0.0.0' || boundHost === '::' ? '127.0.0.1' : boundHost;
|
|
131
185
|
return {
|
|
132
186
|
url: `http://${displayHost}:${boundPort}`,
|
|
133
187
|
port: boundPort,
|
|
@@ -135,6 +189,16 @@ function httpHost(options) {
|
|
|
135
189
|
// Idempotent: the first call owns the shutdown, later ones await it.
|
|
136
190
|
closing ??= (async () => {
|
|
137
191
|
accepting = false;
|
|
192
|
+
if (ownServer) {
|
|
193
|
+
// Detach FIRST. The paths stop being ours the moment close() is
|
|
194
|
+
// called, so a request arriving now falls through to the caller
|
|
195
|
+
// rather than collecting a refusal from a host that is leaving.
|
|
196
|
+
server.off('request', onRequest);
|
|
197
|
+
// Then drain what we are already serving — and stop there. The
|
|
198
|
+
// socket, the idle connections and the shutdown are the caller's.
|
|
199
|
+
await Promise.allSettled([...inFlight]);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
138
202
|
// Drain BEFORE touching sockets — an in-flight request is work the
|
|
139
203
|
// caller is still waiting on, and dropping it would be the exact
|
|
140
204
|
// thing close() promises not to do.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpHost.js","sourceRoot":"","sources":["../../src/hosting/httpHost.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"httpHost.js","sourceRoot":"","sources":["../../src/hosting/httpHost.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,4CAAyC;AACzC,2CAA8C;AAyJ9C;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAqC;IACvD,eAAe,EAAE,GAAG;IACpB,kBAAkB,EAAE,GAAG;IACvB,qBAAqB,EAAE,GAAG;IAC1B,qBAAqB,EAAE,GAAG;IAC1B,kBAAkB,EAAE,GAAG;CACxB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,MAAM,oBAAoB,GAA8B,CAAC,WAAW,CAAC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I,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC;aAC1D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,OAAO,CAAC,GAAY;IAC3B,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CACzB,KAAuB,EACvB,IAAY,EACZ,GAAG,SAAmB;IAEtB,KAAK,MAAM,SAAS,IAAI,CAAC,IAAI,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC;QAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;QACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;IAClE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAVD,kCAUC"}
|
package/dist/hosting/index.js
CHANGED
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
* itself, parameterised by the JSON dialect it speaks. `nodeHost` is one
|
|
33
33
|
* configuration of it; an adapter for someone's container runtime is
|
|
34
34
|
* another. Two paths and five body shapes are all a second HTTP adapter
|
|
35
|
-
* re-decides.
|
|
35
|
+
* re-decides. Pass `server` and it attaches to a `node:http` server YOU
|
|
36
|
+
* own instead of binding one — for the container that gets a single port
|
|
37
|
+
* and must serve a WebSocket upgrade (or anything else) beside the agent.
|
|
36
38
|
* • `memorySessions()` — conversations in a Map, for tests and local dev.
|
|
37
39
|
* • `standingAgent({ agent, sessions, host, durability? })` — the composer.
|
|
38
40
|
* • `toEnvelope` / `readEnvelope` — pack a conversation, and refuse by name to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hosting/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hosting/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;;;AAEH,6CAAmD;AAA1C,uGAAA,QAAQ,OAAA;AAAE,uGAAA,QAAQ,OAAA;AAG3B,6CAAsD;AAA7C,uGAAA,QAAQ,OAAA;AAAE,0GAAA,WAAW,OAAA;AAS9B,yDAAqD;AAA5C,mHAAA,cAAc,OAAA;AACvB,6CAMuB;AALrB,yGAAA,UAAU,OAAA;AACV,+GAAA,gBAAgB,OAAA;AAChB,2GAAA,YAAY,OAAA;AACZ,4GAAA,aAAa,OAAA;AACb,4GAAA,aAAa,OAAA;AAEf,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AAEtB,yCAOqB;AANnB,8GAAA,iBAAiB,OAAA;AACjB,4GAAA,eAAe,OAAA;AACf,+GAAA,kBAAkB,OAAA;AAClB,iHAAA,oBAAoB,OAAA;AACpB,kHAAA,qBAAqB,OAAA;AACrB,8GAAA,iBAAiB,OAAA"}
|
package/dist/hosting/nodeHost.js
CHANGED
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
* a colleague's convention. A path is a deployment detail, so it is a knob
|
|
18
18
|
* here and absent from the port entirely.
|
|
19
19
|
*
|
|
20
|
+
* **The socket can be yours.** Pass `server` — a `node:http` server you
|
|
21
|
+
* created and listened on — and this adapter attaches its two routes to it
|
|
22
|
+
* instead of binding one, so a WebSocket upgrade or your own routes can share
|
|
23
|
+
* the port. `close()` then detaches and drains, and your socket stays up.
|
|
24
|
+
*
|
|
20
25
|
* **Streaming is the caller's choice, not the server's.** Send
|
|
21
26
|
* `Accept: text/event-stream` and the reply is Server-Sent Events, one `chunk`
|
|
22
27
|
* event per `reply.emit(...)` then a final `complete`. Send anything else and
|
|
@@ -85,8 +90,13 @@ function nodeHost(options = {}) {
|
|
|
85
90
|
// particular runtime's container-contract path literal.
|
|
86
91
|
invokePath: options.invokePath ?? '/invoke',
|
|
87
92
|
healthPath: options.healthPath ?? '/health',
|
|
93
|
+
// Passed through as given, never defaulted: with a caller-owned server
|
|
94
|
+
// there is no port to default, and a port passed WITH one is a caller who
|
|
95
|
+
// believes something untrue about where their agent answers — `httpHost`
|
|
96
|
+
// refuses that pair by name rather than picking a winner.
|
|
88
97
|
...(options.port !== undefined && { port: options.port }),
|
|
89
98
|
...(options.hostname !== undefined && { hostname: options.hostname }),
|
|
99
|
+
...(options.server !== undefined && { server: options.server }),
|
|
90
100
|
});
|
|
91
101
|
}
|
|
92
102
|
exports.nodeHost = nodeHost;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeHost.js","sourceRoot":"","sources":["../../src/hosting/nodeHost.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"nodeHost.js","sourceRoot":"","sources":["../../src/hosting/nodeHost.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;;AAEH,+CAA4F;AAqC5F,MAAM,SAAS,GAAG,UAAU,CAAC;AAE7B;;;;;;;GAOG;AACU,QAAA,QAAQ,GAAa;IAChC,WAAW,CAAC,KAAK;QACf,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3E,wEAAwE;QACxE,4EAA4E;QAC5E,MAA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AO,CAAC,UAAU,IAAI,SAAS;QAC3C,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,SAAS;QAC3C,uEAAuE;QACvE,0EAA0E;QAC1E,yEAAyE;QACzE,0DAA0D;QAC1D,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;QACzD,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrE,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;KAChE,CAAC,CAAC;AACL,CAAC;AAhBD,4BAgBC"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Produces an `Injection` with:
|
|
12
12
|
* - flavor: `'fact'`
|
|
13
13
|
* - trigger: configurable (default `'always'`)
|
|
14
|
-
* - inject: `systemPrompt`
|
|
14
|
+
* - inject: `systemPrompt` (default), or `messages` with a declared role
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* const userProfile = defineFact({
|
|
@@ -35,16 +35,28 @@ function defineFact(opts) {
|
|
|
35
35
|
if (!opts.data || opts.data.length === 0) {
|
|
36
36
|
throw new Error(`defineFact(${opts.id}): \`data\` is required.`);
|
|
37
37
|
}
|
|
38
|
-
// The
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
// The runtime guards read a WIDENED view on purpose. The declared type
|
|
39
|
+
// already pairs `slot` with `role` correctly, and TypeScript narrows so well
|
|
40
|
+
// that `opts.role` is provably present inside a `slot === 'messages'` branch
|
|
41
|
+
// — which makes the checks below unreachable *to the compiler* and therefore
|
|
42
|
+
// invisible to the JavaScript callers and `as never` casts they exist for. A
|
|
43
|
+
// refusal that only holds at compile time is not a refusal.
|
|
44
|
+
const raw = opts;
|
|
45
|
+
const toMessages = raw.slot === 'messages';
|
|
46
|
+
if (toMessages && !raw.role) {
|
|
47
|
+
throw new Error(`defineFact('${opts.id}'): \`slot: 'messages'\` requires a \`role\` — ` +
|
|
48
|
+
`'user', 'assistant', or 'system' on a provider that carries it. There is no ` +
|
|
49
|
+
`default: who appears to speak is a meaning your app owns, not one the library picks.`);
|
|
50
|
+
}
|
|
51
|
+
if (toMessages && raw.role === 'tool') {
|
|
52
|
+
throw new Error((0, messagesSlotRefusal_js_1.messagesToolRoleRefusal)(`defineFact('${opts.id}')`));
|
|
43
53
|
}
|
|
44
54
|
const trigger = opts.activeWhen
|
|
45
55
|
? { kind: 'rule', activeWhen: opts.activeWhen }
|
|
46
56
|
: { kind: 'always' };
|
|
47
|
-
const inject =
|
|
57
|
+
const inject = toMessages
|
|
58
|
+
? { messages: [{ role: raw.role, content: opts.data }] }
|
|
59
|
+
: { systemPrompt: opts.data };
|
|
48
60
|
const cache = (0, applyCachePolicy_js_1.resolveCachePolicy)('fact', opts.cache);
|
|
49
61
|
// Two-stage cast (`as unknown as Injection`) is required because
|
|
50
62
|
// `flavor: 'fact'` narrows tighter than `ContextSource`. Both stages
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineFact.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/factories/defineFact.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;
|
|
1
|
+
{"version":3,"file":"defineFact.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/factories/defineFact.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;AAIH,sEAAoE;AACpE,4EAAwE;AA+DxE,SAAgB,UAAU,CAAC,IAAuB;IAChD,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC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AAI,CAAC,KAAK,CAAC,CAAC;IACrD,iEAAiE;IACjE,qEAAqE;IACrE,uEAAuE;IACvE,gEAAgE;IAChE,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1D,MAAM,EAAE,MAAe;QACvB,OAAO;QACP,MAAM;QACN,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;KACnC,CAAyB,CAAC;AAC7B,CAAC;AA7CD,gCA6CC"}
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* Produces an `Injection` with:
|
|
13
13
|
* - flavor: `'instructions'`
|
|
14
14
|
* - trigger: `{ kind: 'rule', activeWhen }` (or `'always'` if omitted)
|
|
15
|
-
* - inject: `{ systemPrompt: prompt }`
|
|
15
|
+
* - inject: `{ systemPrompt: prompt }`, or `{ messages: [{ role, content }] }`
|
|
16
|
+
* when `slot: 'messages'` names the role it speaks as
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* const calmTone = defineInstruction({
|
|
@@ -39,14 +40,24 @@ function defineInstruction(opts) {
|
|
|
39
40
|
if (!opts.prompt || opts.prompt.length === 0) {
|
|
40
41
|
throw new Error(`defineInstruction(${opts.id}): \`prompt\` is required.`);
|
|
41
42
|
}
|
|
42
|
-
// Refused at run time as well as in the type
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
// Refused at run time as well as in the type, read through a widened view —
|
|
44
|
+
// see defineFact for why the widening is deliberate.
|
|
45
|
+
const raw = opts;
|
|
46
|
+
const toMessages = raw.slot === 'messages';
|
|
47
|
+
if (toMessages && !raw.role) {
|
|
48
|
+
throw new Error(`defineInstruction('${opts.id}'): \`slot: 'messages'\` requires a \`role\` — ` +
|
|
49
|
+
`'user', 'assistant', or 'system' on a provider that carries it. There is no ` +
|
|
50
|
+
`default: who appears to speak is a meaning your app owns, not one the library picks.`);
|
|
51
|
+
}
|
|
52
|
+
if (toMessages && raw.role === 'tool') {
|
|
53
|
+
throw new Error((0, messagesSlotRefusal_js_1.messagesToolRoleRefusal)(`defineInstruction('${opts.id}')`));
|
|
45
54
|
}
|
|
46
55
|
const trigger = opts.activeWhen
|
|
47
56
|
? { kind: 'rule', activeWhen: opts.activeWhen }
|
|
48
57
|
: { kind: 'always' };
|
|
49
|
-
const inject =
|
|
58
|
+
const inject = toMessages
|
|
59
|
+
? { messages: [{ role: raw.role, content: opts.prompt }] }
|
|
60
|
+
: { systemPrompt: opts.prompt };
|
|
50
61
|
const cache = (0, applyCachePolicy_js_1.resolveCachePolicy)('instruction', opts.cache);
|
|
51
62
|
return Object.freeze({
|
|
52
63
|
id: opts.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineInstruction.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/factories/defineInstruction.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"defineInstruction.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/factories/defineInstruction.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAIH,sEAAoE;AACpE,4EAAwE;AAsExE,SAAgB,iBAAiB,CAAC,IAA8B;IAC9D,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAC,EAAE,4BAA4B,CAAC,CAAC;IAC5E,CAAC;IACD,4EAA4E;IAC5E,q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,EAAE,CAAC;KACnC,CAAyB,CAAC;AAC7B,CAAC;AApCD,8CAoCC"}
|
|
@@ -1,44 +1,103 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* The messages-slot
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* RECORDED as injected — `context.injected` fired with
|
|
8
|
-
* slot composition counted it, the engine routed it —
|
|
9
|
-
* assembled its message list from the conversation
|
|
10
|
-
* never saw it. The recording said one thing and the
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* the
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
3
|
+
* The messages-slot refusals — said in the same words wherever they are said.
|
|
4
|
+
*
|
|
5
|
+
* ── The arc this module records ──────────────────────────────────────
|
|
6
|
+
* 7.19.1 refused `slot: 'messages'` BY NAME. An Injection targeting the
|
|
7
|
+
* messages slot was RECORDED as injected — `context.injected` fired with
|
|
8
|
+
* its content, the slot composition counted it, the engine routed it —
|
|
9
|
+
* while the request assembled its message list from the conversation
|
|
10
|
+
* itself, so the model never saw it. The recording said one thing and the
|
|
11
|
+
* wire said another, and absence beat that lie.
|
|
12
|
+
*
|
|
13
|
+
* 7.21.0 delivers it, so the refusal moves: from "this placement never
|
|
14
|
+
* reaches the model" to "this placement reaches the model, but not with
|
|
15
|
+
* THAT role on THIS provider, and not at THAT position this iteration."
|
|
16
|
+
* The two facts the old sentence bundled together are now separate, and
|
|
17
|
+
* each is decided against something real:
|
|
18
|
+
*
|
|
19
|
+
* • ROLE — the wire has no system role inside the message list on the
|
|
20
|
+
* Anthropic family (system is a separate top-level field) while the
|
|
21
|
+
* OpenAI family carries it. A provider declares what it carries
|
|
22
|
+
* (`LLMProvider.carriesInMessages`); a role it does not carry is
|
|
23
|
+
* REFUSED at run start, naming the provider and the roles it does
|
|
24
|
+
* carry. Never silently re-roled: changing who appears to speak is a
|
|
25
|
+
* meaning change the app must make, not the library.
|
|
26
|
+
*
|
|
27
|
+
* • POSITION — a delivered injection goes at the END of the history the
|
|
28
|
+
* iteration assembled. If its role would collide with the turn already
|
|
29
|
+
* there, or the tail is waiting on a tool result, delivery is DEFERRED
|
|
30
|
+
* to the next boundary and the deferral is recorded on
|
|
31
|
+
* `messagesDelivery.deferred`. Never a silent drop, never a reorder,
|
|
32
|
+
* never a split `tool_use` / `tool_result` pair.
|
|
33
|
+
*
|
|
34
|
+
* Both refusals are stated in full sentences that name the fix, because a
|
|
35
|
+
* refusal that does not teach just moves the puzzle.
|
|
26
36
|
*/
|
|
27
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.
|
|
38
|
+
exports.messagesDeferralNote = exports.messagesToolRoleRefusal = exports.messagesRoleRefusal = void 0;
|
|
39
|
+
/** Render a role list the way the refusals quote it. */
|
|
40
|
+
function listRoles(roles) {
|
|
41
|
+
if (roles.length === 0)
|
|
42
|
+
return 'no roles at all';
|
|
43
|
+
if (roles.length === 1)
|
|
44
|
+
return `\`${roles[0]}\``;
|
|
45
|
+
const quoted = roles.map((r) => `\`${r}\``);
|
|
46
|
+
return `${quoted.slice(0, -1).join(', ')} and ${quoted[quoted.length - 1]}`;
|
|
47
|
+
}
|
|
29
48
|
/**
|
|
30
|
-
* The refusal
|
|
31
|
-
*
|
|
32
|
-
*
|
|
49
|
+
* The role refusal (D2), addressed from `site` (e.g.
|
|
50
|
+
* `defineFact('turn-time')` or the run-start check).
|
|
51
|
+
*
|
|
52
|
+
* Thrown when a `slot: 'messages'` injection declares a role the attached
|
|
53
|
+
* provider drops on the wire. The alternative — quietly rewriting the role
|
|
54
|
+
* to one that fits — would make the recording true and the meaning false.
|
|
55
|
+
*/
|
|
56
|
+
function messagesRoleRefusal(args) {
|
|
57
|
+
return (`${args.site}: \`role: '${args.role}'\` cannot be delivered inside the message ` +
|
|
58
|
+
`list by the '${args.providerName}' provider, which carries ${listRoles(args.carries)}. ` +
|
|
59
|
+
`The message would be recorded as injected and dropped on the wire, so it is ` +
|
|
60
|
+
`refused here instead. Pick a role this provider carries, put the content in ` +
|
|
61
|
+
`\`slot: 'system-prompt'\` (delivered by every provider), or return it from the ` +
|
|
62
|
+
`tool whose result it is about — a tool result IS a real message at the recency ` +
|
|
63
|
+
`this option is reaching for. The role is never rewritten for you: who appears ` +
|
|
64
|
+
`to speak is your decision, not the library's.`);
|
|
65
|
+
}
|
|
66
|
+
exports.messagesRoleRefusal = messagesRoleRefusal;
|
|
67
|
+
/**
|
|
68
|
+
* The role refusal for a role no wire can carry (`'tool'`).
|
|
69
|
+
*
|
|
70
|
+
* A tool message answers one specific `tool_use` id. An injection has no
|
|
71
|
+
* call to answer, so the message it would produce is malformed on every
|
|
72
|
+
* provider — this one is refused by shape, not by capability.
|
|
73
|
+
*/
|
|
74
|
+
function messagesToolRoleRefusal(site) {
|
|
75
|
+
return (`${site}: \`role: 'tool'\` cannot be injected. A tool message is the answer to a ` +
|
|
76
|
+
`specific tool call and carries that call's id; an injection has no call to ` +
|
|
77
|
+
`answer, so no provider would accept the result. Use \`'user'\` or \`'assistant'\` ` +
|
|
78
|
+
`(\`'system'\` on providers that carry it), or return the content from the tool itself.`);
|
|
79
|
+
}
|
|
80
|
+
exports.messagesToolRoleRefusal = messagesToolRoleRefusal;
|
|
81
|
+
/**
|
|
82
|
+
* The deferral note (D3) — a sentence on `messagesDelivery.deferred`, which
|
|
83
|
+
* is the committed answer to "why is my declaration not on the wire yet?".
|
|
84
|
+
*
|
|
85
|
+
* Not an error: the next boundary retries it unchanged. The note names what
|
|
86
|
+
* blocked it so the reader does not have to reconstruct the window to find out.
|
|
33
87
|
*/
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
`
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
88
|
+
function messagesDeferralNote(args) {
|
|
89
|
+
if (args.reason === 'unanswered-tool-call') {
|
|
90
|
+
return (`'${args.injectionId}' was held back this iteration: the window ends on a tool ` +
|
|
91
|
+
`call that has not been answered yet, and placing a message there would split a ` +
|
|
92
|
+
`tool_use / tool_result pair. It is retried at the next boundary, unchanged.`);
|
|
93
|
+
}
|
|
94
|
+
return (`'${args.injectionId}' was held back this iteration: it would land as ` +
|
|
95
|
+
`\`${args.role}\` immediately after a \`${args.tailRole ?? 'unknown'}\` turn, and ` +
|
|
96
|
+
`providers reject two turns of the same role in a row. It is retried at the next ` +
|
|
97
|
+
`boundary, unchanged — nothing is reordered to make room. In a tool-using loop the ` +
|
|
98
|
+
`window ends on the user's turn or on tool results, so a \`user\` role typically ` +
|
|
99
|
+
`never gets a slot; use \`assistant\`, use \`system\` on a provider that carries it, ` +
|
|
100
|
+
`or return the content from the tool.`);
|
|
42
101
|
}
|
|
43
|
-
exports.
|
|
102
|
+
exports.messagesDeferralNote = messagesDeferralNote;
|
|
44
103
|
//# sourceMappingURL=messagesSlotRefusal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messagesSlotRefusal.js","sourceRoot":"","sources":["../../../src/lib/injection-engine/messagesSlotRefusal.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"messagesSlotRefusal.js","sourceRoot":"","sources":["../../../src/lib/injection-engine/messagesSlotRefusal.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;AAIH,wDAAwD;AACxD,SAAS,SAAS,CAAC,KAA0B;IAC3C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,iBAAiB,CAAC;IACjD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACjD,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,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ection(inj) {
|
|
|
33
33
|
...(meta?.autoActivate && {
|
|
34
34
|
autoActivate: meta.autoActivate,
|
|
35
35
|
}),
|
|
36
|
+
// The cache directive rides across too — see the field's note. Without it
|
|
37
|
+
// the cache decision reads `undefined` for every injection and defaults to
|
|
38
|
+
// "never cacheable", which silently discards what the consumer declared.
|
|
39
|
+
...(meta?.cache !== undefined && {
|
|
40
|
+
cache: meta.cache,
|
|
41
|
+
}),
|
|
36
42
|
inject: {
|
|
37
43
|
...(inj.inject.systemPrompt && { systemPrompt: inj.inject.systemPrompt }),
|
|
38
44
|
...(inj.inject.messages && { messages: inj.inject.messages.map((m) => ({ ...m })) }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/injection-engine/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/injection-engine/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAuQH,wEAAwE;AACxE,SAAgB,sBAAsB,CAAC,GAAc;IACnD,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,MAAM,IAAI,GAAG,GAAG,CAAC,QAEJ,CAAC;IACd,MAAM,GAAG,GAAoB;QAC3B,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,GAAG,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC;QACxD,GAAG,CAAC,IAAI,EAAE,WAAW,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAA6C,EAAE,CAAC;QAC7F,GAAG,CAAC,IAAI,EAAE,YAAY,IAAI;YACxB,YAAY,EAAE,IAAI,CAAC,YAA+C;SACnE,CAAC;QACF,0EAA0E;QAC1E,2EAA2E;QAC3E,yEAAyE;QACzE,GAAG,CAAC,IAAI,EAAE,KAAK,KAAK,SAAS,IAAI;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAiC;SAC9C,CAAC;QACF,MAAM,EAAE;YACN,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YACzE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACpF,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI;gBACtB,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBAClC,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE;oBACvB,WAAW,EAAE,GAAG,CAAC,EAAE;iBACpB,CAAC,CAAC;aACJ,CAAC;SACH;KACF,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC;AAjCD,wDAiCC"}
|
|
@@ -13,18 +13,22 @@
|
|
|
13
13
|
* the lie legible: a reader could pick a role, read it back off the
|
|
14
14
|
* definition, and be told a role the run would never use.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* `
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* would then claim delivery.
|
|
16
|
+
* When this was written the messages slot did not reach the model at all,
|
|
17
|
+
* so honouring `asRole` would have traded a dead option for a
|
|
18
|
+
* recorded-and-dropped one. Since 7.21.0 it DOES reach the model: a
|
|
19
|
+
* `slot: 'messages'` injection is delivered into `scope.history`, subject to
|
|
20
|
+
* what the provider carries and to the sequence rule
|
|
21
|
+
* (`lib/injection-engine/messagesSlotRefusal.ts`). The mechanism a
|
|
22
|
+
* role-differentiated recall would ride now exists.
|
|
24
23
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
24
|
+
* The refusal still stands, and the reason it stands is now the only reason
|
|
25
|
+
* it ever really had: **nobody has asked for it.** A recall formatter that
|
|
26
|
+
* emits a non-system role can be written today — it becomes a messages-slot
|
|
27
|
+
* injection with a declared role, checked like any other. What is missing is
|
|
28
|
+
* evidence that role-differentiated recall answers a real question better
|
|
29
|
+
* than the system prompt does. Building it because the machinery exists is
|
|
30
|
+
* how a library grows options nobody reads — which is exactly the thing this
|
|
31
|
+
* refusal is here to undo. Field evidence decides, not availability.
|
|
28
32
|
*
|
|
29
33
|
* A throw where there was a silent lie is a fix, not a break: nothing that
|
|
30
34
|
* worked stops working, and something that never worked stops pretending.
|
|
@@ -40,10 +44,12 @@ function asRoleRefusal(site) {
|
|
|
40
44
|
return (`${site}: \`asRole\` has never been read. Every formatter this library ships ` +
|
|
41
45
|
`writes \`role: 'system'\`, so recall is always injected as system — the option ` +
|
|
42
46
|
`was stored on the definition and ignored by the run. It is removed rather than ` +
|
|
43
|
-
`honoured
|
|
44
|
-
`
|
|
45
|
-
`
|
|
46
|
-
`
|
|
47
|
+
`honoured: it was refused before the messages slot could deliver anything, and ` +
|
|
48
|
+
`it stays refused now that it can, because no field evidence asks for ` +
|
|
49
|
+
`role-differentiated recall. The machinery is there — a recall formatter that ` +
|
|
50
|
+
`emits a non-system role becomes a \`slot: 'messages'\` injection with a declared ` +
|
|
51
|
+
`role — so this is a decision, not a limitation. Drop the option: the behaviour ` +
|
|
52
|
+
`you already had does not change.`);
|
|
47
53
|
}
|
|
48
54
|
exports.asRoleRefusal = asRoleRefusal;
|
|
49
55
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asRoleRefusal.js","sourceRoot":"","sources":["../../src/memory/asRoleRefusal.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"asRoleRefusal.js","sourceRoot":"","sources":["../../src/memory/asRoleRefusal.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;AAEH;;;;GAIG;AACH,SAAgB,aAAa,CAAC,IAAY;IACxC,OAAO,CACL,GAAG,IAAI,uEAAuE;QAC9E,iFAAiF;QACjF,iFAAiF;QACjF,gFAAgF;QAChF,uEAAuE;QACvE,+EAA+E;QAC/E,mFAAmF;QACnF,iFAAiF;QACjF,kCAAkC,CACnC,CAAC;AACJ,CAAC;AAZD,sCAYC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,OAAe,EAAE,IAAY;IACxD,IAAI,QAAQ,IAAI,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC;AAFD,oCAEC"}
|
|
@@ -198,6 +198,12 @@ function withCircuitBreaker(inner, options = {}) {
|
|
|
198
198
|
}
|
|
199
199
|
const wrapped = {
|
|
200
200
|
name: inner.name,
|
|
201
|
+
// Same wire, same roles — a breaker only decides WHETHER to call. See the
|
|
202
|
+
// note in withRetry: this rebuilds the provider object, so the capability
|
|
203
|
+
// has to be carried across explicitly or it degrades to the floor.
|
|
204
|
+
...(inner.carriesInMessages !== undefined && {
|
|
205
|
+
carriesInMessages: inner.carriesInMessages,
|
|
206
|
+
}),
|
|
201
207
|
async complete(req, hooks) {
|
|
202
208
|
rejectFastIfOpen();
|
|
203
209
|
try {
|