nuabase 2.3.7 → 3.0.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/CHANGELOG.md +58 -0
- package/README.md +233 -200
- package/dist/chunks/local-agent-Bj-QKikS.d.cts +270 -0
- package/dist/chunks/local-agent-Bj-QKikS.d.mts +270 -0
- package/dist/cjs/chunks/strict-json-schema-bKwaMWm1.cjs +145 -0
- package/dist/cjs/index.cjs +991 -11473
- package/dist/cjs/local-agent.cjs +809 -953
- package/dist/esm/chunks/strict-json-schema-Du2LLrVP.mjs +138 -0
- package/dist/esm/index.mjs +989 -11471
- package/dist/esm/local-agent.mjs +782 -954
- package/dist/index.d.cts +94 -0
- package/dist/index.d.mts +94 -0
- package/dist/local-agent.d.cts +150 -0
- package/dist/local-agent.d.mts +150 -0
- package/package.json +12 -24
- package/dist/cjs/chunks/logger-Co5uZG0A.cjs +0 -90
- package/dist/esm/chunks/logger-DnkHzkX_.mjs +0 -88
- package/dist/types/__tests__/helpers/client-factory.d.ts +0 -39
- package/dist/types/__tests__/helpers/index.d.ts +0 -2
- package/dist/types/backend/direct.d.ts +0 -29
- package/dist/types/backend/gateway.d.ts +0 -24
- package/dist/types/backend/types.d.ts +0 -68
- package/dist/types/index.d.cts +0 -7
- package/dist/types/index.d.mts +0 -7
- package/dist/types/lib/auth.d.ts +0 -14
- package/dist/types/lib/env.d.ts +0 -1
- package/dist/types/lib/error-response.d.ts +0 -6
- package/dist/types/lib/error-utils.d.ts +0 -6
- package/dist/types/local-agent.d.cts +0 -2
- package/dist/types/local-agent.d.mts +0 -2
- package/dist/types/nua-llm-core/index.d.ts +0 -23
- package/dist/types/nua-llm-core/lib/error-utils.d.ts +0 -6
- package/dist/types/nua-llm-core/lib/logger.d.ts +0 -44
- package/dist/types/nua-llm-core/lib/nua-errors.d.ts +0 -12
- package/dist/types/nua-llm-core/lib/prompt-template-utils.d.ts +0 -2
- package/dist/types/nua-llm-core/lib/schema-utils.d.ts +0 -1
- package/dist/types/nua-llm-core/lib/stable-stringify.d.ts +0 -1
- package/dist/types/nua-llm-core/lib/strict-json-schema.d.ts +0 -7
- package/dist/types/nua-llm-core/lib/types.d.ts +0 -8
- package/dist/types/nua-llm-core/lib/validate-mappable-input-data.d.ts +0 -4
- package/dist/types/nua-llm-core/local-agent.d.ts +0 -7
- package/dist/types/nua-llm-core/modules/agent/agent-loop.d.ts +0 -10
- package/dist/types/nua-llm-core/modules/agent/agent-turn.d.ts +0 -17
- package/dist/types/nua-llm-core/modules/agent/provider-formatters.d.ts +0 -22
- package/dist/types/nua-llm-core/modules/agent/run-agent.d.ts +0 -7
- package/dist/types/nua-llm-core/modules/agent/types.d.ts +0 -90
- package/dist/types/nua-llm-core/modules/cast/cast-request.d.ts +0 -32
- package/dist/types/nua-llm-core/modules/cast/envelope.d.ts +0 -9
- package/dist/types/nua-llm-core/modules/cast/list-schema.d.ts +0 -32
- package/dist/types/nua-llm-core/modules/cast/prompts/list-prompt.d.ts +0 -3
- package/dist/types/nua-llm-core/modules/cast/prompts/render-prompt.d.ts +0 -7
- package/dist/types/nua-llm-core/modules/cast/prompts/value-prompt.d.ts +0 -3
- package/dist/types/nua-llm-core/modules/cast/run-cast.d.ts +0 -44
- package/dist/types/nua-llm-core/modules/engine/engine-router.d.ts +0 -23
- package/dist/types/nua-llm-core/modules/engine/http/http-engine.d.ts +0 -12
- package/dist/types/nua-llm-core/modules/engine/http/provider-call.d.ts +0 -33
- package/dist/types/nua-llm-core/modules/engine/http/provider-config.d.ts +0 -65
- package/dist/types/nua-llm-core/modules/engine/http/provider-engines.d.ts +0 -35
- package/dist/types/nua-llm-core/modules/engine/llm-engine.d.ts +0 -73
- package/dist/types/nua-llm-core/modules/engine/local-agent/adapters/claude-code.d.ts +0 -2
- package/dist/types/nua-llm-core/modules/engine/local-agent/adapters/codex.d.ts +0 -2
- package/dist/types/nua-llm-core/modules/engine/local-agent/adapters/failure-classification.d.ts +0 -4
- package/dist/types/nua-llm-core/modules/engine/local-agent/adapters/index.d.ts +0 -3
- package/dist/types/nua-llm-core/modules/engine/local-agent/adapters/pi.d.ts +0 -2
- package/dist/types/nua-llm-core/modules/engine/local-agent/adapters/types.d.ts +0 -61
- package/dist/types/nua-llm-core/modules/engine/local-agent/agent-id.d.ts +0 -4
- package/dist/types/nua-llm-core/modules/engine/local-agent/create-local-agent.d.ts +0 -36
- package/dist/types/nua-llm-core/modules/engine/local-agent/detect.d.ts +0 -20
- package/dist/types/nua-llm-core/modules/engine/local-agent/local-agent-engine.d.ts +0 -32
- package/dist/types/nua-llm-core/modules/engine/local-agent/local-agent.d.ts +0 -25
- package/dist/types/nua-llm-core/modules/engine/local-agent/process-runner.d.ts +0 -16
- package/dist/types/nua-llm-core/modules/engine/local-agent/semaphore.d.ts +0 -8
- package/dist/types/nua-llm-core/modules/execution/llm-response-extraction.d.ts +0 -5
- package/dist/types/nua-llm-core/modules/json-schema-validation/ajv-instances.d.ts +0 -12
- package/dist/types/nua-llm-core/modules/json-schema-validation/nua-json-schema-value-validation.d.ts +0 -10
- package/dist/types/nua-llm-core/modules/json-schema-validation/validate-json-schema.d.ts +0 -2
- package/dist/types/nua-llm-core/modules/model-info/index.d.ts +0 -15
- package/dist/types/nua-llm-core/modules/streaming/sse-parser.d.ts +0 -7
- package/dist/types/nua-llm-core/nua-llm-client.d.ts +0 -37
- package/dist/types/nua.d.ts +0 -42
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
class ConsoleLogger {
|
|
2
|
+
debug(message, context) {
|
|
3
|
+
console.debug(`[DEBUG] ${message}`, context || "");
|
|
4
|
+
}
|
|
5
|
+
info(message, context) {
|
|
6
|
+
console.info(`[INFO] ${message}`, context || "");
|
|
7
|
+
}
|
|
8
|
+
warn(message, context) {
|
|
9
|
+
console.warn(`[WARN] ${message}`, context || "");
|
|
10
|
+
}
|
|
11
|
+
error(message, context) {
|
|
12
|
+
console.error(`[ERROR] ${message}`, context || "");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const generateSpanId = () => crypto.randomUUID();
|
|
16
|
+
function pickHeaders(headers, allowlist, redactSet) {
|
|
17
|
+
const result = {};
|
|
18
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
19
|
+
const lowerKey = key.toLowerCase();
|
|
20
|
+
if (allowlist.has(lowerKey)) {
|
|
21
|
+
result[key] = Array.isArray(value) ? value.join(", ") : value ?? "";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
function normalizeError(error) {
|
|
27
|
+
return error instanceof Error ? { message: error.message, stack: error.stack } : String(error);
|
|
28
|
+
}
|
|
29
|
+
const LLM_RESPONSE_HEADER_ALLOWLIST = /* @__PURE__ */ new Set([
|
|
30
|
+
"x-request-id",
|
|
31
|
+
"x-ratelimit-limit-requests",
|
|
32
|
+
"x-ratelimit-limit-tokens",
|
|
33
|
+
"x-ratelimit-remaining-requests",
|
|
34
|
+
"x-ratelimit-remaining-tokens",
|
|
35
|
+
"x-groq-region"
|
|
36
|
+
]);
|
|
37
|
+
const logLlmCallStart = (logger, spanId, service, method, request) => {
|
|
38
|
+
logger.info("LLM call started", {
|
|
39
|
+
type: "llm_call_start",
|
|
40
|
+
span_id: spanId,
|
|
41
|
+
service,
|
|
42
|
+
method,
|
|
43
|
+
...request
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const logLlmCallComplete = (logger, spanId, service, method, response, duration) => {
|
|
47
|
+
const { headers, ...rest } = response;
|
|
48
|
+
logger.info("LLM call completed", {
|
|
49
|
+
type: "llm_call_complete",
|
|
50
|
+
span_id: spanId,
|
|
51
|
+
service,
|
|
52
|
+
method,
|
|
53
|
+
...rest,
|
|
54
|
+
...pickHeaders(headers, LLM_RESPONSE_HEADER_ALLOWLIST),
|
|
55
|
+
duration_ms: duration
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
const logLlmCallError = (logger, spanId, service, method, error, duration) => {
|
|
59
|
+
logger.error("LLM call failed", {
|
|
60
|
+
type: "llm_call_error",
|
|
61
|
+
span_id: spanId,
|
|
62
|
+
service,
|
|
63
|
+
method,
|
|
64
|
+
error: normalizeError(error),
|
|
65
|
+
duration_ms: duration
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const STRICT_UNSUPPORTED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
70
|
+
"patternProperties",
|
|
71
|
+
"propertyNames",
|
|
72
|
+
"unevaluatedProperties",
|
|
73
|
+
"dependentRequired",
|
|
74
|
+
"dependentSchemas",
|
|
75
|
+
"if",
|
|
76
|
+
"then",
|
|
77
|
+
"else",
|
|
78
|
+
"not",
|
|
79
|
+
"allOf",
|
|
80
|
+
"oneOf"
|
|
81
|
+
]);
|
|
82
|
+
function toStrictSchema(schema) {
|
|
83
|
+
return strictNode(schema);
|
|
84
|
+
}
|
|
85
|
+
function strictNode(node) {
|
|
86
|
+
if (typeof node !== "object" || node === null || Array.isArray(node)) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const schema = node;
|
|
90
|
+
for (const key of Object.keys(schema)) {
|
|
91
|
+
if (STRICT_UNSUPPORTED_KEYWORDS.has(key)) return null;
|
|
92
|
+
}
|
|
93
|
+
const result = { ...schema };
|
|
94
|
+
delete result.$schema;
|
|
95
|
+
const isObject = schema.type === "object" || Array.isArray(schema.type) && schema.type.includes("object") || schema.properties !== void 0;
|
|
96
|
+
if (isObject) {
|
|
97
|
+
const properties = schema.properties ?? {};
|
|
98
|
+
if (schema.additionalProperties !== void 0 && schema.additionalProperties !== false) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const required = new Set(schema.required ?? []);
|
|
102
|
+
const shapedProperties = {};
|
|
103
|
+
for (const [name, child] of Object.entries(properties)) {
|
|
104
|
+
if (!required.has(name)) return null;
|
|
105
|
+
const shaped = strictNode(child);
|
|
106
|
+
if (!shaped) return null;
|
|
107
|
+
shapedProperties[name] = shaped;
|
|
108
|
+
}
|
|
109
|
+
result.properties = shapedProperties;
|
|
110
|
+
result.required = Object.keys(shapedProperties);
|
|
111
|
+
result.additionalProperties = false;
|
|
112
|
+
}
|
|
113
|
+
if (schema.items !== void 0) {
|
|
114
|
+
const shaped = strictNode(schema.items);
|
|
115
|
+
if (!shaped) return null;
|
|
116
|
+
result.items = shaped;
|
|
117
|
+
}
|
|
118
|
+
if (schema.prefixItems !== void 0) return null;
|
|
119
|
+
if (schema.anyOf !== void 0) {
|
|
120
|
+
const variants = schema.anyOf.map(strictNode);
|
|
121
|
+
if (variants.some((v) => v === null)) return null;
|
|
122
|
+
result.anyOf = variants;
|
|
123
|
+
}
|
|
124
|
+
for (const defsKey of ["$defs", "definitions"]) {
|
|
125
|
+
if (schema[defsKey] !== void 0) {
|
|
126
|
+
const defs = {};
|
|
127
|
+
for (const [name, child] of Object.entries(schema[defsKey])) {
|
|
128
|
+
const shaped = strictNode(child);
|
|
129
|
+
if (!shaped) return null;
|
|
130
|
+
defs[name] = shaped;
|
|
131
|
+
}
|
|
132
|
+
result[defsKey] = defs;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { ConsoleLogger as C, logLlmCallComplete as a, logLlmCallError as b, generateSpanId as g, logLlmCallStart as l, toStrictSchema as t };
|