agentfootprint 7.24.0 → 7.25.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.
Files changed (71) hide show
  1. package/dist/adapters/hosting/agentcore.js +112 -1
  2. package/dist/adapters/hosting/agentcore.js.map +1 -1
  3. package/dist/esm/adapters/hosting/agentcore.d.ts +50 -1
  4. package/dist/esm/adapters/hosting/agentcore.js +110 -0
  5. package/dist/esm/adapters/hosting/agentcore.js.map +1 -1
  6. package/dist/esm/hosting/errors.d.ts +44 -2
  7. package/dist/esm/hosting/errors.js +63 -0
  8. package/dist/esm/hosting/errors.js.map +1 -1
  9. package/dist/esm/hosting/headers.d.ts +16 -0
  10. package/dist/esm/hosting/headers.js +24 -0
  11. package/dist/esm/hosting/headers.js.map +1 -0
  12. package/dist/esm/hosting/httpHost.d.ts +70 -4
  13. package/dist/esm/hosting/httpHost.js +211 -47
  14. package/dist/esm/hosting/httpHost.js.map +1 -1
  15. package/dist/esm/hosting/index.d.ts +23 -8
  16. package/dist/esm/hosting/index.js +21 -6
  17. package/dist/esm/hosting/index.js.map +1 -1
  18. package/dist/esm/hosting/nodeHost.d.ts +23 -0
  19. package/dist/esm/hosting/nodeHost.js +21 -1
  20. package/dist/esm/hosting/nodeHost.js.map +1 -1
  21. package/dist/esm/hosting/types.d.ts +212 -6
  22. package/dist/esm/hosting/types.js +7 -5
  23. package/dist/esm/hosting/types.js.map +1 -1
  24. package/dist/esm/hosting/webSocketConversation.d.ts +101 -0
  25. package/dist/esm/hosting/webSocketConversation.js +341 -0
  26. package/dist/esm/hosting/webSocketConversation.js.map +1 -0
  27. package/dist/esm/hosting/webSocketFrames.d.ts +164 -0
  28. package/dist/esm/hosting/webSocketFrames.js +284 -0
  29. package/dist/esm/hosting/webSocketFrames.js.map +1 -0
  30. package/dist/esm/hosting-providers.d.ts +7 -2
  31. package/dist/esm/hosting-providers.js +7 -2
  32. package/dist/esm/hosting-providers.js.map +1 -1
  33. package/dist/hosting/errors.js +66 -1
  34. package/dist/hosting/errors.js.map +1 -1
  35. package/dist/hosting/headers.js +28 -0
  36. package/dist/hosting/headers.js.map +1 -0
  37. package/dist/hosting/httpHost.js +211 -47
  38. package/dist/hosting/httpHost.js.map +1 -1
  39. package/dist/hosting/index.js +23 -6
  40. package/dist/hosting/index.js.map +1 -1
  41. package/dist/hosting/nodeHost.js +20 -0
  42. package/dist/hosting/nodeHost.js.map +1 -1
  43. package/dist/hosting/types.js +7 -5
  44. package/dist/hosting/types.js.map +1 -1
  45. package/dist/hosting/webSocketConversation.js +345 -0
  46. package/dist/hosting/webSocketConversation.js.map +1 -0
  47. package/dist/hosting/webSocketFrames.js +297 -0
  48. package/dist/hosting/webSocketFrames.js.map +1 -0
  49. package/dist/hosting-providers.js +8 -2
  50. package/dist/hosting-providers.js.map +1 -1
  51. package/dist/types/adapters/hosting/agentcore.d.ts +50 -1
  52. package/dist/types/adapters/hosting/agentcore.d.ts.map +1 -1
  53. package/dist/types/hosting/errors.d.ts +44 -2
  54. package/dist/types/hosting/errors.d.ts.map +1 -1
  55. package/dist/types/hosting/headers.d.ts +17 -0
  56. package/dist/types/hosting/headers.d.ts.map +1 -0
  57. package/dist/types/hosting/httpHost.d.ts +70 -4
  58. package/dist/types/hosting/httpHost.d.ts.map +1 -1
  59. package/dist/types/hosting/index.d.ts +23 -8
  60. package/dist/types/hosting/index.d.ts.map +1 -1
  61. package/dist/types/hosting/nodeHost.d.ts +23 -0
  62. package/dist/types/hosting/nodeHost.d.ts.map +1 -1
  63. package/dist/types/hosting/types.d.ts +212 -6
  64. package/dist/types/hosting/types.d.ts.map +1 -1
  65. package/dist/types/hosting/webSocketConversation.d.ts +102 -0
  66. package/dist/types/hosting/webSocketConversation.d.ts.map +1 -0
  67. package/dist/types/hosting/webSocketFrames.d.ts +165 -0
  68. package/dist/types/hosting/webSocketFrames.d.ts.map +1 -0
  69. package/dist/types/hosting-providers.d.ts +7 -2
  70. package/dist/types/hosting-providers.d.ts.map +1 -1
  71. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webSocketFrames.js","sourceRoot":"","sources":["../../src/hosting/webSocketFrames.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;;;AAEH,6CAAyC;AAEzC,gFAAgF;AACnE,QAAA,MAAM,GAAG;IACpB,YAAY,EAAE,GAAG;IACjB,IAAI,EAAE,GAAG;IACT,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;CACD,CAAC;AAEX;;;GAGG;AACU,QAAA,UAAU,GAAG;IACxB,sCAAsC;IACtC,MAAM,EAAE,IAAI;IACZ,iCAAiC;IACjC,SAAS,EAAE,IAAI;IACf,mCAAmC;IACnC,aAAa,EAAE,IAAI;IACnB,+DAA+D;IAC/D,eAAe,EAAE,IAAI;IACrB,yEAAyE;IACzE,QAAQ,EAAE,IAAI;IACd,oCAAoC;IACpC,cAAc,EAAE,IAAI;IACpB,+BAA+B;IAC/B,MAAM,EAAE,IAAI;CACJ,CAAC;AAYX;;;;GAIG;AACH,MAAa,kBAAmB,SAAQ,KAAK;IAClC,SAAS,CAAS;IAE3B,YAAY,SAAiB,EAAE,OAAe;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AARD,gDAQC;AAED,iFAAiF;AACjF,MAAM,cAAc,GAAG,sCAAsC,CAAC;AAE9D;;;;GAIG;AACH,SAAgB,SAAS,CAAC,SAAiB;IACzC,OAAO,IAAA,wBAAU,EAAC,MAAM,CAAC;SACtB,MAAM,CAAC,SAAS,GAAG,cAAc,CAAC;SAClC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACtB,CAAC;AAJD,8BAIC;AAED;;;;;;GAMG;AACH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E;YAAE,OAAO,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAE5E,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;QACjD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAClC,CAAC;CACF;AAnGD,kCAmGC;AAED;;;;;;;GAOG;AACH,SAAgB,UAAU,CAAC,OAAe;IACxC,IAAI,CAAC;QACH,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACnE,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,kBAAkB,CAC1B,kBAAU,CAAC,cAAc,EACzB,qDAAqD,CACtD,CAAC;IACJ,CAAC;AACH,CAAC;AATD,gCASC"}
