agentfootprint 7.21.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/dist/adapters/hosting/agentcore.js +12 -2
- package/dist/adapters/hosting/agentcore.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/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/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/types/adapters/hosting/agentcore.d.ts +27 -0
- package/dist/types/adapters/hosting/agentcore.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/package.json +1 -1
|
@@ -158,8 +158,18 @@ function agentCoreRuntimeHost(options = {}) {
|
|
|
158
158
|
wire: agentCoreRuntimeWire(options.busy),
|
|
159
159
|
invokePath: INVOKE_PATH,
|
|
160
160
|
healthPath: HEALTH_PATH,
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
// With a caller-owned server this adapter binds nothing, so it must not
|
|
162
|
+
// invent the contract's port either — the port is whatever the caller
|
|
163
|
+
// listened on, and passing one anyway is refused by `httpHost` rather than
|
|
164
|
+
// quietly ignored. An explicitly passed port still travels, so that refusal
|
|
165
|
+
// reaches a caller who asked for both.
|
|
166
|
+
...(options.server !== undefined
|
|
167
|
+
? {
|
|
168
|
+
server: options.server,
|
|
169
|
+
...(options.port !== undefined && { port: options.port }),
|
|
170
|
+
...(options.hostname !== undefined && { hostname: options.hostname }),
|
|
171
|
+
}
|
|
172
|
+
: { port: options.port ?? RUNTIME_PORT, hostname: options.hostname ?? '0.0.0.0' }),
|
|
163
173
|
});
|
|
164
174
|
}
|
|
165
175
|
exports.agentCoreRuntimeHost = agentCoreRuntimeHost;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../src/adapters/hosting/agentcore.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2DAA0D;AAC1D,2DAAkE;AAGlE,6DAAuD;AAEvD,wEAAwE;AAExE,MAAM,SAAS,GAAG,sBAAsB,CAAC;AAEzC,wFAAwF;AACxF,MAAM,WAAW,GAAG,cAAc,CAAC;AACnC,MAAM,WAAW,GAAG,OAAO,CAAC;AAC5B,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B;;;;GAIG;AACH,MAAM,cAAc,GAAG,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../src/adapters/hosting/agentcore.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2DAA0D;AAC1D,2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D,QAAQ;gBACR,OAAO;gBACP,SAAS;gBACT,cAAc,EAAE,IAAI,IAAI,EAAE;gBAC1B,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;aAC9B,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE;YAC3D,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,mBAAmB,EAAE;gBACrE,QAAQ;gBACR,OAAO;gBACP,SAAS;gBACT,eAAe,EAAE,IAAI;gBACrB,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,CAAC;aAChD,CAAC,CAA+E,CAAC;YAClF,MAAM,MAAM,GAA4B,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBAC7E,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,EAAE;gBAC5B,QAAQ,EAAE,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC;aAC7C,CAAC,CAAC,CAAC;YACJ,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
* `node:fs` and nothing else; the event-backed one lazy-loads the AWS SDK, so
|
|
45
45
|
* importing this module costs zero peer-dep load.
|
|
46
46
|
*/
|
|
47
|
+
/// <reference types="node" />
|
|
47
48
|
import type { HttpHost, HttpWire } from '../../hosting/httpHost.js';
|
|
48
49
|
import type { CheckpointEnvelope, SessionLifecycle } from '../../hosting/types.js';
|
|
49
50
|
/** Options for {@link agentCoreRuntimeHost}. */
|
|
@@ -68,6 +69,32 @@ export interface AgentCoreRuntimeHostOptions {
|
|
|
68
69
|
* honest answer for an agent that answers synchronously.
|
|
69
70
|
*/
|
|
70
71
|
readonly busy?: () => boolean;
|
|
72
|
+
/**
|
|
73
|
+
* A `node:http` server **you** own, already listening. Given one, this
|
|
74
|
+
* adapter attaches `/invocations` and `/ping` to it instead of binding a
|
|
75
|
+
* socket of its own — which is the only way to serve something else on the
|
|
76
|
+
* same port, and a container gets one port.
|
|
77
|
+
*
|
|
78
|
+
* The case this exists for: a container that must also answer a WebSocket
|
|
79
|
+
* upgrade beside the runtime's two routes. Add your `'upgrade'` listener to
|
|
80
|
+
* the server, listen on 8080 yourself, and attach the agent to it.
|
|
81
|
+
*
|
|
82
|
+
* Every law is `httpHost`'s: unmatched paths are YOURS (this adapter writes
|
|
83
|
+
* no 404 on a server it does not own), and `close()` detaches and drains
|
|
84
|
+
* without closing your socket. `port` and `hostname` are refused alongside
|
|
85
|
+
* it — a server you own already has an address.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* const server = createServer();
|
|
89
|
+
* server.on('upgrade', handleWebSocket);
|
|
90
|
+
* await new Promise<void>((r) => server.listen(8080, '0.0.0.0', r));
|
|
91
|
+
* const handle = await standingAgent({
|
|
92
|
+
* agent,
|
|
93
|
+
* host: agentCoreRuntimeHost({ server }),
|
|
94
|
+
* sessions: agentCoreSessions({ store: 'session-storage' }),
|
|
95
|
+
* });
|
|
96
|
+
*/
|
|
97
|
+
readonly server?: import('node:http').Server;
|
|
71
98
|
}
|
|
72
99
|
/**
|
|
73
100
|
* The AgentCore Runtime contract as an {@link HttpWire}.
|
|
@@ -131,8 +131,18 @@ export function agentCoreRuntimeHost(options = {}) {
|
|
|
131
131
|
wire: agentCoreRuntimeWire(options.busy),
|
|
132
132
|
invokePath: INVOKE_PATH,
|
|
133
133
|
healthPath: HEALTH_PATH,
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
// With a caller-owned server this adapter binds nothing, so it must not
|
|
135
|
+
// invent the contract's port either — the port is whatever the caller
|
|
136
|
+
// listened on, and passing one anyway is refused by `httpHost` rather than
|
|
137
|
+
// quietly ignored. An explicitly passed port still travels, so that refusal
|
|
138
|
+
// reaches a caller who asked for both.
|
|
139
|
+
...(options.server !== undefined
|
|
140
|
+
? {
|
|
141
|
+
server: options.server,
|
|
142
|
+
...(options.port !== undefined && { port: options.port }),
|
|
143
|
+
...(options.hostname !== undefined && { hostname: options.hostname }),
|
|
144
|
+
}
|
|
145
|
+
: { port: options.port ?? RUNTIME_PORT, hostname: options.hostname ?? '0.0.0.0' }),
|
|
136
146
|
});
|
|
137
147
|
}
|
|
138
148
|
/** The default file the `'session-storage'` mode writes to. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../../src/adapters/hosting/agentcore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,wEAAwE;AAExE,MAAM,SAAS,GAAG,sBAAsB,CAAC;AAEzC,wFAAwF;AACxF,MAAM,WAAW,GAAG,cAAc,CAAC;AACnC,MAAM,WAAW,GAAG,OAAO,CAAC;AAC5B,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B;;;;GAIG;AACH,MAAM,cAAc,GAAG,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../../src/adapters/hosting/agentcore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0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BACT,cAAc,EAAE,IAAI,IAAI,EAAE;gBAC1B,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;aAC9B,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE;YAC3D,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,mBAAmB,EAAE;gBACrE,QAAQ;gBACR,OAAO;gBACP,SAAS;gBACT,eAAe,EAAE,IAAI;gBACrB,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,CAAC;aAChD,CAAC,CAA+E,CAAC;YAClF,MAAM,MAAM,GAA4B,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBAC7E,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,EAAE;gBAC5B,QAAQ,EAAE,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC;aAC7C,CAAC,CAAC,CAAC;YACJ,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -25,9 +25,20 @@
|
|
|
25
25
|
* `HostRequest` and `HostReply` say exactly what they said before. The gap was
|
|
26
26
|
* in the first adapter, which had no seam, not in the port, which needed none.
|
|
27
27
|
*
|
|
28
|
+
* ── The second thing a deployment gets to re-decide: who owns the socket ─────
|
|
29
|
+
* By default this file creates a server and listens on it. Pass `server` and it
|
|
30
|
+
* attaches to yours instead — because a container is sometimes given exactly
|
|
31
|
+
* one port, and an agent that privately owns the socket cannot share it with a
|
|
32
|
+
* WebSocket upgrade or with routes that were there first. Attached, the host
|
|
33
|
+
* answers its two paths, writes nothing on anyone else's, and `close()`
|
|
34
|
+
* detaches and drains without closing a socket it never opened. That is the
|
|
35
|
+
* whole difference; every other law on this page is the same either way.
|
|
36
|
+
*
|
|
28
37
|
* Pattern: Template method via configuration (Strategy on the wire format).
|
|
29
38
|
* Everything HTTP lives here and in the wires; `types.ts` knows none of it.
|
|
30
39
|
*/
|
|
40
|
+
/// <reference types="node" />
|
|
41
|
+
import type { Server } from 'node:http';
|
|
31
42
|
import type { AgentHost, HostCapability, HostHandle, HostHandler, PendingAsk } from './types.js';
|
|
32
43
|
/** Everything a {@link HttpWire} may read when pulling a request apart. */
|
|
33
44
|
export interface HttpRequestFacts {
|
|
@@ -101,16 +112,64 @@ export interface HttpHostOptions {
|
|
|
101
112
|
readonly invokePath: string;
|
|
102
113
|
/** Path that answers a health probe. Required, for the same reason. */
|
|
103
114
|
readonly healthPath: string;
|
|
104
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Port to bind. Default `8080`. Pass `0` for an ephemeral port.
|
|
117
|
+
*
|
|
118
|
+
* Refused together with {@link HttpHostOptions.server}: a server you own
|
|
119
|
+
* already has an address, and a port here would name a socket this host does
|
|
120
|
+
* not bind.
|
|
121
|
+
*/
|
|
105
122
|
readonly port?: number;
|
|
106
|
-
/** Interface to bind. Default `'0.0.0.0'`. */
|
|
123
|
+
/** Interface to bind. Default `'0.0.0.0'`. Refused together with `server`, for the same reason. */
|
|
107
124
|
readonly hostname?: string;
|
|
108
125
|
/** What this adapter claims beyond the baseline. Default `['streaming']`. */
|
|
109
126
|
readonly capabilities?: readonly HostCapability[];
|
|
127
|
+
/**
|
|
128
|
+
* A `node:http` server **you** own. Given one, this host ATTACHES its two
|
|
129
|
+
* routes to it instead of creating and listening on a server of its own.
|
|
130
|
+
*
|
|
131
|
+
* ── Why ──────────────────────────────────────────────────────────────────
|
|
132
|
+
* Some runtimes hand a container exactly one port, and a container that must
|
|
133
|
+
* also answer a WebSocket upgrade — or anything else — on that port cannot
|
|
134
|
+
* use a host that privately owns the socket. Attaching costs nothing anyone
|
|
135
|
+
* else was using: `node:http` calls EVERY `'request'` listener for every
|
|
136
|
+
* request, so this host and your own routes share the port by taking turns.
|
|
137
|
+
*
|
|
138
|
+
* ── What changes, exactly ────────────────────────────────────────────────
|
|
139
|
+
* - **You own the socket.** `listen()` is yours, and so is closing it. The
|
|
140
|
+
* server must ALREADY be listening when `serve()` is called — a handle
|
|
141
|
+
* that promises `url` and `port` cannot honestly report an address that
|
|
142
|
+
* does not exist yet, so `serve()` refuses rather than guess one.
|
|
143
|
+
* - **The host never writes a 404.** A path it does not own is yours to
|
|
144
|
+
* answer, and answering it with a refusal from this host would be this
|
|
145
|
+
* host answering for your application. Note the consequence: a request no
|
|
146
|
+
* listener answers is not a 404, it HANGS — if this server has no other
|
|
147
|
+
* `'request'` listener, unmatched paths go unanswered until the socket
|
|
148
|
+
* times out. With no `server`, the 404 behaviour is unchanged.
|
|
149
|
+
* - **`close()` detaches and drains, and leaves your server listening.** It
|
|
150
|
+
* removes this host's listener, waits for the requests it is already
|
|
151
|
+
* serving, and touches nothing else — not your connections, not your
|
|
152
|
+
* socket.
|
|
153
|
+
* - It never writes to a response an earlier listener already answered.
|
|
154
|
+
*
|
|
155
|
+
* @example One port, an agent and a WebSocket upgrade
|
|
156
|
+
* const server = createServer();
|
|
157
|
+
* server.on('upgrade', (req, socket, head) => acceptWebSocket(req, socket, head));
|
|
158
|
+
* await new Promise<void>((r) => server.listen(8080, '0.0.0.0', r));
|
|
159
|
+
* const handle = await httpHost({ ...wireOptions, server }).serve(handler);
|
|
160
|
+
* // …later: the host goes away, the socket and the upgrade stay.
|
|
161
|
+
* await handle.close();
|
|
162
|
+
*/
|
|
163
|
+
readonly server?: Server;
|
|
110
164
|
}
|
|
111
165
|
/** A {@link HostHandle} that also says where it landed. */
|
|
112
166
|
export interface HttpHostHandle extends HostHandle {
|
|
113
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* Where it is actually listening, e.g. `http://127.0.0.1:53211`. With a
|
|
169
|
+
* caller-owned {@link HttpHostOptions.server} this is that server's real
|
|
170
|
+
* address — the host reports where it is answering, never where it bound,
|
|
171
|
+
* because with your server it bound nothing.
|
|
172
|
+
*/
|
|
114
173
|
readonly url: string;
|
|
115
174
|
/** The port it actually bound — the real one, when you asked for `0`. */
|
|
116
175
|
readonly port: number;
|
|
@@ -25,6 +25,15 @@
|
|
|
25
25
|
* `HostRequest` and `HostReply` say exactly what they said before. The gap was
|
|
26
26
|
* in the first adapter, which had no seam, not in the port, which needed none.
|
|
27
27
|
*
|
|
28
|
+
* ── The second thing a deployment gets to re-decide: who owns the socket ─────
|
|
29
|
+
* By default this file creates a server and listens on it. Pass `server` and it
|
|
30
|
+
* attaches to yours instead — because a container is sometimes given exactly
|
|
31
|
+
* one port, and an agent that privately owns the socket cannot share it with a
|
|
32
|
+
* WebSocket upgrade or with routes that were there first. Attached, the host
|
|
33
|
+
* answers its two paths, writes nothing on anyone else's, and `close()`
|
|
34
|
+
* detaches and drains without closing a socket it never opened. That is the
|
|
35
|
+
* whole difference; every other law on this page is the same either way.
|
|
36
|
+
*
|
|
28
37
|
* Pattern: Template method via configuration (Strategy on the wire format).
|
|
29
38
|
* Everything HTTP lives here and in the wires; `types.ts` knows none of it.
|
|
30
39
|
*/
|
|
@@ -64,6 +73,17 @@ const DEFAULT_CAPABILITIES = ['streaming'];
|
|
|
64
73
|
*/
|
|
65
74
|
export function httpHost(options) {
|
|
66
75
|
const { name, wire, invokePath, healthPath } = options;
|
|
76
|
+
const ownServer = options.server;
|
|
77
|
+
// Refused at construction, not ignored at serve time: a `port` next to a
|
|
78
|
+
// server this host does not bind is a caller who believes something untrue
|
|
79
|
+
// about where their agent will answer, and silently dropping it is how they
|
|
80
|
+
// stay believing it.
|
|
81
|
+
if (ownServer && (options.port !== undefined || options.hostname !== undefined)) {
|
|
82
|
+
throw new Error(`[hosting] httpHost('${name}') was given both a caller-owned 'server' and a ` +
|
|
83
|
+
`'${options.port !== undefined ? 'port' : 'hostname'}'. A server you own already has ` +
|
|
84
|
+
`an address, and this host binds nothing when you pass one. Drop the port/hostname, ` +
|
|
85
|
+
`or drop the server and let this host bind its own socket.`);
|
|
86
|
+
}
|
|
67
87
|
const port = options.port ?? 8080;
|
|
68
88
|
const hostname = options.hostname ?? '0.0.0.0';
|
|
69
89
|
const capabilities = options.capabilities ?? DEFAULT_CAPABILITIES;
|
|
@@ -71,18 +91,26 @@ export function httpHost(options) {
|
|
|
71
91
|
name,
|
|
72
92
|
capabilities,
|
|
73
93
|
async serve(handler) {
|
|
74
|
-
const { createServer } = await import('node:http');
|
|
75
94
|
const startedAt = Date.now();
|
|
76
95
|
const inFlight = new Set();
|
|
77
96
|
let accepting = true;
|
|
78
97
|
let closing;
|
|
79
|
-
const
|
|
98
|
+
const onRequest = (req, res) => {
|
|
99
|
+
// On a shared server an earlier listener may already have answered.
|
|
100
|
+
// Writing again would corrupt its reply; there is nothing to add.
|
|
101
|
+
if (res.headersSent)
|
|
102
|
+
return;
|
|
80
103
|
const path = (req.url ?? '').split('?')[0];
|
|
81
104
|
if (req.method === 'GET' && path === healthPath) {
|
|
82
105
|
sendJson(res, 200, wire.health(Date.now() - startedAt));
|
|
83
106
|
return;
|
|
84
107
|
}
|
|
85
108
|
if (req.method !== 'POST' || path !== invokePath) {
|
|
109
|
+
// On a server we own, an unmatched path is nobody else's, so saying
|
|
110
|
+
// so is the honest answer. On a server the CALLER owns it is theirs,
|
|
111
|
+
// and a 404 from us would answer for their application.
|
|
112
|
+
if (ownServer)
|
|
113
|
+
return;
|
|
86
114
|
sendJson(res, 404, wire.failure(`no route for ${req.method ?? '?'} ${path}`));
|
|
87
115
|
return;
|
|
88
116
|
}
|
|
@@ -94,14 +122,40 @@ export function httpHost(options) {
|
|
|
94
122
|
const served = serveOne(req, res, handler, wire);
|
|
95
123
|
inFlight.add(served);
|
|
96
124
|
void served.finally(() => inFlight.delete(served));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
server
|
|
101
|
-
|
|
125
|
+
};
|
|
126
|
+
let server;
|
|
127
|
+
if (ownServer) {
|
|
128
|
+
server = ownServer;
|
|
129
|
+
if (!server.listening) {
|
|
130
|
+
throw new Error(`[hosting] httpHost('${name}') was handed a server that is not listening yet. ` +
|
|
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
|
+
});
|
|
144
|
+
}
|
|
102
145
|
const address = server.address();
|
|
103
|
-
const
|
|
104
|
-
|
|
146
|
+
const tcp = typeof address === 'object' && address !== null ? address : undefined;
|
|
147
|
+
if (ownServer && !tcp) {
|
|
148
|
+
server.off('request', onRequest);
|
|
149
|
+
throw new Error(`[hosting] httpHost('${name}') was handed a server bound to ${JSON.stringify(address)}` +
|
|
150
|
+
` — a pipe or socket path, which has no port. This handle promises a url and a ` +
|
|
151
|
+
`port, and inventing one would be worse than refusing. Serve on a TCP server, or ` +
|
|
152
|
+
`drive the handler yourself.`);
|
|
153
|
+
}
|
|
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;
|
|
105
159
|
return {
|
|
106
160
|
url: `http://${displayHost}:${boundPort}`,
|
|
107
161
|
port: boundPort,
|
|
@@ -109,6 +163,16 @@ export function httpHost(options) {
|
|
|
109
163
|
// Idempotent: the first call owns the shutdown, later ones await it.
|
|
110
164
|
closing ??= (async () => {
|
|
111
165
|
accepting = false;
|
|
166
|
+
if (ownServer) {
|
|
167
|
+
// Detach FIRST. The paths stop being ours the moment close() is
|
|
168
|
+
// called, so a request arriving now falls through to the caller
|
|
169
|
+
// rather than collecting a refusal from a host that is leaving.
|
|
170
|
+
server.off('request', onRequest);
|
|
171
|
+
// Then drain what we are already serving — and stop there. The
|
|
172
|
+
// socket, the idle connections and the shutdown are the caller's.
|
|
173
|
+
await Promise.allSettled([...inFlight]);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
112
176
|
// Drain BEFORE touching sockets — an in-flight request is work the
|
|
113
177
|
// caller is still waiting on, and dropping it would be the exact
|
|
114
178
|
// 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,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;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,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAwB;IAC/C,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACvD,MAAM,SAAS,G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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,MAAM,UAAU,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"}
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
* itself, parameterised by the JSON dialect it speaks. `nodeHost` is one
|
|
32
32
|
* configuration of it; an adapter for someone's container runtime is
|
|
33
33
|
* another. Two paths and five body shapes are all a second HTTP adapter
|
|
34
|
-
* re-decides.
|
|
34
|
+
* re-decides. Pass `server` and it attaches to a `node:http` server YOU
|
|
35
|
+
* own instead of binding one — for the container that gets a single port
|
|
36
|
+
* and must serve a WebSocket upgrade (or anything else) beside the agent.
|
|
35
37
|
* • `memorySessions()` — conversations in a Map, for tests and local dev.
|
|
36
38
|
* • `standingAgent({ agent, sessions, host, durability? })` — the composer.
|
|
37
39
|
* • `toEnvelope` / `readEnvelope` — pack a conversation, and refuse by name to
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
* itself, parameterised by the JSON dialect it speaks. `nodeHost` is one
|
|
32
32
|
* configuration of it; an adapter for someone's container runtime is
|
|
33
33
|
* another. Two paths and five body shapes are all a second HTTP adapter
|
|
34
|
-
* re-decides.
|
|
34
|
+
* re-decides. Pass `server` and it attaches to a `node:http` server YOU
|
|
35
|
+
* own instead of binding one — for the container that gets a single port
|
|
36
|
+
* and must serve a WebSocket upgrade (or anything else) beside the agent.
|
|
35
37
|
* • `memorySessions()` — conversations in a Map, for tests and local dev.
|
|
36
38
|
* • `standingAgent({ agent, sessions, host, durability? })` — the composer.
|
|
37
39
|
* • `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,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAStD,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,GAClB,MAAM,aAAa,CAAC"}
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
* a colleague's convention. A path is a deployment detail, so it is a knob
|
|
17
17
|
* here and absent from the port entirely.
|
|
18
18
|
*
|
|
19
|
+
* **The socket can be yours.** Pass `server` — a `node:http` server you
|
|
20
|
+
* created and listened on — and this adapter attaches its two routes to it
|
|
21
|
+
* instead of binding one, so a WebSocket upgrade or your own routes can share
|
|
22
|
+
* the port. `close()` then detaches and drains, and your socket stays up.
|
|
23
|
+
*
|
|
19
24
|
* **Streaming is the caller's choice, not the server's.** Send
|
|
20
25
|
* `Accept: text/event-stream` and the reply is Server-Sent Events, one `chunk`
|
|
21
26
|
* event per `reply.emit(...)` then a final `complete`. Send anything else and
|
|
@@ -29,17 +34,31 @@
|
|
|
29
34
|
* never quietly drift apart on what `close()` drains or what a handler that
|
|
30
35
|
* throws does. `types.ts` knows none of it either way.
|
|
31
36
|
*/
|
|
37
|
+
/// <reference types="node" />
|
|
32
38
|
import { type HttpHost, type HttpHostHandle, type HttpWire } from './httpHost.js';
|
|
33
39
|
/** Options for {@link nodeHost}. */
|
|
34
40
|
export interface NodeHostOptions {
|
|
35
|
-
/** Port to bind. Default `8080`. Pass `0` for an ephemeral port. */
|
|
41
|
+
/** Port to bind. Default `8080`. Pass `0` for an ephemeral port. Refused alongside `server`. */
|
|
36
42
|
readonly port?: number;
|
|
37
|
-
/** Interface to bind. Default `'0.0.0.0'`. */
|
|
43
|
+
/** Interface to bind. Default `'0.0.0.0'`. Refused alongside `server`. */
|
|
38
44
|
readonly hostname?: string;
|
|
39
45
|
/** Path that takes a request. Default `'/invoke'`. */
|
|
40
46
|
readonly invokePath?: string;
|
|
41
47
|
/** Path that answers a health probe. Default `'/health'`. */
|
|
42
48
|
readonly healthPath?: string;
|
|
49
|
+
/**
|
|
50
|
+
* A `node:http` server **you** own, already listening. Given one, this
|
|
51
|
+
* adapter attaches its two routes to it instead of binding a socket of its
|
|
52
|
+
* own — the only way to serve something else (a WebSocket upgrade, routes
|
|
53
|
+
* that were there first) on the same port, which matters when the thing
|
|
54
|
+
* running your process gives it exactly one.
|
|
55
|
+
*
|
|
56
|
+
* You keep `listen()` and you keep the shutdown; `close()` detaches this
|
|
57
|
+
* host and drains what it was already serving. On a server you own the host
|
|
58
|
+
* never writes a 404 either: a path it does not own is yours to answer. The
|
|
59
|
+
* full set of laws is on `httpHost`'s own `server` option, which this is.
|
|
60
|
+
*/
|
|
61
|
+
readonly server?: import('node:http').Server;
|
|
43
62
|
}
|
|
44
63
|
/**
|
|
45
64
|
* What {@link nodeHost}'s `serve()` resolves to — a `HostHandle` that also
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
* a colleague's convention. A path is a deployment detail, so it is a knob
|
|
17
17
|
* here and absent from the port entirely.
|
|
18
18
|
*
|
|
19
|
+
* **The socket can be yours.** Pass `server` — a `node:http` server you
|
|
20
|
+
* created and listened on — and this adapter attaches its two routes to it
|
|
21
|
+
* instead of binding one, so a WebSocket upgrade or your own routes can share
|
|
22
|
+
* the port. `close()` then detaches and drains, and your socket stays up.
|
|
23
|
+
*
|
|
19
24
|
* **Streaming is the caller's choice, not the server's.** Send
|
|
20
25
|
* `Accept: text/event-stream` and the reply is Server-Sent Events, one `chunk`
|
|
21
26
|
* event per `reply.emit(...)` then a final `complete`. Send anything else and
|
|
@@ -82,8 +87,13 @@ export function nodeHost(options = {}) {
|
|
|
82
87
|
// particular runtime's container-contract path literal.
|
|
83
88
|
invokePath: options.invokePath ?? '/invoke',
|
|
84
89
|
healthPath: options.healthPath ?? '/health',
|
|
90
|
+
// Passed through as given, never defaulted: with a caller-owned server
|
|
91
|
+
// there is no port to default, and a port passed WITH one is a caller who
|
|
92
|
+
// believes something untrue about where their agent answers — `httpHost`
|
|
93
|
+
// refuses that pair by name rather than picking a winner.
|
|
85
94
|
...(options.port !== undefined && { port: options.port }),
|
|
86
95
|
...(options.hostname !== undefined && { hostname: options.hostname }),
|
|
96
|
+
...(options.server !== undefined && { server: options.server }),
|
|
87
97
|
});
|
|
88
98
|
}
|
|
89
99
|
//# sourceMappingURL=nodeHost.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeHost.js","sourceRoot":"","sources":["../../../src/hosting/nodeHost.ts"],"names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,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAC1E,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;IAC3B,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;CAC/C,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CAAC,UAA2B,EAAE;IACpD,OAAO,QAAQ,CAAC;QACd,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,QAAQ;QACd,yEAAyE;QACzE,wDAAwD;QACxD,UAAU,EAAE,OAAO,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"}
|
|
@@ -140,6 +140,12 @@ export interface HostHandle {
|
|
|
140
140
|
* transport. Idempotent, so a shutdown hook and an explicit close can
|
|
141
141
|
* coexist. Requests arriving after it are refused with a
|
|
142
142
|
* {@link HostClosedError} naming the adapter.
|
|
143
|
+
*
|
|
144
|
+
* "Release the transport" is as strong as the port can be, because an
|
|
145
|
+
* adapter may be serving on a transport the CALLER owns rather than one it
|
|
146
|
+
* created. Releasing one of those means handing the routes back — never
|
|
147
|
+
* closing it — and a request arriving afterwards is the caller's to answer,
|
|
148
|
+
* not this host's to refuse.
|
|
143
149
|
*/
|
|
144
150
|
close(): Promise<void>;
|
|
145
151
|
}
|
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,CAAC;AAEtE;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,OAAwB;IAC/C,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,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AC,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,MAAM,QAAQ,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,C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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"}
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
* `node:fs` and nothing else; the event-backed one lazy-loads the AWS SDK, so
|
|
45
45
|
* importing this module costs zero peer-dep load.
|
|
46
46
|
*/
|
|
47
|
+
/// <reference types="node" />
|
|
47
48
|
import type { HttpHost, HttpWire } from '../../hosting/httpHost.js';
|
|
48
49
|
import type { CheckpointEnvelope, SessionLifecycle } from '../../hosting/types.js';
|
|
49
50
|
/** Options for {@link agentCoreRuntimeHost}. */
|
|
@@ -68,6 +69,32 @@ export interface AgentCoreRuntimeHostOptions {
|
|
|
68
69
|
* honest answer for an agent that answers synchronously.
|
|
69
70
|
*/
|
|
70
71
|
readonly busy?: () => boolean;
|
|
72
|
+
/**
|
|
73
|
+
* A `node:http` server **you** own, already listening. Given one, this
|
|
74
|
+
* adapter attaches `/invocations` and `/ping` to it instead of binding a
|
|
75
|
+
* socket of its own — which is the only way to serve something else on the
|
|
76
|
+
* same port, and a container gets one port.
|
|
77
|
+
*
|
|
78
|
+
* The case this exists for: a container that must also answer a WebSocket
|
|
79
|
+
* upgrade beside the runtime's two routes. Add your `'upgrade'` listener to
|
|
80
|
+
* the server, listen on 8080 yourself, and attach the agent to it.
|
|
81
|
+
*
|
|
82
|
+
* Every law is `httpHost`'s: unmatched paths are YOURS (this adapter writes
|
|
83
|
+
* no 404 on a server it does not own), and `close()` detaches and drains
|
|
84
|
+
* without closing your socket. `port` and `hostname` are refused alongside
|
|
85
|
+
* it — a server you own already has an address.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* const server = createServer();
|
|
89
|
+
* server.on('upgrade', handleWebSocket);
|
|
90
|
+
* await new Promise<void>((r) => server.listen(8080, '0.0.0.0', r));
|
|
91
|
+
* const handle = await standingAgent({
|
|
92
|
+
* agent,
|
|
93
|
+
* host: agentCoreRuntimeHost({ server }),
|
|
94
|
+
* sessions: agentCoreSessions({ store: 'session-storage' }),
|
|
95
|
+
* });
|
|
96
|
+
*/
|
|
97
|
+
readonly server?: import('node:http').Server;
|
|
71
98
|
}
|
|
72
99
|
/**
|
|
73
100
|
* The AgentCore Runtime contract as an {@link HttpWire}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentcore.d.ts","sourceRoot":"","sources":["../../../../src/adapters/hosting/agentcore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG
|
|
1
|
+
{"version":3,"file":"agentcore.d.ts","sourceRoot":"","sources":["../../../../src/adapters/hosting/agentcore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAoB,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAkBnF,gDAAgD;AAChD,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC;IAC9B;;;;;;;;;;;;;;;;;;;;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AA;KAAE,CAAC,CAAC;CAC3D;AAED,yCAAyC;AACzC,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,MAAM,CAAC,EAAE,0BAA0B,CAAC;IAC7C,iEAAiE;IACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,0BAA0B,CAAC;IAC9C,gGAAgG;IAChG,QAAQ,CAAC,IAAI,CAAC,EAAE,gCAAgC,CAAC;CAClD;AAED,6CAA6C;AAC7C,MAAM,MAAM,wBAAwB,GAChC,4BAA4B,GAC5B,8BAA8B,CAAC;AAEnC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,gBAAgB,CAErF;AA6HD,0EAA0E;AAC1E,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,sBAAsB,CAAC,EAAE,KAAK,MAAM,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK;QACrE,IAAI,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;KACtC,CAAC;IACF,QAAQ,CAAC,kBAAkB,CAAC,EAAE,KAAK,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;IAC9D,QAAQ,CAAC,iBAAiB,CAAC,EAAE,KAAK,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;CAC9D"}
|
|
@@ -25,9 +25,20 @@
|
|
|
25
25
|
* `HostRequest` and `HostReply` say exactly what they said before. The gap was
|
|
26
26
|
* in the first adapter, which had no seam, not in the port, which needed none.
|
|
27
27
|
*
|
|
28
|
+
* ── The second thing a deployment gets to re-decide: who owns the socket ─────
|
|
29
|
+
* By default this file creates a server and listens on it. Pass `server` and it
|
|
30
|
+
* attaches to yours instead — because a container is sometimes given exactly
|
|
31
|
+
* one port, and an agent that privately owns the socket cannot share it with a
|
|
32
|
+
* WebSocket upgrade or with routes that were there first. Attached, the host
|
|
33
|
+
* answers its two paths, writes nothing on anyone else's, and `close()`
|
|
34
|
+
* detaches and drains without closing a socket it never opened. That is the
|
|
35
|
+
* whole difference; every other law on this page is the same either way.
|
|
36
|
+
*
|
|
28
37
|
* Pattern: Template method via configuration (Strategy on the wire format).
|
|
29
38
|
* Everything HTTP lives here and in the wires; `types.ts` knows none of it.
|
|
30
39
|
*/
|
|
40
|
+
/// <reference types="node" />
|
|
41
|
+
import type { Server } from 'node:http';
|
|
31
42
|
import type { AgentHost, HostCapability, HostHandle, HostHandler, PendingAsk } from './types.js';
|
|
32
43
|
/** Everything a {@link HttpWire} may read when pulling a request apart. */
|
|
33
44
|
export interface HttpRequestFacts {
|
|
@@ -101,16 +112,64 @@ export interface HttpHostOptions {
|
|
|
101
112
|
readonly invokePath: string;
|
|
102
113
|
/** Path that answers a health probe. Required, for the same reason. */
|
|
103
114
|
readonly healthPath: string;
|
|
104
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Port to bind. Default `8080`. Pass `0` for an ephemeral port.
|
|
117
|
+
*
|
|
118
|
+
* Refused together with {@link HttpHostOptions.server}: a server you own
|
|
119
|
+
* already has an address, and a port here would name a socket this host does
|
|
120
|
+
* not bind.
|
|
121
|
+
*/
|
|
105
122
|
readonly port?: number;
|
|
106
|
-
/** Interface to bind. Default `'0.0.0.0'`. */
|
|
123
|
+
/** Interface to bind. Default `'0.0.0.0'`. Refused together with `server`, for the same reason. */
|
|
107
124
|
readonly hostname?: string;
|
|
108
125
|
/** What this adapter claims beyond the baseline. Default `['streaming']`. */
|
|
109
126
|
readonly capabilities?: readonly HostCapability[];
|
|
127
|
+
/**
|
|
128
|
+
* A `node:http` server **you** own. Given one, this host ATTACHES its two
|
|
129
|
+
* routes to it instead of creating and listening on a server of its own.
|
|
130
|
+
*
|
|
131
|
+
* ── Why ──────────────────────────────────────────────────────────────────
|
|
132
|
+
* Some runtimes hand a container exactly one port, and a container that must
|
|
133
|
+
* also answer a WebSocket upgrade — or anything else — on that port cannot
|
|
134
|
+
* use a host that privately owns the socket. Attaching costs nothing anyone
|
|
135
|
+
* else was using: `node:http` calls EVERY `'request'` listener for every
|
|
136
|
+
* request, so this host and your own routes share the port by taking turns.
|
|
137
|
+
*
|
|
138
|
+
* ── What changes, exactly ────────────────────────────────────────────────
|
|
139
|
+
* - **You own the socket.** `listen()` is yours, and so is closing it. The
|
|
140
|
+
* server must ALREADY be listening when `serve()` is called — a handle
|
|
141
|
+
* that promises `url` and `port` cannot honestly report an address that
|
|
142
|
+
* does not exist yet, so `serve()` refuses rather than guess one.
|
|
143
|
+
* - **The host never writes a 404.** A path it does not own is yours to
|
|
144
|
+
* answer, and answering it with a refusal from this host would be this
|
|
145
|
+
* host answering for your application. Note the consequence: a request no
|
|
146
|
+
* listener answers is not a 404, it HANGS — if this server has no other
|
|
147
|
+
* `'request'` listener, unmatched paths go unanswered until the socket
|
|
148
|
+
* times out. With no `server`, the 404 behaviour is unchanged.
|
|
149
|
+
* - **`close()` detaches and drains, and leaves your server listening.** It
|
|
150
|
+
* removes this host's listener, waits for the requests it is already
|
|
151
|
+
* serving, and touches nothing else — not your connections, not your
|
|
152
|
+
* socket.
|
|
153
|
+
* - It never writes to a response an earlier listener already answered.
|
|
154
|
+
*
|
|
155
|
+
* @example One port, an agent and a WebSocket upgrade
|
|
156
|
+
* const server = createServer();
|
|
157
|
+
* server.on('upgrade', (req, socket, head) => acceptWebSocket(req, socket, head));
|
|
158
|
+
* await new Promise<void>((r) => server.listen(8080, '0.0.0.0', r));
|
|
159
|
+
* const handle = await httpHost({ ...wireOptions, server }).serve(handler);
|
|
160
|
+
* // …later: the host goes away, the socket and the upgrade stay.
|
|
161
|
+
* await handle.close();
|
|
162
|
+
*/
|
|
163
|
+
readonly server?: Server;
|
|
110
164
|
}
|
|
111
165
|
/** A {@link HostHandle} that also says where it landed. */
|
|
112
166
|
export interface HttpHostHandle extends HostHandle {
|
|
113
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* Where it is actually listening, e.g. `http://127.0.0.1:53211`. With a
|
|
169
|
+
* caller-owned {@link HttpHostOptions.server} this is that server's real
|
|
170
|
+
* address — the host reports where it is answering, never where it bound,
|
|
171
|
+
* because with your server it bound nothing.
|
|
172
|
+
*/
|
|
114
173
|
readonly url: string;
|
|
115
174
|
/** The port it actually bound — the real one, when you asked for `0`. */
|
|
116
175
|
readonly port: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpHost.d.ts","sourceRoot":"","sources":["../../../src/hosting/httpHost.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"httpHost.d.ts","sourceRoot":"","sources":["../../../src/hosting/httpHost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;;AAEH,OAAO,KAAK,EAAmB,MAAM,EAAkB,MAAM,WAAW,CAAC;AAIzE,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,UAAU,EACV,WAAW,EAEX,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,2EAA2E;AAC3E,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjD,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,wCAAwC;IACxC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;;;O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WAAW,cAAe,SAAQ,UAAU;IAChD;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,oDAAoD;AACpD,MAAM,WAAW,QAAS,SAAQ,SAAS;IACzC,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACtD;AA8BD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,QAAQ,CAgI3D;AAyJD;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,gBAAgB,EACvB,IAAI,EAAE,MAAM,EACZ,GAAG,SAAS,EAAE,MAAM,EAAE,GACrB,MAAM,GAAG,SAAS,CAMpB"}
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
* itself, parameterised by the JSON dialect it speaks. `nodeHost` is one
|
|
32
32
|
* configuration of it; an adapter for someone's container runtime is
|
|
33
33
|
* another. Two paths and five body shapes are all a second HTTP adapter
|
|
34
|
-
* re-decides.
|
|
34
|
+
* re-decides. Pass `server` and it attaches to a `node:http` server YOU
|
|
35
|
+
* own instead of binding one — for the container that gets a single port
|
|
36
|
+
* and must serve a WebSocket upgrade (or anything else) beside the agent.
|
|
35
37
|
* • `memorySessions()` — conversations in a Map, for tests and local dev.
|
|
36
38
|
* • `standingAgent({ agent, sessions, host, durability? })` — the composer.
|
|
37
39
|
* • `toEnvelope` / `readEnvelope` — pack a conversation, and refuse by name to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hosting/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hosting/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE/E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACtD,YAAY,EACV,QAAQ,EACR,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,QAAQ,GACT,MAAM,eAAe,CAAC;AAEvB,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,GAClB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,SAAS,EACT,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,UAAU,EACV,WAAW,EACX,SAAS,EACT,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,GACX,MAAM,YAAY,CAAC"}
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
* a colleague's convention. A path is a deployment detail, so it is a knob
|
|
17
17
|
* here and absent from the port entirely.
|
|
18
18
|
*
|
|
19
|
+
* **The socket can be yours.** Pass `server` — a `node:http` server you
|
|
20
|
+
* created and listened on — and this adapter attaches its two routes to it
|
|
21
|
+
* instead of binding one, so a WebSocket upgrade or your own routes can share
|
|
22
|
+
* the port. `close()` then detaches and drains, and your socket stays up.
|
|
23
|
+
*
|
|
19
24
|
* **Streaming is the caller's choice, not the server's.** Send
|
|
20
25
|
* `Accept: text/event-stream` and the reply is Server-Sent Events, one `chunk`
|
|
21
26
|
* event per `reply.emit(...)` then a final `complete`. Send anything else and
|
|
@@ -29,17 +34,31 @@
|
|
|
29
34
|
* never quietly drift apart on what `close()` drains or what a handler that
|
|
30
35
|
* throws does. `types.ts` knows none of it either way.
|
|
31
36
|
*/
|
|
37
|
+
/// <reference types="node" />
|
|
32
38
|
import { type HttpHost, type HttpHostHandle, type HttpWire } from './httpHost.js';
|
|
33
39
|
/** Options for {@link nodeHost}. */
|
|
34
40
|
export interface NodeHostOptions {
|
|
35
|
-
/** Port to bind. Default `8080`. Pass `0` for an ephemeral port. */
|
|
41
|
+
/** Port to bind. Default `8080`. Pass `0` for an ephemeral port. Refused alongside `server`. */
|
|
36
42
|
readonly port?: number;
|
|
37
|
-
/** Interface to bind. Default `'0.0.0.0'`. */
|
|
43
|
+
/** Interface to bind. Default `'0.0.0.0'`. Refused alongside `server`. */
|
|
38
44
|
readonly hostname?: string;
|
|
39
45
|
/** Path that takes a request. Default `'/invoke'`. */
|
|
40
46
|
readonly invokePath?: string;
|
|
41
47
|
/** Path that answers a health probe. Default `'/health'`. */
|
|
42
48
|
readonly healthPath?: string;
|
|
49
|
+
/**
|
|
50
|
+
* A `node:http` server **you** own, already listening. Given one, this
|
|
51
|
+
* adapter attaches its two routes to it instead of binding a socket of its
|
|
52
|
+
* own — the only way to serve something else (a WebSocket upgrade, routes
|
|
53
|
+
* that were there first) on the same port, which matters when the thing
|
|
54
|
+
* running your process gives it exactly one.
|
|
55
|
+
*
|
|
56
|
+
* You keep `listen()` and you keep the shutdown; `close()` detaches this
|
|
57
|
+
* host and drains what it was already serving. On a server you own the host
|
|
58
|
+
* never writes a 404 either: a path it does not own is yours to answer. The
|
|
59
|
+
* full set of laws is on `httpHost`'s own `server` option, which this is.
|
|
60
|
+
*/
|
|
61
|
+
readonly server?: import('node:http').Server;
|
|
43
62
|
}
|
|
44
63
|
/**
|
|
45
64
|
* What {@link nodeHost}'s `serve()` resolves to — a `HostHandle` that also
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeHost.d.ts","sourceRoot":"","sources":["../../../src/hosting/nodeHost.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"nodeHost.d.ts","sourceRoot":"","sources":["../../../src/hosting/nodeHost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;AAEH,OAAO,EAAY,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE5F,oCAAoC;AACpC,MAAM,WAAW,eAAe;IAC9B,gGAAgG;IAChG,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,WAAW,EAAE,MAAM,CAAC;CAC9C;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC;AAE5C,qDAAqD;AACrD,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAIhC;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,QAsBtB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,OAAO,GAAE,eAAoB,GAAG,QAAQ,CAgBhE"}
|
|
@@ -140,6 +140,12 @@ export interface HostHandle {
|
|
|
140
140
|
* transport. Idempotent, so a shutdown hook and an explicit close can
|
|
141
141
|
* coexist. Requests arriving after it are refused with a
|
|
142
142
|
* {@link HostClosedError} naming the adapter.
|
|
143
|
+
*
|
|
144
|
+
* "Release the transport" is as strong as the port can be, because an
|
|
145
|
+
* adapter may be serving on a transport the CALLER owns rather than one it
|
|
146
|
+
* created. Releasing one of those means handing the routes back — never
|
|
147
|
+
* closing it — and a request arriving afterwards is the caller's to answer,
|
|
148
|
+
* not this host's to refuse.
|
|
143
149
|
*/
|
|
144
150
|
close(): Promise<void>;
|
|
145
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/hosting/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAInE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;;;;OAQG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,yCAAyC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,SAAS;IACxB,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;;;;;;;;;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AS,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;IACpE,gEAAgE;IAChE,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE;;;;OAIG;IACH,MAAM,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtE;AAID;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB,CAAC,EAAE,SAAS,UAAU,GAAG,UAAU;IACtE;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG;QAAE,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,EAAE,CAAC,CAAA;KAAE,CAAC;IACxE,8DAA8D;IAC9D,QAAQ,CAAC,kBAAkB,CAAC,EAAE,sBAAsB,CAAC;IACrD;;;;;;;;OAQG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC;CACtC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentfootprint",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.22.0",
|
|
4
4
|
"description": "The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sanjay Krishna Anbalagan",
|