@opengeni/api-router 2.6.4 → 2.10.0-canary.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.
Files changed (75) hide show
  1. package/dist/access-grant-rls.d.ts +3 -0
  2. package/dist/app.d.ts +2 -1
  3. package/dist/app.js +3 -1
  4. package/dist/auth/organization-user-setup.d.ts +23 -0
  5. package/dist/{chunk-XTLI3CBH.js → chunk-XXH7DW34.js} +6866 -3554
  6. package/dist/chunk-XXH7DW34.js.map +1 -0
  7. package/dist/codemode.d.ts +6 -0
  8. package/dist/github-access.d.ts +25 -2
  9. package/dist/http/request-source.d.ts +14 -0
  10. package/dist/index.js +19 -3
  11. package/dist/index.js.map +1 -1
  12. package/dist/integrations/oauth-client.d.ts +2 -11
  13. package/dist/integrations/personal-github-repositories.d.ts +41 -2
  14. package/dist/integrations/slack-interactions.d.ts +1 -1
  15. package/dist/mcp/server.d.ts +158 -1
  16. package/dist/mcp/session-view.d.ts +56 -2
  17. package/dist/mcp/session-wait.d.ts +1 -1
  18. package/dist/mcp-oauth.d.ts +19 -0
  19. package/dist/model-catalog.d.ts +5 -31
  20. package/dist/routes/codex.d.ts +27 -2
  21. package/dist/routes/github.d.ts +2 -0
  22. package/dist/routes/organization-model-providers.d.ts +3 -0
  23. package/dist/routes/workspace-artifacts.d.ts +2 -1
  24. package/dist/work-discovery-observability.d.ts +1 -1
  25. package/dist/workspace-artifact-content.d.ts +28 -0
  26. package/dist/workspace-artifact-provenance.d.ts +7 -0
  27. package/dist/workspace-deletion.d.ts +6 -0
  28. package/dist/workspace-tool-gateway-observability.d.ts +17 -0
  29. package/dist/workspace-tool-gateway.d.ts +118 -0
  30. package/package.json +19 -18
  31. package/src/access-grant-rls.ts +40 -0
  32. package/src/app.ts +296 -53
  33. package/src/auth/organization-user-setup.ts +95 -5
  34. package/src/codemode.ts +33 -4
  35. package/src/github-access.ts +117 -1
  36. package/src/http/auth.ts +11 -0
  37. package/src/http/request-source.ts +37 -0
  38. package/src/http/sse.ts +15 -7
  39. package/src/index.ts +18 -2
  40. package/src/integrations/oauth-client.ts +168 -203
  41. package/src/integrations/personal-github-repositories.ts +238 -9
  42. package/src/integrations/slack-app-home.ts +2 -2
  43. package/src/integrations/slack-interactions.ts +77 -37
  44. package/src/mcp/company-brain-governed-writes.ts +2 -2
  45. package/src/mcp/company-profile-agent-admin.ts +1 -1
  46. package/src/mcp/remember.ts +1 -1
  47. package/src/mcp/server.ts +504 -133
  48. package/src/mcp/session-view.ts +20 -1
  49. package/src/mcp/session-wait.ts +3 -0
  50. package/src/mcp-oauth.ts +539 -0
  51. package/src/model-catalog.ts +45 -337
  52. package/src/routes/automations.ts +178 -19
  53. package/src/routes/codex.ts +242 -73
  54. package/src/routes/connections.ts +271 -16
  55. package/src/routes/documents.ts +67 -19
  56. package/src/routes/files.ts +54 -6
  57. package/src/routes/github.ts +116 -15
  58. package/src/routes/organization-memberships.ts +59 -16
  59. package/src/routes/organization-model-providers.ts +231 -0
  60. package/src/routes/packs.ts +1 -0
  61. package/src/routes/personal-github.ts +39 -0
  62. package/src/routes/pr-review.ts +72 -4
  63. package/src/routes/scheduled-tasks.ts +40 -13
  64. package/src/routes/sessions.ts +153 -65
  65. package/src/routes/supergrok.ts +3 -2
  66. package/src/routes/workspace-artifacts.ts +176 -67
  67. package/src/routes/workspaces.ts +405 -62
  68. package/src/sandbox/channel-a.ts +17 -4
  69. package/src/work-discovery-observability.ts +3 -3
  70. package/src/workspace-artifact-content.ts +163 -0
  71. package/src/workspace-artifact-provenance.ts +104 -0
  72. package/src/workspace-deletion.ts +64 -0
  73. package/src/workspace-tool-gateway-observability.ts +100 -0
  74. package/src/workspace-tool-gateway.ts +691 -0
  75. package/dist/chunk-XTLI3CBH.js.map +0 -1
