@data-club/ai-hub-server 0.0.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.
- package/dist/auth/argon2.d.ts +72 -0
- package/dist/auth/argon2.d.ts.map +1 -0
- package/dist/auth/argon2.js +145 -0
- package/dist/auth/argon2.js.map +1 -0
- package/dist/auth/encryption.d.ts +52 -0
- package/dist/auth/encryption.d.ts.map +1 -0
- package/dist/auth/encryption.js +98 -0
- package/dist/auth/encryption.js.map +1 -0
- package/dist/auth/jwt.d.ts +133 -0
- package/dist/auth/jwt.d.ts.map +1 -0
- package/dist/auth/jwt.js +147 -0
- package/dist/auth/jwt.js.map +1 -0
- package/dist/auth/middleware.d.ts +101 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +161 -0
- package/dist/auth/middleware.js.map +1 -0
- package/dist/auth/passwordPolicy.d.ts +72 -0
- package/dist/auth/passwordPolicy.d.ts.map +1 -0
- package/dist/auth/passwordPolicy.js +88 -0
- package/dist/auth/passwordPolicy.js.map +1 -0
- package/dist/auth/roleRules.d.ts +200 -0
- package/dist/auth/roleRules.d.ts.map +1 -0
- package/dist/auth/roleRules.js +365 -0
- package/dist/auth/roleRules.js.map +1 -0
- package/dist/auth/userView.d.ts +55 -0
- package/dist/auth/userView.d.ts.map +1 -0
- package/dist/auth/userView.js +77 -0
- package/dist/auth/userView.js.map +1 -0
- package/dist/bootstrap.d.ts +104 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +160 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/db/connection.d.ts +39 -0
- package/dist/db/connection.d.ts.map +1 -0
- package/dist/db/connection.js +62 -0
- package/dist/db/connection.js.map +1 -0
- package/dist/db/migrate.d.ts +31 -0
- package/dist/db/migrate.d.ts.map +1 -0
- package/dist/db/migrate.js +197 -0
- package/dist/db/migrate.js.map +1 -0
- package/dist/db/schema.d.ts +1902 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +662 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/db/seed.d.ts +92 -0
- package/dist/db/seed.d.ts.map +1 -0
- package/dist/db/seed.js +160 -0
- package/dist/db/seed.js.map +1 -0
- package/dist/handlers/fetch.d.ts +89 -0
- package/dist/handlers/fetch.d.ts.map +1 -0
- package/dist/handlers/fetch.js +173 -0
- package/dist/handlers/fetch.js.map +1 -0
- package/dist/handlers/nextjs.d.ts +40 -0
- package/dist/handlers/nextjs.d.ts.map +1 -0
- package/dist/handlers/nextjs.js +42 -0
- package/dist/handlers/nextjs.js.map +1 -0
- package/dist/handlers/responses.d.ts +46 -0
- package/dist/handlers/responses.d.ts.map +1 -0
- package/dist/handlers/responses.js +74 -0
- package/dist/handlers/responses.js.map +1 -0
- package/dist/handlers/routeTable.d.ts +21 -0
- package/dist/handlers/routeTable.d.ts.map +1 -0
- package/dist/handlers/routeTable.js +133 -0
- package/dist/handlers/routeTable.js.map +1 -0
- package/dist/handlers/router.d.ts +37 -0
- package/dist/handlers/router.d.ts.map +1 -0
- package/dist/handlers/router.js +82 -0
- package/dist/handlers/router.js.map +1 -0
- package/dist/handlers/sse.d.ts +38 -0
- package/dist/handlers/sse.d.ts.map +1 -0
- package/dist/handlers/sse.js +52 -0
- package/dist/handlers/sse.js.map +1 -0
- package/dist/handlers/types.d.ts +96 -0
- package/dist/handlers/types.d.ts.map +1 -0
- package/dist/handlers/types.js +14 -0
- package/dist/handlers/types.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/letta/client.d.ts +355 -0
- package/dist/letta/client.d.ts.map +1 -0
- package/dist/letta/client.js +529 -0
- package/dist/letta/client.js.map +1 -0
- package/dist/letta/eventTranslator.d.ts +166 -0
- package/dist/letta/eventTranslator.d.ts.map +1 -0
- package/dist/letta/eventTranslator.js +532 -0
- package/dist/letta/eventTranslator.js.map +1 -0
- package/dist/letta/index.d.ts +13 -0
- package/dist/letta/index.d.ts.map +1 -0
- package/dist/letta/index.js +12 -0
- package/dist/letta/index.js.map +1 -0
- package/dist/letta/modelSettings.d.ts +176 -0
- package/dist/letta/modelSettings.d.ts.map +1 -0
- package/dist/letta/modelSettings.js +314 -0
- package/dist/letta/modelSettings.js.map +1 -0
- package/dist/letta/promptWrapping.d.ts +141 -0
- package/dist/letta/promptWrapping.d.ts.map +1 -0
- package/dist/letta/promptWrapping.js +213 -0
- package/dist/letta/promptWrapping.js.map +1 -0
- package/dist/letta/sandbox.d.ts +100 -0
- package/dist/letta/sandbox.d.ts.map +1 -0
- package/dist/letta/sandbox.js +151 -0
- package/dist/letta/sandbox.js.map +1 -0
- package/dist/letta/settingsFileSeed.d.ts +146 -0
- package/dist/letta/settingsFileSeed.d.ts.map +1 -0
- package/dist/letta/settingsFileSeed.js +177 -0
- package/dist/letta/settingsFileSeed.js.map +1 -0
- package/dist/letta/subprocessThrottle.d.ts +151 -0
- package/dist/letta/subprocessThrottle.d.ts.map +1 -0
- package/dist/letta/subprocessThrottle.js +195 -0
- package/dist/letta/subprocessThrottle.js.map +1 -0
- package/dist/letta/tpmRecovery.d.ts +202 -0
- package/dist/letta/tpmRecovery.d.ts.map +1 -0
- package/dist/letta/tpmRecovery.js +314 -0
- package/dist/letta/tpmRecovery.js.map +1 -0
- package/dist/letta/types.d.ts +54 -0
- package/dist/letta/types.d.ts.map +1 -0
- package/dist/letta/types.js +16 -0
- package/dist/letta/types.js.map +1 -0
- package/dist/observability/logger.d.ts +48 -0
- package/dist/observability/logger.d.ts.map +1 -0
- package/dist/observability/logger.js +81 -0
- package/dist/observability/logger.js.map +1 -0
- package/dist/observability/metrics.d.ts +53 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +92 -0
- package/dist/observability/metrics.js.map +1 -0
- package/dist/routes/admin/agents.d.ts +63 -0
- package/dist/routes/admin/agents.d.ts.map +1 -0
- package/dist/routes/admin/agents.js +461 -0
- package/dist/routes/admin/agents.js.map +1 -0
- package/dist/routes/admin/rotatingMessages.d.ts +51 -0
- package/dist/routes/admin/rotatingMessages.d.ts.map +1 -0
- package/dist/routes/admin/rotatingMessages.js +292 -0
- package/dist/routes/admin/rotatingMessages.js.map +1 -0
- package/dist/routes/admin/sessions.d.ts +61 -0
- package/dist/routes/admin/sessions.d.ts.map +1 -0
- package/dist/routes/admin/sessions.js +232 -0
- package/dist/routes/admin/sessions.js.map +1 -0
- package/dist/routes/admin/settings.d.ts +110 -0
- package/dist/routes/admin/settings.d.ts.map +1 -0
- package/dist/routes/admin/settings.js +401 -0
- package/dist/routes/admin/settings.js.map +1 -0
- package/dist/routes/admin/users.d.ts +115 -0
- package/dist/routes/admin/users.d.ts.map +1 -0
- package/dist/routes/admin/users.js +374 -0
- package/dist/routes/admin/users.js.map +1 -0
- package/dist/routes/agents.d.ts +30 -0
- package/dist/routes/agents.d.ts.map +1 -0
- package/dist/routes/agents.js +55 -0
- package/dist/routes/agents.js.map +1 -0
- package/dist/routes/auth.d.ts +121 -0
- package/dist/routes/auth.d.ts.map +1 -0
- package/dist/routes/auth.js +422 -0
- package/dist/routes/auth.js.map +1 -0
- package/dist/routes/chat.d.ts +97 -0
- package/dist/routes/chat.d.ts.map +1 -0
- package/dist/routes/chat.js +484 -0
- package/dist/routes/chat.js.map +1 -0
- package/dist/routes/featureToggles.d.ts +34 -0
- package/dist/routes/featureToggles.d.ts.map +1 -0
- package/dist/routes/featureToggles.js +47 -0
- package/dist/routes/featureToggles.js.map +1 -0
- package/dist/routes/health.d.ts +24 -0
- package/dist/routes/health.d.ts.map +1 -0
- package/dist/routes/health.js +37 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/metrics.d.ts +35 -0
- package/dist/routes/metrics.d.ts.map +1 -0
- package/dist/routes/metrics.js +106 -0
- package/dist/routes/metrics.js.map +1 -0
- package/dist/routes/sessions.d.ts +161 -0
- package/dist/routes/sessions.d.ts.map +1 -0
- package/dist/routes/sessions.js +1501 -0
- package/dist/routes/sessions.js.map +1 -0
- package/dist/routes/stubs.d.ts +25 -0
- package/dist/routes/stubs.d.ts.map +1 -0
- package/dist/routes/stubs.js +25 -0
- package/dist/routes/stubs.js.map +1 -0
- package/dist/state/cron.d.ts +58 -0
- package/dist/state/cron.d.ts.map +1 -0
- package/dist/state/cron.js +160 -0
- package/dist/state/cron.js.map +1 -0
- package/dist/state/rotationRunner.d.ts +96 -0
- package/dist/state/rotationRunner.d.ts.map +1 -0
- package/dist/state/rotationRunner.js +246 -0
- package/dist/state/rotationRunner.js.map +1 -0
- package/dist/state/rotationScheduler.d.ts +76 -0
- package/dist/state/rotationScheduler.d.ts.map +1 -0
- package/dist/state/rotationScheduler.js +124 -0
- package/dist/state/rotationScheduler.js.map +1 -0
- package/dist/state/turnRegistry.d.ts +95 -0
- package/dist/state/turnRegistry.d.ts.map +1 -0
- package/dist/state/turnRegistry.js +149 -0
- package/dist/state/turnRegistry.js.map +1 -0
- package/dist/state/turnRunner.d.ts +134 -0
- package/dist/state/turnRunner.d.ts.map +1 -0
- package/dist/state/turnRunner.js +476 -0
- package/dist/state/turnRunner.js.map +1 -0
- package/package.json +47 -0
- package/src/auth/argon2.ts +152 -0
- package/src/auth/encryption.ts +110 -0
- package/src/auth/jwt.ts +217 -0
- package/src/auth/middleware.ts +250 -0
- package/src/auth/passwordPolicy.ts +99 -0
- package/src/auth/roleRules.ts +497 -0
- package/src/auth/userView.ts +88 -0
- package/src/bootstrap.ts +254 -0
- package/src/db/connection.ts +75 -0
- package/src/db/migrate.ts +212 -0
- package/src/db/schema.ts +750 -0
- package/src/db/seed.ts +236 -0
- package/src/handlers/fetch.ts +251 -0
- package/src/handlers/nextjs.ts +49 -0
- package/src/handlers/responses.ts +95 -0
- package/src/handlers/routeTable.ts +188 -0
- package/src/handlers/router.ts +96 -0
- package/src/handlers/sse.ts +55 -0
- package/src/handlers/types.ts +104 -0
- package/src/index.ts +60 -0
- package/src/letta/client.ts +860 -0
- package/src/letta/eventTranslator.ts +667 -0
- package/src/letta/index.ts +46 -0
- package/src/letta/lettaCliShim.mjs +40 -0
- package/src/letta/sandbox.ts +167 -0
- package/src/letta/settingsFileSeed.ts +254 -0
- package/src/letta/subprocessThrottle.ts +251 -0
- package/src/letta/types.ts +65 -0
- package/src/observability/logger.ts +103 -0
- package/src/observability/metrics.ts +114 -0
- package/src/routes/admin/agents.ts +574 -0
- package/src/routes/admin/rotatingMessages.ts +351 -0
- package/src/routes/admin/sessions.ts +283 -0
- package/src/routes/admin/settings.ts +463 -0
- package/src/routes/admin/users.ts +455 -0
- package/src/routes/agents.ts +66 -0
- package/src/routes/auth.ts +513 -0
- package/src/routes/chat.ts +534 -0
- package/src/routes/featureToggles.ts +52 -0
- package/src/routes/health.ts +44 -0
- package/src/routes/metrics.ts +111 -0
- package/src/routes/sessions.ts +1878 -0
- package/src/state/cron.ts +179 -0
- package/src/state/rotationRunner.ts +326 -0
- package/src/state/rotationScheduler.ts +164 -0
- package/src/state/turnRegistry.ts +210 -0
- package/src/state/turnRunner.ts +588 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small response helpers used by every handler.
|
|
3
|
+
*
|
|
4
|
+
* Centralizing them means error-shape drift can't happen — `unauthorized()`
|
|
5
|
+
* always emits the same `{ error: { code, message } }` envelope, so the
|
|
6
|
+
* React client's `AIHubError` reducer stays consistent.
|
|
7
|
+
*
|
|
8
|
+
* @see SPECIFICATIONS.md §13.4 — input safety / Zod validation
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Writes `body` as JSON with the given `status`. Adds `application/json`
|
|
12
|
+
* content-type automatically.
|
|
13
|
+
*
|
|
14
|
+
* @param status - HTTP status code.
|
|
15
|
+
* @param body - JSON-serializable body.
|
|
16
|
+
* @param headers - extra headers to merge in.
|
|
17
|
+
* @returns the Response.
|
|
18
|
+
*/
|
|
19
|
+
export declare function jsonResponse(status: number, body: unknown, headers?: Record<string, string>): Response;
|
|
20
|
+
/**
|
|
21
|
+
* Standard error envelope. Pairs every error with a stable machine code so
|
|
22
|
+
* the React client's `AIHubError` discriminator stays useful.
|
|
23
|
+
*
|
|
24
|
+
* @param status - HTTP status code.
|
|
25
|
+
* @param code - machine-readable code matching the §7.5 `AIHubError` codes.
|
|
26
|
+
* @param message - human-readable description; safe to surface to end-users.
|
|
27
|
+
* @returns the Response.
|
|
28
|
+
*/
|
|
29
|
+
export declare function errorResponse(status: number, code: string, message: string): Response;
|
|
30
|
+
/** 401 with a generic invalid-credentials envelope (§13.1). */
|
|
31
|
+
export declare function unauthorized(message?: string): Response;
|
|
32
|
+
/** 403 used for role-mismatch + shield + min-count violations (§8.6). */
|
|
33
|
+
export declare function forbidden(message?: string, code?: string): Response;
|
|
34
|
+
/** 400 with a `validation` envelope. */
|
|
35
|
+
export declare function validationError(message: string, code?: string): Response;
|
|
36
|
+
/** 409 used for state-conflict errors (e.g. `theme_switcher_disabled`). */
|
|
37
|
+
export declare function conflictError(code: string, message: string): Response;
|
|
38
|
+
/** 501 used for Step-2 stubs that Step 3+ replaces with real handlers. */
|
|
39
|
+
export declare function notImplemented(message?: string): Response;
|
|
40
|
+
/** 404 with no enumeration leakage — used for unknown paths (§8.6). */
|
|
41
|
+
export declare function notFound(message?: string): Response;
|
|
42
|
+
/** 405 used by the matcher when the path matches but the method doesn't. */
|
|
43
|
+
export declare function methodNotAllowed(message?: string): Response;
|
|
44
|
+
/** 500 for internal-error catch-alls. The body never leaks stack traces. */
|
|
45
|
+
export declare function internalError(message?: string): Response;
|
|
46
|
+
//# sourceMappingURL=responses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/handlers/responses.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,QAAQ,CAQV;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,QAAQ,CAEV;AAED,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,OAAO,SAAwB,GAAG,QAAQ,CAEtE;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CACvB,OAAO,SAAc,EACrB,IAAI,SAAc,GACjB,QAAQ,CAEV;AAED,wCAAwC;AACxC,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAe,GAAG,QAAQ,CAE9E;AAED,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,CAErE;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,OAAO,SAAoB,GAAG,QAAQ,CAEpE;AAED,uEAAuE;AACvE,wBAAgB,QAAQ,CAAC,OAAO,SAAc,GAAG,QAAQ,CAExD;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,OAAO,SAAuB,GAAG,QAAQ,CAEzE;AAED,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,OAAO,SAA0B,GAAG,QAAQ,CAEzE"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small response helpers used by every handler.
|
|
3
|
+
*
|
|
4
|
+
* Centralizing them means error-shape drift can't happen — `unauthorized()`
|
|
5
|
+
* always emits the same `{ error: { code, message } }` envelope, so the
|
|
6
|
+
* React client's `AIHubError` reducer stays consistent.
|
|
7
|
+
*
|
|
8
|
+
* @see SPECIFICATIONS.md §13.4 — input safety / Zod validation
|
|
9
|
+
*/
|
|
10
|
+
/** Default JSON content-type with utf-8 charset. */
|
|
11
|
+
const JSON_CONTENT_TYPE = "application/json; charset=utf-8";
|
|
12
|
+
/**
|
|
13
|
+
* Writes `body` as JSON with the given `status`. Adds `application/json`
|
|
14
|
+
* content-type automatically.
|
|
15
|
+
*
|
|
16
|
+
* @param status - HTTP status code.
|
|
17
|
+
* @param body - JSON-serializable body.
|
|
18
|
+
* @param headers - extra headers to merge in.
|
|
19
|
+
* @returns the Response.
|
|
20
|
+
*/
|
|
21
|
+
export function jsonResponse(status, body, headers) {
|
|
22
|
+
return new Response(JSON.stringify(body), {
|
|
23
|
+
status,
|
|
24
|
+
headers: {
|
|
25
|
+
"Content-Type": JSON_CONTENT_TYPE,
|
|
26
|
+
...(headers ?? {}),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Standard error envelope. Pairs every error with a stable machine code so
|
|
32
|
+
* the React client's `AIHubError` discriminator stays useful.
|
|
33
|
+
*
|
|
34
|
+
* @param status - HTTP status code.
|
|
35
|
+
* @param code - machine-readable code matching the §7.5 `AIHubError` codes.
|
|
36
|
+
* @param message - human-readable description; safe to surface to end-users.
|
|
37
|
+
* @returns the Response.
|
|
38
|
+
*/
|
|
39
|
+
export function errorResponse(status, code, message) {
|
|
40
|
+
return jsonResponse(status, { error: { code, message } });
|
|
41
|
+
}
|
|
42
|
+
/** 401 with a generic invalid-credentials envelope (§13.1). */
|
|
43
|
+
export function unauthorized(message = "Invalid credentials") {
|
|
44
|
+
return errorResponse(401, "unauthorized", message);
|
|
45
|
+
}
|
|
46
|
+
/** 403 used for role-mismatch + shield + min-count violations (§8.6). */
|
|
47
|
+
export function forbidden(message = "Forbidden", code = "forbidden") {
|
|
48
|
+
return errorResponse(403, code, message);
|
|
49
|
+
}
|
|
50
|
+
/** 400 with a `validation` envelope. */
|
|
51
|
+
export function validationError(message, code = "validation") {
|
|
52
|
+
return errorResponse(400, code, message);
|
|
53
|
+
}
|
|
54
|
+
/** 409 used for state-conflict errors (e.g. `theme_switcher_disabled`). */
|
|
55
|
+
export function conflictError(code, message) {
|
|
56
|
+
return errorResponse(409, code, message);
|
|
57
|
+
}
|
|
58
|
+
/** 501 used for Step-2 stubs that Step 3+ replaces with real handlers. */
|
|
59
|
+
export function notImplemented(message = "Not implemented") {
|
|
60
|
+
return errorResponse(501, "not_implemented", message);
|
|
61
|
+
}
|
|
62
|
+
/** 404 with no enumeration leakage — used for unknown paths (§8.6). */
|
|
63
|
+
export function notFound(message = "Not found") {
|
|
64
|
+
return errorResponse(404, "not_found", message);
|
|
65
|
+
}
|
|
66
|
+
/** 405 used by the matcher when the path matches but the method doesn't. */
|
|
67
|
+
export function methodNotAllowed(message = "Method not allowed") {
|
|
68
|
+
return errorResponse(405, "method_not_allowed", message);
|
|
69
|
+
}
|
|
70
|
+
/** 500 for internal-error catch-alls. The body never leaks stack traces. */
|
|
71
|
+
export function internalError(message = "Internal server error") {
|
|
72
|
+
return errorResponse(500, "internal", message);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=responses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.js","sourceRoot":"","sources":["../../src/handlers/responses.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,oDAAoD;AACpD,MAAM,iBAAiB,GAAG,iCAAiC,CAAC;AAE5D;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAc,EACd,IAAa,EACb,OAAgC;IAEhC,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;QACxC,MAAM;QACN,OAAO,EAAE;YACP,cAAc,EAAE,iBAAiB;YACjC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;SACnB;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAc,EACd,IAAY,EACZ,OAAe;IAEf,OAAO,YAAY,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,C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 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical route table.
|
|
3
|
+
*
|
|
4
|
+
* Order matters — the matcher walks top-to-bottom and returns the first
|
|
5
|
+
* pattern that matches. Concrete paths come before any future wildcards.
|
|
6
|
+
*
|
|
7
|
+
* Entries are paired with the step that wires the real handler. After Step 5
|
|
8
|
+
* every endpoint is real; no stubs remain.
|
|
9
|
+
*
|
|
10
|
+
* @see SPECIFICATIONS.md §6.3 — API surface
|
|
11
|
+
* @see docs/IMPLEMENTATION_PLAN.md — per-endpoint step assignment
|
|
12
|
+
*/
|
|
13
|
+
import type { RouteEntry } from "./types.js";
|
|
14
|
+
/**
|
|
15
|
+
* Reads as the canonical Step-5 surface in one place. Step 6 adds no new
|
|
16
|
+
* routes — it extends the chat path with TPM-recovery internals.
|
|
17
|
+
*
|
|
18
|
+
* @returns the immutable route table.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildRouteTable(): ReadonlyArray<RouteEntry>;
|
|
21
|
+
//# sourceMappingURL=routeTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routeTable.d.ts","sourceRoot":"","sources":["../../src/handlers/routeTable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA6DH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,aAAa,CAAC,UAAU,CAAC,CA2G3D"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical route table.
|
|
3
|
+
*
|
|
4
|
+
* Order matters — the matcher walks top-to-bottom and returns the first
|
|
5
|
+
* pattern that matches. Concrete paths come before any future wildcards.
|
|
6
|
+
*
|
|
7
|
+
* Entries are paired with the step that wires the real handler. After Step 5
|
|
8
|
+
* every endpoint is real; no stubs remain.
|
|
9
|
+
*
|
|
10
|
+
* @see SPECIFICATIONS.md §6.3 — API surface
|
|
11
|
+
* @see docs/IMPLEMENTATION_PLAN.md — per-endpoint step assignment
|
|
12
|
+
*/
|
|
13
|
+
import { handleListAgents as handleListAgentsUser } from "../routes/agents.js";
|
|
14
|
+
import { handleGetPublicFeatureToggles } from "../routes/featureToggles.js";
|
|
15
|
+
import { handleCreateAgent, handleListAgents as handleListAgentsAdmin, handlePatchAgent, } from "../routes/admin/agents.js";
|
|
16
|
+
import { handleListSessionsOverview, handlePurgeAdminSessionSandbox, } from "../routes/admin/sessions.js";
|
|
17
|
+
import { handleCreateRotatingMessage, handleListRotatingMessages, handlePatchRotatingMessage, handleRotateRotatingMessageNow, } from "../routes/admin/rotatingMessages.js";
|
|
18
|
+
import { handleGetFeatureToggles, handleGetSettings, handlePatchFeatureToggles, handlePatchSettings, handleRotateMetricsToken, handleRotateSigningKey, } from "../routes/admin/settings.js";
|
|
19
|
+
import { handleCreateUser, handleDeleteUser, handleListUsers, handlePatchUserRole, handleResetUserPassword, } from "../routes/admin/users.js";
|
|
20
|
+
import { handleChangePassword, handleLogin, handleLogout, handleMe, handleMePreferences, } from "../routes/auth.js";
|
|
21
|
+
import { handleHealth, handleHealthReady } from "../routes/health.js";
|
|
22
|
+
import { handleMetrics } from "../routes/metrics.js";
|
|
23
|
+
import { handleGetChatEvents, handlePostChat, handlePostChatCancel, } from "../routes/chat.js";
|
|
24
|
+
import { handleAdminGetSessionMessages, handleCreateSession, handleDeleteMessageOverride, handleGetSession, handleGetSessionMessages, handleListMessageOverrides, handleListSessions, handlePatchSession, handlePatchSessionReasoning, handlePutMessageOverride, } from "../routes/sessions.js";
|
|
25
|
+
/**
|
|
26
|
+
* Reads as the canonical Step-5 surface in one place. Step 6 adds no new
|
|
27
|
+
* routes — it extends the chat path with TPM-recovery internals.
|
|
28
|
+
*
|
|
29
|
+
* @returns the immutable route table.
|
|
30
|
+
*/
|
|
31
|
+
export function buildRouteTable() {
|
|
32
|
+
return [
|
|
33
|
+
// Health probes — public.
|
|
34
|
+
{ method: "GET", path: "/health", handler: handleHealth },
|
|
35
|
+
{ method: "GET", path: "/health/ready", handler: handleHealthReady },
|
|
36
|
+
// Auth — full surface after Step 3.
|
|
37
|
+
{ method: "POST", path: "/auth/login", handler: handleLogin },
|
|
38
|
+
{ method: "POST", path: "/auth/change-password", handler: handleChangePassword },
|
|
39
|
+
{ method: "POST", path: "/auth/logout", handler: handleLogout },
|
|
40
|
+
{ method: "GET", path: "/auth/me", handler: handleMe },
|
|
41
|
+
{ method: "PATCH", path: "/auth/me/preferences", handler: handleMePreferences },
|
|
42
|
+
// Public — Step 10 (deployment-wide UI feature toggles per §8.4).
|
|
43
|
+
{ method: "GET", path: "/feature-toggles", handler: handleGetPublicFeatureToggles },
|
|
44
|
+
// User-facing — Step 4.
|
|
45
|
+
{ method: "GET", path: "/agents", handler: handleListAgentsUser },
|
|
46
|
+
{ method: "GET", path: "/sessions", handler: handleListSessions },
|
|
47
|
+
{ method: "POST", path: "/sessions", handler: handleCreateSession },
|
|
48
|
+
{ method: "GET", path: "/sessions/:id", handler: handleGetSession },
|
|
49
|
+
{ method: "PATCH", path: "/sessions/:id", handler: handlePatchSession },
|
|
50
|
+
{
|
|
51
|
+
method: "PATCH",
|
|
52
|
+
path: "/sessions/:id/reasoning",
|
|
53
|
+
handler: handlePatchSessionReasoning,
|
|
54
|
+
},
|
|
55
|
+
{ method: "GET", path: "/sessions/:id/messages", handler: handleGetSessionMessages },
|
|
56
|
+
{
|
|
57
|
+
method: "GET",
|
|
58
|
+
path: "/sessions/:id/message-overrides",
|
|
59
|
+
handler: handleListMessageOverrides,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
method: "PUT",
|
|
63
|
+
path: "/sessions/:id/message-overrides/:position",
|
|
64
|
+
handler: handlePutMessageOverride,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
method: "DELETE",
|
|
68
|
+
path: "/sessions/:id/message-overrides/:position",
|
|
69
|
+
handler: handleDeleteMessageOverride,
|
|
70
|
+
},
|
|
71
|
+
// Chat — Step 5 (SSE wire protocol per §9).
|
|
72
|
+
{ method: "POST", path: "/chat", handler: handlePostChat },
|
|
73
|
+
{ method: "GET", path: "/chat/:turn_id/events", handler: handleGetChatEvents },
|
|
74
|
+
{ method: "POST", path: "/chat/:turn_id/cancel", handler: handlePostChatCancel },
|
|
75
|
+
// Admin — Step 4.
|
|
76
|
+
{ method: "GET", path: "/admin/users", handler: handleListUsers },
|
|
77
|
+
{ method: "POST", path: "/admin/users", handler: handleCreateUser },
|
|
78
|
+
{ method: "PATCH", path: "/admin/users/:id/role", handler: handlePatchUserRole },
|
|
79
|
+
{ method: "POST", path: "/admin/users/:id/reset-password", handler: handleResetUserPassword },
|
|
80
|
+
{ method: "DELETE", path: "/admin/users/:id", handler: handleDeleteUser },
|
|
81
|
+
{ method: "GET", path: "/admin/agents", handler: handleListAgentsAdmin },
|
|
82
|
+
{ method: "POST", path: "/admin/agents", handler: handleCreateAgent },
|
|
83
|
+
{ method: "PATCH", path: "/admin/agents/:id", handler: handlePatchAgent },
|
|
84
|
+
{
|
|
85
|
+
method: "GET",
|
|
86
|
+
path: "/admin/rotating-messages",
|
|
87
|
+
handler: handleListRotatingMessages,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
method: "POST",
|
|
91
|
+
path: "/admin/rotating-messages",
|
|
92
|
+
handler: handleCreateRotatingMessage,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
method: "PATCH",
|
|
96
|
+
path: "/admin/rotating-messages/:id",
|
|
97
|
+
handler: handlePatchRotatingMessage,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
method: "POST",
|
|
101
|
+
path: "/admin/rotating-messages/:id/rotate-now",
|
|
102
|
+
handler: handleRotateRotatingMessageNow,
|
|
103
|
+
},
|
|
104
|
+
{ method: "GET", path: "/admin/sessions", handler: handleListSessionsOverview },
|
|
105
|
+
{
|
|
106
|
+
method: "GET",
|
|
107
|
+
path: "/admin/sessions/:id/messages",
|
|
108
|
+
handler: handleAdminGetSessionMessages,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
method: "POST",
|
|
112
|
+
path: "/admin/sessions/:id/purge-sandbox",
|
|
113
|
+
handler: handlePurgeAdminSessionSandbox,
|
|
114
|
+
},
|
|
115
|
+
{ method: "GET", path: "/admin/settings", handler: handleGetSettings },
|
|
116
|
+
{ method: "PATCH", path: "/admin/settings", handler: handlePatchSettings },
|
|
117
|
+
{ method: "GET", path: "/admin/settings/feature-toggles", handler: handleGetFeatureToggles },
|
|
118
|
+
{ method: "PATCH", path: "/admin/settings/feature-toggles", handler: handlePatchFeatureToggles },
|
|
119
|
+
{
|
|
120
|
+
method: "POST",
|
|
121
|
+
path: "/admin/settings/rotate-signing-key",
|
|
122
|
+
handler: handleRotateSigningKey,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
method: "POST",
|
|
126
|
+
path: "/admin/settings/rotate-metrics-token",
|
|
127
|
+
handler: handleRotateMetricsToken,
|
|
128
|
+
},
|
|
129
|
+
// Metrics — Step 4 (bearer-token-gated, no JWT).
|
|
130
|
+
{ method: "GET", path: "/metrics", handler: handleMetrics },
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=routeTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routeTable.js","sourceRoot":"","sources":["../../src/handlers/routeTable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EACL,iBAAiB,EACjB,gBAAgB,IAAI,qBAAqB,EACzC,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,GAC/B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,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C;QACD;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,yCAAyC;YAC/C,OAAO,EAAE,8BAA8B;SACxC;QACD,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,0BAA0B,EAAE;QAC/E;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,8BAA8B;YACpC,OAAO,EAAE,6BAA6B;SACvC;QACD;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,mCAAmC;YACzC,OAAO,EAAE,8BAA8B;SACxC;QACD,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,EAAE;QACtE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,mBAAmB,EAAE;QAC1E,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,iCAAiC,EAAE,OAAO,EAAE,uBAAuB,EAAE;QAC5F,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,iCAAiC,EAAE,OAAO,EAAE,yBAAyB,EAAE;QAChG;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,oCAAoC;YAC1C,OAAO,EAAE,sBAAsB;SAChC;QACD;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,sCAAsC;YAC5C,OAAO,EAAE,wBAAwB;SAClC;QAED,iDAAiD;QACjD,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE;KAC5D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny path + method matcher.
|
|
3
|
+
*
|
|
4
|
+
* Lives in-package — we explicitly do NOT depend on Hono / Express /
|
|
5
|
+
* Fastify (§6.2). The route table is flat, the patterns are simple, and a
|
|
6
|
+
* 50-line matcher beats a 500 KB framework runtime that brings its own
|
|
7
|
+
* plugin ecosystem we wouldn't use.
|
|
8
|
+
*
|
|
9
|
+
* Pattern syntax: `/sessions/:id` matches `/sessions/abc` and exposes
|
|
10
|
+
* `{ id: "abc" }` as the parameter map. The matcher does not support globs
|
|
11
|
+
* or regex — every spec'd route is a plain segment-by-segment match.
|
|
12
|
+
*
|
|
13
|
+
* The `*` method is the wildcard used by `OPTIONS` preflight handlers and
|
|
14
|
+
* the catch-all 404. First-registered-first-matched, so wildcards always go
|
|
15
|
+
* at the bottom of the table.
|
|
16
|
+
*
|
|
17
|
+
* @see SPECIFICATIONS.md §6.2 — stack (no framework runtime)
|
|
18
|
+
*/
|
|
19
|
+
import type { RouteEntry } from "./types.js";
|
|
20
|
+
/** A successful match's output. */
|
|
21
|
+
export interface MatchResult {
|
|
22
|
+
/** The handler to invoke. */
|
|
23
|
+
entry: RouteEntry;
|
|
24
|
+
/** Path-parameter map (e.g. `{ id: "abc" }`). */
|
|
25
|
+
params: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Walks `entries` in order and returns the first one whose method + path
|
|
29
|
+
* pattern match `method` and `pathname`. Returns `null` if nothing matches.
|
|
30
|
+
*
|
|
31
|
+
* @param entries - the route table.
|
|
32
|
+
* @param method - request method (uppercased).
|
|
33
|
+
* @param pathname - request path with the basePath already stripped.
|
|
34
|
+
* @returns the matched entry + params, or `null`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function matchRoute(entries: ReadonlyArray<RouteEntry>, method: string, pathname: string): MatchResult | null;
|
|
37
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/handlers/router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,mCAAmC;AACnC,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,KAAK,EAAE,UAAU,CAAC;IAClB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,EAClC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,WAAW,GAAG,IAAI,CAOpB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny path + method matcher.
|
|
3
|
+
*
|
|
4
|
+
* Lives in-package — we explicitly do NOT depend on Hono / Express /
|
|
5
|
+
* Fastify (§6.2). The route table is flat, the patterns are simple, and a
|
|
6
|
+
* 50-line matcher beats a 500 KB framework runtime that brings its own
|
|
7
|
+
* plugin ecosystem we wouldn't use.
|
|
8
|
+
*
|
|
9
|
+
* Pattern syntax: `/sessions/:id` matches `/sessions/abc` and exposes
|
|
10
|
+
* `{ id: "abc" }` as the parameter map. The matcher does not support globs
|
|
11
|
+
* or regex — every spec'd route is a plain segment-by-segment match.
|
|
12
|
+
*
|
|
13
|
+
* The `*` method is the wildcard used by `OPTIONS` preflight handlers and
|
|
14
|
+
* the catch-all 404. First-registered-first-matched, so wildcards always go
|
|
15
|
+
* at the bottom of the table.
|
|
16
|
+
*
|
|
17
|
+
* @see SPECIFICATIONS.md §6.2 — stack (no framework runtime)
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Walks `entries` in order and returns the first one whose method + path
|
|
21
|
+
* pattern match `method` and `pathname`. Returns `null` if nothing matches.
|
|
22
|
+
*
|
|
23
|
+
* @param entries - the route table.
|
|
24
|
+
* @param method - request method (uppercased).
|
|
25
|
+
* @param pathname - request path with the basePath already stripped.
|
|
26
|
+
* @returns the matched entry + params, or `null`.
|
|
27
|
+
*/
|
|
28
|
+
export function matchRoute(entries, method, pathname) {
|
|
29
|
+
for (const entry of entries) {
|
|
30
|
+
if (entry.method !== "*" && entry.method !== method)
|
|
31
|
+
continue;
|
|
32
|
+
const params = matchPath(entry.path, pathname);
|
|
33
|
+
if (params)
|
|
34
|
+
return { entry, params };
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Compares a path template (with `:param` placeholders) against an actual
|
|
40
|
+
* pathname. Returns the parameter map on a match, `null` otherwise.
|
|
41
|
+
*
|
|
42
|
+
* Trailing slashes are tolerated — `/foo/` matches `/foo`.
|
|
43
|
+
*
|
|
44
|
+
* @param template - the route template (e.g. `/sessions/:id`).
|
|
45
|
+
* @param pathname - the actual path being matched.
|
|
46
|
+
* @returns parameter map on a match, else `null`.
|
|
47
|
+
*/
|
|
48
|
+
function matchPath(template, pathname) {
|
|
49
|
+
const tplParts = trimSlashes(template).split("/");
|
|
50
|
+
const pathParts = trimSlashes(pathname).split("/");
|
|
51
|
+
if (tplParts.length !== pathParts.length)
|
|
52
|
+
return null;
|
|
53
|
+
const params = {};
|
|
54
|
+
for (let i = 0; i < tplParts.length; i++) {
|
|
55
|
+
const tp = tplParts[i];
|
|
56
|
+
const pp = pathParts[i];
|
|
57
|
+
if (tp.startsWith(":")) {
|
|
58
|
+
const name = tp.slice(1);
|
|
59
|
+
params[name] = decodeURIComponent(pp);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (tp !== pp)
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return params;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Trims a single leading and trailing `/` so `split("/")` yields the same
|
|
69
|
+
* segment count regardless of slash style.
|
|
70
|
+
*
|
|
71
|
+
* @param s - the path or template string.
|
|
72
|
+
* @returns the input with one leading/trailing slash removed.
|
|
73
|
+
*/
|
|
74
|
+
function trimSlashes(s) {
|
|
75
|
+
let out = s;
|
|
76
|
+
if (out.startsWith("/"))
|
|
77
|
+
out = out.slice(1);
|
|
78
|
+
if (out.endsWith("/"))
|
|
79
|
+
out = out.slice(0, -1);
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/handlers/router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAYH;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CACxB,OAAkC,EAClC,MAAc,EACd,QAAgB;IAEhB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;YAAE,SAAS;QAC9D,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC/C,IAAI,MAAM;YAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACvC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,SAAS,CAChB,QAAgB,EAChB,QAAgB;IAEhB,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnD,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEtD,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAW,CAAC;QACjC,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAW,CAAC;QAClC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACzB,MAAM,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAAC;YACtC,SAAS;QACX,CAAC;QACD,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC;IAC7B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,CAAS;IAC5B,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5C,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9C,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small SSE writer helpers.
|
|
3
|
+
*
|
|
4
|
+
* The chat handler builds a `ReadableStream` of bytes and pipes named
|
|
5
|
+
* events into it. This file holds the encoding (utf-8 + `event:`/`data:`
|
|
6
|
+
* lines) and a `formatSseEvent` helper so the writer stays in one place.
|
|
7
|
+
*
|
|
8
|
+
* @see SPECIFICATIONS.md §9.5 — why SSE (not EventSource)
|
|
9
|
+
*/
|
|
10
|
+
import type { AIHubEvent } from "@data-club/ai-hub";
|
|
11
|
+
/**
|
|
12
|
+
* Formats one ai-hub event into the byte payload an SSE client expects.
|
|
13
|
+
*
|
|
14
|
+
* Format per the W3C EventSource spec:
|
|
15
|
+
*
|
|
16
|
+
* ```
|
|
17
|
+
* event: <event-name>
|
|
18
|
+
* data: <json-payload>
|
|
19
|
+
*
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* The blank line separator is required. Multi-line payloads get one
|
|
23
|
+
* `data:` line per newline; we shouldn't see any in practice (the events
|
|
24
|
+
* we emit are flat JSON), but the helper handles it defensively.
|
|
25
|
+
*
|
|
26
|
+
* @param event - the ai-hub event.
|
|
27
|
+
* @returns the SSE-formatted bytes.
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatSseEvent(event: AIHubEvent): Uint8Array;
|
|
30
|
+
/**
|
|
31
|
+
* Formats a plain SSE comment-line (used for heartbeats). Browsers and
|
|
32
|
+
* proxies treat any line starting with `:` as a comment — keeps the
|
|
33
|
+
* connection alive without delivering an event to the consumer.
|
|
34
|
+
*
|
|
35
|
+
* @returns the bytes of a `:hb\n\n` heartbeat.
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatSseHeartbeat(): Uint8Array;
|
|
38
|
+
//# sourceMappingURL=sse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/handlers/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAa5D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,UAAU,CAE/C"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small SSE writer helpers.
|
|
3
|
+
*
|
|
4
|
+
* The chat handler builds a `ReadableStream` of bytes and pipes named
|
|
5
|
+
* events into it. This file holds the encoding (utf-8 + `event:`/`data:`
|
|
6
|
+
* lines) and a `formatSseEvent` helper so the writer stays in one place.
|
|
7
|
+
*
|
|
8
|
+
* @see SPECIFICATIONS.md §9.5 — why SSE (not EventSource)
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Formats one ai-hub event into the byte payload an SSE client expects.
|
|
12
|
+
*
|
|
13
|
+
* Format per the W3C EventSource spec:
|
|
14
|
+
*
|
|
15
|
+
* ```
|
|
16
|
+
* event: <event-name>
|
|
17
|
+
* data: <json-payload>
|
|
18
|
+
*
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* The blank line separator is required. Multi-line payloads get one
|
|
22
|
+
* `data:` line per newline; we shouldn't see any in practice (the events
|
|
23
|
+
* we emit are flat JSON), but the helper handles it defensively.
|
|
24
|
+
*
|
|
25
|
+
* @param event - the ai-hub event.
|
|
26
|
+
* @returns the SSE-formatted bytes.
|
|
27
|
+
*/
|
|
28
|
+
export function formatSseEvent(event) {
|
|
29
|
+
// `heartbeat` events carry no `data` per the wire-protocol union — for
|
|
30
|
+
// every other variant `data` is present. We pull it out with a narrowing
|
|
31
|
+
// `in` check so we don't include `data: undefined` in the wire payload
|
|
32
|
+
// when there's nothing to send.
|
|
33
|
+
const payload = JSON.stringify({
|
|
34
|
+
seq: event.seq,
|
|
35
|
+
...("data" in event ? { data: event.data } : {}),
|
|
36
|
+
state: event.state,
|
|
37
|
+
});
|
|
38
|
+
const dataLines = payload.split("\n").map((l) => `data: ${l}`).join("\n");
|
|
39
|
+
const text = `event: ${event.event}\n${dataLines}\n\n`;
|
|
40
|
+
return new TextEncoder().encode(text);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Formats a plain SSE comment-line (used for heartbeats). Browsers and
|
|
44
|
+
* proxies treat any line starting with `:` as a comment — keeps the
|
|
45
|
+
* connection alive without delivering an event to the consumer.
|
|
46
|
+
*
|
|
47
|
+
* @returns the bytes of a `:hb\n\n` heartbeat.
|
|
48
|
+
*/
|
|
49
|
+
export function formatSseHeartbeat() {
|
|
50
|
+
return new TextEncoder().encode(":hb\n\n");
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=sse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../src/handlers/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,cAAc,CAAC,KAAiB;IAC9C,uEAAuE;IACvE,yEAAyE;IACzE,uEAAuE;IACvE,gCAAgC;IAChC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC;QAC7B,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,GAAG,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChD,KAAK,EAAE,KAAK,CAAC,KAAK;KACnB,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1E,MAAM,IAAI,GAAG,UAAU,KAAK,CAAC,KAAK,KAAK,SAAS,MAAM,CAAC;IACvD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the Fetch routing core.
|
|
3
|
+
*
|
|
4
|
+
* `AIHubServerContext` is the per-server-instance bundle: DB, logger, parsed
|
|
5
|
+
* encryption key, route prefix. Subsequent steps extend it (Letta client,
|
|
6
|
+
* mock-Letta toggle, etc.) — additions are additive.
|
|
7
|
+
*
|
|
8
|
+
* Handlers are Web-Standard `(Request, ctx) => Promise<Response>` per §6.2.
|
|
9
|
+
* No framework runtime, no plugin ecosystem.
|
|
10
|
+
*
|
|
11
|
+
* @see SPECIFICATIONS.md §6.2 — stack
|
|
12
|
+
*/
|
|
13
|
+
import type Database from "better-sqlite3";
|
|
14
|
+
import type { DrizzleDB } from "../db/connection.js";
|
|
15
|
+
import type { LettaClient } from "../letta/client.js";
|
|
16
|
+
import type { SubprocessThrottle } from "../letta/subprocessThrottle.js";
|
|
17
|
+
import type { Logger } from "../observability/logger.js";
|
|
18
|
+
/** Per-server-instance context wired by `createFetchHandler`. */
|
|
19
|
+
export interface AIHubServerContext {
|
|
20
|
+
/** Drizzle client typed against the schema — call this for typed queries. */
|
|
21
|
+
db: DrizzleDB;
|
|
22
|
+
/** Raw better-sqlite3 handle — used only for `transaction()` + low-level ops. */
|
|
23
|
+
sqlite: Database.Database;
|
|
24
|
+
/** Pino logger with redaction applied. */
|
|
25
|
+
logger: Logger;
|
|
26
|
+
/** Parsed `AI_HUB_ENCRYPTION_KEY` (32 bytes). */
|
|
27
|
+
encryptionKey: Buffer;
|
|
28
|
+
/**
|
|
29
|
+
* The route prefix (default `/api/ai-hub`). The matcher peels this off
|
|
30
|
+
* before pattern-matching. Set via `createFetchHandler({ basePath })`.
|
|
31
|
+
*/
|
|
32
|
+
basePath: string;
|
|
33
|
+
/**
|
|
34
|
+
* Project-shaped Letta client (§6.4). The handler imports types from
|
|
35
|
+
* `letta/client.ts` and calls this for every Letta interaction —
|
|
36
|
+
* **never raw HTTP**. Tests inject a mock via
|
|
37
|
+
* `createFetchHandler({ lettaClient })`.
|
|
38
|
+
*/
|
|
39
|
+
lettaClient: LettaClient;
|
|
40
|
+
/**
|
|
41
|
+
* Per-process throttle that gates Letta Code subprocess spawning. The chat
|
|
42
|
+
* route's `streamUserMessage` path calls `acquire()` before spawning and
|
|
43
|
+
* `release()` in the finally; if acquire throws `ServerOverloadedError`
|
|
44
|
+
* the route returns HTTP 503 with an `error {server_overloaded}` SSE
|
|
45
|
+
* event. The throttle is per-server-instance (the live-count counter is
|
|
46
|
+
* in-memory) and is constructed once in `createFetchHandler` from env-
|
|
47
|
+
* derived config. Tests can inject a configured-for-the-test instance.
|
|
48
|
+
*
|
|
49
|
+
* @see ../letta/subprocessThrottle.ts
|
|
50
|
+
*/
|
|
51
|
+
subprocessThrottle: SubprocessThrottle;
|
|
52
|
+
/**
|
|
53
|
+
* Env-var record used as the fallback source for the Letta API key when
|
|
54
|
+
* the `admin_setting.letta_api_key_encrypted` column is empty (see
|
|
55
|
+
* `letta/client.ts:resolveApiKey` for the precedence). Production passes
|
|
56
|
+
* `process.env`; tests pass the synthesized record they boot with so
|
|
57
|
+
* the fallback behavior is exercisable without touching the real
|
|
58
|
+
* environment.
|
|
59
|
+
*/
|
|
60
|
+
envSource: Record<string, string | undefined>;
|
|
61
|
+
/**
|
|
62
|
+
* Step-12.5 — absolute base directory holding `seeds/` and `sandboxes/`.
|
|
63
|
+
* Resolved once by `resolveFilesDir(env)` at boot from
|
|
64
|
+
* `AI_HUB_FILES_DIR` (or the `${AI_HUB_DATA_DIR}/files` fallback) and
|
|
65
|
+
* threaded through every route that touches sandbox dirs: the admin
|
|
66
|
+
* agents validator (seed existence check), `POST /sessions`
|
|
67
|
+
* (seed → sandbox copy), and `POST /admin/sessions/:id/purge-sandbox`.
|
|
68
|
+
*
|
|
69
|
+
* @see ../letta/sandbox.ts
|
|
70
|
+
* @see docs/server/session-sandboxes.md
|
|
71
|
+
*/
|
|
72
|
+
filesDir: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The shape every route handler implements. Mirrors the Web-Standard fetch
|
|
76
|
+
* function signature plus the per-instance context bundle and the matched
|
|
77
|
+
* path parameters.
|
|
78
|
+
*
|
|
79
|
+
* `params` is keyed by the `:name` placeholders in the route template — e.g.
|
|
80
|
+
* `/admin/users/:id/role` yields `{ id: "abc" }`. Handlers that don't use
|
|
81
|
+
* params can simply omit the third argument (TypeScript bivariance allows it).
|
|
82
|
+
*/
|
|
83
|
+
export type RouteHandler = (req: Request, ctx: AIHubServerContext, params: Readonly<Record<string, string>>) => Promise<Response>;
|
|
84
|
+
/** A path-aware handler entry consumed by the matcher. */
|
|
85
|
+
export interface RouteEntry {
|
|
86
|
+
/** Uppercase HTTP method, or `"*"` to match any. */
|
|
87
|
+
method: string;
|
|
88
|
+
/**
|
|
89
|
+
* Path template with `:param` placeholders (e.g. `/sessions/:id`). Matched
|
|
90
|
+
* against the request path *after* the `basePath` prefix has been peeled.
|
|
91
|
+
*/
|
|
92
|
+
path: string;
|
|
93
|
+
/** The handler. */
|
|
94
|
+
handler: RouteHandler;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAE3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,iEAAiE;AACjE,MAAM,WAAW,kBAAkB;IACjC,6EAA6E;IAC7E,EAAE,EAAE,SAAS,CAAC;IACd,iFAAiF;IACjF,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC1B,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,WAAW,EAAE,WAAW,CAAC;IACzB;;;;;;;;;;OAUG;IACH,kBAAkB,EAAE,kBAAkB,CAAC;IACvC;;;;;;;OAOG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC9C;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,CACzB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,kBAAkB,EACvB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KACrC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,0DAA0D;AAC1D,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,OAAO,EAAE,YAAY,CAAC;CACvB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the Fetch routing core.
|
|
3
|
+
*
|
|
4
|
+
* `AIHubServerContext` is the per-server-instance bundle: DB, logger, parsed
|
|
5
|
+
* encryption key, route prefix. Subsequent steps extend it (Letta client,
|
|
6
|
+
* mock-Letta toggle, etc.) — additions are additive.
|
|
7
|
+
*
|
|
8
|
+
* Handlers are Web-Standard `(Request, ctx) => Promise<Response>` per §6.2.
|
|
9
|
+
* No framework runtime, no plugin ecosystem.
|
|
10
|
+
*
|
|
11
|
+
* @see SPECIFICATIONS.md §6.2 — stack
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|