@jini-ai/http-kit 0.3.8 → 0.4.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 (60) hide show
  1. package/CHANGELOG.md +177 -0
  2. package/README.md +71 -98
  3. package/dist/adapter.d.ts +21 -6
  4. package/dist/adapter.js +47 -17
  5. package/dist/api-security-middleware.d.ts +27 -17
  6. package/dist/api-security-middleware.js +27 -36
  7. package/dist/compat.d.ts +12 -17
  8. package/dist/compat.js +4 -12
  9. package/dist/db-ops.d.ts +3 -3
  10. package/dist/db-ops.js +3 -3
  11. package/dist/delegated-tools.d.ts +9 -78
  12. package/dist/delegated-tools.js +27 -95
  13. package/dist/index.d.ts +21 -70
  14. package/dist/index.js +12 -32
  15. package/dist/local-daemon-request.d.ts +18 -8
  16. package/dist/local-daemon-request.js +23 -32
  17. package/dist/memory.d.ts +1 -1
  18. package/dist/middleware.d.ts +20 -0
  19. package/dist/middleware.js +21 -0
  20. package/dist/observability.d.ts +29 -0
  21. package/dist/observability.js +22 -0
  22. package/dist/origin.d.ts +8 -6
  23. package/dist/origin.js +8 -5
  24. package/dist/pack-http.d.ts +12 -8
  25. package/dist/pack-http.js +3 -3
  26. package/dist/rate-limit.d.ts +97 -0
  27. package/dist/rate-limit.js +94 -0
  28. package/dist/raw-sse.d.ts +7 -2
  29. package/dist/raw-sse.js +6 -7
  30. package/dist/read-only-tools.d.ts +67 -0
  31. package/dist/read-only-tools.js +59 -0
  32. package/dist/remote-run-events.js +1 -1
  33. package/dist/request.d.ts +8 -2
  34. package/dist/request.js +4 -4
  35. package/dist/response.d.ts +16 -4
  36. package/dist/response.js +7 -5
  37. package/dist/route-registration-guard.d.ts +13 -5
  38. package/dist/route-registration-guard.js +6 -6
  39. package/dist/sse.d.ts +25 -9
  40. package/dist/sse.js +10 -10
  41. package/dist/tool-catalog.d.ts +3 -3
  42. package/dist/types.d.ts +52 -15
  43. package/dist/types.js +2 -2
  44. package/dist/verified-origin/configured-origin.d.ts +37 -0
  45. package/dist/verified-origin/configured-origin.js +112 -0
  46. package/dist/verified-origin/index.d.ts +7 -0
  47. package/dist/verified-origin/index.js +6 -0
  48. package/dist/verified-origin/origin.d.ts +65 -0
  49. package/dist/verified-origin/origin.js +151 -0
  50. package/dist/verified-origin/ports.d.ts +40 -0
  51. package/dist/verified-origin/ports.js +2 -0
  52. package/dist/verified-origin/repo.memory.d.ts +34 -0
  53. package/dist/verified-origin/repo.memory.js +34 -0
  54. package/dist/verified-origin/site-path.d.ts +113 -0
  55. package/dist/verified-origin/site-path.js +179 -0
  56. package/dist/verified-origin/types.d.ts +33 -0
  57. package/dist/verified-origin/types.js +23 -0
  58. package/dist/verified-origin.d.ts +2 -0
  59. package/dist/verified-origin.js +2 -0
  60. package/package.json +52 -11
package/dist/index.d.ts CHANGED
@@ -1,26 +1,18 @@
1
1
  /**
2
2
  * @module @jini-ai/http-kit
3
- *
4
- * JSON-route transport for a `@jini-ai/core` daemon composition: the `Result`/route-spec types,
5
- * request parsing, response serialization, the same-origin guard, the Express-mounting Adapter,
6
- * legacy-shaped compat error helpers, a route-pack registrar, generic daemon status/shutdown
7
- * routes, and every route pack this package ships (runs, agents, host-tools, memory, routines,
8
- * db-ops, terminals, model-proxy, active-context, delegated-tools) — all exported flat at this
9
- * root, the load-bearing surface every consumer (including `@jini-ai/server`'s
10
- * `createLocalNodeDaemon`) imports from directly.
11
- *
12
- * This package supported a switchable `express`/`fastify` HTTP transport from 2026-07-19 through
13
- * 2026-07-22; it was removed since nothing ever consumed `transport: 'fastify'` in practice, and
14
- * the maintained-but-unused Fastify subtree cost a recurring "does this new route pack also need a
15
- * Fastify mounting sibling" tax on every future addition to this package. The removed
16
- * implementation is preserved, unchanged, on the `future/fastify-transport` branch — see
17
- * `FASTIFY-TRANSPORT-PARKED.md` at the repo root of that branch for the full reasoning and how to
18
- * revive it. See `source-map.md` for this package's full provenance and scope-decision notes.
3
+ * JSON-route transport: parsing/serialization, same-origin guards, Express mounting and pack
4
+ * registration. Capability-owned HTTP entries own domain route packs; core stays framework-free.
5
+ * pack-http.ts mounts the same composed app-services supplied to CLI, skipping packs without HTTP.
6
+ * Post-hoc external CLI tool events cannot serve as pre-execution authorization; a controlled
7
+ * agent protocol is required for that gate. Unknown API error codes default conservatively to 500.
8
+ * Hand-mounted legacy error helpers retain their public surface for patch-sync fidelity; response.ts
9
+ * owns sending. See the capability owners for raw-stream uploads, bodyless cleanup, attachment
10
+ * rejection mapping and host-owned claim/cleanup lifecycle rather than duplicating those rules here.
19
11
  */
20
- export type { Handler, HttpMethod, InputParser, JsonRouteSpec, Result, RouteInputContext, } from './types.js';
12
+ export type { Handler, HttpMethod, InputParser, JsonRouteSpec, JsonRoutePorts, JsonRouteAuthorize, Result, RouteInputContext, } from './types.js';
21
13
  export { err, ok } from './types.js';
22
- export type { ParsedHostHeader, RequestWithOriginHeaders, } from './origin-validation.js';
23
- export { allowedBrowserPorts, assertValidAllowedOrigins, configuredAllowedHosts, configuredAllowedOrigins, isAllowedBrowserHost, isAllowedBrowserOrigin, isIpLiteralHostname, isLoopbackOrPrivateLanHost, isLocalSameOrigin, isPrivateIpv4, parseHostHeader, } from './origin-validation.js';
14
+ export type { ParsedHostHeader, RequestWithOriginHeaders, } from '@jini-ai/core';
15
+ export { allowedBrowserPorts, assertValidAllowedOrigins, configuredAllowedHosts, configuredAllowedOrigins, isAllowedBrowserHost, isAllowedBrowserOrigin, isIpLiteralHostname, isLoopbackOrPrivateLanHost, isLocalSameOrigin, isPrivateIpv4, parseHostHeader, } from '@jini-ai/core';
24
16
  export type { AdapterContext } from './adapter.js';
