@jami-studio/core 0.92.34 → 0.92.36
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/corpus/core/CHANGELOG.md +12 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/deploy/build.ts +44 -1
- package/corpus/core/src/deploy/route-discovery.ts +26 -0
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +42 -1
- package/dist/deploy/build.js.map +1 -1
- package/dist/deploy/route-discovery.d.ts +7 -0
- package/dist/deploy/route-discovery.d.ts.map +1 -1
- package/dist/deploy/route-discovery.js +29 -0
- package/dist/deploy/route-discovery.js.map +1 -1
- package/dist/observability/routes.d.ts +5 -5
- package/dist/progress/routes.d.ts +1 -1
- package/package.json +1 -1
package/corpus/core/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @agent-native/core
|
|
2
2
|
|
|
3
|
+
## 0.92.36
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- dc8c05b: Serverless route discovery now mounts TOP-LEVEL `server/routes/*` files (e.g. analytics `track.post.ts` → `POST /track`) in the generated worker entry — previously only the `/api` and `/_agent-native` subtrees were scanned, so ingest routes living outside `/api` 404'd on every serverless deploy. Page catch-alls (`[...page].get.ts`) stay unmounted (the static app shell owns page serving), and non-api subdirectories are unchanged.
|
|
8
|
+
|
|
9
|
+
## 0.92.35
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- b88419c: The generated Cloudflare worker entry now strips the mount prefix for the app's own custom h3 routes outside `/api` and `/_agent-native` (exact route-table matches only, e.g. analytics `POST /track` ingest). Previously only `/api` and `/_agent-native` subtrees were stripped, so mounted deployments 404'd bare-registered routes like `/<app>/track` even after the auth guard passed. Page paths keep their full pathname for the static-shell fallback.
|
|
14
|
+
|
|
3
15
|
## 0.92.34
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/corpus/core/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.92.
|
|
3
|
+
"version": "0.92.36",
|
|
4
4
|
"description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
|
|
5
5
|
"homepage": "https://github.com/studio-jami/jami-studio#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -882,6 +882,29 @@ export function generateWorkerEntry(
|
|
|
882
882
|
const routeImports: string[] = [];
|
|
883
883
|
const routeRegistrations: string[] = [];
|
|
884
884
|
|
|
885
|
+
// Custom h3 routes outside /api and /_agent-native need the mount prefix
|
|
886
|
+
// stripped on mounted deployments (exact route-table matches only). Build
|
|
887
|
+
// regex matchers from the discovered route patterns at generation time.
|
|
888
|
+
const mountedCustomRouteMatchers = routes
|
|
889
|
+
.filter(
|
|
890
|
+
(r) =>
|
|
891
|
+
!r.route.startsWith("/api/") &&
|
|
892
|
+
r.route !== "/api" &&
|
|
893
|
+
!r.route.startsWith("/_agent-native"),
|
|
894
|
+
)
|
|
895
|
+
.map((r) => {
|
|
896
|
+
const pattern = r.route
|
|
897
|
+
.split("/")
|
|
898
|
+
.map((segment) => {
|
|
899
|
+
if (segment === "**" || segment.startsWith("**:")) return ".*";
|
|
900
|
+
if (segment.startsWith(":")) return "[^/]+";
|
|
901
|
+
return segment.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
902
|
+
})
|
|
903
|
+
.join("/");
|
|
904
|
+
return `[${JSON.stringify(r.method.toUpperCase())}, new RegExp(${JSON.stringify(`^${pattern}$`)})]`;
|
|
905
|
+
});
|
|
906
|
+
const mountedCustomRouteMatchersSource = `[${mountedCustomRouteMatchers.join(", ")}]`;
|
|
907
|
+
|
|
885
908
|
for (let i = 0; i < routes.length; i++) {
|
|
886
909
|
const r = routes[i];
|
|
887
910
|
const varName = `route_${i}`;
|
|
@@ -1058,6 +1081,22 @@ function isFrameworkPath(pathname) {
|
|
|
1058
1081
|
);
|
|
1059
1082
|
}
|
|
1060
1083
|
|
|
1084
|
+
// Registered custom h3 routes OUTSIDE /api and /_agent-native (e.g. an
|
|
1085
|
+
// analytics /track ingest route). On a mounted deployment these arrive as
|
|
1086
|
+
// /<app>/track; the h3 app registered them bare, so the mount prefix must be
|
|
1087
|
+
// stripped for them too — but ONLY for exact route-table matches, so page
|
|
1088
|
+
// paths keep their full pathname for the React Router shell fallback.
|
|
1089
|
+
const MOUNTED_CUSTOM_ROUTE_MATCHERS = ${mountedCustomRouteMatchersSource};
|
|
1090
|
+
|
|
1091
|
+
function matchesMountedCustomRoute(method, pathname) {
|
|
1092
|
+
const m = method === "HEAD" ? "GET" : method;
|
|
1093
|
+
for (const [routeMethod, pattern] of MOUNTED_CUSTOM_ROUTE_MATCHERS) {
|
|
1094
|
+
if (routeMethod !== m) continue;
|
|
1095
|
+
if (pattern.test(pathname)) return true;
|
|
1096
|
+
}
|
|
1097
|
+
return false;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1061
1100
|
function requestWithMountedApiPrefixStripped(request) {
|
|
1062
1101
|
const basePath = getAppBasePath();
|
|
1063
1102
|
if (!basePath) return request;
|
|
@@ -1066,7 +1105,11 @@ function requestWithMountedApiPrefixStripped(request) {
|
|
|
1066
1105
|
if (strippedPathname === url.pathname) {
|
|
1067
1106
|
return request;
|
|
1068
1107
|
}
|
|
1069
|
-
if (
|
|
1108
|
+
if (
|
|
1109
|
+
!isApiPath(strippedPathname) &&
|
|
1110
|
+
!isFrameworkPath(strippedPathname) &&
|
|
1111
|
+
!matchesMountedCustomRoute(request.method, strippedPathname)
|
|
1112
|
+
) {
|
|
1070
1113
|
return request;
|
|
1071
1114
|
}
|
|
1072
1115
|
url.pathname = strippedPathname;
|
|
@@ -88,15 +88,41 @@ export interface DiscoveredRoute {
|
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* Discover all API routes in a project's server/routes/ directory.
|
|
91
|
+
*
|
|
92
|
+
* Scans the `/api` and `/_agent-native` subtrees plus TOP-LEVEL route files
|
|
93
|
+
* (e.g. analytics `track.post.ts` → `POST /track`, an ingest endpoint that
|
|
94
|
+
* deliberately lives outside `/api`). Top-level catch-alls (`[...page].get.ts`
|
|
95
|
+
* — the SSR page fallback every template ships) are excluded: on serverless
|
|
96
|
+
* workers pages are served by the static app shell, and mounting the
|
|
97
|
+
* catch-all would shadow it.
|
|
91
98
|
*/
|
|
92
99
|
export async function discoverApiRoutes(
|
|
93
100
|
cwd: string,
|
|
94
101
|
): Promise<DiscoveredRoute[]> {
|
|
102
|
+
const fs = await getFs();
|
|
103
|
+
const routesDir = path.join(cwd, "server/routes");
|
|
95
104
|
const apiDir = path.join(cwd, "server/routes/api");
|
|
96
105
|
const agentNativeDir = path.join(cwd, "server/routes/_agent-native");
|
|
106
|
+
const topLevelFiles: string[] = [];
|
|
107
|
+
try {
|
|
108
|
+
if (fs.existsSync(routesDir)) {
|
|
109
|
+
for (const entry of fs.readdirSync(routesDir, { withFileTypes: true })) {
|
|
110
|
+
if (entry.isDirectory()) continue;
|
|
111
|
+
if (!entry.name.endsWith(".ts") && !entry.name.endsWith(".js")) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
// Skip page catch-alls — the static shell owns page serving.
|
|
115
|
+
if (entry.name.startsWith("[...")) continue;
|
|
116
|
+
topLevelFiles.push(entry.name);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} catch {
|
|
120
|
+
// Edge runtime — no filesystem.
|
|
121
|
+
}
|
|
97
122
|
const routeFiles = [
|
|
98
123
|
...(await discoverFiles(apiDir, "api")),
|
|
99
124
|
...(await discoverFiles(agentNativeDir, "_agent-native")),
|
|
125
|
+
...topLevelFiles,
|
|
100
126
|
];
|
|
101
127
|
const routes: DiscoveredRoute[] = [];
|
|
102
128
|
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* Body: { json: any, fieldName?: string, type?: "map"|"array", requestSource?: string }
|
|
14
14
|
*/
|
|
15
15
|
export declare const postCollabJson: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
16
|
-
ok?: undefined;
|
|
17
16
|
error: string;
|
|
17
|
+
ok?: undefined;
|
|
18
18
|
} | {
|
|
19
19
|
error?: undefined;
|
|
20
20
|
ok: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/deploy/build.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG;AAmCH,OAAO,EAML,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,6BAA6B,UAiBzC,CAAC;AAEF,eAAO,MAAM,mCAAmC,UAiB/C,CAAC;AACF,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAuIjE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,UAUnC,CAAC;AAEF,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAaxB;AAoCD,eAAO,MAAM,2CAA2C,EAAE,MAAM,CAC9D,MAAM,EACN,MAAM,CAmSP,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,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,CAqDN;AA6ID;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,gBAAgB,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,UAAU,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,eAAe,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAkBD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iCAAiC,YAAI,KAAK,CAAU,CAAC;AAElE;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,GACnB,IAAI,GAAG,SAAS,MAAM,EAAE,CAK1B"}
|
package/dist/deploy/build.js
CHANGED
|
@@ -711,6 +711,27 @@ export function generateWorkerEntry(routes, pluginPaths, defaultPluginStems = []
|
|
|
711
711
|
const appScopeId = options.appScopeId ?? null;
|
|
712
712
|
const routeImports = [];
|
|
713
713
|
const routeRegistrations = [];
|
|
714
|
+
// Custom h3 routes outside /api and /_agent-native need the mount prefix
|
|
715
|
+
// stripped on mounted deployments (exact route-table matches only). Build
|
|
716
|
+
// regex matchers from the discovered route patterns at generation time.
|
|
717
|
+
const mountedCustomRouteMatchers = routes
|
|
718
|
+
.filter((r) => !r.route.startsWith("/api/") &&
|
|
719
|
+
r.route !== "/api" &&
|
|
720
|
+
!r.route.startsWith("/_agent-native"))
|
|
721
|
+
.map((r) => {
|
|
722
|
+
const pattern = r.route
|
|
723
|
+
.split("/")
|
|
724
|
+
.map((segment) => {
|
|
725
|
+
if (segment === "**" || segment.startsWith("**:"))
|
|
726
|
+
return ".*";
|
|
727
|
+
if (segment.startsWith(":"))
|
|
728
|
+
return "[^/]+";
|
|
729
|
+
return segment.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
730
|
+
})
|
|
731
|
+
.join("/");
|
|
732
|
+
return `[${JSON.stringify(r.method.toUpperCase())}, new RegExp(${JSON.stringify(`^${pattern}$`)})]`;
|
|
733
|
+
});
|
|
734
|
+
const mountedCustomRouteMatchersSource = `[${mountedCustomRouteMatchers.join(", ")}]`;
|
|
714
735
|
for (let i = 0; i < routes.length; i++) {
|
|
715
736
|
const r = routes[i];
|
|
716
737
|
const varName = `route_${i}`;
|
|
@@ -863,6 +884,22 @@ function isFrameworkPath(pathname) {
|
|
|
863
884
|
);
|
|
864
885
|
}
|
|
865
886
|
|
|
887
|
+
// Registered custom h3 routes OUTSIDE /api and /_agent-native (e.g. an
|
|
888
|
+
// analytics /track ingest route). On a mounted deployment these arrive as
|
|
889
|
+
// /<app>/track; the h3 app registered them bare, so the mount prefix must be
|
|
890
|
+
// stripped for them too — but ONLY for exact route-table matches, so page
|
|
891
|
+
// paths keep their full pathname for the React Router shell fallback.
|
|
892
|
+
const MOUNTED_CUSTOM_ROUTE_MATCHERS = ${mountedCustomRouteMatchersSource};
|
|
893
|
+
|
|
894
|
+
function matchesMountedCustomRoute(method, pathname) {
|
|
895
|
+
const m = method === "HEAD" ? "GET" : method;
|
|
896
|
+
for (const [routeMethod, pattern] of MOUNTED_CUSTOM_ROUTE_MATCHERS) {
|
|
897
|
+
if (routeMethod !== m) continue;
|
|
898
|
+
if (pattern.test(pathname)) return true;
|
|
899
|
+
}
|
|
900
|
+
return false;
|
|
901
|
+
}
|
|
902
|
+
|
|
866
903
|
function requestWithMountedApiPrefixStripped(request) {
|
|
867
904
|
const basePath = getAppBasePath();
|
|
868
905
|
if (!basePath) return request;
|
|
@@ -871,7 +908,11 @@ function requestWithMountedApiPrefixStripped(request) {
|
|
|
871
908
|
if (strippedPathname === url.pathname) {
|
|
872
909
|
return request;
|
|
873
910
|
}
|
|
874
|
-
if (
|
|
911
|
+
if (
|
|
912
|
+
!isApiPath(strippedPathname) &&
|
|
913
|
+
!isFrameworkPath(strippedPathname) &&
|
|
914
|
+
!matchesMountedCustomRoute(request.method, strippedPathname)
|
|
915
|
+
) {
|
|
875
916
|
return request;
|
|
876
917
|
}
|
|
877
918
|
url.pathname = strippedPathname;
|