agentfootprint 7.24.0 → 7.26.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 +5 -3
- package/ai-instructions/claude-code/SKILL.md +1 -1
- package/dist/adapters/hosting/agentcore.js +112 -1
- package/dist/adapters/hosting/agentcore.js.map +1 -1
- package/dist/adapters/llm/AnthropicProvider.js +10 -0
- package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
- package/dist/adapters/llm/BedrockProvider.js +13 -1
- package/dist/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/adapters/llm/BrowserAnthropicProvider.js +6 -0
- package/dist/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
- package/dist/adapters/llm/BrowserOpenAIProvider.js +18 -0
- package/dist/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
- package/dist/adapters/llm/MockProvider.js +9 -0
- package/dist/adapters/llm/MockProvider.js.map +1 -1
- package/dist/adapters/llm/OpenAIProvider.js +21 -0
- package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/conventions.js +12 -0
- package/dist/conventions.js.map +1 -1
- package/dist/core/Agent.js +56 -2
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/AgentBuilder.js +98 -1
- package/dist/core/agent/AgentBuilder.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +12 -2
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +12 -3
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/outputEnforcement.js +192 -0
- package/dist/core/agent/outputEnforcement.js.map +1 -0
- package/dist/core/agent/stages/callLLM.js +31 -1
- package/dist/core/agent/stages/callLLM.js.map +1 -1
- package/dist/core/agent/stages/outputRetry.js +102 -0
- package/dist/core/agent/stages/outputRetry.js.map +1 -0
- package/dist/core/agent/stages/route.js +111 -6
- package/dist/core/agent/stages/route.js.map +1 -1
- package/dist/core/outputSchema.js.map +1 -1
- package/dist/esm/adapters/hosting/agentcore.d.ts +50 -1
- package/dist/esm/adapters/hosting/agentcore.js +110 -0
- package/dist/esm/adapters/hosting/agentcore.js.map +1 -1
- package/dist/esm/adapters/llm/AnthropicProvider.d.ts +10 -0
- package/dist/esm/adapters/llm/AnthropicProvider.js +10 -0
- package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +9 -0
- package/dist/esm/adapters/llm/BedrockProvider.js +13 -1
- package/dist/esm/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +1 -0
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.js +6 -0
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +4 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +18 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
- package/dist/esm/adapters/llm/MockProvider.d.ts +9 -0
- package/dist/esm/adapters/llm/MockProvider.js +9 -0
- package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +12 -0
- package/dist/esm/adapters/llm/OpenAIProvider.js +21 -0
- package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/esm/adapters/types.d.ts +46 -0
- package/dist/esm/conventions.d.ts +4 -0
- package/dist/esm/conventions.js +12 -0
- package/dist/esm/conventions.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +26 -1
- package/dist/esm/core/Agent.js +56 -2
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.d.ts +15 -0
- package/dist/esm/core/agent/AgentBuilder.js +98 -1
- package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
- package/dist/esm/core/agent/buildAgentChart.d.ts +13 -1
- package/dist/esm/core/agent/buildAgentChart.js +12 -2
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js +12 -3
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/outputEnforcement.d.ts +173 -0
- package/dist/esm/core/agent/outputEnforcement.js +180 -0
- package/dist/esm/core/agent/outputEnforcement.js.map +1 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +15 -0
- package/dist/esm/core/agent/stages/callLLM.js +31 -1
- package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
- package/dist/esm/core/agent/stages/outputRetry.d.ts +34 -0
- package/dist/esm/core/agent/stages/outputRetry.js +98 -0
- package/dist/esm/core/agent/stages/outputRetry.js.map +1 -0
- package/dist/esm/core/agent/stages/route.d.ts +18 -2
- package/dist/esm/core/agent/stages/route.js +111 -6
- package/dist/esm/core/agent/stages/route.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +18 -0
- package/dist/esm/core/outputSchema.d.ts +51 -0
- package/dist/esm/core/outputSchema.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +47 -1
- package/dist/esm/events/registry.d.ts +3 -1
- package/dist/esm/events/registry.js +2 -0
- package/dist/esm/events/registry.js.map +1 -1
- package/dist/esm/hosting/errors.d.ts +44 -2
- package/dist/esm/hosting/errors.js +63 -0
- package/dist/esm/hosting/errors.js.map +1 -1
- package/dist/esm/hosting/headers.d.ts +16 -0
- package/dist/esm/hosting/headers.js +24 -0
- package/dist/esm/hosting/headers.js.map +1 -0
- package/dist/esm/hosting/httpHost.d.ts +70 -4
- package/dist/esm/hosting/httpHost.js +211 -47
- package/dist/esm/hosting/httpHost.js.map +1 -1
- package/dist/esm/hosting/index.d.ts +23 -8
- package/dist/esm/hosting/index.js +21 -6
- package/dist/esm/hosting/index.js.map +1 -1
- package/dist/esm/hosting/nodeHost.d.ts +23 -0
- package/dist/esm/hosting/nodeHost.js +21 -1
- package/dist/esm/hosting/nodeHost.js.map +1 -1
- package/dist/esm/hosting/types.d.ts +212 -6
- package/dist/esm/hosting/types.js +7 -5
- package/dist/esm/hosting/types.js.map +1 -1
- package/dist/esm/hosting/webSocketConversation.d.ts +101 -0
- package/dist/esm/hosting/webSocketConversation.js +341 -0
- package/dist/esm/hosting/webSocketConversation.js.map +1 -0
- package/dist/esm/hosting/webSocketFrames.d.ts +164 -0
- package/dist/esm/hosting/webSocketFrames.js +284 -0
- package/dist/esm/hosting/webSocketFrames.js.map +1 -0
- package/dist/esm/hosting-providers.d.ts +7 -2
- package/dist/esm/hosting-providers.js +7 -2
- package/dist/esm/hosting-providers.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/resilience/withCircuitBreaker.js +5 -0
- package/dist/esm/resilience/withCircuitBreaker.js.map +1 -1
- package/dist/esm/resilience/withFallback.js +5 -0
- package/dist/esm/resilience/withFallback.js.map +1 -1
- package/dist/esm/resilience/withRetry.js +6 -0
- package/dist/esm/resilience/withRetry.js.map +1 -1
- package/dist/events/registry.js +2 -0
- package/dist/events/registry.js.map +1 -1
- package/dist/hosting/errors.js +66 -1
- package/dist/hosting/errors.js.map +1 -1
- package/dist/hosting/headers.js +28 -0
- package/dist/hosting/headers.js.map +1 -0
- package/dist/hosting/httpHost.js +211 -47
- package/dist/hosting/httpHost.js.map +1 -1
- package/dist/hosting/index.js +23 -6
- package/dist/hosting/index.js.map +1 -1
- package/dist/hosting/nodeHost.js +20 -0
- package/dist/hosting/nodeHost.js.map +1 -1
- package/dist/hosting/types.js +7 -5
- package/dist/hosting/types.js.map +1 -1
- package/dist/hosting/webSocketConversation.js +345 -0
- package/dist/hosting/webSocketConversation.js.map +1 -0
- package/dist/hosting/webSocketFrames.js +297 -0
- package/dist/hosting/webSocketFrames.js.map +1 -0
- package/dist/hosting-providers.js +8 -2
- package/dist/hosting-providers.js.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/resilience/withCircuitBreaker.js +5 -0
- package/dist/resilience/withCircuitBreaker.js.map +1 -1
- package/dist/resilience/withFallback.js +5 -0
- package/dist/resilience/withFallback.js.map +1 -1
- package/dist/resilience/withRetry.js +6 -0
- package/dist/resilience/withRetry.js.map +1 -1
- package/dist/types/adapters/hosting/agentcore.d.ts +50 -1
- package/dist/types/adapters/hosting/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/llm/AnthropicProvider.d.ts +10 -0
- package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/BedrockProvider.d.ts +9 -0
- package/dist/types/adapters/llm/BedrockProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts +1 -0
- package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts +4 -0
- package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/MockProvider.d.ts +9 -0
- package/dist/types/adapters/llm/MockProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/OpenAIProvider.d.ts +12 -0
- package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
- package/dist/types/adapters/types.d.ts +46 -0
- package/dist/types/adapters/types.d.ts.map +1 -1
- package/dist/types/conventions.d.ts +4 -0
- package/dist/types/conventions.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +26 -1
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/AgentBuilder.d.ts +15 -0
- package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts +13 -1
- 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/outputEnforcement.d.ts +174 -0
- package/dist/types/core/agent/outputEnforcement.d.ts.map +1 -0
- package/dist/types/core/agent/stages/callLLM.d.ts +15 -0
- package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
- package/dist/types/core/agent/stages/outputRetry.d.ts +35 -0
- package/dist/types/core/agent/stages/outputRetry.d.ts.map +1 -0
- package/dist/types/core/agent/stages/route.d.ts +18 -2
- package/dist/types/core/agent/stages/route.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/outputSchema.d.ts +51 -0
- package/dist/types/core/outputSchema.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +47 -1
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/registry.d.ts +3 -1
- package/dist/types/events/registry.d.ts.map +1 -1
- package/dist/types/hosting/errors.d.ts +44 -2
- package/dist/types/hosting/errors.d.ts.map +1 -1
- package/dist/types/hosting/headers.d.ts +17 -0
- package/dist/types/hosting/headers.d.ts.map +1 -0
- package/dist/types/hosting/httpHost.d.ts +70 -4
- package/dist/types/hosting/httpHost.d.ts.map +1 -1
- package/dist/types/hosting/index.d.ts +23 -8
- package/dist/types/hosting/index.d.ts.map +1 -1
- package/dist/types/hosting/nodeHost.d.ts +23 -0
- package/dist/types/hosting/nodeHost.d.ts.map +1 -1
- package/dist/types/hosting/types.d.ts +212 -6
- package/dist/types/hosting/types.d.ts.map +1 -1
- package/dist/types/hosting/webSocketConversation.d.ts +102 -0
- package/dist/types/hosting/webSocketConversation.d.ts.map +1 -0
- package/dist/types/hosting/webSocketFrames.d.ts +165 -0
- package/dist/types/hosting/webSocketFrames.d.ts.map +1 -0
- package/dist/types/hosting-providers.d.ts +7 -2
- package/dist/types/hosting-providers.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/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
|
@@ -34,11 +34,27 @@
|
|
|
34
34
|
* detaches and drains without closing a socket it never opened. That is the
|
|
35
35
|
* whole difference; every other law on this page is the same either way.
|
|
36
36
|
*
|
|
37
|
+
* ── The third door: a conversation ───────────────────────────────────────────
|
|
38
|
+
* `serveConversations(handler)` sits beside `serve(handler)` and takes upgrades
|
|
39
|
+
* on `conversationPath`, because `HostRequest → HostReply` is one exchange and
|
|
40
|
+
* some doors are not. Give a host a `conversationPath` and it declares
|
|
41
|
+
* `'conversation'`; leave it out and `serveConversations` refuses by name.
|
|
42
|
+
*
|
|
43
|
+
* **Both doors share ONE socket.** That is not an optimisation, it is the
|
|
44
|
+
* premise: the runtimes that need a conversation are the ones that hand a
|
|
45
|
+
* container exactly one port, so a host whose two doors each bound their own
|
|
46
|
+
* would fail with `EADDRINUSE` on the deployment it exists for. On a private
|
|
47
|
+
* socket the server is created by whichever door opens first and closed by
|
|
48
|
+
* whichever closes last; on a caller-owned one each door attaches and detaches
|
|
49
|
+
* its own listener and neither touches the socket.
|
|
50
|
+
*
|
|
37
51
|
* Pattern: Template method via configuration (Strategy on the wire format).
|
|
38
52
|
* Everything HTTP lives here and in the wires; `types.ts` knows none of it.
|
|
39
53
|
*/
|
|
40
54
|
import { encodeSSE } from '../stream.js';
|
|
41
55
|
import { HostClosedError } from './errors.js';
|
|
56
|
+
import { lowerCasedHeaders } from './headers.js';
|
|
57
|
+
import { conversationDoor, } from './webSocketConversation.js';
|
|
42
58
|
/**
|
|
43
59
|
* Status codes mapped by refusal code. Anything else is a 500.
|
|
44
60
|
*
|
|
@@ -64,6 +80,20 @@ const STATUS_BY_CODE = {
|
|
|
64
80
|
*/
|
|
65
81
|
const AWAITING_STATUS = 202;
|
|
66
82
|
const DEFAULT_CAPABILITIES = ['streaming'];
|
|
83
|
+
/**
|
|
84
|
+
* What a conversation door caps when the deployment did not say.
|
|
85
|
+
*
|
|
86
|
+
* Both are memory this process pays for while somebody else fills it, so
|
|
87
|
+
* "unlimited" is not one of the options — and since what is enforced must be
|
|
88
|
+
* what is declared, the resolved numbers are what the host reports.
|
|
89
|
+
* One mebibyte is chosen as a number large enough that no ordinary protocol
|
|
90
|
+
* frame meets it and small enough that a hostile one cannot spend the heap;
|
|
91
|
+
* a deployment with a real ceiling passes its own.
|
|
92
|
+
*/
|
|
93
|
+
const DEFAULT_CONVERSATION_LIMITS = {
|
|
94
|
+
maxFrameBytes: 1_048_576,
|
|
95
|
+
maxPendingBytes: 1_048_576,
|
|
96
|
+
};
|
|
67
97
|
/**
|
|
68
98
|
* An HTTP host for one handler, speaking the dialect you hand it.
|
|
69
99
|
*
|
|
@@ -72,7 +102,7 @@ const DEFAULT_CAPABILITIES = ['streaming'];
|
|
|
72
102
|
* httpHost({ name: 'myRuntime', wire: myWire, invokePath: '/v1/run', healthPath: '/up' });
|
|
73
103
|
*/
|
|
74
104
|
export function httpHost(options) {
|
|
75
|
-
const { name, wire, invokePath, healthPath } = options;
|
|
105
|
+
const { name, wire, invokePath, healthPath, conversationPath } = options;
|
|
76
106
|
const ownServer = options.server;
|
|
77
107
|
// Refused at construction, not ignored at serve time: a `port` next to a
|
|
78
108
|
// server this host does not bind is a caller who believes something untrue
|
|
@@ -86,10 +116,171 @@ export function httpHost(options) {
|
|
|
86
116
|
}
|
|
87
117
|
const port = options.port ?? 8080;
|
|
88
118
|
const hostname = options.hostname ?? '0.0.0.0';
|
|
89
|
-
|
|
119
|
+
// A door that exists is a capability that can be honoured; one built without
|
|
120
|
+
// a path is not, and says so rather than being discovered at runtime.
|
|
121
|
+
const capabilities = options.capabilities ??
|
|
122
|
+
(conversationPath !== undefined
|
|
123
|
+
? [...DEFAULT_CAPABILITIES, 'conversation']
|
|
124
|
+
: DEFAULT_CAPABILITIES);
|
|
125
|
+
// Resolved once, declared as resolved: `host.conversationLimits` is what is
|
|
126
|
+
// actually enforced, never what was passed in and quietly topped up.
|
|
127
|
+
const conversationLimits = {
|
|
128
|
+
...DEFAULT_CONVERSATION_LIMITS,
|
|
129
|
+
...options.conversationLimits,
|
|
130
|
+
};
|
|
131
|
+
// ── The socket both doors stand on ─────────────────────────────────
|
|
132
|
+
//
|
|
133
|
+
// Refcounted, because the deployment this exists for hands a container ONE
|
|
134
|
+
// port: two doors that each bound their own would be `EADDRINUSE` on exactly
|
|
135
|
+
// the machine that needed both. First door in creates and listens; last door
|
|
136
|
+
// out drains and closes. On a caller-owned server there is nothing to count —
|
|
137
|
+
// the socket was never ours to open or to close.
|
|
138
|
+
let socket;
|
|
139
|
+
let holders = 0;
|
|
140
|
+
async function acquireSocket() {
|
|
141
|
+
if (ownServer) {
|
|
142
|
+
if (!ownServer.listening) {
|
|
143
|
+
throw new Error(`[hosting] httpHost('${name}') was handed a server that is not listening yet. ` +
|
|
144
|
+
`This handle promises the url and port it is answering on, and a server with ` +
|
|
145
|
+
`no address has neither. Call server.listen(...) first, then serve() — ` +
|
|
146
|
+
`attaching after listen() is safe and is the intended order.`);
|
|
147
|
+
}
|
|
148
|
+
return ownServer;
|
|
149
|
+
}
|
|
150
|
+
holders += 1;
|
|
151
|
+
socket ??= (async () => {
|
|
152
|
+
const { createServer } = await import('node:http');
|
|
153
|
+
const created = createServer();
|
|
154
|
+
await new Promise((resolve, reject) => {
|
|
155
|
+
created.once('error', reject);
|
|
156
|
+
created.listen(port, hostname, resolve);
|
|
157
|
+
});
|
|
158
|
+
return created;
|
|
159
|
+
})();
|
|
160
|
+
try {
|
|
161
|
+
return await socket;
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
// A socket that never came up is not one anybody is holding.
|
|
165
|
+
holders -= 1;
|
|
166
|
+
socket = undefined;
|
|
167
|
+
throw err;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async function releaseSocket() {
|
|
171
|
+
if (ownServer)
|
|
172
|
+
return;
|
|
173
|
+
holders -= 1;
|
|
174
|
+
if (holders > 0)
|
|
175
|
+
return;
|
|
176
|
+
const held = socket;
|
|
177
|
+
socket = undefined;
|
|
178
|
+
if (!held)
|
|
179
|
+
return;
|
|
180
|
+
const server = await held.catch(() => undefined);
|
|
181
|
+
if (!server)
|
|
182
|
+
return;
|
|
183
|
+
server.closeIdleConnections();
|
|
184
|
+
await new Promise((resolve) => server.close(() => resolve()));
|
|
185
|
+
}
|
|
186
|
+
/** Where this host is answering — the caller's address, or the one we bound. */
|
|
187
|
+
function addressOf(server) {
|
|
188
|
+
const address = server.address();
|
|
189
|
+
const tcp = typeof address === 'object' && address !== null ? address : undefined;
|
|
190
|
+
if (ownServer && !tcp) {
|
|
191
|
+
throw new Error(`[hosting] httpHost('${name}') was handed a server bound to ${JSON.stringify(address)}` +
|
|
192
|
+
` — a pipe or socket path, which has no port. This handle promises a url and a ` +
|
|
193
|
+
`port, and inventing one would be worse than refusing. Serve on a TCP server, or ` +
|
|
194
|
+
`drive the handler yourself.`);
|
|
195
|
+
}
|
|
196
|
+
const boundPort = tcp ? tcp.port : port;
|
|
197
|
+
// With our own socket the requested hostname IS the answer; with the
|
|
198
|
+
// caller's we ask the socket, because we never chose it.
|
|
199
|
+
const boundHost = ownServer ? tcp?.address ?? '127.0.0.1' : hostname;
|
|
200
|
+
const displayHost = boundHost === '0.0.0.0' || boundHost === '::' ? '127.0.0.1' : boundHost;
|
|
201
|
+
return { url: `http://${displayHost}:${boundPort}`, port: boundPort };
|
|
202
|
+
}
|
|
203
|
+
let conversationsServing = false;
|
|
90
204
|
return {
|
|
91
205
|
name,
|
|
92
206
|
capabilities,
|
|
207
|
+
conversationLimits,
|
|
208
|
+
async serveConversations(handler) {
|
|
209
|
+
if (conversationPath === undefined) {
|
|
210
|
+
throw new Error(`[hosting] the '${name}' host was built without a 'conversationPath', so it has no ` +
|
|
211
|
+
`door to take conversations on and does not declare 'conversation' in its ` +
|
|
212
|
+
`capabilities. Build it with a conversationPath, or feature-detect with ` +
|
|
213
|
+
`host.capabilities.includes('conversation') and use serve() instead.`);
|
|
214
|
+
}
|
|
215
|
+
if (conversationsServing) {
|
|
216
|
+
throw new Error(`[hosting] the '${name}' host is already serving conversations on ` +
|
|
217
|
+
`'${conversationPath}'. One door, one handler — two would make which handler ` +
|
|
218
|
+
`receives a conversation depend on registration order. Close the first handle ` +
|
|
219
|
+
`before serving again.`);
|
|
220
|
+
}
|
|
221
|
+
conversationsServing = true;
|
|
222
|
+
let accepting = true;
|
|
223
|
+
let closing;
|
|
224
|
+
const door = conversationDoor({
|
|
225
|
+
hostName: name,
|
|
226
|
+
path: conversationPath,
|
|
227
|
+
limits: conversationLimits,
|
|
228
|
+
...(wire.readConversation && { readConversation: wire.readConversation.bind(wire) }),
|
|
229
|
+
handler,
|
|
230
|
+
accepting: () => accepting,
|
|
231
|
+
});
|
|
232
|
+
const onUpgrade = (request, socketOfConversation) => {
|
|
233
|
+
if (door.handleUpgrade(request, socketOfConversation))
|
|
234
|
+
return;
|
|
235
|
+
// Not our path. On the caller's server that is theirs to answer or to
|
|
236
|
+
// ignore, exactly as an unmatched request path is; on ours nobody else
|
|
237
|
+
// can, so leaving the socket hanging would be the one dishonest option.
|
|
238
|
+
if (ownServer)
|
|
239
|
+
return;
|
|
240
|
+
socketOfConversation.end('HTTP/1.1 400 Bad Request\r\nconnection: close\r\n\r\n' +
|
|
241
|
+
`[hosting] the '${name}' host takes conversations on ${conversationPath}.`);
|
|
242
|
+
};
|
|
243
|
+
let server;
|
|
244
|
+
try {
|
|
245
|
+
server = await acquireSocket();
|
|
246
|
+
}
|
|
247
|
+
catch (err) {
|
|
248
|
+
conversationsServing = false;
|
|
249
|
+
throw err;
|
|
250
|
+
}
|
|
251
|
+
server.on('upgrade', onUpgrade);
|
|
252
|
+
let where;
|
|
253
|
+
try {
|
|
254
|
+
where = addressOf(server);
|
|
255
|
+
}
|
|
256
|
+
catch (err) {
|
|
257
|
+
server.off('upgrade', onUpgrade);
|
|
258
|
+
conversationsServing = false;
|
|
259
|
+
await releaseSocket();
|
|
260
|
+
throw err;
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
url: where.url,
|
|
264
|
+
port: where.port,
|
|
265
|
+
close() {
|
|
266
|
+
closing ??= (async () => {
|
|
267
|
+
accepting = false;
|
|
268
|
+
if (ownServer)
|
|
269
|
+
server.off('upgrade', onUpgrade);
|
|
270
|
+
// End the live conversations BEFORE letting go of the socket. An
|
|
271
|
+
// upgraded socket keeps `server.close()` waiting forever — measured,
|
|
272
|
+
// not assumed — so a door that walked away from its conversations
|
|
273
|
+
// would hang every shutdown that shares this socket.
|
|
274
|
+
await door.closeAll(`the '${name}' host is shutting down`);
|
|
275
|
+
if (!ownServer)
|
|
276
|
+
server.off('upgrade', onUpgrade);
|
|
277
|
+
conversationsServing = false;
|
|
278
|
+
await releaseSocket();
|
|
279
|
+
})();
|
|
280
|
+
return closing;
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
},
|
|
93
284
|
async serve(handler) {
|
|
94
285
|
const startedAt = Date.now();
|
|
95
286
|
const inFlight = new Set();
|
|
@@ -123,42 +314,20 @@ export function httpHost(options) {
|
|
|
123
314
|
inFlight.add(served);
|
|
124
315
|
void served.finally(() => inFlight.delete(served));
|
|
125
316
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
`This handle promises the url and port it is answering on, and a server with ` +
|
|
132
|
-
`no address has neither. Call server.listen(...) first, then serve() — ` +
|
|
133
|
-
`attaching after listen() is safe and is the intended order.`);
|
|
134
|
-
}
|
|
135
|
-
server.on('request', onRequest);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
const { createServer } = await import('node:http');
|
|
139
|
-
server = createServer(onRequest);
|
|
140
|
-
await new Promise((resolve, reject) => {
|
|
141
|
-
server.once('error', reject);
|
|
142
|
-
server.listen(port, hostname, resolve);
|
|
143
|
-
});
|
|
317
|
+
const server = await acquireSocket();
|
|
318
|
+
server.on('request', onRequest);
|
|
319
|
+
let where;
|
|
320
|
+
try {
|
|
321
|
+
where = addressOf(server);
|
|
144
322
|
}
|
|
145
|
-
|
|
146
|
-
const tcp = typeof address === 'object' && address !== null ? address : undefined;
|
|
147
|
-
if (ownServer && !tcp) {
|
|
323
|
+
catch (err) {
|
|
148
324
|
server.off('request', onRequest);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
`port, and inventing one would be worse than refusing. Serve on a TCP server, or ` +
|
|
152
|
-
`drive the handler yourself.`);
|
|
325
|
+
await releaseSocket();
|
|
326
|
+
throw err;
|
|
153
327
|
}
|
|
154
|
-
const boundPort = tcp ? tcp.port : port;
|
|
155
|
-
// With our own socket the requested hostname IS the answer; with the
|
|
156
|
-
// caller's we ask the socket, because we never chose it.
|
|
157
|
-
const boundHost = ownServer ? tcp?.address ?? '127.0.0.1' : hostname;
|
|
158
|
-
const displayHost = boundHost === '0.0.0.0' || boundHost === '::' ? '127.0.0.1' : boundHost;
|
|
159
328
|
return {
|
|
160
|
-
url:
|
|
161
|
-
port:
|
|
329
|
+
url: where.url,
|
|
330
|
+
port: where.port,
|
|
162
331
|
close() {
|
|
163
332
|
// Idempotent: the first call owns the shutdown, later ones await it.
|
|
164
333
|
closing ??= (async () => {
|
|
@@ -177,8 +346,10 @@ export function httpHost(options) {
|
|
|
177
346
|
// caller is still waiting on, and dropping it would be the exact
|
|
178
347
|
// thing close() promises not to do.
|
|
179
348
|
await Promise.allSettled([...inFlight]);
|
|
180
|
-
server.
|
|
181
|
-
|
|
349
|
+
server.off('request', onRequest);
|
|
350
|
+
// The socket goes only when the LAST door lets go of it. A
|
|
351
|
+
// conversation still open on this port is not this door's to end.
|
|
352
|
+
await releaseSocket();
|
|
182
353
|
})();
|
|
183
354
|
return closing;
|
|
184
355
|
},
|
|
@@ -198,7 +369,7 @@ async function serveOne(req, res, handler, wire) {
|
|
|
198
369
|
sendJson(res, 400, wire.failure(`invalid JSON body: ${asError(err).message}`));
|
|
199
370
|
return;
|
|
200
371
|
}
|
|
201
|
-
const headers =
|
|
372
|
+
const headers = lowerCasedHeaders(req.headers);
|
|
202
373
|
const query = new URLSearchParams((req.url ?? '').split('?')[1] ?? '');
|
|
203
374
|
const { input, sessionId, decision } = wire.readRequest({ body, headers, query });
|
|
204
375
|
if (wantsStream) {
|
|
@@ -317,16 +488,6 @@ function sendJson(res, status, body) {
|
|
|
317
488
|
res.writeHead(status, { 'content-type': 'application/json' });
|
|
318
489
|
res.end(JSON.stringify(body));
|
|
319
490
|
}
|
|
320
|
-
function lowerCased(headers) {
|
|
321
|
-
const out = {};
|
|
322
|
-
for (const [name, value] of Object.entries(headers)) {
|
|
323
|
-
if (typeof value === 'string')
|
|
324
|
-
out[name.toLowerCase()] = value;
|
|
325
|
-
else if (Array.isArray(value))
|
|
326
|
-
out[name.toLowerCase()] = value.join(', ');
|
|
327
|
-
}
|
|
328
|
-
return out;
|
|
329
|
-
}
|
|
330
491
|
function asError(err) {
|
|
331
492
|
return err instanceof Error ? err : new Error(String(err));
|
|
332
493
|
}
|
|
@@ -336,6 +497,9 @@ function asError(err) {
|
|
|
336
497
|
* Exported because every wire that maps a header needs it and re-deriving it
|
|
337
498
|
* per adapter is how one of them ends up matching only the exact casing the
|
|
338
499
|
* author happened to test with.
|
|
500
|
+
*
|
|
501
|
+
* Takes anything carrying lower-cased headers, so a request wire and a
|
|
502
|
+
* handshake wire read a header the same way rather than each growing their own.
|
|
339
503
|
*/
|
|
340
504
|
export function headerValue(facts, name, ...fallbacks) {
|
|
341
505
|
for (const candidate of [name, ...fallbacks]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpHost.js","sourceRoot":"","sources":["../../../src/hosting/httpHost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAyJ9C;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAqC;IACvD,eAAe,EAAE,G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O,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;IAClE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* agentfootprint/hosting — the
|
|
2
|
+
* agentfootprint/hosting — the ports between an agent and the place it runs.
|
|
3
3
|
*
|
|
4
4
|
* An agent that answers one call in a script and an agent that has been up for
|
|
5
|
-
* a month differ in
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* the composer that wires
|
|
5
|
+
* a month differ in a few things: something has to carry requests to it,
|
|
6
|
+
* something sometimes has to hold a channel OPEN to it, and the conversation
|
|
7
|
+
* has to outlive the request. This subpath is those things as **ports**, plus
|
|
8
|
+
* local adapters that prove the ports work, plus the composer that wires the
|
|
9
|
+
* request half together.
|
|
9
10
|
*
|
|
10
11
|
* `AgentHost` — something can call me.
|
|
12
|
+
* `ConversationHost` — something can talk to me, both ways, until one of us
|
|
13
|
+
* ends it. `HostRequest → HostReply` is one exchange;
|
|
14
|
+
* some doors are not.
|
|
11
15
|
* `SessionLifecycle` — the conversation outlives the request.
|
|
12
16
|
* `standingAgent` — hydrate → resume-or-fresh → persist → reply.
|
|
13
17
|
*
|
|
@@ -34,6 +38,17 @@
|
|
|
34
38
|
* re-decides. Pass `server` and it attaches to a `node:http` server YOU
|
|
35
39
|
* own instead of binding one — for the container that gets a single port
|
|
36
40
|
* and must serve a WebSocket upgrade (or anything else) beside the agent.
|
|
41
|
+
* • `host.serveConversations(handler)` — the conversation door, on every
|
|
42
|
+
* adapter built on `httpHost` that was given a `conversationPath`.
|
|
43
|
+
* `nodeHost` serves it on `/conversation` with a real WebSocket
|
|
44
|
+
* implementation and **no dependency to install**, sharing the socket with
|
|
45
|
+
* `/invoke`. Frames are STRINGS at the port; what they mean is your
|
|
46
|
+
* protocol's business, not this port's.
|
|
47
|
+
* • `ConversationLimits` — the ceilings a door DECLARES
|
|
48
|
+
* (`maxFrameBytes`, `idleMs`, `maxPendingBytes`) so the layer above can
|
|
49
|
+
* chunk or heartbeat on its own protocol. The port does neither, on
|
|
50
|
+
* purpose: hiding a cap inside auto-chunking decides a protocol question
|
|
51
|
+
* for every consumer at once.
|
|
37
52
|
* • `memorySessions()` — conversations in a Map, for tests and local dev.
|
|
38
53
|
* • `standingAgent({ agent, sessions, host, durability? })` — the composer.
|
|
39
54
|
* • `toEnvelope` / `readEnvelope` — pack a conversation, and refuse by name to
|
|
@@ -61,9 +76,9 @@
|
|
|
61
76
|
export { nodeHost, jsonWire } from './nodeHost.js';
|
|
62
77
|
export type { NodeHost, NodeHostHandle, NodeHostOptions } from './nodeHost.js';
|
|
63
78
|
export { httpHost, headerValue } from './httpHost.js';
|
|
64
|
-
export type { HttpHost, HttpHostHandle, HttpHostOptions, HttpRequestFacts, HttpWire, } from './httpHost.js';
|
|
79
|
+
export type { ConversationHandshake, HandshakeFacts, HttpHost, HttpHostHandle, HttpHostOptions, HttpRequestFacts, HttpWire, } from './httpHost.js';
|
|
65
80
|
export { memorySessions } from './memorySessions.js';
|
|
66
81
|
export { toEnvelope, toPausedEnvelope, readEnvelope, readPausedRun, checkEnvelope, } from './envelope.js';
|
|
67
82
|
export { standingAgent } from './standingAgent.js';
|
|
68
|
-
export { requireCapability, HostClosedError, ConcurrentRunError, PauseNotCarriedError, AwaitingDecisionError, NoPendingAskError, UnreadableEnvelopeError, } from './errors.js';
|
|
69
|
-
export type { AgentHost, CheckpointEnvelope, ConcurrentInvokePolicy, ConversationEnvelope, DurabilityMode, HostCapability, HostHandle, HostHandler, HostReply, HostRequest, PausedRun, PausedRunEnvelope, PendingAsk, SessionLifecycle, StandingAgentOptions, WakeReason, } from './types.js';
|
|
83
|
+
export { requireCapability, HostClosedError, ConcurrentRunError, PauseNotCarriedError, AwaitingDecisionError, NoPendingAskError, UnreadableEnvelopeError, ConversationClosedError, FrameTooLargeError, } from './errors.js';
|
|
84
|
+
export type { AgentHost, CheckpointEnvelope, ConcurrentInvokePolicy, ConversationClose, ConversationEnvelope, ConversationHandler, ConversationHost, ConversationLimits, DurabilityMode, HostCapability, HostConversation, HostHandle, HostHandler, HostReply, HostRequest, PausedRun, PausedRunEnvelope, PendingAsk, SessionLifecycle, StandingAgentOptions, Unsubscribe, WakeReason, } from './types.js';
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* agentfootprint/hosting — the
|
|
2
|
+
* agentfootprint/hosting — the ports between an agent and the place it runs.
|
|
3
3
|
*
|
|
4
4
|
* An agent that answers one call in a script and an agent that has been up for
|
|
5
|
-
* a month differ in
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* the composer that wires
|
|
5
|
+
* a month differ in a few things: something has to carry requests to it,
|
|
6
|
+
* something sometimes has to hold a channel OPEN to it, and the conversation
|
|
7
|
+
* has to outlive the request. This subpath is those things as **ports**, plus
|
|
8
|
+
* local adapters that prove the ports work, plus the composer that wires the
|
|
9
|
+
* request half together.
|
|
9
10
|
*
|
|
10
11
|
* `AgentHost` — something can call me.
|
|
12
|
+
* `ConversationHost` — something can talk to me, both ways, until one of us
|
|
13
|
+
* ends it. `HostRequest → HostReply` is one exchange;
|
|
14
|
+
* some doors are not.
|
|
11
15
|
* `SessionLifecycle` — the conversation outlives the request.
|
|
12
16
|
* `standingAgent` — hydrate → resume-or-fresh → persist → reply.
|
|
13
17
|
*
|
|
@@ -34,6 +38,17 @@
|
|
|
34
38
|
* re-decides. Pass `server` and it attaches to a `node:http` server YOU
|
|
35
39
|
* own instead of binding one — for the container that gets a single port
|
|
36
40
|
* and must serve a WebSocket upgrade (or anything else) beside the agent.
|
|
41
|
+
* • `host.serveConversations(handler)` — the conversation door, on every
|
|
42
|
+
* adapter built on `httpHost` that was given a `conversationPath`.
|
|
43
|
+
* `nodeHost` serves it on `/conversation` with a real WebSocket
|
|
44
|
+
* implementation and **no dependency to install**, sharing the socket with
|
|
45
|
+
* `/invoke`. Frames are STRINGS at the port; what they mean is your
|
|
46
|
+
* protocol's business, not this port's.
|
|
47
|
+
* • `ConversationLimits` — the ceilings a door DECLARES
|
|
48
|
+
* (`maxFrameBytes`, `idleMs`, `maxPendingBytes`) so the layer above can
|
|
49
|
+
* chunk or heartbeat on its own protocol. The port does neither, on
|
|
50
|
+
* purpose: hiding a cap inside auto-chunking decides a protocol question
|
|
51
|
+
* for every consumer at once.
|
|
37
52
|
* • `memorySessions()` — conversations in a Map, for tests and local dev.
|
|
38
53
|
* • `standingAgent({ agent, sessions, host, durability? })` — the composer.
|
|
39
54
|
* • `toEnvelope` / `readEnvelope` — pack a conversation, and refuse by name to
|
|
@@ -63,5 +78,5 @@ export { httpHost, headerValue } from './httpHost.js';
|
|
|
63
78
|
export { memorySessions } from './memorySessions.js';
|
|
64
79
|
export { toEnvelope, toPausedEnvelope, readEnvelope, readPausedRun, checkEnvelope, } from './envelope.js';
|
|
65
80
|
export { standingAgent } from './standingAgent.js';
|
|
66
|
-
export { requireCapability, HostClosedError, ConcurrentRunError, PauseNotCarriedError, AwaitingDecisionError, NoPendingAskError, UnreadableEnvelopeError, } from './errors.js';
|
|
81
|
+
export { requireCapability, HostClosedError, ConcurrentRunError, PauseNotCarriedError, AwaitingDecisionError, NoPendingAskError, UnreadableEnvelopeError, ConversationClosedError, FrameTooLargeError, } from './errors.js';
|
|
67
82
|
//# sourceMappingURL=index.js.map
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAWtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,aAAa,CAAC"}
|
|
@@ -21,6 +21,13 @@
|
|
|
21
21
|
* instead of binding one, so a WebSocket upgrade or your own routes can share
|
|
22
22
|
* the port. `close()` then detaches and drains, and your socket stays up.
|
|
23
23
|
*
|
|
24
|
+
* **There is a third door.** `serveConversations(handler)` takes WebSocket
|
|
25
|
+
* upgrades on `/conversation` and hands each one to your handler as a
|
|
26
|
+
* `HostConversation` — a channel that stays open, for the callers that cannot
|
|
27
|
+
* host an inbound endpoint and dial out instead. It shares this host's socket
|
|
28
|
+
* with `/invoke` and `/health`, needs nothing installed, and declares what it
|
|
29
|
+
* caps.
|
|
30
|
+
*
|
|
24
31
|
* **Streaming is the caller's choice, not the server's.** Send
|
|
25
32
|
* `Accept: text/event-stream` and the reply is Server-Sent Events, one `chunk`
|
|
26
33
|
* event per `reply.emit(...)` then a final `complete`. Send anything else and
|
|
@@ -36,6 +43,7 @@
|
|
|
36
43
|
*/
|
|
37
44
|
/// <reference types="node" />
|
|
38
45
|
import { type HttpHost, type HttpHostHandle, type HttpWire } from './httpHost.js';
|
|
46
|
+
import type { ConversationLimits } from './types.js';
|
|
39
47
|
/** Options for {@link nodeHost}. */
|
|
40
48
|
export interface NodeHostOptions {
|
|
41
49
|
/** Port to bind. Default `8080`. Pass `0` for an ephemeral port. Refused alongside `server`. */
|
|
@@ -46,6 +54,21 @@ export interface NodeHostOptions {
|
|
|
46
54
|
readonly invokePath?: string;
|
|
47
55
|
/** Path that answers a health probe. Default `'/health'`. */
|
|
48
56
|
readonly healthPath?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Path that takes a conversation upgrade. Default `'/conversation'` — this
|
|
59
|
+
* adapter's own word, chosen the way its other two paths were, and named for
|
|
60
|
+
* what it carries rather than for what any runtime calls it.
|
|
61
|
+
*/
|
|
62
|
+
readonly conversationPath?: string;
|
|
63
|
+
/**
|
|
64
|
+
* What the conversation door caps. Defaults to one mebibyte per frame and one
|
|
65
|
+
* mebibyte held before a handler subscribes — declared, so
|
|
66
|
+
* `host.conversationLimits` always reports what is really enforced. This
|
|
67
|
+
* adapter declares no `idleMs`: it does not idle a conversation out, and
|
|
68
|
+
* reporting a ceiling it neither imposes nor sits behind would be inventing
|
|
69
|
+
* a fact.
|
|
70
|
+
*/
|
|
71
|
+
readonly conversationLimits?: ConversationLimits;
|
|
49
72
|
/**
|
|
50
73
|
* A `node:http` server **you** own, already listening. Given one, this
|
|
51
74
|
* adapter attaches its two routes to it instead of binding a socket of its
|
|
@@ -21,6 +21,13 @@
|
|
|
21
21
|
* instead of binding one, so a WebSocket upgrade or your own routes can share
|
|
22
22
|
* the port. `close()` then detaches and drains, and your socket stays up.
|
|
23
23
|
*
|
|
24
|
+
* **There is a third door.** `serveConversations(handler)` takes WebSocket
|
|
25
|
+
* upgrades on `/conversation` and hands each one to your handler as a
|
|
26
|
+
* `HostConversation` — a channel that stays open, for the callers that cannot
|
|
27
|
+
* host an inbound endpoint and dial out instead. It shares this host's socket
|
|
28
|
+
* with `/invoke` and `/health`, needs nothing installed, and declares what it
|
|
29
|
+
* caps.
|
|
30
|
+
*
|
|
24
31
|
* **Streaming is the caller's choice, not the server's.** Send
|
|
25
32
|
* `Accept: text/event-stream` and the reply is Server-Sent Events, one `chunk`
|
|
26
33
|
* event per `reply.emit(...)` then a final `complete`. Send anything else and
|
|
@@ -34,7 +41,7 @@
|
|
|
34
41
|
* never quietly drift apart on what `close()` drains or what a handler that
|
|
35
42
|
* throws does. `types.ts` knows none of it either way.
|
|
36
43
|
*/
|
|
37
|
-
import { httpHost } from './httpHost.js';
|
|
44
|
+
import { headerValue, httpHost, } from './httpHost.js';
|
|
38
45
|
const HOST_NAME = 'nodeHost';
|
|
39
46
|
/**
|
|
40
47
|
* This adapter's own JSON dialect: `{ input, sessionId? }` in, `{ output }`
|
|
@@ -66,6 +73,15 @@ export const jsonWire = {
|
|
|
66
73
|
failure: (error, code) => ({ error, ...(code !== undefined && { code }) }),
|
|
67
74
|
chunk: (text) => ({ text }),
|
|
68
75
|
awaiting: (pending) => ({ awaiting: pending }),
|
|
76
|
+
readConversation(facts) {
|
|
77
|
+
// A handshake has no body, so this dialect names the two places a session
|
|
78
|
+
// id can be: the header a server-side caller sets, and the query a BROWSER
|
|
79
|
+
// has to use because the WebSocket API gives it no way to set a header.
|
|
80
|
+
// Header wins, so a caller that sets both is not surprised by which one the
|
|
81
|
+
// server preferred — the same rule the request dialect uses for body-vs-header.
|
|
82
|
+
const sessionId = headerValue(facts, 'x-session-id') ?? facts.query.get('sessionId') ?? undefined;
|
|
83
|
+
return { ...(sessionId !== undefined && sessionId.length > 0 && { sessionId }) };
|
|
84
|
+
},
|
|
69
85
|
};
|
|
70
86
|
/**
|
|
71
87
|
* An HTTP host for one handler.
|
|
@@ -87,6 +103,10 @@ export function nodeHost(options = {}) {
|
|
|
87
103
|
// particular runtime's container-contract path literal.
|
|
88
104
|
invokePath: options.invokePath ?? '/invoke',
|
|
89
105
|
healthPath: options.healthPath ?? '/health',
|
|
106
|
+
conversationPath: options.conversationPath ?? '/conversation',
|
|
107
|
+
...(options.conversationLimits !== undefined && {
|
|
108
|
+
conversationLimits: options.conversationLimits,
|
|
109
|
+
}),
|
|
90
110
|
// Passed through as given, never defaulted: with a caller-owned server
|
|
91
111
|
// there is no port to default, and a port passed WITH one is a caller who
|
|
92
112
|
// believes something untrue about where their agent answers — `httpHost`
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EACL,WAAW,EACX,QAAQ,GAIT,MAAM,eAAe,CAAC;AAqDvB,MAAM,SAAS,GAAG,UAAU,CAAC;AAE7B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,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,MAAM,QAAQ,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7F,MAAM,SAAS,GAAG,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAC5D,4EAA4E;QAC5E,wEAAwE;QACxE,0CAA0C;QAC1C,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;QACrC,OAAO;YACL,KAAK;YACL,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,CAAC;YAC7C,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;SAC5C,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,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