@qontinui/ui-bridge 0.2.0 → 0.3.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.
- package/dist/ai/index.d.mts +312 -155
- package/dist/ai/index.d.ts +312 -155
- package/dist/ai/index.js +2363 -67
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/index.mjs +2328 -68
- package/dist/ai/index.mjs.map +1 -1
- package/dist/annotations/index.d.mts +218 -0
- package/dist/annotations/index.d.ts +218 -0
- package/dist/annotations/index.js +246 -0
- package/dist/annotations/index.js.map +1 -0
- package/dist/annotations/index.mjs +241 -0
- package/dist/annotations/index.mjs.map +1 -0
- package/dist/assertions-BSR3afVr.d.ts +161 -0
- package/dist/assertions-CTw1hfOx.d.mts +161 -0
- package/dist/babel-plugin/index.js +504 -0
- package/dist/babel-plugin/index.js.map +1 -0
- package/dist/babel-plugin/index.mjs +488 -0
- package/dist/babel-plugin/index.mjs.map +1 -0
- package/dist/browser-capture-Bms60T6f.d.mts +47 -0
- package/dist/browser-capture-CsTU29mb.d.ts +47 -0
- package/dist/control/index.d.mts +26 -7
- package/dist/control/index.d.ts +26 -7
- package/dist/control/index.js +276 -48
- package/dist/control/index.js.map +1 -1
- package/dist/control/index.mjs +276 -48
- package/dist/control/index.mjs.map +1 -1
- package/dist/core/index.d.mts +115 -44
- package/dist/core/index.d.ts +115 -44
- package/dist/core/index.js +0 -1560
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +1 -1549
- package/dist/core/index.mjs.map +1 -1
- package/dist/debug/index.d.mts +5 -3
- package/dist/debug/index.d.ts +5 -3
- package/dist/debug/index.js +925 -1
- package/dist/debug/index.js.map +1 -1
- package/dist/debug/index.mjs +924 -2
- package/dist/debug/index.mjs.map +1 -1
- package/dist/index.d.mts +13 -9
- package/dist/index.d.ts +13 -9
- package/dist/index.js +8310 -3777
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8246 -3766
- package/dist/index.mjs.map +1 -1
- package/dist/{metrics-NC3csD0R.d.mts → metrics-DuA2qIIz.d.mts} +2 -2
- package/dist/{metrics-C9XRi_mL.d.ts → metrics-KFAAKNEB.d.ts} +2 -2
- package/dist/native/control/index.js +448 -0
- package/dist/native/control/index.js.map +1 -0
- package/dist/native/control/index.mjs +445 -0
- package/dist/native/control/index.mjs.map +1 -0
- package/dist/native/core/index.js +486 -0
- package/dist/native/core/index.js.map +1 -0
- package/dist/native/core/index.mjs +475 -0
- package/dist/native/core/index.mjs.map +1 -0
- package/dist/native/debug/index.js +408 -0
- package/dist/native/debug/index.js.map +1 -0
- package/dist/native/debug/index.mjs +406 -0
- package/dist/native/debug/index.mjs.map +1 -0
- package/dist/native/index.js +2232 -0
- package/dist/native/index.js.map +1 -0
- package/dist/native/index.mjs +2204 -0
- package/dist/native/index.mjs.map +1 -0
- package/dist/native/react/index.js +1377 -0
- package/dist/native/react/index.js.map +1 -0
- package/dist/native/react/index.mjs +1365 -0
- package/dist/native/react/index.mjs.map +1 -0
- package/dist/native/server/index.js +440 -0
- package/dist/native/server/index.js.map +1 -0
- package/dist/native/server/index.mjs +435 -0
- package/dist/native/server/index.mjs.map +1 -0
- package/dist/react/index.d.mts +121 -9
- package/dist/react/index.d.ts +121 -9
- package/dist/react/index.js +2239 -91
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +2239 -92
- package/dist/react/index.mjs.map +1 -1
- package/dist/{registry-CIEDjbQ9.d.ts → registry-C6dDtn1v.d.ts} +34 -15
- package/dist/{registry-SsSDq46X.d.mts → registry-POtcxnal.d.mts} +34 -15
- package/dist/render-log/index.d.mts +1 -1
- package/dist/render-log/index.d.ts +1 -1
- package/dist/server/express.d.mts +37 -0
- package/dist/server/express.d.ts +37 -0
- package/dist/server/express.js +298 -0
- package/dist/server/express.js.map +1 -0
- package/dist/server/express.mjs +294 -0
- package/dist/server/express.mjs.map +1 -0
- package/dist/server/handlers.d.mts +124 -0
- package/dist/server/handlers.d.ts +124 -0
- package/dist/server/handlers.js +7183 -0
- package/dist/server/handlers.js.map +1 -0
- package/dist/server/handlers.mjs +7180 -0
- package/dist/server/handlers.mjs.map +1 -0
- package/dist/server/index.d.mts +12 -0
- package/dist/server/index.d.ts +12 -0
- package/dist/server/index.js +8384 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +8369 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/server/nextjs.d.mts +128 -0
- package/dist/server/nextjs.d.ts +128 -0
- package/dist/server/nextjs.js +390 -0
- package/dist/server/nextjs.js.map +1 -0
- package/dist/server/nextjs.mjs +385 -0
- package/dist/server/nextjs.mjs.map +1 -0
- package/dist/server/standalone.d.mts +7 -0
- package/dist/server/standalone.d.ts +7 -0
- package/dist/server/standalone.js +845 -0
- package/dist/server/standalone.js.map +1 -0
- package/dist/server/standalone.mjs +841 -0
- package/dist/server/standalone.mjs.map +1 -0
- package/dist/specs/index.d.mts +365 -0
- package/dist/specs/index.d.ts +365 -0
- package/dist/specs/index.js +2809 -0
- package/dist/specs/index.js.map +1 -0
- package/dist/specs/index.mjs +2786 -0
- package/dist/specs/index.mjs.map +1 -0
- package/dist/standalone-B6GLIEmR.d.ts +216 -0
- package/dist/standalone-CjdYqj3P.d.mts +216 -0
- package/dist/swc-plugin/index.d.mts +79 -0
- package/dist/swc-plugin/index.d.ts +79 -0
- package/dist/swc-plugin/index.js +15 -0
- package/dist/swc-plugin/index.js.map +1 -0
- package/dist/swc-plugin/index.mjs +9 -0
- package/dist/swc-plugin/index.mjs.map +1 -0
- package/dist/types-B2EfvEaq.d.ts +236 -0
- package/dist/{types-Dr6tH-bm.d.mts → types-C7gVYRnF.d.ts} +72 -2
- package/dist/{types-oCTrRxSw.d.ts → types-CJGrBEhC.d.mts} +72 -2
- package/dist/types-CebMQj76.d.ts +1275 -0
- package/dist/types-D_ypYl3T.d.mts +1275 -0
- package/dist/types-UBtp7R0u.d.mts +132 -0
- package/dist/types-UBtp7R0u.d.ts +132 -0
- package/dist/types-gO696T_t.d.mts +236 -0
- package/dist/{types-CPMbN_Iw.d.mts → types-suaYwWWg.d.mts} +519 -152
- package/dist/{types-CPMbN_Iw.d.ts → types-suaYwWWg.d.ts} +519 -152
- package/package.json +123 -4
- package/swc-plugin-wasm/ui_bridge_swc_plugin.wasm +0 -0
- package/dist/types-BvCfFuEV.d.ts +0 -534
- package/dist/types-CFT3Dnx4.d.mts +0 -534
- package/dist/websocket-client-CX4QJesI.d.ts +0 -124
- package/dist/websocket-client-C_Na0OSp.d.mts +0 -124
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { U as UIBridgeServerConfig, c as UIBridgeServerHandlers } from '../types-gO696T_t.mjs';
|
|
2
|
+
import '../types-suaYwWWg.mjs';
|
|
3
|
+
import '../types-CJGrBEhC.mjs';
|
|
4
|
+
import '../types-D_ypYl3T.mjs';
|
|
5
|
+
import '../render-log/index.mjs';
|
|
6
|
+
import '../types-UBtp7R0u.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Next.js Adapter
|
|
10
|
+
*
|
|
11
|
+
* Next.js API route handlers for UI Bridge server.
|
|
12
|
+
*/
|
|
13
|
+
interface NextRequest extends Request {
|
|
14
|
+
nextUrl: URL;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Next.js specific configuration
|
|
19
|
+
*/
|
|
20
|
+
interface NextJSAdapterConfig extends UIBridgeServerConfig {
|
|
21
|
+
/** Runtime for edge/serverless */
|
|
22
|
+
runtime?: 'edge' | 'nodejs';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Route handler factory for Next.js App Router
|
|
26
|
+
*/
|
|
27
|
+
type NextRouteHandler = (request: NextRequest, context: {
|
|
28
|
+
params: Record<string, string>;
|
|
29
|
+
}) => Promise<Response>;
|
|
30
|
+
/**
|
|
31
|
+
* Create Next.js route handlers for UI Bridge
|
|
32
|
+
*
|
|
33
|
+
* Use this to create route handlers for the App Router.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* // app/api/ui-bridge/[...path]/route.ts
|
|
38
|
+
* import { createNextRouteHandlers } from 'ui-bridge-server/nextjs';
|
|
39
|
+
* import { handlers } from '@/lib/ui-bridge';
|
|
40
|
+
*
|
|
41
|
+
* export const { GET, POST, DELETE } = createNextRouteHandlers(handlers);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare function createNextRouteHandlers(handlers: UIBridgeServerHandlers, config?: NextJSAdapterConfig): {
|
|
45
|
+
GET: NextRouteHandler;
|
|
46
|
+
POST: NextRouteHandler;
|
|
47
|
+
PUT: NextRouteHandler;
|
|
48
|
+
DELETE: NextRouteHandler;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Individual route handler creators for more granular control
|
|
52
|
+
*/
|
|
53
|
+
declare function createRenderLogHandlers(handlers: UIBridgeServerHandlers): {
|
|
54
|
+
GET(request: NextRequest): Promise<Response>;
|
|
55
|
+
DELETE(): Promise<Response>;
|
|
56
|
+
};
|
|
57
|
+
declare function createControlHandlers(handlers: UIBridgeServerHandlers): {
|
|
58
|
+
elements: {
|
|
59
|
+
GET(): Promise<Response>;
|
|
60
|
+
};
|
|
61
|
+
element: {
|
|
62
|
+
GET(_request: NextRequest, context: {
|
|
63
|
+
params: {
|
|
64
|
+
id: string;
|
|
65
|
+
};
|
|
66
|
+
}): Promise<Response>;
|
|
67
|
+
POST(request: NextRequest, context: {
|
|
68
|
+
params: {
|
|
69
|
+
id: string;
|
|
70
|
+
};
|
|
71
|
+
}): Promise<Response>;
|
|
72
|
+
};
|
|
73
|
+
components: {
|
|
74
|
+
GET(): Promise<Response>;
|
|
75
|
+
};
|
|
76
|
+
component: {
|
|
77
|
+
GET(_request: NextRequest, context: {
|
|
78
|
+
params: {
|
|
79
|
+
id: string;
|
|
80
|
+
};
|
|
81
|
+
}): Promise<Response>;
|
|
82
|
+
POST(request: NextRequest, context: {
|
|
83
|
+
params: {
|
|
84
|
+
id: string;
|
|
85
|
+
actionId: string;
|
|
86
|
+
};
|
|
87
|
+
}): Promise<Response>;
|
|
88
|
+
};
|
|
89
|
+
find: {
|
|
90
|
+
POST(request: NextRequest): Promise<Response>;
|
|
91
|
+
};
|
|
92
|
+
discover: {
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated Use /control/find instead
|
|
95
|
+
*/
|
|
96
|
+
POST(request: NextRequest): Promise<Response>;
|
|
97
|
+
};
|
|
98
|
+
snapshot: {
|
|
99
|
+
GET(): Promise<Response>;
|
|
100
|
+
};
|
|
101
|
+
workflows: {
|
|
102
|
+
GET(): Promise<Response>;
|
|
103
|
+
};
|
|
104
|
+
workflow: {
|
|
105
|
+
POST(request: NextRequest, context: {
|
|
106
|
+
params: {
|
|
107
|
+
id: string;
|
|
108
|
+
};
|
|
109
|
+
}): Promise<Response>;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
declare function createDebugHandlers(handlers: UIBridgeServerHandlers): {
|
|
113
|
+
actionHistory: {
|
|
114
|
+
GET(request: NextRequest): Promise<Response>;
|
|
115
|
+
};
|
|
116
|
+
metrics: {
|
|
117
|
+
GET(): Promise<Response>;
|
|
118
|
+
};
|
|
119
|
+
highlight: {
|
|
120
|
+
POST(_request: NextRequest, context: {
|
|
121
|
+
params: {
|
|
122
|
+
id: string;
|
|
123
|
+
};
|
|
124
|
+
}): Promise<Response>;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export { type NextJSAdapterConfig, type NextRouteHandler, createControlHandlers, createDebugHandlers, createNextRouteHandlers, createRenderLogHandlers };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { U as UIBridgeServerConfig, c as UIBridgeServerHandlers } from '../types-B2EfvEaq.js';
|
|
2
|
+
import '../types-suaYwWWg.js';
|
|
3
|
+
import '../types-C7gVYRnF.js';
|
|
4
|
+
import '../types-CebMQj76.js';
|
|
5
|
+
import '../render-log/index.js';
|
|
6
|
+
import '../types-UBtp7R0u.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Next.js Adapter
|
|
10
|
+
*
|
|
11
|
+
* Next.js API route handlers for UI Bridge server.
|
|
12
|
+
*/
|
|
13
|
+
interface NextRequest extends Request {
|
|
14
|
+
nextUrl: URL;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Next.js specific configuration
|
|
19
|
+
*/
|
|
20
|
+
interface NextJSAdapterConfig extends UIBridgeServerConfig {
|
|
21
|
+
/** Runtime for edge/serverless */
|
|
22
|
+
runtime?: 'edge' | 'nodejs';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Route handler factory for Next.js App Router
|
|
26
|
+
*/
|
|
27
|
+
type NextRouteHandler = (request: NextRequest, context: {
|
|
28
|
+
params: Record<string, string>;
|
|
29
|
+
}) => Promise<Response>;
|
|
30
|
+
/**
|
|
31
|
+
* Create Next.js route handlers for UI Bridge
|
|
32
|
+
*
|
|
33
|
+
* Use this to create route handlers for the App Router.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* // app/api/ui-bridge/[...path]/route.ts
|
|
38
|
+
* import { createNextRouteHandlers } from 'ui-bridge-server/nextjs';
|
|
39
|
+
* import { handlers } from '@/lib/ui-bridge';
|
|
40
|
+
*
|
|
41
|
+
* export const { GET, POST, DELETE } = createNextRouteHandlers(handlers);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare function createNextRouteHandlers(handlers: UIBridgeServerHandlers, config?: NextJSAdapterConfig): {
|
|
45
|
+
GET: NextRouteHandler;
|
|
46
|
+
POST: NextRouteHandler;
|
|
47
|
+
PUT: NextRouteHandler;
|
|
48
|
+
DELETE: NextRouteHandler;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Individual route handler creators for more granular control
|
|
52
|
+
*/
|
|
53
|
+
declare function createRenderLogHandlers(handlers: UIBridgeServerHandlers): {
|
|
54
|
+
GET(request: NextRequest): Promise<Response>;
|
|
55
|
+
DELETE(): Promise<Response>;
|
|
56
|
+
};
|
|
57
|
+
declare function createControlHandlers(handlers: UIBridgeServerHandlers): {
|
|
58
|
+
elements: {
|
|
59
|
+
GET(): Promise<Response>;
|
|
60
|
+
};
|
|
61
|
+
element: {
|
|
62
|
+
GET(_request: NextRequest, context: {
|
|
63
|
+
params: {
|
|
64
|
+
id: string;
|
|
65
|
+
};
|
|
66
|
+
}): Promise<Response>;
|
|
67
|
+
POST(request: NextRequest, context: {
|
|
68
|
+
params: {
|
|
69
|
+
id: string;
|
|
70
|
+
};
|
|
71
|
+
}): Promise<Response>;
|
|
72
|
+
};
|
|
73
|
+
components: {
|
|
74
|
+
GET(): Promise<Response>;
|
|
75
|
+
};
|
|
76
|
+
component: {
|
|
77
|
+
GET(_request: NextRequest, context: {
|
|
78
|
+
params: {
|
|
79
|
+
id: string;
|
|
80
|
+
};
|
|
81
|
+
}): Promise<Response>;
|
|
82
|
+
POST(request: NextRequest, context: {
|
|
83
|
+
params: {
|
|
84
|
+
id: string;
|
|
85
|
+
actionId: string;
|
|
86
|
+
};
|
|
87
|
+
}): Promise<Response>;
|
|
88
|
+
};
|
|
89
|
+
find: {
|
|
90
|
+
POST(request: NextRequest): Promise<Response>;
|
|
91
|
+
};
|
|
92
|
+
discover: {
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated Use /control/find instead
|
|
95
|
+
*/
|
|
96
|
+
POST(request: NextRequest): Promise<Response>;
|
|
97
|
+
};
|
|
98
|
+
snapshot: {
|
|
99
|
+
GET(): Promise<Response>;
|
|
100
|
+
};
|
|
101
|
+
workflows: {
|
|
102
|
+
GET(): Promise<Response>;
|
|
103
|
+
};
|
|
104
|
+
workflow: {
|
|
105
|
+
POST(request: NextRequest, context: {
|
|
106
|
+
params: {
|
|
107
|
+
id: string;
|
|
108
|
+
};
|
|
109
|
+
}): Promise<Response>;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
declare function createDebugHandlers(handlers: UIBridgeServerHandlers): {
|
|
113
|
+
actionHistory: {
|
|
114
|
+
GET(request: NextRequest): Promise<Response>;
|
|
115
|
+
};
|
|
116
|
+
metrics: {
|
|
117
|
+
GET(): Promise<Response>;
|
|
118
|
+
};
|
|
119
|
+
highlight: {
|
|
120
|
+
POST(_request: NextRequest, context: {
|
|
121
|
+
params: {
|
|
122
|
+
id: string;
|
|
123
|
+
};
|
|
124
|
+
}): Promise<Response>;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export { type NextJSAdapterConfig, type NextRouteHandler, createControlHandlers, createDebugHandlers, createNextRouteHandlers, createRenderLogHandlers };
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/server/types.ts
|
|
4
|
+
var UI_BRIDGE_ROUTES = [
|
|
5
|
+
// Render log
|
|
6
|
+
{ method: "GET", path: "/render-log", handler: "getRenderLog" },
|
|
7
|
+
{ method: "DELETE", path: "/render-log", handler: "clearRenderLog" },
|
|
8
|
+
{ method: "POST", path: "/render-log/snapshot", handler: "captureSnapshot" },
|
|
9
|
+
{ method: "GET", path: "/render-log/path", handler: "getRenderLogPath" },
|
|
10
|
+
// Control - Elements
|
|
11
|
+
{ method: "GET", path: "/control/elements", handler: "getElements" },
|
|
12
|
+
{ method: "GET", path: "/control/element/:id", handler: "getElement", params: ["id"] },
|
|
13
|
+
{ method: "GET", path: "/control/element/:id/state", handler: "getElementState", params: ["id"] },
|
|
14
|
+
{
|
|
15
|
+
method: "POST",
|
|
16
|
+
path: "/control/element/:id/action",
|
|
17
|
+
handler: "executeElementAction",
|
|
18
|
+
params: ["id"],
|
|
19
|
+
bodyRequired: true
|
|
20
|
+
},
|
|
21
|
+
// Control - Components
|
|
22
|
+
{ method: "GET", path: "/control/components", handler: "getComponents" },
|
|
23
|
+
{ method: "GET", path: "/control/component/:id", handler: "getComponent", params: ["id"] },
|
|
24
|
+
{
|
|
25
|
+
method: "GET",
|
|
26
|
+
path: "/control/component/:id/state",
|
|
27
|
+
handler: "getComponentState",
|
|
28
|
+
params: ["id"]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
method: "POST",
|
|
32
|
+
path: "/control/component/:id/action/:actionId",
|
|
33
|
+
handler: "executeComponentAction",
|
|
34
|
+
params: ["id", "actionId"],
|
|
35
|
+
bodyRequired: true
|
|
36
|
+
},
|
|
37
|
+
// Find (formerly Discovery)
|
|
38
|
+
{ method: "POST", path: "/control/find", handler: "find" },
|
|
39
|
+
{ method: "POST", path: "/control/discover", handler: "discover" },
|
|
40
|
+
// @deprecated Use /control/find
|
|
41
|
+
{ method: "GET", path: "/control/snapshot", handler: "getControlSnapshot" },
|
|
42
|
+
// Workflows
|
|
43
|
+
{ method: "GET", path: "/control/workflows", handler: "getWorkflows" },
|
|
44
|
+
{ method: "POST", path: "/control/workflow/:id/run", handler: "runWorkflow", params: ["id"] },
|
|
45
|
+
{
|
|
46
|
+
method: "GET",
|
|
47
|
+
path: "/control/workflow/:runId/status",
|
|
48
|
+
handler: "getWorkflowStatus",
|
|
49
|
+
params: ["runId"]
|
|
50
|
+
},
|
|
51
|
+
// Debug
|
|
52
|
+
{ method: "GET", path: "/debug/action-history", handler: "getActionHistory" },
|
|
53
|
+
{ method: "GET", path: "/debug/metrics", handler: "getMetrics" },
|
|
54
|
+
{ method: "POST", path: "/debug/highlight/:id", handler: "highlightElement", params: ["id"] },
|
|
55
|
+
{ method: "GET", path: "/debug/element-tree", handler: "getElementTree" },
|
|
56
|
+
{ method: "GET", path: "/control/console-errors", handler: "getConsoleErrors" },
|
|
57
|
+
{ method: "POST", path: "/control/console-errors/clear", handler: "clearConsoleErrors" },
|
|
58
|
+
// AI-native endpoints
|
|
59
|
+
{ method: "POST", path: "/ai/search", handler: "aiSearch", bodyRequired: true },
|
|
60
|
+
{ method: "POST", path: "/ai/execute", handler: "aiExecute", bodyRequired: true },
|
|
61
|
+
{ method: "POST", path: "/ai/assert", handler: "aiAssert", bodyRequired: true },
|
|
62
|
+
{ method: "POST", path: "/ai/assert/batch", handler: "aiAssertBatch", bodyRequired: true },
|
|
63
|
+
{ method: "GET", path: "/ai/snapshot", handler: "getSemanticSnapshot" },
|
|
64
|
+
{ method: "GET", path: "/ai/diff", handler: "getSemanticDiff" },
|
|
65
|
+
{ method: "GET", path: "/ai/summary", handler: "getPageSummary" },
|
|
66
|
+
{ method: "POST", path: "/ai/semantic-search", handler: "aiSemanticSearch", bodyRequired: true },
|
|
67
|
+
// State management (static routes before parameterized)
|
|
68
|
+
{ method: "GET", path: "/control/states", handler: "getStates" },
|
|
69
|
+
{ method: "GET", path: "/control/states/active", handler: "getActiveStates" },
|
|
70
|
+
{ method: "GET", path: "/control/states/snapshot", handler: "getStateSnapshot" },
|
|
71
|
+
{ method: "POST", path: "/control/states/find-path", handler: "findPath", bodyRequired: true },
|
|
72
|
+
{ method: "POST", path: "/control/states/navigate", handler: "navigateTo", bodyRequired: true },
|
|
73
|
+
{ method: "GET", path: "/control/state/:id", handler: "getState", params: ["id"] },
|
|
74
|
+
{ method: "POST", path: "/control/state/:id/activate", handler: "activateState", params: ["id"] },
|
|
75
|
+
{
|
|
76
|
+
method: "POST",
|
|
77
|
+
path: "/control/state/:id/deactivate",
|
|
78
|
+
handler: "deactivateState",
|
|
79
|
+
params: ["id"]
|
|
80
|
+
},
|
|
81
|
+
{ method: "GET", path: "/control/state-groups", handler: "getStateGroups" },
|
|
82
|
+
{
|
|
83
|
+
method: "POST",
|
|
84
|
+
path: "/control/state-group/:id/activate",
|
|
85
|
+
handler: "activateStateGroup",
|
|
86
|
+
params: ["id"]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
method: "POST",
|
|
90
|
+
path: "/control/state-group/:id/deactivate",
|
|
91
|
+
handler: "deactivateStateGroup",
|
|
92
|
+
params: ["id"]
|
|
93
|
+
},
|
|
94
|
+
{ method: "GET", path: "/control/transitions", handler: "getTransitions" },
|
|
95
|
+
{
|
|
96
|
+
method: "GET",
|
|
97
|
+
path: "/control/transition/:id/can-execute",
|
|
98
|
+
handler: "canExecuteTransition",
|
|
99
|
+
params: ["id"]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
method: "POST",
|
|
103
|
+
path: "/control/transition/:id/execute",
|
|
104
|
+
handler: "executeTransition",
|
|
105
|
+
params: ["id"]
|
|
106
|
+
},
|
|
107
|
+
// Intent endpoints
|
|
108
|
+
{ method: "GET", path: "/ai/intents", handler: "listIntents" },
|
|
109
|
+
{ method: "POST", path: "/ai/intents/execute", handler: "executeIntent", bodyRequired: true },
|
|
110
|
+
{ method: "POST", path: "/ai/intents/find", handler: "findIntent", bodyRequired: true },
|
|
111
|
+
{ method: "POST", path: "/ai/intents/register", handler: "registerIntent", bodyRequired: true },
|
|
112
|
+
{
|
|
113
|
+
method: "POST",
|
|
114
|
+
path: "/ai/intents/execute-from-query",
|
|
115
|
+
handler: "executeIntentFromQuery",
|
|
116
|
+
bodyRequired: true
|
|
117
|
+
},
|
|
118
|
+
// Recovery endpoints
|
|
119
|
+
{
|
|
120
|
+
method: "POST",
|
|
121
|
+
path: "/ai/recovery/attempt",
|
|
122
|
+
handler: "attemptRecovery",
|
|
123
|
+
bodyRequired: true
|
|
124
|
+
},
|
|
125
|
+
// Cross-app analysis endpoints
|
|
126
|
+
{ method: "GET", path: "/ai/analyze/data", handler: "analyzePageData" },
|
|
127
|
+
{ method: "GET", path: "/ai/analyze/regions", handler: "analyzePageRegions" },
|
|
128
|
+
{ method: "GET", path: "/ai/analyze/structured-data", handler: "analyzeStructuredData" },
|
|
129
|
+
{
|
|
130
|
+
method: "POST",
|
|
131
|
+
path: "/ai/analyze/cross-app-compare",
|
|
132
|
+
handler: "crossAppCompare",
|
|
133
|
+
bodyRequired: true
|
|
134
|
+
},
|
|
135
|
+
// Page navigation
|
|
136
|
+
{ method: "POST", path: "/control/page/refresh", handler: "pageRefresh" },
|
|
137
|
+
{ method: "POST", path: "/control/page/navigate", handler: "pageNavigate", bodyRequired: true },
|
|
138
|
+
{ method: "POST", path: "/control/page/back", handler: "pageGoBack" },
|
|
139
|
+
{ method: "POST", path: "/control/page/forward", handler: "pageGoForward" },
|
|
140
|
+
// Annotations (static routes before parameterized)
|
|
141
|
+
{ method: "GET", path: "/annotations", handler: "getAnnotations" },
|
|
142
|
+
{ method: "GET", path: "/annotations/export", handler: "exportAnnotations" },
|
|
143
|
+
{ method: "GET", path: "/annotations/coverage", handler: "getAnnotationCoverage" },
|
|
144
|
+
{ method: "POST", path: "/annotations/import", handler: "importAnnotations", bodyRequired: true },
|
|
145
|
+
{ method: "GET", path: "/annotations/:id", handler: "getAnnotation", params: ["id"] },
|
|
146
|
+
{
|
|
147
|
+
method: "PUT",
|
|
148
|
+
path: "/annotations/:id",
|
|
149
|
+
handler: "setAnnotation",
|
|
150
|
+
params: ["id"],
|
|
151
|
+
bodyRequired: true
|
|
152
|
+
},
|
|
153
|
+
{ method: "DELETE", path: "/annotations/:id", handler: "deleteAnnotation", params: ["id"] },
|
|
154
|
+
// Performance diagnostics
|
|
155
|
+
{ method: "GET", path: "/control/performance-entries", handler: "getPerformanceEntries" },
|
|
156
|
+
{
|
|
157
|
+
method: "POST",
|
|
158
|
+
path: "/control/performance-entries/clear",
|
|
159
|
+
handler: "clearPerformanceEntries"
|
|
160
|
+
},
|
|
161
|
+
{ method: "GET", path: "/control/browser-events", handler: "getBrowserEvents" }
|
|
162
|
+
];
|
|
163
|
+
|
|
164
|
+
// src/server/nextjs.ts
|
|
165
|
+
function wrapError(error, code) {
|
|
166
|
+
return {
|
|
167
|
+
success: false,
|
|
168
|
+
error: typeof error === "string" ? error : error.message,
|
|
169
|
+
code,
|
|
170
|
+
timestamp: Date.now()
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function jsonResponse(data, status = 200) {
|
|
174
|
+
return new Response(JSON.stringify(data), {
|
|
175
|
+
status,
|
|
176
|
+
headers: {
|
|
177
|
+
"Content-Type": "application/json"
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
function createNextRouteHandlers(handlers, config = {}) {
|
|
182
|
+
const authenticate = config.authenticate;
|
|
183
|
+
async function handleRequest(request, context) {
|
|
184
|
+
try {
|
|
185
|
+
if (authenticate) {
|
|
186
|
+
const authenticated = await authenticate(request);
|
|
187
|
+
if (!authenticated) {
|
|
188
|
+
return jsonResponse(wrapError("Unauthorized", "UNAUTHORIZED"), 401);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const pathParam = context.params.path;
|
|
192
|
+
const path = Array.isArray(pathParam) ? "/" + pathParam.join("/") : "/" + pathParam;
|
|
193
|
+
const method = request.method;
|
|
194
|
+
const route = findMatchingRoute(path, method);
|
|
195
|
+
if (!route) {
|
|
196
|
+
return jsonResponse(wrapError("Not found", "NOT_FOUND"), 404);
|
|
197
|
+
}
|
|
198
|
+
const params = extractParams(path, route);
|
|
199
|
+
const handlerName = route.handler;
|
|
200
|
+
const handler = handlers[handlerName];
|
|
201
|
+
if (!handler) {
|
|
202
|
+
return jsonResponse(wrapError("Handler not found", "NOT_IMPLEMENTED"), 501);
|
|
203
|
+
}
|
|
204
|
+
const args = [];
|
|
205
|
+
if (route.params) {
|
|
206
|
+
for (const param of route.params) {
|
|
207
|
+
args.push(params[param]);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (route.bodyRequired || method === "POST" || method === "PUT" || method === "PATCH") {
|
|
211
|
+
try {
|
|
212
|
+
const body = await request.json();
|
|
213
|
+
args.push(body);
|
|
214
|
+
} catch {
|
|
215
|
+
args.push({});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (method === "GET") {
|
|
219
|
+
const searchParams = Object.fromEntries(request.nextUrl.searchParams);
|
|
220
|
+
if (Object.keys(searchParams).length > 0) {
|
|
221
|
+
args.push(searchParams);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const result = await handler(
|
|
225
|
+
...args
|
|
226
|
+
);
|
|
227
|
+
return jsonResponse(result);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error("UI Bridge error:", error);
|
|
230
|
+
return jsonResponse(wrapError(error, "INTERNAL_ERROR"), 500);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
GET: handleRequest,
|
|
235
|
+
POST: handleRequest,
|
|
236
|
+
PUT: handleRequest,
|
|
237
|
+
DELETE: handleRequest
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function findMatchingRoute(path, method) {
|
|
241
|
+
for (const route of UI_BRIDGE_ROUTES) {
|
|
242
|
+
if (route.method !== method) continue;
|
|
243
|
+
const routeRegex = route.path.replace(/:[^/]+/g, "([^/]+)").replace(/\//g, "\\/");
|
|
244
|
+
const regex = new RegExp(`^${routeRegex}$`);
|
|
245
|
+
if (regex.test(path)) {
|
|
246
|
+
return route;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
function extractParams(path, route) {
|
|
252
|
+
const params = {};
|
|
253
|
+
if (!route.params) return params;
|
|
254
|
+
const routeParts = route.path.split("/");
|
|
255
|
+
const pathParts = path.split("/");
|
|
256
|
+
for (let i = 0; i < routeParts.length; i++) {
|
|
257
|
+
const routePart = routeParts[i];
|
|
258
|
+
if (routePart.startsWith(":")) {
|
|
259
|
+
const paramName = routePart.slice(1);
|
|
260
|
+
params[paramName] = pathParts[i];
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return params;
|
|
264
|
+
}
|
|
265
|
+
function createRenderLogHandlers(handlers) {
|
|
266
|
+
return {
|
|
267
|
+
async GET(request) {
|
|
268
|
+
const searchParams = Object.fromEntries(request.nextUrl.searchParams);
|
|
269
|
+
const query = {
|
|
270
|
+
type: searchParams.type,
|
|
271
|
+
since: searchParams.since ? parseInt(searchParams.since) : void 0,
|
|
272
|
+
until: searchParams.until ? parseInt(searchParams.until) : void 0,
|
|
273
|
+
limit: searchParams.limit ? parseInt(searchParams.limit) : void 0
|
|
274
|
+
};
|
|
275
|
+
const result = await handlers.getRenderLog(query);
|
|
276
|
+
return jsonResponse(result);
|
|
277
|
+
},
|
|
278
|
+
async DELETE() {
|
|
279
|
+
const result = await handlers.clearRenderLog();
|
|
280
|
+
return jsonResponse(result);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
function createControlHandlers(handlers) {
|
|
285
|
+
return {
|
|
286
|
+
elements: {
|
|
287
|
+
async GET() {
|
|
288
|
+
const result = await handlers.getElements();
|
|
289
|
+
return jsonResponse(result);
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
element: {
|
|
293
|
+
async GET(_request, context) {
|
|
294
|
+
const result = await handlers.getElement(context.params.id);
|
|
295
|
+
return jsonResponse(result);
|
|
296
|
+
},
|
|
297
|
+
async POST(request, context) {
|
|
298
|
+
const body = await request.json();
|
|
299
|
+
const result = await handlers.executeElementAction(context.params.id, body);
|
|
300
|
+
return jsonResponse(result);
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
components: {
|
|
304
|
+
async GET() {
|
|
305
|
+
const result = await handlers.getComponents();
|
|
306
|
+
return jsonResponse(result);
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
component: {
|
|
310
|
+
async GET(_request, context) {
|
|
311
|
+
const result = await handlers.getComponent(context.params.id);
|
|
312
|
+
return jsonResponse(result);
|
|
313
|
+
},
|
|
314
|
+
async POST(request, context) {
|
|
315
|
+
const body = await request.json();
|
|
316
|
+
const result = await handlers.executeComponentAction(context.params.id, {
|
|
317
|
+
...body,
|
|
318
|
+
action: context.params.actionId
|
|
319
|
+
});
|
|
320
|
+
return jsonResponse(result);
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
find: {
|
|
324
|
+
async POST(request) {
|
|
325
|
+
const body = await request.json();
|
|
326
|
+
const result = await handlers.find(body);
|
|
327
|
+
return jsonResponse(result);
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
discover: {
|
|
331
|
+
/**
|
|
332
|
+
* @deprecated Use /control/find instead
|
|
333
|
+
*/
|
|
334
|
+
async POST(request) {
|
|
335
|
+
const body = await request.json();
|
|
336
|
+
const result = await handlers.discover(body);
|
|
337
|
+
return jsonResponse(result);
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
snapshot: {
|
|
341
|
+
async GET() {
|
|
342
|
+
const result = await handlers.getControlSnapshot();
|
|
343
|
+
return jsonResponse(result);
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
workflows: {
|
|
347
|
+
async GET() {
|
|
348
|
+
const result = await handlers.getWorkflows();
|
|
349
|
+
return jsonResponse(result);
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
workflow: {
|
|
353
|
+
async POST(request, context) {
|
|
354
|
+
const body = await request.json();
|
|
355
|
+
const result = await handlers.runWorkflow(context.params.id, body);
|
|
356
|
+
return jsonResponse(result);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function createDebugHandlers(handlers) {
|
|
362
|
+
return {
|
|
363
|
+
actionHistory: {
|
|
364
|
+
async GET(request) {
|
|
365
|
+
const limit = request.nextUrl.searchParams.get("limit");
|
|
366
|
+
const result = await handlers.getActionHistory(limit ? parseInt(limit) : void 0);
|
|
367
|
+
return jsonResponse(result);
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
metrics: {
|
|
371
|
+
async GET() {
|
|
372
|
+
const result = await handlers.getMetrics();
|
|
373
|
+
return jsonResponse(result);
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
highlight: {
|
|
377
|
+
async POST(_request, context) {
|
|
378
|
+
const result = await handlers.highlightElement(context.params.id);
|
|
379
|
+
return jsonResponse(result);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
exports.createControlHandlers = createControlHandlers;
|
|
386
|
+
exports.createDebugHandlers = createDebugHandlers;
|
|
387
|
+
exports.createNextRouteHandlers = createNextRouteHandlers;
|
|
388
|
+
exports.createRenderLogHandlers = createRenderLogHandlers;
|
|
389
|
+
//# sourceMappingURL=nextjs.js.map
|
|
390
|
+
//# sourceMappingURL=nextjs.js.map
|