@fulmenhq/tsfulmen 0.2.2 → 0.2.4

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/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { APP_IDENTITY_DIR, APP_IDENTITY_ENV_VAR, APP_IDENTITY_FILENAME, APP_IDENTITY_SCHEMA_ID, AppIdentity, AppIdentityError, ConfigIdentifiers, Identity, IdentityMetadata, LoadIdentityOptions, MAX_ANCESTOR_SEARCH_DEPTH, PythonMetadata, RepositoryCategory, buildEnvVar, clearEmbeddedIdentity, clearIdentityCache, getBinaryName, getCachedIdentity, getConfigIdentifiers, getConfigName, getEmbeddedIdentity, getEnvPrefix, getEnvVar, getTelemetryNamespace, getVendor, hasEmbeddedIdentity, loadIdentity, registerEmbeddedIdentity } from './appidentity/index.js';
1
+ export { APP_IDENTITY_DIR, APP_IDENTITY_ENV_VAR, APP_IDENTITY_FILENAME, APP_IDENTITY_SCHEMA_ID, AppIdentityError, BuildRuntimeInfoOptions, ConfigIdentifiers, MAX_ANCESTOR_SEARCH_DEPTH, RuntimeInfo, RuntimeName, buildEnvVar, buildRuntimeInfo, clearEmbeddedIdentity, clearIdentityCache, getBinaryName, getCachedIdentity, getConfigIdentifiers, getConfigName, getEmbeddedIdentity, getEnvPrefix, getEnvVar, getTelemetryNamespace, getVendor, hasEmbeddedIdentity, loadIdentity, registerEmbeddedIdentity } from './appidentity/index.js';
2
+ export { A as AppIdentity, I as Identity, a as IdentityMetadata, L as LoadIdentityOptions, P as PythonMetadata, R as RepositoryCategory } from './types-Dv5TERCM.js';
2
3
  export { DocScribeError, DocScribeFormat, DocScribeFrontmatterResult, DocScribeHeader, DocScribeInfo, DocScribeMetadata, DocScribeMetadataValue, DocScribeOptions, DocScribeParseError, DocScribePrimitiveValue, DocScribeSplit, DocScribeUnsupportedFormatError, NormalizedInput, __internal, detectFormat, extractHeaders, extractMetadata, inspectDocument, normalizeInput, parseFrontmatter, splitDocuments, stripFrontmatter } from './docscribe/index.js';
3
4
  export { ERROR_CODES, FULPACK_VERSION, FulpackOperationError, checkDecompressionBomb, create, createFulpackError, extract, hasPathTraversal, info, isAbsolutePath, scan, validatePath, verify } from './fulpack/index.js';
4
5
  export { ArchiveEntry, ArchiveFormat, ArchiveInfo, ArchiveManifest, CreateOptions, EntryType, ExtractOptions, ExtractResult, FulpackError, Operation, ScanOptions, ValidationResult } from './crucible/fulpack/index.js';
@@ -11,6 +12,6 @@ import './types-DdoeE7F5.js';
11
12
  * Provides ergonomic access to Crucible SSOT assets and core utilities
12
13
  * for TypeScript/Node.js applications in the FulmenHQ ecosystem.
13
14
  */
14
- declare const VERSION = "0.2.2";
15
+ declare const VERSION = "0.2.4";
15
16
 
16
17
  export { VERSION };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import addFormats from 'ajv-formats';
1
2
  import { spawn } from 'child_process';
2
3
  import { readFile, writeFile, access, mkdir } from 'fs/promises';
3
4
  import { parse, stringify, parseDocument } from 'yaml';
@@ -8,7 +9,6 @@ import Ajv from 'ajv';
8
9
  import Ajv2019 from 'ajv/dist/2019';
9
10
  import Ajv2020 from 'ajv/dist/2020';
10
11
  import AjvDraft04 from 'ajv-draft-04';
11
- import addFormats from 'ajv-formats';
12
12
  import { pipeline, Readable } from 'stream';
13
13
  import picomatch from 'picomatch';