25
17
  export { ClientFacingError, defineJsonRoute, mountJsonRoute } from './adapter.js';
26
18
  export type { InstallRouteRegistrationGuardOptions, RouteRegistration } from './route-registration-guard.js';
@@ -29,58 +21,17 @@ export type { CreateSseChannelOptions, SseChannel, SseEvent } from './sse.js';
29
21
  export { createSseChannel, DEFAULT_MAX_QUEUED_SSE_EVENTS, requestedAfterCursor, sendRawApiError } from './sse.js';
30
22
  export type { CreateSseResponseOptions, SseConnection } from './raw-sse.js';
31
23
  export { createSseResponse } from './raw-sse.js';
32
- export type { ResolveWorkspaceRootOptions, WorkspaceRootRequest, WorkspaceRootResolver, } from './workspace-root.js';
33
- export { denyAllWorkspaceRoots, resolveWorkspaceRoot, WorkspaceRootDeniedError } from './workspace-root.js';
34
24
  export { mountPackHttp } from './pack-http.js';
35
- export type { RunCancellationService } from './cancel-owned-runs.js';
36
- export { cancelRunsOwnedBy } from './cancel-owned-runs.js';
37
- export type { ActiveContextDeps, ActiveContextResource } from './active-context.js';
38
- export { ACTIVE_CONTEXT_TTL_MS, getActiveRoute, registerActiveContextRoutes, setActiveRoute, } from './active-context.js';
39
- export type { CatalogueEntry, HostEditor, HostEditorsResponse, HostToolLaunchPlan, HostToolProbeEnv, LaunchHostToolResult, Platform, RealPlatform, } from './host-tools.js';
40
- export { applicableForPlatform, CATALOGUE, currentPlatform, defaultProbeEnv, hostEditorsRoute, launchHostTool, listAvailableEditors, pathDirs, probeCommandOnPath, probeMacBundle, registerHostToolsRoutes, resolveEntry, resolveHostToolLaunchPlan, } from './host-tools.js';
41
25
  export type { ApiBearerAuthMiddlewareDeps, ApiOriginGuardMiddlewareDeps, StrictBearerTokenDeps, } from './api-security-middleware.js';
42
26
  export { bearerTokenFromHeader, registerApiBearerAuthMiddleware, registerApiOriginGuardMiddleware, requireStrictBearerToken, timingSafeTokenMatch, } from './api-security-middleware.js';
