@opengeni/api-router 0.23.1 → 0.26.1

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 (107) hide show
  1. package/dist/app.d.ts +2 -2
  2. package/dist/app.js +1 -1
  3. package/dist/browser-controller-authority.d.ts +43 -0
  4. package/dist/browser-state-authority.d.ts +27 -0
  5. package/dist/{chunk-T4T2PGU4.js → chunk-JIKNR5YL.js} +26181 -14408
  6. package/dist/chunk-JIKNR5YL.js.map +1 -0
  7. package/dist/codemode.d.ts +23 -0
  8. package/dist/editable-artifact-live-hints.d.ts +11 -0
  9. package/dist/editable-artifact-native-kernel.d.ts +37 -0
  10. package/dist/editable-artifact-office-import.d.ts +22 -0
  11. package/dist/editable-artifact-production.d.ts +29 -0
  12. package/dist/editable-artifact-websocket.d.ts +49 -0
  13. package/dist/editable-artifact-workspace-files.d.ts +23 -0
  14. package/dist/github-browser-flow.d.ts +6 -0
  15. package/dist/http/cors.d.ts +1 -0
  16. package/dist/index.d.ts +3 -2
  17. package/dist/index.js +1796 -22
  18. package/dist/index.js.map +1 -1
  19. package/dist/integrations/api-integrations.d.ts +24 -0
  20. package/dist/integrations/atlassian.d.ts +176 -0
  21. package/dist/integrations/github-skill-source.d.ts +5 -0
  22. package/dist/integrations/google-drive.d.ts +85 -0
  23. package/dist/integrations/oauth-client.d.ts +22 -1
  24. package/dist/integrations/provider-oauth.d.ts +19 -0
  25. package/dist/integrations/slack-bot.d.ts +4 -0
  26. package/dist/integrations/slack-interactions.d.ts +8 -2
  27. package/dist/integrations/social-api.d.ts +2 -1
  28. package/dist/mcp/editable-artifact-query-schema.d.ts +4 -0
  29. package/dist/mcp/editable-artifacts.d.ts +13 -0
  30. package/dist/mcp/scheduled-task-view.d.ts +168 -0
  31. package/dist/mcp/server.d.ts +14 -3
  32. package/dist/memory-slack-delivery.d.ts +9 -0
  33. package/dist/routes/api-integrations.d.ts +8 -0
  34. package/dist/routes/browser-identities.d.ts +5 -0
  35. package/dist/routes/browser-sessions.d.ts +6 -0
  36. package/dist/routes/company-profile.d.ts +3 -0
  37. package/dist/routes/computer-sessions.d.ts +6 -0
  38. package/dist/routes/editable-artifacts.d.ts +44 -0
  39. package/dist/routes/integration-features.d.ts +3 -0
  40. package/dist/routes/memory-slack-publications.d.ts +6 -0
  41. package/dist/routes/plugins.d.ts +8 -0
  42. package/dist/routes/sessions.d.ts +17 -2
  43. package/dist/routes/skills.d.ts +6 -0
  44. package/dist/routes/video-generation.d.ts +3 -0
  45. package/dist/sandbox/channel-a.d.ts +55 -2
  46. package/dist/sandbox/metrics-ingestion.d.ts +6 -1
  47. package/dist/sandbox/viewer.d.ts +4 -2
  48. package/dist/temporal-schedule-cleanup.d.ts +26 -0
  49. package/package.json +19 -14
  50. package/src/app.ts +274 -37
  51. package/src/browser-controller-authority.ts +137 -0
  52. package/src/browser-state-authority.ts +236 -0
  53. package/src/codemode.ts +186 -0
  54. package/src/editable-artifact-live-hints.ts +64 -0
  55. package/src/editable-artifact-native-kernel.ts +659 -0
  56. package/src/editable-artifact-office-import.ts +230 -0
  57. package/src/editable-artifact-production.ts +419 -0
  58. package/src/editable-artifact-websocket.ts +311 -0
  59. package/src/editable-artifact-workspace-files.ts +186 -0
  60. package/src/github-browser-flow.ts +35 -6
  61. package/src/http/auth.ts +2 -0
  62. package/src/http/cors.ts +3 -0
  63. package/src/index.ts +119 -20
  64. package/src/integrations/api-integrations.ts +350 -0
  65. package/src/integrations/atlassian.ts +1621 -0
  66. package/src/integrations/github-skill-source.ts +142 -0
  67. package/src/integrations/google-drive.ts +1000 -64
  68. package/src/integrations/oauth-client.ts +123 -33
  69. package/src/integrations/provider-oauth.ts +777 -0
  70. package/src/integrations/slack-bot.ts +31 -2
  71. package/src/integrations/slack-interactions.ts +487 -27
  72. package/src/integrations/social-api.ts +11 -0
  73. package/src/mcp/documents.ts +32 -1
  74. package/src/mcp/editable-artifact-query-schema.ts +236 -0
  75. package/src/mcp/editable-artifacts.ts +448 -0
  76. package/src/mcp/scheduled-task-view.ts +34 -0
  77. package/src/mcp/server.ts +923 -145
  78. package/src/memory-slack-delivery.ts +209 -0
  79. package/src/routes/api-integrations.ts +407 -0
  80. package/src/routes/browser-identities.ts +136 -0
  81. package/src/routes/browser-sessions.ts +2543 -0
  82. package/src/routes/company-profile.ts +255 -0
  83. package/src/routes/computer-sessions.ts +1247 -0
  84. package/src/routes/connections.ts +284 -99
  85. package/src/routes/documents.ts +22 -3
  86. package/src/routes/editable-artifacts.ts +1159 -0
  87. package/src/routes/files.ts +106 -4
  88. package/src/routes/github.ts +18 -2
  89. package/src/routes/install.ts +7 -1
  90. package/src/routes/integration-features.ts +258 -0
  91. package/src/routes/memory-slack-publications.ts +216 -0
  92. package/src/routes/packs.ts +437 -7
  93. package/src/routes/plugins.ts +751 -0
  94. package/src/routes/rigs.ts +77 -20
  95. package/src/routes/scheduled-tasks.ts +67 -40
  96. package/src/routes/sessions.ts +421 -245
  97. package/src/routes/skills.ts +174 -0
  98. package/src/routes/video-generation.ts +132 -0
  99. package/src/routes/workspaces.ts +46 -24
  100. package/src/sandbox/channel-a.ts +723 -116
  101. package/src/sandbox/metrics-ingestion.ts +121 -3
  102. package/src/sandbox/rematerialize.ts +35 -47
  103. package/src/sandbox/viewer.ts +29 -9
  104. package/src/temporal-schedule-cleanup.ts +135 -0
  105. package/dist/chunk-T4T2PGU4.js.map +0 -1
  106. package/dist/mcp/toolspace.d.ts +0 -71
  107. package/src/mcp/toolspace.ts +0 -1190
