@ultrst-armada/kloks 1.21.0 → 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.
- package/.krusbl-release-attestation.json +3 -3
- package/package.json +4 -4
- package/packages/audio-midi/dist/{audioClipEngine-BOT33JKI.js → audioClipEngine-E5ODQNYR.js} +3 -2
- package/packages/audio-midi/dist/{audioInputManager-BLDGGLAR.js → audioInputManager-OOH3TOJ6.js} +2 -1
- package/packages/audio-midi/dist/{chunk-N55BWOC6.js → chunk-2U7VIADS.js} +1 -1
- package/packages/audio-midi/dist/{chunk-3GRGELA4.js → chunk-3FXNT6PF.js} +2 -2
- package/packages/audio-midi/dist/chunk-QGM4M3NI.js +37 -0
- package/packages/audio-midi/dist/dist-XMSSRYDR.js +899 -0
- package/packages/audio-midi/dist/index.js +534 -75
- package/packages/audio-midi/dist/transformers.node-HWHOAE4H.js +43879 -0
- package/packages/audio-midi/package.json +1 -1
- package/packages/backend/dist/ai-inference/index.js +1 -0
- package/packages/backend/dist/ai-keys/index.d.ts +1 -0
- package/packages/backend/dist/ai-keys/index.js +2 -1
- package/packages/backend/dist/ai-models/index.js +3 -2
- package/packages/backend/dist/ai-provider/index.js +1 -0
- package/packages/backend/dist/ai-routing/index.js +4 -3
- package/packages/backend/dist/ai-tools/index.js +1 -0
- package/packages/backend/dist/api/index.js +1 -0
- package/packages/backend/dist/auth/index.js +1 -0
- package/packages/backend/dist/{chunk-RBF2OGMC.js → chunk-B3VJ4HDV.js} +4 -15
- package/packages/backend/dist/{chunk-OYVHKYJW.js → chunk-IJ5QNZCY.js} +1 -1
- package/packages/backend/dist/{chunk-4WUVDLIQ.js → chunk-LMWXONZG.js} +1 -1
- package/packages/backend/dist/chunk-MWSYNRNZ.js +871 -0
- package/packages/backend/dist/{chunk-4ONX56XS.js → chunk-NB2X3HEX.js} +26 -14
- package/packages/backend/dist/{chunk-RSKFM7AC.js → chunk-OB65KZ2M.js} +8 -5
- package/packages/backend/dist/{chunk-F7JDIU2C.js → chunk-P7H6TIEA.js} +3 -0
- package/packages/backend/dist/{chunk-UYXROZPP.js → chunk-PT6J6UEU.js} +2 -2
- package/packages/backend/dist/chunk-QGM4M3NI.js +37 -0
- package/packages/backend/dist/client/index.js +1 -0
- package/packages/backend/dist/connectivity/index.js +1 -0
- package/packages/backend/dist/control-plane/index.js +1 -0
- package/packages/backend/dist/development/index.js +3 -2
- package/packages/backend/dist/dist-XMSSRYDR.js +899 -0
- package/packages/backend/dist/index.js +77 -76
- package/packages/backend/dist/krnl-ai-services.d.ts +12 -2
- package/packages/backend/dist/krnl-ai-services.js +6 -5
- package/packages/backend/dist/krnl-services.d.ts +8 -0
- package/packages/backend/dist/krnl-services.js +7 -6
- package/packages/backend/dist/services/index.d.ts +2 -3
- package/packages/backend/dist/services/index.js +4 -3
- package/packages/backend/dist/srkl/index.js +1 -0
- package/packages/backend/dist/storage/index.js +8 -7
- package/packages/backend/dist/transformers.node-HWHOAE4H.js +43879 -0
- package/packages/backend/dist/workspace/index.js +3 -2
- package/packages/backend/package.json +5 -5
- package/packages/client/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/fod/dist/index.js +2 -2
- package/packages/fod/package.json +24 -13
- package/packages/functions/dist/chunk-QGM4M3NI.js +37 -0
- package/packages/functions/dist/dist-XMSSRYDR.js +899 -0
- package/packages/functions/dist/index.d.ts +2 -0
- package/packages/functions/dist/index.js +581 -94
- package/packages/functions/dist/transformers.node-HWHOAE4H.js +43879 -0
- package/packages/functions/package.json +1 -1
- package/packages/orchestrations/package.json +3 -3
- package/packages/services/dist/chunk-QGM4M3NI.js +37 -0
- package/packages/services/dist/dist-XMSSRYDR.js +899 -0
- package/packages/services/dist/index.d.ts +55 -8
- package/packages/services/dist/index.js +640 -85
- package/packages/services/dist/transformers.node-HWHOAE4H.js +43879 -0
- package/packages/services/package.json +1 -1
- package/packages/state-graph/dist/chunk-QGM4M3NI.js +37 -0
- package/packages/state-graph/dist/dist-XMSSRYDR.js +899 -0
- package/packages/state-graph/dist/domain/index.js +1 -0
- package/packages/state-graph/dist/index.js +602 -119
- package/packages/state-graph/dist/rules/index.js +1 -0
- package/packages/state-graph/dist/spatial/index.js +1 -0
- package/packages/state-graph/dist/state/index.js +1 -0
- package/packages/state-graph/dist/store/index.js +1 -0
- package/packages/state-graph/dist/transformers.node-HWHOAE4H.js +43879 -0
- package/packages/state-graph/package.json +1 -1
- package/packages/backend/dist/chunk-TY32TUNI.js +0 -376
- package/packages/backend/dist/{chunk-2XTHJI4I.js → chunk-6DNGLKAV.js} +3 -3
|
@@ -1,4 +1,301 @@
|
|
|
1
|
-
|
|
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";
|
|
5
|
+
|
|
6
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/define-api.js
|
|
7
|
+
function defineApi(definition) {
|
|
8
|
+
const properties = Object.fromEntries(definition.parameters.map((parameter) => [
|
|
9
|
+
parameter.name,
|
|
10
|
+
{
|
|
11
|
+
...parameter.schema,
|
|
12
|
+
description: parameter.description
|
|
13
|
+
}
|
|
14
|
+
]));
|
|
15
|
+
return Object.freeze({
|
|
16
|
+
...definition,
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: "object",
|
|
19
|
+
description: `Arguments for ${definition.name}.`,
|
|
20
|
+
properties,
|
|
21
|
+
required: definition.parameters.filter((parameter) => parameter.required).map((parameter) => parameter.name),
|
|
22
|
+
additionalProperties: false
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/array-apis.js
|
|
28
|
+
var array = { type: "array" };
|
|
29
|
+
var integer = { type: "integer" };
|
|
30
|
+
var arrayApis = [
|
|
31
|
+
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 } }),
|
|
32
|
+
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 } }),
|
|
33
|
+
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."] }),
|
|
34
|
+
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 } }),
|
|
35
|
+
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 } })
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/json-apis.js
|
|
39
|
+
var json = { type: "object", description: "A JSON-compatible value." };
|
|
40
|
+
var jsonApis = [
|
|
41
|
+
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 } }),
|
|
42
|
+
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."] }),
|
|
43
|
+
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 } }),
|
|
44
|
+
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."] })
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/number-apis.js
|
|
48
|
+
var numberApis = [
|
|
49
|
+
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."] }),
|
|
50
|
+
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."] }),
|
|
51
|
+
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."] }),
|
|
52
|
+
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 } }),
|
|
53
|
+
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 } })
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/object-apis.js
|
|
57
|
+
var objectApis = [
|
|
58
|
+
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 } }),
|
|
59
|
+
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 } }),
|
|
60
|
+
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 } }),
|
|
61
|
+
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 } })
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/string-apis.js
|
|
65
|
+
var string = { type: "string" };
|
|
66
|
+
var stringApis = [
|
|
67
|
+
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 } }),
|
|
68
|
+
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 } }),
|
|
69
|
+
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 } }),
|
|
70
|
+
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 } }),
|
|
71
|
+
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 } }),
|
|
72
|
+
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 } }),
|
|
73
|
+
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 } }),
|
|
74
|
+
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 } }),
|
|
75
|
+
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 } }),
|
|
76
|
+
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."] }),
|
|
77
|
+
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."] })
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/url-apis.js
|
|
81
|
+
var string2 = { type: "string" };
|
|
82
|
+
var urlApis = [
|
|
83
|
+
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 } }),
|
|
84
|
+
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 } }),
|
|
85
|
+
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 } }),
|
|
86
|
+
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."] })
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/needle3/index.js
|
|
90
|
+
var needle3Metadata = {
|
|
91
|
+
id: "model.cactus-needle3",
|
|
92
|
+
name: "Needle 3",
|
|
93
|
+
provider: "Cactus Compute",
|
|
94
|
+
version: "3",
|
|
95
|
+
description: "Tiny structured inference model for tool selection, argument extraction, classification, and embeddings.",
|
|
96
|
+
examples: ["select a tool", "extract fields", "classify an intent"],
|
|
97
|
+
avoidWhen: "Avoid for open-ended long-form generation or complex multi-step reasoning.",
|
|
98
|
+
whenToUse: "Use when natural language must be mapped to a small tool set or structured schema.",
|
|
99
|
+
size: { min: 8, max: 29, unit: "MB", qualifier: "range" },
|
|
100
|
+
capabilities: ["tool-selection", "argument-extraction", "classification", "structured-output", "embeddings"],
|
|
101
|
+
input: "Natural-language text with optional tools or extraction schema",
|
|
102
|
+
output: "Structured JSON or embedding vector",
|
|
103
|
+
runtime: "Cactus Needle runtime adapter",
|
|
104
|
+
modelUri: "Cactus-Compute/needle3"
|
|
105
|
+
};
|
|
106
|
+
var needle3CompleteApi = defineApi({
|
|
107
|
+
id: "model.cactus-needle3.complete",
|
|
108
|
+
name: "Needle3.complete",
|
|
109
|
+
category: "models",
|
|
110
|
+
description: "Select tools or extract structured data from natural-language input.",
|
|
111
|
+
parameters: [
|
|
112
|
+
{ name: "prompt", description: "Natural-language input.", required: true, schema: { type: "string" } },
|
|
113
|
+
{ name: "tools", description: "Optional tool definitions.", required: false, schema: { type: "array" } },
|
|
114
|
+
{ name: "schema", description: "Optional extraction schema.", required: false, schema: { type: "object" } }
|
|
115
|
+
],
|
|
116
|
+
output: { type: "object", description: "Structured model result." },
|
|
117
|
+
semantics: { deterministic: false, pure: false, sideEffects: false }
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/runtimes/ettin-head.js
|
|
121
|
+
import fs from "fs";
|
|
122
|
+
import path from "path";
|
|
123
|
+
import os from "os";
|
|
124
|
+
|
|
125
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/smollm2/index.js
|
|
126
|
+
var smolLM2Metadata = {
|
|
127
|
+
id: "model.smollm2-135m-instruct",
|
|
128
|
+
name: "SmolLM2-135M-Instruct",
|
|
129
|
+
provider: "Hugging Face",
|
|
130
|
+
version: "135M",
|
|
131
|
+
description: "Compact instruction-tuned language model for general text generation.",
|
|
132
|
+
examples: ["summarize text", "rewrite text", "draft a short response"],
|
|
133
|
+
avoidWhen: "Avoid for high-stakes reasoning, broad factual knowledge, or tasks requiring large context.",
|
|
134
|
+
whenToUse: "Use for short general-purpose text generation when a local model is preferred.",
|
|
135
|
+
size: { value: 105, unit: "MB", qualifier: "artifact" },
|
|
136
|
+
capabilities: ["text-generation", "instruction-following"],
|
|
137
|
+
input: "Natural-language prompt",
|
|
138
|
+
output: "Generated natural-language text",
|
|
139
|
+
runtime: "ModelRuntime adapter",
|
|
140
|
+
modelUri: "HuggingFaceTB/SmolLM2-135M-Instruct",
|
|
141
|
+
license: "Apache-2.0"
|
|
142
|
+
};
|
|
143
|
+
var smolLM2GenerateApi = defineApi({
|
|
144
|
+
id: "model.smollm2-135m-instruct.generate",
|
|
145
|
+
name: "SmolLM2-135M-Instruct.generate",
|
|
146
|
+
category: "models",
|
|
147
|
+
description: "Generate natural-language text with SmolLM2-135M-Instruct.",
|
|
148
|
+
parameters: [
|
|
149
|
+
{ name: "prompt", description: "Prompt supplied to the model.", required: true, schema: { type: "string" } },
|
|
150
|
+
{ name: "maxNewTokens", description: "Maximum number of new tokens.", required: false, schema: { type: "number" } }
|
|
151
|
+
],
|
|
152
|
+
output: { type: "string", description: "Generated natural-language text." },
|
|
153
|
+
semantics: { deterministic: false, pure: false, sideEffects: false },
|
|
154
|
+
errors: ["Model load failure", "Inference failure"]
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/whistle/index.js
|
|
158
|
+
var whistleMetadata = {
|
|
159
|
+
id: "model.cactus-whistle",
|
|
160
|
+
name: "Whistle",
|
|
161
|
+
provider: "Cactus Compute",
|
|
162
|
+
version: "1",
|
|
163
|
+
description: "Compact CPU speech-recognition model for on-device transcription.",
|
|
164
|
+
examples: ["transcribe a voice note", "transcribe a command"],
|
|
165
|
+
avoidWhen: "Avoid when audio understanding beyond transcription is required.",
|
|
166
|
+
whenToUse: "Use for local speech-to-text when low resource use and privacy matter.",
|
|
167
|
+
size: { value: 16.9, unit: "MB", qualifier: "artifact" },
|
|
168
|
+
capabilities: ["speech-to-text", "on-device", "cpu"],
|
|
169
|
+
input: "Audio bytes",
|
|
170
|
+
output: "Transcribed natural-language text",
|
|
171
|
+
runtime: "Cactus Needle runtime adapter",
|
|
172
|
+
modelUri: "Cactus-Compute/whistle"
|
|
173
|
+
};
|
|
174
|
+
var whistleTranscribeApi = defineApi({
|
|
175
|
+
id: "model.cactus-whistle.transcribe",
|
|
176
|
+
name: "Whistle.transcribe",
|
|
177
|
+
category: "models",
|
|
178
|
+
description: "Transcribe speech audio into natural-language text.",
|
|
179
|
+
parameters: [
|
|
180
|
+
{ name: "audio", description: "Audio bytes supplied to the speech model.", required: true, schema: { type: "string" } },
|
|
181
|
+
{ name: "language", description: "Optional language identifier.", required: false, schema: { type: "string" } }
|
|
182
|
+
],
|
|
183
|
+
output: { type: "string", description: "Transcribed text." },
|
|
184
|
+
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/ettin/index.js
|
|
188
|
+
var defineEttin = (id2, name, parameters, description) => ({
|
|
189
|
+
id: id2,
|
|
190
|
+
name,
|
|
191
|
+
provider: "Hugging Face",
|
|
192
|
+
version: String(parameters),
|
|
193
|
+
description,
|
|
194
|
+
examples: ["rank search results", "order retrieved documents by relevance"],
|
|
195
|
+
whenToUse: "Use for cross-encoder reranking when candidate texts must be sorted by semantic relevance.",
|
|
196
|
+
avoidWhen: "Avoid for text generation, embeddings, or transcription.",
|
|
197
|
+
size: { value: parameters * 1e6, unit: "parameters", qualifier: "parameters" },
|
|
198
|
+
capabilities: ["reranking", "relevance-scoring"],
|
|
199
|
+
input: "Query and candidate texts",
|
|
200
|
+
output: "Candidate relevance scores",
|
|
201
|
+
runtime: "ModelRuntime adapter",
|
|
202
|
+
modelUri: `cross-encoder/ettin-reranker-${parameters}m-v1`,
|
|
203
|
+
license: "Apache-2.0"
|
|
204
|
+
});
|
|
205
|
+
var ettinReranker17MMetadata = defineEttin("model.ettin-reranker-17m", "Ettin-Reranker-17M", 17, "Very small relevance model for ranking candidate text.");
|
|
206
|
+
var ettinReranker32MMetadata = defineEttin("model.ettin-reranker-32m", "Ettin-Reranker-32M", 32, "Small relevance model for ranking candidate text.");
|
|
207
|
+
var ettinReranker68MMetadata = defineEttin("model.ettin-reranker-68m", "Ettin-Reranker-68M", 68, "Compact relevance model for higher-quality candidate ranking.");
|
|
208
|
+
var ettinReranker150MMetadata = defineEttin("model.ettin-reranker-150m", "Ettin-Reranker-150M", 150, "Larger compact relevance model for candidate ranking.");
|
|
209
|
+
var ettinRerankApi = defineApi({
|
|
210
|
+
id: "model.ettin-reranker.rerank",
|
|
211
|
+
name: "EttinReranker.rerank",
|
|
212
|
+
category: "models",
|
|
213
|
+
description: "Rank candidate texts by relevance to a query.",
|
|
214
|
+
parameters: [
|
|
215
|
+
{ name: "query", description: "Query text.", required: true, schema: { type: "string" } },
|
|
216
|
+
{ name: "candidates", description: "Candidate texts to rank.", required: true, schema: { type: "array", items: { type: "string" } } }
|
|
217
|
+
],
|
|
218
|
+
output: { type: "array", description: "Relevance scores in candidate order.", items: { type: "number" } },
|
|
219
|
+
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/minilm/index.js
|
|
223
|
+
var miniLML6Metadata = {
|
|
224
|
+
id: "model.minilm-l6-v2",
|
|
225
|
+
name: "MiniLM-L6-v2",
|
|
226
|
+
provider: "Sentence Transformers",
|
|
227
|
+
version: "L6-v2",
|
|
228
|
+
description: "Compact sentence embedding model for semantic similarity.",
|
|
229
|
+
examples: ["compare two texts", "match a query to a short description"],
|
|
230
|
+
avoidWhen: "Avoid when generation, extraction, or tool calling is required.",
|
|
231
|
+
whenToUse: "Use for lightweight semantic similarity and embedding-based matching.",
|
|
232
|
+
size: { value: 227e5, unit: "parameters", qualifier: "parameters" },
|
|
233
|
+
capabilities: ["embeddings", "semantic-similarity"],
|
|
234
|
+
input: "Two text strings",
|
|
235
|
+
output: "Similarity score",
|
|
236
|
+
runtime: "ModelRuntime adapter",
|
|
237
|
+
modelUri: "sentence-transformers/all-MiniLM-L6-v2",
|
|
238
|
+
license: "Apache-2.0"
|
|
239
|
+
};
|
|
240
|
+
var miniLMSimilarityApi = defineApi({
|
|
241
|
+
id: "model.minilm-l6-v2.similarity",
|
|
242
|
+
name: "MiniLM-L6-v2.similarity",
|
|
243
|
+
category: "models",
|
|
244
|
+
description: "Compute semantic similarity between two texts.",
|
|
245
|
+
parameters: [
|
|
246
|
+
{ name: "left", description: "First text.", required: true, schema: { type: "string" } },
|
|
247
|
+
{ name: "right", description: "Second text.", required: true, schema: { type: "string" } }
|
|
248
|
+
],
|
|
249
|
+
output: { type: "number", description: "Semantic similarity score." },
|
|
250
|
+
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/api-registry.js
|
|
254
|
+
var guttsApiDefinitions = Object.freeze([
|
|
255
|
+
...arrayApis,
|
|
256
|
+
...jsonApis,
|
|
257
|
+
...numberApis,
|
|
258
|
+
...objectApis,
|
|
259
|
+
...stringApis,
|
|
260
|
+
...urlApis,
|
|
261
|
+
smolLM2GenerateApi,
|
|
262
|
+
needle3CompleteApi,
|
|
263
|
+
whistleTranscribeApi,
|
|
264
|
+
ettinRerankApi,
|
|
265
|
+
miniLMSimilarityApi
|
|
266
|
+
]);
|
|
267
|
+
var guttsApiById = Object.freeze(Object.fromEntries(guttsApiDefinitions.map((api) => [api.id, api])));
|
|
268
|
+
|
|
269
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/fod-node-provider.js
|
|
270
|
+
var schemaType = (schema) => String(schema?.type ?? "any");
|
|
271
|
+
function guttsApiToFodNode(api) {
|
|
272
|
+
return {
|
|
273
|
+
type: `gutts/${api.id}`,
|
|
274
|
+
label: api.name,
|
|
275
|
+
description: api.description,
|
|
276
|
+
category: "gutts",
|
|
277
|
+
group: api.category,
|
|
278
|
+
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 })),
|
|
279
|
+
outputs: [{ id: "result", name: "result", direction: "output", dataType: schemaType(api.output), ...api.output.description ? { description: api.output.description } : {}, schema: api.output }],
|
|
280
|
+
metadata: { apiId: api.id, package: "@dinilmusick/gutts", semantics: api.semantics }
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
var guttsFodNodeDefinitions = Object.freeze(guttsApiDefinitions.map(guttsApiToFodNode));
|
|
284
|
+
|
|
285
|
+
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.1.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/model-registry.js
|
|
286
|
+
var guttsModelDefinitions = Object.freeze([
|
|
287
|
+
smolLM2Metadata,
|
|
288
|
+
needle3Metadata,
|
|
289
|
+
whistleMetadata,
|
|
290
|
+
ettinReranker17MMetadata,
|
|
291
|
+
ettinReranker32MMetadata,
|
|
292
|
+
ettinReranker68MMetadata,
|
|
293
|
+
ettinReranker150MMetadata,
|
|
294
|
+
miniLML6Metadata
|
|
295
|
+
]);
|
|
296
|
+
var guttsModelById = Object.freeze(Object.fromEntries(guttsModelDefinitions.map((model) => [model.id, model])));
|
|
297
|
+
|
|
298
|
+
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.9_@types+node@22.20.5/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
|
|
2
299
|
var ServiceStateStore = class {
|
|
3
300
|
state;
|
|
4
301
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -25,33 +322,6 @@ var ServiceStateStore = class {
|
|
|
25
322
|
this.state = { ...newState || {} };
|
|
26
323
|
}
|
|
27
324
|
};
|
|
28
|
-
var ServiceEventBus = class {
|
|
29
|
-
handlers = /* @__PURE__ */ new Map();
|
|
30
|
-
on(event, handler) {
|
|
31
|
-
if (!this.handlers.has(event)) {
|
|
32
|
-
this.handlers.set(event, /* @__PURE__ */ new Set());
|
|
33
|
-
}
|
|
34
|
-
const set = this.handlers.get(event);
|
|
35
|
-
set.add(handler);
|
|
36
|
-
return () => {
|
|
37
|
-
set.delete(handler);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
emit(event, payload) {
|
|
41
|
-
const set = this.handlers.get(event);
|
|
42
|
-
if (!set) return;
|
|
43
|
-
for (const handler of Array.from(set)) {
|
|
44
|
-
try {
|
|
45
|
-
handler(payload);
|
|
46
|
-
} catch (err) {
|
|
47
|
-
console.error(`[ServiceEventBus] Handler error for '${event}':`, err);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
clear() {
|
|
52
|
-
this.handlers.clear();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
325
|
var TRANSITIONS = {
|
|
56
326
|
uninitialized: ["initializing"],
|
|
57
327
|
initializing: ["ready", "uninitialized"],
|
|
@@ -86,14 +356,228 @@ var LifecycleManager = class {
|
|
|
86
356
|
}
|
|
87
357
|
}
|
|
88
358
|
};
|
|
359
|
+
var runtimeProcess = typeof globalThis !== "undefined" ? globalThis.process : void 0;
|
|
360
|
+
var runtimePerformance = typeof globalThis !== "undefined" ? globalThis.performance : void 0;
|
|
361
|
+
function telemetryNow() {
|
|
362
|
+
return runtimePerformance?.now ? runtimePerformance.now() : Date.now();
|
|
363
|
+
}
|
|
364
|
+
function sampleResources() {
|
|
365
|
+
const memory = runtimeProcess?.memoryUsage?.();
|
|
366
|
+
const cpu = runtimeProcess?.cpuUsage?.();
|
|
367
|
+
const eventLoop = runtimePerformance?.eventLoopUtilization?.();
|
|
368
|
+
return {
|
|
369
|
+
cpuUserMicros: cpu?.user,
|
|
370
|
+
cpuSystemMicros: cpu?.system,
|
|
371
|
+
heapUsedBytes: memory?.heapUsed,
|
|
372
|
+
heapTotalBytes: memory?.heapTotal,
|
|
373
|
+
rssBytes: memory?.rss,
|
|
374
|
+
externalBytes: memory?.external,
|
|
375
|
+
arrayBuffersBytes: memory?.arrayBuffers,
|
|
376
|
+
eventLoopUtilization: eventLoop?.utilization,
|
|
377
|
+
scope: memory || cpu || eventLoop ? "process" : "runtime"
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
function deltaResources(start, end) {
|
|
381
|
+
const delta = (a, b) => a === void 0 || b === void 0 ? void 0 : b - a;
|
|
382
|
+
return {
|
|
383
|
+
cpuUserMicros: delta(start.cpuUserMicros, end.cpuUserMicros),
|
|
384
|
+
cpuSystemMicros: delta(start.cpuSystemMicros, end.cpuSystemMicros),
|
|
385
|
+
heapUsedBytes: delta(start.heapUsedBytes, end.heapUsedBytes),
|
|
386
|
+
heapTotalBytes: delta(start.heapTotalBytes, end.heapTotalBytes),
|
|
387
|
+
rssBytes: delta(start.rssBytes, end.rssBytes),
|
|
388
|
+
externalBytes: delta(start.externalBytes, end.externalBytes),
|
|
389
|
+
arrayBuffersBytes: delta(start.arrayBuffersBytes, end.arrayBuffersBytes),
|
|
390
|
+
eventLoopUtilization: delta(start.eventLoopUtilization, end.eventLoopUtilization),
|
|
391
|
+
scope: start.scope
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
var id = (prefix) => `${prefix}_${randomUUID()}`;
|
|
395
|
+
function percentiles(values) {
|
|
396
|
+
if (!values.length) return { min: 0, mean: 0, p50: 0, p90: 0, p95: 0, p99: 0, max: 0 };
|
|
397
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
398
|
+
const pick2 = (p) => sorted[Math.min(sorted.length - 1, Math.floor((sorted.length - 1) * p))];
|
|
399
|
+
return {
|
|
400
|
+
min: sorted[0],
|
|
401
|
+
mean: sorted.reduce((sum2, value) => sum2 + value, 0) / sorted.length,
|
|
402
|
+
p50: pick2(0.5),
|
|
403
|
+
p90: pick2(0.9),
|
|
404
|
+
p95: pick2(0.95),
|
|
405
|
+
p99: pick2(0.99),
|
|
406
|
+
max: sorted[sorted.length - 1]
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
var TelemetryController = class {
|
|
410
|
+
constructor(serviceId, options = {}) {
|
|
411
|
+
this.serviceId = serviceId;
|
|
412
|
+
this.mode = options.mode ?? "off";
|
|
413
|
+
this.maxSamples = Math.max(1, options.maxSamples ?? 2048);
|
|
414
|
+
this.maxRecentInvocations = Math.max(1, options.maxRecentInvocations ?? 100);
|
|
415
|
+
}
|
|
416
|
+
serviceId;
|
|
417
|
+
mode;
|
|
418
|
+
maxSamples;
|
|
419
|
+
maxRecentInvocations;
|
|
420
|
+
samples = [];
|
|
421
|
+
active = /* @__PURE__ */ new Map();
|
|
422
|
+
totalInvocationCount = 0;
|
|
423
|
+
totalSuccessCount = 0;
|
|
424
|
+
totalErrorCount = 0;
|
|
425
|
+
lastInvocationAt;
|
|
426
|
+
enable(mode = "standard") {
|
|
427
|
+
this.mode = mode;
|
|
428
|
+
}
|
|
429
|
+
disable() {
|
|
430
|
+
this.mode = "off";
|
|
431
|
+
this.active.clear();
|
|
432
|
+
}
|
|
433
|
+
setMode(mode) {
|
|
434
|
+
this.mode = mode;
|
|
435
|
+
if (mode === "off") this.active.clear();
|
|
436
|
+
}
|
|
437
|
+
getMode() {
|
|
438
|
+
return this.mode;
|
|
439
|
+
}
|
|
440
|
+
status() {
|
|
441
|
+
return {
|
|
442
|
+
enabled: this.mode !== "off",
|
|
443
|
+
mode: this.mode,
|
|
444
|
+
serviceId: this.serviceId,
|
|
445
|
+
invocationCount: this.totalInvocationCount,
|
|
446
|
+
activeInvocations: this.active.size,
|
|
447
|
+
lastInvocationAt: this.lastInvocationAt
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
begin(target, kind, correlationId, parentSpanId) {
|
|
451
|
+
if (this.mode === "off") {
|
|
452
|
+
return {
|
|
453
|
+
invocationId: "",
|
|
454
|
+
traceId: "",
|
|
455
|
+
spanId: "",
|
|
456
|
+
parentSpanId,
|
|
457
|
+
end: () => void 0
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
const invocationId = id("inv");
|
|
461
|
+
const spanId = id("span");
|
|
462
|
+
const traceId = parentSpanId ? this.findTraceId(parentSpanId) ?? id("trace") : id("trace");
|
|
463
|
+
const active = {
|
|
464
|
+
invocationId,
|
|
465
|
+
traceId,
|
|
466
|
+
spanId,
|
|
467
|
+
parentSpanId,
|
|
468
|
+
serviceId: this.serviceId,
|
|
469
|
+
target,
|
|
470
|
+
kind,
|
|
471
|
+
correlationId,
|
|
472
|
+
startedAt: telemetryNow(),
|
|
473
|
+
resourcesStart: this.mode === "standard" ? void 0 : sampleResources()
|
|
474
|
+
};
|
|
475
|
+
this.active.set(invocationId, active);
|
|
476
|
+
return {
|
|
477
|
+
invocationId,
|
|
478
|
+
traceId,
|
|
479
|
+
spanId,
|
|
480
|
+
parentSpanId,
|
|
481
|
+
end: (error) => this.finish(active, error)
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
reset() {
|
|
485
|
+
this.samples.length = 0;
|
|
486
|
+
this.active.clear();
|
|
487
|
+
this.totalInvocationCount = 0;
|
|
488
|
+
this.totalSuccessCount = 0;
|
|
489
|
+
this.totalErrorCount = 0;
|
|
490
|
+
this.lastInvocationAt = void 0;
|
|
491
|
+
}
|
|
492
|
+
snapshot() {
|
|
493
|
+
const invocations = this.samples.slice();
|
|
494
|
+
const durations = invocations.map((item) => item.durationMs);
|
|
495
|
+
const targetMap = /* @__PURE__ */ new Map();
|
|
496
|
+
for (const invocation of invocations) {
|
|
497
|
+
const key = `${invocation.kind}:${invocation.target}`;
|
|
498
|
+
const group = targetMap.get(key) ?? [];
|
|
499
|
+
group.push(invocation);
|
|
500
|
+
targetMap.set(key, group);
|
|
501
|
+
}
|
|
502
|
+
const targets = [...targetMap.values()].map((group) => ({
|
|
503
|
+
target: group[0].target,
|
|
504
|
+
kind: group[0].kind,
|
|
505
|
+
count: group.length,
|
|
506
|
+
successCount: group.filter((item) => item.status === "completed").length,
|
|
507
|
+
errorCount: group.filter((item) => item.status === "failed").length,
|
|
508
|
+
durationMs: percentiles(group.map((item) => item.durationMs)),
|
|
509
|
+
lastInvocationAt: group[group.length - 1]?.completedAt
|
|
510
|
+
}));
|
|
511
|
+
return {
|
|
512
|
+
serviceId: this.serviceId,
|
|
513
|
+
mode: this.mode,
|
|
514
|
+
capturedAt: Date.now(),
|
|
515
|
+
status: this.status(),
|
|
516
|
+
totals: {
|
|
517
|
+
invocationCount: this.totalInvocationCount,
|
|
518
|
+
successCount: this.totalSuccessCount,
|
|
519
|
+
errorCount: this.totalErrorCount,
|
|
520
|
+
durationMs: percentiles(durations)
|
|
521
|
+
},
|
|
522
|
+
targets,
|
|
523
|
+
activeInvocations: this.active.size,
|
|
524
|
+
recentInvocations: invocations.slice(-this.maxRecentInvocations)
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
functionality(name) {
|
|
528
|
+
return this.snapshot().targets.find((target) => target.kind === "functionality" && target.target === name);
|
|
529
|
+
}
|
|
530
|
+
functionalities() {
|
|
531
|
+
return this.snapshot().targets.filter((target) => target.kind === "functionality");
|
|
532
|
+
}
|
|
533
|
+
findTraceId(parentSpanId) {
|
|
534
|
+
for (let index = this.samples.length - 1; index >= 0; index -= 1) {
|
|
535
|
+
if (this.samples[index].spanId === parentSpanId) return this.samples[index].traceId;
|
|
536
|
+
}
|
|
537
|
+
for (const active of this.active.values()) {
|
|
538
|
+
if (active.spanId === parentSpanId) return active.traceId;
|
|
539
|
+
}
|
|
540
|
+
return void 0;
|
|
541
|
+
}
|
|
542
|
+
finish(active, error) {
|
|
543
|
+
if (!this.active.delete(active.invocationId)) return;
|
|
544
|
+
const completedAt = telemetryNow();
|
|
545
|
+
const resourcesEnd = this.mode === "standard" ? void 0 : sampleResources();
|
|
546
|
+
const invocation = {
|
|
547
|
+
invocationId: active.invocationId,
|
|
548
|
+
traceId: active.traceId,
|
|
549
|
+
spanId: active.spanId,
|
|
550
|
+
parentSpanId: active.parentSpanId,
|
|
551
|
+
serviceId: active.serviceId,
|
|
552
|
+
target: active.target,
|
|
553
|
+
kind: active.kind,
|
|
554
|
+
correlationId: active.correlationId,
|
|
555
|
+
startedAt: active.startedAt,
|
|
556
|
+
completedAt,
|
|
557
|
+
durationMs: Math.max(0, completedAt - active.startedAt),
|
|
558
|
+
status: error === void 0 ? "completed" : "failed",
|
|
559
|
+
error: error === void 0 ? void 0 : {
|
|
560
|
+
name: error instanceof Error ? error.name : "Error",
|
|
561
|
+
message: error instanceof Error ? error.message : String(error)
|
|
562
|
+
},
|
|
563
|
+
resources: active.resourcesStart && resourcesEnd ? { start: active.resourcesStart, end: resourcesEnd, delta: deltaResources(active.resourcesStart, resourcesEnd) } : void 0
|
|
564
|
+
};
|
|
565
|
+
this.samples.push(invocation);
|
|
566
|
+
this.totalInvocationCount += 1;
|
|
567
|
+
if (invocation.status === "completed") this.totalSuccessCount += 1;
|
|
568
|
+
else this.totalErrorCount += 1;
|
|
569
|
+
if (this.samples.length > this.maxSamples) this.samples.splice(0, this.samples.length - this.maxSamples);
|
|
570
|
+
this.lastInvocationAt = Date.now();
|
|
571
|
+
}
|
|
572
|
+
};
|
|
89
573
|
var ServiceInstance = class {
|
|
90
574
|
constructor(definition) {
|
|
91
575
|
this.definition = definition;
|
|
92
576
|
this.id = definition.id;
|
|
93
577
|
this.name = definition.name;
|
|
94
578
|
this.version = definition.version;
|
|
579
|
+
this.telemetry = new TelemetryController(this.id);
|
|
95
580
|
this.lifecycle = new LifecycleManager();
|
|
96
|
-
this.eventBus = new ServiceEventBus();
|
|
97
581
|
if (definition.state) {
|
|
98
582
|
this.stateStore = new ServiceStateStore(definition.state.initial);
|
|
99
583
|
}
|
|
@@ -102,8 +586,8 @@ var ServiceInstance = class {
|
|
|
102
586
|
id;
|
|
103
587
|
name;
|
|
104
588
|
version;
|
|
589
|
+
telemetry;
|
|
105
590
|
stateStore;
|
|
106
|
-
eventBus;
|
|
107
591
|
lifecycle;
|
|
108
592
|
initialized = false;
|
|
109
593
|
disposed = false;
|
|
@@ -167,7 +651,19 @@ var ServiceInstance = class {
|
|
|
167
651
|
if (!operation) {
|
|
168
652
|
throw new Error("[Service:" + this.name + "] Operation '" + op + "' not found.");
|
|
169
653
|
}
|
|
170
|
-
|
|
654
|
+
if (ctx.metadata?.__krnlTelemetryInternal === true) {
|
|
655
|
+
return await operation.handler(input, ctx);
|
|
656
|
+
}
|
|
657
|
+
const parentSpanId = typeof ctx.metadata?.__krnlTelemetryParentSpanId === "string" ? ctx.metadata.__krnlTelemetryParentSpanId : void 0;
|
|
658
|
+
const handle = this.telemetry.begin(op, "service", ctx.correlationId, parentSpanId);
|
|
659
|
+
try {
|
|
660
|
+
const output = await operation.handler(input, ctx);
|
|
661
|
+
handle.end();
|
|
662
|
+
return output;
|
|
663
|
+
} catch (error) {
|
|
664
|
+
handle.end(error);
|
|
665
|
+
throw error;
|
|
666
|
+
}
|
|
171
667
|
}
|
|
172
668
|
getState() {
|
|
173
669
|
return this.stateStore?.getState() ?? Object.freeze({});
|
|
@@ -179,12 +675,6 @@ var ServiceInstance = class {
|
|
|
179
675
|
}
|
|
180
676
|
this.stateStore.setState(mutation);
|
|
181
677
|
}
|
|
182
|
-
on(event, handler) {
|
|
183
|
-
return this.eventBus.on(event, handler);
|
|
184
|
-
}
|
|
185
|
-
emit(event, payload) {
|
|
186
|
-
this.eventBus.emit(event, payload);
|
|
187
|
-
}
|
|
188
678
|
};
|
|
189
679
|
function assertRecord(value, field) {
|
|
190
680
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -218,12 +708,6 @@ function validateServiceDefinition(definition) {
|
|
|
218
708
|
throw new Error("[Service:" + definition.name + "] Operation '" + key + "' must define a handler.");
|
|
219
709
|
}
|
|
220
710
|
}
|
|
221
|
-
for (const [key, event] of Object.entries(definition.events ?? {})) {
|
|
222
|
-
if (!event || typeof event !== "object") {
|
|
223
|
-
throw new Error("[Service:" + definition.name + "] Invalid event '" + key + "'.");
|
|
224
|
-
}
|
|
225
|
-
assertNonEmptyString(event.name, "events." + key + ".name");
|
|
226
|
-
}
|
|
227
711
|
for (const [key, schema] of Object.entries(definition.inputs ?? {})) assertRecord(schema, "inputs." + key);
|
|
228
712
|
for (const [key, schema] of Object.entries(definition.outputs ?? {})) assertRecord(schema, "outputs." + key);
|
|
229
713
|
if (definition.state?.schema !== void 0) assertRecord(definition.state.schema, "state.schema");
|
|
@@ -549,9 +1033,9 @@ function objectDiff(before, after) {
|
|
|
549
1033
|
}
|
|
550
1034
|
return { added, removed, changed };
|
|
551
1035
|
}
|
|
552
|
-
function getPath(obj,
|
|
553
|
-
if (!
|
|
554
|
-
const parts =
|
|
1036
|
+
function getPath(obj, path7, defaultValue) {
|
|
1037
|
+
if (!path7) return obj;
|
|
1038
|
+
const parts = path7.split(".");
|
|
555
1039
|
let current = obj;
|
|
556
1040
|
for (const part of parts) {
|
|
557
1041
|
if (current === null || current === void 0) {
|
|
@@ -561,9 +1045,9 @@ function getPath(obj, path6, defaultValue) {
|
|
|
561
1045
|
}
|
|
562
1046
|
return current !== void 0 ? current : defaultValue;
|
|
563
1047
|
}
|
|
564
|
-
function setPath(obj,
|
|
565
|
-
if (!
|
|
566
|
-
const parts =
|
|
1048
|
+
function setPath(obj, path7, value) {
|
|
1049
|
+
if (!path7) return obj;
|
|
1050
|
+
const parts = path7.split(".");
|
|
567
1051
|
let current = obj;
|
|
568
1052
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
569
1053
|
const part = parts[i];
|
|
@@ -577,8 +1061,8 @@ function setPath(obj, path6, value) {
|
|
|
577
1061
|
}
|
|
578
1062
|
|
|
579
1063
|
// src/cache.ts
|
|
580
|
-
import
|
|
581
|
-
import
|
|
1064
|
+
import fs2 from "fs";
|
|
1065
|
+
import path2 from "path";
|
|
582
1066
|
var LRUCache = class {
|
|
583
1067
|
maxSize;
|
|
584
1068
|
cache;
|
|
@@ -660,20 +1144,20 @@ var FileCache = class {
|
|
|
660
1144
|
constructor(cacheDir) {
|
|
661
1145
|
this.cacheDir = cacheDir;
|
|
662
1146
|
try {
|
|
663
|
-
if (!
|
|
664
|
-
|
|
1147
|
+
if (!fs2.existsSync(cacheDir)) {
|
|
1148
|
+
fs2.mkdirSync(cacheDir, { recursive: true });
|
|
665
1149
|
}
|
|
666
1150
|
} catch (e) {
|
|
667
1151
|
}
|
|
668
1152
|
}
|
|
669
1153
|
getFilePath(key) {
|
|
670
|
-
return
|
|
1154
|
+
return path2.join(this.cacheDir, `${encodeURIComponent(key)}.json`);
|
|
671
1155
|
}
|
|
672
1156
|
get(key) {
|
|
673
1157
|
const file = this.getFilePath(key);
|
|
674
|
-
if (!
|
|
1158
|
+
if (!fs2.existsSync(file)) return null;
|
|
675
1159
|
try {
|
|
676
|
-
const content =
|
|
1160
|
+
const content = fs2.readFileSync(file, "utf8");
|
|
677
1161
|
return JSON.parse(content);
|
|
678
1162
|
} catch (e) {
|
|
679
1163
|
return null;
|
|
@@ -682,24 +1166,24 @@ var FileCache = class {
|
|
|
682
1166
|
set(key, value) {
|
|
683
1167
|
const file = this.getFilePath(key);
|
|
684
1168
|
try {
|
|
685
|
-
|
|
1169
|
+
fs2.writeFileSync(file, JSON.stringify(value, null, 2), "utf8");
|
|
686
1170
|
} catch (e) {
|
|
687
1171
|
}
|
|
688
1172
|
}
|
|
689
1173
|
delete(key) {
|
|
690
1174
|
const file = this.getFilePath(key);
|
|
691
|
-
if (
|
|
1175
|
+
if (fs2.existsSync(file)) {
|
|
692
1176
|
try {
|
|
693
|
-
|
|
1177
|
+
fs2.unlinkSync(file);
|
|
694
1178
|
} catch (e) {
|
|
695
1179
|
}
|
|
696
1180
|
}
|
|
697
1181
|
}
|
|
698
1182
|
clear() {
|
|
699
1183
|
try {
|
|
700
|
-
const files =
|
|
1184
|
+
const files = fs2.readdirSync(this.cacheDir);
|
|
701
1185
|
for (const file of files) {
|
|
702
|
-
|
|
1186
|
+
fs2.unlinkSync(path2.join(this.cacheDir, file));
|
|
703
1187
|
}
|
|
704
1188
|
} catch (e) {
|
|
705
1189
|
}
|
|
@@ -707,8 +1191,8 @@ var FileCache = class {
|
|
|
707
1191
|
};
|
|
708
1192
|
|
|
709
1193
|
// src/env.ts
|
|
710
|
-
import
|
|
711
|
-
import
|
|
1194
|
+
import fs3 from "fs";
|
|
1195
|
+
import path3 from "path";
|
|
712
1196
|
function getEnv(key, defaultValue) {
|
|
713
1197
|
const val = process.env[key];
|
|
714
1198
|
if (val === void 0) {
|
|
@@ -741,10 +1225,10 @@ function requireEnv(key) {
|
|
|
741
1225
|
return val;
|
|
742
1226
|
}
|
|
743
1227
|
function loadEnv(filePath) {
|
|
744
|
-
const file = filePath ||
|
|
745
|
-
if (!
|
|
1228
|
+
const file = filePath || path3.join(process.cwd(), ".env");
|
|
1229
|
+
if (!fs3.existsSync(file)) return;
|
|
746
1230
|
try {
|
|
747
|
-
const content =
|
|
1231
|
+
const content = fs3.readFileSync(file, "utf8");
|
|
748
1232
|
const lines = content.split(/\r?\n/);
|
|
749
1233
|
for (const line of lines) {
|
|
750
1234
|
const trimmed = line.trim();
|
|
@@ -798,16 +1282,16 @@ async function requestRaw(url, opts = {}) {
|
|
|
798
1282
|
const retries = opts.retries || 0;
|
|
799
1283
|
const perform = async () => {
|
|
800
1284
|
const controller = new AbortController();
|
|
801
|
-
const
|
|
1285
|
+
const id2 = setTimeout(() => controller.abort(), timeout);
|
|
802
1286
|
try {
|
|
803
1287
|
const response = await fetch(url, {
|
|
804
1288
|
...opts,
|
|
805
1289
|
signal: controller.signal
|
|
806
1290
|
});
|
|
807
|
-
clearTimeout(
|
|
1291
|
+
clearTimeout(id2);
|
|
808
1292
|
return response;
|
|
809
1293
|
} catch (e) {
|
|
810
|
-
clearTimeout(
|
|
1294
|
+
clearTimeout(id2);
|
|
811
1295
|
throw e;
|
|
812
1296
|
}
|
|
813
1297
|
};
|
|
@@ -872,10 +1356,10 @@ async function del(url, opts = {}) {
|
|
|
872
1356
|
}
|
|
873
1357
|
function createClient(baseUrl, defaultHeaders = {}) {
|
|
874
1358
|
return {
|
|
875
|
-
get: (
|
|
876
|
-
post: (
|
|
877
|
-
put: (
|
|
878
|
-
del: (
|
|
1359
|
+
get: (path7, opts = {}) => get(`${baseUrl}${path7}`, { ...opts, headers: { ...defaultHeaders, ...opts.headers } }),
|
|
1360
|
+
post: (path7, body, opts = {}) => post(`${baseUrl}${path7}`, body, { ...opts, headers: { ...defaultHeaders, ...opts.headers } }),
|
|
1361
|
+
put: (path7, body, opts = {}) => put(`${baseUrl}${path7}`, body, { ...opts, headers: { ...defaultHeaders, ...opts.headers } }),
|
|
1362
|
+
del: (path7, opts = {}) => del(`${baseUrl}${path7}`, { ...opts, headers: { ...defaultHeaders, ...opts.headers } })
|
|
879
1363
|
};
|
|
880
1364
|
}
|
|
881
1365
|
async function* streamResponse(url, opts = {}) {
|
|
@@ -898,8 +1382,8 @@ async function* streamResponse(url, opts = {}) {
|
|
|
898
1382
|
|
|
899
1383
|
// src/shell.ts
|
|
900
1384
|
import childProcess from "child_process";
|
|
901
|
-
import
|
|
902
|
-
import
|
|
1385
|
+
import path4 from "path";
|
|
1386
|
+
import fs4 from "fs";
|
|
903
1387
|
function execCmd(cmd, opts = {}) {
|
|
904
1388
|
const timeout = opts.timeout || 3e4;
|
|
905
1389
|
return new Promise((resolve, reject) => {
|
|
@@ -935,13 +1419,13 @@ function platform(routing) {
|
|
|
935
1419
|
}
|
|
936
1420
|
function which(cmd) {
|
|
937
1421
|
const envPath = process.env.PATH || "";
|
|
938
|
-
const paths = envPath.split(
|
|
1422
|
+
const paths = envPath.split(path4.delimiter);
|
|
939
1423
|
const extensions = process.platform === "win32" ? [".exe", ".cmd", ".bat", ""] : [""];
|
|
940
1424
|
for (const p of paths) {
|
|
941
1425
|
for (const ext of extensions) {
|
|
942
|
-
const fullPath =
|
|
1426
|
+
const fullPath = path4.join(p, `${cmd}${ext}`);
|
|
943
1427
|
try {
|
|
944
|
-
if (
|
|
1428
|
+
if (fs4.existsSync(fullPath) && fs4.statSync(fullPath).isFile()) {
|
|
945
1429
|
return fullPath;
|
|
946
1430
|
}
|
|
947
1431
|
} catch (e) {
|
|
@@ -952,11 +1436,11 @@ function which(cmd) {
|
|
|
952
1436
|
}
|
|
953
1437
|
|
|
954
1438
|
// src/fs-lock.ts
|
|
955
|
-
import
|
|
1439
|
+
import path5 from "path";
|
|
956
1440
|
var FileLock = class _FileLock {
|
|
957
1441
|
static locks = /* @__PURE__ */ new Map();
|
|
958
1442
|
static async acquire(filePath) {
|
|
959
|
-
const resolvedPath =
|
|
1443
|
+
const resolvedPath = path5.resolve(filePath);
|
|
960
1444
|
const existing = _FileLock.locks.get(resolvedPath) || Promise.resolve();
|
|
961
1445
|
let release = () => {
|
|
962
1446
|
};
|
|
@@ -973,10 +1457,10 @@ var FileLock = class _FileLock {
|
|
|
973
1457
|
};
|
|
974
1458
|
|
|
975
1459
|
// src/fs.ts
|
|
976
|
-
import
|
|
1460
|
+
import fs5 from "fs";
|
|
977
1461
|
import fsp from "fs/promises";
|
|
978
|
-
import
|
|
979
|
-
import
|
|
1462
|
+
import path6 from "path";
|
|
1463
|
+
import os2 from "os";
|
|
980
1464
|
async function readFile(filePath, encoding = "utf8") {
|
|
981
1465
|
return await fsp.readFile(filePath, encoding);
|
|
982
1466
|
}
|
|
@@ -984,14 +1468,14 @@ async function writeFile(filePath, content) {
|
|
|
984
1468
|
await fsp.writeFile(filePath, content);
|
|
985
1469
|
}
|
|
986
1470
|
async function writeFileAtomic(filePath, content) {
|
|
987
|
-
const dir =
|
|
1471
|
+
const dir = path6.dirname(filePath);
|
|
988
1472
|
await ensureDir(dir);
|
|
989
|
-
const tempFile =
|
|
1473
|
+
const tempFile = path6.join(dir, `.${path6.basename(filePath)}.tmp_${Date.now()}_${Math.random().toString(36).substring(7)}`);
|
|
990
1474
|
try {
|
|
991
1475
|
await fsp.writeFile(tempFile, content);
|
|
992
1476
|
await fsp.rename(tempFile, filePath);
|
|
993
1477
|
} catch (e) {
|
|
994
|
-
if (
|
|
1478
|
+
if (fs5.existsSync(tempFile)) {
|
|
995
1479
|
await fsp.unlink(tempFile).catch(() => {
|
|
996
1480
|
});
|
|
997
1481
|
}
|
|
@@ -1059,7 +1543,7 @@ async function listDir(dirPath) {
|
|
|
1059
1543
|
async function* walkDir(dirPath, filter) {
|
|
1060
1544
|
const list = await listDir(dirPath);
|
|
1061
1545
|
for (const item of list) {
|
|
1062
|
-
const full =
|
|
1546
|
+
const full = path6.join(dirPath, item);
|
|
1063
1547
|
const stat = await getFileStat(full);
|
|
1064
1548
|
if (stat.isDir) {
|
|
1065
1549
|
yield* walkDir(full, filter);
|
|
@@ -1082,8 +1566,8 @@ async function copyDir(src, dest) {
|
|
|
1082
1566
|
await ensureDir(dest);
|
|
1083
1567
|
const list = await listDir(src);
|
|
1084
1568
|
for (const item of list) {
|
|
1085
|
-
const srcItem =
|
|
1086
|
-
const destItem =
|
|
1569
|
+
const srcItem = path6.join(src, item);
|
|
1570
|
+
const destItem = path6.join(dest, item);
|
|
1087
1571
|
const stat = await getFileStat(srcItem);
|
|
1088
1572
|
if (stat.isDir) {
|
|
1089
1573
|
await copyDir(srcItem, destItem);
|
|
@@ -1102,24 +1586,24 @@ async function firstExisting(candidates) {
|
|
|
1102
1586
|
}
|
|
1103
1587
|
function watchFile(filePath, handler, debounceMs = 100) {
|
|
1104
1588
|
let timer = null;
|
|
1105
|
-
return
|
|
1589
|
+
return fs5.watch(filePath, (event) => {
|
|
1106
1590
|
if (timer) clearTimeout(timer);
|
|
1107
1591
|
timer = setTimeout(() => handler(event), debounceMs);
|
|
1108
1592
|
});
|
|
1109
1593
|
}
|
|
1110
1594
|
function watchDir(dirPath, handler, debounceMs = 100) {
|
|
1111
1595
|
let timer = null;
|
|
1112
|
-
return
|
|
1596
|
+
return fs5.watch(dirPath, (event, filename) => {
|
|
1113
1597
|
if (timer) clearTimeout(timer);
|
|
1114
1598
|
timer = setTimeout(() => handler(event, filename), debounceMs);
|
|
1115
1599
|
});
|
|
1116
1600
|
}
|
|
1117
1601
|
function createTempFile(prefix = "tmp-") {
|
|
1118
|
-
return
|
|
1602
|
+
return path6.join(os2.tmpdir(), `${prefix}${Math.random().toString(36).substring(7)}.tmp`);
|
|
1119
1603
|
}
|
|
1120
1604
|
function createTempDir(prefix = "tmp-dir-") {
|
|
1121
|
-
const dir =
|
|
1122
|
-
|
|
1605
|
+
const dir = path6.join(os2.tmpdir(), `${prefix}${Math.random().toString(36).substring(7)}`);
|
|
1606
|
+
fs5.mkdirSync(dir, { recursive: true });
|
|
1123
1607
|
return dir;
|
|
1124
1608
|
}
|
|
1125
1609
|
async function withTempDir(fn, prefix = "tmp-") {
|
|
@@ -1219,6 +1703,9 @@ var FunctionsServiceFacade = {
|
|
|
1219
1703
|
runtime: "server",
|
|
1220
1704
|
deployment: "local",
|
|
1221
1705
|
definition: FunctionsServiceDefinition,
|
|
1706
|
+
get telemetry() {
|
|
1707
|
+
return defaultFunctionsService.telemetry;
|
|
1708
|
+
},
|
|
1222
1709
|
createInstance: () => createService(FunctionsServiceDefinition),
|
|
1223
1710
|
execute: async (op, input) => {
|
|
1224
1711
|
await defaultFunctionsService.start();
|