@teamscala/service-boot 0.23.345 → 0.23.347
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1064 -1093
- package/src/fn-routers/index.ts +0 -2
- package/src/two-phase-boot.ts +2 -1
- package/src/agreement-gate.d.ts +0 -19
- package/src/asset-cache-key.d.ts +0 -11
- package/src/asset-optimize.d.ts +0 -17
- package/src/asset-proxy.d.ts +0 -11
- package/src/asset-social-card.d.ts +0 -17
- package/src/attach-agreement-magic.d.ts +0 -20
- package/src/attach-portal-members.d.ts +0 -23
- package/src/attach-proposal-accept.d.ts +0 -26
- package/src/attach-proposal-magic.d.ts +0 -18
- package/src/attach-transfers-upload.d.ts +0 -27
- package/src/auth-gate.d.ts +0 -29
- package/src/bind-page-handler.d.ts +0 -18
- package/src/build-client-assets/input-hashing.d.ts +0 -25
- package/src/build-client-assets/source-candidates.d.ts +0 -27
- package/src/build-client-assets.d.ts +0 -50
- package/src/compose-page-title.d.ts +0 -41
- package/src/content-gate/access.d.ts +0 -15
- package/src/content-gate/config-types.d.ts +0 -99
- package/src/content-gate/gate.d.ts +0 -13
- package/src/content-gate/parse-cookie.d.ts +0 -9
- package/src/content-gate/token.d.ts +0 -48
- package/src/content-page-floor.d.ts +0 -39
- package/src/discover-blocks.d.ts +0 -28
- package/src/expand-roster.d.ts +0 -34
- package/src/fn-routers/agreement-completion-email.d.ts +0 -14
- package/src/fn-routers/agreement-send-router.d.ts +0 -82
- package/src/fn-routers/ai-health-router.d.ts +0 -35
- package/src/fn-routers/auth-router.d.ts +0 -47
- package/src/fn-routers/cache-admin-router.d.ts +0 -57
- package/src/fn-routers/chat-session-router.d.ts +0 -219
- package/src/fn-routers/email-defaults.d.ts +0 -1
- package/src/fn-routers/email-link-ttl.d.ts +0 -1
- package/src/fn-routers/index.d.ts +0 -18
- package/src/fn-routers/orchestrator-registration-router.d.ts +0 -60
- package/src/fn-routers/orchestrator-registration-router.ts +0 -77
- package/src/fn-routers/orchestrator-registration.live.test.ts +0 -70
- package/src/fn-routers/orchestrator-registration.test.ts +0 -23
- package/src/fn-routers/panel-data-router.d.ts +0 -19
- package/src/fn-routers/persist-chat-messages.d.ts +0 -36
- package/src/fn-routers/plans-router.d.ts +0 -25
- package/src/fn-routers/proposal-send-router.d.ts +0 -58
- package/src/fn-routers/public-agreement-router.d.ts +0 -289
- package/src/fn-routers/public-assessment-router.d.ts +0 -68
- package/src/fn-routers/public-gpt-session-router.d.ts +0 -143
- package/src/fn-routers/sign-in-flow-router.d.ts +0 -107
- package/src/fn-routers/task-sync-assign.d.ts +0 -307
- package/src/fn-routers/task-sync-brief.d.ts +0 -98
- package/src/fn-routers/task-sync-close.d.ts +0 -41
- package/src/fn-routers/task-sync-dispatch.d.ts +0 -47
- package/src/fn-routers/task-sync-dispatch.ts +0 -81
- package/src/fn-routers/task-sync-lane.d.ts +0 -49
- package/src/fn-routers/task-sync-lane.ts +0 -114
- package/src/fn-routers/task-sync-projection.d.ts +0 -144
- package/src/fn-routers/task-sync-rename.d.ts +0 -91
- package/src/fn-routers/task-sync-router.d.ts +0 -455
- package/src/fn-routers/task-sync-router.test.ts +0 -361
- package/src/fn-routers/task-sync-router.ts +0 -1075
- package/src/fn-routers/tasks-router.d.ts +0 -25
- package/src/fn-routers/user-preferences-router.d.ts +0 -77
- package/src/fn-routers/work-items-router.d.ts +0 -102
- package/src/gate-ttls.d.ts +0 -6
- package/src/gpt-gate.d.ts +0 -25
- package/src/handlers/bun-stable-watch.d.ts +0 -1
- package/src/handlers/pane-outbox-drain.d.ts +0 -1
- package/src/handlers/projects-digest.d.ts +0 -26
- package/src/handlers/prune-stale-data.d.ts +0 -30
- package/src/handlers/registry-stale-inactive-sweep.d.ts +0 -1
- package/src/handlers/scala-tools-currency-watch.d.ts +0 -1
- package/src/handlers/singleton-tools-currency-watch.d.ts +0 -1
- package/src/handlers/sweep-event-log.d.ts +0 -1
- package/src/handlers/sweep-host-cache.d.ts +0 -24
- package/src/handlers/upstream-issue-sync.d.ts +0 -1
- package/src/handlers/whatsapp-liveness-logic.d.ts +0 -34
- package/src/handlers/whatsapp-liveness.d.ts +0 -4
- package/src/hono-error-handler.d.ts +0 -25
- package/src/install-harness.d.ts +0 -45
- package/src/install-logging.d.ts +0 -34
- package/src/load-service-install-row.d.ts +0 -24
- package/src/load-service-prisma-client.d.ts +0 -18
- package/src/mount-orpc-router.d.ts +0 -15
- package/src/mount-server-packages.d.ts +0 -29
- package/src/mount.d.ts +0 -9
- package/src/mutable-app-ref.d.ts +0 -44
- package/src/page-route-shell-types.d.ts +0 -12
- package/src/page-server-orpc/audit-revert-router.d.ts +0 -37
- package/src/page-server-orpc/hub-mcp-client.d.ts +0 -12
- package/src/page-server-orpc/portal-diagnostics-router.d.ts +0 -49
- package/src/page-server-orpc/puck-pages-router.d.ts +0 -58
- package/src/page-server-orpc/server-client.d.ts +0 -16
- package/src/page-server-orpc/templates-router.d.ts +0 -34
- package/src/page-server-orpc/user-preferences-router.d.ts +0 -79
- package/src/pg-boss-handler-registry.d.ts +0 -27
- package/src/pg-boss-mount.d.ts +0 -42
- package/src/proposal-authorized-emails.d.ts +0 -28
- package/src/proposal-chat-inject.d.ts +0 -17
- package/src/proposal-gate.d.ts +0 -18
- package/src/read-html-template.d.ts +0 -38
- package/src/read-viewport-from-request.d.ts +0 -18
- package/src/readiness-gate.d.ts +0 -16
- package/src/register-api-routes.d.ts +0 -18
- package/src/register-crash-handlers.d.ts +0 -15
- package/src/register-page-routes.d.ts +0 -27
- package/src/register-page-server-client.d.ts +0 -11
- package/src/register-registry-page-route/ai-chat-prefetch.d.ts +0 -13
- package/src/register-registry-page-route/graph-cache.d.ts +0 -30
- package/src/register-registry-page-route/meta-title.d.ts +0 -2
- package/src/register-registry-page-route/proposal-approval-email-token.d.ts +0 -14
- package/src/register-registry-page-route/proposal-brand-stamping.d.ts +0 -28
- package/src/register-registry-page-route/resolve-page-data.d.ts +0 -1
- package/src/register-registry-page-route.d.ts +0 -27
- package/src/register-static-assets.d.ts +0 -13
- package/src/register-ws-routes.d.ts +0 -28
- package/src/resolve-app-base-url.d.ts +0 -13
- package/src/resolve-brand-favicon.d.ts +0 -28
- package/src/resolve-from-loader-config.d.ts +0 -32
- package/src/resolve-service-context.d.ts +0 -17
- package/src/resolve-service-port.d.ts +0 -75
- package/src/resolve-theme-mode.d.ts +0 -42
- package/src/resolvers/fetch-org-brand.d.ts +0 -2
- package/src/resolvers/portal-route-paths.d.ts +0 -39
- package/src/resolvers/website-by-host-map.d.ts +0 -12
- package/src/resource-chat-inject.d.ts +0 -46
- package/src/resource-not-found.d.ts +0 -60
- package/src/run-boot-hook-list.d.ts +0 -19
- package/src/run-boot-hooks.d.ts +0 -31
- package/src/scala-tools-currency-watchdog.d.ts +0 -10
- package/src/security-headers.d.ts +0 -12
- package/src/serve/serve.d.ts +0 -46
- package/src/serve/stamp-transport-identity.d.ts +0 -39
- package/src/server-error-page.d.ts +0 -29
- package/src/start-scheduled-jobs.d.ts +0 -18
- package/src/two-phase-boot.d.ts +0 -176
- package/src/types.d.ts +0 -46
- package/src/ui-service.d.ts +0 -46
- package/src/ws-boot-self-test.d.ts +0 -19
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @system service-boot
|
|
3
|
-
* @status handwritten
|
|
4
|
-
* @edit edit directly
|
|
5
|
-
*
|
|
6
|
-
* Stamp transport-derived identity onto a request — the single shared stamp
|
|
7
|
-
* point used by BOTH serve paths (direct `createFetchHandler` + mutable-ref
|
|
8
|
-
* `fetchWithMutableApp`), so every request on every UI service carries the
|
|
9
|
-
* same identity regardless of boot mode.
|
|
10
|
-
*
|
|
11
|
-
* Two identity layers, both transport-derived (no-client-controlled-trust-
|
|
12
|
-
* signals — never from a client-controllable header):
|
|
13
|
-
* 1. `x-caller-remote-address` / `-port` — the unforgeable socket peer, from
|
|
14
|
-
* `Bun.serve.requestIP`. ALWAYS sanitised (any client-supplied spoof
|
|
15
|
-
* deleted) then set to the verified peer. The /mcp + fleet loopback gates
|
|
16
|
-
* read this.
|
|
17
|
-
* 2. `x-caller-local-comm` / `-cmd` — for a LOOPBACK peer with no forwarding
|
|
18
|
-
* header (a local `fetch` carries no CF-Connecting-IP), the owning local
|
|
19
|
-
* PROCESS resolved via /proc (@teamscala/proc-walker). Names the daemon
|
|
20
|
-
* behind every local request on the access log — including an unidentified
|
|
21
|
-
* sweeper. Attribution only (trust stays transport-derived).
|
|
22
|
-
*
|
|
23
|
-
* Best-effort + never throws: a resolution miss returns the original request
|
|
24
|
-
* unchanged (the request is always served; identity degrades to address-only).
|
|
25
|
-
* WebSocket upgrades are returned untouched (Bun tracks upgrades by Request
|
|
26
|
-
* identity — a clone can never upgrade).
|
|
27
|
-
*/
|
|
28
|
-
/**
|
|
29
|
-
* Preserve useful process attribution without copying arbitrary argv into logs.
|
|
30
|
-
* Arguments routinely contain bearer headers, inline scripts, URLs and secret
|
|
31
|
-
* values. There is no complete flag-name redaction list, so the safe boundary
|
|
32
|
-
* is structural: retain argv[0] and state that arguments were removed.
|
|
33
|
-
*/
|
|
34
|
-
export declare function summariseLocalCommand(cmdline: readonly string[]): string | null;
|
|
35
|
-
/**
|
|
36
|
-
* Return a Request with transport-identity headers stamped, or the original
|
|
37
|
-
* `req` when no stamping is needed/possible. Never throws.
|
|
38
|
-
*/
|
|
39
|
-
export declare function stampTransportIdentity(req: Request, server: ReturnType<typeof Bun.serve>): Request;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @system service-boot
|
|
3
|
-
* @status handwritten
|
|
4
|
-
* @edit edit directly
|
|
5
|
-
*
|
|
6
|
-
* The branded HTML error page for a FAILED PAGE RENDER — the page-server
|
|
7
|
-
* render catch's response surface (constitution `error-responses-via-error-
|
|
8
|
-
* report`). When SSR resolve+render fails (render budget exhausted, DEGRADED
|
|
9
|
-
* protective layer, a thrown loader), the browser is mid-navigation: serving
|
|
10
|
-
* a JSON body there is the violation this closes (2026-07-24: the operator
|
|
11
|
-
* saw a raw `{"error":"Request failed"}` blob where the dashboard should be).
|
|
12
|
-
*
|
|
13
|
-
* Classification stays in `buildErrorReport` (`@teamscala/os`) — the ONE
|
|
14
|
-
* classifier; this file is ONLY the HTML shaper for the page-navigation
|
|
15
|
-
* surface (API/ORPC `onError` keeps the JSON body, consumed by code). It
|
|
16
|
-
* renders the report's already-decided status + Retry-After + message, so the
|
|
17
|
-
* screen, the log line, and the GlitchTip event all share one `errorId`.
|
|
18
|
-
*
|
|
19
|
-
* Deliberately NOT a Puck page: it must render even when data loading is what
|
|
20
|
-
* failed. Sibling of `resource-not-found.ts` (the missing-resource floor) —
|
|
21
|
-
* same dark branded template + org-logo resolver, distinct trigger.
|
|
22
|
-
*/
|
|
23
|
-
import type { ErrorReport } from "@teamscala/os/errors/error-report";
|
|
24
|
-
/**
|
|
25
|
-
* Render an `ErrorReport` as a branded HTML page. Pure shaper — the caller
|
|
26
|
-
* classifies via `buildErrorReport` and resolves the logo first. Skew-tolerant
|
|
27
|
-
* by construction: a missing logo degrades to a plain branded dark page.
|
|
28
|
-
*/
|
|
29
|
-
export declare function buildServerErrorPageResponse(report: ErrorReport, logoUrl?: string | null): Response;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @system server-boot
|
|
3
|
-
* @status handwritten
|
|
4
|
-
* @edit edit directly
|
|
5
|
-
*
|
|
6
|
-
* Starts `service_install.scheduled_jobs[]`. Two kinds:
|
|
7
|
-
*
|
|
8
|
-
* - `long_running`: handler invoked once at boot, runs for the lifetime of
|
|
9
|
-
* the process (e.g. SSE subscribers, WAL watchers). Failures are logged.
|
|
10
|
-
* - `recurring`: declared here but cron scheduling lands via pg-boss in a
|
|
11
|
-
* follow-up — currently a no-op log.
|
|
12
|
-
*
|
|
13
|
-
* Implementations are registered by server_packages via
|
|
14
|
-
* ctx.registerScheduledJob during the mount phase.
|
|
15
|
-
*/
|
|
16
|
-
import type { ServiceInstallConfig } from "@teamscala/db/registry/loader/load-service-install-row";
|
|
17
|
-
import type { MountRegistry } from "@teamscala/os/runtime-contracts/mount-context";
|
|
18
|
-
export declare function startScheduledJobs(config: ServiceInstallConfig, mountRegistry: MountRegistry, serviceSlug: string): void;
|
package/src/two-phase-boot.d.ts
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @system service-boot
|
|
3
|
-
* @status handwritten
|
|
4
|
-
* @edit edit directly
|
|
5
|
-
*
|
|
6
|
-
* Two-phase boot for UI services. Splits the boot process into:
|
|
7
|
-
* 1. Minimal app (tool-only surface): ORPC, data routes, auth gates
|
|
8
|
-
* 2. Full app (with pages and hydration): adds block discovery, page routes,
|
|
9
|
-
* client asset building, boot hooks, scheduled jobs
|
|
10
|
-
*
|
|
11
|
-
* The minimal app starts serving immediately (<10s), then the full app is
|
|
12
|
-
* built in the background and atomically swapped in. This eliminates the
|
|
13
|
-
* ~25s channel outage window during scala-agents restart.
|
|
14
|
-
*/
|
|
15
|
-
import { Hono, type Context } from "hono";
|
|
16
|
-
import type { ServiceInstallConfig } from "./load-service-install-row.ts";
|
|
17
|
-
import { mountServerPackages } from "./mount-server-packages.ts";
|
|
18
|
-
import type { PageServerDeps } from "./ui-service.ts";
|
|
19
|
-
import type { CreatePageHandler } from "./types.ts";
|
|
20
|
-
/**
|
|
21
|
-
* Set the real page handler (called when Phase 2 completes on an SSR service).
|
|
22
|
-
*
|
|
23
|
-
* Registering the SSR handler implies the full app is built, so this also flips
|
|
24
|
-
* readiness — but the reverse does NOT hold, which is why `markFullAppReady`
|
|
25
|
-
* exists separately. See its note.
|
|
26
|
-
*/
|
|
27
|
-
export declare function setPageHandler(handler: CreatePageHandler): void;
|
|
28
|
-
/**
|
|
29
|
-
* Flip readiness once phase 2 has built the full app.
|
|
30
|
-
*
|
|
31
|
-
* SEPARATE FROM `setPageHandler` BECAUSE THE TWO FACTS CAME APART. Readiness
|
|
32
|
-
* means "phase 2 finished"; the page handler means "this service renders pages
|
|
33
|
-
* server-side". Every service was SSR, so one flag honestly carried both — until
|
|
34
|
-
* `render_mode=client` (`granular runtime`) made a service that completes phase 2
|
|
35
|
-
* and never registers an SSR handler.
|
|
36
|
-
*
|
|
37
|
-
* Leaving readiness inside `setPageHandler` made such a service PERMANENTLY
|
|
38
|
-
* un-ready: `/health` answered `{"status":"starting"}` forever while the process
|
|
39
|
-
* was healthy and serving. That is the failure `readiness-gated-boot` is written
|
|
40
|
-
* against — a service must be "binary: fully-ready or cleanly-unavailable", and
|
|
41
|
-
* a never-ready health signal makes the activator's wake gate and every
|
|
42
|
-
* health-gated router treat a working service as down.
|
|
43
|
-
*
|
|
44
|
-
* Measured 2026-08-07 on scala-agents-ui: boot completed in 5023ms, "Full app
|
|
45
|
-
* built: 50 block(s)" logged, `GET /` correctly 302'd to sign-in, and `/health`
|
|
46
|
-
* still reported starting — while three untouched UI services reported ok.
|
|
47
|
-
*/
|
|
48
|
-
export declare function markFullAppReady(): void;
|
|
49
|
-
/**
|
|
50
|
-
* Reset both phase-2 flags. TEST-ONLY.
|
|
51
|
-
*
|
|
52
|
-
* `fullAppReady` is module state that only ever transitions false -> true in
|
|
53
|
-
* production, and Bun shares a module instance across every test file in a run —
|
|
54
|
-
* so the SSR readiness test and the client-only readiness test contaminate each
|
|
55
|
-
* other purely by file order. Splitting them across files does NOT isolate them;
|
|
56
|
-
* it only hides the coupling until CI runs them together.
|
|
57
|
-
*
|
|
58
|
-
* A test that passes alone and fails in a suite is worse than no test, so the
|
|
59
|
-
* reset is exported rather than left as an ordering convention nobody can see.
|
|
60
|
-
* Never called from production code — `setPageHandler`/`markFullAppReady` are
|
|
61
|
-
* the only writers on the boot path.
|
|
62
|
-
*/
|
|
63
|
-
export declare function __resetPhase2StateForTest(): void;
|
|
64
|
-
/**
|
|
65
|
-
* Get the current page handler state.
|
|
66
|
-
*/
|
|
67
|
-
export declare function getPageHandlerState(): {
|
|
68
|
-
ready: boolean;
|
|
69
|
-
hasHandler: boolean;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* `/health` for a UI service — 200 ONLY once the full app can actually render
|
|
73
|
-
* a page, 503 before that.
|
|
74
|
-
*
|
|
75
|
-
* This endpoint is not decoration: it is the wake gate for every scale-to-zero
|
|
76
|
-
* app. `scala-activator` (`@teamscala/scale-to-zero`) holds the client's TCP
|
|
77
|
-
* connection through a cold wake and pipes it the instant `isHealthy(port)` —
|
|
78
|
-
* a plain `GET /health` — returns ok, which is what `scale-to-zero-apps-sleep-
|
|
79
|
-
* on-demand` means by "`/health`-gates the wake (the client never sees a boot
|
|
80
|
-
* 503)".
|
|
81
|
-
*
|
|
82
|
-
* It previously answered a flat `{status:"ok"}` as soon as the MINIMAL app was
|
|
83
|
-
* serving, because the readiness gate flips ready after phase 1 so the ORPC/MCP
|
|
84
|
-
* surface can accept traffic early. But phase 1 CANNOT render: the phase-1 page
|
|
85
|
-
* handler below returns 503 until `setPageHandler` runs at the phase-2 swap. So
|
|
86
|
-
* `/health` reported ready while every page 503'd, the activator believed the
|
|
87
|
-
* wake had landed, and it piped the customer's first request straight into that
|
|
88
|
-
* window — the customer got the 503.
|
|
89
|
-
*
|
|
90
|
-
* Measured 2026-07-31 on quiz-dev/sign-dev: the activator logged `awake` for
|
|
91
|
-
* scala-quiz at 05:58:25.446 and the app logged `GET / 503 3ms` at 05:58:25.452
|
|
92
|
-
* — 6ms later, and 1004ms BEFORE "Swapped from minimal app to full app". Nine
|
|
93
|
-
* such 503s on scala-quiz and two on scala-sign, every one 0-23ms (the
|
|
94
|
-
* placeholder, which does no render work). scala-public logged ZERO, which is
|
|
95
|
-
* the whole reason it looked healthy while the other two did not: the gap is a
|
|
96
|
-
* RACE whose width is the phase-1→phase-2 build time (1420ms cold, 137ms warm),
|
|
97
|
-
* not a config difference between the apps.
|
|
98
|
-
*
|
|
99
|
-
* Gating this on `fullAppReady` makes the signal honest for every consumer at
|
|
100
|
-
* once (the activator's wake gate, `poller-post-restart-health-gate`, any
|
|
101
|
-
* health-gated router) rather than teaching each one its own probe, and it is
|
|
102
|
-
* what `readiness-gated-boot` already requires: "/health returns 503 until
|
|
103
|
-
* ready, 200 after — so it is the real readiness signal", a service being
|
|
104
|
-
* "binary: fully-ready or cleanly-unavailable". A UI service that cannot render
|
|
105
|
-
* is not ready, per `liveness-by-capability-not-process-existence` — liveness is
|
|
106
|
-
* a probe of the capability being REQUESTED, never of process existence or of
|
|
107
|
-
* some other surface that happens to answer.
|
|
108
|
-
*
|
|
109
|
-
* The early readiness-gate flip is deliberately left alone: it gates the ORPC
|
|
110
|
-
* tool surface, which genuinely IS usable at phase 1. Only this endpoint, whose
|
|
111
|
-
* one consumer contract is "can you serve me a page", is moved to phase 2.
|
|
112
|
-
*/
|
|
113
|
-
export declare function healthHandler(c: Context): Response;
|
|
114
|
-
export interface MinimalAppResult {
|
|
115
|
-
app: Hono;
|
|
116
|
-
mountRegistry: Awaited<ReturnType<typeof mountServerPackages>>;
|
|
117
|
-
apiRouteCount: number;
|
|
118
|
-
wsRouteCount: number;
|
|
119
|
-
pageRouteCount: number;
|
|
120
|
-
config: ServiceInstallConfig;
|
|
121
|
-
serviceSlug: string;
|
|
122
|
-
databaseUrl: string;
|
|
123
|
-
blockPackages: string[];
|
|
124
|
-
components: Record<string, unknown>;
|
|
125
|
-
loaded: string[];
|
|
126
|
-
skipped: string[];
|
|
127
|
-
}
|
|
128
|
-
export interface FullAppResult {
|
|
129
|
-
app: Hono;
|
|
130
|
-
blocks: {
|
|
131
|
-
slug: string;
|
|
132
|
-
packagePath: string;
|
|
133
|
-
}[];
|
|
134
|
-
routes: string[];
|
|
135
|
-
pgBossJobs: Array<{
|
|
136
|
-
handlerSlug: string;
|
|
137
|
-
}>;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Build the minimal tool-only app. This excludes the expensive operations:
|
|
141
|
-
* - Client asset building (Vite build)
|
|
142
|
-
* - Boot hooks (may have expensive initialization)
|
|
143
|
-
* - Scheduled jobs (can start later)
|
|
144
|
-
* - pg-boss (can start later)
|
|
145
|
-
*
|
|
146
|
-
* CRITICAL: All route registration MUST happen here before serving, because
|
|
147
|
-
* Hono's RegExpRouter compiles on the first request and becomes immutable.
|
|
148
|
-
* Once compiled, no new routes can be added. So we include:
|
|
149
|
-
* - Block discovery and page routes (registers all page paths)
|
|
150
|
-
* - All other routes (API, WS, data, static assets)
|
|
151
|
-
*
|
|
152
|
-
* The minimal app includes everything needed for MCP tools and ORPC:
|
|
153
|
-
* - Error handling, readiness gate, health check
|
|
154
|
-
* - Security headers, CORS, compression, timing
|
|
155
|
-
* - Content gate access, auth gates, static assets
|
|
156
|
-
* - ORPC router, API routes, WS routes, data routes, page routes
|
|
157
|
-
*/
|
|
158
|
-
export declare function buildMinimalApp(config: ServiceInstallConfig, serviceSlug: string, databaseUrl: string): Promise<MinimalAppResult>;
|
|
159
|
-
/**
|
|
160
|
-
* Build the full app with hydration. This adds the expensive operations that
|
|
161
|
-
* were deferred from the minimal app:
|
|
162
|
-
* - Client asset building (Vite build)
|
|
163
|
-
* - Boot hooks (may have expensive initialization)
|
|
164
|
-
* - Scheduled jobs (can start later)
|
|
165
|
-
* - pg-boss (can start later)
|
|
166
|
-
*
|
|
167
|
-
* This runs in the background after the minimal app is already serving.
|
|
168
|
-
* NOTE: All routes (including page routes) are already registered in Phase 1,
|
|
169
|
-
* so we don't need to modify the app here. The app reference stays the same.
|
|
170
|
-
*/
|
|
171
|
-
export declare function buildFullApp(minimalResult: MinimalAppResult, deps: PageServerDeps): Promise<FullAppResult>;
|
|
172
|
-
/**
|
|
173
|
-
* Swap the minimal app for the full app. This atomically replaces the
|
|
174
|
-
* app reference that Bun.serve is using.
|
|
175
|
-
*/
|
|
176
|
-
export declare function swapToFullApp(fullApp: Hono, serviceSlug: string): void;
|
package/src/types.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @system service-boot
|
|
3
|
-
* @status handwritten
|
|
4
|
-
* @edit edit directly
|
|
5
|
-
*
|
|
6
|
-
* Shared type definitions for service-boot boot helpers.
|
|
7
|
-
*/
|
|
8
|
-
type RendererComponent = (props: Record<string, unknown>) => unknown;
|
|
9
|
-
export interface RendererComponentEntry {
|
|
10
|
-
render: RendererComponent;
|
|
11
|
-
fields?: Record<string, {
|
|
12
|
-
type: string;
|
|
13
|
-
}>;
|
|
14
|
-
/** block_schema.defaults, carried onto the entry by discoverBlocks so
|
|
15
|
-
* buildPuckConfig merges them under authored props at SSR
|
|
16
|
-
* (blocks-fully-programmable). */
|
|
17
|
-
defaultProps?: Record<string, unknown>;
|
|
18
|
-
}
|
|
19
|
-
export interface PageHandlerExtras {
|
|
20
|
-
htmlTemplate: string;
|
|
21
|
-
userId?: string;
|
|
22
|
-
orgId?: string;
|
|
23
|
-
searchParams?: Record<string, string>;
|
|
24
|
-
nonce?: string;
|
|
25
|
-
}
|
|
26
|
-
export type CreatePageHandler = (config: PageHandlerConfig) => (request: Request, extras: PageHandlerExtras) => Promise<Response>;
|
|
27
|
-
export interface PageHandlerConfig {
|
|
28
|
-
components: Record<string, RendererComponentEntry>;
|
|
29
|
-
providers?: string[];
|
|
30
|
-
loadData: (request: Request) => Promise<unknown>;
|
|
31
|
-
renderMode?: "public" | "portals" | "utility";
|
|
32
|
-
/**
|
|
33
|
-
* Owning service slug — used by the page-server render catch to resolve
|
|
34
|
-
* the branded logo on the render-error page. Mirrors service-runtime's
|
|
35
|
-
* PageHandlerConfig.
|
|
36
|
-
*/
|
|
37
|
-
serviceSlug?: string;
|
|
38
|
-
/**
|
|
39
|
-
* Redirect a signed-in user's `/` to their org-scoped portal dashboard.
|
|
40
|
-
* Set only for services serving a `/*` catchall page_route (the portal);
|
|
41
|
-
* single-site portal-mode services serve their real page at `/`.
|
|
42
|
-
* Mirrors service-runtime's PageHandlerConfig (1.15.82).
|
|
43
|
-
*/
|
|
44
|
-
portalHomeRedirect?: boolean;
|
|
45
|
-
}
|
|
46
|
-
export type { ServiceInstallConfig } from "@teamscala/db/registry/loader/load-service-install-row";
|
package/src/ui-service.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @system ui-service-boot
|
|
3
|
-
* @status handwritten
|
|
4
|
-
* @edit edit directly
|
|
5
|
-
*
|
|
6
|
-
* Boots a `kind: "ui"` service. Reads the service_install registry row and
|
|
7
|
-
* orchestrates a fixed pipeline of single-purpose stages onto one Hono app
|
|
8
|
-
* served by @teamscala/service-runtime/serve (one Bun.serve in dev and prod).
|
|
9
|
-
*/
|
|
10
|
-
import { Hono } from "hono";
|
|
11
|
-
import type { ServiceInstallConfig } from "./load-service-install-row.ts";
|
|
12
|
-
export interface ResolvedBlock {
|
|
13
|
-
slug: string;
|
|
14
|
-
packagePath: string;
|
|
15
|
-
}
|
|
16
|
-
export interface UiServiceBootResult {
|
|
17
|
-
kind: "ui";
|
|
18
|
-
blocks: ResolvedBlock[];
|
|
19
|
-
routes: string[];
|
|
20
|
-
port: number;
|
|
21
|
-
app: Hono;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Page-server symbols injected by the caller. service-boot is tier 4
|
|
25
|
-
* (server) and must not import from tier 2 (`@teamscala/service-runtime`)
|
|
26
|
-
* per `installer-and-runtime` Rule 1. The runtime's bin entrypoint
|
|
27
|
-
* boot pipeline imports these from `page-server/` (same package —
|
|
28
|
-
* legal) and passes them down here.
|
|
29
|
-
*/
|
|
30
|
-
export interface PageServerDeps {
|
|
31
|
-
createPageHandler: import("./types.ts").CreatePageHandler;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Boots a UI service using two-phase boot for fast availability.
|
|
35
|
-
*
|
|
36
|
-
* Phase 1 (fast): Build and serve minimal tool-only app (ORPC, data routes,
|
|
37
|
-
* auth gates). This becomes available within ~10s, enabling the MCP tool
|
|
38
|
-
* surface to accept requests immediately after restart.
|
|
39
|
-
*
|
|
40
|
-
* Phase 2 (background): Build full app (pages, hydration) and atomically swap
|
|
41
|
-
* it in. The readiness gate flips to ready after Phase 1, not Phase 2.
|
|
42
|
-
*
|
|
43
|
-
* The interim mitigation (503 + gateway retry + circuit breaker) remains in
|
|
44
|
-
* place and is NOT undone.
|
|
45
|
-
*/
|
|
46
|
-
export declare function bootUiService(config: ServiceInstallConfig, serviceSlug: string, deps: PageServerDeps, databaseUrl: string): Promise<UiServiceBootResult>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @system server-boot
|
|
3
|
-
* @status handwritten
|
|
4
|
-
* @edit edit directly
|
|
5
|
-
*
|
|
6
|
-
* Post-listen WebSocket self-test. Runs after serveStart binds the port.
|
|
7
|
-
* For each declared websocket_routes path, opens a synthetic WebSocket
|
|
8
|
-
* connection and asserts 101 upgrade. Non-101 → BootFatalError.
|
|
9
|
-
*
|
|
10
|
-
* This catches the class of bugs where:
|
|
11
|
-
* - WS route registered after ORPC catch-all (order-dependent 404)
|
|
12
|
-
* - fetchWithPeerPort clones the Request on WS upgrade (breaks Bun.upgrade identity)
|
|
13
|
-
* - websocket_routes config row is stale / missing a handler
|
|
14
|
-
*
|
|
15
|
-
* Runs synchronously after serveStart so the boot aborts before the service
|
|
16
|
-
* reports healthy.
|
|
17
|
-
*/
|
|
18
|
-
import type { ServiceInstallConfig } from "@teamscala/db/registry/loader/load-service-install-row";
|
|
19
|
-
export declare function runWsBootSelfTest(config: ServiceInstallConfig, serviceSlug: string, port: number): Promise<void>;
|