@telorun/kernel 0.63.0 → 0.64.0

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 (73) hide show
  1. package/dist/boot-context-registry.js +1 -3
  2. package/dist/boot-context-registry.js.map +1 -1
  3. package/dist/bundle/module-artifact.js +15 -8
  4. package/dist/bundle/module-artifact.js.map +1 -1
  5. package/dist/controller-loader.js +4 -0
  6. package/dist/controller-loader.js.map +1 -1
  7. package/dist/controller-loaders/bundle-loader.js +1 -0
  8. package/dist/controller-loaders/bundle-loader.js.map +1 -1
  9. package/dist/controller-loaders/napi-loader.d.ts.map +1 -1
  10. package/dist/controller-loaders/napi-loader.js +24 -8
  11. package/dist/controller-loaders/napi-loader.js.map +1 -1
  12. package/dist/controller-loaders/npm-loader.js +37 -28
  13. package/dist/controller-loaders/npm-loader.js.map +1 -1
  14. package/dist/controller-registry.js +3 -5
  15. package/dist/controller-registry.js.map +1 -1
  16. package/dist/controllers/resource-definition/abstract-controller.js +2 -1
  17. package/dist/controllers/resource-definition/abstract-controller.js.map +1 -1
  18. package/dist/controllers/resource-definition/resource-definition-controller.js +2 -1
  19. package/dist/controllers/resource-definition/resource-definition-controller.js.map +1 -1
  20. package/dist/controllers/type/json-schema-controller.js +3 -0
  21. package/dist/controllers/type/json-schema-controller.js.map +1 -1
  22. package/dist/directory-lock.js +5 -5
  23. package/dist/directory-lock.js.map +1 -1
  24. package/dist/evaluation-context.js +60 -21
  25. package/dist/evaluation-context.js.map +1 -1
  26. package/dist/events.js +1 -3
  27. package/dist/events.js.map +1 -1
  28. package/dist/host-env.js +3 -2
  29. package/dist/host-env.js.map +1 -1
  30. package/dist/kernel.js +57 -26
  31. package/dist/kernel.js.map +1 -1
  32. package/dist/logging/console-sink.js +18 -29
  33. package/dist/logging/console-sink.js.map +1 -1
  34. package/dist/logging/debug-wire-sink.js +11 -23
  35. package/dist/logging/debug-wire-sink.js.map +1 -1
  36. package/dist/logging/drop-accounting.js +28 -41
  37. package/dist/logging/drop-accounting.js.map +1 -1
  38. package/dist/logging/file-sink.js +28 -38
  39. package/dist/logging/file-sink.js.map +1 -1
  40. package/dist/logging/kernel-logging.js +30 -41
  41. package/dist/logging/kernel-logging.js.map +1 -1
  42. package/dist/logging/logging-pipeline.js +197 -197
  43. package/dist/logging/logging-pipeline.js.map +1 -1
  44. package/dist/logging/sampler.js +21 -34
  45. package/dist/logging/sampler.js.map +1 -1
  46. package/dist/manifest-sources/local-manifest-cache-source.js +2 -0
  47. package/dist/manifest-sources/local-manifest-cache-source.js.map +1 -1
  48. package/dist/manifest-sources/memory-source.js +1 -3
  49. package/dist/manifest-sources/memory-source.js.map +1 -1
  50. package/dist/module-context.js +62 -37
  51. package/dist/module-context.js.map +1 -1
  52. package/dist/registry.js +5 -7
  53. package/dist/registry.js.map +1 -1
  54. package/dist/resource-context.js +30 -29
  55. package/dist/resource-context.js.map +1 -1
  56. package/dist/resource-uri.js +4 -0
  57. package/dist/resource-uri.js.map +1 -1
  58. package/dist/runtime-seam.js +42 -55
  59. package/dist/runtime-seam.js.map +1 -1
  60. package/dist/schema-validator.js +20 -18
  61. package/dist/schema-validator.js.map +1 -1
  62. package/dist/tracing.js +4 -19
  63. package/dist/tracing.js.map +1 -1
  64. package/dist/transports/oci/oci-client.js +3 -1
  65. package/dist/transports/oci/oci-client.js.map +1 -1
  66. package/dist/transports/oci/oci-transport.js +17 -16
  67. package/dist/transports/oci/oci-transport.js.map +1 -1
  68. package/dist/transports/registry-transport.js +4 -0
  69. package/dist/transports/registry-transport.js.map +1 -1
  70. package/dist/transports/transport-registry.js +1 -0
  71. package/dist/transports/transport-registry.js.map +1 -1
  72. package/package.json +3 -3
  73. package/src/controller-loaders/napi-loader.ts +28 -9
