agentfootprint 9.114.2 → 9.115.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/CAPABILITIES.md +3 -0
- package/ai-instructions/claude-code/SKILL.md +1 -1
- package/dist/adapters/hosting/agentCoreA2A.js +5 -0
- package/dist/adapters/hosting/agentCoreA2A.js.map +1 -1
- package/dist/adapters/hosting/agentcore.js +5 -0
- package/dist/adapters/hosting/agentcore.js.map +1 -1
- package/dist/adapters/hosting/foundryResponses.js +5 -0
- package/dist/adapters/hosting/foundryResponses.js.map +1 -1
- package/dist/adapters/observability/agentcore.js +18 -5
- package/dist/adapters/observability/agentcore.js.map +1 -1
- package/dist/adapters/observability/audit.js +17 -4
- package/dist/adapters/observability/audit.js.map +1 -1
- package/dist/adapters/observability/otel.js +890 -33
- package/dist/adapters/observability/otel.js.map +1 -1
- package/dist/artifacts/capability.js +9 -3
- package/dist/artifacts/capability.js.map +1 -1
- package/dist/bridge/eventMeta.js +40 -1
- package/dist/bridge/eventMeta.js.map +1 -1
- package/dist/core/Agent.js +40 -6
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/RunnerBase.js +32 -1
- package/dist/core/RunnerBase.js.map +1 -1
- package/dist/core/agent/AgentBuilder.js +13 -1
- package/dist/core/agent/AgentBuilder.js.map +1 -1
- package/dist/core/agent/stages/toolCalls.js +64 -7
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/core/flowchartAsTool.js +8 -2
- package/dist/core/flowchartAsTool.js.map +1 -1
- package/dist/core/runbook/runbookAsTool.js +7 -2
- package/dist/core/runbook/runbookAsTool.js.map +1 -1
- package/dist/core/toolShownArgs.js +55 -0
- package/dist/core/toolShownArgs.js.map +1 -0
- package/dist/esm/adapters/hosting/agentCoreA2A.d.ts +14 -1
- package/dist/esm/adapters/hosting/agentCoreA2A.js +5 -0
- package/dist/esm/adapters/hosting/agentCoreA2A.js.map +1 -1
- package/dist/esm/adapters/hosting/agentcore.d.ts +18 -2
- package/dist/esm/adapters/hosting/agentcore.js +5 -0
- package/dist/esm/adapters/hosting/agentcore.js.map +1 -1
- package/dist/esm/adapters/hosting/foundryResponses.d.ts +15 -1
- package/dist/esm/adapters/hosting/foundryResponses.js +5 -0
- package/dist/esm/adapters/hosting/foundryResponses.js.map +1 -1
- package/dist/esm/adapters/observability/agentcore.d.ts +17 -5
- package/dist/esm/adapters/observability/agentcore.js +18 -5
- package/dist/esm/adapters/observability/agentcore.js.map +1 -1
- package/dist/esm/adapters/observability/audit.d.ts +6 -2
- package/dist/esm/adapters/observability/audit.js +17 -4
- package/dist/esm/adapters/observability/audit.js.map +1 -1
- package/dist/esm/adapters/observability/otel.d.ts +240 -11
- package/dist/esm/adapters/observability/otel.js +890 -33
- package/dist/esm/adapters/observability/otel.js.map +1 -1
- package/dist/esm/artifacts/capability.d.ts +3 -1
- package/dist/esm/artifacts/capability.js +9 -3
- package/dist/esm/artifacts/capability.js.map +1 -1
- package/dist/esm/bridge/eventMeta.d.ts +32 -0
- package/dist/esm/bridge/eventMeta.js +38 -0
- package/dist/esm/bridge/eventMeta.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +18 -5
- package/dist/esm/core/Agent.js +42 -8
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/RunnerBase.d.ts +20 -0
- package/dist/esm/core/RunnerBase.js +32 -1
- package/dist/esm/core/RunnerBase.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.js +13 -1
- package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
- package/dist/esm/core/agent/stages/toolCalls.d.ts +11 -0
- package/dist/esm/core/agent/stages/toolCalls.js +64 -7
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/core/flowchartAsTool.js +8 -2
- package/dist/esm/core/flowchartAsTool.js.map +1 -1
- package/dist/esm/core/runbook/runbookAsTool.js +7 -2
- package/dist/esm/core/runbook/runbookAsTool.js.map +1 -1
- package/dist/esm/core/toolShownArgs.d.ts +62 -0
- package/dist/esm/core/toolShownArgs.js +49 -0
- package/dist/esm/core/toolShownArgs.js.map +1 -0
- package/dist/esm/events/payloads.d.ts +122 -6
- package/dist/esm/events/registry.d.ts +3 -1
- package/dist/esm/events/registry.js +2 -0
- package/dist/esm/events/registry.js.map +1 -1
- package/dist/esm/events/types.d.ts +7 -0
- package/dist/esm/hosting/artifactWire.d.ts +10 -2
- package/dist/esm/hosting/artifactWire.js +20 -2
- package/dist/esm/hosting/artifactWire.js.map +1 -1
- package/dist/esm/hosting/doorGuard.d.ts +280 -0
- package/dist/esm/hosting/doorGuard.js +499 -0
- package/dist/esm/hosting/doorGuard.js.map +1 -0
- package/dist/esm/hosting/errors.d.ts +113 -0
- package/dist/esm/hosting/errors.js +177 -0
- package/dist/esm/hosting/errors.js.map +1 -1
- package/dist/esm/hosting/httpHost.d.ts +32 -3
- package/dist/esm/hosting/httpHost.js +218 -4
- package/dist/esm/hosting/httpHost.js.map +1 -1
- package/dist/esm/hosting/index.d.ts +7 -5
- package/dist/esm/hosting/index.js +10 -3
- package/dist/esm/hosting/index.js.map +1 -1
- package/dist/esm/hosting/ingressRecord.d.ts +64 -10
- package/dist/esm/hosting/ingressRecord.js +65 -6
- package/dist/esm/hosting/ingressRecord.js.map +1 -1
- package/dist/esm/hosting/nodeHost.d.ts +32 -2
- package/dist/esm/hosting/nodeHost.js +10 -0
- package/dist/esm/hosting/nodeHost.js.map +1 -1
- package/dist/esm/hosting/standingAgent.js +362 -51
- package/dist/esm/hosting/standingAgent.js.map +1 -1
- package/dist/esm/hosting/turnArtifacts.d.ts +93 -0
- package/dist/esm/hosting/turnArtifacts.js +126 -0
- package/dist/esm/hosting/turnArtifacts.js.map +1 -0
- package/dist/esm/hosting/types.d.ts +196 -3
- package/dist/esm/hosting/types.js +10 -0
- package/dist/esm/hosting/types.js.map +1 -1
- package/dist/esm/hosting/webSocketConversation.d.ts +15 -1
- package/dist/esm/hosting/webSocketConversation.js +54 -2
- package/dist/esm/hosting/webSocketConversation.js.map +1 -1
- package/dist/esm/integrity/disposition/ledger.d.ts +8 -0
- package/dist/esm/integrity/disposition/ledger.js +0 -0
- package/dist/esm/integrity/disposition/ledger.js.map +1 -1
- package/dist/esm/lib/mcp/mcpServe.js +39 -2
- package/dist/esm/lib/mcp/mcpServe.js.map +1 -1
- package/dist/esm/lib/mcp/types.d.ts +30 -0
- package/dist/esm/recorders/observability/commentary/artifactPhrases.d.ts +4 -0
- package/dist/esm/recorders/observability/commentary/artifactPhrases.js +9 -0
- package/dist/esm/recorders/observability/commentary/artifactPhrases.js.map +1 -1
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.js +30 -3
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
- package/dist/esm/recorders/observability/recordRun.d.ts +12 -0
- package/dist/esm/recorders/observability/recordRun.js +17 -1
- package/dist/esm/recorders/observability/recordRun.js.map +1 -1
- package/dist/esm/strategies/attach.js +87 -1
- package/dist/esm/strategies/attach.js.map +1 -1
- package/dist/events/registry.js +2 -0
- package/dist/events/registry.js.map +1 -1
- package/dist/hosting/artifactWire.js +21 -3
- package/dist/hosting/artifactWire.js.map +1 -1
- package/dist/hosting/doorGuard.js +509 -0
- package/dist/hosting/doorGuard.js.map +1 -0
- package/dist/hosting/errors.js +183 -1
- package/dist/hosting/errors.js.map +1 -1
- package/dist/hosting/httpHost.js +218 -4
- package/dist/hosting/httpHost.js.map +1 -1
- package/dist/hosting/index.js +19 -2
- package/dist/hosting/index.js.map +1 -1
- package/dist/hosting/ingressRecord.js +66 -6
- package/dist/hosting/ingressRecord.js.map +1 -1
- package/dist/hosting/nodeHost.js +11 -1
- package/dist/hosting/nodeHost.js.map +1 -1
- package/dist/hosting/standingAgent.js +359 -48
- package/dist/hosting/standingAgent.js.map +1 -1
- package/dist/hosting/turnArtifacts.js +130 -0
- package/dist/hosting/turnArtifacts.js.map +1 -0
- package/dist/hosting/types.js +11 -1
- package/dist/hosting/types.js.map +1 -1
- package/dist/hosting/webSocketConversation.js +54 -2
- package/dist/hosting/webSocketConversation.js.map +1 -1
- package/dist/integrity/disposition/ledger.js +0 -0
- package/dist/integrity/disposition/ledger.js.map +1 -1
- package/dist/lib/mcp/mcpServe.js +39 -2
- package/dist/lib/mcp/mcpServe.js.map +1 -1
- package/dist/recorders/observability/commentary/artifactPhrases.js +10 -1
- package/dist/recorders/observability/commentary/artifactPhrases.js.map +1 -1
- package/dist/recorders/observability/commentary/commentaryTemplates.js +29 -2
- package/dist/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
- package/dist/recorders/observability/recordRun.js +20 -3
- package/dist/recorders/observability/recordRun.js.map +1 -1
- package/dist/strategies/attach.js +87 -1
- package/dist/strategies/attach.js.map +1 -1
- package/dist/types/adapters/hosting/agentCoreA2A.d.ts +14 -1
- package/dist/types/adapters/hosting/agentCoreA2A.d.ts.map +1 -1
- package/dist/types/adapters/hosting/agentcore.d.ts +18 -2
- package/dist/types/adapters/hosting/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/hosting/foundryResponses.d.ts +15 -1
- package/dist/types/adapters/hosting/foundryResponses.d.ts.map +1 -1
- package/dist/types/adapters/observability/agentcore.d.ts +17 -5
- package/dist/types/adapters/observability/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/observability/audit.d.ts +6 -2
- package/dist/types/adapters/observability/audit.d.ts.map +1 -1
- package/dist/types/adapters/observability/otel.d.ts +240 -11
- package/dist/types/adapters/observability/otel.d.ts.map +1 -1
- package/dist/types/artifacts/capability.d.ts +3 -1
- package/dist/types/artifacts/capability.d.ts.map +1 -1
- package/dist/types/bridge/eventMeta.d.ts +32 -0
- package/dist/types/bridge/eventMeta.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +18 -5
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/RunnerBase.d.ts +20 -0
- package/dist/types/core/RunnerBase.d.ts.map +1 -1
- package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
- package/dist/types/core/agent/stages/toolCalls.d.ts +11 -0
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/core/flowchartAsTool.d.ts.map +1 -1
- package/dist/types/core/runbook/runbookAsTool.d.ts.map +1 -1
- package/dist/types/core/toolShownArgs.d.ts +63 -0
- package/dist/types/core/toolShownArgs.d.ts.map +1 -0
- package/dist/types/events/payloads.d.ts +122 -6
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/registry.d.ts +3 -1
- package/dist/types/events/registry.d.ts.map +1 -1
- package/dist/types/events/types.d.ts +7 -0
- package/dist/types/events/types.d.ts.map +1 -1
- package/dist/types/hosting/artifactWire.d.ts +10 -2
- package/dist/types/hosting/artifactWire.d.ts.map +1 -1
- package/dist/types/hosting/doorGuard.d.ts +281 -0
- package/dist/types/hosting/doorGuard.d.ts.map +1 -0
- package/dist/types/hosting/errors.d.ts +113 -0
- package/dist/types/hosting/errors.d.ts.map +1 -1
- package/dist/types/hosting/httpHost.d.ts +32 -3
- package/dist/types/hosting/httpHost.d.ts.map +1 -1
- package/dist/types/hosting/index.d.ts +7 -5
- package/dist/types/hosting/index.d.ts.map +1 -1
- package/dist/types/hosting/ingressRecord.d.ts +64 -10
- package/dist/types/hosting/ingressRecord.d.ts.map +1 -1
- package/dist/types/hosting/nodeHost.d.ts +32 -2
- package/dist/types/hosting/nodeHost.d.ts.map +1 -1
- package/dist/types/hosting/standingAgent.d.ts.map +1 -1
- package/dist/types/hosting/turnArtifacts.d.ts +94 -0
- package/dist/types/hosting/turnArtifacts.d.ts.map +1 -0
- package/dist/types/hosting/types.d.ts +196 -3
- package/dist/types/hosting/types.d.ts.map +1 -1
- package/dist/types/hosting/webSocketConversation.d.ts +15 -1
- package/dist/types/hosting/webSocketConversation.d.ts.map +1 -1
- package/dist/types/integrity/disposition/ledger.d.ts +8 -0
- package/dist/types/integrity/disposition/ledger.d.ts.map +1 -1
- package/dist/types/lib/mcp/mcpServe.d.ts.map +1 -1
- package/dist/types/lib/mcp/types.d.ts +30 -0
- package/dist/types/lib/mcp/types.d.ts.map +1 -1
- package/dist/types/recorders/observability/commentary/artifactPhrases.d.ts +4 -0
- package/dist/types/recorders/observability/commentary/artifactPhrases.d.ts.map +1 -1
- package/dist/types/recorders/observability/commentary/commentaryTemplates.d.ts.map +1 -1
- package/dist/types/recorders/observability/recordRun.d.ts +12 -0
- package/dist/types/recorders/observability/recordRun.d.ts.map +1 -1
- package/dist/types/strategies/attach.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -339,6 +339,37 @@ export class ArtifactNotCarriedError extends Error {
|
|
|
339
339
|
this.ref = ref;
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Refused when host code uses a turn's artifact hand-over
|
|
344
|
+
* (`HostReply.turnArtifacts`) after that turn ended.
|
|
345
|
+
*
|
|
346
|
+
* The hand-over is live only while the hook runs: the composer awaits the
|
|
347
|
+
* hook while the session's lane is held, waits for every operation the hook
|
|
348
|
+
* started, then revokes the binding before the reply ends. A verb called
|
|
349
|
+
* after that is refused by name rather than performed. The footprintjs
|
|
350
|
+
* `ScopeFacade · assertLive` law, one layer up: a handle held past its stage
|
|
351
|
+
* is refused, because a write made outside its turn lands on whatever run the
|
|
352
|
+
* instance is serving by then — in the shared shape, another person's — and
|
|
353
|
+
* makes the record lie.
|
|
354
|
+
*
|
|
355
|
+
* The fix is always the same: file INSIDE the hook (`await
|
|
356
|
+
* turn.artifacts.put(...)`), and carry the ticket onward from there.
|
|
357
|
+
*/
|
|
358
|
+
export class TurnArtifactsExpiredError extends Error {
|
|
359
|
+
code = 'ERR_TURN_ARTIFACTS_EXPIRED';
|
|
360
|
+
/** Which verb was called after the turn ended. */
|
|
361
|
+
op;
|
|
362
|
+
constructor(op) {
|
|
363
|
+
super(`[hosting] turnArtifacts.${op}(...) was called after its turn ended. The hand-over ` +
|
|
364
|
+
`is live only while reply.turnArtifacts runs: the composer awaits the hook, waits ` +
|
|
365
|
+
`for every operation it started, then revokes the binding before the reply ends — ` +
|
|
366
|
+
`a write made later would land on whatever run the agent is serving by then. File ` +
|
|
367
|
+
`inside the hook (await turn.artifacts.${op}(...)) and carry the result onward from ` +
|
|
368
|
+
`there.`);
|
|
369
|
+
this.name = 'TurnArtifactsExpiredError';
|
|
370
|
+
this.op = op;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
342
373
|
/**
|
|
343
374
|
* An already-computed preview, so {@link UnreadableEnvelopeError.withSession}
|
|
344
375
|
* can copy a refusal without being handed the stored bytes a second time. Not
|
|
@@ -770,6 +801,152 @@ export class WireRequestRefusal extends Error {
|
|
|
770
801
|
this.name = 'WireRequestRefusal';
|
|
771
802
|
}
|
|
772
803
|
}
|
|
804
|
+
// ─── The door guard ──────────────────────────────────────────────────
|
|
805
|
+
//
|
|
806
|
+
// Four refusals the HOST makes before any handler sees a request — see
|
|
807
|
+
// `doorGuard.ts` for the rules and `docs/design/2026-09-door-hardening.md` for
|
|
808
|
+
// the threat. Each carries its own HTTP `status`, because the conversation door
|
|
809
|
+
// answers a pre-101 socket by hand and an application route calling the same
|
|
810
|
+
// guard answers with its own response writer; a status only `httpHost` could
|
|
811
|
+
// look up would leave both of them guessing.
|
|
812
|
+
//
|
|
813
|
+
// **None of them ever repeats what the caller sent.** Not the content type,
|
|
814
|
+
// not the Origin, not the Host, not one character of a session id — the
|
|
815
|
+
// refusal names the rule and the option that changes it, nothing else. A
|
|
816
|
+
// session id in a refusal is a session id in every log line and trace span the
|
|
817
|
+
// refusal reaches, which is the exposure the fourth one exists to close.
|
|
818
|
+
/**
|
|
819
|
+
* A request that changes something did not say `content-type: application/json`.
|
|
820
|
+
*
|
|
821
|
+
* The door is a JSON API, and that is only half the reason. The other half is
|
|
822
|
+
* the web: a page on ANY site can make a browser send `text/plain`,
|
|
823
|
+
* `application/x-www-form-urlencoded` or `multipart/form-data` — or no content
|
|
824
|
+
* type at all — without asking the server first (a CORS "simple" request). A
|
|
825
|
+
* browser must ask first (a preflight, which this host never approves) before
|
|
826
|
+
* it sends `application/json` across origins. Requiring it is what turns a
|
|
827
|
+
* forged request into one the browser refuses to send.
|
|
828
|
+
*/
|
|
829
|
+
export class UnsupportedMediaTypeError extends Error {
|
|
830
|
+
code = 'ERR_UNSUPPORTED_MEDIA_TYPE';
|
|
831
|
+
/** 415 Unsupported Media Type. */
|
|
832
|
+
status = 415;
|
|
833
|
+
constructor(hostName) {
|
|
834
|
+
super(`[hosting] the '${hostName}' host takes JSON: a request that changes anything must say ` +
|
|
835
|
+
`content-type: application/json. Other content types are refused because a web page on ` +
|
|
836
|
+
`any site can make a browser send them without asking first — this is the cross-site ` +
|
|
837
|
+
`request defence, not a parser preference. Send the header; an integration that ` +
|
|
838
|
+
`genuinely cannot is named on the host with requireJsonContentType: false.`);
|
|
839
|
+
this.name = 'UnsupportedMediaTypeError';
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* A browser request came from a page whose origin this door does not allow —
|
|
844
|
+
* or from an opaque origin (`Origin: null`), which any sandboxed frame on any
|
|
845
|
+
* site can produce and which is therefore never allowed — or the browser said
|
|
846
|
+
* outright that it was sent cross-site.
|
|
847
|
+
*
|
|
848
|
+
* Only BROWSERS send `Origin` (on every request that changes something, and on
|
|
849
|
+
* every WebSocket handshake), so a request without one is a script or a
|
|
850
|
+
* server — unless the same request carries the browser's own `Sec-Fetch-Site:
|
|
851
|
+
* cross-site`, which is how a stripped `Origin` still gets caught.
|
|
852
|
+
*/
|
|
853
|
+
export class OriginNotAllowedError extends Error {
|
|
854
|
+
code = 'ERR_ORIGIN_NOT_ALLOWED';
|
|
855
|
+
/** 403 Forbidden. */
|
|
856
|
+
status = 403;
|
|
857
|
+
/** Which browser fact refused it. */
|
|
858
|
+
rule;
|
|
859
|
+
constructor(hostName, rule) {
|
|
860
|
+
super(`[hosting] the '${hostName}' host refuses a request sent by a web page from an origin it ` +
|
|
861
|
+
`does not allow. ` +
|
|
862
|
+
(rule === 'listed'
|
|
863
|
+
? `Only the origins listed in allowedOrigins may drive it from a browser — add the ` +
|
|
864
|
+
`page's origin there if it should.`
|
|
865
|
+
: rule === 'same-host'
|
|
866
|
+
? `With allowedOrigins unset, a page may drive it only from this host's own name ` +
|
|
867
|
+
`(the request's Host, or X-Forwarded-Host from a proxy). Serve the page from this ` +
|
|
868
|
+
`host, or list its origin in allowedOrigins.`
|
|
869
|
+
: `The browser marked it cross-site (Sec-Fetch-Site) and its Origin is not one ` +
|
|
870
|
+
`allowedOrigins lists. If this is your own page, a reverse proxy in front of this ` +
|
|
871
|
+
`host is stripping or rewriting headers: it must forward Origin and Sec-Fetch-* ` +
|
|
872
|
+
`unchanged. Otherwise list the page's origin in allowedOrigins.`));
|
|
873
|
+
this.name = 'OriginNotAllowedError';
|
|
874
|
+
this.rule = rule;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* A request named a Host this door was not configured to answer for.
|
|
879
|
+
*
|
|
880
|
+
* The DNS-rebinding defence: a page on an attacker's domain re-points its OWN
|
|
881
|
+
* name at this server's address, and from then on the browser treats it as
|
|
882
|
+
* same-origin with the door — so every other check passes, and the Host header
|
|
883
|
+
* (which no page can set) is the one fact that still names the attacker.
|
|
884
|
+
* 421 is the status HTTP defines for exactly this (RFC 9110 §15.5.20: a target
|
|
885
|
+
* "that does not match an origin for which the server has been configured").
|
|
886
|
+
*/
|
|
887
|
+
export class HostNotAllowedError extends Error {
|
|
888
|
+
code = 'ERR_HOST_NOT_ALLOWED';
|
|
889
|
+
/** 421 Misdirected Request. */
|
|
890
|
+
status = 421;
|
|
891
|
+
/**
|
|
892
|
+
* Where the list came from: `'listed'` — the deployment's own
|
|
893
|
+
* `allowedHosts`; `'loopback-default'` — nobody set one, and the door is
|
|
894
|
+
* bound to a loopback address, so it answers the loopback names only.
|
|
895
|
+
*/
|
|
896
|
+
rule;
|
|
897
|
+
constructor(hostName, rule = 'listed') {
|
|
898
|
+
super(rule === 'loopback-default'
|
|
899
|
+
? `[hosting] the '${hostName}' host is bound to a loopback address, so with allowedHosts ` +
|
|
900
|
+
`unset it answers only localhost, 127.0.0.1 and [::1] — the defence against a page ` +
|
|
901
|
+
`on another domain re-pointing its own name at this machine (DNS rebinding). Behind ` +
|
|
902
|
+
`a reverse proxy that forwards the public name in Host (nginx ` +
|
|
903
|
+
`proxy_set_header Host $host), list that name in allowedHosts.`
|
|
904
|
+
: `[hosting] the '${hostName}' host is not configured to answer for the name this ` +
|
|
905
|
+
`request was sent to. It answers only the names in allowedHosts — the defence ` +
|
|
906
|
+
`against a page on another domain re-pointing its own name at this server (DNS ` +
|
|
907
|
+
`rebinding). Reach it by one of its configured names, or add this one to ` +
|
|
908
|
+
`allowedHosts.`);
|
|
909
|
+
this.name = 'HostNotAllowedError';
|
|
910
|
+
this.rule = rule;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* A session id the door will not carry: empty, longer than the ceiling, or
|
|
915
|
+
* holding anything but visible ASCII (0x21–0x7E).
|
|
916
|
+
*
|
|
917
|
+
* A session id is caller data that travels everywhere the conversation does —
|
|
918
|
+
* the store's key, every log line, every exported trace span of every turn.
|
|
919
|
+
* Unbounded, one caller with no credentials could make every span of a turn
|
|
920
|
+
* carry megabytes; with a control, a line separator or a bidi override, it
|
|
921
|
+
* could forge or disguise a line in any log that prints it; with non-ASCII,
|
|
922
|
+
* the same id read from a header (latin1) and from a body (UTF-8) would be two
|
|
923
|
+
* different conversations. So it is bounded at the door, before any of that
|
|
924
|
+
* happens. The refusal says how long the id was, never what it said.
|
|
925
|
+
*/
|
|
926
|
+
export class InvalidSessionIdError extends Error {
|
|
927
|
+
code = 'ERR_INVALID_SESSION_ID';
|
|
928
|
+
/** 400 Bad Request — the caller can send a valid id and continue. */
|
|
929
|
+
status = 400;
|
|
930
|
+
/** Which rule the id broke. Never the id. */
|
|
931
|
+
reason;
|
|
932
|
+
constructor(reason, hostName, length, limit) {
|
|
933
|
+
super(reason === 'too-long'
|
|
934
|
+
? `[hosting] the '${hostName}' host refuses a session id of ${String(length)} ` +
|
|
935
|
+
`characters; the ceiling is ${String(limit)}. A session id travels into every ` +
|
|
936
|
+
`stored row, log line and trace span of the conversation, so it is bounded at the ` +
|
|
937
|
+
`door. Send a shorter one — a UUID is 36.`
|
|
938
|
+
: reason === 'empty'
|
|
939
|
+
? `[hosting] the '${hostName}' host refuses an empty session id: every caller that ` +
|
|
940
|
+
`sent one would share a single conversation. Send an id, or leave the field out ` +
|
|
941
|
+
`to have no session.`
|
|
942
|
+
: `[hosting] the '${hostName}' host refuses a session id containing a character ` +
|
|
943
|
+
`outside visible ASCII (0x21–0x7E). A session id is printed wherever the ` +
|
|
944
|
+
`conversation is logged and read from headers and bodies alike, so it is limited ` +
|
|
945
|
+
`to characters every one of them spells the same way — a UUID fits.`);
|
|
946
|
+
this.name = 'InvalidSessionIdError';
|
|
947
|
+
this.reason = reason;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
773
950
|
export function requireCapability(host, capability) {
|
|
774
951
|
if (host.capabilities.includes(capability))
|
|
775
952
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/hosting/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD;;;;;GAKG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,GAAG,iBAA0B,CAAC;IAC3C,6BAA6B;IACpB,QAAQ,CAAS;IAE1B,YAAY,QAAgB;QAC1B,KAAK,CACH,kBAAkB,QAAQ,sDAAsD;YAC9E,wFAAwF;YACxF,iDAAiD,CACpD,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED;;;;;;;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ACF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAC/B,IAAkC,EAClC,UAA0B;IAE1B,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO;IACnD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACjF,MAAM,IAAI,KAAK,CACb,kBAAkB,IAAI,CAAC,IAAI,4BAA4B,UAAU,KAAK;QACpE,eAAe,GAAG,wBAAwB;QAC1C,+BAA+B,UAAU,uCAAuC;QAChF,oFAAoF,CACvF,CAAC;AACJ,CAAC"}
|
|
@@ -63,12 +63,28 @@
|
|
|
63
63
|
* whichever closes last; on a caller-owned one each door attaches and detaches
|
|
64
64
|
* its own listener and neither touches the socket.
|
|
65
65
|
*
|
|
66
|
+
* ── The door guard, on both doors ────────────────────────────────────────────
|
|
67
|
+
* Being able to reach the port is not permission: every browser inside the
|
|
68
|
+
* network can be steered by any page it opens. So before any handler sees a
|
|
69
|
+
* request, the request door and the conversation door ask one guard
|
|
70
|
+
* (`doorGuard.ts`): a Host this door was not configured for (421), a browser
|
|
71
|
+
* origin it does not allow (403), a state-changing request that does not say
|
|
72
|
+
* it is JSON (415) — and, once a dialect has read it, a session id over the
|
|
73
|
+
* bound (400). Judged on the headers alone — a refused body is never parsed,
|
|
74
|
+
* only drained when small so its sender reads the answer — and never invited
|
|
75
|
+
* with a `100 Continue` on a socket this host owns. Answered with the
|
|
76
|
+
* refusal's own sentence, reported to `onRefusal` listeners. Probes (the
|
|
77
|
+
* health GET, the HEAD probe) are never asked; routes handed to `onUnhandled`
|
|
78
|
+
* are the caller's. A loopback bind with `allowedHosts` unset answers the
|
|
79
|
+
* loopback names only.
|
|
80
|
+
*
|
|
66
81
|
* Pattern: Template method via configuration (Strategy on the wire format).
|
|
67
82
|
* Everything HTTP lives here and in the wires; `types.ts` knows none of it.
|
|
68
83
|
*/
|
|
69
84
|
/// <reference types="node" />
|
|
70
85
|
import type { IncomingMessage, Server, ServerResponse } from 'node:http';
|
|
71
86
|
import type { ArtifactWireRequest, ArtifactWireResult } from './artifactWire.js';
|
|
87
|
+
import { type CrossSiteOptions } from './doorGuard.js';
|
|
72
88
|
import type { SessionWireRequest, SessionWireResult } from './sessionWire.js';
|
|
73
89
|
import type { AgentHost, ConversationHandler, ConversationHost, ConversationLimits, HostCapability, HostHandle, HostHandler, PendingAsk } from './types.js';
|
|
74
90
|
import { type ConversationHandshake, type HandshakeFacts } from './webSocketConversation.js';
|
|
@@ -305,8 +321,16 @@ export interface HttpWire {
|
|
|
305
321
|
*/
|
|
306
322
|
readConversation?(facts: HandshakeFacts): ConversationHandshake;
|
|
307
323
|
}
|
|
308
|
-
/**
|
|
309
|
-
|
|
324
|
+
/**
|
|
325
|
+
* Options for {@link httpHost}.
|
|
326
|
+
*
|
|
327
|
+
* The three cross-site fields — `allowedOrigins`, `allowedHosts`,
|
|
328
|
+
* `requireJsonContentType` — come from {@link CrossSiteOptions} and are
|
|
329
|
+
* enforced by this host's door guard on its request door and its conversation
|
|
330
|
+
* door alike, before any handler sees a request. Their defaults are the safe
|
|
331
|
+
* ones; see `doorGuard.ts` for what each costs.
|
|
332
|
+
*/
|
|
333
|
+
export interface HttpHostOptions extends CrossSiteOptions {
|
|
310
334
|
/**
|
|
311
335
|
* Which adapter this is. Every refusal names it, so a caller reading an error
|
|
312
336
|
* learns which adapter said no rather than which file it came from.
|
|
@@ -331,7 +355,12 @@ export interface HttpHostOptions {
|
|
|
331
355
|
* not bind.
|
|
332
356
|
*/
|
|
333
357
|
readonly port?: number;
|
|
334
|
-
/**
|
|
358
|
+
/**
|
|
359
|
+
* Interface to bind. Default `'0.0.0.0'`. Refused together with `server`, for the same reason.
|
|
360
|
+
*
|
|
361
|
+
* Every interface means every name that resolves to one of them — which is
|
|
362
|
+
* why a host serving with `allowedHosts` unset says so once at boot.
|
|
363
|
+
*/
|
|
335
364
|
readonly hostname?: string;
|
|
336
365
|
/** What this adapter claims beyond the baseline. Default `['streaming']`. */
|
|
337
366
|
readonly capabilities?: readonly HostCapability[];
|
|
@@ -63,13 +63,30 @@
|
|
|
63
63
|
* whichever closes last; on a caller-owned one each door attaches and detaches
|
|
64
64
|
* its own listener and neither touches the socket.
|
|
65
65
|
*
|
|
66
|
+
* ── The door guard, on both doors ────────────────────────────────────────────
|
|
67
|
+
* Being able to reach the port is not permission: every browser inside the
|
|
68
|
+
* network can be steered by any page it opens. So before any handler sees a
|
|
69
|
+
* request, the request door and the conversation door ask one guard
|
|
70
|
+
* (`doorGuard.ts`): a Host this door was not configured for (421), a browser
|
|
71
|
+
* origin it does not allow (403), a state-changing request that does not say
|
|
72
|
+
* it is JSON (415) — and, once a dialect has read it, a session id over the
|
|
73
|
+
* bound (400). Judged on the headers alone — a refused body is never parsed,
|
|
74
|
+
* only drained when small so its sender reads the answer — and never invited
|
|
75
|
+
* with a `100 Continue` on a socket this host owns. Answered with the
|
|
76
|
+
* refusal's own sentence, reported to `onRefusal` listeners. Probes (the
|
|
77
|
+
* health GET, the HEAD probe) are never asked; routes handed to `onUnhandled`
|
|
78
|
+
* are the caller's. A loopback bind with `allowedHosts` unset answers the
|
|
79
|
+
* loopback names only.
|
|
80
|
+
*
|
|
66
81
|
* Pattern: Template method via configuration (Strategy on the wire format).
|
|
67
82
|
* Everything HTTP lives here and in the wires; `types.ts` knows none of it.
|
|
68
83
|
*/
|
|
69
84
|
import { encodeSSE } from '../stream.js';
|
|
85
|
+
import { checkSessionId, doorGuard, warnAllowedHostsUnset, warnBrowserRulesOff, } from './doorGuard.js';
|
|
70
86
|
import { ArtifactNotCarriedError, HostClosedError, InvalidWireOpError, RequestTooLargeError, SessionsNotCarriedError, WireRequestRefusal, } from './errors.js';
|
|
71
87
|
import { SESSION_LIST_OP, SESSION_TRANSCRIPT_OP, SESSION_PENDING_OP } from './sessionWire.js';
|
|
72
88
|
import { lowerCasedHeaders } from './headers.js';
|
|
89
|
+
import { bearerToken } from './identityVerification.js';
|
|
73
90
|
import { conversationDoor, } from './webSocketConversation.js';
|
|
74
91
|
/**
|
|
75
92
|
* Status codes mapped by refusal code. Anything else is a 500.
|
|
@@ -128,6 +145,17 @@ const STATUS_BY_CODE = {
|
|
|
128
145
|
ERR_SESSION_INDEX_UNAVAILABLE: 501,
|
|
129
146
|
ERR_SESSIONS_NOT_CARRIED: 501,
|
|
130
147
|
ERR_REQUEST_TOO_LARGE: 413,
|
|
148
|
+
// The door guard — each refusal also carries its own `status`, which is what
|
|
149
|
+
// this host answers with; listed here too so a handler that fails a reply
|
|
150
|
+
// with one of them gets the same status and never a 500.
|
|
151
|
+
// 415: a request that changes something did not say it was JSON.
|
|
152
|
+
// 403: a browser page from an origin this door does not allow.
|
|
153
|
+
// 421: a Host this door was not configured to answer for (RFC 9110 §15.5.20).
|
|
154
|
+
// 400: a session id over the ceiling or with a control character in it.
|
|
155
|
+
ERR_UNSUPPORTED_MEDIA_TYPE: 415,
|
|
156
|
+
ERR_ORIGIN_NOT_ALLOWED: 403,
|
|
157
|
+
ERR_HOST_NOT_ALLOWED: 421,
|
|
158
|
+
ERR_INVALID_SESSION_ID: 400,
|
|
131
159
|
};
|
|
132
160
|
/**
|
|
133
161
|
* What a run that stopped to ask a person answers with: **202 Accepted.**
|
|
@@ -209,6 +237,48 @@ export function httpHost(options) {
|
|
|
209
237
|
...DEFAULT_CONVERSATION_LIMITS,
|
|
210
238
|
...options.conversationLimits,
|
|
211
239
|
};
|
|
240
|
+
// ── The door guard ─────────────────────────────────────────────────
|
|
241
|
+
//
|
|
242
|
+
// Built at construction, so a configuration it could only misread (an
|
|
243
|
+
// `allowedOrigins` of 'null', an empty `allowedHosts`) is refused here, by
|
|
244
|
+
// name, before a socket exists. Both doors ask it; every refusal it makes —
|
|
245
|
+
// and every session id the bound refuses — goes to the listeners below,
|
|
246
|
+
// which is how a request no handler ever saw still reaches an ingress
|
|
247
|
+
// record.
|
|
248
|
+
//
|
|
249
|
+
// A LOOPBACK bind this host makes itself, with `allowedHosts` unset, answers
|
|
250
|
+
// the loopback names only: such a socket can be reached by no other name, so
|
|
251
|
+
// the default refuses nobody and closes DNS rebinding on a developer's own
|
|
252
|
+
// machine. (A caller-owned server's address is the caller's; it is not
|
|
253
|
+
// guessed.)
|
|
254
|
+
const guard = doorGuard({
|
|
255
|
+
name,
|
|
256
|
+
...(!ownServer && { bindHost: hostname }),
|
|
257
|
+
...(options.allowedOrigins !== undefined && { allowedOrigins: options.allowedOrigins }),
|
|
258
|
+
...(options.allowedHosts !== undefined && { allowedHosts: options.allowedHosts }),
|
|
259
|
+
...(options.requireJsonContentType !== undefined && {
|
|
260
|
+
requireJsonContentType: options.requireJsonContentType,
|
|
261
|
+
}),
|
|
262
|
+
});
|
|
263
|
+
const refusalListeners = new Set();
|
|
264
|
+
/** Tell every listener; a listener that throws is contained — the refusal is already answered. */
|
|
265
|
+
function reportRefusal(refusal) {
|
|
266
|
+
for (const listener of [...refusalListeners]) {
|
|
267
|
+
try {
|
|
268
|
+
listener(refusal);
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
// A broken log must not turn an answered refusal into this process's failure.
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/** The staged default and the rules-off notice, each said once at boot (per host name, per process). */
|
|
276
|
+
function announceBoot() {
|
|
277
|
+
if (guard.allowedHostsUnset)
|
|
278
|
+
warnAllowedHostsUnset(name);
|
|
279
|
+
if (guard.browserRulesOff)
|
|
280
|
+
warnBrowserRulesOff(name);
|
|
281
|
+
}
|
|
212
282
|
// ── The socket both doors stand on ─────────────────────────────────
|
|
213
283
|
//
|
|
214
284
|
// Refcounted, because the deployment this exists for hands a container ONE
|
|
@@ -286,6 +356,12 @@ export function httpHost(options) {
|
|
|
286
356
|
name,
|
|
287
357
|
capabilities,
|
|
288
358
|
conversationLimits,
|
|
359
|
+
onRefusal(listener) {
|
|
360
|
+
refusalListeners.add(listener);
|
|
361
|
+
return () => {
|
|
362
|
+
refusalListeners.delete(listener);
|
|
363
|
+
};
|
|
364
|
+
},
|
|
289
365
|
async serveConversations(handler) {
|
|
290
366
|
if (conversationPath === undefined) {
|
|
291
367
|
throw new Error(`[hosting] the '${name}' host was built without a 'conversationPath', so it has no ` +
|
|
@@ -309,6 +385,8 @@ export function httpHost(options) {
|
|
|
309
385
|
...(wire.readConversation && { readConversation: wire.readConversation.bind(wire) }),
|
|
310
386
|
handler,
|
|
311
387
|
accepting: () => accepting,
|
|
388
|
+
guard,
|
|
389
|
+
onRefusal: reportRefusal,
|
|
312
390
|
});
|
|
313
391
|
const onUpgrade = (request, socketOfConversation) => {
|
|
314
392
|
// THE LAW again, on the other door: an `'upgrade'` listener runs on
|
|
@@ -347,6 +425,7 @@ export function httpHost(options) {
|
|
|
347
425
|
conversationsServing = false;
|
|
348
426
|
throw err;
|
|
349
427
|
}
|
|
428
|
+
announceBoot();
|
|
350
429
|
server.on('upgrade', onUpgrade);
|
|
351
430
|
let where;
|
|
352
431
|
try {
|
|
@@ -385,6 +464,68 @@ export function httpHost(options) {
|
|
|
385
464
|
const inFlight = new Set();
|
|
386
465
|
let accepting = true;
|
|
387
466
|
let closing;
|
|
467
|
+
/**
|
|
468
|
+
* Answer a door-guard refusal, report it, and close the connection.
|
|
469
|
+
*
|
|
470
|
+
* The body the caller is still sending is never parsed. When it was
|
|
471
|
+
* INVITED (no `Expect: 100-continue`, so the client is already
|
|
472
|
+
* uploading) and is small — at most {@link REFUSAL_DRAIN_BYTES}, within
|
|
473
|
+
* {@link REFUSAL_DRAIN_MS} — it is read and discarded first, so the
|
|
474
|
+
* client finishes its upload and READS the refusal instead of meeting a
|
|
475
|
+
* reset: closing a socket with unread bytes in it makes the kernel send
|
|
476
|
+
* RST, which a client mid-upload reports as `ECONNRESET` and never sees
|
|
477
|
+
* the 415. A body announced larger than that, or one that overruns it,
|
|
478
|
+
* is not drained — the answer goes out at once and a client still
|
|
479
|
+
* sending may see the reset. That is the bound, stated.
|
|
480
|
+
*/
|
|
481
|
+
const refuseAtRequestDoor = (req, res, refusal, bodyInvited) => {
|
|
482
|
+
reportRefusal({
|
|
483
|
+
door: 'request',
|
|
484
|
+
error: refusal,
|
|
485
|
+
bearerPresent: bearerToken(lowerCasedHeaders(req.headers)) !== undefined,
|
|
486
|
+
});
|
|
487
|
+
const answer = () => {
|
|
488
|
+
try {
|
|
489
|
+
if (res.headersSent || res.writableEnded)
|
|
490
|
+
return;
|
|
491
|
+
sendJson(res, refusal.status, wire.failure(refusal.message, refusal.code), {
|
|
492
|
+
connection: 'close',
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
catch (err) {
|
|
496
|
+
failSafely(res, wire, err);
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
if (bodyInvited)
|
|
500
|
+
drainThenAnswer(req, answer);
|
|
501
|
+
else
|
|
502
|
+
answer();
|
|
503
|
+
};
|
|
504
|
+
/**
|
|
505
|
+
* `Expect: 100-continue` on a socket this host owns: judge the headers
|
|
506
|
+
* BEFORE node would say "100 Continue", so a refused request is never
|
|
507
|
+
* invited to send the body it is about to be refused for. Everything
|
|
508
|
+
* else gets its 100 and the ordinary route, exactly as node's default.
|
|
509
|
+
* (On a caller-owned server node answers 100 itself before any listener
|
|
510
|
+
* runs — that server's `checkContinue` is the caller's to own.)
|
|
511
|
+
*/
|
|
512
|
+
const onCheckContinue = (req, res) => {
|
|
513
|
+
try {
|
|
514
|
+
const path = (req.url ?? '').split('?')[0];
|
|
515
|
+
if (accepting && req.method === 'POST' && path === invokePath) {
|
|
516
|
+
const crossSite = guard.check(req);
|
|
517
|
+
if (crossSite !== undefined) {
|
|
518
|
+
refuseAtRequestDoor(req, res, crossSite, false);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
res.writeContinue();
|
|
523
|
+
route(req, res);
|
|
524
|
+
}
|
|
525
|
+
catch (err) {
|
|
526
|
+
failSafely(res, wire, err);
|
|
527
|
+
}
|
|
528
|
+
};
|
|
388
529
|
const route = (req, res) => {
|
|
389
530
|
// On a shared server an earlier listener may already have answered.
|
|
390
531
|
// Writing again would corrupt its reply; there is nothing to add.
|
|
@@ -425,7 +566,15 @@ export function httpHost(options) {
|
|
|
425
566
|
sendJson(res, STATUS_BY_CODE[refusal.code] ?? 500, wire.failure(refusal.message, refusal.code));
|
|
426
567
|
return;
|
|
427
568
|
}
|
|
428
|
-
|
|
569
|
+
// The door guard, on the headers alone: a forged request's body is
|
|
570
|
+
// never parsed. See `refuseAtRequestDoor` for what happens to the
|
|
571
|
+
// bytes it is still sending.
|
|
572
|
+
const crossSite = guard.check(req);
|
|
573
|
+
if (crossSite !== undefined) {
|
|
574
|
+
refuseAtRequestDoor(req, res, crossSite, true);
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
const served = serveOne(req, res, handler, wire, name, maxBodyBytes, reportRefusal);
|
|
429
578
|
inFlight.add(served);
|
|
430
579
|
// `serveOne` never rejects, by construction — see its doc.
|
|
431
580
|
void served.finally(() => inFlight.delete(served));
|
|
@@ -445,13 +594,17 @@ export function httpHost(options) {
|
|
|
445
594
|
}
|
|
446
595
|
};
|
|
447
596
|
const server = await acquireSocket();
|
|
597
|
+
announceBoot();
|
|
448
598
|
server.on('request', onRequest);
|
|
599
|
+
if (!ownServer)
|
|
600
|
+
server.on('checkContinue', onCheckContinue);
|
|
449
601
|
let where;
|
|
450
602
|
try {
|
|
451
603
|
where = addressOf(server);
|
|
452
604
|
}
|
|
453
605
|
catch (err) {
|
|
454
606
|
server.off('request', onRequest);
|
|
607
|
+
server.off('checkContinue', onCheckContinue);
|
|
455
608
|
await releaseSocket();
|
|
456
609
|
throw err;
|
|
457
610
|
}
|
|
@@ -477,6 +630,7 @@ export function httpHost(options) {
|
|
|
477
630
|
// thing close() promises not to do.
|
|
478
631
|
await Promise.allSettled([...inFlight]);
|
|
479
632
|
server.off('request', onRequest);
|
|
633
|
+
server.off('checkContinue', onCheckContinue);
|
|
480
634
|
// The socket goes only when the LAST door lets go of it. A
|
|
481
635
|
// conversation still open on this port is not this door's to end.
|
|
482
636
|
await releaseSocket();
|
|
@@ -495,9 +649,9 @@ export function httpHost(options) {
|
|
|
495
649
|
* which on node's defaults is the same crash the law above forbids, reached by
|
|
496
650
|
* a different road.
|
|
497
651
|
*/
|
|
498
|
-
async function serveOne(req, res, handler, wire, hostName, maxBodyBytes) {
|
|
652
|
+
async function serveOne(req, res, handler, wire, hostName, maxBodyBytes, reportRefusal) {
|
|
499
653
|
try {
|
|
500
|
-
await dispatchOne(req, res, handler, wire, hostName, maxBodyBytes);
|
|
654
|
+
await dispatchOne(req, res, handler, wire, hostName, maxBodyBytes, reportRefusal);
|
|
501
655
|
}
|
|
502
656
|
catch (err) {
|
|
503
657
|
// Everything inside answers its own failures; anything that got past them
|
|
@@ -506,7 +660,7 @@ async function serveOne(req, res, handler, wire, hostName, maxBodyBytes) {
|
|
|
506
660
|
failSafely(res, wire, err);
|
|
507
661
|
}
|
|
508
662
|
}
|
|
509
|
-
async function dispatchOne(req, res, handler, wire, hostName, maxBodyBytes) {
|
|
663
|
+
async function dispatchOne(req, res, handler, wire, hostName, maxBodyBytes, reportRefusal) {
|
|
510
664
|
const controller = new AbortController();
|
|
511
665
|
let body;
|
|
512
666
|
try {
|
|
@@ -556,6 +710,20 @@ async function dispatchOne(req, res, handler, wire, hostName, maxBodyBytes) {
|
|
|
556
710
|
}
|
|
557
711
|
throw err;
|
|
558
712
|
}
|
|
713
|
+
// The session-id bound, on whatever the dialect read it from — a body field,
|
|
714
|
+
// a header, a cookie — and on the id a session-history op names inside
|
|
715
|
+
// itself. Here, once, so no dialect can forget it, and before anything is
|
|
716
|
+
// framed: an id past this line rides every span of every turn it touches.
|
|
717
|
+
const unboundedSession = checkSessionId(read.sessionId, hostName) ?? checkSessionId(sessionOpId(read.session), hostName);
|
|
718
|
+
if (unboundedSession !== undefined) {
|
|
719
|
+
sendJson(res, unboundedSession.status, wire.failure(unboundedSession.message, unboundedSession.code, facts));
|
|
720
|
+
reportRefusal({
|
|
721
|
+
door: 'request',
|
|
722
|
+
error: unboundedSession,
|
|
723
|
+
bearerPresent: bearerToken(headers) !== undefined,
|
|
724
|
+
});
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
559
727
|
const { input, sessionId, userId, decision, artifact, session, responseHeaders } = read;
|
|
560
728
|
// The dialect's own reply headers — a `Set-Cookie` that issues a session, and
|
|
561
729
|
// nothing else so far. Stripped of `content-type` because the framing below
|
|
@@ -751,6 +919,48 @@ async function dispatchOne(req, res, handler, wire, hostName, maxBodyBytes) {
|
|
|
751
919
|
* was found to break: a surprise this file has not imagined yet becomes THIS
|
|
752
920
|
* REQUEST's 400 or 500, the failure of the thing that caused it.
|
|
753
921
|
*/
|
|
922
|
+
/** The largest refused body read-and-discarded so its sender sees the refusal. */
|
|
923
|
+
const REFUSAL_DRAIN_BYTES = 1_048_576;
|
|
924
|
+
/** How long a refused body may take to arrive before the answer goes out anyway. */
|
|
925
|
+
const REFUSAL_DRAIN_MS = 2_000;
|
|
926
|
+
/**
|
|
927
|
+
* Read and discard a refused request's body — bounded in bytes and in time —
|
|
928
|
+
* then answer. A body announced over the bound (or none at all) is answered at
|
|
929
|
+
* once. Every listener is wrapped by `answer` itself, so nothing here can be
|
|
930
|
+
* the process's failure.
|
|
931
|
+
*/
|
|
932
|
+
function drainThenAnswer(req, answer) {
|
|
933
|
+
const declared = req.headers['content-length'];
|
|
934
|
+
const chunked = req.headers['transfer-encoding'] !== undefined;
|
|
935
|
+
const length = declared === undefined ? 0 : Number(declared);
|
|
936
|
+
if (!chunked && !(length > 0 && length <= REFUSAL_DRAIN_BYTES)) {
|
|
937
|
+
answer();
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
let read = 0;
|
|
941
|
+
let done = false;
|
|
942
|
+
const finish = () => {
|
|
943
|
+
if (done)
|
|
944
|
+
return;
|
|
945
|
+
done = true;
|
|
946
|
+
clearTimeout(timer);
|
|
947
|
+
req.off('data', onData);
|
|
948
|
+
req.off('end', finish);
|
|
949
|
+
req.off('error', finish);
|
|
950
|
+
answer();
|
|
951
|
+
};
|
|
952
|
+
const onData = (chunk) => {
|
|
953
|
+
read += chunk.length;
|
|
954
|
+
if (read > REFUSAL_DRAIN_BYTES)
|
|
955
|
+
finish();
|
|
956
|
+
};
|
|
957
|
+
const timer = setTimeout(finish, REFUSAL_DRAIN_MS);
|
|
958
|
+
if (typeof timer.unref === 'function')
|
|
959
|
+
timer.unref();
|
|
960
|
+
req.on('data', onData);
|
|
961
|
+
req.once('end', finish);
|
|
962
|
+
req.once('error', finish);
|
|
963
|
+
}
|
|
754
964
|
/**
|
|
755
965
|
* Write a framing's frames, in order, as Server-Sent Events.
|
|
756
966
|
*
|
|
@@ -833,6 +1043,10 @@ function readJson(req, maxBodyBytes, hostName) {
|
|
|
833
1043
|
});
|
|
834
1044
|
});
|
|
835
1045
|
}
|
|
1046
|
+
/** The conversation a session-history op names inside itself, when it names one. */
|
|
1047
|
+
function sessionOpId(session) {
|
|
1048
|
+
return session !== undefined && 'sessionId' in session ? session.sessionId : undefined;
|
|
1049
|
+
}
|
|
836
1050
|
function sendJson(res, status, body, extraHeaders) {
|
|
837
1051
|
res.writeHead(status, { ...extraHeaders, 'content-type': 'application/json' });
|
|
838
1052
|
res.end(JSON.stringify(body));
|