@ultrst-armada/kloks 1.21.1 → 1.22.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 (68) hide show
  1. package/.krusbl-release-attestation.json +3 -3
  2. package/package.json +4 -4
  3. package/packages/audio-midi/dist/{audioClipEngine-BOT33JKI.js → audioClipEngine-E5ODQNYR.js} +3 -2
  4. package/packages/audio-midi/dist/{audioInputManager-BLDGGLAR.js → audioInputManager-OOH3TOJ6.js} +2 -1
  5. package/packages/audio-midi/dist/{chunk-N55BWOC6.js → chunk-2U7VIADS.js} +1 -1
  6. package/packages/audio-midi/dist/{chunk-3GRGELA4.js → chunk-3FXNT6PF.js} +2 -2
  7. package/packages/audio-midi/dist/chunk-QGM4M3NI.js +37 -0
  8. package/packages/audio-midi/dist/dist-XMSSRYDR.js +899 -0
  9. package/packages/audio-midi/dist/index.js +534 -75
  10. package/packages/audio-midi/dist/transformers.node-HWHOAE4H.js +43879 -0
  11. package/packages/audio-midi/package.json +1 -1
  12. package/packages/backend/dist/ai-inference/index.js +1 -0
  13. package/packages/backend/dist/ai-keys/index.js +1 -0
  14. package/packages/backend/dist/ai-models/index.js +1 -0
  15. package/packages/backend/dist/ai-provider/index.js +1 -0
  16. package/packages/backend/dist/ai-routing/index.js +1 -0
  17. package/packages/backend/dist/ai-tools/index.js +1 -0
  18. package/packages/backend/dist/api/index.js +1 -0
  19. package/packages/backend/dist/auth/index.js +1 -0
  20. package/packages/backend/dist/{chunk-RBF2OGMC.js → chunk-B3VJ4HDV.js} +4 -15
  21. package/packages/backend/dist/{chunk-OYVHKYJW.js → chunk-IJ5QNZCY.js} +1 -1
  22. package/packages/backend/dist/chunk-MWSYNRNZ.js +871 -0
  23. package/packages/backend/dist/{chunk-LCRK2QSY.js → chunk-NB2X3HEX.js} +13 -1
  24. package/packages/backend/dist/{chunk-KPLQLZHB.js → chunk-OB65KZ2M.js} +1 -1
  25. package/packages/backend/dist/chunk-QGM4M3NI.js +37 -0
  26. package/packages/backend/dist/client/index.js +1 -0
  27. package/packages/backend/dist/connectivity/index.js +1 -0
  28. package/packages/backend/dist/control-plane/index.js +1 -0
  29. package/packages/backend/dist/development/index.js +3 -2
  30. package/packages/backend/dist/dist-XMSSRYDR.js +899 -0
  31. package/packages/backend/dist/index.js +14 -13
  32. package/packages/backend/dist/krnl-ai-services.js +3 -2
  33. package/packages/backend/dist/krnl-services.d.ts +8 -0
  34. package/packages/backend/dist/krnl-services.js +3 -2
  35. package/packages/backend/dist/services/index.d.ts +2 -3
  36. package/packages/backend/dist/services/index.js +3 -2
  37. package/packages/backend/dist/srkl/index.js +1 -0
  38. package/packages/backend/dist/storage/index.js +1 -0
  39. package/packages/backend/dist/transformers.node-HWHOAE4H.js +43879 -0
  40. package/packages/backend/dist/workspace/index.js +1 -0
  41. package/packages/backend/package.json +5 -5
  42. package/packages/client/package.json +1 -1
  43. package/packages/contracts/package.json +1 -1
  44. package/packages/fod/package.json +24 -13
  45. package/packages/functions/dist/chunk-QGM4M3NI.js +37 -0
  46. package/packages/functions/dist/dist-XMSSRYDR.js +899 -0
  47. package/packages/functions/dist/index.d.ts +2 -0
  48. package/packages/functions/dist/index.js +581 -94
  49. package/packages/functions/dist/transformers.node-HWHOAE4H.js +43879 -0
  50. package/packages/functions/package.json +1 -1
  51. package/packages/orchestrations/package.json +3 -3
  52. package/packages/services/dist/chunk-QGM4M3NI.js +37 -0
  53. package/packages/services/dist/dist-XMSSRYDR.js +899 -0
  54. package/packages/services/dist/index.d.ts +55 -8
  55. package/packages/services/dist/index.js +640 -85
  56. package/packages/services/dist/transformers.node-HWHOAE4H.js +43879 -0
  57. package/packages/services/package.json +1 -1
  58. package/packages/state-graph/dist/chunk-QGM4M3NI.js +37 -0
  59. package/packages/state-graph/dist/dist-XMSSRYDR.js +899 -0
  60. package/packages/state-graph/dist/domain/index.js +1 -0
  61. package/packages/state-graph/dist/index.js +602 -119
  62. package/packages/state-graph/dist/rules/index.js +1 -0
  63. package/packages/state-graph/dist/spatial/index.js +1 -0
  64. package/packages/state-graph/dist/state/index.js +1 -0
  65. package/packages/state-graph/dist/store/index.js +1 -0
  66. package/packages/state-graph/dist/transformers.node-HWHOAE4H.js +43879 -0
  67. package/packages/state-graph/package.json +1 -1
  68. package/packages/backend/dist/chunk-TY32TUNI.js +0 -376
@@ -1,5 +1,302 @@
1
- // ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.3/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
1
+ import "./chunk-QGM4M3NI.js";
2
+
3
+ // ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.9_@types+node@22.20.5/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
4
+ import { randomUUID } from "crypto";
2
5
  import http from "http";