@@ -20,7 +20,12 @@
20
20
  * • `agentCoreRuntimeHost({ port?, hostname?, busy? })` — an `AgentHost` for
21
21
  * AWS Bedrock AgentCore Runtime's container contract: `POST /invocations`,
22
22
  * `GET /ping`, port 8080, and the conversation id read from the
23
- * `X-Amzn-Bedrock-AgentCore-Runtime-Session-Id` header.
23
+ * `X-Amzn-Bedrock-AgentCore-Runtime-Session-Id` header. It is a
24
+ * `ConversationHost` too: `serveConversations(handler)` takes the runtime's
25
+ * `/ws` door on the SAME socket, with `{ maxFrameBytes: 32768,
26
+ * idleMs: 900000 }` declared, session affinity readable from header or
27
+ * query, and a `Sec-WebSocket-Protocol` bearer mapped into
28
+ * `headers.authorization`.
24
29
  * • `agentCoreSessions({ store })` — a `SessionLifecycle` whose checkpoint
25
30
  * home you choose at construction: a JSON file in the runtime's own session
26
31
  * storage (survives a stop/resume, needs no SDK), or one AgentCore Memory
@@ -48,10 +53,11 @@
48
53
  * process.on('SIGTERM', () => void handle.close());
49
54
  */
50
55
  Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.DEFAULT_SESSION_STORAGE_PATH = exports.agentCoreSessions = exports.agentCoreRuntimeWire = exports.agentCoreRuntimeHost = void 0;
