@lowdefy/server-dev 0.0.0-experimental-20260720072521 → 0.0.0-experimental-20260720135014

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 (196) hide show
  1. package/.eslintrc.yaml +1 -0
  2. package/lib/build/app.js +1 -8
  3. package/lib/build/appMeta.js +1 -8
  4. package/lib/build/auth.js +1 -8
  5. package/lib/build/config.js +1 -8
  6. package/lib/build/i18n.js +1 -8
  7. package/lib/build/logger.js +1 -8
  8. package/lib/build/theme.js +1 -8
  9. package/lib/client/App.js +80 -0
  10. package/{client/Page.jsx → lib/client/Page.js} +5 -5
  11. package/{client/Reload.jsx → lib/client/Reload.js} +7 -5
  12. package/lib/client/auth/{Auth.jsx → Auth.js} +5 -12
  13. package/lib/client/auth/AuthConfigured.js +61 -0
  14. package/lib/client/auth/AuthNotConfigured.js +2 -22
  15. package/lib/client/setPageId.js +5 -6
  16. package/lib/client/utils/useMutateCache.js +1 -14
  17. package/lib/client/utils/usePageConfig.js +11 -31
  18. package/lib/server/apiWrapper.js +116 -0
  19. package/lib/server/auth/{getStrategies.js → getAuthOptions.js} +9 -14
  20. package/lib/server/auth/{getMockUser.js → getMockSession.js} +19 -10
  21. package/{src/routes/docs/checkpointsRevert.js → lib/server/auth/getServerSession.js} +13 -11
  22. package/lib/server/compileCss.js +39 -0
  23. package/lib/server/jitPageBuilder.js +11 -36
  24. package/lib/server/log/logRequest.js +3 -1
  25. package/manager/getContext.mjs +7 -3
  26. package/manager/processes/compileCss.mjs +54 -0
  27. package/manager/processes/initialBuild.mjs +2 -0
  28. package/manager/processes/installPlugins.mjs +11 -19
  29. package/manager/processes/lowdefyBuild.mjs +7 -29
  30. package/manager/processes/nextBuild.mjs +50 -0
  31. package/manager/processes/readDotEnv.mjs +1 -13
  32. package/manager/processes/shutdownServer.mjs +6 -6
  33. package/manager/processes/startServer.mjs +7 -8
  34. package/manager/processes/startWatchers.mjs +2 -2
  35. package/manager/run.mjs +0 -41
  36. package/manager/utils/createCustomPluginMessagesMap.mjs +1 -8
  37. package/manager/utils/createCustomPluginTypesMap.mjs +2 -3
  38. package/manager/utils/{getViteBin.mjs → getNextBin.mjs} +10 -7
  39. package/manager/utils/updatePageTailwindCss.mjs +1 -7
  40. package/manager/watchers/lowdefyBuildWatcher.mjs +1 -0
  41. package/manager/watchers/moduleBuildWatcher.mjs +1 -0
  42. package/manager/watchers/{serverArtifactWatcher.mjs → nextBuildWatcher.mjs} +22 -18
  43. package/next.config.js +25 -0
  44. package/package.json +47 -63
  45. package/package.original.json +55 -66
  46. package/{src/routes/devTools.js → pages/404.js} +2 -4
  47. package/{src/routes/docs/appMap.js → pages/[[...pageId]].js} +2 -6
  48. package/{client/App.jsx → pages/_app.js} +33 -21
  49. package/pages/_document.js +107 -0
  50. package/pages/api/agent/[...path].js +86 -0
  51. package/pages/api/auth/[...nextauth].js +48 -0
  52. package/pages/api/client-error.js +45 -0
  53. package/{src/routes/docs/buildStatus.js → pages/api/dev-tools.js} +4 -5
  54. package/{lib/docs/clientErrorStore.js → pages/api/endpoints/[...endpointId].js} +11 -15
  55. package/{src/lib/serveBuildJs.js → pages/api/icons/dynamic.js} +12 -8
  56. package/{src/routes/jsEnv.js → pages/api/js/[env].js} +20 -8
  57. package/pages/api/page/[...pageId].js +74 -0
  58. package/{src/routes → pages/api}/ping.js +2 -4
  59. package/pages/api/reload.js +53 -0
  60. package/pages/api/request/[...path].js +41 -0
  61. package/{src/routes → pages/api}/root.js +4 -4
  62. package/client/Inspector.jsx +0 -206
  63. package/client/Routing.jsx +0 -106
  64. package/client/feedback/FeedbackMount.jsx +0 -83
  65. package/client/feedback/FeedbackOverlay.jsx +0 -901
  66. package/client/feedback/captureTabScreenshot.js +0 -84
  67. package/client/feedback/copyToClipboard.js +0 -45
  68. package/client/feedback/drawAnnotationsSvg.js +0 -119
  69. package/client/feedback/elementInspect.js +0 -99
  70. package/client/feedback/feedbackStyles.js +0 -301
  71. package/client/feedback/pinResponsiveImages.js +0 -59
  72. package/client/feedback/sendFeedback.js +0 -39
  73. package/client/feedback/useFeedbackToggle.js +0 -70
  74. package/client/main.jsx +0 -42
  75. package/client/openInEditor/OpenInEditorListener.jsx +0 -261
  76. package/client/openInEditor/findBlockLocation.js +0 -51
  77. package/lib/client/auth/AuthConfigured.jsx +0 -155
  78. package/lib/docs/captureAnnotatedScreenshot.js +0 -88
  79. package/lib/docs/checkpointPaths.js +0 -91
  80. package/lib/docs/checkpointStore.js +0 -234
  81. package/lib/docs/checkpointToMocks.js +0 -65
  82. package/lib/docs/configCheckpoints.test.mjs +0 -156
  83. package/lib/docs/createConfigCheckpoint.js +0 -92
  84. package/lib/docs/createDocsMcpServer.js +0 -506
  85. package/lib/docs/createDocsMcpServer.test.mjs +0 -123
  86. package/lib/docs/devMockRegistry.js +0 -68
  87. package/lib/docs/docs.test.mjs +0 -448
  88. package/lib/docs/enrichFeedback.js +0 -71
  89. package/lib/docs/evalOperator.js +0 -39
  90. package/lib/docs/evalOperator.test.mjs +0 -112
  91. package/lib/docs/evalOperatorHeadless.js +0 -87
  92. package/lib/docs/evalOperatorHeadless.test.mjs +0 -72
  93. package/lib/docs/evalOperatorInTab.js +0 -48
  94. package/lib/docs/findConfig.js +0 -260
  95. package/lib/docs/formatFeedback.js +0 -121
  96. package/lib/docs/formatFeedback.test.mjs +0 -204
  97. package/lib/docs/getAppMap.js +0 -180
  98. package/lib/docs/getBrowser.js +0 -115
  99. package/lib/docs/getBuildStatus.js +0 -37
  100. package/lib/docs/getCoreDoc.js +0 -63
  101. package/lib/docs/getDocsManifest.js +0 -40
  102. package/lib/docs/getExamples.js +0 -58
  103. package/lib/docs/getOverview.js +0 -115
  104. package/lib/docs/getPageConfig.js +0 -53
  105. package/lib/docs/getPluginDoc.js +0 -55
  106. package/lib/docs/getSchema.js +0 -65
  107. package/lib/docs/inspectState.js +0 -41
  108. package/lib/docs/inspectState.test.mjs +0 -91
  109. package/lib/docs/inspectStateFromTab.js +0 -40
  110. package/lib/docs/inspectStateHeadless.js +0 -84
  111. package/lib/docs/inspectStateHeadless.test.mjs +0 -60
  112. package/lib/docs/isWriteRequestsAllowed.js +0 -50
  113. package/lib/docs/listConfigCheckpoints.js +0 -55
  114. package/lib/docs/listPlugins.js +0 -80
  115. package/lib/docs/listTypes.js +0 -105
  116. package/lib/docs/loadState.js +0 -139
  117. package/lib/docs/mapPageBuildErrors.js +0 -28
  118. package/lib/docs/normalizeTypeKind.js +0 -40
  119. package/lib/docs/readBuildArtifact.js +0 -35
  120. package/lib/docs/readPageArtifact.js +0 -26
  121. package/lib/docs/resolvePluginDir.js +0 -49
  122. package/lib/docs/revertConfigCheckpoint.js +0 -73
  123. package/lib/docs/runRequest.js +0 -141
  124. package/lib/docs/saveAnnotatedScreenshot.js +0 -43
  125. package/lib/docs/scaffoldPage.js +0 -75
  126. package/lib/docs/scaffoldPage.test.mjs +0 -97
  127. package/lib/docs/screenshotPage.js +0 -109
  128. package/lib/docs/screenshotPage.test.mjs +0 -59
  129. package/lib/docs/screenshotPageClip.test.mjs +0 -102
  130. package/lib/docs/searchDocs.js +0 -67
  131. package/lib/docs/setupTestFixtures.mjs +0 -335
  132. package/lib/docs/snapshotState.js +0 -59
  133. package/lib/docs/stateCheckpoints.test.mjs +0 -348
  134. package/lib/docs/tabAvailable.js +0 -28
  135. package/lib/docs/tabChannel.js +0 -119
  136. package/lib/docs/tabChannel.test.mjs +0 -130
  137. package/lib/server/auth/createSystemContext.js +0 -70
  138. package/lib/server/auth/getAuth.js +0 -46
  139. package/lib/server/auth/getHeadlessUser.js +0 -39
  140. package/lib/server/auth/headlessUser.js +0 -30
  141. package/lib/server/createLowdefyContext.js +0 -133
  142. package/lib/server/loadDynamicJsMap.js +0 -47
  143. package/manager/processes/lowdefyBuild.test.mjs +0 -102
  144. package/manager/utils/formatNoticeBox.mjs +0 -30
  145. package/manager/utils/writeBuildStatus.mjs +0 -39
  146. package/manager/utils/writeBuildStatus.test.mjs +0 -76
  147. package/postcss.config.cjs +0 -1
  148. package/src/app.js +0 -188
  149. package/src/html/renderDevPage.js +0 -86
  150. package/src/lib/getPathSegments.js +0 -25
  151. package/src/lib/safeScriptJson.js +0 -38
  152. package/src/middleware/apiContext.js +0 -32
  153. package/src/middleware/errorHandler.js +0 -55
  154. package/src/routes/agent.js +0 -64
  155. package/src/routes/auth.js +0 -43
  156. package/src/routes/clientError.js +0 -57
  157. package/src/routes/cron.js +0 -44
  158. package/src/routes/detached.js +0 -51
  159. package/src/routes/devInspect.js +0 -94
  160. package/src/routes/docs/checkpointsCreate.js +0 -28
  161. package/src/routes/docs/checkpointsList.js +0 -23
  162. package/src/routes/docs/content.js +0 -31
  163. package/src/routes/docs/evalOperator.js +0 -46
  164. package/src/routes/docs/examples.js +0 -33
  165. package/src/routes/docs/find.js +0 -30
  166. package/src/routes/docs/index.js +0 -23
  167. package/src/routes/docs/inspectState.js +0 -34
  168. package/src/routes/docs/loadState.js +0 -38
  169. package/src/routes/docs/mcp.js +0 -30
  170. package/src/routes/docs/pageConfig.js +0 -36
  171. package/src/routes/docs/pluginDoc.js +0 -33
  172. package/src/routes/docs/plugins.js +0 -23
  173. package/src/routes/docs/runRequest.js +0 -34
  174. package/src/routes/docs/schema.js +0 -37
  175. package/src/routes/docs/screenshot.js +0 -66
  176. package/src/routes/docs/search.js +0 -27
  177. package/src/routes/docs/snapshotState.js +0 -36
  178. package/src/routes/docs/stateCheckpointsList.js +0 -26
  179. package/src/routes/docs/types.js +0 -33
  180. package/src/routes/endpoints.js +0 -76
  181. package/src/routes/feedback.js +0 -110
  182. package/src/routes/feedback.test.mjs +0 -204
  183. package/src/routes/iconsDynamic.js +0 -25
  184. package/src/routes/jitPage.js +0 -99
  185. package/src/routes/reload.js +0 -81
  186. package/src/routes/request.js +0 -66
  187. package/src/routes/usage.js +0 -46
  188. package/src/routes/user.js +0 -27
  189. package/src/routes/websocket.js +0 -33
  190. package/src/websocket/devWebSocket.js +0 -78
  191. package/vite.config.js +0 -111
  192. /package/lib/client/{BuildErrorPage.jsx → BuildErrorPage.js} +0 -0
  193. /package/lib/client/{BuildingPage.jsx → BuildingPage.js} +0 -0
  194. /package/lib/client/{ErrorBar.jsx → ErrorBar.js} +0 -0
  195. /package/lib/client/{InstallingPluginsPage.jsx → InstallingPluginsPage.js} +0 -0
  196. /package/lib/client/{RestartingPage.jsx → RestartingPage.js} +0 -0