@@ -19,6 +19,10 @@ export declare class CodemodeCatalogNotReadyError extends Error {
19
19
  readonly code = "codemode_catalog_not_ready";
20
20
  constructor();
21
21
  }
22
+ export declare class CodemodeCatalogStaleError extends Error {
23
+ readonly code = "codemode_catalog_stale";
24
+ constructor();
25
+ }
22
26
  export declare function codemodeAuthorityForGrant(grant: AccessGrant): CodemodeGrantAuthority | null;
23
27
  export declare function isCodemodeGrant(grant: AccessGrant): boolean;
24
28
  export declare function requireMatchingCodemodeCatalog(authority: CodemodeGrantAuthority, catalog: AttemptToolCatalog | null): AttemptToolCatalog;
@@ -27,4 +31,6 @@ export declare function requireActiveCodemodeCatalog(deps: ApiRouteDeps, grant:
27
31
  catalog: AttemptToolCatalog;
28
32
  }>;
29
33
  export declare function submitAndDispatchCodemodeCall(deps: ApiRouteDeps, grant: AccessGrant, rawRequest: unknown): Promise<CodemodeCallSubmissionValue>;
34
+ export declare function codemodeOperationNeedsDispatch(operation: CodemodeOperation): boolean;
30
35
  export declare function readCodemodeOperation(deps: ApiRouteDeps, grant: AccessGrant, operationId: string): Promise<CodemodeOperation | null>;
36
+ export declare function refreshAdmittedCodemodeOperation(admitted: CodemodeOperation, read: () => Promise<CodemodeOperation | null>): Promise<CodemodeOperation>;
@@ -1,6 +1,22 @@
1
- import type { GitHubBindingStatus, GitHubInstallationBinding, GitHubRepository } from "@opengeni/contracts";
2
- import { listGitHubInstallationAccessForWorkspace } from "@opengeni/db";
1
+ import type { GitHubAppRepositoryBranchPage, GitHubBindingStatus, GitHubInstallationBinding, GitHubRepository } from "@opengeni/contracts";
2
+ import { type GitHubRepositoryBranchesResponse, type ListGitHubRepositoryBranchesQuery } from "@opengeni/contracts/github-repository-contracts";
3
+ import { areGitHubRepositoriesAllowedForWorkspace, listGitHubInstallationAccessForWorkspace } from "@opengeni/db";
3
4
  import type { ApiRouteDeps } from "@opengeni/core";
5
+ export type GitHubRepositoryBranchAuthorityErrorCode = "changed" | "not_authorized";
6
+ export declare class GitHubRepositoryBranchAuthorityError extends Error {
7
+ readonly code: GitHubRepositoryBranchAuthorityErrorCode;
8
+ constructor(code: GitHubRepositoryBranchAuthorityErrorCode);
9
+ }
10
+ export type WorkspaceGitHubRepositoryBranchServices = {
11
+ listInstallationAccess: typeof listGitHubInstallationAccessForWorkspace;
12
+ areRepositoriesAllowed: typeof areGitHubRepositoriesAllowedForWorkspace;
13
+ listProviderBranches: (deps: ApiRouteDeps, input: {
14
+ installationId: number;
15
+ repositoryId: number;
16
+ page: number;
17
+ limit: number;
18
+ }) => Promise<GitHubAppRepositoryBranchPage | null>;
19
+ };
4
20
  export declare function listWorkspaceGitHubInstallationBindings(deps: ApiRouteDeps, workspaceId: string): Promise<GitHubInstallationBinding[]>;
5
21
  export declare function githubBindingStatus(configured: boolean, installations: GitHubInstallationBinding[]): GitHubBindingStatus;