@@ -0,0 +1,136 @@
1
+ import {
2
+ BrowserIdentity,
3
+ BrowserIdentityListResponse,
4
+ BrowserIdentityMutationResponse,
5
+ BrowserRevisionListResponse,
6
+ CreateBrowserIdentityRequest,
7
+ } from "@opengeni/contracts";
8
+ import {
9
+ BrowserIdentityConflictError,
10
+ BrowserIdentityNotFoundError,
11
+ BrowserIdentityStateError,
12
+ createBrowserIdentity,
13
+ getBrowserIdentity,
14
+ listBrowserIdentities,
15
+ listBrowserRevisions,
16
+ } from "@opengeni/db";
17
+ import { requireAccessGrant, type ApiRouteDeps } from "@opengeni/core";
18
+ import type { Context, Hono } from "hono";
19
+ import { HTTPException } from "hono/http-exception";
20
+
21
+ export function registerBrowserIdentityRoutes(app: Hono, deps: ApiRouteDeps): void {
22
+ app.get("/v1/workspaces/:workspaceId/browser-identities", async (context) => {
23
+ const workspaceId = context.req.param("workspaceId") ?? "";
24
+ const grant = await requireAccessGrant(context, deps, workspaceId, "sessions:read");
25
+ try {
26
+ return context.json(
27
+ BrowserIdentityListResponse.parse(
28
+ await listBrowserIdentities(deps.db, {
29
+ accountId: grant.accountId,
30
+ workspaceId,
31
+ includeArchived: context.req.query("includeArchived") === "true",
32
+ }),
33
+ ),
34
+ );
35
+ } catch (error) {
36
+ throw browserIdentityRouteError(error);
37
+ }
38
+ });
39
+
40
+ app.post("/v1/workspaces/:workspaceId/browser-identities", async (context) => {
41
+ const workspaceId = context.req.param("workspaceId") ?? "";
42
+ const grant = await requireAccessGrant(context, deps, workspaceId, "sessions:control");
43
+ const request = await parseJsonBody(context, CreateBrowserIdentityRequest);
44
+ try {
45
+ const response = await createBrowserIdentity(deps.db, {
46
+ accountId: grant.accountId,
47
+ workspaceId,
48
+ operationId: request.operationId,
49
+ name: request.name,
50
+ actorSubjectId: grant.subjectId,
51
+ });
52
+ return context.json(
53
+ BrowserIdentityMutationResponse.parse(response),
54
+ response.replayed ? 200 : 201,
55
+ );
56
+ } catch (error) {
57
+ throw browserIdentityRouteError(error);
58
+ }
59
+ });
60
+
61
+ app.get("/v1/workspaces/:workspaceId/browser-identities/:identityId", async (context) => {
62
+ const workspaceId = context.req.param("workspaceId") ?? "";
63
+ const grant = await requireAccessGrant(context, deps, workspaceId, "sessions:read");
64
+ try {
65
+ return context.json(
66
+ BrowserIdentity.parse(
67
+ await getBrowserIdentity(deps.db, {
68
+ accountId: grant.accountId,
69
+ workspaceId,
70
+ identityId: uuidParam(context, "identityId"),
71
+ }),
72
+ ),
73
+ );
74
+ } catch (error) {
75
+ throw browserIdentityRouteError(error);
76
+ }
77
+ });
78
+
79
+ app.get(
80
+ "/v1/workspaces/:workspaceId/browser-identities/:identityId/revisions",
81
+ async (context) => {
82
+ const workspaceId = context.req.param("workspaceId") ?? "";
83
+ const grant = await requireAccessGrant(context, deps, workspaceId, "sessions:read");
84
+ try {
85
+ return context.json(
86
+ BrowserRevisionListResponse.parse(
87
+ await listBrowserRevisions(deps.db, {
88
+ accountId: grant.accountId,
89
+ workspaceId,
90
+ identityId: uuidParam(context, "identityId"),
91
+ }),
92
+ ),
93
+ );
94
+ } catch (error) {
95
+ throw browserIdentityRouteError(error);
96
+ }
97
+ },
98
+ );
99
+ }
100
+
101
+ async function parseJsonBody<T>(
102
+ context: Context,
103
+ schema: {
104
+ safeParse(value: unknown): { success: true; data: T } | { success: false };
105
+ },
106
+ ): Promise<T> {
107
+ const value = await context.req.json().catch(() => undefined);
108
+ const parsed = schema.safeParse(value);
109
+ if (!parsed.success) throw new HTTPException(400, { message: "invalid request body" });
110
+ return parsed.data;
111
+ }
112
+
113
+ function uuidParam(context: Context, name: string): string {
114
+ const value = context.req.param(name);
115
+ if (
116
+ typeof value !== "string" ||
117
+ !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(value)
118
+ ) {
119
+ throw new HTTPException(400, { message: `${name} must be a UUID` });
120
+ }
121
+ return value;
122
+ }
123
+
124
+ export function browserIdentityRouteError(error: unknown): HTTPException {
125
+ if (error instanceof HTTPException) return error;
126
+ if (error instanceof BrowserIdentityNotFoundError) {
127
+ return new HTTPException(404, { message: error.message, cause: error });
128
+ }
129
+ if (error instanceof BrowserIdentityConflictError || error instanceof BrowserIdentityStateError) {
130
+ return new HTTPException(409, { message: error.message, cause: error });
131
+ }
132
+ return new HTTPException(500, {
133
+ message: "BrowserIdentity request failed",
134
+ cause: error,
135
+ });
136
+ }