@mosetta/build 0.0.21 → 0.0.24

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/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @mosetta/build
2
2
 
3
+ ## 0.0.24
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [ba3d567]
8
+ - @mosetta/server@0.0.24
9
+ - @mosetta/router@0.0.24
10
+ - @mosetta/runtime@0.0.24
11
+ - @mosetta/server-action@0.0.24
12
+ - @mosetta/tar@0.0.24
13
+
14
+ ## 0.0.23
15
+
16
+ ### Patch Changes
17
+
18
+ - d5114f4: An assistant's connector is an ordinary handler, and an address has settings like a block.
19
+
20
+ - `@mosetta/server-action`: `@mosetta/server-action/mcp` — `serveMcp` (the protocol from a handler) and `siteActionTools` (a server whose tools are the site's actions, each called with an ordinary request carrying the caller's own key); a handler declares the settings of its addresses (`settings` beside its description).
21
+ - `@mosetta/build`: what a server module offers (its tools, its handlers with their settings) is written into its private descriptor at build.
22
+ - `@mosetta/server`: the site lists what its modules offer for anybody (`GET /api/server-action/`), from the catalog; the runner no longer speaks MCP itself and no longer asks modules on the fly; actions and handlers fetch their own site through the zone's front door.
23
+ - `@mosetta/content`: an address is a handler of its root's server module, its root's settings the address's.
24
+ - `@mosetta/cloudflare`: the site's own OAuth key reaches its code (a handler calls the site's actions with it); the platform's token still does not.
25
+ - `@mosetta/react`: an editor side may give `Endpoint` beside `Component` — the form of an address's settings, mounted with `placement: 'endpoint'` (`useEditorEndpoint` names the handler).
26
+
27
+ - Updated dependencies [d5114f4]
28
+ - @mosetta/server-action@0.0.23
29
+ - @mosetta/server@0.0.23
30
+ - @mosetta/router@0.0.23
31
+ - @mosetta/runtime@0.0.23
32
+ - @mosetta/tar@0.0.23
33
+
34
+ ## 0.0.22
35
+
36
+ ### Patch Changes
37
+
38
+ - Updated dependencies [7e99e44]
39
+ - @mosetta/server-action@0.0.22
40
+ - @mosetta/server@0.0.22
41
+ - @mosetta/router@0.0.22
42
+ - @mosetta/runtime@0.0.22
43
+ - @mosetta/tar@0.0.22
44
+
3
45
  ## 0.0.21
4
46
 
5
47
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mosetta/build",
3
- "version": "0.0.21",
3
+ "version": "0.0.24",
4
4
  "license": "MIT",
5
5
  "description": "The core of the tile forge: builds a tile palette — its tile side artifacts, their dependency closure, the tile host descriptor. Environment-agnostic — the file system and the bundling engine are supplied from outside.",
6
6
  "type": "module",
@@ -27,11 +27,11 @@
27
27
  "scheduler": "*",
28
28
  "systemjs": "^6.15.1",
29
29
  "yaml": "^2.9.0",
30
- "@mosetta/router": "0.0.21",
31
- "@mosetta/runtime": "0.0.21",
32
- "@mosetta/server": "0.0.21",
33
- "@mosetta/tar": "0.0.21",
34
- "@mosetta/server-action": "0.0.21"
30
+ "@mosetta/router": "0.0.24",
31
+ "@mosetta/runtime": "0.0.24",
32
+ "@mosetta/tar": "0.0.24",
33
+ "@mosetta/server": "0.0.24",
34
+ "@mosetta/server-action": "0.0.24"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"
package/src/build.mjs CHANGED
@@ -68,6 +68,28 @@ class OutputFS {
68
68
  * own): a library root whose distribution is there and a published package that is there are not
69
69
  * built again. Absent — everything is built, as a local build does.
70
70
  */
71
+ /**
72
+ * What a built server module offers, asked of it the way the runner would (`x-mosetta-describe`):
73
+ * its actions that offer themselves as tools and its handlers — or null when it says nothing (built
74
+ * with a framework before modules could say) or cannot be run here. Only what is offered is kept: an
75
+ * action that offers nothing is nobody's business but its blocks'.
76
+ */
77
+ async function offersOf(jsCode, evaluate) {
78
+ try {
79
+ const module = await evaluate(jsCode);
80
+ const fetchOf = module?.default?.fetch;
81
+ if (typeof fetchOf !== 'function') return null;
82
+ const res = await fetchOf(new Request('https://build.invalid/api/server-action/describe/describe', { method: 'POST', headers: { 'x-mosetta-describe': '1' } }));
83
+ if (!res.ok) return null;
84
+ const said = await res.json();
85
+ if (!Array.isArray(said?.actions) || !Array.isArray(said?.handlers)) return null;
86
+ const tools = said.actions.filter((a) => typeof a?.tool === 'string');
87
+ return tools.length || said.handlers.length ? { actions: tools, handlers: said.handlers } : null;
88
+ } catch {
89
+ return null;
90
+ }
91
+ }
92
+
71
93
  export async function build(root, { mode = 'development', log, fileSystem, resolver, engine, frameworkDir, buildConfig = INERT_BUILD_CONFIG, cache = null, evaluate = null, released = null }) {
72
94
  const out = new OutputFS();
73
95
  const watchFiles = new Set();
@@ -406,8 +428,13 @@ export async function build(root, { mode = 'development', log, fileSystem, resol
406
428
  let serverCount = 0;
407
429
  for (const sm of serverMods) {
408
430
  try {
409
- const s = await memo(`server:${fullTileName(sm)}`,
410
- () => buildServerModule(fileSystem, sm, { resolver, mode, buildConfig, engine, sourceBase: root, frameworkDir }));
431
+ // what the module OFFERS — its actions that offer themselves as tools, its handlers, their
432
+ // input and settings as JSON Schema — asked of the built module itself, kept with the build
433
+ // (and rebuilt with it): the site lists it from the descriptor without running the module
434
+ const s = await memo(`server:${fullTileName(sm)}`, async () => {
435
+ const built = await buildServerModule(fileSystem, sm, { resolver, mode, buildConfig, engine, sourceBase: root, frameworkDir });
436
+ return { ...built, offers: evaluate ? await offersOf(built.jsCode, evaluate) : null };
437
+ });
411
438
  addWatch(s.watchFiles);
412
439
  writeJs(`private/modules/${s.full}/${s.full}.js`, s.jsCode, s.map);
413
440
  // the facet's wasm imports travel as assets next to the monolith: the runner will declare
@@ -416,7 +443,7 @@ export async function build(root, { mode = 'development', log, fileSystem, resol
416
443
  out.set(`private/modules/${s.full}/${assetName}`, fileSystem.readFile(srcFile));
417
444
  }
418
445
  recordPrivate(s.full, { namespace: sm.namespace, name: sm.name, type: 'server', version: sm.version },
419
- {}, [...s.wasmAssets.keys()]);
446
+ s.offers ? { offers: s.offers } : {}, [...s.wasmAssets.keys()]);
420
447
  record(sm, 'server', s.jsCode.length, 'private'
421
448
  + (s.wasmAssets.size ? `, ${s.wasmAssets.size} wasm asset(s)` : ''));
422
449
  serverCount++;