@opengeni/api-router 0.11.8 → 0.12.0
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/app.js +1 -1
- package/dist/{chunk-DQWFAIPE.js → chunk-S2N4252E.js} +1526 -453
- package/dist/chunk-S2N4252E.js.map +1 -0
- package/dist/index.js +1 -1
- package/package.json +10 -10
- package/src/app.ts +34 -24
- package/src/http/auth.ts +4 -1
- package/src/integrations/slack-bot.ts +694 -0
- package/src/mcp/server.ts +120 -0
- package/src/routes/connections.ts +155 -1
- package/src/routes/sessions.ts +10 -0
- package/src/routes/workspace-instruction-policies.ts +243 -0
- package/src/sandbox/channel-a.ts +131 -70
- package/dist/chunk-DQWFAIPE.js.map +0 -1
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/api-router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "OpenGeni HTTP surface: the Hono adapter/router (createApp), routes, MCP HTTP transport, and HTTP access adapters over @opengeni/core. An engine-distribution surface — its runtime closure includes engine-internal packages.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -44,17 +44,17 @@
|
|
|
44
44
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
45
45
|
"@opengeni/agent-proto": "^0.3.0",
|
|
46
46
|
"@opengeni/codex": "^0.2.7",
|
|
47
|
-
"@opengeni/config": "^0.7.
|
|
48
|
-
"@opengeni/contracts": "^0.
|
|
49
|
-
"@opengeni/core": "^0.
|
|
50
|
-
"@opengeni/db": "^0.
|
|
51
|
-
"@opengeni/documents": "^0.2.
|
|
52
|
-
"@opengeni/events": "^0.3.
|
|
53
|
-
"@opengeni/github": "^0.3.
|
|
47
|
+
"@opengeni/config": "^0.7.7",
|
|
48
|
+
"@opengeni/contracts": "^0.20.0",
|
|
49
|
+
"@opengeni/core": "^0.12.0",
|
|
50
|
+
"@opengeni/db": "^0.13.0",
|
|
51
|
+
"@opengeni/documents": "^0.2.37",
|
|
52
|
+
"@opengeni/events": "^0.3.28",
|
|
53
|
+
"@opengeni/github": "^0.3.19",
|
|
54
54
|
"@opengeni/network": "^0.1.1",
|
|
55
55
|
"@opengeni/observability": "^0.3.0",
|
|
56
|
-
"@opengeni/runtime": "^0.13.
|
|
57
|
-
"@opengeni/storage": "^0.2.
|
|
56
|
+
"@opengeni/runtime": "^0.13.11",
|
|
57
|
+
"@opengeni/storage": "^0.2.31",
|
|
58
58
|
"@temporalio/client": "^1.17.0",
|
|
59
59
|
"better-auth": "^1.6.14",
|
|
60
60
|
"hono": "^4.12.18",
|
package/src/app.ts
CHANGED
|
@@ -63,6 +63,7 @@ import { registerScheduledTaskRoutes } from "./routes/scheduled-tasks";
|
|
|
63
63
|
import { registerSessionRoutes } from "./routes/sessions";
|
|
64
64
|
import { registerSocialRoutes } from "./routes/social";
|
|
65
65
|
import { registerWorkspaceRoutes } from "./routes/workspaces";
|
|
66
|
+
import { registerWorkspaceInstructionPolicyRoutes } from "./routes/workspace-instruction-policies";
|
|
66
67
|
import { projectClientModel } from "./model-catalog";
|
|
67
68
|
|
|
68
69
|
export type {
|
|
@@ -307,6 +308,12 @@ export function createApp(deps: AppDependencies): Hono {
|
|
|
307
308
|
return c.json(result, result.ok ? 200 : 503);
|
|
308
309
|
});
|
|
309
310
|
|
|
311
|
+
app.get("/traffic-readyz", async (c) => {
|
|
312
|
+
const { db } = readinessChecks(deps);
|
|
313
|
+
const result = await runReadinessChecks({ db }, 2_000);
|
|
314
|
+
return c.json(result, result.ok ? 200 : 503);
|
|
315
|
+
});
|
|
316
|
+
|
|
310
317
|
app.get("/metrics", async (c) =>
|
|
311
318
|
c.text(await observability.prometheusMetrics(), 200, {
|
|
312
319
|
"content-type": "text/plain; version=0.0.4; charset=utf-8",
|
|
@@ -417,6 +424,7 @@ export function createApp(deps: AppDependencies): Hono {
|
|
|
417
424
|
registerGitHubRoutes(app, routeDeps);
|
|
418
425
|
registerInstallRoutes(app, routeDeps);
|
|
419
426
|
registerWorkspaceRoutes(app, routeDeps);
|
|
427
|
+
registerWorkspaceInstructionPolicyRoutes(app, routeDeps);
|
|
420
428
|
registerSocialRoutes(app, routeDeps);
|
|
421
429
|
registerConnectionRoutes(app, routeDeps);
|
|
422
430
|
registerCapabilityRoutes(app, routeDeps);
|
|
@@ -574,7 +582,9 @@ function boundedCorrelationId(value: string | undefined): string | null {
|
|
|
574
582
|
}
|
|
575
583
|
|
|
576
584
|
type ReadinessCheckName = "db" | "nats" | "temporal";
|
|
577
|
-
type
|
|
585
|
+
type ReadinessCheck = () => Promise<void> | void;
|
|
586
|
+
type ReadinessChecks = Record<ReadinessCheckName, ReadinessCheck>;
|
|
587
|
+
type ReadinessCheckResult = { ok: boolean; error?: string };
|
|
578
588
|
|
|
579
589
|
function readinessChecks(deps: AppDependencies): ReadinessChecks {
|
|
580
590
|
return {
|
|
@@ -599,35 +609,30 @@ function readinessChecks(deps: AppDependencies): ReadinessChecks {
|
|
|
599
609
|
};
|
|
600
610
|
}
|
|
601
611
|
|
|
602
|
-
async function runReadinessChecks(
|
|
603
|
-
checks:
|
|
612
|
+
async function runReadinessChecks<const Checks extends Readonly<Record<string, ReadinessCheck>>>(
|
|
613
|
+
checks: Checks,
|
|
604
614
|
timeoutMs: number,
|
|
605
615
|
): Promise<{
|
|
606
616
|
ok: boolean;
|
|
607
|
-
checks:
|
|
617
|
+
checks: { [Name in keyof Checks]: ReadinessCheckResult };
|
|
608
618
|
}> {
|
|
609
619
|
const entries = await Promise.all(
|
|
610
|
-
(Object.entries(checks) as Array<[
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
},
|
|
625
|
-
),
|
|
620
|
+
(Object.entries(checks) as Array<[keyof Checks, ReadinessCheck]>).map(async ([name, check]) => {
|
|
621
|
+
try {
|
|
622
|
+
await withTimeout(Promise.resolve().then(check), timeoutMs);
|
|
623
|
+
return [name, { ok: true }] as const;
|
|
624
|
+
} catch (error) {
|
|
625
|
+
return [
|
|
626
|
+
name,
|
|
627
|
+
{
|
|
628
|
+
ok: false,
|
|
629
|
+
error: error instanceof Error ? error.message : String(error),
|
|
630
|
+
},
|
|
631
|
+
] as const;
|
|
632
|
+
}
|
|
633
|
+
}),
|
|
626
634
|
);
|
|
627
|
-
const result = Object.fromEntries(entries) as
|
|
628
|
-
ReadinessCheckName,
|
|
629
|
-
{ ok: boolean; error?: string }
|
|
630
|
-
>;
|
|
635
|
+
const result = Object.fromEntries(entries) as { [Name in keyof Checks]: ReadinessCheckResult };
|
|
631
636
|
return {
|
|
632
637
|
ok: Object.values(result).every((check) => check.ok),
|
|
633
638
|
checks: result,
|
|
@@ -656,6 +661,7 @@ async function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T
|
|
|
656
661
|
const routeLabelPatterns: Array<{ pattern: RegExp; label: string }> = [
|
|
657
662
|
{ pattern: /^\/healthz$/, label: "/healthz" },
|
|
658
663
|
{ pattern: /^\/readyz$/, label: "/readyz" },
|
|
664
|
+
{ pattern: /^\/traffic-readyz$/, label: "/traffic-readyz" },
|
|
659
665
|
{
|
|
660
666
|
pattern: /^\/v1\/workspaces\/[^/]+\/codex\/connect\/start$/,
|
|
661
667
|
label: "/v1/workspaces/:workspaceId/codex/connect/start",
|
|
@@ -950,6 +956,10 @@ const routeLabelPatterns: Array<{ pattern: RegExp; label: string }> = [
|
|
|
950
956
|
pattern: /^\/v1\/workspaces\/[^/]+\/connections\/oauth\/start$/,
|
|
951
957
|
label: "/v1/workspaces/:workspaceId/connections/oauth/start",
|
|
952
958
|
},
|
|
959
|
+
{
|
|
960
|
+
pattern: /^\/v1\/workspaces\/[^/]+\/connections\/slack-bot$/,
|
|
961
|
+
label: "/v1/workspaces/:workspaceId/connections/slack-bot",
|
|
962
|
+
},
|
|
953
963
|
{
|
|
954
964
|
pattern: /^\/v1\/workspaces\/[^/]+\/connections\/[^/]+$/,
|
|
955
965
|
label: "/v1/workspaces/:workspaceId/connections/:connectionId",
|
package/src/http/auth.ts
CHANGED
|
@@ -77,7 +77,10 @@ function isAuthExempt(c: Context, settings: Settings): boolean {
|
|
|
77
77
|
if (installExactPaths.has(path) || isInstallRedirectPath(path)) {
|
|
78
78
|
return true;
|
|
79
79
|
}
|
|
80
|
-
if (
|
|
80
|
+
if (
|
|
81
|
+
settings.authAllowHealth &&
|
|
82
|
+
(path === "/healthz" || path === "/readyz" || path === "/traffic-readyz")
|
|
83
|
+
) {
|
|
81
84
|
return true;
|
|
82
85
|
}
|
|
83
86
|
if (settings.authAllowMetrics && path === "/metrics") {
|