43
- export { isLoopbackHostname, isLoopbackPeerAddress, localOriginFromHeader, normalizeLocalAuthority, requireLocalDaemonRequest, validateLocalDaemonRequest, } from './local-daemon-request.js';
44
- export type { DaemonShutdownResponse, DaemonStatusDeps, DaemonStatusResponse, } from './daemon-status.js';
45
- export { daemonShutdownRoute, daemonStatusRoute, registerDaemonStatusRoutes } from './daemon-status.js';
46
- export type { RunCancelResponse, RunCreateRequest, RunHttpDeps, RunInternalErrorContext, RunListResponse, RunStartContext, RunStartHandler, RunStartResponse, RunStatusResponse, } from './runs.js';
47
- export { registerRunEventStream, registerRunRoutes, RUN_EVENTS_ROUTE_PATH, runCancelRoute, runListRoute, runStartRoute, runStatusRoute, } from './runs.js';
48
- export { JINI_ROUTE_MANIFEST, manifestRoutesForFamilies, routeFamilyManifest } from './route-manifest.js';
49
- export type { AgentListResponse, AgentModelSummary, AgentsHttpDeps, AgentSummary } from './agents.js';
50
- export { agentListRoute, agentRescanRoute, registerAgentRoutes } from './agents.js';
51
- export type { MemoryChangeEmitter, MemoryConfigResponse, MemoryDeleteEntryResponse, MemoryEntryInput, MemoryEntryResponse, MemoryExtractionLog, MemoryExtractionsResponse, MemoryHttpDeps, MemoryIndexResponse, MemoryNoteEntry, MemoryNoteEntrySummary, MemoryNoteStore, MemoryNoteStoreOptions, MemoryOverviewResponse, MemoryRemovedResponse, MemoryTreeNode, MemoryTreeNodePatch, MemoryTreeResponse, MemoryUpdateTreeNodeResponse, MemoryVerificationsResponse, MemoryVerifyLog, } from './memory.js';
52
- export { memoryClearExtractionsRoute, memoryClearVerificationsRoute, memoryCreateEntryRoute, memoryDeleteEntryRoute, memoryListExtractionsRoute, memoryListVerificationsRoute, memoryOverviewRoute, memoryReadEntryRoute, memoryRemoveExtractionRoute, memoryRemoveVerificationRoute, memoryTreeRoute, memoryUpdateEntryRoute, memoryUpdateTreeNodeRoute, memoryWriteConfigRoute, memoryWriteIndexRoute, registerMemoryEventStream, registerMemoryRoutes, } from './memory.js';
53
- export type { RoutineDeleteResponse, RoutineHttpDeps, RoutineListResponse, RoutineResponse, RoutineRunNowResponse, RoutineRunsResponse, RoutineScheduler, } from './routines.js';
54
- export { registerRoutineRoutes, routineCreateRoute, routineDeleteRoute, routineGetRoute, routineListRoute, routineRunNowRoute, routineRunsListRoute, routineUpdateRoute, } from './routines.js';
55
- export type { CreateDaemonDbToolRegistrationsOptions, DaemonDbHttpDeps, DaemonDbInternalErrorContext, DaemonDbOperations, DaemonDbStatusReport, DaemonDbTableInfo, DaemonDbToolRegistrations, DaemonDbVacuumResult, DbIntegrityIssue, DbIntegrityIssueKind, DbIntegrityReport, } from './db-ops.js';
56
- export { createDaemonDbToolRegistrations, daemonDbInspectRoute, daemonDbVacuumRoute, daemonDbVerifyRoute, DB_INSPECT_TOOL_ID, DB_VACUUM_TOOL_ID, DB_VERIFY_TOOL_ID, denyAllDaemonDbPolicy, registerDaemonDbRoutes, } from './db-ops.js';
57
- export type { ToolCatalogEntry, ToolCatalogHttpDeps, ToolCatalogQuery, ToolCatalogSearchHit, } from './tool-catalog.js';
58
- export { registerToolCatalogRoutes, toolCatalogDescribeRoute, toolCatalogSearchRoute, } from './tool-catalog.js';
59
- export type { ComponentCatalogEntry, ComponentCatalogHttpDeps, ComponentCatalogQuery, ComponentCatalogSearchHit, } from './component-catalog.js';
60
- export { registerComponentCatalogRoutes, componentCatalogDescribeRoute, componentCatalogSearchRoute, } from './component-catalog.js';
61
- export type { DelegatedToolExecuteRequest, DelegatedToolExecuteResponse, DelegatedToolsHttpDeps, DelegatedToolsInternalErrorContext, } from './delegated-tools.js';
62
- export { delegatedToolExecuteRoute, readOnlyRefusalMessage, READ_ONLY_UNVERIFIABLE_MESSAGE, registerDelegatedToolRoutes, } from './delegated-tools.js';
63
- export type { RemoteRunEventHttpDeps, RemoteRunEventResponse, RemoteToolBridgeTokenConfig, RemoteToolResultRequest, RemoteToolUseRequest, } from './remote-run-events.js';
64
- export { registerRemoteRunEventRoutes, remoteToolResultRoute, remoteToolUseRoute, requireRemoteToolBridgeToken, } from './remote-run-events.js';
65
- export type { FrontendSessionAttachedEvent, FrontendSessionErrorEvent, FrontendSessionInvocationEvent, FrontendSessionResponseBody, FrontendSessionResponseRequest, FrontendSessionStreamEvent, FrontendSessionsHttpDeps, } from './frontend-sessions.js';
66
- export { FRONTEND_SESSION_RESPONSE_ROUTE_PATH, FRONTEND_SESSION_STREAM_ROUTE_PATH, frontendSessionResponseRoute, handleFrontendSessionStream, parseCapabilityQuery, registerFrontendSessionRoutes, } from './frontend-sessions.js';
67
- export { createFrontendControl } from './frontend-control.js';
68
- export type { CreateFrontendControlOptions, FrontendBindErrorContext, FrontendControl, FrontendHttpExtension, } from './frontend-control.js';
69
- export type { TerminalActionResponse, TerminalCreateRequest, TerminalListResponse, TerminalsHttpDeps, TerminalsInternalErrorContext, } from './terminals.js';
70
- export { registerTerminalEventStream, registerTerminalRoutes, terminalCreateRoute, terminalDeleteRoute, terminalKillRoute, terminalListRoute, terminalResizeRoute, terminalStdinRoute, } from './terminals.js';
71
- export type { ModelProxyHttpDeps, ModelProxyInternalErrorContext } from './model-proxy.js';
72
- export { registerModelProxyRoutes } from './model-proxy.js';
73
- export type { HealthHttpDeps, HealthReadinessResult, LivenessResponse, ReadinessResponse, VersionResponse } from './health.js';
74
- export { apiHealthRoute, apiReadyRoute, apiVersionInfoRoute, healthRoute, readyRoute, registerHealthRoutes, versionInfoRoute, } from './health.js';
75
- export type { AuthCredentials, AuthProvider, AuthSession, AuthUser, Charge, ChargeInput, ChargeStatus, ConnectorsAuthSessionResponse, ConnectorsAuthUserResponse, ConnectorsAuthVerifyResponse, ConnectorsChargeResponse, ConnectorsDbQueryResponse, ConnectorsDbRecordResponse, ConnectorsHttpDeps, ConnectorsInternalErrorContext, ConnectorsOkResponse, ConnectorsStorageGetResponse, ConnectorsStorageListResponse, ConnectorsStorageMetaResponse, DbProvider, DbQuery, DbRecord, PaymentsProvider, RealtimeProvider, StorageObjectMeta, StorageProvider, StoragePutOptions, } from './connectors.js';
76
- export { connectorsAuthSessionRoute, connectorsAuthSignInRoute, connectorsAuthSignOutRoute, connectorsAuthSignUpRoute, connectorsDbDeleteRoute, connectorsDbGetRoute, connectorsDbInsertRoute, connectorsDbQueryRoute, connectorsDbUpdateRoute, connectorsPaymentsChargeRoute, connectorsPaymentsGetRoute, connectorsPaymentsRefundRoute, connectorsRealtimePublishRoute, connectorsStorageDeleteRoute, connectorsStorageGetRoute, connectorsStorageListRoute, connectorsStoragePutRoute, registerConnectorsRoutes, } from './connectors.js';
77
- export type { ResearchHttpDeps, ResearchInternalErrorContext, ResearchProviderCredentials, ResearchSearchResponse, ResearchSource, } from './research.js';
78
- export { registerResearchRoutes, researchSearchRoute } from './research.js';
79
- export type { MediaGenerateResponse, MediaHttpDeps, MediaInternalErrorContext, MediaTaskDeleteResponse, MediaTaskListResponse, MediaTaskResponse, } from './media.js';
80
- export { mediaGenerateRoute, mediaTaskDeleteRoute, mediaTaskGetRoute, mediaTaskListRoute, registerMediaRoutes, } from './media.js';
81
- export type { AttachmentClaim, AttachmentRejectionReason, AttachmentsHttpDeps, AttachmentsInternalErrorContext, AttachmentStore, AttachmentUploadResponse, CreateDiskAttachmentStoreOptions, ObservedAttachmentIdentity, PendingAttachmentSummary, RecordedAttachmentIdentity, StoredAttachment, } from './attachments.js';
82
- export { ATTACHMENTS_ROUTE_PATH, AttachmentRejectedError, createDiskAttachmentStore, detectAttachmentKind, handleAttachmentCleanup, handleAttachmentUpload, isUnchangedAttachment, registerAttachmentRoutes, sanitizeAttachmentName, writeBoundedAttachmentBody, } from './attachments.js';
83
- export type { XaiAuthStatusResponse, XaiHttpDeps, XaiInternalErrorContext, XaiOauthStartResponse, XaiOkResponse, XaiSearchResponse, } from './xai.js';
84
- export { registerXaiRoutes, xaiAuthStatusRoute, xaiOauthCancelRoute, xaiOauthCompleteRoute, xaiOauthDisconnectRoute, xaiOauthStartRoute, xaiSearchRoute, } from './xai.js';
85
- export { createCompatApiError, createCompatApiErrorResponse, sendApiError as sendCompatApiError, } from './compat.js';
27
+ export { isLoopbackHostname } from '@jini-ai/platform/net';
28
+ export { isLoopbackPeerAddress, localOriginFromHeader, normalizeLocalAuthority, requireLocalDaemonRequest, validateLocalDaemonRequest, } from './local-daemon-request.js';
29
+ export { createCompatApiError, createCompatApiErrorResponse, } from './compat.js';
30
+ export * from './rate-limit.js';
31
+ export * from './middleware.js';
32
+ export * from './verified-origin.js';
33
+ export * from './observability.js';
34
+ export * from './request.js';
35
+ export * from './response.js';
36
+ export * from './origin.js';
86
37
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,40 +1,20 @@
1
1
  export { err, ok } from './types.js';