@@ -1,51 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import { runDetachedEndpoint } from '@lowdefy/api';
18
-
19
- import getPathSegments from '../lib/getPathSegments.js';
20
-
21
- // Target of a CallApi step with `detached: true`: the calling invocation
22
- // fire-and-forgets a POST here, so the endpoint runs in its OWN function
23
- // invocation with a fresh duration budget (chainable bounded work without a
24
- // queue). Transport auth is CRON_SECRET (fails closed), which proves the
25
- // request originated from the deployment. The run carries the DISPATCHER'S
26
- // identity (Decision 4): the request body carries a server-built principal
27
- // snapshot that runDetachedEndpoint rehydrates, so nested calls authorize
28
- // against the dispatcher, not a forced system context. Delivery is at-most-once
29
- // with no retry: targets must be idempotent.
30
- async function detachedHandler(c) {
31
- if (c.req.method !== 'POST') {
32
- throw new Error('Only POST requests are supported.');
33
- }
34
- const context = c.get('lowdefyContext');
35
-
36
- // The secret gate stays first: an external POST without the secret is
37
- // rejected before the body (and its principal assertion) is ever read.
38
- const secret = process.env.CRON_SECRET;
39
- if (!secret || c.req.header('authorization') !== `Bearer ${secret}`) {
40
- context.logger.warn({ event: 'detached_unauthorized' });
41
- return c.json({ error: 'Unauthorized' }, 401);
42
- }
43
-
44
- const endpointId = getPathSegments(c, '/api/detached/').join('/');
45
- const { payload, principal } = await c.req.json();
46
- context.logger.info({ event: 'call_detached_endpoint', endpointId });
47
- const response = await runDetachedEndpoint(context, { endpointId, payload, principal });
48
- return c.json(response);
49
- }
50
-
51
- export default detachedHandler;
@@ -1,94 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import { serializer } from '@lowdefy/helpers';
18
-
19
- import { readCheckpoint } from '../../lib/docs/checkpointStore.js';
20
- import { loadMocks } from '../../lib/docs/devMockRegistry.js';
21
- import getPathSegments from '../lib/getPathSegments.js';
22
- import { listTabs, resolveTabRequest } from '../../lib/docs/tabChannel.js';
23
-
24
- // Origin/host check mirrors clientError.js — this endpoint accepts a POST
25
- // from Inspector.jsx (a same-origin dev-only browser component), not from
26
- // arbitrary agents, so it needs the same CSRF-style guard.
27
- function checkOrigin(c) {
28
- const origin = c.req.header('origin');
29
- if (!origin) {
30
- return false;
31
- }
32
- try {
33
- return new URL(origin).host === c.req.header('host');
34
- } catch {
35
- return false;
36
- }
37
- }
38
-
39
- // Dev-only agent-state-xray: a human tab bootstrapping from a
40
- // `?_checkpoint=<name>` URL (client/Inspector.jsx) fetches this. It returns
41
- // the checkpoint's state part + manifest for the tab to inject client-side,
42
- // and — as a side effect — loads the checkpoint's recorded requests into
43
- // devMockRegistry server-side, so that tab's own requests (src/routes/
44
- // request.js) replay recorded data instead of hitting real connections.
45
- function handleCheckpointBootstrap(c, { name }) {
46
- let checkpoint;
47
- try {
48
- checkpoint = readCheckpoint({ name });
49
- } catch (error) {
50
- return c.json({ error: error.message }, 404);
51
- }
52
- loadMocks({ pageId: checkpoint.checkpoint.pageId, mocks: checkpoint.requests });
53
- return c.json(
54
- serializer.serialize({
55
- checkpoint: checkpoint.checkpoint,
56
- state: checkpoint.state,
57
- urlQuery: checkpoint.urlQuery,
58
- input: checkpoint.input,
59
- user: checkpoint.user,
60
- global: checkpoint.global,
61
- })
62
- );
63
- }
64
-
65
- // GET lists connected tabs for diagnostics (or, under /checkpoint/<name>,
66
- // bootstraps a human tab from a state checkpoint); POST is the answer leg of
67
- // the SSE request/response round trip (Inspector.jsx posts back {requestId,
68
- // result} after handling an inspect-request/eval-request event).
69
- async function devInspectHandler(c) {
70
- if (c.req.method === 'GET') {
71
- const segments = getPathSegments(c, '/api/dev-inspect/');
72
- if (segments[0] === 'checkpoint' && segments[1]) {
73
- return handleCheckpointBootstrap(c, { name: segments[1] });
74
- }
75
- return c.json({ tabs: listTabs() });
76
- }
77
-
78
- if (c.req.method !== 'POST') {
79
- throw new Error('Only GET and POST requests are supported.');
80
- }
81
-
82
- if (!checkOrigin(c)) {
83
- return c.json({ error: 'Forbidden' }, 403);
84
- }
85
-
86
- const { requestId, result } = await c.req.json();
87
- if (!requestId) {
88
- return c.json({ error: 'Missing "requestId".' }, 400);
89
- }
90
- const resolved = resolveTabRequest({ requestId, result });
91
- return c.json({ ok: resolved });
92
- }
93
-
94
- export default devInspectHandler;
@@ -1,28 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import createConfigCheckpoint from '../../../lib/docs/createConfigCheckpoint.js';
18
-
19
- // Lets an agent snapshot the config directory before an experimental change,
20
- // so it can revert cleanly with POST /lowdefy-docs/checkpoints/revert if the
21
- // change doesn't work out.
22
- async function docsCheckpointsCreateHandler(c) {
23
- const body = await c.req.json().catch(() => ({}));
24
- const result = createConfigCheckpoint({ label: body.label });
25
- return c.json(result);
26
- }
27
-
28
- export default docsCheckpointsCreateHandler;
@@ -1,23 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import listConfigCheckpoints from '../../../lib/docs/listConfigCheckpoints.js';
18
-
19
- function docsCheckpointsListHandler(c) {
20
- return c.json(listConfigCheckpoints());
21
- }
22
-
23
- export default docsCheckpointsListHandler;
@@ -1,31 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import getCoreDoc from '../../../lib/docs/getCoreDoc.js';
18
-
19
- function docsContentHandler(c) {
20
- const slug = c.req.param('slug');
21
- const doc = getCoreDoc({ slug });
22
- if (doc === null) {
23
- return c.json(
24
- { error: `No doc found for slug "${slug}". Use GET /lowdefy-docs/search?q=... to find the right slug.` },
25
- 404
26
- );
27
- }
28
- return c.text(doc.markdown, 200, { 'Content-Type': 'text/markdown; charset=utf-8' });
29
- }
30
-
31
- export default docsContentHandler;
@@ -1,46 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import evalOperator from '../../../lib/docs/evalOperator.js';
18
-
19
- async function docsEvalOperatorHandler(c) {
20
- const body = await c.req.json().catch(() => ({}));
21
- const { pageId, source } = body;
22
- // "operator" is accepted as an alias for "expression" — agents commonly
23
- // guess it as the body key for this endpoint.
24
- const expression = body.expression ?? body.operator;
25
- if (expression === undefined) {
26
- return c.json(
27
- {
28
- error:
29
- 'POST /lowdefy-docs/eval-operator requires an "expression" in the JSON body — the operator expression to evaluate, e.g. {"pageId": "home", "expression": {"_state": "key"}}.',
30
- },
31
- 400
32
- );
33
- }
34
- // Derived from the incoming request rather than a config value — this is
35
- // the origin an agent can actually reach the dev server on (host/port it
36
- // just connected to), regardless of how the server is bound.
37
- const origin = new URL(c.req.url).origin;
38
-
39
- const result = await evalOperator({ origin, pageId, expression, source });
40
- if (result.error) {
41
- return c.json({ error: result.error, source: result.source }, 502);
42
- }
43
- return c.json(result);
44
- }
45
-
46
- export default docsEvalOperatorHandler;
@@ -1,33 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import getExamples from '../../../lib/docs/getExamples.js';
18
-
19
- function docsExamplesHandler(c) {
20
- const type = c.req.param('type');
21
- const examples = getExamples({ type });
22
- if (examples === null) {
23
- return c.json(
24
- {
25
- error: `No examples shipped for block type "${type}". Use GET /lowdefy-docs/schema/blocks/${type} for its schema.`,
26
- },
27
- 404
28
- );
29
- }
30
- return c.json(examples);
31
- }
32
-
33
- export default docsExamplesHandler;
@@ -1,30 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import findConfig from '../../../lib/docs/findConfig.js';
18
-
19
- async function docsFindHandler(c) {
20
- const id = c.req.param('id');
21
- const pageId = c.req.query('pageId');
22
- try {
23
- const result = await findConfig({ id, pageId });
24
- return c.json(result);
25
- } catch (error) {
26
- return c.json({ error: error.message }, 400);
27
- }
28
- }
29
-
30
- export default docsFindHandler;
@@ -1,23 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import getOverview from '../../../lib/docs/getOverview.js';
18
-
19
- function docsIndexHandler(c) {
20
- return c.text(getOverview(), 200, { 'Content-Type': 'text/markdown; charset=utf-8' });
21
- }
22
-
23
- export default docsIndexHandler;
@@ -1,34 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import inspectState from '../../../lib/docs/inspectState.js';
18
-
19
- async function docsInspectStateHandler(c) {
20
- const pageId = c.req.param('pageId');
21
- const source = c.req.query('source');
22
- // Derived from the incoming request rather than a config value — this is
23
- // the origin an agent can actually reach the dev server on (host/port it
24
- // just connected to), regardless of how the server is bound.
25
- const origin = new URL(c.req.url).origin;
26
-
27
- const result = await inspectState({ origin, pageId, source });
28
- if (result.error) {
29
- return c.json({ error: result.error, source: result.source }, 502);
30
- }
31
- return c.json(result);
32
- }
33
-
34
- export default docsInspectStateHandler;
@@ -1,38 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import loadState from '../../../lib/docs/loadState.js';
18
-
19
- // Loads a state checkpoint back into the running app. mode: 'headless'
20
- // (default) drives a headless page and injects state directly for an agent
21
- // to verify; mode: 'registry-only' just loads the recorded requests into
22
- // devMockRegistry and returns a URL for a human to open in a real browser
23
- // tab (client/Inspector.jsx does the state injection there).
24
- async function docsLoadStateHandler(c) {
25
- const { name, mode } = await c.req.json();
26
- // Derived from the incoming request rather than a config value — this is
27
- // the origin an agent can actually reach the dev server on (host/port it
28
- // just connected to), regardless of how the server is bound.
29
- const origin = new URL(c.req.url).origin;
30
-
31
- const result = await loadState({ origin, name, mode });
32
- if (result.error) {
33
- return c.json({ error: result.error }, 502);
34
- }
35
- return c.json(result);
36
- }
37
-
38
- export default docsLoadStateHandler;
@@ -1,30 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import { StreamableHTTPTransport } from '@hono/mcp';
18
-
19
- import createDocsMcpServer from '../../../lib/docs/createDocsMcpServer.js';
20
-
21
- // Stateless per-request server: docs tools read build artifacts fresh on
22
- // every call, so there is no session state worth keeping between requests.
23
- async function mcpHandler(c) {
24
- const server = createDocsMcpServer({ origin: new URL(c.req.url).origin, honoContext: c });
25
- const transport = new StreamableHTTPTransport();
26
- await server.connect(transport);
27
- return transport.handleRequest(c);
28
- }
29
-
30
- export default mcpHandler;
@@ -1,36 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import getPageConfig from '../../../lib/docs/getPageConfig.js';
18
-
19
- // 404 when the pageId isn't registered at all. 200 with { buildError, errors }
20
- // when the pageId is registered but its JIT build failed — agents need the
21
- // errors in the body, not just a failing status code.
22
- async function docsPageConfigHandler(c) {
23
- const pageId = c.req.param('pageId');
24
- const result = await getPageConfig({ pageId });
25
- if (result === null) {
26
- return c.json(
27
- {
28
- error: `No page found for pageId "${pageId}". Check the pageId in your lowdefy.yaml pages config.`,
29
- },
30
- 404
31
- );
32
- }
33
- return c.json(result);
34
- }
35
-
36
- export default docsPageConfigHandler;
@@ -1,33 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import getPluginDoc from '../../../lib/docs/getPluginDoc.js';
18
-
19
- function docsPluginDocHandler(c) {
20
- const packageName = c.req.param('package');
21
- const doc = getPluginDoc({ packageName });
22
- if (doc === null) {
23
- return c.json(
24
- {
25
- error: `Package "${packageName}" ships no markdown docs. See GET /lowdefy-docs/plugins for its types.`,
26
- },
27
- 404
28
- );
29
- }
30
- return c.text(doc.markdown, 200, { 'Content-Type': 'text/markdown; charset=utf-8' });
31
- }
32
-
33
- export default docsPluginDocHandler;
@@ -1,23 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import listPlugins from '../../../lib/docs/listPlugins.js';
18
-
19
- function docsPluginsHandler(c) {
20
- return c.json(listPlugins());
21
- }
22
-
23
- export default docsPluginsHandler;
@@ -1,34 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import runRequest from '../../../lib/docs/runRequest.js';
18
-
19
- // Refusals and request errors are returned as 200 data (see runRequest.js) —
20
- // only malformed input (missing pageId/requestId) is a 400.
21
- async function docsRunRequestHandler(c) {
22
- // Parse the body from a clone: runRequest builds a Lowdefy context whose
23
- // resolveAuthentication reads c.req.raw (headers) to resolve the caller,
24
- // so leave the original request body intact and read our own copy here.
25
- const { pageId, requestId, payload } = await c.req.raw.clone().json();
26
- try {
27
- const result = await runRequest({ pageId, requestId, payload, honoContext: c });
28
- return c.json(result);
29
- } catch (error) {
30
- return c.json({ error: error.message }, 400);
31
- }
32
- }
33
-
34
- export default docsRunRequestHandler;
@@ -1,37 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import getSchema from '../../../lib/docs/getSchema.js';
18
-
19
- function docsSchemaHandler(c) {
20
- const kind = c.req.param('kind');
21
- const type = c.req.param('type');
22
- let schema;
23
- try {
24
- schema = getSchema({ kind, type });
25
- } catch (error) {
26
- return c.json({ error: error.message }, 400);
27
- }
28
- if (schema === null) {
29
- return c.json(
30
- { error: `No schema found for ${kind} type "${type}". See GET /lowdefy-docs/${kind} for available types.` },
31
- 404
32
- );
33
- }
34
- return c.json(schema);
35
- }
36
-
37
- export default docsSchemaHandler;