56
+ exports.DEFAULT_SESSION_STORAGE_PATH = exports.agentCoreSessions = exports.readAgentCoreConversation = exports.agentCoreRuntimeWire = exports.agentCoreRuntimeHost = void 0;
52
57
  var agentcore_js_1 = require("./adapters/hosting/agentcore.js");
53
58
  Object.defineProperty(exports, "agentCoreRuntimeHost", { enumerable: true, get: function () { return agentcore_js_1.agentCoreRuntimeHost; } });
54
59
  Object.defineProperty(exports, "agentCoreRuntimeWire", { enumerable: true, get: function () { return agentcore_js_1.agentCoreRuntimeWire; } });
60
+ Object.defineProperty(exports, "readAgentCoreConversation", { enumerable: true, get: function () { return agentcore_js_1.readAgentCoreConversation; } });
55
61
  Object.defineProperty(exports, "agentCoreSessions", { enumerable: true, get: function () { return agentcore_js_1.agentCoreSessions; } });
56
62
  Object.defineProperty(exports, "DEFAULT_SESSION_STORAGE_PATH", { enumerable: true, get: function () { return agentcore_js_1.DEFAULT_SESSION_STORAGE_PATH; } });
57
63
  //# sourceMappingURL=hosting-providers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hosting-providers.js","sourceRoot":"","sources":["../src/hosting-providers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;;;AAEH,gEAKyC;AAJvC,oHAAA,oBAAoB,OAAA;AACpB,oHAAA,oBAAoB,OAAA;AACpB,iHAAA,iBAAiB,OAAA;AACjB,4HAAA,4BAA4B,OAAA"}
