stitchkit 0.67.0 → 0.68.1

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 (226) hide show
  1. package/dist/agent-runtime/admission-lanes.d.ts +1 -1
  2. package/dist/agent-runtime/compaction.d.ts +2 -2
  3. package/dist/agent-runtime/events.d.ts +1 -1
  4. package/dist/agent-runtime/history.d.ts +1 -1
  5. package/dist/agent-runtime/history.d.ts.map +1 -1
  6. package/dist/agent-runtime/injection.d.ts +1 -1
  7. package/dist/agent-runtime/managed-tools.d.ts +3 -3
  8. package/dist/agent-runtime/models.d.ts +1 -1
  9. package/dist/agent-runtime/observability.d.ts +1 -1
  10. package/dist/agent-runtime/prompt.d.ts +1 -1
  11. package/dist/agent-runtime/prompt.d.ts.map +1 -1
  12. package/dist/agent-runtime/protocol.d.ts +19 -1
  13. package/dist/agent-runtime/protocol.d.ts.map +1 -1
  14. package/dist/agent-runtime/run-execution.d.ts +5 -5
  15. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  16. package/dist/agent-runtime/runtime-internals.d.ts +1 -1
  17. package/dist/agent-runtime/runtime-result.d.ts +1 -1
  18. package/dist/agent-runtime/runtime.d.ts +14 -12
  19. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  20. package/dist/agent-runtime/store-driver.d.ts +2 -2
  21. package/dist/agent-runtime/store.d.ts +2 -2
  22. package/dist/agent-runtime/terminal-commit.d.ts +2 -2
  23. package/dist/agent-runtime/terminal-status.d.ts +1 -1
  24. package/dist/agent-runtime-openrouter.d.ts +1 -1
  25. package/dist/agent-runtime.d.ts +15 -15
  26. package/dist/agent-runtime.d.ts.map +1 -1
  27. package/dist/agent-runtime.js +90 -30
  28. package/dist/application/admission.d.ts +131 -0
  29. package/dist/application/admission.d.ts.map +1 -0
  30. package/dist/application/channel.d.ts +106 -0
  31. package/dist/application/channel.d.ts.map +1 -0
  32. package/dist/application/events.d.ts +2 -2
  33. package/dist/application/grammy.d.ts +2 -2
  34. package/dist/application/graph.d.ts +1 -1
  35. package/dist/application/health.d.ts +1 -1
  36. package/dist/application/kernel.d.ts +3 -3
  37. package/dist/application/latest-sink.d.ts.map +1 -1
  38. package/dist/application/opentelemetry.d.ts +3 -3
  39. package/dist/application/resource.d.ts +1 -1
  40. package/dist/application/schedule.d.ts +1 -1
  41. package/dist/application/server-resource.d.ts +7 -9
  42. package/dist/application/server-resource.d.ts.map +1 -1
  43. package/dist/application-grammy.d.ts +1 -1
  44. package/dist/application-grammy.js +1 -1
  45. package/dist/application-opentelemetry.d.ts +1 -1
  46. package/dist/application-opentelemetry.js +1 -1
  47. package/dist/application.d.ts +11 -9
  48. package/dist/application.d.ts.map +1 -1
  49. package/dist/application.js +393 -24
  50. package/dist/browser/client-multipart.d.ts +1 -1
  51. package/dist/browser/client-url.d.ts +2 -2
  52. package/dist/browser/client.d.ts +4 -5
  53. package/dist/browser/client.d.ts.map +1 -1
  54. package/dist/browser/contract-stream.d.ts +5 -0
  55. package/dist/browser/contract-stream.d.ts.map +1 -0
  56. package/dist/browser/http.d.ts +9 -6
  57. package/dist/browser/http.d.ts.map +1 -1
  58. package/dist/browser/socket-io.d.ts +12 -31
  59. package/dist/browser/socket-io.d.ts.map +1 -1
  60. package/dist/browser/stream.d.ts +5 -2
  61. package/dist/browser/stream.d.ts.map +1 -1
  62. package/dist/browser/transport.d.ts +3 -0
  63. package/dist/browser/transport.d.ts.map +1 -0
  64. package/dist/cli.d.ts +6 -6
  65. package/dist/cli.js +7 -7
  66. package/dist/contract/define.d.ts +34 -2
  67. package/dist/contract/define.d.ts.map +1 -1
  68. package/dist/contract/errors-factory.d.ts +1 -1
  69. package/dist/contract/errors.d.ts +4 -0
  70. package/dist/contract/errors.d.ts.map +1 -1
  71. package/dist/contract/factory.d.ts +1 -1
  72. package/dist/contract/index.d.ts +7 -6
  73. package/dist/contract/index.d.ts.map +1 -1
  74. package/dist/contract/index.js +5 -1
  75. package/dist/contract/stream.d.ts +19 -0
  76. package/dist/contract/stream.d.ts.map +1 -0
  77. package/dist/files/boundary.d.ts +1 -1
  78. package/dist/files.d.ts +2 -2
  79. package/dist/{index-xxye8j3k.js → index-0w9abg87.js} +4 -0
  80. package/dist/{index-svqhcrrj.js → index-2ve29dzn.js} +159 -13
  81. package/dist/index-69m2278y.js +115 -0
  82. package/dist/{index-physbf4z.js → index-6wzr93cg.js} +1 -1
  83. package/dist/index-7etq650s.js +75 -0
  84. package/dist/index-9ky9hhg3.js +484 -0
  85. package/dist/{index-413xk7ga.js → index-cq9q73nf.js} +50 -1
  86. package/dist/{index-1pgeyyee.js → index-cszjsxy5.js} +25 -88
  87. package/dist/{index-wrhf06ak.js → index-cz32amcb.js} +8 -8
  88. package/dist/{index-6taryy00.js → index-dafax5md.js} +1 -1
  89. package/dist/index-g2j2m6vv.js +63 -0
  90. package/dist/{index-8mxadm34.js → index-nck3yx3y.js} +1102 -22
  91. package/dist/{index-y91zd0ch.js → index-pr0qsmjy.js} +3 -2
  92. package/dist/index-v5bayx1z.js +138 -0
  93. package/dist/{index-mfw1pec7.js → index-wqyrvhzz.js} +3 -3
  94. package/dist/{index-x8v8b7rc.js → index-zpyj7hsv.js} +330 -58
  95. package/dist/index.d.ts +10 -10
  96. package/dist/index.js +274 -109
  97. package/dist/internal/bounded-lines.d.ts +4 -0
  98. package/dist/internal/bounded-lines.d.ts.map +1 -0
  99. package/dist/internal/errors.d.ts +1 -1
  100. package/dist/internal/observability-sink.d.ts +1 -1
  101. package/dist/node.d.ts +11 -10
  102. package/dist/node.d.ts.map +1 -1
  103. package/dist/node.js +11 -8
  104. package/dist/observability/audit.d.ts +5 -5
  105. package/dist/observability/context.d.ts +2 -2
  106. package/dist/observability/event.d.ts +2 -2
  107. package/dist/observability/index.d.ts +6 -6
  108. package/dist/observability/index.js +6 -7
  109. package/dist/react/entity-cache.d.ts +26 -1
  110. package/dist/react/entity-cache.d.ts.map +1 -1
  111. package/dist/react.d.ts +3 -3
  112. package/dist/react.d.ts.map +1 -1
  113. package/dist/react.js +136 -38
  114. package/dist/realtime/contract.d.ts +1 -1
  115. package/dist/realtime/index.d.ts +4 -4
  116. package/dist/realtime/rejection.d.ts +1 -1
  117. package/dist/realtime/request.d.ts +1 -1
  118. package/dist/realtime/socket.d.ts +2 -2
  119. package/dist/remote.d.ts +1 -1
  120. package/dist/remote.js +5 -6
  121. package/dist/server/bun.d.ts +3 -3
  122. package/dist/server/context-contribution.d.ts +1 -1
  123. package/dist/server/context.d.ts +4 -4
  124. package/dist/server/contract-stream.d.ts +5 -0
  125. package/dist/server/contract-stream.d.ts.map +1 -0
  126. package/dist/server/create.d.ts +1 -1
  127. package/dist/server/create.d.ts.map +1 -1
  128. package/dist/server/error-hook.d.ts +3 -3
  129. package/dist/server/file.d.ts +1 -1
  130. package/dist/server/implement.d.ts +2 -2
  131. package/dist/server/implement.d.ts.map +1 -1
  132. package/dist/server/index.d.ts +31 -30
  133. package/dist/server/index.d.ts.map +1 -1
  134. package/dist/server/index.js +44 -286
  135. package/dist/server/lifecycle.d.ts +1 -1
  136. package/dist/server/logging.d.ts +1 -1
  137. package/dist/server/middleware/auth.d.ts +2 -2
  138. package/dist/server/multipart.d.ts +2 -2
  139. package/dist/server/node.d.ts +2 -2
  140. package/dist/server/openapi.d.ts +1 -1
  141. package/dist/server/openapi.d.ts.map +1 -1
  142. package/dist/server/process-signal-common.d.ts +1 -1
  143. package/dist/server/process-signals.d.ts +1 -1
  144. package/dist/server/realtime.d.ts +4 -4
  145. package/dist/server/response-metadata.d.ts +1 -1
  146. package/dist/server/router.d.ts +1 -1
  147. package/dist/server/shutdown.d.ts +1 -1
  148. package/dist/server/socket-io-node.d.ts +3 -3
  149. package/dist/server/socket-io.d.ts +6 -6
  150. package/dist/server/stream.d.ts +3 -1
  151. package/dist/server/stream.d.ts.map +1 -1
  152. package/dist/server/streaming-route.d.ts +4 -2
  153. package/dist/server/streaming-route.d.ts.map +1 -1
  154. package/dist/server/types.d.ts +18 -8
  155. package/dist/server/types.d.ts.map +1 -1
  156. package/dist/server/unix-client-body.d.ts +4 -0
  157. package/dist/server/unix-client-body.d.ts.map +1 -0
  158. package/dist/server/unix-client-bun.d.ts +13 -0
  159. package/dist/server/unix-client-bun.d.ts.map +1 -0
  160. package/dist/server/unix-client-error.d.ts +9 -0
  161. package/dist/server/unix-client-error.d.ts.map +1 -0
  162. package/dist/server/unix-client.d.ts +25 -0
  163. package/dist/server/unix-client.d.ts.map +1 -0
  164. package/dist/testing/agent-store-conformance.d.ts +1 -1
  165. package/dist/testing/managed-resource-conformance-contract.d.ts +1 -1
  166. package/dist/testing/managed-resource-conformance-driver.d.ts +2 -2
  167. package/dist/testing/managed-resource-conformance-scenarios.d.ts +2 -2
  168. package/dist/testing/managed-resource-conformance.d.ts +2 -2
  169. package/dist/testing/surface-conformance.d.ts +3 -3
  170. package/dist/testing/surface-manifest.d.ts +5 -5
  171. package/dist/testing.d.ts +8 -8
  172. package/dist/testing.js +6 -5
  173. package/dist/tool-invoker.d.ts +9 -0
  174. package/dist/tool-invoker.d.ts.map +1 -0
  175. package/dist/tool-invoker.js +16 -0
  176. package/dist/tools/agent.d.ts +4 -4
  177. package/dist/tools/async-operation.d.ts +3 -3
  178. package/dist/tools/cli-command.d.ts +3 -3
  179. package/dist/tools/cli-format.d.ts +1 -1
  180. package/dist/tools/cli-policy.d.ts +1 -1
  181. package/dist/tools/cli-wait.d.ts +1 -1
  182. package/dist/tools/cli.d.ts +7 -7
  183. package/dist/tools/define-download-tool.d.ts +4 -4
  184. package/dist/tools/define-upload-tool.d.ts +3 -3
  185. package/dist/tools/define-view-file-tool.d.ts +3 -3
  186. package/dist/tools/define-wait-tool.d.ts +2 -2
  187. package/dist/tools/download-core.d.ts +2 -2
  188. package/dist/tools/execute.d.ts +2 -2
  189. package/dist/tools/flatten-join.d.ts +1 -1
  190. package/dist/tools/internal/surface-projector.d.ts +3 -3
  191. package/dist/tools/invoker.d.ts +4 -4
  192. package/dist/tools/lifecycle.d.ts +1 -1
  193. package/dist/tools/list-names.d.ts +2 -2
  194. package/dist/tools/managed-file-error.d.ts +1 -1
  195. package/dist/tools/manifest.d.ts +3 -3
  196. package/dist/tools/mcp-handler.d.ts +4 -4
  197. package/dist/tools/mcp-prepare.d.ts +8 -8
  198. package/dist/tools/mcp-round-policy.d.ts +1 -1
  199. package/dist/tools/mcp-round.d.ts +3 -3
  200. package/dist/tools/mcp-stdio-signals.d.ts +2 -2
  201. package/dist/tools/mcp-stdio.d.ts +3 -3
  202. package/dist/tools/mcp.d.ts +7 -7
  203. package/dist/tools/mount-download.d.ts +1 -1
  204. package/dist/tools/mount-upload.d.ts +1 -1
  205. package/dist/tools/mount.d.ts +5 -5
  206. package/dist/tools/native-definition.d.ts +2 -2
  207. package/dist/tools/native-mcp.d.ts +3 -3
  208. package/dist/tools/oauth-metadata.d.ts +1 -1
  209. package/dist/tools/oauth-provider.d.ts +1 -1
  210. package/dist/tools/presentation.d.ts +1 -1
  211. package/dist/tools/remote.d.ts +3 -3
  212. package/dist/tools/runtime-tool.d.ts +2 -2
  213. package/dist/tools/surface.d.ts +5 -5
  214. package/dist/tools/tool-logger.d.ts +1 -1
  215. package/dist/tools/toolkit.d.ts +7 -7
  216. package/dist/tools/transports.d.ts +2 -2
  217. package/dist/tools/upload-core.d.ts +1 -1
  218. package/dist/tools/view-file.d.ts +1 -1
  219. package/dist/tools.d.ts +42 -42
  220. package/dist/tools.js +27 -72
  221. package/llms-full.txt +506 -35
  222. package/package.json +8 -4
  223. package/dist/index-48ffdxgk.js +0 -6
  224. package/dist/index-pzyt11ch.js +0 -127
  225. package/dist/index-tvwcrx2d.js +0 -224
  226. package/dist/index-wd8g8z6e.js +0 -206