2
- export { allowedBrowserPorts, assertValidAllowedOrigins, configuredAllowedHosts, configuredAllowedOrigins, isAllowedBrowserHost, isAllowedBrowserOrigin, isIpLiteralHostname, isLoopbackOrPrivateLanHost, isLocalSameOrigin, isPrivateIpv4, parseHostHeader, } from './origin-validation.js';
2
+ export { allowedBrowserPorts, assertValidAllowedOrigins, configuredAllowedHosts, configuredAllowedOrigins, isAllowedBrowserHost, isAllowedBrowserOrigin, isIpLiteralHostname, isLoopbackOrPrivateLanHost, isLocalSameOrigin, isPrivateIpv4, parseHostHeader, } from '@jini-ai/core';
3
3
  export { ClientFacingError, defineJsonRoute, mountJsonRoute } from './adapter.js';
4
4
  export { getRouteRegistrationInventory, guardedRouteKey, installRouteRegistrationGuard, } from './route-registration-guard.js';
5
5
  export { createSseChannel, DEFAULT_MAX_QUEUED_SSE_EVENTS, requestedAfterCursor, sendRawApiError } from './sse.js';
6
6
  export { createSseResponse } from './raw-sse.js';
7
- export { denyAllWorkspaceRoots, resolveWorkspaceRoot, WorkspaceRootDeniedError } from './workspace-root.js';
8
7
  export { mountPackHttp } from './pack-http.js';
9
- export { cancelRunsOwnedBy } from './cancel-owned-runs.js';
10
- export { ACTIVE_CONTEXT_TTL_MS, getActiveRoute, registerActiveContextRoutes, setActiveRoute, } from './active-context.js';
11
- export { applicableForPlatform, CATALOGUE, currentPlatform, defaultProbeEnv, hostEditorsRoute, launchHostTool, listAvailableEditors, pathDirs, probeCommandOnPath, probeMacBundle, registerHostToolsRoutes, resolveEntry, resolveHostToolLaunchPlan, } from './host-tools.js';
12
8
  export { bearerTokenFromHeader, registerApiBearerAuthMiddleware, registerApiOriginGuardMiddleware, requireStrictBearerToken, timingSafeTokenMatch, } from './api-security-middleware.js';
13
- export { isLoopbackHostname, isLoopbackPeerAddress, localOriginFromHeader, normalizeLocalAuthority, requireLocalDaemonRequest, validateLocalDaemonRequest, } from './local-daemon-request.js';
14
- export { daemonShutdownRoute, daemonStatusRoute, registerDaemonStatusRoutes } from './daemon-status.js';
15
- export { registerRunEventStream, registerRunRoutes, RUN_EVENTS_ROUTE_PATH, runCancelRoute, runListRoute, runStartRoute, runStatusRoute, } from './runs.js';
16
- export { JINI_ROUTE_MANIFEST, manifestRoutesForFamilies, routeFamilyManifest } from './route-manifest.js';
17
- export { agentListRoute, agentRescanRoute, registerAgentRoutes } from './agents.js';
18
- export { memoryClearExtractionsRoute, memoryClearVerificationsRoute, memoryCreateEntryRoute, memoryDeleteEntryRoute, memoryListExtractionsRoute, memoryListVerificationsRoute, memoryOverviewRoute, memoryReadEntryRoute, memoryRemoveExtractionRoute, memoryRemoveVerificationRoute, memoryTreeRoute, memoryUpdateEntryRoute, memoryUpdateTreeNodeRoute, memoryWriteConfigRoute, memoryWriteIndexRoute, registerMemoryEventStream, registerMemoryRoutes, } from './memory.js';
19
- export { registerRoutineRoutes, routineCreateRoute, routineDeleteRoute, routineGetRoute, routineListRoute, routineRunNowRoute, routineRunsListRoute, routineUpdateRoute, } from './routines.js';
20
- export { createDaemonDbToolRegistrations, daemonDbInspectRoute, daemonDbVacuumRoute, daemonDbVerifyRoute, DB_INSPECT_TOOL_ID, DB_VACUUM_TOOL_ID, DB_VERIFY_TOOL_ID, denyAllDaemonDbPolicy, registerDaemonDbRoutes, } from './db-ops.js';
21
- export { registerToolCatalogRoutes, toolCatalogDescribeRoute, toolCatalogSearchRoute, } from './tool-catalog.js';
22
- export { registerComponentCatalogRoutes, componentCatalogDescribeRoute, componentCatalogSearchRoute, } from './component-catalog.js';
23
- export { delegatedToolExecuteRoute, readOnlyRefusalMessage, READ_ONLY_UNVERIFIABLE_MESSAGE, registerDelegatedToolRoutes, } from './delegated-tools.js';
24
- export { registerRemoteRunEventRoutes, remoteToolResultRoute, remoteToolUseRoute, requireRemoteToolBridgeToken, } from './remote-run-events.js';
25
- export { FRONTEND_SESSION_RESPONSE_ROUTE_PATH, FRONTEND_SESSION_STREAM_ROUTE_PATH, frontendSessionResponseRoute, handleFrontendSessionStream, parseCapabilityQuery, registerFrontendSessionRoutes, } from './frontend-sessions.js';
26
- export { createFrontendControl } from './frontend-control.js';
27
- export { registerTerminalEventStream, registerTerminalRoutes, terminalCreateRoute, terminalDeleteRoute, terminalKillRoute, terminalListRoute, terminalResizeRoute, terminalStdinRoute, } from './terminals.js';
28
- export { registerModelProxyRoutes } from './model-proxy.js';
29
- export { apiHealthRoute, apiReadyRoute, apiVersionInfoRoute, healthRoute, readyRoute, registerHealthRoutes, versionInfoRoute, } from './health.js';
30
- export { connectorsAuthSessionRoute, connectorsAuthSignInRoute, connectorsAuthSignOutRoute, connectorsAuthSignUpRoute, connectorsDbDeleteRoute, connectorsDbGetRoute, connectorsDbInsertRoute, connectorsDbQueryRoute, connectorsDbUpdateRoute, connectorsPaymentsChargeRoute, connectorsPaymentsGetRoute, connectorsPaymentsRefundRoute, connectorsRealtimePublishRoute, connectorsStorageDeleteRoute, connectorsStorageGetRoute, connectorsStorageListRoute, connectorsStoragePutRoute, registerConnectorsRoutes, } from './connectors.js';
31
- export { registerResearchRoutes, researchSearchRoute } from './research.js';
32
- export { mediaGenerateRoute, mediaTaskDeleteRoute, mediaTaskGetRoute, mediaTaskListRoute, registerMediaRoutes, } from './media.js';
33
- export { ATTACHMENTS_ROUTE_PATH, AttachmentRejectedError, createDiskAttachmentStore, detectAttachmentKind, handleAttachmentCleanup, handleAttachmentUpload, isUnchangedAttachment, registerAttachmentRoutes, sanitizeAttachmentName, writeBoundedAttachmentBody, } from './attachments.js';
34
- export { registerXaiRoutes, xaiAuthStatusRoute, xaiOauthCancelRoute, xaiOauthCompleteRoute, xaiOauthDisconnectRoute, xaiOauthStartRoute, xaiSearchRoute, } from './xai.js';
35
- // Legacy-shaped compat error helpers (separate code/message/init call shape). `sendApiError`
36
- // above (from `response.ts`) takes a single `ApiError` object; this compat `sendApiError` takes
37
- // `(code, message, init)` — same job, different call-site generation, so it is re-exported here
38
- // under a distinct name to avoid a duplicate export.
39
- export { createCompatApiError, createCompatApiErrorResponse, sendApiError as sendCompatApiError, } from './compat.js';
9
+ export { isLoopbackHostname } from '@jini-ai/platform/net';
10
+ export { isLoopbackPeerAddress, localOriginFromHeader, normalizeLocalAuthority, requireLocalDaemonRequest, validateLocalDaemonRequest, } from './local-daemon-request.js';
11
+ export { createCompatApiError, createCompatApiErrorResponse, } from './compat.js';
12
+ export * from './rate-limit.js';
13
+ export * from './middleware.js';
14
+ export * from './verified-origin.js';
15
+ export * from './observability.js';
16
+ // Generic request/response and origin primitives used by capability-owned route packs.
17
+ export * from './request.js';
18
+ export * from './response.js';
19
+ export * from './origin.js';
40
20
  //# sourceMappingURL=index.js.map