1
+ {"version":3,"file":"hosting-providers.js","sourceRoot":"","sources":["../src/hosting-providers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;;;AAEH,gEAMyC;AALvC,oHAAA,oBAAoB,OAAA;AACpB,oHAAA,oBAAoB,OAAA;AACpB,yHAAA,yBAAyB,OAAA;AACzB,iHAAA,iBAAiB,OAAA;AACjB,4HAAA,4BAA4B,OAAA"}
@@ -23,12 +23,26 @@
23
23
  *
24
24
  * POST /invocations JSON `{ "prompt": "..." }` → JSON `{ "response", "status" }`
25
25
  * GET /ping → `{ "status": "Healthy", "time_of_last_update": <unix seconds> }`
26
+ * GET /ws a bidirectional WebSocket, on the SAME port
26
27
  *
27
28
  * and the caller's conversation arrives in the
28
29
  * `X-Amzn-Bedrock-AgentCore-Runtime-Session-Id` header rather than in the body,
29
30
  * which is the one thing paths-and-bodies configuration alone could not
30
31
  * express before this release.
31
32
  *
33
+ * ── The second door ──────────────────────────────────────────────────────────
34
+ * `/ws` is this runtime's answer for a caller that cannot host an inbound
35
+ * endpoint — a browser, most obviously — and so dials out and parks a channel
36
+ * instead. It is the same container and the same port, which is exactly why the
37
+ * two doors here share one socket.
38
+ *
39
+ * Its wire facts are ADAPTER facts and live nowhere but this file: 32KB frames,
40
+ * a 15-minute idle ceiling, the bearer credential carried as a
41
+ * `Sec-WebSocket-Protocol` offer because a browser's WebSocket API cannot set a
42
+ * header, and session affinity that has to be readable from the query string
43
+ * for the same reason. The port knows none of it — it is handed a session id
44
+ * and a header bag, the same two things every other transport hands it.
45
+ *
32
46
  * ── Verification status, stated plainly ──────────────────────────────────────
33
47
  * `agentCoreRuntimeHost` is **plain HTTP and is really verified**: it runs the
34
48
  * same host conformance suite as `nodeHost`, over a real socket, in
@@ -54,7 +68,7 @@
54
68
  * importing this module costs zero peer-dep load.
55
69
  */
56
70
  /// <reference types="node" />
57
- import type { HttpHost, HttpWire } from '../../hosting/httpHost.js';
71
+ import type { ConversationHandshake, HandshakeFacts, HttpHost, HttpWire } from '../../hosting/httpHost.js';
58
72
  import type { CheckpointEnvelope, SessionLifecycle } from '../../hosting/types.js';
59
73
  /** Options for {@link agentCoreRuntimeHost}. */
60
74
  export interface AgentCoreRuntimeHostOptions {
@@ -104,6 +118,14 @@ export interface AgentCoreRuntimeHostOptions {
104
118
  * });
105
119
  */
106
120
  readonly server?: import('node:http').Server;
121
+ /**
122
+ * Path that takes a conversation upgrade. Default `'/ws'` — the runtime's
123
+ * own second door, beside `/invocations` on the same port.
124
+ *
125
+ * You do not need `server` for this: both doors share one socket by
126
+ * construction, which is what the single-port container required.
127
+ */
128
+ readonly conversationPath?: string;
107
129
  }
108
130
  /**
109
131
  * The AgentCore Runtime contract as an {@link HttpWire}.
@@ -113,6 +135,33 @@ export interface AgentCoreRuntimeHostOptions {
113
135
  * else can reuse them by name.
114
136
  */
115
137
  export declare function agentCoreRuntimeWire(busy?: () => boolean): HttpWire;
138
+ /**
139
+ * The `/ws` handshake, in this runtime's spelling: **header-or-query session
140
+ * affinity, and the bearer subprotocol mapped into headers.**
141
+ *
142
+ * ── Why the query string is read at all ──────────────────────────────────────
143
+ * The same header carries the session on `/invocations`, and it is preferred
144
+ * here too. But the caller this door exists for is a browser, and the browser
145
+ * WebSocket API cannot set a header — so a session id has nowhere to travel
146
+ * except the URL. Both the runtime's header name and the plain `sessionId` are
147
+ * accepted as query parameters, case-insensitively; **the header wins** when
148
+ * both arrive, so a caller that sets both is never surprised by which one the
149
+ * server preferred. That is the same precedence rule the request dialect uses.
150
+ *
151
+ * ── Why the credential becomes a header ──────────────────────────────────────
152
+ * A bearer token offered as a subprotocol is this runtime's spelling of
153
+ * `Authorization`, and a port field spelled the way one vendor spells it is how
154
+ * a port stops being one. So it lands in `headers.authorization` as
155
+ * `Bearer <token>` — the vocabulary every other transport already uses — and
156
+ * the raw `sec-websocket-protocol` header is left in place, so an application
157
+ * that reads the offer itself still can. **Nothing here authenticates
158
+ * anything**: the port never proves who is calling, and a token that arrived is
159
+ * a claim, exactly like the session id beside it.
160
+ *
161
+ * Exported by name so the mapping is inspectable and testable without binding a
162
+ * socket, the same way the body shapes are.
163
+ */
164
+ export declare function readAgentCoreConversation(facts: HandshakeFacts): ConversationHandshake;
116
165
  /**
117
166
  * An `AgentHost` that speaks AgentCore Runtime's container contract.
118
167
  *
@@ -1 +1 @@
1
- {"version":3,"file":"agentcore.d.ts","sourceRoot":"","sources":["../../../../src/adapters/hosting/agentcore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;;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;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,WAAW,EAAE,MAAM,CAAC;CAC9C;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,MAAM,OAAO,GAAG,QAAQ,CA4CnE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,2BAAgC,GAAG,QAAQ,CAmBxF;AAID;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG,QAAQ,CAAC;AAEjE,+DAA+D;AAC/D,eAAO,MAAM,4BAA4B,2BAA2B,CAAC;AAErE,wCAAwC;AACxC,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,kEAAkE;AAClE,MAAM,WAAW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just needs to
18
18
  * say so loudly and name the adapter it is talking about.
19
19
  */