6
22
  export type LiveGitHubInstallation = {
@@ -10,3 +26,10 @@ export type LiveGitHubInstallation = {
10
26
  };
11
27
  export declare function githubInstallationBindingLifecycle(stored: Awaited<ReturnType<typeof listGitHubInstallationAccessForWorkspace>>[number], liveById: Map<number, LiveGitHubInstallation | null>, installationId: number, lifecycleVerified: boolean): GitHubInstallationBinding["lifecycle"];
12
28
  export declare function listWorkspaceGitHubRepositories(deps: ApiRouteDeps, workspaceId: string): Promise<GitHubRepository[]>;
29
+ export declare function listWorkspaceGitHubRepositoryBranches(deps: ApiRouteDeps, input: {
30
+ accountId: string;
31
+ workspaceId: string;
32
+ installationId: number;
33
+ repositoryId: number;
34
+ query: ListGitHubRepositoryBranchesQuery;
35
+ }, services?: WorkspaceGitHubRepositoryBranchServices): Promise<GitHubRepositoryBranchesResponse>;
@@ -0,0 +1,14 @@
1
+ import type { Context } from "hono";
2
+ declare const TRANSPORT_PEER_ADDRESS_BINDING = "opengeniTransportPeerAddress";
3
+ type ApiRequestBindings = {
4
+ [TRANSPORT_PEER_ADDRESS_BINDING]?: string | null;
5
+ };
6
+ export declare function apiRequestBindingsForTransportPeer(address: string | null | undefined): ApiRequestBindings;
7
+ /**
8
+ * Resolve a quota/audit source from the server-owned transport peer. Forwarded
9
+ * values are considered only when the operator declares an exact trusted proxy
10
+ * hop count; the chain is then walked from the server side so caller-prepended
11
+ * values cannot replace the address inserted by the trusted edge.
12
+ */
13
+ export declare function trustedRequestSourceAddress(c: Context, trustedProxyHops: number): string;
14
+ export {};
package/dist/index.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  InteractionFrameProxyTransport,
3
3
  SlackBotProviderError,
4
+ apiRequestBindingsForTransportPeer,
4
5
  cleanupScheduledTaskConnectorAuthorization,
5
6
  createAppComposition,
6
7
  createOpenGeniSlackBotInteractionClient,
7
8
  startSlackInteractionPump,
8
9
  startTemporalScheduleCleanupPump
9
- } from "./chunk-XTLI3CBH.js";
10
+ } from "./chunk-XXH7DW34.js";
10
11
 
11
12
  // src/index.ts
12
13
  import {
@@ -32,7 +33,10 @@ import {
32
33
  } from "@opengeni/observability";
33
34
  import { createObjectStorage } from "@opengeni/storage";
34
35
  import { isArtifactRuntimeConfigured } from "@opengeni/artifact-tool/runtime/development";
35
- import { SESSION_WORKFLOW_WAKE_DISPATCHER_SCHEDULE_ID } from "@opengeni/core";
36
+ import {
37
+ resolveCatalogSettings,
38
+ SESSION_WORKFLOW_WAKE_DISPATCHER_SCHEDULE_ID
39
+ } from "@opengeni/core";
36
40
  import {
37
41
  Connection,
38
42
  Client as TemporalClient,
@@ -2905,6 +2909,15 @@ async function startApi(options = {}) {
2905
2909
  () => assertRuntimeDatabasePosture(dbClient.db, databasePosture),
2906
2910
  { ...retryOptions, onRetry }
2907
2911
  );
2912
+ const resolvedCatalog = await retryStartupDependency(
2913
+ "model catalog",
2914
+ () => resolveCatalogSettings(dbClient.db, settings),
2915
+ { ...retryOptions, onRetry }
2916
+ );
2917
+ observability.info("OpenGeni model catalog resolved", {
2918
+ catalogSource: resolvedCatalog.source,
2919
+ catalogVersion: resolvedCatalog.version
2920
+ });
2908
2921
  bus = await retryStartupDependency(
2909
2922
  "NATS",
2910
2923
  () => createNatsEventBus(
@@ -2986,7 +2999,10 @@ async function startApi(options = {}) {
2986
2999
  if (artifactWebSockets.handles(request)) {
2987
3000
  return artifactWebSockets.upgrade(request, bunServer);
2988
3001
  }
2989
- return app.fetch(request);
3002
+ return app.fetch(
3003
+ request,
3004
+ apiRequestBindingsForTransportPeer(bunServer.requestIP(request)?.address)
3005
+ );
2990
3006
  },
2991
3007
  websocket: {
2992
3008
  maxPayloadLength: EDITABLE_ARTIFACT_LIVE_WEBSOCKET_MAX_MESSAGE_BYTES,