@opengeni/api-router 1.2.1-canary.37222965366001 → 1.3.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-Q77DZ2M4.js → chunk-IZEGLLKZ.js} +1236 -468
- package/dist/{chunk-Q77DZ2M4.js.map → chunk-IZEGLLKZ.js.map} +1 -1
- package/dist/codemode.d.ts +3 -1
- package/dist/fatal-process-boundary.d.ts +9 -1
- package/dist/http/api-error.d.ts +11 -0
- package/dist/index.js +40 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/slack-bot.d.ts +72 -1
- package/dist/integrations/slack-tool-review.d.ts +5 -0
- package/dist/mcp/action-catalog-types.d.ts +5 -0
- package/dist/mcp/scheduled-task-view.d.ts +191 -0
- package/dist/mcp/server.d.ts +1 -1
- package/dist/organization-mcp.d.ts +8 -0
- package/dist/routes/client-errors.d.ts +1 -0
- package/dist/routes/organization-integration-policy.d.ts +6 -1
- package/dist/routes/slack-bot-access.d.ts +3 -0
- package/package.json +20 -20
- package/src/app.ts +38 -1
- package/src/auth/managed-auth-session-adapter.ts +8 -2
- package/src/auth/managed-auth.ts +19 -0
- package/src/codemode.ts +14 -7
- package/src/fatal-process-boundary.ts +50 -1
- package/src/http/api-error.ts +26 -1
- package/src/integrations/slack-bot.ts +276 -23
- package/src/integrations/slack-interactions.ts +177 -11
- package/src/integrations/slack-tool-review.ts +65 -0
- package/src/mcp/action-catalog-types.ts +5 -0
- package/src/mcp/action-catalog.gen.ts +85 -19
- package/src/mcp/scheduled-task-view.ts +10 -0
- package/src/mcp/server.ts +38 -16
- package/src/organization-mcp.ts +63 -3
- package/src/routes/api-integrations.ts +0 -17
- package/src/routes/capabilities.ts +2 -0
- package/src/routes/codex.ts +25 -12
- package/src/routes/managed-auth-session-sets.ts +11 -5
- package/src/routes/organization-integration-policy.ts +4 -4
- package/src/routes/sessions.ts +44 -0
- package/src/routes/slack-bot-access.ts +108 -0
- package/src/workspace-tool-gateway.ts +90 -4
package/dist/codemode.d.ts
CHANGED
|
@@ -50,5 +50,7 @@ export declare function requireActiveCodemodeCatalog(deps: ApiRouteDeps, grant:
|
|
|
50
50
|
}>;
|
|
51
51
|
export declare function submitAndDispatchCodemodeCall(deps: ApiRouteDeps, grant: AccessGrant, rawRequest: unknown): Promise<CodemodeCallSubmissionValue>;
|
|
52
52
|
export declare function codemodeOperationNeedsDispatch(operation: CodemodeOperation): boolean;
|
|
53
|
-
export declare function readCodemodeOperation(deps: ApiRouteDeps, grant: AccessGrant, operationId: string
|
|
53
|
+
export declare function readCodemodeOperation(deps: ApiRouteDeps, grant: AccessGrant, operationId: string, options?: {
|
|
54
|
+
durableApproval?: boolean;
|
|
55
|
+
}): Promise<CodemodeOperation | null>;
|
|
54
56
|
export declare function refreshAdmittedCodemodeOperation(admitted: CodemodeOperation, read: () => Promise<CodemodeOperation | null>): Promise<CodemodeOperation>;
|
|
@@ -2,7 +2,7 @@ import type { Observability } from "@opengeni/observability";
|
|
|
2
2
|
export type ApiFatalEvent = "startup_failure" | "unhandled_rejection" | "uncaught_exception";
|
|
3
3
|
export type ApiFatalPhase = "startup" | "running";
|
|
4
4
|
export type ApiFatalReasonKind = "bigint" | "boolean" | "error" | "function" | "null" | "number" | "object" | "string" | "symbol" | "undefined";
|
|
5
|
-
type ApiFatalObservability = Pick<Observability, "error" | "flush" | "startSpan"> & Partial<Pick<Observability, "recordFailureDiagnostic">>;
|
|
5
|
+
type ApiFatalObservability = Pick<Observability, "error" | "flush" | "startSpan"> & Partial<Pick<Observability, "recordFailureDiagnostic" | "warn" | "incrementCounter">>;
|
|
6
6
|
type ApiFatalProcess = {
|
|
7
7
|
on: (event: "unhandledRejection" | "uncaughtException", listener: (reason: unknown) => void) => void;
|
|
8
8
|
off: (event: "unhandledRejection" | "uncaughtException", listener: (reason: unknown) => void) => void;
|
|
@@ -14,6 +14,14 @@ export type ApiFatalProcessBoundaryOptions = {
|
|
|
14
14
|
flushTimeoutMs?: number;
|
|
15
15
|
correlationId?: () => string;
|
|
16
16
|
fallbackLog?: (message: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Classifies an unhandled rejection that leaves no process state behind and
|
|
19
|
+
* is therefore survivable once the API is serving. Defaults to a lost
|
|
20
|
+
* database connection (deploy drain, failover, restart): the rejected query
|
|
21
|
+
* held only a pooled connection the driver has already discarded, and every
|
|
22
|
+
* durable loop retries its claim on the next tick.
|
|
23
|
+
*/
|
|
24
|
+
isRecoverableRejection?: (reason: unknown) => boolean;
|
|
17
25
|
};
|
|
18
26
|
export type ApiFatalProcessBoundary = {
|
|
19
27
|
attachObservability: (observability: ApiFatalObservability) => void;
|
package/dist/http/api-error.d.ts
CHANGED
|
@@ -26,6 +26,17 @@ export declare function allowanceExhaustedHttpError(error: unknown): ApiHttpErro
|
|
|
26
26
|
* error so their retry classifier treats it as transient.
|
|
27
27
|
*/
|
|
28
28
|
export declare function workspaceControlBusyHttpError(error: unknown): ApiHttpError | null;
|
|
29
|
+
/** `details.code` of the retryable 503 for a request whose database connection was lost. */
|
|
30
|
+
export declare const DATABASE_UNAVAILABLE_ERROR_DETAIL_CODE = "DATABASE_UNAVAILABLE";
|
|
31
|
+
/**
|
|
32
|
+
* The request's database connection went away (an operator drain, failover,
|
|
33
|
+
* restart, or socket loss) rather than the statement being rejected. That is a
|
|
34
|
+
* brief, retryable outage, not an internal error. A read is safe to repeat. A
|
|
35
|
+
* mutation's outcome is unknown: the connection may have dropped after COMMIT,
|
|
36
|
+
* or after an earlier transaction of the same request committed, so the client
|
|
37
|
+
* must reconcile by its own idempotency key before resending.
|
|
38
|
+
*/
|
|
39
|
+
export declare function databaseUnavailableHttpError(error: unknown, method: string): ApiHttpError | null;
|
|
29
40
|
/**
|
|
30
41
|
* A typed agent-configuration failure (capability unavailable, conflict,
|
|
31
42
|
* widening, not enabled). Rendered as 422 validation_failed with the specific
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
startSlackInteractionPump,
|
|
13
13
|
startTemporalScheduleCleanupPump,
|
|
14
14
|
withAccessGrantSessionRlsContext
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-IZEGLLKZ.js";
|
|
16
16
|
import "./chunk-OGQDXVXY.js";
|
|
17
17
|
|
|
18
18
|
// src/index.ts
|
|
@@ -2887,6 +2887,7 @@ function rawRows(result) {
|
|
|
2887
2887
|
|
|
2888
2888
|
// src/fatal-process-boundary.ts
|
|
2889
2889
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
2890
|
+
import { isDatabaseConnectionLoss } from "@opengeni/db";
|
|
2890
2891
|
var API_FATAL_FLUSH_TIMEOUT_MS = 1e3;
|
|
2891
2892
|
var API_FATAL_CORRELATION_ID_PATTERN = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
2892
2893
|
var FATAL_ERROR_CODES = {
|
|
@@ -2899,9 +2900,46 @@ function installApiFatalProcessBoundary(options = {}) {
|
|
|
2899
2900
|
const flushTimeoutMs = options.flushTimeoutMs ?? API_FATAL_FLUSH_TIMEOUT_MS;
|
|
2900
2901
|
const correlationId = options.correlationId ?? (() => `api-fatal.${randomUUID3()}`);
|
|
2901
2902
|
const fallbackLog = options.fallbackLog ?? ((message) => console.error(message));
|
|
2903
|
+
const isRecoverableRejection = options.isRecoverableRejection ?? isDatabaseConnectionLoss;
|
|
2902
2904
|
let observability = options.observability;
|
|
2903
2905
|
let phase = "startup";
|
|
2904
2906
|
let reporting = false;
|
|
2907
|
+
const recover = (reason) => {
|
|
2908
|
+
if (phase !== "running" || reporting) return false;
|
|
2909
|
+
let recoverable = false;
|
|
2910
|
+
try {
|
|
2911
|
+
recoverable = isRecoverableRejection(reason);
|
|
2912
|
+
} catch {
|
|
2913
|
+
return false;
|
|
2914
|
+
}
|
|
2915
|
+
if (!recoverable) return false;
|
|
2916
|
+
const attributes = {
|
|
2917
|
+
errorClass: "ApiRecoveredRejection",
|
|
2918
|
+
errorCode: "api_unhandled_database_connection_loss",
|
|
2919
|
+
origin: "api",
|
|
2920
|
+
reasonKind: apiFatalReasonKind(reason)
|
|
2921
|
+
};
|
|
2922
|
+
try {
|
|
2923
|
+
if (observability?.warn) {
|
|
2924
|
+
observability.warn(
|
|
2925
|
+
"OpenGeni API recovered an unhandled database connection loss",
|
|
2926
|
+
attributes
|
|
2927
|
+
);
|
|
2928
|
+
} else {
|
|
2929
|
+
safeFallbackLog(
|
|
2930
|
+
fallbackLog,
|
|
2931
|
+
"OpenGeni API recovered an unhandled database connection loss (api_unhandled_database_connection_loss)"
|
|
2932
|
+
);
|
|
2933
|
+
}
|
|
2934
|
+
observability?.incrementCounter?.({
|
|
2935
|
+
name: "opengeni_api_recovered_rejections_total",
|
|
2936
|
+
help: "Unhandled rejections the API survived because they only reported a lost database connection.",
|
|
2937
|
+
labels: { code: "api_unhandled_database_connection_loss" }
|
|
2938
|
+
});
|
|
2939
|
+
} catch {
|
|
2940
|
+
}
|
|
2941
|
+
return true;
|
|
2942
|
+
};
|
|
2905
2943
|
const report = async (event, reason) => {
|
|
2906
2944
|
if (reporting) return;
|
|
2907
2945
|
reporting = true;
|
|
@@ -2946,6 +2984,7 @@ function installApiFatalProcessBoundary(options = {}) {
|
|
|
2946
2984
|
}
|
|
2947
2985
|
};
|
|
2948
2986
|
const onUnhandledRejection = (reason) => {
|
|
2987
|
+
if (recover(reason)) return;
|
|
2949
2988
|
void report("unhandled_rejection", reason);
|
|
2950
2989
|
};
|
|
2951
2990
|
const onUncaughtException = (reason) => {
|