@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,142 @@
|
|
|
1
|
+
import type { Settings } from "@opengeni/config";
|
|
2
|
+
import type { GitHubSkillSourceClient, GitHubSkillTreeEntry } from "@opengeni/core";
|
|
3
|
+
import { pinnedFetch, readResponseJsonBounded, readResponseTextBounded } from "@opengeni/network";
|
|
4
|
+
|
|
5
|
+
const githubApiBase = "https://api.github.com";
|
|
6
|
+
const githubRequestTimeoutMs = 15_000;
|
|
7
|
+
const githubMetadataMaxBytes = 4 * 1024 * 1024;
|
|
8
|
+
const githubBlobResponseMaxBytes = 512 * 1024;
|
|
9
|
+
|
|
10
|
+
type GitHubJsonRequest = (path: string, maxBytes: number, label: string) => Promise<unknown>;
|
|
11
|
+
|
|
12
|
+
export function createGitHubSkillSourceClient(
|
|
13
|
+
settings: Settings,
|
|
14
|
+
requestJson: GitHubJsonRequest = (path, maxBytes, label) =>
|
|
15
|
+
githubJson(settings, path, maxBytes, label),
|
|
16
|
+
): GitHubSkillSourceClient {
|
|
17
|
+
return {
|
|
18
|
+
resolveCommit: async (owner, repository, ref) => {
|
|
19
|
+
const payload = recordValue(
|
|
20
|
+
await requestJson(
|
|
21
|
+
`/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repository)}/commits/${encodeURIComponent(ref)}`,
|
|
22
|
+
githubMetadataMaxBytes,
|
|
23
|
+
"GitHub Skill commit",
|
|
24
|
+
),
|
|
25
|
+
"GitHub commit",
|
|
26
|
+
);
|
|
27
|
+
const sha = stringValue(payload.sha);
|
|
28
|
+
if (!sha) throw new Error("GitHub commit response omitted sha");
|
|
29
|
+
return sha.toLowerCase();
|
|
30
|
+
},
|
|
31
|
+
listTree: async (owner, repository, commit) => {
|
|
32
|
+
const payload = recordValue(
|
|
33
|
+
await requestJson(
|
|
34
|
+
`/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repository)}/git/trees/${encodeURIComponent(commit)}?recursive=1`,
|
|
35
|
+
githubMetadataMaxBytes,
|
|
36
|
+
"GitHub Skill tree",
|
|
37
|
+
),
|
|
38
|
+
"GitHub tree",
|
|
39
|
+
);
|
|
40
|
+
if (payload.truncated === true) {
|
|
41
|
+
throw new Error("GitHub repository tree is too large to import safely");
|
|
42
|
+
}
|
|
43
|
+
if (!Array.isArray(payload.tree)) throw new Error("GitHub tree response omitted entries");
|
|
44
|
+
return payload.tree.map((entry, index): GitHubSkillTreeEntry => {
|
|
45
|
+
const record = recordValue(entry, `GitHub tree entry ${index}`);
|
|
46
|
+
const path = stringValue(record.path);
|
|
47
|
+
const type = stringValue(record.type);
|
|
48
|
+
const mode = stringValue(record.mode);
|
|
49
|
+
const sha = stringValue(record.sha);
|
|
50
|
+
const size = record.size;
|
|
51
|
+
if (
|
|
52
|
+
!path ||
|
|
53
|
+
(type !== "blob" && type !== "tree" && type !== "commit") ||
|
|
54
|
+
!mode ||
|
|
55
|
+
!sha ||
|
|
56
|
+
(size !== undefined &&
|
|
57
|
+
size !== null &&
|
|
58
|
+
(typeof size !== "number" || !Number.isSafeInteger(size) || size < 0))
|
|
59
|
+
) {
|
|
60
|
+
throw new Error(`GitHub tree entry ${index} is invalid`);
|
|
61
|
+
}
|
|
62
|
+
return { path, type, mode, sha, size: typeof size === "number" ? size : null };
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
readBlob: async (owner, repository, sha) => {
|
|
66
|
+
const payload = recordValue(
|
|
67
|
+
await requestJson(
|
|
68
|
+
`/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repository)}/git/blobs/${encodeURIComponent(sha)}`,
|
|
69
|
+
githubBlobResponseMaxBytes,
|
|
70
|
+
"GitHub Skill file",
|
|
71
|
+
),
|
|
72
|
+
"GitHub blob",
|
|
73
|
+
);
|
|
74
|
+
if (payload.encoding !== "base64" || typeof payload.content !== "string") {
|
|
75
|
+
throw new Error("GitHub Skill file did not use base64 encoding");
|
|
76
|
+
}
|
|
77
|
+
const normalized = payload.content.replace(/\s+/gu, "");
|
|
78
|
+
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u.test(normalized)) {
|
|
79
|
+
throw new Error("GitHub Skill file contained invalid base64");
|
|
80
|
+
}
|
|
81
|
+
const bytes = Uint8Array.from(Buffer.from(normalized, "base64"));
|
|
82
|
+
if (
|
|
83
|
+
typeof payload.size === "number" &&
|
|
84
|
+
Number.isSafeInteger(payload.size) &&
|
|
85
|
+
payload.size !== bytes.byteLength
|
|
86
|
+
) {
|
|
87
|
+
throw new Error("GitHub Skill file size did not match its payload");
|
|
88
|
+
}
|
|
89
|
+
return bytes;
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function githubJson(
|
|
95
|
+
settings: Settings,
|
|
96
|
+
path: string,
|
|
97
|
+
maxBytes: number,
|
|
98
|
+
label: string,
|
|
99
|
+
): Promise<unknown> {
|
|
100
|
+
const controller = new AbortController();
|
|
101
|
+
const timeout = setTimeout(() => controller.abort(), githubRequestTimeoutMs);
|
|
102
|
+
try {
|
|
103
|
+
const response = await pinnedFetch(
|
|
104
|
+
`${githubApiBase}${path}`,
|
|
105
|
+
{
|
|
106
|
+
method: "GET",
|
|
107
|
+
headers: {
|
|
108
|
+
accept: "application/vnd.github+json",
|
|
109
|
+
"user-agent": "OpenGeni-Capabilities",
|
|
110
|
+
"x-github-api-version": "2022-11-28",
|
|
111
|
+
},
|
|
112
|
+
signal: controller.signal,
|
|
113
|
+
},
|
|
114
|
+
settings,
|
|
115
|
+
{ label, requireHttpsOutsideLocalTest: true },
|
|
116
|
+
);
|
|
117
|
+
if (!response.ok) {
|
|
118
|
+
await readResponseTextBounded(response, 8_192, `${label} error`).catch(() => undefined);
|
|
119
|
+
if (response.status === 404) throw new Error(`${label} was not found or is not public`);
|
|
120
|
+
if (response.status === 403 || response.status === 429) {
|
|
121
|
+
throw new Error(`${label} is temporarily unavailable because GitHub limited the request`);
|
|
122
|
+
}
|
|
123
|
+
throw new Error(`${label} failed with HTTP ${response.status}`);
|
|
124
|
+
}
|
|
125
|
+
return await readResponseJsonBounded(response, maxBytes, label, {
|
|
126
|
+
signal: controller.signal,
|
|
127
|
+
});
|
|
128
|
+
} finally {
|
|
129
|
+
clearTimeout(timeout);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function recordValue(value: unknown, label: string): Record<string, unknown> {
|
|
134
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
135
|
+
throw new Error(`${label} response is invalid`);
|
|
136
|
+
}
|
|
137
|
+
return value as Record<string, unknown>;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function stringValue(value: unknown): string | null {
|
|
141
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
142
|
+
}
|