@hearsay-tools/squawk 0.19.0-dev.9137 → 0.19.0-dev.9155

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 (49) hide show
  1. package/dist/ci-wait/controller.d.ts +7 -7
  2. package/dist/contract/hosts.d.ts +254 -0
  3. package/dist/contract/index.js +35 -0
  4. package/dist/core/http-route-registry.d.ts +7 -4
  5. package/dist/core/http-route-registry.js +6 -0
  6. package/dist/core/http-route-registry.js.map +1 -1
  7. package/dist/features/automations/server-plugin.js.map +1 -1
  8. package/dist/features/hosts/bootstrap.d.ts +1 -0
  9. package/dist/features/hosts/bootstrap.js +18 -6
  10. package/dist/features/hosts/bootstrap.js.map +1 -1
  11. package/dist/features/hosts/gateway-routes.d.ts +14 -0
  12. package/dist/features/hosts/gateway-routes.js +20 -0
  13. package/dist/features/hosts/gateway-routes.js.map +1 -0
  14. package/dist/features/hosts/gateway.d.ts +105 -0
  15. package/dist/features/hosts/gateway.js +800 -0
  16. package/dist/features/hosts/gateway.js.map +1 -0
  17. package/dist/features/hosts/index.d.ts +7 -1
  18. package/dist/features/hosts/index.js +23 -16
  19. package/dist/features/hosts/index.js.map +1 -1
  20. package/dist/features/hosts/routes.d.ts +91 -2
  21. package/dist/features/hosts/routes.js +142 -11
  22. package/dist/features/hosts/routes.js.map +1 -1
  23. package/dist/features/hosts/supervisor.d.ts +22 -8
  24. package/dist/features/hosts/supervisor.js +94 -37
  25. package/dist/features/hosts/supervisor.js.map +1 -1
  26. package/dist/features/reports/routes.d.ts +2 -2
  27. package/dist/features/webhooks/server-plugin.js.map +1 -1
  28. package/dist/plugin/index.d.ts +1 -1
  29. package/dist/plugin/index.js.map +1 -1
  30. package/dist/server/activity-routes.d.ts +23 -23
  31. package/dist/server/checkout.d.ts +10 -0
  32. package/dist/server/checkout.js +1 -1
  33. package/dist/server/checkout.js.map +1 -1
  34. package/dist/server/create-project.d.ts +6 -0
  35. package/dist/server/create-project.js +1 -1
  36. package/dist/server/create-project.js.map +1 -1
  37. package/dist/server/plugin-http-routes.d.ts +18 -6
  38. package/dist/server/plugin-http-routes.js +30 -14
  39. package/dist/server/plugin-http-routes.js.map +1 -1
  40. package/dist/server/project-settings-routes.d.ts +107 -107
  41. package/dist/server/projects-routes.d.ts +41 -41
  42. package/dist/server/provider-sign-in-routes.d.ts +2 -2
  43. package/dist/server/runner-install-routes.d.ts +10 -10
  44. package/dist/server/runs-routes.d.ts +333 -333
  45. package/dist/server/server.d.ts +1170 -1170
  46. package/dist/server/server.js +10 -8
  47. package/dist/server/server.js.map +1 -1
  48. package/dist/server/workspace-identity-routes.d.ts +5 -5
  49. package/package.json +4 -4
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Main-server HTTP gateway for saved remote hosts (`ALL /api/v1/hosts/:hostId/api/v1/*`,
3
+ * spec § Architecture 3 & § 6, hearsay-tools/squawk#4540).
4
+ *
5
+ * Security & streaming invariants:
6
+ * - Mounted behind the global `/api/*` request-origin guard; skips global 32 MiB body buffering
7
+ * and main-server response compression so request and response bodies stream directly over the
8
+ * loopback SSH tunnel.
9
+ * - Request headers use a fixed allowlist only (never Origin, Cookie, Authorization, Sec-Fetch-*,
10
+ * or X-Forwarded-*), `Host` is always set to the remote loopback authority, and every forwarded
11
+ * request carrying a body is framed (validated `Content-Length` with exact-length enforcement,
12
+ * or explicit `Transfer-Encoding: chunked` for every method).
13
+ * - Response headers use a denylist (dropping hop-by-hop headers including `proxy-connection`,
14
+ * Connection-nominated headers, `set-cookie`, every `access-control-*` header,
15
+ * `strict-transport-security`, `clear-site-data`, `service-worker-allowed`, `alt-svc`,
16
+ * `refresh`, `www-authenticate`, and `location`) so security headers such as
17
+ * `content-security-policy` and `x-content-type-options` are never lost.
18
+ * - 3xx responses from the remote other than `304 Not Modified` are refused
19
+ * (`502 host-unexpected-redirect`).
20
+ * - WebSocket upgrades are never forwarded: real upgrade sockets are closed by
21
+ * `server/upgrade-router.ts` before reaching Hono; in-process or non-upgrade requests carrying
22
+ * `Upgrade` or `Connection: upgrade` receive `400 host-upgrade-unsupported`.
23
+ * - Every error response generated by the gateway carries `cache-control: no-store`.
24
+ */
25
+ import { type IncomingHttpHeaders, type OutgoingHttpHeaders } from 'node:http';
26
+ import { type HostEntry, type HostGatewayErrorCode, type HostState } from '../../contract/index.js';
27
+ import type { Home } from '../../home/home.ts';
28
+ import type { HostRuntimeSnapshot } from './supervisor.ts';
29
+ export declare const GATEWAY_CONNECT_TIMEOUT_MS = 10000;
30
+ /**
31
+ * Maximum idle wait with no write progress while streaming a request body to the upstream.
32
+ * Cleared when the request body ends and the response-headers deadline takes over.
33
+ */
34
+ export declare const GATEWAY_UPLOAD_IDLE_TIMEOUT_MS = 60000;
35
+ /**
36
+ * Maximum wait from end of request body until response headers arrive for read/poll methods
37
+ * (`GET` and `HEAD`; SSE streams send headers immediately so body duration is unbounded).
38
+ */
39
+ export declare const GATEWAY_READ_HEADERS_TIMEOUT_MS = 60000;
40
+ /**
41
+ * Maximum wait from end of request body until response headers arrive for non-read methods
42
+ * (exceeds the remote server's 600 s clone/create-project budgets). A dead tunnel is detected
43
+ * by SSH keep-alives and the supervisor within ~45 s and closes the upstream socket, so this
44
+ * deadline only bounds a remote server that hangs while its tunnel stays alive.
45
+ */
46
+ export declare const GATEWAY_MUTATION_HEADERS_TIMEOUT_MS = 630000;
47
+ /** Fixed allowlist of client request headers forwarded to a remote host server. */
48
+ export declare const GATEWAY_REQUEST_HEADER_ALLOWLIST: ReadonlySet<string>;
49
+ /** RFC 9110 hop-by-hop headers (plus legacy `proxy-connection`) never forwarded across the gateway. */
50
+ export declare const GATEWAY_HOP_BY_HOP_HEADERS: ReadonlySet<string>;
51
+ /** Origin-affecting response headers dropped so a remote cannot act on the main origin. */
52
+ export declare const GATEWAY_RESPONSE_HEADER_DENYLIST: ReadonlySet<string>;
53
+ export interface HostGatewaySupervisor {
54
+ getState(hostId: string): HostRuntimeSnapshot | undefined;
55
+ getTunnelPort(hostId: string): number | undefined;
56
+ ensureConnected(hostId: string, entry?: HostEntry): Promise<HostRuntimeSnapshot | undefined>;
57
+ syncHostEntry?(entry: HostEntry): void;
58
+ reconcile?(): void;
59
+ }
60
+ export interface HostGatewayOptions {
61
+ /** Maximum wait for on-demand `ensureConnected` inside a single gateway request. */
62
+ connectTimeoutMs?: number | undefined;
63
+ /** Maximum idle wait with no write progress while uploading a request body. */
64
+ uploadIdleTimeoutMs?: number | undefined;
65
+ /** Maximum wait for response headers on `GET`/`HEAD` requests (no body deadline). */
66
+ readHeadersTimeoutMs?: number | undefined;
67
+ /** Maximum wait for response headers on non-`GET`/`HEAD` requests (no body deadline). */
68
+ mutationHeadersTimeoutMs?: number | undefined;
69
+ }
70
+ type NonConnectedHostState = Exclude<HostState, 'connected'>;
71
+ export declare function gatewayErrorResponse(status: 400 | 404 | 409 | 502, body: {
72
+ error: string;
73
+ code?: HostGatewayErrorCode;
74
+ }): Response;
75
+ export declare function mapHostStateToGatewayError(state: NonConnectedHostState): Response;
76
+ /** True when the request asks for a WebSocket or other HTTP protocol upgrade. */
77
+ export declare function isGatewayUpgradeRequest(request: Request): boolean;
78
+ /**
79
+ * Extract `{ hostId, upstreamPath, normalizedPath }` from `/api/v1/hosts/:hostId/api/v1/*[?query]`.
80
+ * Matches the same decoded segments Hono's router matches (so `%68osts`, `%61pi`, `v%31` resolve
81
+ * consistently), while preserving the raw path to forward upstream.
82
+ */
83
+ export declare function parseGatewayTarget(requestUrl: string): {
84
+ hostId: string;
85
+ upstreamPath: string;
86
+ normalizedPath: string;
87
+ } | null;
88
+ /**
89
+ * True when an upstream path would re-enter a remote server's own host gateway, evaluated on the
90
+ * same decoded segments Hono's router matches (catching `%68osts`, `%61pi`, `v%31`, mixed-case hex).
91
+ */
92
+ export declare function isNestedGatewayPath(normalizedPath: string): boolean;
93
+ /** Build the outbound loopback request headers using the fixed allowlist only. */
94
+ export declare function buildForwardedRequestHeaders(request: Request, localPort: number): OutgoingHttpHeaders;
95
+ /**
96
+ * Copy every remote response header except the denylisted transport/origin headers.
97
+ * Adds zero headers of its own.
98
+ */
99
+ export declare function buildForwardedResponseHeaders(rawHeaders: IncomingHttpHeaders): Headers;
100
+ /** Handle one incoming gateway request to `ALL /api/v1/hosts/:hostId/api/v1/*`. */
101
+ export declare function handleHostGatewayRequest(request: Request, deps: {
102
+ home: Home;
103
+ supervisor: HostGatewaySupervisor | undefined;
104
+ }, options?: HostGatewayOptions): Promise<Response>;
105
+ export {};