@opengeni/api-router 0.23.1 → 0.30.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 (152) hide show
  1. package/dist/app.d.ts +3 -2
  2. package/dist/app.js +5 -3
  3. package/dist/auth/canonical-human-session-admission.d.ts +27 -0
  4. package/dist/browser-auth-broker.d.ts +20 -0
  5. package/dist/browser-controller-authority.d.ts +61 -0
  6. package/dist/browser-network-route.d.ts +8 -0
  7. package/dist/browser-state-authority.d.ts +27 -0
  8. package/dist/{chunk-T4T2PGU4.js → chunk-2PQMSRCB.js} +37891 -17463
  9. package/dist/chunk-2PQMSRCB.js.map +1 -0
  10. package/dist/codemode.d.ts +23 -0
  11. package/dist/controller-data-plane.d.ts +12 -0
  12. package/dist/editable-artifact-live-hints.d.ts +11 -0
  13. package/dist/editable-artifact-native-kernel.d.ts +37 -0
  14. package/dist/editable-artifact-office-import.d.ts +22 -0
  15. package/dist/editable-artifact-production.d.ts +29 -0
  16. package/dist/editable-artifact-websocket.d.ts +49 -0
  17. package/dist/editable-artifact-workspace-files.d.ts +23 -0
  18. package/dist/github-browser-flow.d.ts +6 -0
  19. package/dist/http/auth.d.ts +1 -1
  20. package/dist/http/cors.d.ts +1 -0
  21. package/dist/http/sse.d.ts +18 -1
  22. package/dist/index.d.ts +3 -2
  23. package/dist/index.js +1796 -22
  24. package/dist/index.js.map +1 -1
  25. package/dist/integrations/api-integrations.d.ts +24 -0
  26. package/dist/integrations/atlassian.d.ts +176 -0
  27. package/dist/integrations/fiken.d.ts +233 -0
  28. package/dist/integrations/github-skill-source.d.ts +5 -0
  29. package/dist/integrations/google-drive.d.ts +85 -0
  30. package/dist/integrations/oauth-client.d.ts +22 -1
  31. package/dist/integrations/provider-oauth.d.ts +17 -0
  32. package/dist/integrations/slack-bot.d.ts +175 -1
  33. package/dist/integrations/slack-interactions.d.ts +24 -6
  34. package/dist/integrations/social-api.d.ts +2 -1
  35. package/dist/interaction-holder-heartbeat.d.ts +17 -0
  36. package/dist/interaction-metrics.d.ts +11 -0
  37. package/dist/mcp/editable-artifact-query-schema.d.ts +4 -0
  38. package/dist/mcp/editable-artifacts.d.ts +13 -0
  39. package/dist/mcp/scheduled-task-view.d.ts +168 -0
  40. package/dist/mcp/server.d.ts +16 -4
  41. package/dist/memory-slack-delivery.d.ts +9 -0
  42. package/dist/model-catalog.d.ts +1 -0
  43. package/dist/routes/api-integrations.d.ts +8 -0
  44. package/dist/routes/browser-identities.d.ts +5 -0
  45. package/dist/routes/browser-sessions.d.ts +6 -0
  46. package/dist/routes/canonical-human-identities.d.ts +3 -0
  47. package/dist/routes/channels.d.ts +3 -0
  48. package/dist/routes/company-profile.d.ts +3 -0
  49. package/dist/routes/computer-sessions.d.ts +6 -0
  50. package/dist/routes/editable-artifacts.d.ts +44 -0
  51. package/dist/routes/integration-facets.d.ts +3 -0
  52. package/dist/routes/interaction-resources.d.ts +5 -0
  53. package/dist/routes/memory-slack-publications.d.ts +6 -0
  54. package/dist/routes/organization-memberships.d.ts +3 -0
  55. package/dist/routes/plugins.d.ts +8 -0
  56. package/dist/routes/sessions.d.ts +18 -2
  57. package/dist/routes/skills.d.ts +6 -0
  58. package/dist/routes/slack-task-policy.d.ts +3 -0
  59. package/dist/routes/supergrok.d.ts +3 -0
  60. package/dist/routes/video-generation.d.ts +3 -0
  61. package/dist/sandbox/channel-a.d.ts +62 -2
  62. package/dist/sandbox/machines.d.ts +2 -2
  63. package/dist/sandbox/metrics-ingestion.d.ts +6 -1
  64. package/dist/sandbox/viewer.d.ts +7 -3
  65. package/dist/slack-reaction-files.d.ts +27 -0
  66. package/dist/temporal-schedule-cleanup.d.ts +26 -0
  67. package/dist/transcription/providers/xai-subscription.d.ts +8 -0
  68. package/dist/xai-realtime.d.ts +26 -0
  69. package/dist/xai-subscription-auth.d.ts +23 -0
  70. package/package.json +20 -14
  71. package/src/app.ts +604 -64
  72. package/src/auth/canonical-human-session-admission.ts +116 -0
  73. package/src/auth/managed-auth.ts +101 -0
  74. package/src/browser-auth-broker.ts +155 -0
  75. package/src/browser-controller-authority.ts +186 -0
  76. package/src/browser-network-route.ts +34 -0
  77. package/src/browser-state-authority.ts +236 -0
  78. package/src/codemode.ts +186 -0
  79. package/src/controller-data-plane.ts +35 -0
  80. package/src/editable-artifact-live-hints.ts +64 -0
  81. package/src/editable-artifact-native-kernel.ts +659 -0
  82. package/src/editable-artifact-office-import.ts +230 -0
  83. package/src/editable-artifact-production.ts +419 -0
  84. package/src/editable-artifact-websocket.ts +311 -0
  85. package/src/editable-artifact-workspace-files.ts +186 -0
  86. package/src/github-browser-flow.ts +35 -6
  87. package/src/http/auth.ts +29 -9
  88. package/src/http/cors.ts +3 -0
  89. package/src/http/sse.ts +229 -5
  90. package/src/index.ts +119 -20
  91. package/src/integrations/api-integrations.ts +365 -0
  92. package/src/integrations/atlassian.ts +1621 -0
  93. package/src/integrations/fiken.ts +1230 -0
  94. package/src/integrations/github-skill-source.ts +142 -0
  95. package/src/integrations/google-drive.ts +1005 -64
  96. package/src/integrations/oauth-client.ts +123 -33
  97. package/src/integrations/provider-oauth.ts +756 -0
  98. package/src/integrations/slack-bot.ts +669 -11
  99. package/src/integrations/slack-interactions.ts +2063 -93
  100. package/src/integrations/social-api.ts +11 -0
  101. package/src/interaction-holder-heartbeat.ts +95 -0
  102. package/src/interaction-metrics.ts +159 -0
  103. package/src/mcp/documents.ts +146 -6
  104. package/src/mcp/editable-artifact-query-schema.ts +236 -0
  105. package/src/mcp/editable-artifacts.ts +448 -0
  106. package/src/mcp/scheduled-task-view.ts +34 -0
  107. package/src/mcp/server.ts +1756 -355
  108. package/src/memory-slack-delivery.ts +209 -0
  109. package/src/model-catalog.ts +19 -6
  110. package/src/routes/api-integrations.ts +410 -0
  111. package/src/routes/browser-identities.ts +160 -0
  112. package/src/routes/browser-sessions.ts +4482 -0
  113. package/src/routes/canonical-human-identities.ts +156 -0
  114. package/src/routes/channels.ts +90 -0
  115. package/src/routes/company-profile.ts +255 -0
  116. package/src/routes/computer-sessions.ts +1602 -0
  117. package/src/routes/connections.ts +421 -99
  118. package/src/routes/documents.ts +22 -3
  119. package/src/routes/editable-artifacts.ts +1159 -0
  120. package/src/routes/files.ts +106 -4
  121. package/src/routes/github.ts +18 -2
  122. package/src/routes/install.ts +7 -1
  123. package/src/routes/integration-facets.ts +258 -0
  124. package/src/routes/interaction-resources.ts +595 -0
  125. package/src/routes/memory-slack-publications.ts +216 -0
  126. package/src/routes/organization-memberships.ts +53 -0
  127. package/src/routes/packs.ts +437 -7
  128. package/src/routes/plugins.ts +752 -0
  129. package/src/routes/rigs.ts +77 -20
  130. package/src/routes/scheduled-tasks.ts +67 -40
  131. package/src/routes/sessions.ts +830 -278
  132. package/src/routes/skills.ts +256 -0
  133. package/src/routes/slack-task-policy.ts +115 -0
  134. package/src/routes/supergrok.ts +717 -0
  135. package/src/routes/transcription-recordings.ts +9 -2
  136. package/src/routes/transcriptions.ts +2 -1
  137. package/src/routes/video-generation.ts +162 -0
  138. package/src/routes/workspaces.ts +68 -28
  139. package/src/sandbox/channel-a.ts +750 -116
  140. package/src/sandbox/machines.ts +5 -5
  141. package/src/sandbox/metrics-ingestion.ts +121 -3
  142. package/src/sandbox/rematerialize.ts +35 -47
  143. package/src/sandbox/viewer.ts +39 -12
  144. package/src/slack-reaction-files.ts +181 -0
  145. package/src/temporal-schedule-cleanup.ts +135 -0
  146. package/src/transcription/providers/xai-subscription.ts +110 -0
  147. package/src/transcription/service.ts +17 -2
  148. package/src/xai-realtime.ts +216 -0
  149. package/src/xai-subscription-auth.ts +132 -0
  150. package/dist/chunk-T4T2PGU4.js.map +0 -1
  151. package/dist/mcp/toolspace.d.ts +0 -71
  152. package/src/mcp/toolspace.ts +0 -1190
