@gethelio/proxy 0.1.1 → 0.3.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/index.d.ts CHANGED
@@ -113,6 +113,7 @@ declare const helioConfigSchema: z.ZodObject<{
113
113
  connect_timeout: z.ZodDefault<z.ZodString>;
114
114
  request_timeout: z.ZodDefault<z.ZodString>;
115
115
  forward_headers: z.ZodDefault<z.ZodArray<z.ZodString>>;
116
+ headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
116
117
  }, z.core.$strip>;
117
118
  listen: z.ZodPrefault<z.ZodObject<{
118
119
  port: z.ZodDefault<z.ZodNumber>;
@@ -483,8 +484,7 @@ declare function startServer(app: Hono, config: HelioConfig): ServerHandle;
483
484
  */
484
485
  declare function startSidebandServer(app: Hono, port: number, host?: string): ServerHandle;
485
486
 
486
- /** Options for constructing an UpstreamForwarder. */
487
- interface UpstreamForwarderOptions {
487
+ interface StreamableHttpForwarderOptions {
488
488
  /** The upstream MCP server URL (e.g. "http://localhost:8080/mcp"). */
489
489
  url: string;
490
490
  /** Static headers to include on every upstream request (e.g. API keys). */
@@ -493,17 +493,44 @@ interface UpstreamForwarderOptions {
493
493
  requestTimeoutMs?: number;
494
494
  }
495
495
  /**
496
- * Forward MCP requests to an upstream server via HTTP.
496
+ * Spec-compliant upstream MCP Streamable HTTP client.
497
497
  *
498
- * Sends JSON-RPC POST requests to the configured URL, passes through
499
- * session IDs and per-request headers, and captures request timing.
498
+ * Parses both `application/json` and `text/event-stream` POST responses, sends
499
+ * the negotiated protocol version, relays the upstream session id back
500
+ * downstream, and — for Helio-internal requests with no downstream session —
501
+ * borrows an internally-managed session established via `initialize`.
500
502
  */
501
- declare class UpstreamForwarder implements McpForwarder {
503
+ declare class StreamableHttpForwarder implements McpForwarder {
502
504
  private readonly url;
503
505
  private readonly staticHeaders;
504
506
  private readonly requestTimeoutMs;
505
- constructor(options: UpstreamForwarderOptions);
507
+ private readonly sessions;
508
+ constructor(options: StreamableHttpForwarderOptions);
509
+ /** Lifecycle parity with sse/stdio. No eager connect — sessions are lazy. */
510
+ connect(): Promise<void>;
511
+ /** Lifecycle parity with sse/stdio. */
512
+ close(): Promise<void>;
506
513
  forward(request: McpRequest): Promise<ForwardResult>;
514
+ /**
515
+ * Helio-internal execution path (startup prime / internal maintenance) that
516
+ * may borrow the proxy-managed internal session.
517
+ */
518
+ forwardInternal(request: McpRequest): Promise<ForwardResult>;
519
+ private send;
520
+ }
521
+
522
+ /** Options for constructing an UpstreamForwarder. */
523
+ type UpstreamForwarderOptions = StreamableHttpForwarderOptions;
524
+ /**
525
+ * @deprecated Use `StreamableHttpForwarder` directly for new code.
526
+ *
527
+ * Backward-compatible alias for older integrations that imported
528
+ * `UpstreamForwarder`. Kept to avoid a breaking API change.
529
+ *
530
+ * Behavior matches `StreamableHttpForwarder` (including Streamable HTTP SSE
531
+ * response parsing and managed internal session support).
532
+ */
533
+ declare class UpstreamForwarder extends StreamableHttpForwarder {
507
534
  }
508
535
 
509
536
  /** Options for constructing an SseUpstreamForwarder. */
@@ -1582,6 +1609,11 @@ declare class GovernedForwarder implements McpForwarder {
1582
1609
  *
1583
1610
  * This path is intended for startup warm-up and intentionally bypasses policy
1584
1611
  * and audit handling. Runtime tools/list requests still flow through forward().
1612
+ *
1613
+ * When the inner forwarder exposes `forwardInternal` (duck-typed), the prime
1614
+ * request is routed through it so session-enforcing servers (e.g. Streamable
1615
+ * HTTP upstreams) receive the request on the managed internal session rather
1616
+ * than as a sessionless call that they would reject with HTTP 400.
1585
1617
  */
1586
1618
  primeAnnotationCache(): Promise<AnnotationCachePrimeResult>;
1587
1619
  forward(request: McpRequest): Promise<ForwardResult>;
@@ -1871,4 +1903,4 @@ interface DashboardAppOptions {
1871
1903
  */
1872
1904
  declare function createDashboardApp(deps: DashboardAppDeps, options?: DashboardAppOptions): Hono;
1873
1905
 
1874
- export { type ApprovalAppOptions, type ApprovalChannel, type ApprovalOutcome, ApprovalQueue, type ApprovalQueueOptions, ApprovalRouter, type ApprovalRouterOptions, type ApprovalStatus, type ApprovalTicket, type AuditAggregateStats, type AuditListResult, type AuditPaginationOptions, type AuditQueryFilters, type AuditRecord, AuditStore, type AuditStoreOptions, type AuditTimeBucket, AuditWriter, type AuditWriterOptions, type CompilePoliciesResult, type CompiledPolicy, type CompiledPolicyRule, ConfigError, type CreateAppOptions, type DashboardAppDeps, type DashboardAppOptions, DashboardEventBus, type DashboardEventType, type DashboardEvents, type EvidenceEntry, EvidenceStore, type EvidenceStoreOptions, GovernedForwarder, type GovernedForwarderOptions, type HelioConfig, type MatchContext, type PolicyDecision, PolicyParseError, QueueChannel, type RateLimitCheckParams, type RateLimitKeyState, type RateLimitResult, RateLimiter, type RateLimiterOptions, type ServerHandle, type SessionState, type SlackActionAppOptions, SlackChannel, type SlackChannelOptions, type SpendLimitCheckParams, type SpendLimitKeyState, type SpendLimitResult, SpendLimiter, type SpendLimiterOptions, SseUpstreamForwarder, type SseUpstreamForwarderOptions, StdioForwarder, type StdioForwarderOptions, UpstreamForwarder, type UpstreamForwarderOptions, VERSION, WebhookChannel, type WebhookChannelOptions, compilePolicies, createApp, createApprovalApp, createChannels, createDashboardApp, createSidebandApp, createSlackActionApp, evaluatePolicy, loadConfig, matchRule, startServer, startSidebandServer };
1906
+ export { type ApprovalAppOptions, type ApprovalChannel, type ApprovalOutcome, ApprovalQueue, type ApprovalQueueOptions, ApprovalRouter, type ApprovalRouterOptions, type ApprovalStatus, type ApprovalTicket, type AuditAggregateStats, type AuditListResult, type AuditPaginationOptions, type AuditQueryFilters, type AuditRecord, AuditStore, type AuditStoreOptions, type AuditTimeBucket, AuditWriter, type AuditWriterOptions, type CompilePoliciesResult, type CompiledPolicy, type CompiledPolicyRule, ConfigError, type CreateAppOptions, type DashboardAppDeps, type DashboardAppOptions, DashboardEventBus, type DashboardEventType, type DashboardEvents, type EvidenceEntry, EvidenceStore, type EvidenceStoreOptions, GovernedForwarder, type GovernedForwarderOptions, type HelioConfig, type MatchContext, type PolicyDecision, PolicyParseError, QueueChannel, type RateLimitCheckParams, type RateLimitKeyState, type RateLimitResult, RateLimiter, type RateLimiterOptions, type ServerHandle, type SessionState, type SlackActionAppOptions, SlackChannel, type SlackChannelOptions, type SpendLimitCheckParams, type SpendLimitKeyState, type SpendLimitResult, SpendLimiter, type SpendLimiterOptions, SseUpstreamForwarder, type SseUpstreamForwarderOptions, StdioForwarder, type StdioForwarderOptions, StreamableHttpForwarder, type StreamableHttpForwarderOptions, UpstreamForwarder, type UpstreamForwarderOptions, VERSION, WebhookChannel, type WebhookChannelOptions, compilePolicies, createApp, createApprovalApp, createChannels, createDashboardApp, createSidebandApp, createSlackActionApp, evaluatePolicy, loadConfig, matchRule, startServer, startSidebandServer };