@opengeni/api-router 0.5.2 → 0.5.4
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-YY6OAEL6.js → chunk-DO2G3JSB.js} +5333 -2205
- package/dist/chunk-DO2G3JSB.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +297 -54
- package/dist/index.js.map +1 -1
- package/package.json +21 -21
- package/src/app.ts +415 -147
- package/src/auth/managed-auth.ts +32 -16
- package/src/http/auth.ts +8 -1
- package/src/http/common.ts +6 -2
- package/src/http/sse.ts +27 -6
- package/src/index.ts +196 -74
- package/src/integrations/oauth-client.ts +592 -131
- package/src/integrations/provider-domain.ts +4 -1
- package/src/mcp/documents.ts +173 -94
- package/src/mcp/server.ts +1517 -692
- package/src/mcp/session-view.ts +8 -2
- package/src/mcp/toolspace.ts +175 -84
- package/src/observability.ts +7 -1
- package/src/routes/api-keys.ts +39 -23
- package/src/routes/billing.ts +180 -65
- package/src/routes/capabilities.ts +17 -8
- package/src/routes/catalog-assets.ts +5 -2
- package/src/routes/codex.ts +244 -63
- package/src/routes/connections.ts +72 -34
- package/src/routes/documents.ts +242 -92
- package/src/routes/enrollments.ts +100 -70
- package/src/routes/environments.ts +205 -136
- package/src/routes/files.ts +164 -39
- package/src/routes/github.ts +123 -50
- package/src/routes/install.ts +9 -2
- package/src/routes/machines.ts +9 -8
- package/src/routes/packs.ts +141 -89
- package/src/routes/rigs.ts +189 -0
- package/src/routes/scheduled-tasks.ts +51 -9
- package/src/routes/sessions.ts +839 -329
- package/src/routes/social.ts +50 -38
- package/src/routes/workspace-capture.ts +238 -0
- package/src/routes/workspaces.ts +159 -13
- package/src/sandbox/access.ts +11 -3
- package/src/sandbox/auth-callout.ts +5 -1
- package/src/sandbox/channel-a.ts +104 -27
- package/src/sandbox/enrollment.ts +13 -3
- package/src/sandbox/machines.ts +68 -59
- package/src/sandbox/metrics-ingestion.ts +238 -17
- package/src/sandbox/viewer.ts +172 -46
- package/dist/chunk-YY6OAEL6.js.map +0 -1
|
@@ -7,7 +7,10 @@ import { HTTPException } from "hono/http-exception";
|
|
|
7
7
|
* domain silently breaks the enable-time connectionRef domain match.
|
|
8
8
|
*/
|
|
9
9
|
export function canonicalProviderDomain(value: string): string {
|
|
10
|
-
const canonical = value
|
|
10
|
+
const canonical = value
|
|
11
|
+
.trim()
|
|
12
|
+
.toLowerCase()
|
|
13
|
+
.replace(/^www\./, "");
|
|
11
14
|
if (!canonical) {
|
|
12
15
|
throw new HTTPException(400, { message: "providerDomain must not be empty" });
|
|
13
16
|
}
|
package/src/mcp/documents.ts
CHANGED
|
@@ -4,11 +4,7 @@ import {
|
|
|
4
4
|
searchDocuments,
|
|
5
5
|
type DocumentServices,
|
|
6
6
|
} from "@opengeni/documents";
|
|
7
|
-
import {
|
|
8
|
-
createKnowledgeMemory,
|
|
9
|
-
listKnowledgeMemories,
|
|
10
|
-
type Database,
|
|
11
|
-
} from "@opengeni/db";
|
|
7
|
+
import { createKnowledgeMemory, listKnowledgeMemories, type Database } from "@opengeni/db";
|
|
12
8
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
13
9
|
import * as z from "zod/v4";
|
|
14
10
|
|
|
@@ -17,7 +13,20 @@ const SearchInputSchema = {
|
|
|
17
13
|
baseIds: z.array(z.string().uuid()).optional(),
|
|
18
14
|
limit: z.number().int().positive().max(50).optional(),
|
|
19
15
|
mode: z.enum(["hybrid", "vector", "keyword"]).optional(),
|
|
20
|
-
sourceKinds: z
|
|
16
|
+
sourceKinds: z
|
|
17
|
+
.array(
|
|
18
|
+
z.enum([
|
|
19
|
+
"manual_upload",
|
|
20
|
+
"meeting_transcript",
|
|
21
|
+
"repository",
|
|
22
|
+
"email",
|
|
23
|
+
"chat",
|
|
24
|
+
"document",
|
|
25
|
+
"web",
|
|
26
|
+
"other",
|
|
27
|
+
]),
|
|
28
|
+
)
|
|
29
|
+
.optional(),
|
|
21
30
|
aclTags: z.array(z.string().min(1)).optional(),
|
|
22
31
|
};
|
|
23
32
|
|
|
@@ -42,91 +51,142 @@ export function buildDocumentsMcpServer(
|
|
|
42
51
|
version: "1.0.0",
|
|
43
52
|
});
|
|
44
53
|
|
|
45
|
-
server.registerTool(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
server.registerTool(
|
|
55
|
+
"list_document_bases",
|
|
56
|
+
{
|
|
57
|
+
description: "List document bases available for retrieval.",
|
|
58
|
+
inputSchema: {},
|
|
59
|
+
},
|
|
60
|
+
async () => ({
|
|
61
|
+
content: [{ type: "text", text: JSON.stringify(await listDocumentBases(db, workspaceId)) }],
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
51
64
|
|
|
52
|
-
server.registerTool(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
server.registerTool(
|
|
66
|
+
"search_documents",
|
|
67
|
+
{
|
|
68
|
+
description: "Search indexed documents with hybrid, vector, or keyword retrieval.",
|
|
69
|
+
inputSchema: SearchInputSchema,
|
|
70
|
+
},
|
|
71
|
+
async (input) => searchContent(db, workspaceId, documentServices, input),
|
|
72
|
+
);
|
|
56
73
|
|
|
57
|
-
server.registerTool(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
74
|
+
server.registerTool(
|
|
75
|
+
"knowledge_search",
|
|
76
|
+
{
|
|
77
|
+
description:
|
|
78
|
+
"Search company knowledge sources with optional base, source-kind, ACL, and retrieval-mode filters.",
|
|
79
|
+
inputSchema: SearchInputSchema,
|
|
80
|
+
},
|
|
81
|
+
async (input) => searchContent(db, workspaceId, documentServices, input),
|
|
82
|
+
);
|
|
61
83
|
|
|
62
|
-
server.registerTool(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
84
|
+
server.registerTool(
|
|
85
|
+
"fetch_document_chunk",
|
|
86
|
+
{
|
|
87
|
+
description: "Fetch one indexed document chunk by id.",
|
|
88
|
+
inputSchema: {
|
|
89
|
+
chunkId: z.string().uuid(),
|
|
90
|
+
},
|
|
66
91
|
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
92
|
+
async ({ chunkId }) => {
|
|
93
|
+
const found = await getDocumentChunk(db, workspaceId, chunkId);
|
|
94
|
+
return {
|
|
95
|
+
content: [
|
|
96
|
+
{ type: "text", text: found ? JSON.stringify(found) : `chunk not found: ${chunkId}` },
|
|
97
|
+
],
|
|
98
|
+
isError: !found,
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
);
|
|
74
102
|
|
|
75
|
-
server.registerTool(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
103
|
+
server.registerTool(
|
|
104
|
+
"knowledge_fetch",
|
|
105
|
+
{
|
|
106
|
+
description: "Fetch one knowledge source chunk by id.",
|
|
107
|
+
inputSchema: {
|
|
108
|
+
chunkId: z.string().uuid(),
|
|
109
|
+
},
|
|
79
110
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
111
|
+
async ({ chunkId }) => {
|
|
112
|
+
const found = await getDocumentChunk(db, workspaceId, chunkId);
|
|
113
|
+
return {
|
|
114
|
+
content: [
|
|
115
|
+
{ type: "text", text: found ? JSON.stringify(found) : `chunk not found: ${chunkId}` },
|
|
116
|
+
],
|
|
117
|
+
isError: !found,
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
);
|
|
87
121
|
|
|
88
|
-
server.registerTool(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
122
|
+
server.registerTool(
|
|
123
|
+
"memory_search",
|
|
124
|
+
{
|
|
125
|
+
description: "Search approved company memory records.",
|
|
126
|
+
inputSchema: {
|
|
127
|
+
query: z.string().min(1).optional(),
|
|
128
|
+
kind: MemoryKindSchema.optional(),
|
|
129
|
+
scope: z.string().min(1).optional(),
|
|
130
|
+
limit: z.number().int().positive().max(100).optional(),
|
|
131
|
+
},
|
|
95
132
|
},
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
133
|
+
async ({ query, kind, scope, limit }) => ({
|
|
134
|
+
content: [
|
|
135
|
+
{
|
|
136
|
+
type: "text",
|
|
137
|
+
text: JSON.stringify(
|
|
138
|
+
await listKnowledgeMemories(db, workspaceId, {
|
|
139
|
+
...(query ? { query } : {}),
|
|
140
|
+
status: ["active", "approved"],
|
|
141
|
+
...(kind ? { kind } : {}),
|
|
142
|
+
...(scope ? { scope } : {}),
|
|
143
|
+
...(limit ? { limit } : {}),
|
|
144
|
+
}),
|
|
145
|
+
),
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
105
150
|
|
|
106
|
-
server.registerTool(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
151
|
+
server.registerTool(
|
|
152
|
+
"memory_propose",
|
|
153
|
+
{
|
|
154
|
+
description: "Propose a company memory record for human review.",
|
|
155
|
+
inputSchema: {
|
|
156
|
+
text: z.string().min(1),
|
|
157
|
+
kind: MemoryKindSchema.optional(),
|
|
158
|
+
scope: z.string().min(1).optional(),
|
|
159
|
+
sourceRefs: z.array(SourceRefSchema).optional(),
|
|
160
|
+
confidence: z.number().min(0).max(1).optional(),
|
|
161
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
162
|
+
},
|
|
115
163
|
},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
164
|
+
async ({ text, kind, scope, sourceRefs, confidence, metadata }) => ({
|
|
165
|
+
content: [
|
|
166
|
+
{
|
|
167
|
+
type: "text",
|
|
168
|
+
text: JSON.stringify(
|
|
169
|
+
await createKnowledgeMemory(db, {
|
|
170
|
+
accountId,
|
|
171
|
+
workspaceId,
|
|
172
|
+
status: "proposed",
|
|
173
|
+
kind: kind ?? "semantic",
|
|
174
|
+
scope: scope ?? "workspace",
|
|
175
|
+
text,
|
|
176
|
+
sourceRefs:
|
|
177
|
+
sourceRefs?.map((sourceRef) => ({
|
|
178
|
+
...sourceRef,
|
|
179
|
+
metadata: sourceRef.metadata ?? {},
|
|
180
|
+
})) ?? [],
|
|
181
|
+
confidence: confidence ?? 0.5,
|
|
182
|
+
metadata: metadata ?? {},
|
|
183
|
+
createdBySessionId: options.createdBySessionId,
|
|
184
|
+
}),
|
|
185
|
+
),
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
}),
|
|
189
|
+
);
|
|
130
190
|
|
|
131
191
|
return server;
|
|
132
192
|
}
|
|
@@ -140,22 +200,41 @@ async function searchContent(
|
|
|
140
200
|
baseIds?: string[] | undefined;
|
|
141
201
|
limit?: number | undefined;
|
|
142
202
|
mode?: "hybrid" | "vector" | "keyword" | undefined;
|
|
143
|
-
sourceKinds?:
|
|
203
|
+
sourceKinds?:
|
|
204
|
+
| Array<
|
|
205
|
+
| "manual_upload"
|
|
206
|
+
| "meeting_transcript"
|
|
207
|
+
| "repository"
|
|
208
|
+
| "email"
|
|
209
|
+
| "chat"
|
|
210
|
+
| "document"
|
|
211
|
+
| "web"
|
|
212
|
+
| "other"
|
|
213
|
+
>
|
|
214
|
+
| undefined;
|
|
144
215
|
aclTags?: string[] | undefined;
|
|
145
216
|
},
|
|
146
217
|
) {
|
|
147
218
|
return {
|
|
148
|
-
content: [
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
219
|
+
content: [
|
|
220
|
+
{
|
|
221
|
+
type: "text" as const,
|
|
222
|
+
text: JSON.stringify(
|
|
223
|
+
await searchDocuments(
|
|
224
|
+
db,
|
|
225
|
+
{
|
|
226
|
+
workspaceId,
|
|
227
|
+
query: input.query,
|
|
228
|
+
...(input.baseIds ? { baseIds: input.baseIds } : {}),
|
|
229
|
+
...(input.limit ? { limit: input.limit } : {}),
|
|
230
|
+
...(input.mode ? { mode: input.mode } : {}),
|
|
231
|
+
...(input.sourceKinds ? { sourceKinds: input.sourceKinds } : {}),
|
|
232
|
+
...(input.aclTags ? { aclTags: input.aclTags } : {}),
|
|
233
|
+
},
|
|
234
|
+
documentServices,
|
|
235
|
+
),
|
|
236
|
+
),
|
|
237
|
+
},
|
|
238
|
+
],
|
|
160
239
|
};
|
|
161
240
|
}
|