@hearsay-tools/squawk 0.19.0-pr4456.8755 → 0.19.0-pr4457.8764
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boot.js +2 -0
- package/dist/boot.js.map +1 -1
- package/dist/built-in-http-routes.d.ts +10 -0
- package/dist/built-in-http-routes.js +41 -0
- package/dist/built-in-http-routes.js.map +1 -0
- package/dist/contract/automation-requests.d.ts +4 -0
- package/dist/core/http-route-registry.d.ts +28 -5
- package/dist/core/http-route-registry.js +37 -9
- package/dist/core/http-route-registry.js.map +1 -1
- package/dist/plugin/api.js +3 -1
- package/dist/plugin/api.js.map +1 -1
- package/dist/plugin/index.d.ts +1 -1
- package/dist/plugin/index.js.map +1 -1
- package/dist/server/live-routes.d.ts +6 -6
- package/dist/server/plugin-http-routes.d.ts +29 -4
- package/dist/server/plugin-http-routes.js +100 -13
- package/dist/server/plugin-http-routes.js.map +1 -1
- package/dist/server/providers-routes.d.ts +7 -7
- package/dist/server/repo-routes.d.ts +13 -13
- package/dist/server/runs-routes.d.ts +16 -16
- package/dist/server/server.d.ts +2783 -5583
- package/dist/server/server.js +39 -59
- package/dist/server/server.js.map +1 -1
- package/dist/server/ws.d.ts +6 -0
- package/dist/server/ws.js +41 -0
- package/dist/server/ws.js.map +1 -1
- package/package.json +4 -4
package/dist/boot.js
CHANGED
|
@@ -49,6 +49,7 @@ async function sealRuntime({ pluginsDir, bundledRunnersDir, bundledFeaturesDir,
|
|
|
49
49
|
registerBuiltInCliCommands();
|
|
50
50
|
const { registerBuiltInRunSlots, sealBuiltInRunSlots } = await import('./built-in-run-slots.js');
|
|
51
51
|
const { registerBuiltInLaunchParts, sealBuiltInLaunchParts } = await import('./built-in-launch-parts.js');
|
|
52
|
+
const { registerBuiltInHttpRoutes } = await import('./built-in-http-routes.js');
|
|
52
53
|
const { registerBuiltInStepKinds, sealBuiltInStepKinds } = await import('./workflows/step-kind-registry.js');
|
|
53
54
|
const { registerBuiltInTools, sealBuiltInTools } = await import('./built-in-tools.js');
|
|
54
55
|
const { registerBuiltInWaitKinds, sealBuiltInWaitKinds } = await import('./built-in-wait-kinds.js');
|
|
@@ -58,6 +59,7 @@ async function sealRuntime({ pluginsDir, bundledRunnersDir, bundledFeaturesDir,
|
|
|
58
59
|
const loader = await import('./plugin/loader.js');
|
|
59
60
|
registerBuiltInRunSlots();
|
|
60
61
|
registerBuiltInLaunchParts();
|
|
62
|
+
registerBuiltInHttpRoutes();
|
|
61
63
|
registerBuiltInStepKinds();
|
|
62
64
|
registerBuiltInTools();
|
|
63
65
|
registerBuiltInWaitKinds();
|
package/dist/boot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot.js","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAGpE;;;GAGG;AACH,MAAM,UAAU,WAAW;IACzB,0BAA0B,EAAE,CAAC;IAC7B,sBAAsB,EAAE,CAAC;AAC3B,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,cAAc,CAAC,IAAgB,EAAE,IAAI,GAA2B,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;IACzG,IAAI,CAAC;QACH,OAAO,IAAI,EAAE,CAAC,OAAO,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,oCAAoC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACjI,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAwBD,IAAI,WAAsC,CAA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,EAAE,CAAC,CAAC,CAAC;IACxE,MAAM,CAAC,mBAAmB,KAAK,MAAM,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC/E,IAAI,UAAU,KAAK,SAAS,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACnD,iBAAiB,GAAG,IAAI,CAAC;QACzB,MAAM,MAAM,CAAC,gBAAgB,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,UAAU,EAAE,EAAE,CAAC;IACrB,sBAAsB,EAAE,CAAC;IACzB,cAAc,EAAE,CAAC;IACjB,WAAW,EAAE,CAAC;IACd,mBAAmB,EAAE,CAAC;IACtB,sBAAsB,EAAE,CAAC;IACzB,oBAAoB,EAAE,CAAC;IACvB,gBAAgB,EAAE,CAAC;IACnB,oBAAoB,EAAE,CAAC;IACvB,yBAAyB,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Temporary built-in HTTP route bundle registrations for automations (hearsay-tools/squawk#4441).
|
|
3
|
+
* Moves into `features/automations/index.ts` and is deleted in `hearsay-tools/squawk#4444`.
|
|
4
|
+
*/
|
|
5
|
+
import { type HttpBundleRouteDefinition, type HttpRouteDefinition } from './core/http-route-registry.ts';
|
|
6
|
+
export declare const automationsHttpRoute: HttpBundleRouteDefinition;
|
|
7
|
+
export declare const automationChecksHttpRoute: HttpBundleRouteDefinition;
|
|
8
|
+
export declare const BUILT_IN_HTTP_ROUTES: readonly HttpRouteDefinition[];
|
|
9
|
+
/** Register the temporary built-in HTTP routes. Idempotent for the same objects. */
|
|
10
|
+
export declare function registerBuiltInHttpRoutes(): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Temporary built-in HTTP route bundle registrations for automations (hearsay-tools/squawk#4441).
|
|
3
|
+
* Moves into `features/automations/index.ts` and is deleted in `hearsay-tools/squawk#4444`.
|
|
4
|
+
*/
|
|
5
|
+
import { registerHttpRoute, } from './core/http-route-registry.js';
|
|
6
|
+
import { createAutomationsRouteBundles } from './server/automations-routes.js';
|
|
7
|
+
const bundlesByBridge = new WeakMap();
|
|
8
|
+
function automationsBundles(context) {
|
|
9
|
+
const bridge = context.appBridge;
|
|
10
|
+
if (!bridge || typeof bridge !== 'object') {
|
|
11
|
+
throw new Error('HTTP routes: automations bundle requires server app context.');
|
|
12
|
+
}
|
|
13
|
+
let created = bundlesByBridge.get(bridge);
|
|
14
|
+
if (!created) {
|
|
15
|
+
created = createAutomationsRouteBundles(bridge);
|
|
16
|
+
bundlesByBridge.set(bridge, created);
|
|
17
|
+
}
|
|
18
|
+
return created;
|
|
19
|
+
}
|
|
20
|
+
export const automationsHttpRoute = {
|
|
21
|
+
kind: 'bundle',
|
|
22
|
+
id: 'automations',
|
|
23
|
+
scope: 'project',
|
|
24
|
+
createRoutes: (context) => automationsBundles(context).automationsRoutes,
|
|
25
|
+
};
|
|
26
|
+
export const automationChecksHttpRoute = {
|
|
27
|
+
kind: 'bundle',
|
|
28
|
+
id: 'automation-checks',
|
|
29
|
+
scope: 'workspace',
|
|
30
|
+
createRoutes: (context) => automationsBundles(context).automationChecksRoutes,
|
|
31
|
+
};
|
|
32
|
+
export const BUILT_IN_HTTP_ROUTES = [
|
|
33
|
+
automationsHttpRoute,
|
|
34
|
+
automationChecksHttpRoute,
|
|
35
|
+
];
|
|
36
|
+
/** Register the temporary built-in HTTP routes. Idempotent for the same objects. */
|
|
37
|
+
export function registerBuiltInHttpRoutes() {
|
|
38
|
+
for (const route of BUILT_IN_HTTP_ROUTES)
|
|
39
|
+
registerHttpRoute(route);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=built-in-http-routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built-in-http-routes.js","sourceRoot":"","sources":["../src/built-in-http-routes.ts"],"names":[],"mappings":"AAA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QAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -164,6 +164,7 @@ export declare const automationCreateSchema: z.ZodObject<{
|
|
|
164
164
|
}, z.core.$strict>;
|
|
165
165
|
enable: z.ZodOptional<z.ZodBoolean>;
|
|
166
166
|
}, z.core.$strict>;
|
|
167
|
+
export type AutomationCreateRequest = z.input<typeof automationCreateSchema>;
|
|
167
168
|
export declare const automationUpdateSchema: z.ZodObject<{
|
|
168
169
|
name: z.ZodString;
|
|
169
170
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -244,12 +245,14 @@ export declare const automationUpdateSchema: z.ZodObject<{
|
|
|
244
245
|
}, z.core.$strict>;
|
|
245
246
|
expectedRevision: z.ZodNumber;
|
|
246
247
|
}, z.core.$strict>;
|
|
248
|
+
export type AutomationUpdateRequest = z.input<typeof automationUpdateSchema>;
|
|
247
249
|
export declare const automationCheckRequestSchema: z.ZodObject<{
|
|
248
250
|
mode: z.ZodEnum<{
|
|
249
251
|
execute: "execute";
|
|
250
252
|
preview: "preview";
|
|
251
253
|
}>;
|
|
252
254
|
}, z.core.$strict>;
|
|
255
|
+
export type AutomationCheckRequest = z.input<typeof automationCheckRequestSchema>;
|
|
253
256
|
export declare const automationLogQuerySchema: z.ZodObject<{
|
|
254
257
|
automationId: z.ZodOptional<z.ZodString>;
|
|
255
258
|
result: z.ZodOptional<z.ZodEnum<{
|
|
@@ -276,3 +279,4 @@ export declare const automationLogQuerySchema: z.ZodObject<{
|
|
|
276
279
|
cursor: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
277
280
|
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
278
281
|
}, z.core.$strip>;
|
|
282
|
+
export type AutomationLogQuery = z.output<typeof automationLogQuerySchema>;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Follows the register → seal → read lifecycle of `core/registry.ts`.
|
|
4
|
-
* outside `AppType` RPC inference, behind the global `/api/*`
|
|
5
|
-
* SPA catch-all.
|
|
2
|
+
* Plugin HTTP route registry for bundled features and plugins (hearsay-tools/squawk#4402,
|
|
3
|
+
* hearsay-tools/squawk#4441). Follows the register → seal → read lifecycle of `core/registry.ts`.
|
|
4
|
+
* Routes mounted here sit outside `AppType` RPC inference, behind the global `/api/*`
|
|
5
|
+
* request-origin guard and before the SPA catch-all.
|
|
6
6
|
*/
|
|
7
|
+
import type { Hono } from 'hono';
|
|
7
8
|
import type { Home } from '../home/home.ts';
|
|
8
9
|
export declare const HTTP_ROUTE_METHODS: readonly ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ALL'];
|
|
9
10
|
export type HttpRouteMethod = typeof HTTP_ROUTE_METHODS[number];
|
|
11
|
+
export declare const HTTP_ROUTE_SCOPES: readonly ['project', 'workspace'];
|
|
12
|
+
export type HttpRouteScope = typeof HTTP_ROUTE_SCOPES[number];
|
|
10
13
|
export interface HttpRouteContext {
|
|
11
14
|
readonly home: Home;
|
|
12
15
|
readonly version: string;
|
|
@@ -15,7 +18,15 @@ export interface HttpRouteContext {
|
|
|
15
18
|
/** Invoke the cockpit HTTP app in-process (synthetic loopback Host, no Origin). */
|
|
16
19
|
fetchApp(request: Request): Promise<Response>;
|
|
17
20
|
}
|
|
18
|
-
export interface
|
|
21
|
+
export interface HttpRouteBundleContext extends HttpRouteContext {
|
|
22
|
+
/**
|
|
23
|
+
* Opaque per-app bridge for server-scoped route bundles until server lifecycle hooks
|
|
24
|
+
* (`hearsay-tools/squawk#4442`) replace it with `ServerPluginContext`.
|
|
25
|
+
*/
|
|
26
|
+
readonly appBridge?: unknown;
|
|
27
|
+
}
|
|
28
|
+
export interface HttpHandlerRouteDefinition {
|
|
29
|
+
readonly kind?: 'handler' | undefined;
|
|
19
30
|
readonly id: string;
|
|
20
31
|
readonly method: HttpRouteMethod;
|
|
21
32
|
/** Must start with `/api/v1/`. */
|
|
@@ -27,6 +38,18 @@ export interface HttpRouteDefinition {
|
|
|
27
38
|
readonly managesBodyLimit?: boolean | undefined;
|
|
28
39
|
handle(request: Request, context: HttpRouteContext): Response | Promise<Response>;
|
|
29
40
|
}
|
|
41
|
+
export interface HttpBundleRouteDefinition {
|
|
42
|
+
readonly kind: 'bundle';
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly scope: HttpRouteScope;
|
|
45
|
+
/**
|
|
46
|
+
* Build the Hono sub-app mounted under `/api/v1/p/:projectId` and `/api/v1` (when `scope` is
|
|
47
|
+
* `'project'`) or under `/api/v1` only (when `scope` is `'workspace'`).
|
|
48
|
+
*/
|
|
49
|
+
createRoutes(context: HttpRouteBundleContext): Hono<any, any, any>;
|
|
50
|
+
}
|
|
51
|
+
export type HttpRouteDefinition = HttpHandlerRouteDefinition | HttpBundleRouteDefinition;
|
|
52
|
+
export declare function isHttpBundleRoute(route: HttpRouteDefinition): route is HttpBundleRouteDefinition;
|
|
30
53
|
/** Throws what `registerHttpRoute` would throw, without writing. */
|
|
31
54
|
export declare function checkHttpRouteRegistration(route: HttpRouteDefinition): void;
|
|
32
55
|
export declare function registerHttpRoute(route: HttpRouteDefinition): void;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { createKeyedRegistry } from './registry.js';
|
|
2
2
|
export const HTTP_ROUTE_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ALL'];
|
|
3
|
+
export const HTTP_ROUTE_SCOPES = ['project', 'workspace'];
|
|
4
|
+
export function isHttpBundleRoute(route) {
|
|
5
|
+
return route.kind === 'bundle';
|
|
6
|
+
}
|
|
3
7
|
const API_V1_PREFIX = '/api/v1/';
|
|
4
8
|
const routes = createKeyedRegistry({
|
|
5
9
|
name: 'HTTP routes',
|
|
6
10
|
bootHint: 'register every HTTP route, then call sealHttpRoutes() at the runtime boot boundary (boot.ts), or import a testkit that seals it.',
|
|
7
11
|
});
|
|
8
12
|
const claimedPaths = new Map();
|
|
9
|
-
function
|
|
10
|
-
if (typeof route !== 'object' || route === null)
|
|
11
|
-
throw new Error('HTTP routes: a route definition must be an object.');
|
|
12
|
-
if (typeof route.id !== 'string' || route.id.length === 0)
|
|
13
|
-
throw new Error(`HTTP routes: invalid id ${JSON.stringify(route.id)}.`);
|
|
13
|
+
function checkHandlerShape(route) {
|
|
14
14
|
if (!HTTP_ROUTE_METHODS.includes(route.method)) {
|
|
15
15
|
throw new Error(`HTTP routes: '${route.id}' has unsupported method ${JSON.stringify(route.method)}.`);
|
|
16
16
|
}
|
|
@@ -23,19 +23,47 @@ function checkShape(route) {
|
|
|
23
23
|
if (typeof route.handle !== 'function')
|
|
24
24
|
throw new Error(`HTTP routes: '${route.id}' needs a handle function.`);
|
|
25
25
|
}
|
|
26
|
+
function checkBundleShape(route) {
|
|
27
|
+
if (!HTTP_ROUTE_SCOPES.includes(route.scope)) {
|
|
28
|
+
throw new Error(`HTTP routes: '${route.id}' has unsupported scope ${JSON.stringify(route.scope)}.`);
|
|
29
|
+
}
|
|
30
|
+
if (typeof route.createRoutes !== 'function') {
|
|
31
|
+
throw new Error(`HTTP routes: '${route.id}' needs a createRoutes function.`);
|
|
32
|
+
}
|
|
33
|
+
if (route.createRoutes.constructor?.name === 'AsyncFunction') {
|
|
34
|
+
throw new Error(`HTTP routes: '${route.id}' createRoutes must be synchronous.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function checkShape(route) {
|
|
38
|
+
if (typeof route !== 'object' || route === null)
|
|
39
|
+
throw new Error('HTTP routes: a route definition must be an object.');
|
|
40
|
+
if (typeof route.id !== 'string' || route.id.length === 0)
|
|
41
|
+
throw new Error(`HTTP routes: invalid id ${JSON.stringify(route.id)}.`);
|
|
42
|
+
if (route.kind === 'bundle') {
|
|
43
|
+
checkBundleShape(route);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (route.kind !== undefined && route.kind !== 'handler') {
|
|
47
|
+
throw new Error(`HTTP routes: '${route.id}' has unsupported kind ${JSON.stringify(route.kind)}.`);
|
|
48
|
+
}
|
|
49
|
+
checkHandlerShape(route);
|
|
50
|
+
}
|
|
26
51
|
/** Throws what `registerHttpRoute` would throw, without writing. */
|
|
27
52
|
export function checkHttpRouteRegistration(route) {
|
|
28
53
|
checkShape(route);
|
|
29
54
|
routes.check(route.id, route);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
55
|
+
if (!isHttpBundleRoute(route)) {
|
|
56
|
+
const owner = claimedPaths.get(route.path);
|
|
57
|
+
if (owner !== undefined && owner !== route) {
|
|
58
|
+
throw new Error(`HTTP routes: path '${route.path}' is already registered by '${owner.id}'.`);
|
|
59
|
+
}
|
|
33
60
|
}
|
|
34
61
|
}
|
|
35
62
|
export function registerHttpRoute(route) {
|
|
36
63
|
checkHttpRouteRegistration(route);
|
|
37
64
|
routes.register(route.id, route);
|
|
38
|
-
|
|
65
|
+
if (!isHttpBundleRoute(route))
|
|
66
|
+
claimedPaths.set(route.path, route);
|
|
39
67
|
}
|
|
40
68
|
export function sealHttpRoutes() { routes.seal(); }
|
|
41
69
|
/** Whether the registry is sealed. Never throws. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-route-registry.js","sourceRoot":"","sources":["../../src/core/http-route-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-route-registry.js","sourceRoot":"","sources":["../../src/core/http-route-registry.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAC;AAG5F,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,WAAW,CAAU,CAAC;AA+CnE,MAAM,UAAU,iBAAiB,CAAC,KAA0B;IAC1D,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AACjC,CAAC;AAED,MAAM,a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,UAAU,0BAA0B,CAAC,KAA0B;IACnE,UAAU,CAAC,KAAK,CAAC,CAAC;IAClB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC9B,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,CAAC,IAAI,+BAA+B,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAA0B;IAC1D,0BAA0B,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACjC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC;QAAE,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,cAAc,KAAW,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAEzD,oDAAoD;AACpD,MAAM,UAAU,gBAAgB,KAAc,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;AAEzE,gFAAgF;AAChF,MAAM,UAAU,oBAAoB;IAClC,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;AACzB,CAAC"}
|
package/dist/plugin/api.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { checkAgentToolRegistration, registerAgentTool } from '../ci-wait/tool-registry.js';
|
|
8
8
|
import { checkCliCommandRegistration, registerCliCommand } from '../core/cli-registry.js';
|
|
9
|
-
import { checkHttpRouteRegistration, registerHttpRoute } from '../core/http-route-registry.js';
|
|
9
|
+
import { checkHttpRouteRegistration, isHttpBundleRoute, registerHttpRoute } from '../core/http-route-registry.js';
|
|
10
10
|
import { checkLaunchPartRegistration, registerLaunchPart } from '../core/launch-registry.js';
|
|
11
11
|
import { checkRunnerRegistration, registerRunner } from '../core/runner-registry.js';
|
|
12
12
|
import { checkRunLifecycleListenerRegistration, registerRunLifecycleListener } from '../runs/lifecycle-registry.js';
|
|
@@ -77,6 +77,8 @@ function checkSlots(slots) {
|
|
|
77
77
|
function checkStagedHttpPaths(routes) {
|
|
78
78
|
const owners = new Map();
|
|
79
79
|
for (const route of routes) {
|
|
80
|
+
if (isHttpBundleRoute(route))
|
|
81
|
+
continue;
|
|
80
82
|
const owner = owners.get(route.path);
|
|
81
83
|
if (owner && owner !== route)
|
|
82
84
|
throw new Error(`HTTP routes: the plugin registers path '${route.path}' twice.`);
|
package/dist/plugin/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/plugin/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAA4B,MAAM,6BAA6B,CAAC;AACtH,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAA6B,MAAM,yBAAyB,CAAC;AACrH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAA4B,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/plugin/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAA4B,MAAM,6BAA6B,CAAC;AACtH,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAA6B,MAAM,yBAAyB,CAAC;AACrH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,iBAAiB,EAA4B,MAAM,gCAAgC,CAAC;AAC5I,OAAO,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AE,MAAM,CAAC,SAAS,CAAC,MAAM;QAC9C,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;KACvD,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAoB;IACvD,MAAM,MAAM,GAAiB,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IACzK,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,CAAC;YAAS,CAAC;QACT,IAAI,GAAG,KAAK,CAAC;IACf,CAAC;IACD,WAAW,CAAC,MAAM,CAAC,CAAC;IACpB,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type { AgentToolDefinition, AgentToolResult } from '../ci-wait/tool-regis
|
|
|
8
8
|
export type { WaitKindRow, WaitKindRegistration, WaitLifecycle, WaitInputDescriptor } from '../workflows/run/wait-kind-registry.ts';
|
|
9
9
|
export type { StepKindDefinition, StepKindContext, StepKindOutcome } from '../workflows/step-kind-registry.ts';
|
|
10
10
|
export type { CliCommandDefinition, RootCommandContext, SubcommandRunner } from '../core/cli-registry.ts';
|
|
11
|
-
export type { HttpRouteContext, HttpRouteDefinition, HttpRouteMethod } from '../core/http-route-registry.ts';
|
|
11
|
+
export type { HttpBundleRouteDefinition, HttpHandlerRouteDefinition, HttpRouteBundleContext, HttpRouteContext, HttpRouteDefinition, HttpRouteMethod, HttpRouteScope, } from '../core/http-route-registry.ts';
|
|
12
12
|
export type { RunSlots, DeletionGate, DeletionGateContext, DeletionKind, ReclaimPreparation, ReclaimContext, RemovalCleanup } from '../runs/removal-slots.ts';
|
|
13
13
|
export type { LaunchCockpitAddress, LaunchPartContext, LaunchPartContribution, LaunchPartDefinition } from '../core/launch-registry.ts';
|
|
14
14
|
export type { RunLifecycleHandlers, RunLifecycleHandler, RunLifecycleEvents, RunLifecycleEventType } from '../runs/lifecycle.ts';
|
package/dist/plugin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAsBA,cAAc,iBAAiB,CAAC"}
|
|
@@ -16,12 +16,6 @@ export declare function createLiveRoutes({ resolveProject, serverGeneration, res
|
|
|
16
16
|
output: {
|
|
17
17
|
generation: string;
|
|
18
18
|
results: ({
|
|
19
|
-
projectId: string;
|
|
20
|
-
runId: string;
|
|
21
|
-
type: "error" | "reset";
|
|
22
|
-
status: 400 | 404 | 409 | 413 | 503;
|
|
23
|
-
error: string;
|
|
24
|
-
} | {
|
|
25
19
|
projectId: string;
|
|
26
20
|
runId: string;
|
|
27
21
|
type: "batch";
|
|
@@ -42,6 +36,12 @@ export declare function createLiveRoutes({ resolveProject, serverGeneration, res
|
|
|
42
36
|
cursor: string;
|
|
43
37
|
afterSeq: number;
|
|
44
38
|
hasMore: boolean;
|
|
39
|
+
} | {
|
|
40
|
+
projectId: string;
|
|
41
|
+
runId: string;
|
|
42
|
+
type: "error" | "reset";
|
|
43
|
+
status: 400 | 404 | 409 | 413 | 503;
|
|
44
|
+
error: string;
|
|
45
45
|
})[];
|
|
46
46
|
};
|
|
47
47
|
outputFormat: "json";
|
|
@@ -1,21 +1,46 @@
|
|
|
1
1
|
import type { Hono } from 'hono';
|
|
2
2
|
import { type HttpRouteDefinition } from '../core/http-route-registry.ts';
|
|
3
3
|
import type { Home } from '../home/home.ts';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import type { ProjectApiEnv } from './server-types.ts';
|
|
5
|
+
export interface MountPluginHttpRoutesBaseInput {
|
|
6
6
|
home: Home;
|
|
7
7
|
version: string;
|
|
8
8
|
squawkPort?: (() => number | undefined) | undefined;
|
|
9
9
|
isHostedMode: () => boolean;
|
|
10
10
|
httpRoutes?: readonly HttpRouteDefinition[] | undefined;
|
|
11
11
|
}
|
|
12
|
+
export interface MountPluginRouteBundlesInput extends MountPluginHttpRoutesBaseInput {
|
|
13
|
+
app: Hono;
|
|
14
|
+
v1: Hono<ProjectApiEnv>;
|
|
15
|
+
workspaceV1: Hono;
|
|
16
|
+
v1Prefix: string;
|
|
17
|
+
v1ScopedPrefix: string;
|
|
18
|
+
/** Called for each mounted method+path of a project-scoped route bundle. */
|
|
19
|
+
onProjectRouteMounted?: ((methodAndPath: string) => void) | undefined;
|
|
20
|
+
/** Per-app bridge forwarded to route bundles until S2 introduces `ServerPluginContext`. */
|
|
21
|
+
appBridge?: unknown;
|
|
22
|
+
/** Receives one stderr line per skipped non-bundled bundle that fails to initialize. */
|
|
23
|
+
warn?: ((line: string) => void) | undefined;
|
|
24
|
+
}
|
|
25
|
+
export interface MountPluginHttpHandlersInput extends MountPluginHttpRoutesBaseInput {
|
|
26
|
+
routed: Hono;
|
|
27
|
+
}
|
|
12
28
|
/**
|
|
13
29
|
* Paths whose plugin route enforces its own auth and streaming body limit, so the global 32 MiB
|
|
14
30
|
* `bodyLimit` middleware skips them instead of pre-buffering unauthenticated chunked uploads.
|
|
15
31
|
*/
|
|
16
32
|
export declare function pluginManagedBodyLimitPaths(httpRoutes?: readonly HttpRouteDefinition[]): ReadonlySet<string>;
|
|
17
33
|
/**
|
|
18
|
-
* Mount
|
|
34
|
+
* Mount project-scoped and workspace-scoped plugin route bundles onto `v1` and `workspaceV1`
|
|
35
|
+
* AFTER those sub-apps fix their `AppType` types and BEFORE `app.route(...)` mounts them.
|
|
36
|
+
* That preserves single-pass project scope resolution (one `resolveProjectScope` per request),
|
|
37
|
+
* enforces unavailable-store and admission guards on every bundle route (including `.all()`),
|
|
38
|
+
* and isolates non-bundled (host) bundle factory failures so a broken host plugin never aborts
|
|
39
|
+
* cockpit startup.
|
|
40
|
+
*/
|
|
41
|
+
export declare function mountPluginRouteBundles(input: MountPluginRouteBundlesInput): void;
|
|
42
|
+
/**
|
|
43
|
+
* Mount single-path plugin HTTP handlers (hearsay-tools/squawk#4402) outside the `AppType` RPC
|
|
19
44
|
* chain, after the global `/api/*` request-origin guard and before the SPA catch-all.
|
|
20
45
|
*/
|
|
21
|
-
export declare function mountPluginHttpRoutes(input:
|
|
46
|
+
export declare function mountPluginHttpRoutes(input: MountPluginHttpHandlersInput): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { httpRoutesSealed, registeredHttpRoutes, } from '../core/http-route-registry.js';
|
|
1
|
+
import { httpRoutesSealed, isHttpBundleRoute, registeredHttpRoutes, } from '../core/http-route-registry.js';
|
|
2
|
+
import { pluginLoadReport } from '../plugin/loader.js';
|
|
2
3
|
/**
|
|
3
4
|
* Paths whose plugin route enforces its own auth and streaming body limit, so the global 32 MiB
|
|
4
5
|
* `bodyLimit` middleware skips them instead of pre-buffering unauthenticated chunked uploads.
|
|
@@ -7,19 +8,12 @@ export function pluginManagedBodyLimitPaths(httpRoutes) {
|
|
|
7
8
|
const routes = httpRoutes ?? (httpRoutesSealed() ? registeredHttpRoutes() : []);
|
|
8
9
|
const paths = new Set();
|
|
9
10
|
for (const route of routes) {
|
|
10
|
-
if (route.managesBodyLimit)
|
|
11
|
+
if (!isHttpBundleRoute(route) && route.managesBodyLimit)
|
|
11
12
|
paths.add(route.path);
|
|
12
13
|
}
|
|
13
14
|
return paths;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
* Mount non-RPC plugin HTTP routes (hearsay-tools/squawk#4402) outside the `AppType` RPC
|
|
17
|
-
* chain, after the global `/api/*` request-origin guard and before the SPA catch-all.
|
|
18
|
-
*/
|
|
19
|
-
export function mountPluginHttpRoutes(input) {
|
|
20
|
-
const pluginHttpRoutes = input.httpRoutes ?? (httpRoutesSealed() ? registeredHttpRoutes() : []);
|
|
21
|
-
if (pluginHttpRoutes.length === 0)
|
|
22
|
-
return;
|
|
16
|
+
function buildRouteContext(target, input, appBridge) {
|
|
23
17
|
const fetchApp = async (request) => {
|
|
24
18
|
const headers = new Headers(request.headers);
|
|
25
19
|
headers.delete('origin');
|
|
@@ -32,16 +26,109 @@ export function mountPluginHttpRoutes(input) {
|
|
|
32
26
|
...(body !== undefined ? { body } : {}),
|
|
33
27
|
signal: request.signal,
|
|
34
28
|
});
|
|
35
|
-
return
|
|
29
|
+
return target.fetch(internal);
|
|
36
30
|
};
|
|
37
|
-
|
|
31
|
+
return {
|
|
38
32
|
home: input.home,
|
|
39
33
|
version: input.version,
|
|
40
34
|
squawkPort: () => input.squawkPort?.(),
|
|
41
35
|
isHostedMode: input.isHostedMode,
|
|
42
36
|
fetchApp,
|
|
37
|
+
appBridge,
|
|
43
38
|
};
|
|
44
|
-
|
|
39
|
+
}
|
|
40
|
+
function errorText(error) {
|
|
41
|
+
if (error instanceof Error)
|
|
42
|
+
return error.message;
|
|
43
|
+
try {
|
|
44
|
+
return String(error);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return 'a thrown value with no string form';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function validateBundleSubApp(route, subApp) {
|
|
51
|
+
if ((typeof subApp === 'object' || typeof subApp === 'function') && subApp !== null && typeof subApp.then === 'function') {
|
|
52
|
+
// Consume any rejection from a JS plugin that returned a Promise/thenable so Node never terminates on unhandledRejection.
|
|
53
|
+
void Promise.resolve(subApp).catch(() => undefined);
|
|
54
|
+
throw new Error(`HTTP route bundle '${route.id}' createRoutes() must be synchronous and return a Hono instance.`);
|
|
55
|
+
}
|
|
56
|
+
if (typeof subApp !== 'object' || subApp === null || !Array.isArray(subApp.routes)) {
|
|
57
|
+
throw new Error(`HTTP route bundle '${route.id}' createRoutes() must return a Hono instance.`);
|
|
58
|
+
}
|
|
59
|
+
const app = subApp;
|
|
60
|
+
for (const entry of app.routes) {
|
|
61
|
+
if (entry.method === 'ALL' && (entry.path === '*' || entry.path === '/*')) {
|
|
62
|
+
throw new Error(`HTTP route bundle '${route.id}' cannot register a root wildcard handler ('${entry.path}').`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return app;
|
|
66
|
+
}
|
|
67
|
+
function bundledHttpRouteIds() {
|
|
68
|
+
const ids = new Set();
|
|
69
|
+
for (const plugin of pluginLoadReport().loaded) {
|
|
70
|
+
if (plugin.source !== 'bundled')
|
|
71
|
+
continue;
|
|
72
|
+
for (const id of plugin.contributions.httpRoutes)
|
|
73
|
+
ids.add(id);
|
|
74
|
+
}
|
|
75
|
+
return ids;
|
|
76
|
+
}
|
|
77
|
+
function joinMountedPath(prefix, path) {
|
|
78
|
+
return path === '/' ? prefix : `${prefix}${path}`;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Mount project-scoped and workspace-scoped plugin route bundles onto `v1` and `workspaceV1`
|
|
82
|
+
* AFTER those sub-apps fix their `AppType` types and BEFORE `app.route(...)` mounts them.
|
|
83
|
+
* That preserves single-pass project scope resolution (one `resolveProjectScope` per request),
|
|
84
|
+
* enforces unavailable-store and admission guards on every bundle route (including `.all()`),
|
|
85
|
+
* and isolates non-bundled (host) bundle factory failures so a broken host plugin never aborts
|
|
86
|
+
* cockpit startup.
|
|
87
|
+
*/
|
|
88
|
+
export function mountPluginRouteBundles(input) {
|
|
89
|
+
const pluginHttpRoutes = input.httpRoutes ?? (httpRoutesSealed() ? registeredHttpRoutes() : []);
|
|
90
|
+
const bundles = pluginHttpRoutes.filter(isHttpBundleRoute);
|
|
91
|
+
if (bundles.length === 0)
|
|
92
|
+
return;
|
|
93
|
+
const routeContext = buildRouteContext(input.app, input, input.appBridge);
|
|
94
|
+
const bundledIds = bundledHttpRouteIds();
|
|
95
|
+
const warn = input.warn ?? ((line) => { process.stderr.write(`${line}\n`); });
|
|
96
|
+
for (const route of bundles) {
|
|
97
|
+
let subApp;
|
|
98
|
+
try {
|
|
99
|
+
subApp = validateBundleSubApp(route, route.createRoutes(routeContext));
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (bundledIds.has(route.id))
|
|
103
|
+
throw error;
|
|
104
|
+
warn(`[hsq] plugin HTTP route bundle "${route.id}" skipped: ${errorText(error)}`);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (route.scope === 'project') {
|
|
108
|
+
const before = input.v1.routes.length;
|
|
109
|
+
input.v1.route('/', subApp);
|
|
110
|
+
for (const mounted of input.v1.routes.slice(before)) {
|
|
111
|
+
for (const prefix of [input.v1Prefix, input.v1ScopedPrefix]) {
|
|
112
|
+
input.onProjectRouteMounted?.(`${mounted.method} ${joinMountedPath(prefix, mounted.path)}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
input.workspaceV1.route('/', subApp);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Mount single-path plugin HTTP handlers (hearsay-tools/squawk#4402) outside the `AppType` RPC
|
|
123
|
+
* chain, after the global `/api/*` request-origin guard and before the SPA catch-all.
|
|
124
|
+
*/
|
|
125
|
+
export function mountPluginHttpRoutes(input) {
|
|
126
|
+
const pluginHttpRoutes = input.httpRoutes ?? (httpRoutesSealed() ? registeredHttpRoutes() : []);
|
|
127
|
+
const handlers = pluginHttpRoutes.filter((route) => !isHttpBundleRoute(route));
|
|
128
|
+
if (handlers.length === 0)
|
|
129
|
+
return;
|
|
130
|
+
const routeContext = buildRouteContext(input.routed, input);
|
|
131
|
+
for (const route of handlers) {
|
|
45
132
|
const handler = (c) => route.handle(c.req.raw, routeContext);
|
|
46
133
|
if (route.method === 'ALL')
|
|
47
134
|
input.routed.all(route.path, handler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-http-routes.js","sourceRoot":"","sources":["../../src/server/plugin-http-routes.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"plugin-http-routes.js","sourceRoot":"","sources":["../../src/server/plugin-http-routes.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GAIrB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA6BvD;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,UAA2C;IACrF,MAAM,MAAM,GAAG,UAAU,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAChF,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,gBAAgB;YAAE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAY,EAAE,KAAqC,EAAE,SAAmB;IACjG,MAAM,QAAQ,GAAG,KAAK,EAAE,OAAgB,EAAqB,EAAE;QAC7D,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACzB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