@@ -218,13 +218,26 @@ export class NapiControllerLoader {
218
218
  throw new ControllerEnvMissingError("rustc not found on PATH");
219
219
  }
220
220
 
221
+ // Read before building: the metadata answers both "where did the dylib
222
+ // land" and "does this crate use the SDK", and the second decides the build
223
+ // flags.
224
+ const { targetDir, libName, usesSdk } = await resolveCrateMetadata(cratePath, fallbackName);
225
+
221
226
  try {
222
- // Plain `cargo build --release` no `--features` flag. The SDK's
223
- // `default = ["napi"]` selects the napi backend transitively, so the
224
- // controller crate's Cargo.toml stays free of any `[features]` block
225
- // or napi-rs deps. A future Rust kernel passes
226
- // `--no-default-features --features native` here instead.
227
- await execFileAsync("cargo", ["build", "--release"], {
227
+ // The backend is selected as a *dependency* feature of the SDK. A crate
228
+ // built on `telorun-sdk` carries no `[features]` block of its own, so this
229
+ // is the only way to pick one from outside it: `--no-default-features`
230
+ // here would apply to the controller crate, not to the SDK, and the SDK
231
+ // therefore declares no default backend at all. The Rust kernel passes
232
+ // `--features telorun-sdk/native` at the same spot.
233
+ //
234
+ // Only when the crate actually depends on the SDK. `pkg:cargo` names a
235
+ // Rust controller, not an SDK user — a crate may implement the napi
236
+ // exports by hand (the `tests/napi-echo` fixture does exactly that, which
237
+ // is what makes it a test of this loader rather than of the SDK). Naming a
238
+ // feature of a dependency it does not have is a hard cargo error.
239
+ const featureArgs = usesSdk ? ["--features", "telorun-sdk/napi"] : [];
240
+ await execFileAsync("cargo", ["build", "--release", ...featureArgs], {
228
241
  cwd: cratePath,
229
242
  maxBuffer: 32 * 1024 * 1024,
230
243
  env: hostEnv(),
@@ -237,8 +250,6 @@ export class NapiControllerLoader {
237
250
  );
238
251
  }
239
252
 
240
- const { targetDir, libName } = await resolveCrateMetadata(cratePath, fallbackName);
241
-
242
253
  const dylibPath = await findDylib(targetDir, libName);
243
254
  if (!dylibPath) {
244
255
  throw new RuntimeError(
@@ -300,10 +311,14 @@ function project(module: any, entry: string | undefined, where: string): Control
300
311
  return sub;
301
312
  }
302
313
 
314
+ /** The SDK crate whose backend feature selects the FFI bridge, when the
315
+ * controller is built on it. */
316
+ const SDK_CRATE_NAME = "telorun-sdk";
317
+
303
318
  async function resolveCrateMetadata(
304
319
  cratePath: string,
305
320
  fallbackName: string,
306
- ): Promise<{ targetDir: string; libName: string }> {
321
+ ): Promise<{ targetDir: string; libName: string; usesSdk: boolean }> {
307
322
  const result = await execFileAsync("cargo", [
308
323
  "metadata",
309
324
  "--format-version",
@@ -317,9 +332,13 @@ async function resolveCrateMetadata(
317
332
  (p: any) => p.manifest_path === path.join(cratePath, "Cargo.toml"),
318
333
  );
319
334
  const packageName = cratePackage?.name ?? fallbackName;
335
+ const usesSdk = (cratePackage?.dependencies ?? []).some(
336
+ (dependency: any) => dependency?.name === SDK_CRATE_NAME,
337
+ );
320
338
  return {
321
339
  targetDir: metadata.target_directory,
322
340
  libName: packageName.replace(/-/g, "_"),
341
+ usesSdk,
323
342
  };
324
343
  }
325
344