@@ -12,14 +12,18 @@ interface LocalDaemonValidationError {
12
12
  message: string;
13
13
  details: Record<string, string>;
14
14
  }
15
- /** Parses a `Host`-header-shaped authority string, rejecting anything with a path/userinfo/query. */
16
- export declare function normalizeLocalAuthority(value: unknown): LocalAuthority | null;
17
- /** True when `hostname` is `localhost`, an IPv6 loopback literal, or a `127.0.0.0/8` IPv4 literal. */
18
- export declare function isLoopbackHostname(hostname: unknown): boolean;
15
+ /** Parses a `Host`-header-shaped authority string, rejecting anything with a path/userinfo/query/fragment. */
16
+ export declare function normalizeLocalAuthority({ value }: {
17
+ readonly value: unknown;
18
+ }, _optional?: Record<string, never>): LocalAuthority | null;
19
19
  /** True when `address` (typically `req.socket.remoteAddress`) is a loopback peer, unwrapping an IPv4-mapped IPv6 prefix first. */
20
- export declare function isLoopbackPeerAddress(address: unknown): boolean;
20
+ export declare function isLoopbackPeerAddress({ address }: {
21
+ readonly address: unknown;
22
+ }, _optional?: Record<string, never>): boolean;
21
23
  /** Parses an `Origin` header value into its origin string, requiring a bare `scheme://loopback-host[:port]` with no path/query/userinfo. */
22
- export declare function localOriginFromHeader(value: unknown): string | null;
24
+ export declare function localOriginFromHeader({ value }: {
25
+ readonly value: unknown;
26
+ }, _optional?: Record<string, never>): string | null;
23
27
  /**
24
28
  * Validates that `req` is a loopback request: the TCP peer address, the `Host`
25
29
  * header, and (when present) the `Origin` header must all resolve to a
@@ -30,7 +34,9 @@ export declare function localOriginFromHeader(value: unknown): string | null;
30
34
  * `null` when the request carried none); otherwise `{ ok: false, message, details }` naming which
31
35
  * check failed.
32
36
  */
33
- export declare function validateLocalDaemonRequest(req: Request): LocalDaemonValidation | LocalDaemonValidationError;
37
+ export declare function validateLocalDaemonRequest({ req }: {
38
+ readonly req: Request;
39
+ }, _optional?: Record<string, never>): LocalDaemonValidation | LocalDaemonValidationError;
34
40
  /**
35
41
  * Express middleware that rejects any non-loopback request with a 403, and
36
42
  * otherwise sets permissive same-machine CORS headers before calling `next()`.
@@ -39,6 +45,10 @@ export declare function validateLocalDaemonRequest(req: Request): LocalDaemonVal
39
45
  * @param res - The response to reject on, or set CORS headers on before continuing.
40
46
  * @param next - Called when the request validates as loopback.
41
47
  */
42
- export declare function requireLocalDaemonRequest(req: Request, res: Response, next: NextFunction): void | Response;
48
+ export declare function requireLocalDaemonRequest({ req, res, next }: {
49
+ readonly req: Request;
50
+ readonly res: Response;
51
+ readonly next: NextFunction;
52
+ }, _optional?: Record<string, never>): void | Response;
43
53
  export {};
44
54
  //# sourceMappingURL=local-daemon-request.d.ts.map
@@ -10,16 +10,20 @@
10
10
  * allow-list configuration.
11
11
  */
12
12
  import net from 'node:net';