14
14
  import { suggest as suggest$1, substringSimilarity, score as score$1, normalize as normalize$1, jaro_winkler, damerau_levenshtein, osa_distance, levenshtein } from '@3leaps/string-metrics-wasm';
@@ -45,6 +45,27 @@ var init_constants = __esm({
45
45
  MAX_ANCESTOR_SEARCH_DEPTH = 20;
46
46
  }
47
47
  });
48
+ function applyFulmenAjvFormats(ajv, options = {}) {
49
+ const mode = options.mode ?? "fast";
50
+ const formats = options.formats ?? DEFAULT_FORMATS;
51
+ addFormats(ajv, { mode, formats });
52
+ return ajv;
53
+ }
54
+ var DEFAULT_FORMATS;
55
+ var init_ajv_formats = __esm({
56
+ "src/schema/ajv-formats.ts"() {
57
+ DEFAULT_FORMATS = [
58
+ "date-time",
59
+ "email",
60
+ "hostname",
61
+ "ipv4",
62
+ "ipv6",
63
+ "uri",
64
+ "uri-reference",
65
+ "uuid"
66
+ ];
67
+ }
68
+ });
48
69
 
49
70
  // src/schema/errors.ts
50
71
  var errors_exports = {};
@@ -1600,10 +1621,7 @@ function createAjv(dialect) {
1600
1621
  // Enable async schema loading for YAML references
1601
1622
  loadSchema: loadReferencedSchema
1602
1623
  });
1603
- addFormats(ajv, {
1604
- mode: "fast",
1605
- formats: ["date-time", "email", "hostname", "ipv4", "ipv6", "uri", "uri-reference"]
1606
- });
1624
+ applyFulmenAjvFormats(ajv);
1607
1625
  return ajv;
1608
1626
  }