@@ -1,31 +1,32 @@
1
- export { AppError, appError, badRequest, conflict, forbidden, isStitchErrorCode, notFound, rateLimited, STITCH_ERROR_STATUS, type StitchErrorCode, unauthorized, } from '../contract';
2
- export { errorCode, formatZodError, normalizeError, type ZodIssueSummary, zodIssues, } from '../internal/errors';
3
- export { isWithinDir } from '../internal/within-dir';
4
- export { type BunFetchComposition as FetchComposition, type BunFetchHandler as FetchHandler, type BunHandlerConfig as HandlerConfig, type BunRawRoute as RawRoute, type BunRawRouteContext as RawRouteContext, type BunServer, type BunServerConfig, type BunServerHandle, createServer, type ServerPassthrough, type UnixListenConfig, } from './bun';
5
- export { type CacheOptions, cacheHeaders, createCache } from './cache';
6
- export { createHandler } from './create';
7
- export { createErrorHook, type ErrorHookConfig, type ResolvedError, } from './error-hook';
8
- export { createEventBus, type DefaultEventMap, type EventBus, type EventBusOptions, type EventHandler, } from './event-bus';
9
- export { type ByteRange, parseByteRange, type ServeFileOptions, serveFile, staticRoute, weakETag, } from './file';
10
- export { createImplement, createImplementRegistry, createMultipartStream, createScopedImplement, createScopedImplementRegistry, defineMultipartStream, type ExactRegistryHandlers, type ExactScopedRegistryHandlers, type ImplementationRegistry, implement, implementRegistry, type KeyedServices, type MultipartStreamConfig, type RegistryHandlers, type ScopedImplementationRegistry, type ScopedRegistryHandlers, type StreamScope, } from './implement';
11
- export { composeLifecycleHooks } from './lifecycle';
12
- export type { LogFormat } from './logger';
13
- export { type AuthHook, type AuthHookConfig, type AuthRule, type AuthRuleContribution, type AuthRules, type AuthScopes, type BearerResolverConfig, type ComposeAuthHooksConfig, type ComposedAuthScopes, composeAuthHooks, createAuthHook, createBearerResolver, extractToken, type JwtPayload, type RuleScopes, type ScopedAuthHook, type ScopedAuthRule, type SignJwtOptions, signJwt, type VerifyJwtOptions, verifyJwt, } from './middleware/auth';
14
- export { type CookieDef, type CookieOptions, defineCookie, parseCookies, serializeCookie, } from './middleware/cookies';
15
- export { type CorsConfig, corsHeaders, corsPreflightResponse, DEFAULT_CORS_ALLOW_HEADERS, DEFAULT_CORS_EXPOSE_HEADERS, } from './middleware/cors';
16
- export { deriveCodeChallenge, type PkceMethod, verifyPkce } from './middleware/pkce';
17
- export { type MultipartLifecycle, type MultipartResult, parseMultipart } from './multipart';
18
- export { generateOpenApiDocument, type OpenApiConfig, type OpenApiDocument, type OpenApiInfo, type OpenApiServer, openApiRoute, } from './openapi';
19
- export { bindProcessSignals, type ProcessSignalName, type ProcessSignalsBinding, type ProcessSignalsErrorPhase, type ProcessSignalsOptions, type ShutdownTarget, type SignalSource, } from './process-signals';
20
- export { createRateLimiter, type RateLimitConfig } from './rate-limit';
21
- export { errorResponse, parseBody, respondJson } from './raw';
22
- export { bindRealtimeServer, type RealtimeServer, type RealtimeServerConnection, type RealtimeServerHandle, } from './realtime';
23
- export { type ClientIpOptions, extractIp, generateTraceId, getClientInfo, resolveSocketIp, resolveTraceId, } from './request';
24
- export { type ManagedServerHandle, type ShutdownOptions, ShutdownOptionsSchema, type ShutdownResult, ShutdownResultSchema, type ShutdownState, ShutdownStateSchema, type ShutdownStatus, ShutdownStatusSchema, } from './shutdown';
25
- export type { SocketIOHandshakeConfig, SocketIOPeerLoaders, SocketIORequestPolicy, SocketIOServerConfig, SocketIOServerHandle, SocketIOServerLifecycle, } from './socket-io';
26
- export { createSocketIOServer, socketIoLane } from './socket-io';
27
- export { type ParseSSEOptions, parseSSE, streamSSE } from './stream';
28
- export { DEFAULT_STREAM_HEARTBEAT_MS, ndjsonRoute, type StreamingFormat, type StreamingRouteOptions, type StreamingSourceContext, sseRoute, streamingRoute, } from './streaming-route';
29
- export type { AuthorizationContext, EffectiveScope, EndpointHandlerContext, Handlers, LifecycleHooks, LoggingConfig, LogOutcome, MethodDef, MultipartFileMetadata, MultipartReceiver, MultipartReceiverResult, OperationIdentity, RouteGroup, ScopeContexts, ScopedHandlers, ServiceDef, StitchLogger, StreamingMultipartImplementation, } from './types';
30
- export { type ComposedLane, composeWebSocketHandlers, type WebSocketComposeConfig, type WebSocketLane, webSocketLane, } from './websocket';
1
+ export { AppError, appError, badRequest, conflict, forbidden, isStitchErrorCode, notFound, rateLimited, STITCH_ERROR_STATUS, type StitchErrorCode, unauthorized, } from '../contract/index.js';
2
+ export { errorCode, formatZodError, normalizeError, type ZodIssueSummary, zodIssues, } from '../internal/errors.js';
3
+ export { isWithinDir } from '../internal/within-dir.js';
4
+ export { type BunFetchComposition as FetchComposition, type BunFetchHandler as FetchHandler, type BunHandlerConfig as HandlerConfig, type BunRawRoute as RawRoute, type BunRawRouteContext as RawRouteContext, type BunServer, type BunServerConfig, type BunServerHandle, createServer, type ServerPassthrough, type UnixListenConfig, } from './bun.js';
5
+ export { type CacheOptions, cacheHeaders, createCache } from './cache.js';
6
+ export { createHandler } from './create.js';
7
+ export { createErrorHook, type ErrorHookConfig, type ResolvedError, } from './error-hook.js';
8
+ export { createEventBus, type DefaultEventMap, type EventBus, type EventBusOptions, type EventHandler, } from './event-bus.js';
9
+ export { type ByteRange, parseByteRange, type ServeFileOptions, serveFile, staticRoute, weakETag, } from './file.js';
10
+ export { createImplement, createImplementRegistry, createMultipartStream, createScopedImplement, createScopedImplementRegistry, defineMultipartStream, type ExactRegistryHandlers, type ExactScopedRegistryHandlers, type ImplementationRegistry, implement, implementRegistry, type KeyedServices, type MultipartStreamConfig, type RegistryHandlers, type ScopedImplementationRegistry, type ScopedRegistryHandlers, type StreamScope, } from './implement.js';
11
+ export { composeLifecycleHooks } from './lifecycle.js';
12
+ export type { LogFormat } from './logger.js';
13
+ export { type AuthHook, type AuthHookConfig, type AuthRule, type AuthRuleContribution, type AuthRules, type AuthScopes, type BearerResolverConfig, type ComposeAuthHooksConfig, type ComposedAuthScopes, composeAuthHooks, createAuthHook, createBearerResolver, extractToken, type JwtPayload, type RuleScopes, type ScopedAuthHook, type ScopedAuthRule, type SignJwtOptions, signJwt, type VerifyJwtOptions, verifyJwt, } from './middleware/auth.js';
14
+ export { type CookieDef, type CookieOptions, defineCookie, parseCookies, serializeCookie, } from './middleware/cookies.js';
15
+ export { type CorsConfig, corsHeaders, corsPreflightResponse, DEFAULT_CORS_ALLOW_HEADERS, DEFAULT_CORS_EXPOSE_HEADERS, } from './middleware/cors.js';
16
+ export { deriveCodeChallenge, type PkceMethod, verifyPkce } from './middleware/pkce.js';
17
+ export { type MultipartLifecycle, type MultipartResult, parseMultipart } from './multipart.js';
18
+ export { generateOpenApiDocument, type OpenApiConfig, type OpenApiDocument, type OpenApiInfo, type OpenApiServer, openApiRoute, } from './openapi.js';
19
+ export { bindProcessSignals, type ProcessSignalName, type ProcessSignalsBinding, type ProcessSignalsErrorPhase, type ProcessSignalsOptions, type ShutdownTarget, type SignalSource, } from './process-signals.js';
20
+ export { createRateLimiter, type RateLimitConfig } from './rate-limit.js';
21
+ export { errorResponse, parseBody, respondJson } from './raw.js';
22
+ export { bindRealtimeServer, type RealtimeServer, type RealtimeServerConnection, type RealtimeServerHandle, } from './realtime.js';
23
+ export { type ClientIpOptions, extractIp, generateTraceId, getClientInfo, resolveSocketIp, resolveTraceId, } from './request.js';
24
+ export { type ManagedServerHandle, type ShutdownOptions, ShutdownOptionsSchema, type ShutdownResult, ShutdownResultSchema, type ShutdownState, ShutdownStateSchema, type ShutdownStatus, ShutdownStatusSchema, } from './shutdown.js';
25
+ export type { SocketIOHandshakeConfig, SocketIOPeerLoaders, SocketIORequestPolicy, SocketIOServerConfig, SocketIOServerHandle, SocketIOServerLifecycle, } from './socket-io.js';
26
+ export { createSocketIOServer, socketIoLane } from './socket-io.js';
27
+ export { type ParseSSEOptions, parseSSE, streamSSE } from './stream.js';
28
+ export { DEFAULT_STREAM_HEARTBEAT_MS, ndjsonRoute, type StreamingFormat, type StreamingRouteOptions, type StreamingSourceContext, sseRoute, streamingRoute, } from './streaming-route.js';
29
+ export type { AuthorizationContext, EffectiveScope, EndpointHandlerContext, Handlers, LifecycleHooks, LoggingConfig, LogOutcome, MethodDef, MultipartFileMetadata, MultipartReceiver, MultipartReceiverResult, OperationIdentity, RouteGroup, ScopeContexts, ScopedHandlers, ServiceDef, StitchLogger, StreamingMultipartImplementation, } from './types.js';
30
+ export { createUnixClientTransport, type UnixClientDeliveryState, type UnixClientTransport, type UnixClientTransportConfig, UnixClientTransportError, type UnixClientTransportErrorCode, } from './unix-client.js';
31
+ export { type ComposedLane, composeWebSocketHandlers, type WebSocketComposeConfig, type WebSocketLane, webSocketLane, } from './websocket.js';
31
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,KAAK,mBAAmB,IAAI,gBAAgB,EAC5C,KAAK,eAAe,IAAI,YAAY,EACpC,KAAK,gBAAgB,IAAI,aAAa,EACtC,KAAK,WAAW,IAAI,QAAQ,EAC5B,KAAK,kBAAkB,IAAI,eAAe,EAC1C,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,SAAS,EACd,cAAc,EACd,KAAK,gBAAgB,EACrB,SAAS,EACT,WAAW,EACX,QAAQ,GACT,MAAM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GACf,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,YAAY,EACZ,gCAAgC,GACjC,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,YAAY,EACjB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,aAAa,GACd,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,KAAK,mBAAmB,IAAI,gBAAgB,EAC5C,KAAK,eAAe,IAAI,YAAY,EACpC,KAAK,gBAAgB,IAAI,aAAa,EACtC,KAAK,WAAW,IAAI,QAAQ,EAC5B,KAAK,kBAAkB,IAAI,eAAe,EAC1C,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACz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B,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EACL,2BAA2B,EAC3B,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,QAAQ,EACR,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,YAAY,EACZ,gCAAgC,GACjC,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,yBAAyB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,wBAAwB,EACxB,KAAK,4BAA4B,GAClC,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,YAAY,EACjB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,aAAa,GACd,MAAM,aAAa,CAAC"}
@@ -1,13 +1,19 @@
1
1
  import {
2
+ DEFAULT_STREAM_HEARTBEAT_MS,
3
+ UnixClientTransportError,
2
4
  bindProcessSignals,
3
5
  bindRealtimeServer,
4
6
  composeWebSocketHandlers,
5
7
  createHandler,
6
8
  createSocketIOServer,
9
+ createUnixClientTransport,
10
+ ndjsonRoute,
7
11
  parseMultipart,
8
12
  socketIoLane,
13
+ sseRoute,
14
+ streamingRoute,
9
15
  webSocketLane
10
- } from "../index-8mxadm34.js";
16
+ } from "../index-nck3yx3y.js";
11
17
  import {
12
18
  composeAuthHooks,
13
19
  createAuthHook,
@@ -20,7 +26,7 @@ import {
20
26
  signJwt,
21
27
  verifyJwt,
22
28
  verifyPkce
23
- } from "../index-mfw1pec7.js";
29
+ } from "../index-wqyrvhzz.js";
24
30
  import {
25
31
  DEFAULT_CORS_ALLOW_HEADERS,
26
32
  DEFAULT_CORS_EXPOSE_HEADERS,
@@ -34,7 +40,15 @@ import {
34
40
  defineMultipartStream,
35
41
  implement,
36
42
  implementRegistry
37
- } from "../index-y91zd0ch.js";
43
+ } from "../index-pr0qsmjy.js";
44
+ import {
45
+ extractIp,
46
+ generateTraceId,
47
+ getClientInfo,
48
+ getTraceId,
49
+ resolveSocketIp,
50
+ resolveTraceId
51
+ } from "../index-69m2278y.js";
38
52
  import {
39
53
  isWithinDir,
40
54
  realPathWithinDir
@@ -52,26 +66,19 @@ import {
52
66
  toJsonSchema
53
67
  } from "../index-cby4ar3v.js";
54
68
  import {
55
- inputIsQuery
56
- } from "../index-48ffdxgk.js";
69
+ inputIsQuery,
70
+ parseSSE,
71
+ streamSSE
72
+ } from "../index-v5bayx1z.js";
57
73
  import {
74
+ DEFAULT_CONTRACT_STREAM_FRAME_BYTES,
58
75
  errorCode,
59
- extractIp,
60
76
  formatZodError,
61
- generateTraceId,
62
- getClientInfo,
63
- getTraceId,
77
+ joinRoutePath,
64
78
  normalizeError,
65
- resolveSocketIp,
66
- resolveTraceId,
79
+ parseTrailingWildcard,
67
80
  zodIssues
68
- } from "../index-tvwcrx2d.js";
69
- import"../index-wd8g8z6e.js";
70
- import"../index-6k1937bx.js";
71
- import {
72
- joinRoutePath,
73
- parseTrailingWildcard
74
- } from "../index-pzyt11ch.js";
81
+ } from "../index-9ky9hhg3.js";
75
82
  import {
76
83
  isRecord
77
84
  } from "../index-smpbdg6k.js";