@@ -0,0 +1,24 @@
1
+ import { type IntegrationCredentialResolver, type IntegrationInvocationAuthority, type IntegrationTransport } from "@opengeni/capabilities";
2
+ import { ApiIntegrationPreview, type IntegrationSource } from "@opengeni/contracts";
3
+ import type { StoredApiIntegrationRevision } from "@opengeni/db";
4
+ export type ApiIntegrationConnectionDescriptor = {
5
+ id: string;
6
+ kind: "oauth2" | "api_key" | "app_install" | "delegated";
7
+ providerDomain: string;
8
+ scopes: string[];
9
+ ownership: "workspace" | "personal";
10
+ };
11
+ export type ResolvedApiIntegrationPreview = {
12
+ preview: ApiIntegrationPreview;
13
+ revision: StoredApiIntegrationRevision;
14
+ provider: string | null;
15
+ requiredScopes: string[];
16
+ authScheme: Record<string, unknown>;
17
+ };
18
+ export declare function resolveApiIntegrationPreview(input: {
19
+ source: IntegrationSource;
20
+ connection: ApiIntegrationConnectionDescriptor | null;
21
+ transport: IntegrationTransport;
22
+ credentialResolver?: IntegrationCredentialResolver;
23
+ authority: IntegrationInvocationAuthority;
24
+ }): Promise<ResolvedApiIntegrationPreview>;
@@ -0,0 +1,176 @@
1
+ import type { AccessGrant, ScheduledTask } from "@opengeni/contracts";
2
+ import { AtlassianOAuthStartResponse, type AtlassianDisconnectRequest, type AtlassianLifecycleActionRequest, type AtlassianOAuthStartRequest } from "@opengeni/contracts/atlassian";
3
+ import { type ApiRouteDeps } from "@opengeni/core";
4
+ import { getConnectionMetadata } from "@opengeni/db";
5
+ type AtlassianConnectionRecord = NonNullable<Awaited<ReturnType<typeof getConnectionMetadata>>>;
6
+ export declare function startAtlassianOAuth(deps: ApiRouteDeps, input: {
7
+ accountId: string;
8
+ workspaceId: string;
9
+ subjectId: string;
10
+ requestUrl: string;
11
+ payload: AtlassianOAuthStartRequest;
12
+ }): Promise<AtlassianOAuthStartResponse>;
13
+ export declare function completeAtlassianOAuthCallback(deps: ApiRouteDeps, input: {
14
+ code?: string | undefined;
15
+ state?: string | undefined;
16
+ error?: string | undefined;
17
+ requestUrl: string;
18
+ }): Promise<{
19
+ redirectTo: string;
20
+ }>;
21
+ export declare function browseAtlassianSources(deps: ApiRouteDeps, input: {
22
+ workspaceId: string;
23
+ subjectId: string;
24
+ connectionId: string;
25
+ }): Promise<{
26
+ connection: {
27
+ id: string;
28
+ accountId: string;
29
+ workspaceId: string;
30
+ subjectId: string | null;
31
+ providerDomain: string;
32
+ kind: "api_key" | "app_install" | "delegated" | "oauth2";
33
+ status: "active" | "error" | "needs_reauth" | "revoked";
34
+ grantedScopes: string[];
35
+ expiresAt: string | null;
36
+ lastRefreshAt: string | null;
37
+ lastUsedAt: string | null;
38
+ lastError: string | null;
39
+ version: number;
40
+ verifiedInstallAt?: string | null | undefined;
41
+ verifiedInstallVersion?: number | null | undefined;
42
+ metadata: Record<string, unknown>;
43
+ createdBySubjectId: string | null;
44
+ updatedBySubjectId: string | null;
45
+ createdAt: string;
46
+ updatedAt: string;
47
+ };
48
+ items: {
49
+ id: string;
50
+ cloudId: string;
51
+ siteName: string;
52
+ siteUrl: string;
53
+ resourceId: string;
54
+ key: string;
55
+ name: string;
56
+ kind: "confluence_space" | "jira_project";
57
+ description: string | null;
58
+ webUrl: string;
59
+ }[];
60
+ }>;
61
+ export declare function searchAtlassianLive(deps: ApiRouteDeps, input: {
62
+ workspaceId: string;
63
+ subjectId: string;
64
+ connectionId: string;
65
+ query: string;
66
+ product?: "jira" | "confluence" | undefined;
67
+ limit: number;
68
+ }): Promise<({
69
+ kind: "jira_issue";
70
+ id: string;
71
+ key: string;
72
+ title: string;
73
+ sourceId: string | null;
74
+ sourceName: string | null;
75
+ status: string | null;
76
+ updatedAt: string | null;
77
+ url: string;
78
+ } | {
79
+ kind: "confluence_page";
80
+ id: string;
81
+ key: null;
82
+ title: string;
83
+ sourceId: string | null;
84
+ sourceName: string | null;
85
+ status: null;
86
+ updatedAt: string | null;
87
+ url: string;
88
+ })[]>;
89
+ export declare function getAtlassianLiveItem(deps: ApiRouteDeps, input: {
90
+ workspaceId: string;
91
+ subjectId: string;
92
+ connectionId: string;
93
+ kind: "jira_issue" | "confluence_page";
94
+ id: string;
95
+ }): Promise<{
96
+ kind: "jira_issue";
97
+ id: string;
98
+ key: string;
99
+ title: string;
100
+ source: {
101
+ id: string;
102
+ name: string;
103
+ siteName: string;
104
+ };
105
+ status: string | null;
106
+ issueType: string | null;
107
+ priority: string | null;
108
+ assignee: string | null;
109
+ reporter: string | null;
110
+ labels: string[];
111
+ createdAt: string | null;
112
+ updatedAt: string | null;
113
+ description: string;
114
+ comments: {
115
+ author: string | null;
116
+ createdAt: string | null;
117
+ body: string;
118
+ }[];
119
+ url: string;
120
+ content?: never;
121
+ } | {
122
+ key?: never;
123
+ issueType?: never;
124
+ priority?: never;
125
+ assignee?: never;
126
+ reporter?: never;
127
+ labels?: never;
128
+ description?: never;
129
+ kind: "confluence_page";
130
+ id: string;
131
+ title: string;
132
+ source: {
133
+ id: string;
134
+ name: string;
135
+ siteName: string;
136
+ };
137
+ status: string | null;
138
+ createdAt: string | null;
139
+ updatedAt: string | null;
140
+ content: string;
141
+ comments: {
142
+ createdAt: string | null;
143
+ content: string;
144
+ }[];
145
+ url: string;
146
+ }>;
147
+ export declare function saveAtlassianSources(deps: ApiRouteDeps, input: {
148
+ accountId: string;
149
+ workspaceId: string;
150
+ subjectId: string;
151
+ connectionId: string;
152
+ grant: AccessGrant;
153
+ payload: unknown;
154
+ canManageOrganizationDestination: boolean;
155
+ canManageWorkspaceDestination: boolean;
156
+ canManagePersonalDestination: boolean;
157
+ }): Promise<import("@opengeni/db").ConnectionMetadataWithVerification>;
158
+ export declare function transitionAtlassianLifecycle(deps: ApiRouteDeps, input: {
159
+ workspaceId: string;
160
+ subjectId: string;
161
+ connectionId: string;
162
+ payload: AtlassianLifecycleActionRequest;
163
+ }): Promise<import("@opengeni/db").ConnectionMetadataWithVerification>;
164
+ export declare function disconnectAtlassian(deps: ApiRouteDeps, input: {
165
+ workspaceId: string;
166
+ subjectId: string;
167
+ connection: AtlassianConnectionRecord;
168
+ payload: AtlassianDisconnectRequest;
169
+ }): Promise<import("@opengeni/db").ConnectionMetadataWithVerification | null>;
170
+ export declare function revokeAtlassianScheduleAuthorization(deps: ApiRouteDeps, input: {
171
+ task: ScheduledTask;
172
+ subjectId: string;
173
+ }): Promise<void>;
174
+ export declare function isSelectableConfluenceSpaceType(value: unknown): boolean;
175
+ export declare function confluenceNextUrl(cloudId: string, next: string): URL;
176
+ export {};
@@ -0,0 +1,233 @@
1
+ import type { ApiRouteDeps } from "@opengeni/core";
2
+ import type { Settings } from "@opengeni/config";
3
+ import { FikenOAuthStartResponse, type AccessGrant, type ConnectionMetadata, type FikenCompanySummary, type FikenConnectionMetadata, type FikenOAuthStartRequest } from "@opengeni/contracts";
4
+ import { type Database } from "@opengeni/db";
5
+ import { type FetchLike } from "@opengeni/network";
6
+ import { HTTPException } from "hono/http-exception";
7
+ export type FikenOperation = "companies.list" | "contacts.list" | "contact.create" | "products.list" | "invoices.list" | "invoice.get" | "invoice_draft.create" | "bank_accounts.list" | "purchases.list" | "sales.list";
8
+ export declare class FikenProviderError extends Error {
9
+ readonly code: string;
10
+ readonly status: number | null;
11
+ constructor(code: string, status?: number | null, providerMessage?: string | null);
12
+ }
13
+ export declare class FikenCredentialVerificationError extends HTTPException {
14
+ constructor(message: string);
15
+ }
16
+ export type FikenPage = {
17
+ page: number;
18
+ pageSize: number;
19
+ pageCount: number | null;
20
+ resultCount: number | null;
21
+ };
22
+ type FikenContext = {
23
+ accountId: string;
24
+ workspaceId: string;
25
+ subjectId: string | null;
26
+ sessionId: string | null;
27
+ };
28
+ /**
29
+ * Validates a pasted Fiken personal API token before it enters encrypted
30
+ * storage, and discovers the companies it can act on. The companies list is
31
+ * the connection's bounded metadata; company slugs are re-validated by Fiken
32
+ * itself on every later call.
33
+ */
34
+ export declare function verifyFikenApiToken(token: string, fetchImpl?: FetchLike): Promise<{
35
+ companies: FikenCompanySummary[];
36
+ }>;
37
+ export declare function fikenCredentialBundle(token: string): Record<string, unknown>;
38
+ export declare function resolveFikenConnectionForTool(input: {
39
+ db: Database;
40
+ grant: AccessGrant;
41
+ sessionId: string | null;
42
+ requestedConnectionId?: string;
43
+ }): Promise<{
44
+ connection: ConnectionMetadata;
45
+ metadata: FikenConnectionMetadata;
46
+ context: FikenContext;
47
+ }>;
48
+ export type FikenListInput = {
49
+ companySlug?: string | undefined;
50
+ page?: number | undefined;
51
+ pageSize?: number | undefined;
52
+ };
53
+ export declare class FikenClient {
54
+ private readonly db;
55
+ private readonly settings;
56
+ private readonly connection;
57
+ private readonly metadata;
58
+ private readonly context;
59
+ private readonly fetchImpl;
60
+ private readonly resolveCredential;
61
+ constructor(db: Database, settings: Settings, connection: ConnectionMetadata, metadata: FikenConnectionMetadata, context: FikenContext, fetchImpl?: FetchLike);
62
+ listCompanies(input?: {
63
+ page?: number;
64
+ pageSize?: number;
65
+ }): Promise<{
66
+ companies: Record<string, unknown>[];
67
+ page: FikenPage | null;
68
+ }>;
69
+ listContacts(input: FikenListInput & {
70
+ name?: string | undefined;
71
+ email?: string | undefined;
72
+ organizationNumber?: string | undefined;
73
+ customer?: boolean | undefined;
74
+ supplier?: boolean | undefined;
75
+ inactive?: boolean | undefined;
76
+ }): Promise<{
77
+ companySlug: string;
78
+ contacts: Record<string, unknown>[];
79
+ page: FikenPage | null;
80
+ }>;
81
+ createContact(input: {
82
+ companySlug?: string | undefined;
83
+ name: string;
84
+ email?: string | undefined;
85
+ organizationNumber?: string | undefined;
86
+ phoneNumber?: string | undefined;
87
+ customer?: boolean | undefined;
88
+ supplier?: boolean | undefined;
89
+ }): Promise<{
90
+ companySlug: string;
91
+ contactId: number;
92
+ receipt: {
93
+ credentialRole: "fiken_api_token";
94
+ credentialLabel: "Fiken API token";
95
+ connectionId: string;
96
+ operation: FikenOperation;
97
+ operationId?: string;
98
+ };
99
+ }>;
100
+ listProducts(input: FikenListInput & {
101
+ name?: string | undefined;
102
+ active?: boolean | undefined;
103
+ }): Promise<{
104
+ companySlug: string;
105
+ products: Record<string, unknown>[];
106
+ page: FikenPage | null;
107
+ }>;
108
+ listInvoices(input: FikenListInput & {
109
+ issueDateGe?: string | undefined;
110
+ issueDateLe?: string | undefined;
111
+ customerId?: number | undefined;
112
+ settled?: boolean | undefined;
113
+ invoiceNumber?: string | undefined;
114
+ }): Promise<{
115
+ companySlug: string;
116
+ invoices: Record<string, unknown>[];
117
+ page: FikenPage | null;
118
+ }>;
119
+ getInvoice(input: {
120
+ companySlug?: string | undefined;
121
+ invoiceId: number;
122
+ }): Promise<{
123
+ companySlug: string;
124
+ invoice: Record<string, unknown> | null;
125
+ }>;
126
+ createInvoiceDraft(input: {
127
+ companySlug?: string | undefined;
128
+ operationId: string;
129
+ customerId: number;
130
+ daysUntilDueDate: number;
131
+ invoiceText?: string | undefined;
132
+ yourReference?: string | undefined;
133
+ ourReference?: string | undefined;
134
+ currency?: string | undefined;
135
+ bankAccountNumber?: string | undefined;
136
+ lines: Array<{
137
+ description?: string | undefined;
138
+ productId?: number | undefined;
139
+ unitPriceCents?: number | undefined;
140
+ vatType?: string | undefined;
141
+ quantity: number;
142
+ discountPercent?: number | undefined;
143
+ incomeAccount?: string | undefined;
144
+ comment?: string | undefined;
145
+ }>;
146
+ }): Promise<{
147
+ companySlug: string;
148
+ draftId: number | null;
149
+ draft: Record<string, unknown>;
150
+ alreadyExisted: boolean;
151
+ receipt: {
152
+ credentialRole: "fiken_api_token";
153
+ credentialLabel: "Fiken API token";
154
+ connectionId: string;
155
+ operation: FikenOperation;
156
+ operationId?: string;
157
+ };
158
+ } | {
159
+ draft?: never;
160
+ companySlug: string;
161
+ draftId: number;
162
+ alreadyExisted: boolean;
163
+ receipt: {
164
+ credentialRole: "fiken_api_token";
165
+ credentialLabel: "Fiken API token";
166
+ connectionId: string;
167
+ operation: FikenOperation;
168
+ operationId?: string;
169
+ };
170
+ }>;
171
+ listBankAccounts(input: FikenListInput & {
172
+ inactive?: boolean | undefined;
173
+ }): Promise<{
174
+ companySlug: string;
175
+ bankAccounts: Record<string, unknown>[];
176
+ page: FikenPage | null;
177
+ }>;
178
+ listPurchases(input: FikenListInput & {
179
+ dateGe?: string | undefined;
180
+ dateLe?: string | undefined;
181
+ paid?: boolean | undefined;
182
+ }): Promise<{
183
+ companySlug: string;
184
+ purchases: Record<string, unknown>[];
185
+ page: FikenPage | null;
186
+ }>;
187
+ listSales(input: FikenListInput & {
188
+ dateGe?: string | undefined;
189
+ dateLe?: string | undefined;
190
+ settled?: boolean | undefined;
191
+ }): Promise<{
192
+ companySlug: string;
193
+ sales: Record<string, unknown>[];
194
+ page: FikenPage | null;
195
+ }>;
196
+ /**
197
+ * The company scope for a call: an explicit slug wins, then the connection's
198
+ * configured default, then the only verified company. Ambiguity is an error
199
+ * that lists the available slugs instead of guessing.
200
+ */
201
+ private companySlugFor;
202
+ private request;
203
+ private readResponse;
204
+ private markNeedsReauth;
205
+ private headersFor;
206
+ private receipt;
207
+ private recordAudit;
208
+ }
209
+ export declare function createFikenClient(deps: {
210
+ db: Database;
211
+ settings: Settings;
212
+ fikenFetch?: typeof fetch;
213
+ }, resolved: Awaited<ReturnType<typeof resolveFikenConnectionForTool>>): FikenClient;
214
+ export declare class FikenOAuthCallbackError extends Error {
215
+ readonly reason: string;
216
+ constructor(reason: string);
217
+ }
218
+ export declare function startFikenOAuth(deps: ApiRouteDeps, input: {
219
+ accountId: string;
220
+ workspaceId: string;
221
+ subjectId: string;
222
+ requestUrl: string;
223
+ payload: FikenOAuthStartRequest;
224
+ }): Promise<FikenOAuthStartResponse>;
225
+ export declare function completeFikenOAuthCallback(deps: ApiRouteDeps, input: {
226
+ code?: string | undefined;
227
+ state?: string | undefined;
228
+ error?: string | undefined;
229
+ requestUrl: string;
230
+ }): Promise<{
231
+ redirectTo: string;
232
+ }>;
233
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { Settings } from "@opengeni/config";
2
+ import type { GitHubSkillSourceClient } from "@opengeni/core";
3
+ type GitHubJsonRequest = (path: string, maxBytes: number, label: string) => Promise<unknown>;
4
+ export declare function createGitHubSkillSourceClient(settings: Settings, requestJson?: GitHubJsonRequest): GitHubSkillSourceClient;
5
+ export {};
@@ -1,6 +1,19 @@
1
+ import type { AccessGrant, ScheduledTask } from "@opengeni/contracts";
1
2
  import { GoogleDriveOAuthStartResponse, type GoogleDriveDisconnectRequest, type GoogleDriveLifecycleActionRequest, type GoogleDriveOAuthStartRequest } from "@opengeni/contracts/google-drive";