1609
1627
  async function getAjv(dialect) {
@@ -1849,6 +1867,7 @@ var ajvInstances, metaschemaReady, schemaCache;
1849
1867
  var init_validator = __esm({
1850
1868
  "src/schema/validator.ts"() {
1851
1869
  init_telemetry();
1870
+ init_ajv_formats();
1852
1871
  init_errors();
1853
1872
  init_registry();
1854
1873
  init_utils();
@@ -3808,6 +3827,224 @@ var init_capabilities2 = __esm({
3808
3827
  }
3809
3828
  });
3810
3829
 
3830
+ // src/foundry/signals/config-reload-endpoint.ts
3831
+ function createConfigReloadEndpoint(options) {
3832
+ const { loader, validator, onReload: onReload2, auth, rateLimit, logger, telemetry } = options;
3833
+ return async (payload, req) => {
3834
+ const correlationId = payload.correlation_id ?? generateCorrelationId();
3835
+ const authResult = await auth(req);
3836
+ if (!authResult.authenticated) {
3837
+ if (logger) {
3838
+ logger.warn("Config reload endpoint: authentication failed", {
3839
+ correlation_id: correlationId,
3840
+ reason: authResult.reason
3841
+ });
3842
+ }
3843
+ if (telemetry) {
3844
+ telemetry.emit("fulmen.config.http_endpoint.auth_failed", {
3845
+ correlation_id: correlationId
3846
+ });
3847
+ }
3848
+ return {
3849
+ status: "error",
3850
+ error: "authentication_failed",
3851
+ message: authResult.reason || "Authentication required",
3852
+ statusCode: 401
3853
+ };
3854
+ }
3855
+ const identity = authResult.identity || "unknown";
3856
+ if (rateLimit) {
3857
+ const rateLimitResult = await rateLimit(identity);
3858
+ if (!rateLimitResult.allowed) {
3859
+ if (logger) {
3860
+ logger.warn("Config reload endpoint: rate limit exceeded", {
3861
+ correlation_id: correlationId,
3862
+ identity
3863
+ });
3864
+ }
3865
+ if (telemetry) {
3866
+ telemetry.emit("fulmen.config.http_endpoint.rate_limited", {
3867
+ correlation_id: correlationId
3868
+ });
3869
+ }
3870
+ return {
3871
+ status: "error",
3872
+ error: "rate_limit_exceeded",
3873
+ message: "Rate limit exceeded. Please try again later.",
3874
+ statusCode: 429
3875
+ };
3876
+ }
3877
+ }
3878
+ if (telemetry) {
3879
+ telemetry.emit("fulmen.config.http_endpoint.reload_requested", {
3880
+ correlation_id: correlationId
3881
+ });
3882
+ }
3883
+ try {
3884
+ const config = await loader();
3885
+ if (validator) {
3886
+ const validation = await validator(config);
3887
+ if (!validation.valid) {
3888
+ if (logger) {
3889
+ logger.warn("Config reload endpoint: validation failed", {
3890
+ correlation_id: correlationId,
3891
+ error_count: validation.errors?.length ?? 0
3892
+ });
3893
+ }
3894
+ if (telemetry) {
3895
+ telemetry.emit("fulmen.config.http_endpoint.reload_rejected", {
3896
+ correlation_id: correlationId,
3897
+ reason: "validation_failed"
3898
+ });
3899
+ }
3900
+ return {
3901
+ status: "error",
3902
+ error: "validation_failed",
3903
+ message: "Configuration validation failed",
3904
+ validation_errors: validation.errors,
3905
+ statusCode: 422
3906
+ };
3907
+ }
3908
+ }
3909
+ if (onReload2) {
3910
+ await onReload2(config);
3911
+ }
3912
+ if (telemetry) {
3913
+ telemetry.emit("fulmen.config.http_endpoint.reload_accepted", {
3914
+ correlation_id: correlationId
3915
+ });
3916
+ }
3917
+ if (logger) {
3918
+ logger.info("Config reload endpoint: reload accepted", {
3919
+ correlation_id: correlationId,
3920
+ reason: payload.reason
3921
+ });
3922
+ }
3923
+ return {
3924
+ status: "reloaded",
3925
+ correlation_id: correlationId,
3926
+ message: "Configuration reloaded",
3927
+ statusCode: 200
3928
+ };
3929
+ } catch (error) {
3930
+ if (logger) {
3931
+ logger.warn("Config reload endpoint: reload failed", {
3932
+ correlation_id: correlationId,
3933
+ error: error instanceof Error ? error.message : String(error)
3934
+ });
3935
+ }
3936
+ if (telemetry) {
3937
+ telemetry.emit("fulmen.config.http_endpoint.reload_error", {
3938
+ correlation_id: correlationId,
3939
+ error_type: error instanceof Error ? error.constructor.name : "unknown"
3940
+ });
3941
+ }
3942
+ return {
3943
+ status: "error",
3944
+ error: "reload_failed",
3945
+ message: error instanceof Error ? error.message : String(error),
3946
+ statusCode: 500
3947
+ };
3948
+ }
3949
+ };
3950
+ }
3951
+ function generateCorrelationId() {
3952
+ return `cfg-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
3953
+ }
3954
+ var init_config_reload_endpoint = __esm({
3955
+ "src/foundry/signals/config-reload-endpoint.ts"() {
3956
+ }
3957
+ });
3958
+
3959
+ // src/appidentity/runtime.ts
3960
+ function detectRuntime() {
3961
+ const versions = process.versions;
3962
+ if (typeof versions.bun === "string" && versions.bun.length > 0) {
3963
+ return { name: "bun", version: versions.bun };
3964
+ }
3965
+ if (typeof versions.node === "string" && versions.node.length > 0) {
3966
+ return { name: "node", version: versions.node };
3967
+ }
3968
+ return { name: "unknown" };
3969
+ }
3970
+ function buildRuntimeInfo(options = {}) {
3971
+ const runtime = detectRuntime();
3972
+ const serviceName = options.serviceName ?? options.identity?.app.binary_name ?? "unknown-service";
3973
+ const vendor = options.vendor ?? options.identity?.app.vendor;
3974
+ return {
3975
+ service: {
3976
+ name: serviceName,
3977
+ vendor,
3978
+ version: options.version
3979
+ },
3980
+ runtime,
3981
+ platform: {
3982
+ os: process.platform,
3983
+ arch: process.arch
3984
+ }
3985
+ };
3986
+ }
3987
+ var init_runtime = __esm({
3988
+ "src/appidentity/runtime.ts"() {
3989
+ }
3990
+ });
3991
+
3992
+ // src/foundry/signals/control-discovery-endpoint.ts
3993
+ function createControlDiscoveryEndpoint(options) {
3994
+ const { identity, version, endpoints, auth, authSummary, logger, telemetry } = options;
3995
+ return async (req) => {
3996
+ if (auth) {
3997
+ const authResult = await auth(req);
3998
+ if (!authResult.authenticated) {
3999
+ if (logger) {
4000
+ logger.warn("Control discovery endpoint: authentication failed", {
4001
+ reason: authResult.reason
4002
+ });
4003
+ }
4004
+ if (telemetry) {
4005
+ telemetry.emit("fulmen.control.discovery.auth_failed", {
4006
+ service: identity.app.binary_name
4007
+ });
4008
+ }
4009
+ return {
4010
+ status: "error",
4011
+ error: "authentication_failed",
4012
+ message: authResult.reason || "Authentication required",
4013
+ statusCode: 401
4014
+ };
4015
+ }
4016
+ }
4017
+ if (telemetry) {
4018
+ telemetry.emit("fulmen.control.discovery.served", {
4019
+ service: identity.app.binary_name
4020
+ });
4021
+ }
4022
+ const runtime = buildRuntimeInfo({ identity, version });
4023
+ return {
4024
+ status: "ok",
4025
+ service: {
4026
+ name: identity.app.binary_name,
4027
+ vendor: identity.app.vendor,
4028
+ version
4029
+ },
4030
+ runtime: {
4031
+ name: runtime.runtime.name,
4032
+ version: runtime.runtime.version,
4033
+ platform: runtime.platform.os,
4034
+ arch: runtime.platform.arch
4035
+ },
4036
+ auth_summary: authSummary,
4037
+ endpoints,
4038
+ statusCode: 200
4039
+ };
4040
+ };
4041
+ }
4042
+ var init_control_discovery_endpoint = __esm({
4043
+ "src/foundry/signals/control-discovery-endpoint.ts"() {
4044
+ init_runtime();
4045
+ }
4046
+ });
4047
+
3811
4048
  // src/foundry/signals/convenience.ts
3812
4049
  async function onShutdown(manager, handler, options = {}) {
3813
4050
  await manager.register("SIGTERM", handler, options);
@@ -4067,7 +4304,7 @@ var init_guards = __esm({
4067
4304
  function createSignalEndpoint(options) {
4068
4305
  const { manager, auth, rateLimit, logger, telemetry, allowedSignals } = options;
4069
4306
  return async (payload, req) => {
4070
- const correlationId = payload.correlation_id ?? generateCorrelationId();
4307
+ const correlationId = payload.correlation_id ?? generateCorrelationId2();
4071
4308
  const authResult = await auth(req);
4072
4309
  if (!authResult.authenticated) {
4073
4310
  if (logger) {
@@ -4190,7 +4427,7 @@ function normalizeSignalName(signal) {
4190
4427
  }
4191
4428
  return `SIG${upper}`;
4192
4429
  }
4193
- function generateCorrelationId() {
4430
+ function generateCorrelationId2() {
4194
4431
  return `sig-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
4195
4432
  }
4196
4433
  function createBearerTokenAuth(expectedToken) {
@@ -4657,6 +4894,8 @@ var init_signals = __esm({
4657
4894
  "src/foundry/signals/index.ts"() {
4658
4895
  init_capabilities2();
4659
4896
  init_catalog();
4897
+ init_config_reload_endpoint();
4898
+ init_control_discovery_endpoint();
4660
4899
  init_convenience();
4661
4900
  init_double_tap();
4662
4901
  init_guards();
@@ -4802,7 +5041,9 @@ __export(foundry_exports, {
4802
5041
  clearMimeTypeCache: () => clearMimeTypeCache,
4803
5042
  clearPatternCache: () => clearPatternCache,
4804
5043
  createBearerTokenAuth: () => createBearerTokenAuth,
5044
+ createConfigReloadEndpoint: () => createConfigReloadEndpoint,
4805
5045
  createConfigReloadHandler: () => createConfigReloadHandler,
5046
+ createControlDiscoveryEndpoint: () => createControlDiscoveryEndpoint,
4806
5047
  createDoubleTapTracker: () => createDoubleTapTracker,
4807
5048
  createSignalEndpoint: () => createSignalEndpoint,
4808
5049
  createSignalManager: () => createSignalManager,
@@ -5834,6 +6075,7 @@ var init_cli = __esm({
5834
6075
  // src/schema/index.ts
5835
6076
  var init_schema = __esm({
5836
6077
  "src/schema/index.ts"() {
6078
+ init_ajv_formats();
5837
6079
  init_cli();
5838
6080
  init_errors();
5839
6081
  init_export();
@@ -5950,6 +6192,7 @@ async function getEnvVar(key, options) {
5950
6192
 
5951
6193
  // src/appidentity/index.ts
5952
6194
  init_loader2();
6195
+ init_runtime();
5953
6196
 
5954
6197
  // src/docscribe/normalize.ts
5955
6198
  var decoder = new TextDecoder("utf-8", { fatal: false, ignoreBOM: true });
@@ -8116,8 +8359,8 @@ async function scanZip(archive, options) {
8116
8359
  var FULPACK_VERSION = "1.0.0";
8117
8360
 
8118
8361
  // src/index.ts
8119
- var VERSION2 = "0.2.2";
8362
+ var VERSION2 = "0.2.4";
8120
8363
 
8121
- export { APP_IDENTITY_DIR, APP_IDENTITY_ENV_VAR, APP_IDENTITY_FILENAME, APP_IDENTITY_SCHEMA_ID, AppIdentityError, ArchiveFormat, DocScribeError, DocScribeParseError, DocScribeUnsupportedFormatError, ERROR_CODES, EntryType, FULPACK_VERSION, FulpackOperationError, MAX_ANCESTOR_SEARCH_DEPTH, Operation, VERSION2 as VERSION, __internal, buildEnvVar, checkDecompressionBomb, clearEmbeddedIdentity, clearIdentityCache, create, createFulpackError, detectFormat2 as detectFormat, extract, extractHeaders, extractMetadata, getBinaryName, getCachedIdentity, getConfigIdentifiers, getConfigName, getEmbeddedIdentity, getEnvPrefix, getEnvVar, getTelemetryNamespace, getVendor, hasEmbeddedIdentity, hasPathTraversal, info, inspectDocument, isAbsolutePath, loadIdentity, normalizeInput, parseFrontmatter, registerEmbeddedIdentity, scan, splitDocuments, stripFrontmatter, validatePath, verify };
8364
+ export { APP_IDENTITY_DIR, APP_IDENTITY_ENV_VAR, APP_IDENTITY_FILENAME, APP_IDENTITY_SCHEMA_ID, AppIdentityError, ArchiveFormat, DocScribeError, DocScribeParseError, DocScribeUnsupportedFormatError, ERROR_CODES, EntryType, FULPACK_VERSION, FulpackOperationError, MAX_ANCESTOR_SEARCH_DEPTH, Operation, VERSION2 as VERSION, __internal, buildEnvVar, buildRuntimeInfo, checkDecompressionBomb, clearEmbeddedIdentity, clearIdentityCache, create, createFulpackError, detectFormat2 as detectFormat, extract, extractHeaders, extractMetadata, getBinaryName, getCachedIdentity, getConfigIdentifiers, getConfigName, getEmbeddedIdentity, getEnvPrefix, getEnvVar, getTelemetryNamespace, getVendor, hasEmbeddedIdentity, hasPathTraversal, info, inspectDocument, isAbsolutePath, loadIdentity, normalizeInput, parseFrontmatter, registerEmbeddedIdentity, scan, splitDocuments, stripFrontmatter, validatePath, verify };
8122
8365
  //# sourceMappingURL=index.js.map
8123
8366
  //# sourceMappingURL=index.js.map