13
- import { sendApiError } from './compat.js';
14
- /** Parses a `Host`-header-shaped authority string, rejecting anything with a path/userinfo/query. */
15
- export function normalizeLocalAuthority(value) {
13
+ import { isLoopbackHostname } from '@jini-ai/platform/net';
14
+ import { createCompatApiError } from './compat.js';
15
+ import { sendApiError } from './response.js';
16
+ /** Parses a `Host`-header-shaped authority string, rejecting anything with a path/userinfo/query/fragment. */
17
+ export function normalizeLocalAuthority({ value }, _optional = {}) {
16
18
  if (typeof value !== 'string')
17
19
  return null;
18
20
  const trimmed = value.trim();
19
- if (!trimmed || /[\s/@]/.test(trimmed) || trimmed.includes(','))
21
+ if (!trimmed || /[\s/@?\\#]/.test(trimmed) || trimmed.includes(','))
20
22
  return null;
21
23
  try {
22
- // The guard above already rejects any `/`, `@`, or whitespace in `trimmed`, and the WHATWG
24
+ // Reject delimiters before parsing: WHATWG URL parsing would otherwise silently discard a
25
+ // query/fragment (including a bare `?`/`#`) or turn a backslash into a path separator.
26
+ // The guard above already rejects any path delimiter, `@`, or whitespace in `trimmed`, and the WHATWG
23
27
  // URL parser requires a non-empty host for an `http:` URL — so `parsed.hostname` is always
24
28
  // non-empty and `parsed.pathname` is always `/` for every `trimmed` value that reaches this
25
29
  // line without throwing. `hostname` below can still end up empty after stripping a trailing
@@ -34,29 +38,15 @@ export function normalizeLocalAuthority(value) {
34
38
  return null;
35
39
  }
36
40
  }
37
- /** True when `hostname` is `localhost`, an IPv6 loopback literal, or a `127.0.0.0/8` IPv4 literal. */
38
- export function isLoopbackHostname(hostname) {
39
- const normalized = String(hostname || '')
40
- .toLowerCase()
41
- .replace(/^\[|\]$/g, '')
42
- .replace(/\.$/, '');
43
- if (normalized === 'localhost')
44
- return true;
45
- if (normalized === '::1' || normalized === '0:0:0:0:0:0:0:1')
46
- return true;
47
- if (net.isIP(normalized) === 4)
48
- return normalized === '127.0.0.1' || normalized.startsWith('127.');
49
- return false;
50
- }
51
41
  /** True when `address` (typically `req.socket.remoteAddress`) is a loopback peer, unwrapping an IPv4-mapped IPv6 prefix first. */
52
- export function isLoopbackPeerAddress(address) {
42
+ export function isLoopbackPeerAddress({ address }, _optional = {}) {
53
43
  if (typeof address !== 'string')
54
44
  return false;
55
45
  const normalized = address.trim().toLowerCase().replace(/^\[|\]$/g, '');
56
46
  if (!normalized)
57
47
  return false;
58
48
  if (normalized.startsWith('::ffff:'))
59
- return isLoopbackPeerAddress(normalized.slice('::ffff:'.length));
49
+ return isLoopbackPeerAddress({ address: normalized.slice('::ffff:'.length) });
60
50
  if (normalized === '::1' || normalized === '0:0:0:0:0:0:0:1')
61
51
  return true;
62
52
  if (net.isIP(normalized) === 4)
@@ -64,7 +54,7 @@ export function isLoopbackPeerAddress(address) {
64
54
  return false;
65
55
  }
66
56
  /** Parses an `Origin` header value into its origin string, requiring a bare `scheme://loopback-host[:port]` with no path/query/userinfo. */
67
- export function localOriginFromHeader(value) {
57
+ export function localOriginFromHeader({ value }, _optional = {}) {
68
58
  if (typeof value !== 'string')
69
59
  return null;
70
60
  const trimmed = value.trim();
@@ -76,7 +66,7 @@ export function localOriginFromHeader(value) {
76
66
  return null;
77
67
  if (parsed.pathname !== '/' || parsed.search || parsed.hash || parsed.username || parsed.password)
78
68
  return null;
79
- if (!isLoopbackHostname(parsed.hostname))
69
+ if (!isLoopbackHostname({ hostname: parsed.hostname }))
80
70
  return null;
81
71
  return parsed.origin;
82
72
  }
@@ -94,16 +84,16 @@ export function localOriginFromHeader(value) {
94
84
  * `null` when the request carried none); otherwise `{ ok: false, message, details }` naming which
95
85
  * check failed.
96
86
  */
97
- export function validateLocalDaemonRequest(req) {
98
- if (!isLoopbackPeerAddress(req.socket?.remoteAddress)) {
87
+ export function validateLocalDaemonRequest({ req }, _optional = {}) {
88
+ if (!isLoopbackPeerAddress({ address: req.socket?.remoteAddress })) {
99
89
  return {
100
90
  ok: false,
101
91
  message: 'request peer must be a loopback address',
102
92
  details: { peer: 'remoteAddress' },
103
93
  };
104
94
  }
105
- const host = normalizeLocalAuthority(req.get('host'));
106
- if (!host || !isLoopbackHostname(host.hostname)) {
95
+ const host = normalizeLocalAuthority({ value: req.get('host') });
96
+ if (!host || !isLoopbackHostname({ hostname: host.hostname })) {
107
97
  return {
108
98
  ok: false,
109
99
  message: 'request host must be a loopback daemon address',
@@ -111,14 +101,14 @@ export function validateLocalDaemonRequest(req) {
111
101
  };
112
102
  }
113
103
  const originHeader = req.get('origin');
114
- if (originHeader !== undefined && !localOriginFromHeader(originHeader)) {
104
+ if (originHeader !== undefined && !localOriginFromHeader({ value: originHeader })) {
115
105
  return {
116
106
  ok: false,
117
107
  message: 'request origin must be a loopback daemon origin',
118
108
  details: { header: 'origin' },
119
109
  };
120
110
  }
121
- return { ok: true, origin: localOriginFromHeader(originHeader) };
111
+ return { ok: true, origin: localOriginFromHeader({ value: originHeader }) };
122
112
  }
123
113
  /**
124
114
  * Express middleware that rejects any non-loopback request with a 403, and
@@ -128,10 +118,11 @@ export function validateLocalDaemonRequest(req) {
128
118
  * @param res - The response to reject on, or set CORS headers on before continuing.
129
119
  * @param next - Called when the request validates as loopback.
130
120
  */
131
- export function requireLocalDaemonRequest(req, res, next) {
132
- const validation = validateLocalDaemonRequest(req);
121
+ export function requireLocalDaemonRequest({ req, res, next }, _optional = {}) {
122
+ const validation = validateLocalDaemonRequest({ req });
133
123
  if (!validation.ok) {
134
- return sendApiError(res, 403, 'FORBIDDEN', validation.message, { details: validation.details });
124
+ sendApiError({ res, status: 403, error: createCompatApiError({ code: 'FORBIDDEN', message: validation.message }, { details: validation.details }) });
125
+ return;
135
126
  }
136
127
  res.setHeader('Vary', 'Origin');
137
128
  if (validation.origin) {
package/dist/memory.d.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  * importing `@jini-ai/memory` directly would fail `pnpm guard`'s R7 check
17
17
  * outright (the same constraint `packages/media/src/sqlite-task-store.ts`'s
18
18
  * `ADS-memory/reports/proposals/PROP-media-durable-tasks-2026-07-21.md`
19
- * documents for `@jini-ai/sqlite`/`@jini-ai/media`). The types below
19
+ * documents for `@jini-ai/sqlite-chat`/`@jini-ai/media`). The types below
20
20
  * (`MemoryNoteStore`/`MemoryExtractionLog`/`MemoryVerifyLog`) are local,
21
21
  * structural mirrors of `@jini-ai/memory`'s real `NoteStore`/`ExtractionLog`/
22
22
  * `VerifyLog` interfaces — a real `@jini-ai/memory` instance satisfies them
@@ -0,0 +1,20 @@
1
+ import type { RequestHandler } from 'express';
2
+ /** Host response wording and envelope, evaluated only for an oversized body. */
3
+ export type ErrorResponseFactory = (required: {
4
+ maxBytes: number;
5
+ bodyBytes: number;
6
+ }) => unknown;
7
+ export interface BodySizeLimitRequired {
8
+ readonly maxBytes: number;
9
+ readonly errorResponseFactory: ErrorResponseFactory;
10
+ }
11
+ export type BodySizeLimitOptional = Record<string, never>;
12
+ /**
13
+ * Enforces a route-specific UTF-8 byte ceiling on already-parsed JSON.
14
+ * Mount after the host JSON parser, whose allocation ceiling remains necessary.
15
+ * Null and undefined preserve the original empty-object serialization fallback.
16
+ * @param required - Byte ceiling and required host error-response wording.
17
+ * @returns Express middleware; oversized requests receive 413 without next().
18
+ */
19
+ export declare function rejectOversizedJsonBody({ maxBytes, errorResponseFactory }: BodySizeLimitRequired, _optional?: BodySizeLimitOptional): RequestHandler;
20
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1,21 @@
1
+ // A second express.json({ limit }) silently skips a body already parsed upstream, so it cannot
2
+ // tighten a route's limit. Re-measure the serialized bytes here; the upstream parser must still
3
+ // bound initial allocation. Reject before next() so an oversized body never reaches a write.
4
+ /**
5
+ * Enforces a route-specific UTF-8 byte ceiling on already-parsed JSON.
6
+ * Mount after the host JSON parser, whose allocation ceiling remains necessary.
7
+ * Null and undefined preserve the original empty-object serialization fallback.
8
+ * @param required - Byte ceiling and required host error-response wording.
9
+ * @returns Express middleware; oversized requests receive 413 without next().
10
+ */
11
+ export function rejectOversizedJsonBody({ maxBytes, errorResponseFactory }, _optional = {}) {
12
+ return (req, res, next) => {
13
+ const bodyBytes = Buffer.byteLength(JSON.stringify(req.body ?? {}), 'utf8');
14
+ if (bodyBytes > maxBytes) {
15
+ res.status(413).json(errorResponseFactory({ maxBytes, bodyBytes }));
16
+ return;
17
+ }
18
+ next();
19
+ };
20
+ }
21
+ //# sourceMappingURL=middleware.js.map
@@ -0,0 +1,29 @@
1
+ import type { Express, RequestHandler } from 'express';
2
+ /** Structural port satisfied by diagnostics/observability, with host-owned logging and tracing. */
3
+ export interface HttpRequestObservabilityPort {
4
+ trackRequest(required: {
5
+ method: string;
6
+ path: string;
7
+ }): {
8
+ end(required: {
9
+ statusCode: number;
10
+ routePattern: string;
11
+ }): void;
12
+ };
13
+ }
14
+ /** Track requests before routing and read the mount-aware route pattern at response completion.
15
+ * Unmatched paths use a fixed label so attacker-selected paths do not become metric labels.
16
+ * Each response completes its tracker once; hook error policy belongs to the injected adapter.
17
+ * @complexity O(1) per request, excluding injected hooks and Express routing.
18
+ */
19
+ export declare function createRequestTrackingMiddleware({ observability }: {
20
+ observability: HttpRequestObservabilityPort;
21
+ }): RequestHandler;
22
+ /** Mount first, before serving gates and routes, so refusals and unmatched requests are measured.
23
+ * @complexity O(1) registration; effects are restricted to Express middleware registration.
24
+ */
25
+ export declare function applyRequestTracking({ app, observability }: {
26
+ app: Express;
27
+ observability: HttpRequestObservabilityPort;
28
+ }): void;
29
+ //# sourceMappingURL=observability.d.ts.map
@@ -0,0 +1,22 @@
1
+ /** Track requests before routing and read the mount-aware route pattern at response completion.
2
+ * Unmatched paths use a fixed label so attacker-selected paths do not become metric labels.
3
+ * Each response completes its tracker once; hook error policy belongs to the injected adapter.
4
+ * @complexity O(1) per request, excluding injected hooks and Express routing.
5
+ */
6
+ export function createRequestTrackingMiddleware({ observability }) {
7
+ return (req, res, next) => {
8
+ const tracker = observability.trackRequest({ method: req.method, path: req.path });
9
+ res.once('finish', () => {
10
+ const routePattern = req.route ? `${req.baseUrl}${req.route.path}` : 'unmatched';
11
+ tracker.end({ statusCode: res.statusCode, routePattern });
12
+ });
13
+ next();
14
+ };
15
+ }
16
+ /** Mount first, before serving gates and routes, so refusals and unmatched requests are measured.
17
+ * @complexity O(1) registration; effects are restricted to Express middleware registration.
18
+ */
19
+ export function applyRequestTracking({ app, observability }) {
20
+ app.use(createRequestTrackingMiddleware({ observability }));
21
+ }
22
+ //# sourceMappingURL=observability.js.map
package/dist/origin.d.ts CHANGED
@@ -3,17 +3,16 @@
3
3
  * the Adapter can treat an origin failure the same as a parse/handle failure.
4
4
  */
5
5
  import type { Request } from 'express';
6
+ import { type OriginValidationEnvConfig } from '@jini-ai/core';
6
7
  import { type Result } from './types.js';
7
8
  /** The subset of server startup state `guardSameOrigin` needs: the resolved local port, and the
8
9
  * environment the origin policy is read from. */
9
- export interface OriginContext {
10
+ export interface OriginContext extends OriginValidationEnvConfig {
10
11
  resolvedPortRef: {
11
12
  current: number;
12
13
  };
13
14
  /**
14
- * Environment `JINI_BIND_HOST`, `JINI_ALLOWED_ORIGINS` and `JINI_WEB_PORT` are read from.
15
- *
16
- * @default `process.env`
15
+ * Host-supplied environment; the host also names the bind-host, allowed-origin and web-port vars.
17
16
  *
18
17
  * Present because a host can inject its own environment (`@jini-ai/server`'s
19
18
  * `createLocalNodeDaemon`/`composeJiniKernel` `env` option), and that injection already reaches
@@ -22,11 +21,14 @@ export interface OriginContext {
22
21
  * the host configured and the per-route guard then rejects it, or a bind host the host never set
23
22
  * decides what counts as same-origin.
24
23
  */
25
- env?: NodeJS.ProcessEnv;
24
+ env: NodeJS.ProcessEnv;
26
25
  }
27
26
  /**
28
27
  * Wraps `isLocalSameOrigin` so the HTTP Adapter can fold the origin decision into the same
29
28
  * error-handling pipeline as parse/handle failures.
30
29
  */
31
- export declare function guardSameOrigin(req: Request, origin: OriginContext): Result<void>;
30
+ export declare function guardSameOrigin({ req, origin }: {
31
+ readonly req: Request;
32
+ readonly origin: OriginContext;
33
+ }, _optional?: Record<string, never>): Result<void>;
32
34
  //# sourceMappingURL=origin.d.ts.map
package/dist/origin.js CHANGED
@@ -1,14 +1,17 @@
1
1
  import { createApiError } from '@jini-ai/protocol';
2
- import { isLocalSameOrigin } from './origin-validation.js';
2
+ import { isLocalSameOrigin } from '@jini-ai/core';
3
3
  import { err, ok } from './types.js';
4
4
  /**
5
5
  * Wraps `isLocalSameOrigin` so the HTTP Adapter can fold the origin decision into the same
6
6
  * error-handling pipeline as parse/handle failures.
7
7
  */
8
- export function guardSameOrigin(req, origin) {
9
- if (isLocalSameOrigin(req, origin.resolvedPortRef.current, origin.env ?? process.env)) {
10
- return ok(undefined);
8
+ export function guardSameOrigin({ req, origin }, _optional = {}) {
9
+ const { env, allowedOriginsEnvVar, webPortEnvVar, bindHostEnvVar } = origin;
10
+ if (isLocalSameOrigin({ req, port: origin.resolvedPortRef.current, env,
11
+ config: { allowedOriginsEnvVar, webPortEnvVar, bindHostEnvVar },
12
+ })) {
13
+ return ok({ value: undefined });
11
14
  }
12
- return err(createApiError('FORBIDDEN', 'cross-origin request rejected'));
15
+ return err({ error: createApiError({ code: 'FORBIDDEN', message: 'cross-origin request rejected' }) });
13
16
  }
14
17
  //# sourceMappingURL=origin.js.map
@@ -1,30 +1,34 @@
1
1
  /**
2
2
  * Route-pack registrar: mounts every composed pack's `http` registrar (`Pack.http`, typed
3
- * `(app: unknown, services) => void` in `@jini-ai/core` so the kernel never depends on any one HTTP
3
+ * `({ app: unknown, services }) => void` in `@jini-ai/core` so the kernel never depends on any one HTTP
4
4
  * framework) onto a concrete app instance. This is the piece of extraction-plan.md §3's
5
5
  * "@jini-ai/http-kit — HTTP/SSE transport + route-pack registrar" that ties a `Daemon` composed by
6
- * `createDaemon` to a real HTTP surface: a pack that declares an `http(app, services)` function
6
+ * `createDaemon` to a real HTTP surface: a pack that declares an `http({ app, services })` function
7
7
  * gets called with the *same* app and the *same* services object `@jini-ai/cli` would receive via
8
8
  * `Pack.cli` (extraction-plan.md §2.3). `app` is typed `unknown` here (mirroring `Pack.http`'s own
9
9
  * signature) rather than a concrete Express app type, since this registrar itself never touches
10
- * `app` beyond passing it straight through to each pack's own `http(app, services)`.
10
+ * `app` beyond passing it straight through to each pack's own `http({ app, services })`.
11
11
  *
12
12
  * Injecting an `ExecutionDelegate` for the tool-execution boundary (extraction-plan.md §2.5,
13
- * §10 task 6) is explicitly out of scope here — no `ToolExecutor` exists in this codebase yet.
13
+ * §10 task 6) is explicitly out of scope here — this registrar does not construct a `ToolExecutor`.
14
14
  * `mountPackHttp` only wires the transport-neutral pack composition already built in
15
- * `@jini-ai/core`; a future task adds delegate injection once the boundary itself exists.
15
+ * `@jini-ai/core`; hosts supply their execution boundary independently of this registrar.
16
16
  *
17
- * **Note for pack authors:** a pack's own `http(app, services)` registrar receives the concrete
17
+ * **Note for pack authors:** a pack's own `http({ app, services })` registrar receives the concrete
18
18
  * Express instance the caller assembled — write it against Express's own API, or (preferred) build
19
19
  * it on `@jini-ai/http-kit`'s own `defineJsonRoute`/`mountJsonRoute`.
20
20
  */
21
21
  import type { Daemon, Pack } from '@jini-ai/core';
22
22
  type AnyPack = Pack<any, any, string>;
23
23
  /**
24
- * Calls `pack.http(app, services)` for every pack in `packs` that declares an `http` registrar,
24
+ * Calls `pack.http({ app, services })` for every pack in `packs` that declares an `http` registrar,
25
25
  * passing the services object `createDaemon` already composed for that pack. Packs with no
26
26
  * `http` registrar (e.g. a CLI-only or headless pack) are skipped.
27
27
  */
28
- export declare function mountPackHttp<const Packs extends readonly AnyPack[]>(app: unknown, packs: Packs, daemon: Daemon<Packs>): void;
28
+ export declare function mountPackHttp<const Packs extends readonly AnyPack[]>({ app, packs, daemon }: {
29
+ readonly app: unknown;
30
+ readonly packs: Packs;
31
+ readonly daemon: Daemon<Packs>;
32
+ }, _optional?: Record<string, never>): void;
29
33
  export {};
30
34
  //# sourceMappingURL=pack-http.d.ts.map
package/dist/pack-http.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Calls `pack.http(app, services)` for every pack in `packs` that declares an `http` registrar,
2
+ * Calls `pack.http({ app, services })` for every pack in `packs` that declares an `http` registrar,
3
3
  * passing the services object `createDaemon` already composed for that pack. Packs with no
4
4
  * `http` registrar (e.g. a CLI-only or headless pack) are skipped.
5
5
  */
6
- export function mountPackHttp(app, packs, daemon) {
6
+ export function mountPackHttp({ app, packs, daemon }, _optional = {}) {
7
7
  const services = daemon.services;
8
8
  for (const pack of packs) {
9
- pack.http?.(app, services[pack.name]);
9
+ pack.http?.({ app, services: services[pack.name] });
10
10
  }
11
11
  }
12
12
  //# sourceMappingURL=pack-http.js.map