20
- import type { AgentHost, HostCapability, PendingAsk } from './types.js';
20
+ import type { AgentHost, ConversationHost, HostCapability, PendingAsk } from './types.js';
21
21
  /**
22
22
  * Thrown when a request arrives at a host that is shutting down or shut down.
23
23
  *
@@ -110,6 +110,44 @@ export declare class NoPendingAskError extends Error {
110
110
  readonly sessionId: string;
111
111
  constructor(sessionId: string);
112
112
  }
113
+ /**
114
+ * Thrown when something is sent down a conversation that has already ended.
115
+ *
116
+ * A closed channel that accepts frames and drops them is the worst of the three
117
+ * options: the sender believes the far side got it, the far side never did, and
118
+ * nothing anywhere says so. Refusing by name is the only version of this that
119
+ * leaves a trace.
120
+ *
121
+ * `onClose` is how you avoid meeting this — subscribe, and stop sending.
122
+ */
123
+ export declare class ConversationClosedError extends Error {
124
+ readonly code: "ERR_CONVERSATION_CLOSED";
125
+ /** Which adapter's door this was. */
126
+ readonly hostName: string;
127
+ /** The session the conversation claimed, when it claimed one. */
128
+ readonly sessionId?: string;
129
+ constructor(hostName: string, sessionId?: string);
130
+ }
131
+ /**
132
+ * Thrown when a frame is bigger than the ceiling the adapter DECLARED.
133
+ *
134
+ * This is the other half of {@link ConversationLimits} — a declared ceiling
135
+ * nothing enforces is a number in a doc comment. The port neither chunks nor
136
+ * truncates, on purpose: how a message is split, numbered and reassembled is
137
+ * the consumer's protocol question, and answering it inside the adapter would
138
+ * answer it for every consumer at once. So the ceiling is visible, the refusal
139
+ * names it, and the splitting happens above the port where the protocol lives.
140
+ */
141
+ export declare class FrameTooLargeError extends Error {
142
+ readonly code: "ERR_FRAME_TOO_LARGE";
143
+ /** Which adapter's door refused. */
144
+ readonly hostName: string;
145
+ /** How big the frame was, in bytes of UTF-8. */
146
+ readonly bytes: number;
147
+ /** The declared ceiling it crossed. */
148
+ readonly maxFrameBytes: number;
149
+ constructor(hostName: string, bytes: number, maxFrameBytes: number);
150
+ }
113
151
  /**
114
152
  * Thrown when a store hands back something that is **present but unreadable**
115
153
  * where a `CheckpointEnvelope` should be.
@@ -161,11 +199,15 @@ export declare class UnreadableEnvelopeError extends TypeError {
161
199
  * assumed, and asking for one that is absent tells you which adapter you are
162
200
  * actually holding rather than failing quietly somewhere downstream.
163
201
  *
202
+ * Takes either port, because both declare the same two facts — who they are and
203
+ * what they can do — and a caller holding a conversation-only host is entitled
204
+ * to the same answer as one holding a request host.
205
+ *
164
206
  * @example
165
207
  * requireCapability(host, 'streaming'); // throws unless this host streams
166
208
  *
167
209
  * // or branch instead of insisting:
168
210
  * if (host.capabilities.includes('streaming')) { ... }
169
211
  */