6
+
7
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/define-api.js
8
+ function defineApi(definition) {
9
+ const properties = Object.fromEntries(definition.parameters.map((parameter) => [
10
+ parameter.name,
11
+ {
12
+ ...parameter.schema,
13
+ description: parameter.description
14
+ }
15
+ ]));
16
+ return Object.freeze({
17
+ ...definition,
18
+ inputSchema: {
19
+ type: "object",
20
+ description: `Arguments for ${definition.name}.`,
21
+ properties,
22
+ required: definition.parameters.filter((parameter) => parameter.required).map((parameter) => parameter.name),
23
+ additionalProperties: false
24
+ }
25
+ });
26
+ }
27
+
28
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/array-apis.js
29
+ var array = { type: "array" };
30
+ var integer = { type: "integer" };
31
+ var arrayApis = [
32
+ defineApi({ id: "gutts.arrays.compact", name: "compact", category: "arrays", description: "Removes null and undefined values from an array while preserving the remaining values and their order.", parameters: [{ name: "values", description: "The array whose nullish elements should be removed.", required: true, schema: array }], output: { type: "array", description: "The array without null or undefined elements." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
33
+ defineApi({ id: "gutts.arrays.unique", name: "unique", category: "arrays", description: "Removes duplicate values from an array while preserving the first occurrence of each value.", parameters: [{ name: "values", description: "The array from which duplicate values should be removed.", required: true, schema: array }], output: { type: "array", description: "The array containing only the first occurrence of each value." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
34
+ defineApi({ id: "gutts.arrays.chunk", name: "chunk", category: "arrays", description: "Splits an array into consecutive subarrays of the requested maximum size.", parameters: [{ name: "values", description: "The array to split into chunks.", required: true, schema: array }, { name: "size", description: "The positive integer maximum number of elements in each chunk.", required: true, schema: integer }], output: { type: "array", items: array, description: "An array of consecutive subarrays." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when size is not a positive integer."] }),
35
+ defineApi({ id: "gutts.arrays.flatten", name: "flatten", category: "arrays", description: "Flattens one level of nested arrays into a single array.", parameters: [{ name: "values", description: "The array containing values or one-level nested arrays.", required: true, schema: array }], output: { type: "array", description: "The flattened array." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
36
+ defineApi({ id: "gutts.arrays.last", name: "last", category: "arrays", description: "Returns the final element of an array, or undefined when the array is empty.", parameters: [{ name: "values", description: "The array whose final element should be returned.", required: true, schema: array }], output: { description: "The final array element, or undefined for an empty array." }, semantics: { deterministic: true, pure: true, sideEffects: false } })
37
+ ];
38
+
39
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/json-apis.js
40
+ var json = { type: "object", description: "A JSON-compatible value." };
41
+ var jsonApis = [
42
+ defineApi({ id: "gutts.json.isJsonValue", name: "isJsonValue", category: "json", description: "Checks whether an unknown value can be represented as a finite JSON value.", parameters: [{ name: "value", description: "The value to validate as JSON-compatible data.", required: true, schema: {} }], output: { type: "boolean", description: "True when the value is a valid JSON value." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
43
+ defineApi({ id: "gutts.json.parseJson", name: "parseJson", category: "json", description: "Parses a JSON text string into a JSON-compatible value.", parameters: [{ name: "text", description: "The JSON document to parse.", required: true, schema: { type: "string" } }], output: json, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws SyntaxError when text is not valid JSON."] }),
44
+ defineApi({ id: "gutts.json.tryParseJson", name: "tryParseJson", category: "json", description: "Attempts to parse JSON text and returns undefined instead of throwing when parsing fails.", parameters: [{ name: "text", description: "The JSON document to parse.", required: true, schema: { type: "string" } }], output: { description: "The parsed JSON value, or undefined when parsing fails." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
45
+ defineApi({ id: "gutts.json.stringifyJson", name: "stringifyJson", category: "json", description: "Serializes a JSON-compatible value into JSON text, optionally using indentation.", parameters: [{ name: "value", description: "The JSON-compatible value to serialize.", required: true, schema: {} }, { name: "space", description: "Optional number of indentation spaces to use in the serialized output.", required: false, schema: { type: "number" } }], output: { type: "string", description: "The serialized JSON text." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws TypeError when the value cannot be serialized as JSON."] })
46
+ ];
47
+
48
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/number-apis.js
49
+ var numberApis = [
50
+ defineApi({ id: "gutts.numbers.clamp", name: "clamp", category: "numbers", description: "Restricts a numeric value to an inclusive minimum and maximum range.", parameters: [{ name: "value", description: "The numeric value to constrain.", required: true, schema: { type: "number" } }, { name: "min", description: "The inclusive lower bound.", required: true, schema: { type: "number" } }, { name: "max", description: "The inclusive upper bound.", required: true, schema: { type: "number" } }], output: { type: "number", description: "The value constrained to the inclusive range." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when min exceeds max."] }),
51
+ defineApi({ id: "gutts.numbers.inRange", name: "inRange", category: "numbers", description: "Checks whether a numeric value falls within the configured range.", parameters: [{ name: "value", description: "The numeric value to test.", required: true, schema: { type: "number" } }, { name: "min", description: "The lower range boundary.", required: true, schema: { type: "number" } }, { name: "max", description: "The upper range boundary.", required: true, schema: { type: "number" } }], output: { type: "boolean", description: "Whether the value is inside the range." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when min exceeds max."] }),
52
+ defineApi({ id: "gutts.numbers.roundTo", name: "roundTo", category: "numbers", description: "Rounds a number to a specified non-negative number of decimal places.", parameters: [{ name: "value", description: "The number to round.", required: true, schema: { type: "number" } }, { name: "decimals", description: "The non-negative integer number of decimal places.", required: false, schema: { type: "integer" } }], output: { type: "number", description: "The rounded number." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when decimals is negative or not an integer."] }),
53
+ defineApi({ id: "gutts.numbers.isFiniteNumber", name: "isFiniteNumber", category: "numbers", description: "Checks whether a value is a JavaScript number and is finite.", parameters: [{ name: "value", description: "The value to test.", required: true, schema: {} }], output: { type: "boolean", description: "True only for finite JavaScript numbers." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
54
+ defineApi({ id: "gutts.numbers.sum", name: "sum", category: "numbers", description: "Adds all numbers in an array and returns their total.", parameters: [{ name: "values", description: "The numeric values to add.", required: true, schema: { type: "array", items: { type: "number" } } }], output: { type: "number", description: "The sum of all input numbers." }, semantics: { deterministic: true, pure: true, sideEffects: false } })
55
+ ];
56
+
57
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/object-apis.js
58
+ var objectApis = [
59
+ defineApi({ id: "gutts.objects.hasOwn", name: "hasOwn", category: "objects", description: "Checks whether an object contains a requested property.", parameters: [{ name: "value", description: "The object to inspect.", required: true, schema: { type: "object" } }, { name: "key", description: "The property key to look for.", required: true, schema: { type: "string" } }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
60
+ defineApi({ id: "gutts.objects.pick", name: "pick", category: "objects", description: "Creates an object containing only requested properties.", parameters: [{ name: "value", description: "The source object.", required: true, schema: { type: "object" } }, { name: "keys", description: "The property keys to retain.", required: true, schema: { type: "array", items: { type: "string" } } }], output: { type: "object" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
61
+ defineApi({ id: "gutts.objects.omit", name: "omit", category: "objects", description: "Creates an object without requested properties.", parameters: [{ name: "value", description: "The source object.", required: true, schema: { type: "object" } }, { name: "keys", description: "The property keys to remove.", required: true, schema: { type: "array", items: { type: "string" } } }], output: { type: "object" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
62
+ defineApi({ id: "gutts.objects.isPlainObject", name: "isPlainObject", category: "objects", description: "Checks whether a value is a plain JavaScript object.", parameters: [{ name: "value", description: "The value to classify.", required: true, schema: {} }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } })
63
+ ];
64
+
65
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/string-apis.js
66
+ var string = { type: "string" };
67
+ var stringApis = [
68
+ defineApi({ id: "gutts.strings.isBlank", name: "isBlank", category: "strings", description: "Checks whether a string contains no non-whitespace characters.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
69
+ defineApi({ id: "gutts.strings.isNonBlank", name: "isNonBlank", category: "strings", description: "Checks whether a string contains at least one non-whitespace character.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
70
+ defineApi({ id: "gutts.strings.isEmail", name: "isEmail", category: "strings", description: "Checks whether a string conforms to the email-address validation rules used by GutTS.", parameters: [{ name: "value", description: "The string to validate as an email address.", required: true, schema: string }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
71
+ defineApi({ id: "gutts.strings.startsWithAny", name: "startsWithAny", category: "strings", description: "Checks whether a string starts with at least one supplied prefix.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }, { name: "prefixes", description: "The prefixes to test.", required: true, schema: { type: "array", items: string } }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
72
+ defineApi({ id: "gutts.strings.endsWithAny", name: "endsWithAny", category: "strings", description: "Checks whether a string ends with at least one supplied suffix.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }, { name: "suffixes", description: "The suffixes to test.", required: true, schema: { type: "array", items: string } }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
73
+ defineApi({ id: "gutts.strings.capitalize", name: "capitalize", category: "strings", description: "Capitalizes a string using the library's existing capitalization behavior.", parameters: [{ name: "value", description: "The string to capitalize.", required: true, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
74
+ defineApi({ id: "gutts.strings.camelCase", name: "camelCase", category: "strings", description: "Converts a string into lower camel case.", parameters: [{ name: "value", description: "The string to convert.", required: true, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
75
+ defineApi({ id: "gutts.strings.kebabCase", name: "kebabCase", category: "strings", description: "Converts a string into lower kebab case.", parameters: [{ name: "value", description: "The string to convert.", required: true, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
76
+ defineApi({ id: "gutts.strings.snakeCase", name: "snakeCase", category: "strings", description: "Converts a string into lower snake case.", parameters: [{ name: "value", description: "The string to convert.", required: true, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
77
+ defineApi({ id: "gutts.strings.truncate", name: "truncate", category: "strings", description: "Shortens a string to a maximum length and appends a suffix when truncation is required.", parameters: [{ name: "value", description: "The string to shorten.", required: true, schema: string }, { name: "maxLength", description: "The non-negative maximum output length.", required: true, schema: { type: "number" } }, { name: "suffix", description: "The suffix used when truncation occurs.", required: false, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when maxLength is negative."] }),
78
+ defineApi({ id: "gutts.strings.truncateWords", name: "truncateWords", category: "strings", description: "Shortens a string to a maximum number of words and appends a suffix when truncation is required.", parameters: [{ name: "value", description: "The string to shorten.", required: true, schema: string }, { name: "maxWords", description: "The non-negative maximum number of words.", required: true, schema: { type: "number" } }, { name: "suffix", description: "The suffix used when truncation occurs.", required: false, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when maxWords is negative."] })
79
+ ];
80
+
81
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/url-apis.js
82
+ var string2 = { type: "string" };
83
+ var urlApis = [
84
+ defineApi({ id: "gutts.urls.isUrl", name: "isUrl", category: "urls", description: "Checks whether a string can be parsed as a URL by the standard URL constructor.", parameters: [{ name: "value", description: "The string to validate.", required: true, schema: string2 }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
85
+ defineApi({ id: "gutts.urls.joinUrl", name: "joinUrl", category: "urls", description: "Joins a base URL-like string and path segments using single separators.", parameters: [{ name: "base", description: "The base URL or path.", required: true, schema: string2 }, { name: "parts", description: "The path segments to append.", required: true, schema: { type: "array", items: string2 } }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
86
+ defineApi({ id: "gutts.urls.getQueryParam", name: "getQueryParam", category: "urls", description: "Reads one query-string parameter from a URL.", parameters: [{ name: "url", description: "The URL to inspect.", required: true, schema: string2 }, { name: "key", description: "The query parameter name.", required: true, schema: string2 }], output: { type: "string", description: "The value, or null when absent." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
87
+ defineApi({ id: "gutts.urls.setQueryParam", name: "setQueryParam", category: "urls", description: "Returns a URL with one query-string parameter set to the supplied value.", parameters: [{ name: "url", description: "The URL to modify.", required: true, schema: string2 }, { name: "key", description: "The query parameter name.", required: true, schema: string2 }, { name: "value", description: "The query parameter value.", required: true, schema: string2 }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws when url cannot be parsed as a URL."] })
88
+ ];
89
+
90
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/needle3/index.js
91
+ var needle3Metadata = {
92
+ id: "model.cactus-needle3",
93
+ name: "Needle 3",
94
+ provider: "Cactus Compute",
95
+ version: "3",
96
+ description: "Tiny structured inference model for tool selection, argument extraction, classification, and embeddings.",
97
+ examples: ["select a tool", "extract fields", "classify an intent"],
98
+ avoidWhen: "Avoid for open-ended long-form generation or complex multi-step reasoning.",
99
+ whenToUse: "Use when natural language must be mapped to a small tool set or structured schema.",
100
+ size: { min: 8, max: 29, unit: "MB", qualifier: "range" },
101
+ capabilities: ["tool-selection", "argument-extraction", "classification", "structured-output", "embeddings"],
102
+ input: "Natural-language text with optional tools or extraction schema",
103
+ output: "Structured JSON or embedding vector",
104
+ runtime: "Cactus Needle runtime adapter",
105
+ modelUri: "Cactus-Compute/needle3"
106
+ };
107
+ var needle3CompleteApi = defineApi({
108
+ id: "model.cactus-needle3.complete",
109
+ name: "Needle3.complete",
110
+ category: "models",
111
+ description: "Select tools or extract structured data from natural-language input.",
112
+ parameters: [
113
+ { name: "prompt", description: "Natural-language input.", required: true, schema: { type: "string" } },
114
+ { name: "tools", description: "Optional tool definitions.", required: false, schema: { type: "array" } },
115
+ { name: "schema", description: "Optional extraction schema.", required: false, schema: { type: "object" } }
116
+ ],
117
+ output: { type: "object", description: "Structured model result." },
118
+ semantics: { deterministic: false, pure: false, sideEffects: false }
119
+ });
120
+
121
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/runtimes/ettin-head.js
122
+ import fs from "fs";
123
+ import path from "path";
124
+ import os from "os";
125
+
126
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/smollm2/index.js
127
+ var smolLM2Metadata = {
128
+ id: "model.smollm2-135m-instruct",
129
+ name: "SmolLM2-135M-Instruct",
130
+ provider: "Hugging Face",
131
+ version: "135M",
132
+ description: "Compact instruction-tuned language model for general text generation.",
133
+ examples: ["summarize text", "rewrite text", "draft a short response"],
134
+ avoidWhen: "Avoid for high-stakes reasoning, broad factual knowledge, or tasks requiring large context.",
135
+ whenToUse: "Use for short general-purpose text generation when a local model is preferred.",
136
+ size: { value: 105, unit: "MB", qualifier: "artifact" },
137
+ capabilities: ["text-generation", "instruction-following"],
138
+ input: "Natural-language prompt",
139
+ output: "Generated natural-language text",
140
+ runtime: "ModelRuntime adapter",
141
+ modelUri: "HuggingFaceTB/SmolLM2-135M-Instruct",
142
+ license: "Apache-2.0"
143
+ };
144
+ var smolLM2GenerateApi = defineApi({
145
+ id: "model.smollm2-135m-instruct.generate",
146
+ name: "SmolLM2-135M-Instruct.generate",
147
+ category: "models",
148
+ description: "Generate natural-language text with SmolLM2-135M-Instruct.",
149
+ parameters: [
150
+ { name: "prompt", description: "Prompt supplied to the model.", required: true, schema: { type: "string" } },
151
+ { name: "maxNewTokens", description: "Maximum number of new tokens.", required: false, schema: { type: "number" } }
152
+ ],
153
+ output: { type: "string", description: "Generated natural-language text." },
154
+ semantics: { deterministic: false, pure: false, sideEffects: false },
155
+ errors: ["Model load failure", "Inference failure"]
156
+ });
157
+
158
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/whistle/index.js
159
+ var whistleMetadata = {
160
+ id: "model.cactus-whistle",
161
+ name: "Whistle",
162
+ provider: "Cactus Compute",
163
+ version: "1",
164
+ description: "Compact CPU speech-recognition model for on-device transcription.",
165
+ examples: ["transcribe a voice note", "transcribe a command"],
166
+ avoidWhen: "Avoid when audio understanding beyond transcription is required.",
167
+ whenToUse: "Use for local speech-to-text when low resource use and privacy matter.",
168
+ size: { value: 16.9, unit: "MB", qualifier: "artifact" },
169
+ capabilities: ["speech-to-text", "on-device", "cpu"],
170
+ input: "Audio bytes",
171
+ output: "Transcribed natural-language text",
172
+ runtime: "Cactus Needle runtime adapter",
173
+ modelUri: "Cactus-Compute/whistle"
174
+ };
175
+ var whistleTranscribeApi = defineApi({
176
+ id: "model.cactus-whistle.transcribe",
177
+ name: "Whistle.transcribe",
178
+ category: "models",
179
+ description: "Transcribe speech audio into natural-language text.",
180
+ parameters: [
181
+ { name: "audio", description: "Audio bytes supplied to the speech model.", required: true, schema: { type: "string" } },
182
+ { name: "language", description: "Optional language identifier.", required: false, schema: { type: "string" } }
183
+ ],
184
+ output: { type: "string", description: "Transcribed text." },
185
+ semantics: { deterministic: true, pure: false, sideEffects: false }
186
+ });
187
+
188
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/ettin/index.js
189
+ var defineEttin = (id2, name, parameters, description) => ({
190
+ id: id2,
191
+ name,
192
+ provider: "Hugging Face",
193
+ version: String(parameters),
194
+ description,
195
+ examples: ["rank search results", "order retrieved documents by relevance"],
196
+ whenToUse: "Use for cross-encoder reranking when candidate texts must be sorted by semantic relevance.",
197
+ avoidWhen: "Avoid for text generation, embeddings, or transcription.",
198
+ size: { value: parameters * 1e6, unit: "parameters", qualifier: "parameters" },
199
+ capabilities: ["reranking", "relevance-scoring"],
200
+ input: "Query and candidate texts",
201
+ output: "Candidate relevance scores",
202
+ runtime: "ModelRuntime adapter",
203
+ modelUri: `cross-encoder/ettin-reranker-${parameters}m-v1`,
204
+ license: "Apache-2.0"
205
+ });
206
+ var ettinReranker17MMetadata = defineEttin("model.ettin-reranker-17m", "Ettin-Reranker-17M", 17, "Very small relevance model for ranking candidate text.");
207
+ var ettinReranker32MMetadata = defineEttin("model.ettin-reranker-32m", "Ettin-Reranker-32M", 32, "Small relevance model for ranking candidate text.");
208
+ var ettinReranker68MMetadata = defineEttin("model.ettin-reranker-68m", "Ettin-Reranker-68M", 68, "Compact relevance model for higher-quality candidate ranking.");
209
+ var ettinReranker150MMetadata = defineEttin("model.ettin-reranker-150m", "Ettin-Reranker-150M", 150, "Larger compact relevance model for candidate ranking.");
210
+ var ettinRerankApi = defineApi({
211
+ id: "model.ettin-reranker.rerank",
212
+ name: "EttinReranker.rerank",
213
+ category: "models",
214
+ description: "Rank candidate texts by relevance to a query.",
215
+ parameters: [
216
+ { name: "query", description: "Query text.", required: true, schema: { type: "string" } },
217
+ { name: "candidates", description: "Candidate texts to rank.", required: true, schema: { type: "array", items: { type: "string" } } }
218
+ ],
219
+ output: { type: "array", description: "Relevance scores in candidate order.", items: { type: "number" } },
220
+ semantics: { deterministic: true, pure: false, sideEffects: false }
221
+ });
222
+
223
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/minilm/index.js
224
+ var miniLML6Metadata = {
225
+ id: "model.minilm-l6-v2",
226
+ name: "MiniLM-L6-v2",
227
+ provider: "Sentence Transformers",
228
+ version: "L6-v2",
229
+ description: "Compact sentence embedding model for semantic similarity.",
230
+ examples: ["compare two texts", "match a query to a short description"],
231
+ avoidWhen: "Avoid when generation, extraction, or tool calling is required.",
232
+ whenToUse: "Use for lightweight semantic similarity and embedding-based matching.",
233
+ size: { value: 227e5, unit: "parameters", qualifier: "parameters" },
234
+ capabilities: ["embeddings", "semantic-similarity"],
235
+ input: "Two text strings",
236
+ output: "Similarity score",
237
+ runtime: "ModelRuntime adapter",
238
+ modelUri: "sentence-transformers/all-MiniLM-L6-v2",
239
+ license: "Apache-2.0"
240
+ };
241
+ var miniLMSimilarityApi = defineApi({
242
+ id: "model.minilm-l6-v2.similarity",
243
+ name: "MiniLM-L6-v2.similarity",
244
+ category: "models",
245
+ description: "Compute semantic similarity between two texts.",
246
+ parameters: [
247
+ { name: "left", description: "First text.", required: true, schema: { type: "string" } },
248
+ { name: "right", description: "Second text.", required: true, schema: { type: "string" } }
249
+ ],
250
+ output: { type: "number", description: "Semantic similarity score." },
251
+ semantics: { deterministic: true, pure: false, sideEffects: false }
252
+ });
253
+
254
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/api-registry.js
255
+ var guttsApiDefinitions = Object.freeze([
256
+ ...arrayApis,
257
+ ...jsonApis,
258
+ ...numberApis,
259
+ ...objectApis,
260
+ ...stringApis,
261
+ ...urlApis,
262
+ smolLM2GenerateApi,
263
+ needle3CompleteApi,
264
+ whistleTranscribeApi,
265
+ ettinRerankApi,
266
+ miniLMSimilarityApi
267
+ ]);
268
+ var guttsApiById = Object.freeze(Object.fromEntries(guttsApiDefinitions.map((api) => [api.id, api])));
269
+
270
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/fod-node-provider.js
271
+ var schemaType = (schema) => String(schema?.type ?? "any");
272
+ function guttsApiToFodNode(api) {
273
+ return {
274
+ type: `gutts/${api.id}`,
275
+ label: api.name,
276
+ description: api.description,
277
+ category: "gutts",
278
+ group: api.category,
279
+ inputs: api.parameters.map((parameter) => ({ id: parameter.name, name: parameter.name, direction: "input", dataType: schemaType(parameter.schema), required: parameter.required, description: parameter.description, schema: parameter.schema })),
280
+ outputs: [{ id: "result", name: "result", direction: "output", dataType: schemaType(api.output), ...api.output.description ? { description: api.output.description } : {}, schema: api.output }],
281
+ metadata: { apiId: api.id, package: "@dinilmusick/gutts", semantics: api.semantics }
282
+ };
283
+ }
284
+ var guttsFodNodeDefinitions = Object.freeze(guttsApiDefinitions.map(guttsApiToFodNode));
285
+
286
+ // ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/model-registry.js
287
+ var guttsModelDefinitions = Object.freeze([
288
+ smolLM2Metadata,
289
+ needle3Metadata,
290
+ whistleMetadata,
291
+ ettinReranker17MMetadata,
292
+ ettinReranker32MMetadata,
293
+ ettinReranker68MMetadata,
294
+ ettinReranker150MMetadata,
295
+ miniLML6Metadata
296
+ ]);
297
+ var guttsModelById = Object.freeze(Object.fromEntries(guttsModelDefinitions.map((model) => [model.id, model])));
298
+
299
+ // ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.9_@types+node@22.20.5/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
3
300
  var ServiceStateStore = class {
4
301
  state;
5
302
  listeners = /* @__PURE__ */ new Set();
@@ -26,33 +323,6 @@ var ServiceStateStore = class {
26
323
  this.state = { ...newState || {} };
27
324
  }
28
325
  };
29
- var ServiceEventBus = class {
30
- handlers = /* @__PURE__ */ new Map();
31
- on(event, handler) {
32
- if (!this.handlers.has(event)) {
33
- this.handlers.set(event, /* @__PURE__ */ new Set());
34
- }
35
- const set = this.handlers.get(event);
36
- set.add(handler);
37
- return () => {
38
- set.delete(handler);
39
- };
40
- }
41
- emit(event, payload) {
42
- const set = this.handlers.get(event);
43
- if (!set) return;
44
- for (const handler of Array.from(set)) {
45
- try {
46
- handler(payload);
47
- } catch (err) {
48
- console.error(`[ServiceEventBus] Handler error for '${event}':`, err);
49
- }
50
- }
51
- }
52
- clear() {
53
- this.handlers.clear();
54
- }
55
- };
56
326
  var TRANSITIONS = {
57
327
  uninitialized: ["initializing"],
58
328
  initializing: ["ready", "uninitialized"],
@@ -87,14 +357,228 @@ var LifecycleManager = class {
87
357
  }
88
358
  }
89
359
  };
360
+ var runtimeProcess = typeof globalThis !== "undefined" ? globalThis.process : void 0;
361
+ var runtimePerformance = typeof globalThis !== "undefined" ? globalThis.performance : void 0;
362
+ function telemetryNow() {
363
+ return runtimePerformance?.now ? runtimePerformance.now() : Date.now();
364
+ }
365
+ function sampleResources() {
366
+ const memory = runtimeProcess?.memoryUsage?.();
367
+ const cpu = runtimeProcess?.cpuUsage?.();
368
+ const eventLoop = runtimePerformance?.eventLoopUtilization?.();
369
+ return {
370
+ cpuUserMicros: cpu?.user,
371
+ cpuSystemMicros: cpu?.system,
372
+ heapUsedBytes: memory?.heapUsed,
373
+ heapTotalBytes: memory?.heapTotal,
374
+ rssBytes: memory?.rss,
375
+ externalBytes: memory?.external,
376
+ arrayBuffersBytes: memory?.arrayBuffers,
377
+ eventLoopUtilization: eventLoop?.utilization,
378
+ scope: memory || cpu || eventLoop ? "process" : "runtime"
379
+ };
380
+ }
381
+ function deltaResources(start, end) {
382
+ const delta = (a, b) => a === void 0 || b === void 0 ? void 0 : b - a;
383
+ return {
384
+ cpuUserMicros: delta(start.cpuUserMicros, end.cpuUserMicros),
385
+ cpuSystemMicros: delta(start.cpuSystemMicros, end.cpuSystemMicros),
386
+ heapUsedBytes: delta(start.heapUsedBytes, end.heapUsedBytes),
387
+ heapTotalBytes: delta(start.heapTotalBytes, end.heapTotalBytes),
388
+ rssBytes: delta(start.rssBytes, end.rssBytes),
389
+ externalBytes: delta(start.externalBytes, end.externalBytes),
390
+ arrayBuffersBytes: delta(start.arrayBuffersBytes, end.arrayBuffersBytes),
391
+ eventLoopUtilization: delta(start.eventLoopUtilization, end.eventLoopUtilization),
392
+ scope: start.scope
393
+ };
394
+ }
395
+ var id = (prefix) => `${prefix}_${randomUUID()}`;
396
+ function percentiles(values) {
397
+ if (!values.length) return { min: 0, mean: 0, p50: 0, p90: 0, p95: 0, p99: 0, max: 0 };
398
+ const sorted = [...values].sort((a, b) => a - b);
399
+ const pick2 = (p) => sorted[Math.min(sorted.length - 1, Math.floor((sorted.length - 1) * p))];
400
+ return {
401
+ min: sorted[0],
402
+ mean: sorted.reduce((sum2, value) => sum2 + value, 0) / sorted.length,
403
+ p50: pick2(0.5),
404
+ p90: pick2(0.9),
405
+ p95: pick2(0.95),
406
+ p99: pick2(0.99),
407
+ max: sorted[sorted.length - 1]
408
+ };
409
+ }
410
+ var TelemetryController = class {
411
+ constructor(serviceId, options = {}) {
412
+ this.serviceId = serviceId;
413
+ this.mode = options.mode ?? "off";
414
+ this.maxSamples = Math.max(1, options.maxSamples ?? 2048);
415
+ this.maxRecentInvocations = Math.max(1, options.maxRecentInvocations ?? 100);
416
+ }
417
+ serviceId;
418
+ mode;
419
+ maxSamples;
420
+ maxRecentInvocations;
421
+ samples = [];
422
+ active = /* @__PURE__ */ new Map();
423
+ totalInvocationCount = 0;
424
+ totalSuccessCount = 0;
425
+ totalErrorCount = 0;
426
+ lastInvocationAt;
427
+ enable(mode = "standard") {
428
+ this.mode = mode;
429
+ }
430
+ disable() {
431
+ this.mode = "off";
432
+ this.active.clear();
433
+ }
434
+ setMode(mode) {
435
+ this.mode = mode;
436
+ if (mode === "off") this.active.clear();
437
+ }
438
+ getMode() {
439
+ return this.mode;
440
+ }
441
+ status() {
442
+ return {
443
+ enabled: this.mode !== "off",
444
+ mode: this.mode,
445
+ serviceId: this.serviceId,
446
+ invocationCount: this.totalInvocationCount,
447
+ activeInvocations: this.active.size,
448
+ lastInvocationAt: this.lastInvocationAt
449
+ };
450
+ }
451
+ begin(target, kind, correlationId, parentSpanId) {
452
+ if (this.mode === "off") {
453
+ return {
454
+ invocationId: "",
455
+ traceId: "",
456
+ spanId: "",
457
+ parentSpanId,
458
+ end: () => void 0
459
+ };
460
+ }
461
+ const invocationId = id("inv");
462
+ const spanId = id("span");
463
+ const traceId = parentSpanId ? this.findTraceId(parentSpanId) ?? id("trace") : id("trace");
464
+ const active = {
465
+ invocationId,
466
+ traceId,
467
+ spanId,
468
+ parentSpanId,
469
+ serviceId: this.serviceId,
470
+ target,
471
+ kind,
472
+ correlationId,
473
+ startedAt: telemetryNow(),
474
+ resourcesStart: this.mode === "standard" ? void 0 : sampleResources()
475
+ };
476
+ this.active.set(invocationId, active);
477
+ return {
478
+ invocationId,
479
+ traceId,
480
+ spanId,
481
+ parentSpanId,
482
+ end: (error) => this.finish(active, error)
483
+ };
484
+ }
485
+ reset() {
486
+ this.samples.length = 0;
487
+ this.active.clear();
488
+ this.totalInvocationCount = 0;
489
+ this.totalSuccessCount = 0;
490
+ this.totalErrorCount = 0;
491
+ this.lastInvocationAt = void 0;
492
+ }
493
+ snapshot() {
494
+ const invocations = this.samples.slice();
495
+ const durations = invocations.map((item) => item.durationMs);
496
+ const targetMap = /* @__PURE__ */ new Map();
497
+ for (const invocation of invocations) {
498
+ const key = `${invocation.kind}:${invocation.target}`;
499
+ const group = targetMap.get(key) ?? [];
500
+ group.push(invocation);
501
+ targetMap.set(key, group);
502
+ }
503
+ const targets = [...targetMap.values()].map((group) => ({
504
+ target: group[0].target,
505
+ kind: group[0].kind,
506
+ count: group.length,
507
+ successCount: group.filter((item) => item.status === "completed").length,
508
+ errorCount: group.filter((item) => item.status === "failed").length,
509
+ durationMs: percentiles(group.map((item) => item.durationMs)),
510
+ lastInvocationAt: group[group.length - 1]?.completedAt
511
+ }));
512
+ return {
513
+ serviceId: this.serviceId,
514
+ mode: this.mode,
515
+ capturedAt: Date.now(),
516
+ status: this.status(),
517
+ totals: {
518
+ invocationCount: this.totalInvocationCount,
519
+ successCount: this.totalSuccessCount,
520
+ errorCount: this.totalErrorCount,
521
+ durationMs: percentiles(durations)
522
+ },
523
+ targets,
524
+ activeInvocations: this.active.size,
525
+ recentInvocations: invocations.slice(-this.maxRecentInvocations)
526
+ };
527
+ }
528
+ functionality(name) {
529
+ return this.snapshot().targets.find((target) => target.kind === "functionality" && target.target === name);
530
+ }
531
+ functionalities() {
532
+ return this.snapshot().targets.filter((target) => target.kind === "functionality");
533
+ }
534
+ findTraceId(parentSpanId) {
535
+ for (let index = this.samples.length - 1; index >= 0; index -= 1) {
536
+ if (this.samples[index].spanId === parentSpanId) return this.samples[index].traceId;
537
+ }
538
+ for (const active of this.active.values()) {
539
+ if (active.spanId === parentSpanId) return active.traceId;
540
+ }
541
+ return void 0;
542
+ }
543
+ finish(active, error) {
544
+ if (!this.active.delete(active.invocationId)) return;
545
+ const completedAt = telemetryNow();
546
+ const resourcesEnd = this.mode === "standard" ? void 0 : sampleResources();
547
+ const invocation = {
548
+ invocationId: active.invocationId,
549
+ traceId: active.traceId,
550
+ spanId: active.spanId,
551
+ parentSpanId: active.parentSpanId,
552
+ serviceId: active.serviceId,
553
+ target: active.target,
554
+ kind: active.kind,
555
+ correlationId: active.correlationId,
556
+ startedAt: active.startedAt,
557
+ completedAt,
558
+ durationMs: Math.max(0, completedAt - active.startedAt),
559
+ status: error === void 0 ? "completed" : "failed",
560
+ error: error === void 0 ? void 0 : {
561
+ name: error instanceof Error ? error.name : "Error",
562
+ message: error instanceof Error ? error.message : String(error)
563
+ },
564
+ resources: active.resourcesStart && resourcesEnd ? { start: active.resourcesStart, end: resourcesEnd, delta: deltaResources(active.resourcesStart, resourcesEnd) } : void 0
565
+ };
566
+ this.samples.push(invocation);
567
+ this.totalInvocationCount += 1;
568
+ if (invocation.status === "completed") this.totalSuccessCount += 1;
569
+ else this.totalErrorCount += 1;
570
+ if (this.samples.length > this.maxSamples) this.samples.splice(0, this.samples.length - this.maxSamples);
571
+ this.lastInvocationAt = Date.now();
572
+ }
573
+ };
90
574
  var ServiceInstance = class {
91
575
  constructor(definition) {
92
576
  this.definition = definition;
93
577
  this.id = definition.id;
94
578
  this.name = definition.name;
95
579
  this.version = definition.version;
580
+ this.telemetry = new TelemetryController(this.id);
96
581
  this.lifecycle = new LifecycleManager();
97
- this.eventBus = new ServiceEventBus();
98
582
  if (definition.state) {
99
583
  this.stateStore = new ServiceStateStore(definition.state.initial);
100
584
  }
@@ -103,8 +587,8 @@ var ServiceInstance = class {
103
587
  id;
104
588
  name;
105
589
  version;
590
+ telemetry;
106
591
  stateStore;
107
- eventBus;
108
592
  lifecycle;
109
593
  initialized = false;
110
594
  disposed = false;
@@ -168,7 +652,19 @@ var ServiceInstance = class {
168
652
  if (!operation) {
169
653
  throw new Error("[Service:" + this.name + "] Operation '" + op + "' not found.");
170
654
  }
171
- return await operation.handler(input, ctx);
655
+ if (ctx.metadata?.__krnlTelemetryInternal === true) {
656
+ return await operation.handler(input, ctx);
657
+ }
658
+ const parentSpanId = typeof ctx.metadata?.__krnlTelemetryParentSpanId === "string" ? ctx.metadata.__krnlTelemetryParentSpanId : void 0;
659
+ const handle = this.telemetry.begin(op, "service", ctx.correlationId, parentSpanId);
660
+ try {
661
+ const output = await operation.handler(input, ctx);
662
+ handle.end();
663
+ return output;
664
+ } catch (error) {
665
+ handle.end(error);
666
+ throw error;
667
+ }
172
668
  }
173
669
  getState() {
174
670
  return this.stateStore?.getState() ?? Object.freeze({});
@@ -180,12 +676,6 @@ var ServiceInstance = class {
180
676
  }
181
677
  this.stateStore.setState(mutation);
182
678
  }
183
- on(event, handler) {
184
- return this.eventBus.on(event, handler);
185
- }
186
- emit(event, payload) {
187
- this.eventBus.emit(event, payload);
188
- }
189
679
  };
190
680
  var ServiceProxy = class {
191
681
  constructor(definition, adapter, endpoint) {
@@ -204,6 +694,7 @@ var ServiceProxy = class {
204
694
  this.id = definition.id;
205
695
  this.name = definition.name;
206
696
  this.version = definition.version;
697
+ this.telemetry = new TelemetryController(this.id);
207
698
  this.stateCache = { ...definition.state?.initial ?? {} };
208
699
  }
209
700
  definition;
@@ -212,6 +703,7 @@ var ServiceProxy = class {
212
703
  id;
213
704
  name;
214
705
  version;
706
+ telemetry;
215
707
  stateCache;
216
708
  eventHandlers = /* @__PURE__ */ new Map();
217
709
  lifecycle = new LifecycleManager();
@@ -269,11 +761,21 @@ var ServiceProxy = class {
269
761
  payload: input,
270
762
  timestamp: Date.now()
271
763
  };
272
- const response = await this.adapter.send(this.endpoint, envelope);
273
- if (response.error) {
274
- throw new Error("[ServiceProxy:" + this.name + "] Remote error: " + response.error);
764
+ const parentSpanId = typeof ctx.metadata?.__krnlTelemetryParentSpanId === "string" ? ctx.metadata.__krnlTelemetryParentSpanId : void 0;
765
+ const handle = this.telemetry.begin(op, "service", ctx.correlationId, parentSpanId);
766
+ try {
767
+ const response = await this.adapter.send(this.endpoint, envelope);
768
+ if (response.error) {
769
+ const error = new Error("[ServiceProxy:" + this.name + "] Remote error: " + response.error);
770
+ handle.end(error);
771
+ throw error;
772
+ }
773
+ handle.end();
774
+ return response.payload;
775
+ } catch (error) {
776
+ handle.end(error);
777
+ throw error;
275
778
  }
276
- return response.payload;
277
779
  }
278
780
  getState() {
279
781
  return Object.freeze({ ...this.stateCache });
@@ -331,12 +833,6 @@ function validateServiceDefinition(definition) {
331
833
  throw new Error("[Service:" + definition.name + "] Operation '" + key + "' must define a handler.");
332
834
  }
333
835
  }
334
- for (const [key, event] of Object.entries(definition.events ?? {})) {
335
- if (!event || typeof event !== "object") {
336
- throw new Error("[Service:" + definition.name + "] Invalid event '" + key + "'.");
337
- }
338
- assertNonEmptyString(event.name, "events." + key + ".name");
339
- }
340
836
  for (const [key, schema] of Object.entries(definition.inputs ?? {})) assertRecord(schema, "inputs." + key);
341
837
  for (const [key, schema] of Object.entries(definition.outputs ?? {})) assertRecord(schema, "outputs." + key);
342
838
  if (definition.state?.schema !== void 0) assertRecord(definition.state.schema, "state.schema");
@@ -455,13 +951,13 @@ var HttpProtocolAdapter = class {
455
951
  headers: { "Content-Type": "application/json" },
456
952
  body: JSON.stringify(envelope.payload || {})
457
953
  });
458
- const json = await res.json();
954
+ const json2 = await res.json();
459
955
  return {
460
956
  id: `res-${Date.now()}`,
461
957
  type: "response",
462
958
  correlationId: envelope.id,
463
- payload: json.payload,
464
- error: json.error,
959
+ payload: json2.payload,
960
+ error: json2.error,
465
961
  timestamp: Date.now()
466
962
  };
467
963
  }
@@ -487,12 +983,12 @@ async function loadDatabase(store) {
487
983
  parsed.forEach((u) => {
488
984
  if (u && u.email) {
489
985
  const emailKey = u.email.toLowerCase();
490
- let id = u.id || `usr_${Math.random().toString(36).substring(2, 8)}`;
491
- if (seenIds.has(id)) {
492
- id = `${id}_${Math.random().toString(36).substring(2, 6)}`;
986
+ let id2 = u.id || `usr_${Math.random().toString(36).substring(2, 8)}`;
987
+ if (seenIds.has(id2)) {
988
+ id2 = `${id2}_${Math.random().toString(36).substring(2, 6)}`;
493
989
  }
494
- seenIds.add(id);
495
- store.users.set(emailKey, { ...u, id, email: emailKey });
990
+ seenIds.add(id2);
991
+ store.users.set(emailKey, { ...u, id: id2, email: emailKey });
496
992
  }
497
993
  });
498
994
  }
@@ -509,12 +1005,12 @@ async function loadDatabase(store) {
509
1005
  if (u && u.email) {
510
1006
  const emailKey = u.email.toLowerCase();
511
1007
  if (!store.users.has(emailKey)) {
512
- let id = u.id || `usr_${Math.random().toString(36).substring(2, 8)}`;
513
- if (existingIds.has(id)) {
514
- id = `${id}_${Math.random().toString(36).substring(2, 6)}`;
1008
+ let id2 = u.id || `usr_${Math.random().toString(36).substring(2, 8)}`;
1009
+ if (existingIds.has(id2)) {
1010
+ id2 = `${id2}_${Math.random().toString(36).substring(2, 6)}`;
515
1011
  }
516
- existingIds.add(id);
517
- store.users.set(emailKey, { ...u, id, email: emailKey });
1012
+ existingIds.add(id2);
1013
+ store.users.set(emailKey, { ...u, id: id2, email: emailKey });
518
1014
  }
519
1015
  }
520
1016
  });
@@ -1301,12 +1797,12 @@ var SystemDbService = class {
1301
1797
  return { success: false };
1302
1798
  }
1303
1799
  }
1304
- async setPrimaryDatabase(id) {
1800
+ async setPrimaryDatabase(id2) {
1305
1801
  try {
1306
1802
  const res = await fetch("/api/admin/backend", {
1307
1803
  method: "PUT",
1308
1804
  headers: { "Content-Type": "application/json" },
1309
- body: JSON.stringify({ action: "update_database", id, updates: { role: "primary", enabled: true } })
1805
+ body: JSON.stringify({ action: "update_database", id: id2, updates: { role: "primary", enabled: true } })
1310
1806
  });
1311
1807
  const data = await res.json();
1312
1808
  await this.refreshStatus();
@@ -1315,9 +1811,9 @@ var SystemDbService = class {
1315
1811
  return { success: false };
1316
1812
  }
1317
1813
  }
1318
- async deleteDatabase(id) {
1814
+ async deleteDatabase(id2) {
1319
1815
  try {
1320
- const res = await fetch(`/api/admin/backend?id=${encodeURIComponent(id)}`, {
1816
+ const res = await fetch(`/api/admin/backend?id=${encodeURIComponent(id2)}`, {
1321
1817
  method: "DELETE"
1322
1818
  });
1323
1819
  const data = await res.json();
@@ -1481,9 +1977,9 @@ var StorageService = class {
1481
1977
  getConnections() {
1482
1978
  return [...this.connections];
1483
1979
  }
1484
- getConnectionById(id) {
1485
- if (!id) return void 0;
1486
- return this.connections.find((c) => c.id === id);
1980
+ getConnectionById(id2) {
1981
+ if (!id2) return void 0;
1982
+ return this.connections.find((c) => c.id === id2);
1487
1983
  }
1488
1984
  getPrimaryConnection() {
1489
1985
  return this.connections.find((c) => c.role === "primary") || this.connections[0];
@@ -1583,15 +2079,15 @@ var StorageService = class {
1583
2079
  this.persistState();
1584
2080
  return conn;
1585
2081
  }
1586
- setPrimaryConnection(id) {
2082
+ setPrimaryConnection(id2) {
1587
2083
  this.connections = this.connections.map((c) => ({
1588
2084
  ...c,
1589
- role: c.id === id ? "primary" : "redundant_clone"
2085
+ role: c.id === id2 ? "primary" : "redundant_clone"
1590
2086
  }));
1591
2087
  this.persistState();
1592
2088
  }
1593
- deleteConnection(id) {
1594
- this.connections = this.connections.filter((c) => c.id !== id);
2089
+ deleteConnection(id2) {
2090
+ this.connections = this.connections.filter((c) => c.id !== id2);
1595
2091
  if (this.connections.length > 0 && !this.connections.some((c) => c.role === "primary")) {
1596
2092
  this.connections[0].role = "primary";
1597
2093
  }
@@ -1637,13 +2133,13 @@ var StorageService = class {
1637
2133
  systemDbService.addDatabase(newEntry);
1638
2134
  return newEntry;
1639
2135
  }
1640
- updateDatabaseEntry(id, updates) {
2136
+ updateDatabaseEntry(id2, updates) {
1641
2137
  if (updates.role === "primary") {
1642
- systemDbService.setPrimaryDatabase(id);
2138
+ systemDbService.setPrimaryDatabase(id2);
1643
2139
  }
1644
2140
  }
1645
- deleteDatabaseEntry(id) {
1646
- systemDbService.deleteDatabase(id);
2141
+ deleteDatabaseEntry(id2) {
2142
+ systemDbService.deleteDatabase(id2);
1647
2143
  }
1648
2144
  async syncRedundancyCluster() {
1649
2145
  return systemDbService.syncRedundancy();
@@ -2105,6 +2601,61 @@ var UIAuthoringServiceFacade = {
2105
2601
  }
2106
2602
  };
2107
2603
 
2604
+ // src/client-services/srklAccountService.ts
2605
+ var SrklAccountClient = class {
2606
+ fetchImpl;
2607
+ baseUrl;
2608
+ userId;
2609
+ appId;
2610
+ constructor(options) {
2611
+ this.fetchImpl = options.fetchImpl || fetch;
2612
+ this.baseUrl = options.baseUrl.replace(/\/+$/, "");
2613
+ this.userId = options.userId;
2614
+ this.appId = options.appId;
2615
+ }
2616
+ async sync(manifest = {}) {
2617
+ const response = await this.fetchImpl(`${this.baseUrl}/api/ecosystem/accounts`, {
2618
+ method: "POST",
2619
+ headers: {
2620
+ "content-type": "application/json",
2621
+ "x-user-id": this.userId,
2622
+ "x-app-id": this.appId
2623
+ },
2624
+ body: JSON.stringify({ ...manifest, appId: manifest.appId || this.appId })
2625
+ });
2626
+ if (!response.ok) throw new Error(`SRKL account sync failed: ${response.status}`);
2627
+ return response.json();
2628
+ }
2629
+ async list(manifest = {}) {
2630
+ return this.sync(manifest);
2631
+ }
2632
+ async getByService(serviceId) {
2633
+ const result = await this.sync({ requiredServices: [serviceId] });
2634
+ return result.accounts.find(
2635
+ (account) => account.serviceId.toLowerCase() === serviceId.toLowerCase() || account.provider.toLowerCase() === serviceId.toLowerCase()
2636
+ );
2637
+ }
2638
+ };
2639
+ function createSrklAccountClient(options) {
2640
+ return new SrklAccountClient(options);
2641
+ }
2642
+ function mergeSrklAccounts(local, remote) {
2643
+ const remoteIds = new Set(remote.map((account) => account.id));
2644
+ const byRemoteId = new Map(local.filter((item) => item.srklAccountId).map((item) => [item.srklAccountId, item]));
2645
+ const merged = remote.map((account) => ({
2646
+ ...byRemoteId.get(account.id) || {},
2647
+ ...account,
2648
+ srklAccountId: account.id,
2649
+ syncedAt: (/* @__PURE__ */ new Date()).toISOString(),
2650
+ source: "SRKL"
2651
+ }));
2652
+ for (const item of local) {
2653
+ if (item.srklAccountId && remoteIds.has(item.srklAccountId)) continue;
2654
+ if (!item.srklAccountId) merged.push(item);
2655
+ }
2656
+ return merged;
2657
+ }
2658
+
2108
2659
  // src/client-services/index.ts
2109
2660
  var AuthClientServiceDefinition = createServiceDefinition({
2110
2661
  id: "kloks.service.auth",
@@ -2234,6 +2785,7 @@ var ServiceAFacade = {
2234
2785
  runtime: "server",
2235
2786
  deployment: "local",
2236
2787
  definition: ServiceADefinition,
2788
+ telemetry: serviceAInstance.telemetry,
2237
2789
  createInstance: () => createService(ServiceADefinition),
2238
2790
  execute: async (op, input) => {
2239
2791
  await serviceAInstance.start();
@@ -2289,6 +2841,9 @@ var ServiceBFacade = {
2289
2841
  runtime: "server",
2290
2842
  deployment: "local",
2291
2843
  definition: ServiceBDefinition,
2844
+ get telemetry() {
2845
+ return defaultServiceB.telemetry;
2846
+ },
2292
2847
  createInstance: createServiceB,
2293
2848
  execute: async (op, input) => {
2294
2849
  await defaultServiceB.start();
@@ -2296,17 +2851,10 @@ var ServiceBFacade = {
2296
2851
  }
2297
2852
  };
2298
2853
  function createServiceC() {
2299
- let instanceRef;
2300
2854
  const def = createServiceDefinition({
2301
2855
  id: "kloks.service.c",
2302
2856
  name: "ServiceC",
2303
2857
  version: "1.0.0",
2304
- events: {
2305
- reading: {
2306
- name: "reading",
2307
- description: "Emitted when a new metric reading is recorded"
2308
- }
2309
- },
2310
2858
  operations: {
2311
2859
  publishReading: {
2312
2860
  id: "ServiceC.publishReading",
@@ -2317,14 +2865,12 @@ function createServiceC() {
2317
2865
  value: input.value,
2318
2866
  timestamp: Date.now()
2319
2867
  };
2320
- instanceRef.emit("reading", payload);
2321
2868
  return payload;
2322
2869
  }
2323
2870
  }
2324
2871
  }
2325
2872
  });
2326
- instanceRef = createService(def);
2327
- return instanceRef;
2873
+ return createService(def);
2328
2874
  }
2329
2875
  var defaultServiceC = createServiceC();
2330
2876
  var ServiceCDefinition = defaultServiceC.getDefinition();
@@ -2335,6 +2881,9 @@ var ServiceCFacade = {
2335
2881
  runtime: "server",
2336
2882
  deployment: "local",
2337
2883
  definition: ServiceCDefinition,
2884
+ get telemetry() {
2885
+ return defaultServiceC.telemetry;
2886
+ },
2338
2887
  createInstance: createServiceC,
2339
2888
  execute: async (op, input) => {
2340
2889
  await defaultServiceC.start();
@@ -2403,6 +2952,9 @@ var ServiceDFacade = {
2403
2952
  runtime: "server",
2404
2953
  deployment: "remote",
2405
2954
  definition: ServiceDDefinition,
2955
+ get telemetry() {
2956
+ return defaultServiceD.telemetry;
2957
+ },
2406
2958
  createInstance: () => createService(ServiceDDefinition),
2407
2959
  execute: async (op, input) => {
2408
2960
  await defaultServiceD.start();
@@ -2438,6 +2990,7 @@ export {
2438
2990
  ServiceCFacade,
2439
2991
  ServiceDDefinition,
2440
2992
  ServiceDFacade,
2993
+ SrklAccountClient,
2441
2994
  StorageClientServiceDefinition,
2442
2995
  StorageClientServiceFacade,
2443
2996
  StorageService,
@@ -2453,6 +3006,7 @@ export {
2453
3006
  createMonacoIdeService,
2454
3007
  createServiceB,
2455
3008
  createServiceC,
3009
+ createSrklAccountClient,
2456
3010
  createUIAuthoringService,
2457
3011
  createWorkspace,
2458
3012
  deleteWorkspace,
@@ -2478,6 +3032,7 @@ export {
2478
3032
  loadDatabase,
2479
3033
  loginAdmin,
2480
3034
  loginUser,
3035
+ mergeSrklAccounts,
2481
3036
  persistDatabase,
2482
3037
  register,
2483
3038
  restoreSession,