@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.
- package/dist/app.d.ts +3 -2
- package/dist/app.js +5 -3
- package/dist/auth/canonical-human-session-admission.d.ts +27 -0
- package/dist/browser-auth-broker.d.ts +20 -0
- package/dist/browser-controller-authority.d.ts +61 -0
- package/dist/browser-network-route.d.ts +8 -0
- package/dist/browser-state-authority.d.ts +27 -0
- package/dist/{chunk-T4T2PGU4.js → chunk-2PQMSRCB.js} +37891 -17463
- package/dist/chunk-2PQMSRCB.js.map +1 -0
- package/dist/codemode.d.ts +23 -0
- package/dist/controller-data-plane.d.ts +12 -0
- package/dist/editable-artifact-live-hints.d.ts +11 -0
- package/dist/editable-artifact-native-kernel.d.ts +37 -0
- package/dist/editable-artifact-office-import.d.ts +22 -0
- package/dist/editable-artifact-production.d.ts +29 -0
- package/dist/editable-artifact-websocket.d.ts +49 -0
- package/dist/editable-artifact-workspace-files.d.ts +23 -0
- package/dist/github-browser-flow.d.ts +6 -0
- package/dist/http/auth.d.ts +1 -1
- package/dist/http/cors.d.ts +1 -0
- package/dist/http/sse.d.ts +18 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1796 -22
- package/dist/index.js.map +1 -1
- package/dist/integrations/api-integrations.d.ts +24 -0
- package/dist/integrations/atlassian.d.ts +176 -0
- package/dist/integrations/fiken.d.ts +233 -0
- package/dist/integrations/github-skill-source.d.ts +5 -0
- package/dist/integrations/google-drive.d.ts +85 -0
- package/dist/integrations/oauth-client.d.ts +22 -1
- package/dist/integrations/provider-oauth.d.ts +17 -0
- package/dist/integrations/slack-bot.d.ts +175 -1
- package/dist/integrations/slack-interactions.d.ts +24 -6
- package/dist/integrations/social-api.d.ts +2 -1
- package/dist/interaction-holder-heartbeat.d.ts +17 -0
- package/dist/interaction-metrics.d.ts +11 -0
- package/dist/mcp/editable-artifact-query-schema.d.ts +4 -0
- package/dist/mcp/editable-artifacts.d.ts +13 -0
- package/dist/mcp/scheduled-task-view.d.ts +168 -0
- package/dist/mcp/server.d.ts +16 -4
- package/dist/memory-slack-delivery.d.ts +9 -0
- package/dist/model-catalog.d.ts +1 -0
- package/dist/routes/api-integrations.d.ts +8 -0
- package/dist/routes/browser-identities.d.ts +5 -0
- package/dist/routes/browser-sessions.d.ts +6 -0
- package/dist/routes/canonical-human-identities.d.ts +3 -0
- package/dist/routes/channels.d.ts +3 -0
- package/dist/routes/company-profile.d.ts +3 -0
- package/dist/routes/computer-sessions.d.ts +6 -0
- package/dist/routes/editable-artifacts.d.ts +44 -0
- package/dist/routes/integration-facets.d.ts +3 -0
- package/dist/routes/interaction-resources.d.ts +5 -0
- package/dist/routes/memory-slack-publications.d.ts +6 -0
- package/dist/routes/organization-memberships.d.ts +3 -0
- package/dist/routes/plugins.d.ts +8 -0
- package/dist/routes/sessions.d.ts +18 -2
- package/dist/routes/skills.d.ts +6 -0
- package/dist/routes/slack-task-policy.d.ts +3 -0
- package/dist/routes/supergrok.d.ts +3 -0
- package/dist/routes/video-generation.d.ts +3 -0
- package/dist/sandbox/channel-a.d.ts +62 -2
- package/dist/sandbox/machines.d.ts +2 -2
- package/dist/sandbox/metrics-ingestion.d.ts +6 -1
- package/dist/sandbox/viewer.d.ts +7 -3
- package/dist/slack-reaction-files.d.ts +27 -0
- package/dist/temporal-schedule-cleanup.d.ts +26 -0
- package/dist/transcription/providers/xai-subscription.d.ts +8 -0
- package/dist/xai-realtime.d.ts +26 -0
- package/dist/xai-subscription-auth.d.ts +23 -0
- package/package.json +20 -14
- package/src/app.ts +604 -64
- package/src/auth/canonical-human-session-admission.ts +116 -0
- package/src/auth/managed-auth.ts +101 -0
- package/src/browser-auth-broker.ts +155 -0
- package/src/browser-controller-authority.ts +186 -0
- package/src/browser-network-route.ts +34 -0
- package/src/browser-state-authority.ts +236 -0
- package/src/codemode.ts +186 -0
- package/src/controller-data-plane.ts +35 -0
- package/src/editable-artifact-live-hints.ts +64 -0
- package/src/editable-artifact-native-kernel.ts +659 -0
- package/src/editable-artifact-office-import.ts +230 -0
- package/src/editable-artifact-production.ts +419 -0
- package/src/editable-artifact-websocket.ts +311 -0
- package/src/editable-artifact-workspace-files.ts +186 -0
- package/src/github-browser-flow.ts +35 -6
- package/src/http/auth.ts +29 -9
- package/src/http/cors.ts +3 -0
- package/src/http/sse.ts +229 -5
- package/src/index.ts +119 -20
- package/src/integrations/api-integrations.ts +365 -0
- package/src/integrations/atlassian.ts +1621 -0
- package/src/integrations/fiken.ts +1230 -0
- package/src/integrations/github-skill-source.ts +142 -0
- package/src/integrations/google-drive.ts +1005 -64
- package/src/integrations/oauth-client.ts +123 -33
- package/src/integrations/provider-oauth.ts +756 -0
- package/src/integrations/slack-bot.ts +669 -11
- package/src/integrations/slack-interactions.ts +2063 -93
- package/src/integrations/social-api.ts +11 -0
- package/src/interaction-holder-heartbeat.ts +95 -0
- package/src/interaction-metrics.ts +159 -0
- package/src/mcp/documents.ts +146 -6
- package/src/mcp/editable-artifact-query-schema.ts +236 -0
- package/src/mcp/editable-artifacts.ts +448 -0
- package/src/mcp/scheduled-task-view.ts +34 -0
- package/src/mcp/server.ts +1756 -355
- package/src/memory-slack-delivery.ts +209 -0
- package/src/model-catalog.ts +19 -6
- package/src/routes/api-integrations.ts +410 -0
- package/src/routes/browser-identities.ts +160 -0
- package/src/routes/browser-sessions.ts +4482 -0
- package/src/routes/canonical-human-identities.ts +156 -0
- package/src/routes/channels.ts +90 -0
- package/src/routes/company-profile.ts +255 -0
- package/src/routes/computer-sessions.ts +1602 -0
- package/src/routes/connections.ts +421 -99
- package/src/routes/documents.ts +22 -3
- package/src/routes/editable-artifacts.ts +1159 -0
- package/src/routes/files.ts +106 -4
- package/src/routes/github.ts +18 -2
- package/src/routes/install.ts +7 -1
- package/src/routes/integration-facets.ts +258 -0
- package/src/routes/interaction-resources.ts +595 -0
- package/src/routes/memory-slack-publications.ts +216 -0
- package/src/routes/organization-memberships.ts +53 -0
- package/src/routes/packs.ts +437 -7
- package/src/routes/plugins.ts +752 -0
- package/src/routes/rigs.ts +77 -20
- package/src/routes/scheduled-tasks.ts +67 -40
- package/src/routes/sessions.ts +830 -278
- package/src/routes/skills.ts +256 -0
- package/src/routes/slack-task-policy.ts +115 -0
- package/src/routes/supergrok.ts +717 -0
- package/src/routes/transcription-recordings.ts +9 -2
- package/src/routes/transcriptions.ts +2 -1
- package/src/routes/video-generation.ts +162 -0
- package/src/routes/workspaces.ts +68 -28
- package/src/sandbox/channel-a.ts +750 -116
- package/src/sandbox/machines.ts +5 -5
- package/src/sandbox/metrics-ingestion.ts +121 -3
- package/src/sandbox/rematerialize.ts +35 -47
- package/src/sandbox/viewer.ts +39 -12
- package/src/slack-reaction-files.ts +181 -0
- package/src/temporal-schedule-cleanup.ts +135 -0
- package/src/transcription/providers/xai-subscription.ts +110 -0
- package/src/transcription/service.ts +17 -2
- package/src/xai-realtime.ts +216 -0
- package/src/xai-subscription-auth.ts +132 -0
- package/dist/chunk-T4T2PGU4.js.map +0 -1
- package/dist/mcp/toolspace.d.ts +0 -71
- package/src/mcp/toolspace.ts +0 -1190
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { environmentsEncryptionKeyBytes, type Settings } from "@opengeni/config";
|
|
2
|
+
import type { XaiProviderAccountAuthoritySnapshotV1 } from "@opengeni/contracts";
|
|
3
|
+
import {
|
|
4
|
+
materializeXaiCredentialForRun,
|
|
5
|
+
refreshXaiSubscriptionCredentialSerialized,
|
|
6
|
+
resolveXaiProviderAccountAuthoritySnapshotForAcceptance,
|
|
7
|
+
selectXaiCredentialForUse,
|
|
8
|
+
type Database,
|
|
9
|
+
} from "@opengeni/db";
|
|
10
|
+
import {
|
|
11
|
+
refreshXaiToken,
|
|
12
|
+
XAI_CLIENT_VERSION,
|
|
13
|
+
XaiSubscriptionReloginRequired,
|
|
14
|
+
xaiAccessTokenExpiry,
|
|
15
|
+
type XaiFetch,
|
|
16
|
+
type XaiProxyAuthContext,
|
|
17
|
+
} from "@opengeni/xai-subscription";
|
|
18
|
+
|
|
19
|
+
export type XaiSubscriptionAuthorization = {
|
|
20
|
+
context: XaiProxyAuthContext;
|
|
21
|
+
credentialId: string;
|
|
22
|
+
authoritySnapshot: XaiProviderAccountAuthoritySnapshotV1;
|
|
23
|
+
rotationEnabled: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export async function buildXaiSubscriptionAuthorization(input: {
|
|
27
|
+
db: Database;
|
|
28
|
+
settings: Settings;
|
|
29
|
+
accountId: string;
|
|
30
|
+
workspaceId: string;
|
|
31
|
+
subjectId: string;
|
|
32
|
+
shardKey: string;
|
|
33
|
+
pinnedCredentialId?: string | null;
|
|
34
|
+
pinSource?: "manual" | "policy" | null;
|
|
35
|
+
authoritySnapshot?: XaiProviderAccountAuthoritySnapshotV1;
|
|
36
|
+
sessionId?: string;
|
|
37
|
+
fetch?: XaiFetch;
|
|
38
|
+
}): Promise<XaiSubscriptionAuthorization> {
|
|
39
|
+
const encryptionKey = environmentsEncryptionKeyBytes(input.settings);
|
|
40
|
+
if (!encryptionKey) {
|
|
41
|
+
throw new Error("SuperGrok subscriptions require OPENGENI_ENVIRONMENTS_ENCRYPTION_KEY");
|
|
42
|
+
}
|
|
43
|
+
const authoritySnapshot =
|
|
44
|
+
input.authoritySnapshot ??
|
|
45
|
+
(await resolveXaiProviderAccountAuthoritySnapshotForAcceptance(input.db, {
|
|
46
|
+
workspaceId: input.workspaceId,
|
|
47
|
+
subjectId: input.subjectId,
|
|
48
|
+
}));
|
|
49
|
+
const selected = await selectXaiCredentialForUse(input.db, {
|
|
50
|
+
accountId: input.accountId,
|
|
51
|
+
workspaceId: input.workspaceId,
|
|
52
|
+
subjectId: input.subjectId,
|
|
53
|
+
authoritySnapshot,
|
|
54
|
+
shardKey: input.shardKey,
|
|
55
|
+
pinnedCredentialId: input.pinnedCredentialId ?? null,
|
|
56
|
+
pinSource: input.pinSource ?? null,
|
|
57
|
+
});
|
|
58
|
+
if (!selected.credentialId) {
|
|
59
|
+
throw new Error("No eligible SuperGrok subscription account is available");
|
|
60
|
+
}
|
|
61
|
+
const credentialId = selected.credentialId;
|
|
62
|
+
let credential = await materializeXaiCredentialForRun(input.db, {
|
|
63
|
+
workspaceId: input.workspaceId,
|
|
64
|
+
subjectId: input.subjectId,
|
|
65
|
+
credentialId,
|
|
66
|
+
authoritySnapshot,
|
|
67
|
+
encryptionKey,
|
|
68
|
+
});
|
|
69
|
+
const tokenSnapshot = () => {
|
|
70
|
+
if (!credential.secret.accessToken || !credential.providerAccountId) {
|
|
71
|
+
throw new XaiSubscriptionReloginRequired(
|
|
72
|
+
"The SuperGrok connection is missing a verified token identity. Reconnect the account.",
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
accessToken: credential.secret.accessToken,
|
|
77
|
+
userId: credential.providerAccountId,
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
credentialId,
|
|
82
|
+
authoritySnapshot,
|
|
83
|
+
rotationEnabled: selected.rotationEnabled,
|
|
84
|
+
context: {
|
|
85
|
+
clientVersion: XAI_CLIENT_VERSION,
|
|
86
|
+
...(input.sessionId ? { sessionId: input.sessionId } : {}),
|
|
87
|
+
getToken: async () => tokenSnapshot(),
|
|
88
|
+
refresh: async () => {
|
|
89
|
+
const observedAccessToken = credential.secret.accessToken;
|
|
90
|
+
const observedRefreshToken = credential.secret.refreshToken;
|
|
91
|
+
if (!observedRefreshToken) {
|
|
92
|
+
throw new XaiSubscriptionReloginRequired(
|
|
93
|
+
"The SuperGrok connection cannot be refreshed. Reconnect the account.",
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
const result = await refreshXaiSubscriptionCredentialSerialized(input.db, {
|
|
97
|
+
accountId: input.accountId,
|
|
98
|
+
workspaceId: input.workspaceId,
|
|
99
|
+
subjectId: input.subjectId,
|
|
100
|
+
credentialId,
|
|
101
|
+
authoritySnapshot,
|
|
102
|
+
encryptionKey,
|
|
103
|
+
observedAccessToken,
|
|
104
|
+
observedRefreshToken,
|
|
105
|
+
refresh: async (current) => {
|
|
106
|
+
const refreshToken = current.secret.refreshToken;
|
|
107
|
+
if (!refreshToken) {
|
|
108
|
+
throw new XaiSubscriptionReloginRequired(
|
|
109
|
+
"The SuperGrok connection cannot be refreshed. Reconnect the account.",
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
const tokens = await refreshXaiToken(refreshToken, {
|
|
113
|
+
...(input.fetch ? { fetch: input.fetch } : {}),
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
secret: {
|
|
117
|
+
version: 1,
|
|
118
|
+
accessToken: tokens.accessToken,
|
|
119
|
+
refreshToken: tokens.refreshToken,
|
|
120
|
+
},
|
|
121
|
+
expiresAt:
|
|
122
|
+
xaiAccessTokenExpiry(tokens.accessToken) ??
|
|
123
|
+
new Date(Date.now() + tokens.expiresInSeconds * 1_000),
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
credential = result.credential;
|
|
128
|
+
return tokenSnapshot();
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|