170
- export declare function requireCapability(host: AgentHost, capability: HostCapability): void;
212
+ export declare function requireCapability(host: AgentHost | ConversationHost, capability: HostCapability): void;
171
213
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/hosting/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExE;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,oBAA8B;IAC3C,6BAA6B;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,QAAQ,EAAE,MAAM;CAS7B;AAED;;;;;;;;GAQG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,uBAAiC;IAC9C,gDAAgD;IAChD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,mEAAmE;IACnE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;gBAElB,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;CAapD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAA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ED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,GAAG,gBAAgB,EAClC,UAAU,EAAE,cAAc,GACzB,IAAI,CASN"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * hosting/headers — one lower-casing of one header bag, shared by every door.
3
+ *
4
+ * A six-line helper gets its own file for the reason every other shared piece
5
+ * in this folder does: two copies of it is how the request door and the
6
+ * conversation door end up disagreeing about whether a header the caller sent
7
+ * as `X-Session-Id` is present, and that disagreement would surface as one door
8
+ * seeing a session the other cannot.
9
+ */
10
+ /// <reference types="node" />
11
+ import type { IncomingMessage } from 'node:http';
12
+ /**
13
+ * Header names lower-cased, repeated values joined — the shape every wire reads
14
+ * from, so no wire ever has to guess at casing.
15
+ */
16
+ export declare function lowerCasedHeaders(headers: IncomingMessage['headers']): Record<string, string>;
17
+ //# sourceMappingURL=headers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../../src/hosting/headers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO7F"}
@@ -34,12 +34,28 @@
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
  /// <reference types="node" />
41
55
  import type { Server } from 'node:http';
42
- import type { AgentHost, HostCapability, HostHandle, HostHandler, PendingAsk } from './types.js';
56
+ import type { AgentHost, ConversationHandler, ConversationHost, ConversationLimits, HostCapability, HostHandle, HostHandler, PendingAsk } from './types.js';
57
+ import { type ConversationHandshake, type HandshakeFacts } from './webSocketConversation.js';
58
+ export type { ConversationHandshake, HandshakeFacts };
43
59
  /** Everything a {@link HttpWire} may read when pulling a request apart. */