3
+ import { IntegrationFacetMutationResult } from "@opengeni/contracts";
2
4
  import type { ApiRouteDeps } from "@opengeni/core";
3
5
  import { getConnectionMetadata } from "@opengeni/db";
6
+ export declare function wakeGoogleDriveSourcesFromWorkspaceEvent(deps: ApiRouteDeps, input: {
7
+ accountId: string;
8
+ workspaceId: string;
9
+ connectionId: string;
10
+ connectionOwnerSubjectId: string;
11
+ eventId: string;
12
+ driveId: string | null;
13
+ }): Promise<{
14
+ enabled: boolean;
15
+ triggered: number;
16
+ }>;
4
17
  type GoogleDriveConnectionRecord = NonNullable<Awaited<ReturnType<typeof getConnectionMetadata>>>;
5
18
  export declare function startGoogleDriveOAuth(deps: ApiRouteDeps, input: {
6
19
  accountId: string;
@@ -82,14 +95,86 @@ export declare function browseGoogleDrive(deps: ApiRouteDeps, input: {
82
95
  nextPageToken: string | null;
83
96
  incompleteSearch: boolean;
84
97
  }>;
98
+ export declare function browseGoogleDriveFacetSource(deps: ApiRouteDeps, input: {
99
+ workspaceId: string;
100
+ subjectId: string;
101
+ capabilityId: string;
102
+ instanceKey: string;
103
+ facetKey: string;
104
+ parentId: string;
105
+ pageToken?: string | undefined;
106
+ }): Promise<{
107
+ connection: {
108
+ id: string;
109
+ accountId: string;
110
+ workspaceId: string;
111
+ subjectId: string | null;
112
+ providerDomain: string;
113
+ kind: "api_key" | "app_install" | "delegated" | "oauth2";
114
+ status: "active" | "error" | "needs_reauth" | "revoked";
115
+ grantedScopes: string[];
116
+ expiresAt: string | null;
117
+ lastRefreshAt: string | null;
118
+ lastUsedAt: string | null;
119
+ lastError: string | null;
120
+ version: number;
121
+ verifiedInstallAt?: string | null | undefined;
122
+ verifiedInstallVersion?: number | null | undefined;
123
+ metadata: Record<string, unknown>;
124
+ createdBySubjectId: string | null;
125
+ updatedBySubjectId: string | null;
126
+ createdAt: string;
127
+ updatedAt: string;
128
+ };
129
+ parentId: string;
130
+ current: {
131
+ id: string;
132
+ name: string;
133
+ mimeType: string;
134
+ kind: "file" | "folder";
135
+ driveId: string | null;
136
+ modifiedTime: string | null;
137
+ size: string | null;
138
+ webViewLink: string | null;
139
+ } | null;
140
+ items: {
141
+ id: string;
142
+ name: string;
143
+ mimeType: string;
144
+ kind: "file" | "folder";
145
+ driveId: string | null;
146
+ modifiedTime: string | null;
147
+ size: string | null;
148
+ webViewLink: string | null;
149
+ }[];
150
+ nextPageToken: string | null;
151
+ incompleteSearch: boolean;
152
+ }>;
153
+ export declare function saveGoogleDriveFacetSource(deps: ApiRouteDeps, input: {
154
+ accountId: string;
155
+ workspaceId: string;
156
+ subjectId: string;
157
+ capabilityId: string;
158
+ instanceKey: string;
159
+ facetKey: string;
160
+ payload: unknown;
161
+ canManageOrganizationDestination: boolean;
162
+ canManageWorkspaceDestination: boolean;
163
+ canManagePersonalDestination: boolean;
164
+ }): Promise<IntegrationFacetMutationResult>;
85
165
  export declare function saveGoogleDriveSource(deps: ApiRouteDeps, input: {
86
166
  accountId: string;
87
167
  workspaceId: string;
88
168
  subjectId: string;
89
169
  connectionId: string;
170
+ grant: AccessGrant;
90
171
  payload: unknown;
91
172
  canManageOrganizationDestination: boolean;
92
173
  canManageWorkspaceDestination: boolean;
93
174
  canManagePersonalDestination: boolean;
94
175
  }): Promise<import("@opengeni/db").ConnectionMetadataWithVerification>;
176
+ export declare function revokeKnowledgeSourceScheduleAuthorization(deps: ApiRouteDeps, input: {
177
+ task: ScheduledTask;
178
+ subjectId: string;
179
+ }): Promise<void>;
95
180
  export {};
@@ -1,9 +1,11 @@
1
1
  import { type Settings } from "@opengeni/config";
2
- import { OAuthStartResponse, type OAuthStartRequest } from "@opengeni/contracts";
2
+ import { OAuthStartResponse, type ConnectionOwnership, type OAuthStartRequest } from "@opengeni/contracts";
3
3
  import type { Observability } from "@opengeni/observability";
4
4
  import { type Database } from "@opengeni/db";
5
5
  export declare const oauthStateTtlMs: number;
6
6
  export declare const OFFICIAL_SLACK_MCP_URL: "https://mcp.slack.com/mcp";
7
+ export declare const OFFICIAL_GMAIL_MCP_URL = "https://gmailmcp.googleapis.com/mcp/v1";
8
+ export declare const OFFICIAL_GMAIL_MCP_SCOPES: readonly ["https://www.googleapis.com/auth/gmail.readonly", "https://www.googleapis.com/auth/gmail.compose", "https://www.googleapis.com/auth/gmail.modify"];
7
9
  export { OAUTH_MAX_RESPONSE_BYTES } from "@opengeni/network";
8
10
  type OAuthClientDeps = {
9
11
  db: Database;
@@ -37,6 +39,7 @@ export declare const OAUTH_START_DEADLINE_MS = 15000;
37
39
  export declare const OAUTH_CALLBACK_DEADLINE_MS = 30000;
38
40
  export type OAuthStartStage = "connection_lookup" | "mcp_challenge" | "protected_resource_metadata" | "authorization_server_metadata" | "client_registration";
39
41
  export declare function startMcpOAuth(deps: OAuthClientDeps, context: OAuthStartContext): Promise<OAuthStartResponse>;
42
+ export declare function assertOfficialGmailPersonalOwnership(mcpUrl: string, ownership: ConnectionOwnership): void;
40
43
  export declare function completeMcpOAuthCallback(deps: OAuthClientDeps, input: {
41
44
  code?: string | undefined;
42
45
  state?: string | undefined;
@@ -45,6 +48,18 @@ export declare function completeMcpOAuthCallback(deps: OAuthClientDeps, input: {
45
48
  export declare function integrationBaseUrl(publicBaseUrl: string | undefined, requestUrl: string): string;
46
49
  export declare function requireIntegrationsStateSecret(settings: Settings): string;
47
50
  export declare function assertSlackAuthorizationServer(as: AuthorizationServerMetadata): void;
51
+ export declare function assertGoogleAuthorizationServer(as: AuthorizationServerMetadata): void;
52
+ export declare function buildAuthorizationUrl(input: {
53
+ endpoint: string;
54
+ settings: Settings;
55
+ clientId: string;
56
+ redirectUri: string;
57
+ state: string;
58
+ resource: string;
59
+ verifier: string;
60
+ scopes: string[];
61
+ resourceParameterSupported: boolean;
62
+ }): string;
48
63
  export type OAuthPublicErrorFields = {
49
64
  errorClass: "OAuthOperationError";
50
65
  errorCode: "oauth_operation_failed";
@@ -53,3 +68,9 @@ export type OAuthPublicErrorFields = {
53
68
  };
54
69
  /** Allowlisted projection for public telemetry; canonical OAuth errors stay exact. */
55
70
  export declare function oauthPublicErrorFields(error: unknown): OAuthPublicErrorFields;
71
+ export declare function chooseMcpAuthorizeScopes(input: {
72
+ mcpUrl: string;
73
+ requested: string[] | undefined;
74
+ challenged: string[] | undefined;
75
+ supported: string[];
76
+ }): string[];
@@ -0,0 +1,17 @@
1
+ import { OAuthStartResponse, type ApiIntegrationOAuthStartRequest } from "@opengeni/contracts";
2
+ import { type ApiRouteDeps } from "@opengeni/core";
3
+ export declare function startApiIntegrationProviderOAuth(deps: ApiRouteDeps, input: {
4
+ accountId: string;
5
+ workspaceId: string;
6
+ subjectId: string;
7
+ requestUrl: string;
8
+ payload: ApiIntegrationOAuthStartRequest;
9
+ }): Promise<OAuthStartResponse>;
10
+ export declare function completeApiIntegrationProviderOAuth(deps: ApiRouteDeps, input: {
11
+ code?: string | undefined;
12
+ state?: string | undefined;
13
+ error?: string | undefined;
14
+ requestUrl: string;
15
+ }): Promise<{
16
+ redirectTo: string;
17
+ }>;