@@ -86,7 +93,8 @@ import {
86
93
  notFound,
87
94
  rateLimited,
88
95
  unauthorized
89
- } from "../index-xxye8j3k.js";
96
+ } from "../index-0w9abg87.js";
97
+ import"../index-6k1937bx.js";
90
98
  // src/server/bun.ts
91
99
  import { chmodSync, statSync, unlinkSync } from "node:fs";
92
100
  function reclaimStaleUnixSocket(path) {
@@ -782,6 +790,19 @@ function generateOpenApiDocument(config) {
782
790
  }
783
791
  }
784
792
  };
793
+ } else if (method.stream) {
794
+ const mediaType = method.stream.format === "sse" ? "text/event-stream" : "application/x-ndjson";
795
+ responses["200"] = {
796
+ description: "Validated streaming response",
797
+ content: {
798
+ [mediaType]: {
799
+ schema: { type: "string" },
800
+ "x-stitchkit-item-schema": safeJson(method.stream.item, "output"),
801
+ "x-stitchkit-max-frame-bytes": method.stream.maxFrameBytes ?? DEFAULT_CONTRACT_STREAM_FRAME_BYTES,
802
+ "x-stitchkit-terminal-required": Boolean(method.stream.terminal)
803
+ }
804
+ }
805
+ };
785
806
  } else if (method.outputSchema) {
786
807
  responses[String(method.responseMeta?.status ?? 200)] = {
787
808
  description: "Success",
@@ -795,7 +816,8 @@ function generateOpenApiDocument(config) {
795
816
  operationId: `${service.name}_${key}`,
796
817
  "x-stitchkit-scope": method.scope,
797
818
  "x-stitchkit-has-input": Boolean(method.inputSchema),
798
- "x-stitchkit-has-output": Boolean(method.outputSchema),
819
+ "x-stitchkit-has-output": Boolean(method.outputSchema || method.stream),
820
+ ...method.stream && { "x-stitchkit-stream": true },
799
821
  ...parameters.length > 0 && { parameters },
800
822
  responses
801
823
  };
@@ -942,272 +964,6 @@ async function parseBody(req, schema) {
942
964
  const parsed = schema.safeParse(raw);
943
965
  return parsed.success ? parsed.data : null;
944
966
  }
945
- // src/server/stream.ts
946
- function streamSSE(generator) {
947
- const encoder = new TextEncoder;
948
- let cancelled = false;
949
- const stream = new ReadableStream({
950
- async start(controller) {
951
- try {
952
- for await (const chunk of generator) {
953
- if (cancelled)
954
- return;
955
- const data = JSON.stringify(chunk);
956
- controller.enqueue(encoder.encode(`data: ${data}
957
-
958
- `));
959
- }
960
- if (cancelled)
961
- return;
962
- controller.enqueue(encoder.encode(`data: [DONE]
963
-
964
- `));
965
- controller.close();
966
- } catch (err) {
967
- if (cancelled)
968
- return;
969
- const envelope = normalizeError(err).toJSON();
970
- controller.enqueue(encoder.encode(`data: ${JSON.stringify(envelope)}
971
-
972
- `));
973
- controller.close();
974
- }
975
- },
976
- cancel() {
977
- cancelled = true;
978
- generator.return(undefined).catch(() => {
979
- return;
980
- });
981
- }
982
- });
983
- return new Response(stream, {
984
- headers: {
985
- "Content-Type": "text/event-stream",
986
- "Cache-Control": "no-cache",
987
- Connection: "keep-alive"
988
- }
989
- });
990
- }
991
- async function* parseSSE(response, options) {
992
- const reader = response.body?.getReader();
993
- if (!reader)
994
- return;
995
- const decoder = new TextDecoder;
996
- let buffer = "";
997
- try {
998
- while (true) {
999
- const { done, value } = await reader.read();
1000
- if (done)
1001
- break;
1002
- buffer += decoder.decode(value, { stream: true });
1003
- const lines = buffer.split(`
1004
- `);
1005
- buffer = lines.pop() ?? "";
1006
- for (const rawLine of lines) {
1007
- const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
1008
- if (!line.startsWith("data:"))
1009
- continue;
1010
- const data = line.slice(5).replace(/^ /, "");
1011
- if (data === "[DONE]")
1012
- return;
1013
- try {
1014
- yield JSON.parse(data);
1015
- } catch (err) {
1016
- options?.onParseError?.(data, err instanceof Error ? err : new Error(String(err)));
1017
- }
1018
- }
1019
- }
1020
- } finally {
1021
- reader.releaseLock();
1022
- }
1023
- }
1024
- // src/server/streaming-route.ts
1025
- var DEFAULT_STREAM_HEARTBEAT_MS = 5000;
1026
- var FRAMINGS = {
1027
- ndjson: {
1028
- contentType: "application/x-ndjson",
1029
- keepAlive: `
1030
- `,
1031
- frame: (value) => `${JSON.stringify(value)}
1032
- `
1033
- },
1034
- sse: {
1035
- contentType: "text/event-stream",
1036
- keepAlive: `: keep-alive
1037
-
1038
- `,
1039
- frame: (value) => `data: ${JSON.stringify(value)}
1040
-
1041
- `,
1042
- done: `data: [DONE]
1043
-
1044
- `
1045
- }
1046
- };
1047
- function applyIdleTimeout(server, request, seconds) {
1048
- if (typeof server !== "object" || server === null)
1049
- return;
1050
- const timeout = Reflect.get(server, "timeout");
1051
- if (typeof timeout !== "function")
1052
- return;
1053
- try {
1054
- Reflect.apply(timeout, server, [request, seconds]);
1055
- } catch {}
1056
- }
1057
- function unrefTimer(timer) {
1058
- if (typeof timer !== "object" || timer === null)
1059
- return;
1060
- const unref = Reflect.get(timer, "unref");
1061
- if (typeof unref === "function")
1062
- Reflect.apply(unref, timer, []);
1063
- }
1064
- var MAX_BUFFERED_FRAMES = 16;
1065
- function responseHeaders(framing, extra) {
1066
- const headers = new Headers(extra);
1067
- headers.set("Content-Type", framing.contentType);
1068
- headers.set("Cache-Control", "no-cache");
1069
- headers.set("Connection", "keep-alive");
1070
- headers.set("X-Accel-Buffering", "no");
1071
- return headers;
1072
- }
1073
- function streamingRoute(options) {
1074
- const heartbeatMs = options.heartbeatMs ?? DEFAULT_STREAM_HEARTBEAT_MS;
1075
- if (!Number.isFinite(heartbeatMs) || heartbeatMs <= 0) {
1076
- throw new TypeError("heartbeatMs must be a finite positive number of milliseconds");
1077
- }
1078
- const idleTimeoutSeconds = options.idleTimeoutSeconds ?? 0;
1079
- if (!Number.isInteger(idleTimeoutSeconds) || idleTimeoutSeconds < 0) {
1080
- throw new TypeError("idleTimeoutSeconds must be a non-negative integer");
1081
- }
1082
- const framing = FRAMINGS[options.format ?? "ndjson"];
1083
- return {
1084
- method: options.method ?? "GET",
1085
- path: options.path,
1086
- handler: async (request, context) => {
1087
- applyIdleTimeout(context.server, request, idleTimeoutSeconds);
1088
- const departed = new AbortController;
1089
- const iterable = await options.source(request, { ...context, signal: departed.signal });
1090
- const iterator = iterable[Symbol.asyncIterator]();
1091
- const encoder = new TextEncoder;
1092
- let heartbeat = null;
1093
- let closed = false;
1094
- const stopHeartbeat = () => {
1095
- if (heartbeat === null)
1096
- return;
1097
- clearInterval(heartbeat);
1098
- heartbeat = null;
1099
- };
1100
- const release = () => {
1101
- if (closed)
1102
- return;
1103
- closed = true;
1104
- try {
1105
- stopHeartbeat();
1106
- signalDemand();
1107
- departed.abort();
1108
- Promise.resolve(iterator.return?.(undefined)).catch(() => {
1109
- return;
1110
- });
1111
- } catch {}
1112
- };
1113
- let demand = null;
1114
- const signalDemand = () => {
1115
- const resolve2 = demand;
1116
- demand = null;
1117
- resolve2?.();
1118
- };
1119
- const stream = new ReadableStream({
1120
- start(controller) {
1121
- const send = (text) => {
1122
- if (closed)
1123
- return false;
1124
- try {
1125
- controller.enqueue(encoder.encode(text));
1126
- return true;
1127
- } catch {
1128
- release();
1129
- return false;
1130
- }
1131
- };
1132
- const finish = () => {
1133
- try {
1134
- controller.close();
1135
- } catch {}
1136
- };
1137
- if (request.signal.aborted) {
1138
- release();
1139
- finish();
1140
- return;
1141
- }
1142
- request.signal.addEventListener("abort", () => {
1143
- release();
1144
- finish();
1145
- });
1146
- send(framing.keepAlive);
1147
- heartbeat = setInterval(() => {
1148
- if ((controller.desiredSize ?? 1) > 0)
1149
- send(framing.keepAlive);
1150
- }, heartbeatMs);
1151
- unrefTimer(heartbeat);
1152
- const awaitDemand = async () => {
1153
- while (!closed && (controller.desiredSize ?? 1) <= 0) {
1154
- await new Promise((resolve2) => {
1155
- demand = resolve2;
1156
- });
1157
- }
1158
- };
1159
- let sinceYield = 0;
1160
- (async () => {
1161
- try {
1162
- for (;; ) {
1163
- await awaitDemand();
1164
- if (closed)
1165
- return;
1166
- const next = await iterator.next();
1167
- if (closed)
1168
- return;
1169
- if (next.done)
1170
- break;
1171
- if (!send(framing.frame(next.value)))
1172
- return;
1173
- sinceYield += 1;
1174
- if (sinceYield >= MAX_BUFFERED_FRAMES) {
1175
- sinceYield = 0;
1176
- await new Promise((resolve2) => {
1177
- setTimeout(resolve2, 0);
1178
- });
1179
- if (closed)
1180
- return;
1181
- }
1182
- }
1183
- if (framing.done)
1184
- send(framing.done);
1185
- } catch (error) {
1186
- if (!closed)
1187
- send(framing.frame(normalizeError(error).toJSON()));
1188
- } finally {
1189
- release();
1190
- finish();
1191
- }
1192
- })();
1193
- },
1194
- pull() {
1195
- signalDemand();
1196
- },
1197
- cancel() {
1198
- release();
1199
- }
1200
- }, { highWaterMark: MAX_BUFFERED_FRAMES });
1201
- return new Response(stream, { headers: responseHeaders(framing, options.headers) });
1202
- }
1203
- };
1204
- }
1205
- function ndjsonRoute(options) {
1206
- return streamingRoute({ ...options, format: "ndjson" });
1207
- }
1208
- function sseRoute(options) {
1209
- return streamingRoute({ ...options, format: "sse" });
1210
- }
1211
967
  export {
1212
968
  AppError,
1213
969
  DEFAULT_CORS_ALLOW_HEADERS,
@@ -1218,6 +974,7 @@ export {
1218
974
  ShutdownResultSchema,
1219
975
  ShutdownStateSchema,
1220
976
  ShutdownStatusSchema,
977
+ UnixClientTransportError,
1221
978
  appError,
1222
979
  badRequest,
1223
980
  bindProcessSignals,
@@ -1243,6 +1000,7 @@ export {
1243
1000
  createScopedImplementRegistry,
1244
1001
  createServer,
1245
1002
  createSocketIOServer,
1003
+ createUnixClientTransport,
1246
1004
  defineCookie,
1247
1005
  defineMultipartStream,
1248
1006
  deriveCodeChallenge,
@@ -1,4 +1,4 @@
1
- import type { LifecycleHooks } from './types';
1
+ import type { LifecycleHooks } from './types.js';
2
2
  /** Compose ordinary HTTP lifecycle hooks inside each existing phase slot. */
3
3
  export declare function composeLifecycleHooks(...hooks: readonly (LifecycleHooks | undefined)[]): LifecycleHooks;
4
4
  //# sourceMappingURL=lifecycle.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { LoggingConfig, LogOutcome } from './types';
1
+ import type { LoggingConfig, LogOutcome } from './types.js';
2
2
  /**
3
3
  * Normalise `logging` into either a config or `null` (off). `true` is shorthand
4
4
  * for `{}`: any object turns logging on, and `logger` decides which sink writes.
@@ -1,5 +1,5 @@
1
- import type { RuntimeContext } from '../../contract';
2
- import type { AuthorizationContext, OperationIdentity } from '../types';
1
+ import type { RuntimeContext } from '../../contract/index.js';
2
+ import type { AuthorizationContext, OperationIdentity } from '../types.js';
3
3
  export interface JwtPayload {
4
4
  [key: string]: unknown;
5
5
  }
@@ -1,5 +1,5 @@
1
- import type { MultipartDescriptor } from '../contract';
2
- import type { MultipartReceiver } from './types';
1
+ import type { MultipartDescriptor } from '../contract/index.js';
2
+ import type { MultipartReceiver } from './types.js';
3
3
  export interface MultipartLifecycle {
4
4
  rollback(): Promise<void>;
5
5
  }
@@ -1,7 +1,7 @@
1
1
  import type { Server as HttpServer } from 'node:http';
2
2
  import { serve } from 'srvx/node';
3
- import { type ManagedServerHandle } from './shutdown';
4
- import type { FetchComposition, HandlerConfig } from './types';
3
+ import { type ManagedServerHandle } from './shutdown.js';
4
+ import type { FetchComposition, HandlerConfig } from './types.js';
5
5
  export interface NodeSocketLifecycle {
6
6
  attach(server: HttpServer): void;
7
7
  beginShutdown(): void;
@@ -10,7 +10,7 @@
10
10
  * emits — not a divergent code path. Schemas are inlined (valid OpenAPI);
11
11
  * `$ref` de-duplication can come later if a spec grows unwieldy.
12
12
  */
13
- import type { MethodDef, RawRoute, ServiceDef } from './types';
13
+ import type { MethodDef, RawRoute, ServiceDef } from './types.js';
14
14
  export interface OpenApiInfo {
15
15
  title: string;
16
16
  version: string;
@@ -1 +1 @@
1
- {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../src/server/openapi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE/D,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,UAAU,EAAE,CA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,EAAE,CAAC;IACxB,iFAAiF;IACjF,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC,CAAC;IAChE,oCAAoC;IACpC,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,KAAK,OAAO,CAAC;CAC1D;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAChD;AA6DD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,aAAa,GAAG,eAAe,CA8L9E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,QAAQ,CAM9E"}
@@ -1,4 +1,4 @@
1
- import type { ProcessSignalName, SignalSource } from './process-signals';
1
+ import type { ProcessSignalName, SignalSource } from './process-signals.js';
2
2
  export declare const DEFAULT_PROCESS_SIGNALS: readonly ProcessSignalName[];
3
3
  export declare const defaultSignalSource: SignalSource;
4
4
  export declare function reportSignalError<TPhase extends string>(phase: TPhase, error: unknown, onError: ((phase: TPhase, error: unknown) => void) | undefined): void;
@@ -9,7 +9,7 @@
9
9
  * throws, and a third signal on a process whose default disposition the first
10
10
  * `process.on` already suppressed. → ADR 0076
11
11
  */
12
- import type { ShutdownOptions, ShutdownResult } from './shutdown';
12
+ import type { ShutdownOptions, ShutdownResult } from './shutdown.js';
13
13
  /**
14
14
  * Signal names this binding can listen for.
15
15
  *
@@ -1,8 +1,8 @@
1
1
  import type { DefaultEventsMap, Socket, Server as SocketIOServer } from 'socket.io';
2
- import type { SocketEventMap } from '../browser/socket-io';
3
- import type { StitchLogger } from '../logger';
4
- import type { RealtimeContract, RealtimeEventRegistry, RealtimeRejectedEventHook } from '../realtime/contract';
5
- import { type ValidatedRealtimeSocket } from '../realtime/socket';
2
+ import type { SocketEventMap } from '../browser/socket-io.js';
3
+ import type { StitchLogger } from '../logger.js';
4
+ import type { RealtimeContract, RealtimeEventRegistry, RealtimeRejectedEventHook } from '../realtime/contract.js';
5
+ import { type ValidatedRealtimeSocket } from '../realtime/socket.js';
6
6
  export interface RealtimeServerConnection<TServerToClient extends RealtimeEventRegistry, TClientToServer extends RealtimeEventRegistry, TData = any> {
7
7
  /**
8
8
  * Raw Socket.IO socket for rooms and application-owned delivery policy.
@@ -1,4 +1,4 @@
1
- import type { ResponseMetadata } from '../contract';
1
+ import type { ResponseMetadata } from '../contract/index.js';
2
2
  /** Create one isolated outbound collector for a response-metadata handler. */
3
3
  export declare function createResponseMetadata(): ResponseMetadata;
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { LifecycleHooks, MethodDef, RawRoute, ServiceDef } from './types';
1
+ import type { LifecycleHooks, MethodDef, RawRoute, ServiceDef } from './types.js';
2
2
  /** A service mounted under a path prefix, carrying optional group hooks. */
3
3
  export interface NormalizedGroup {
4
4
  prefix: string;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import type { FetchHandler } from './types';
2
+ import type { FetchHandler } from './types.js';
3
3
  export declare const ShutdownStateSchema: z.ZodEnum<{
4
4
  clean: "clean";
5
5
  "closing-realtime": "closing-realtime";
@@ -1,9 +1,9 @@
1
1
  /** Node-facing Socket.IO surface without Bun engine declarations. */
2
2
  import type { Server as HttpServer } from 'node:http';
3
3
  import type { DefaultEventsMap, Server as SocketIOServer } from 'socket.io';
4
- import type { SocketEventMap } from '../browser/socket-io';
5
- import type { SocketIOServerConfig } from './socket-io-config';
6
- export type { SocketIOHandshakeConfig, SocketIOPeerLoaders, SocketIORequestPolicy, SocketIOServerConfig, } from './socket-io-config';
4
+ import type { SocketEventMap } from '../browser/socket-io.js';
5
+ import type { SocketIOServerConfig } from './socket-io-config.js';
6
+ export type { SocketIOHandshakeConfig, SocketIOPeerLoaders, SocketIORequestPolicy, SocketIOServerConfig, } from './socket-io-config.js';
7
7
  /** The runtime-neutral part of a Socket.IO handle used by `serveNode`. */
8
8
  export interface NodeSocketIOServerHandle<TServerEvents extends SocketEventMap, TClientEvents extends SocketEventMap, TData = any> {
9
9
  io: SocketIOServer<TClientEvents, TServerEvents, DefaultEventsMap, TData>;
@@ -18,12 +18,12 @@
18
18
  import type { Server as HttpServer } from 'node:http';
19
19
  import type { Server as BunEngine } from '@socket.io/bun-engine';
20
20
  import type { DefaultEventsMap, Server as SocketIOServer } from 'socket.io';
21
- import type { SocketEventMap } from '../browser/socket-io';
22
- import type { BunServer } from './bun';
23
- import type { SocketIOServerConfig } from './socket-io-config';
24
- import type { RawRoute } from './types';
25
- import { type ComposedLane } from './websocket';
26
- export type { SocketIOHandshakeConfig, SocketIOPeerLoaders, SocketIORequestPolicy, SocketIOServerConfig, } from './socket-io-config';
21
+ import type { SocketEventMap } from '../browser/socket-io.js';
22
+ import type { BunServer } from './bun.js';
23
+ import type { SocketIOServerConfig } from './socket-io-config.js';
24
+ import type { RawRoute } from './types.js';
25
+ import { type ComposedLane } from './websocket.js';
26
+ export type { SocketIOHandshakeConfig, SocketIOPeerLoaders, SocketIORequestPolicy, SocketIOServerConfig, } from './socket-io-config.js';
27
27
  export interface SocketIOServerLifecycle {
28
28
  /**
29
29
  * WebSocket handler for `Bun.serve({ websocket })`. Real on Bun; on Node it is
@@ -8,7 +8,9 @@
8
8
  export declare function streamSSE(generator: AsyncGenerator<unknown>): Response;
9
9
  /** Options for `parseSSE`. */
10
10
  export interface ParseSSEOptions {
11
- /** Called for a `data:` line that is not valid JSON — the alternative to throwing. */
11
+ /** Maximum bytes retained for one SSE line. Default 1 MiB. */
12
+ maxLineBytes?: number;
13
+ /** Called for invalid UTF-8/JSON; without it parsing fails closed. */
12
14
  onParseError?: (raw: string, error: Error) => void;
13
15
  }
14
16
  /**