44
60
  export interface HttpRequestFacts {
45
61
  /** The parsed JSON body, or `{}` for an empty one. */
@@ -93,6 +109,17 @@ export interface HttpWire {
93
109
  * either way.
94
110
  */
95
111
  awaiting?(pending: PendingAsk): unknown;
112
+ /**
113
+ * Pull the port's vocabulary out of one conversation handshake — the session
114
+ * this conversation claims, any header mapping this dialect performs, and the
115
+ * subprotocol to echo.
116
+ *
117
+ * Optional, and absent means "raw headers, no session": there is no body in a
118
+ * handshake, so a dialect that wants a session id has to name where it looks,
119
+ * and guessing on its behalf would invent an affinity rule the deployment
120
+ * never agreed to.
121
+ */
122
+ readConversation?(facts: HandshakeFacts): ConversationHandshake;
96
123
  }
97
124
  /** Options for {@link httpHost}. */
98
125
  export interface HttpHostOptions {
@@ -161,6 +188,31 @@ export interface HttpHostOptions {
161
188
  * await handle.close();
162
189
  */
163
190
  readonly server?: Server;
191
+ /**
192
+ * Path that takes a conversation upgrade.
193
+ *
194
+ * **No default, for exactly the reason `invokePath` has none** — a default
195
+ * here is inherited by every adapter built on this file, and one that
196
+ * silently matched somebody's runtime contract is that runtime leaking into a
197
+ * library that promises not to know about one.
198
+ *
199
+ * ABSENT is meaningful: the host does not declare `'conversation'` and
200
+ * {@link HttpHost.serveConversations} refuses by name. Present, and the host
201
+ * can carry conversations whether or not anybody serves them.
202
+ */
203
+ readonly conversationPath?: string;
204
+ /**
205
+ * What the conversation door caps. Whatever is left out is filled with this
206
+ * file's defaults and then DECLARED, so `conversationLimits` on the host is
207
+ * always what is actually enforced rather than what was passed in.
208
+ *
209
+ * An unset `maxFrameBytes` would mean an unbounded buffer somebody else
210
+ * fills, which is a way to kill this process; an unset `maxPendingBytes` the
211
+ * same, one layer up. `idleMs` has no default because this door does not idle
212
+ * anything out — it reports the ceiling of whatever sits in front of it, and
213
+ * inventing one would be reporting a fact nobody established.
214
+ */
215
+ readonly conversationLimits?: ConversationLimits;
164
216
  }
165
217
  /** A {@link HostHandle} that also says where it landed. */
166
218
  export interface HttpHostHandle extends HostHandle {
@@ -174,9 +226,18 @@ export interface HttpHostHandle extends HostHandle {
174
226
  /** The port it actually bound — the real one, when you asked for `0`. */
175
227
  readonly port: number;
176
228
  }
177
- /** {@link AgentHost} narrowed to an HTTP handle. */
178
- export interface HttpHost extends AgentHost {
229
+ /**
230
+ * {@link AgentHost} and {@link ConversationHost} narrowed to an HTTP handle.
231
+ *
232
+ * One object with two doors, because they share one socket. Whether the
233
+ * conversation door is USABLE is `capabilities`' answer, not this type's: a
234
+ * host built without a `conversationPath` still has the method and refuses by
235
+ * name, which is a better error than a method that is missing at runtime on
236
+ * some adapters and present on others.
237
+ */
238
+ export interface HttpHost extends AgentHost, ConversationHost {
179
239
  serve(handler: HostHandler): Promise<HttpHostHandle>;
240
+ serveConversations(handler: ConversationHandler): Promise<HttpHostHandle>;
180
241
  }
181
242
  /**
182
243
  * An HTTP host for one handler, speaking the dialect you hand it.
@@ -192,6 +253,11 @@ export declare function httpHost(options: HttpHostOptions): HttpHost;
192
253
  * Exported because every wire that maps a header needs it and re-deriving it
193
254
  * per adapter is how one of them ends up matching only the exact casing the
194
255
  * author happened to test with.
256
+ *
257
+ * Takes anything carrying lower-cased headers, so a request wire and a
258
+ * handshake wire read a header the same way rather than each growing their own.
195
259
  */
196
- export declare function headerValue(facts: HttpRequestFacts, name: string, ...fallbacks: string[]): string | undefined;
260
+ export declare function headerValue(facts: {
261
+ readonly headers: Readonly<Record<string, string>>;
262
+ }, name: string, ...fallbacks: string[]): string | undefined;
197
263
  //# sourceMappingURL=httpHost.d.ts.map
@@ -1 +1 @@
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;;;;;;OAMG;IACH,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG;QACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAC5B;;;;WAIG;QACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;KAC7B,CAAC;IACF,kFAAkF;IAClF,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;I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;OAUG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CAClD;AAED,2DAA2D;AAC3D,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAS,SAAQ,SAAS,EAAE,gBAAgB;IAC3D,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACrD,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC3E;AA6CD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,QAAQ,CAmR3D;AAgJD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,EAC7D,IAAI,EAAE,MAAM,EACZ,GAAG,SAAS,EAAE,MAAM,EAAE,GACrB,MAAM,GAAG,SAAS,CAMpB"}
@@ -1,13 +1,17 @@
1
1
  /**
2
- * agentfootprint/hosting — the two ports between an agent and the place it runs.
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 two things, and only two: something has to carry requests
6
- * to it, and the conversation has to outlive the request. This subpath is those
7
- * two things as **ports**, plus local adapters that prove the ports work, plus
8
- * the composer that wires them together.
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,10 +76,10 @@
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';
70
85
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hosting/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;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,EACjB,uBAAuB,GACxB,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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hosting/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;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,qBAAqB,EACrB,cAAc,EACd,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,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,SAAS,EACT,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,SAAS,EACT,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,UAAU,GACX,MAAM,YAAY,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
@@ -1 +1 @@
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,eA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