nuabase 2.3.11 → 3.0.1

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 (80) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +233 -200
  3. package/dist/chunks/local-agent-Bj-QKikS.d.cts +270 -0
  4. package/dist/chunks/local-agent-Bj-QKikS.d.mts +270 -0
  5. package/dist/cjs/chunks/strict-json-schema-bKwaMWm1.cjs +145 -0
  6. package/dist/cjs/index.cjs +989 -11504
  7. package/dist/cjs/local-agent.cjs +819 -877
  8. package/dist/esm/chunks/strict-json-schema-Du2LLrVP.mjs +138 -0
  9. package/dist/esm/index.mjs +987 -11502
  10. package/dist/esm/local-agent.mjs +792 -878
  11. package/dist/index.d.cts +94 -0
  12. package/dist/index.d.mts +94 -0
  13. package/dist/local-agent.d.cts +150 -0
  14. package/dist/local-agent.d.mts +150 -0
  15. package/package.json +12 -17
  16. package/dist/cjs/chunks/strict-json-schema-DUE7RTxG.cjs +0 -177
  17. package/dist/esm/chunks/strict-json-schema-DI9qiH5h.mjs +0 -174
  18. package/dist/types/__tests__/helpers/client-factory.d.ts +0 -39
  19. package/dist/types/__tests__/helpers/index.d.ts +0 -2
  20. package/dist/types/backend/direct.d.ts +0 -29
  21. package/dist/types/backend/gateway.d.ts +0 -24
  22. package/dist/types/backend/types.d.ts +0 -68
  23. package/dist/types/index.d.cts +0 -7
  24. package/dist/types/index.d.mts +0 -7
  25. package/dist/types/lib/auth.d.ts +0 -14
  26. package/dist/types/lib/env.d.ts +0 -1
  27. package/dist/types/lib/error-response.d.ts +0 -6
  28. package/dist/types/lib/error-utils.d.ts +0 -6
  29. package/dist/types/local-agent.d.cts +0 -2
  30. package/dist/types/local-agent.d.mts +0 -2
  31. package/dist/types/nua-llm-core/index.d.ts +0 -23
  32. package/dist/types/nua-llm-core/lib/error-utils.d.ts +0 -6
  33. package/dist/types/nua-llm-core/lib/logger.d.ts +0 -44
  34. package/dist/types/nua-llm-core/lib/nua-errors.d.ts +0 -12
  35. package/dist/types/nua-llm-core/lib/prompt-template-utils.d.ts +0 -2
  36. package/dist/types/nua-llm-core/lib/schema-utils.d.ts +0 -1
  37. package/dist/types/nua-llm-core/lib/stable-stringify.d.ts +0 -1
  38. package/dist/types/nua-llm-core/lib/strict-json-schema.d.ts +0 -7
  39. package/dist/types/nua-llm-core/lib/types.d.ts +0 -8
  40. package/dist/types/nua-llm-core/lib/validate-mappable-input-data.d.ts +0 -4
  41. package/dist/types/nua-llm-core/local-agent.d.ts +0 -7
  42. package/dist/types/nua-llm-core/modules/agent/agent-loop.d.ts +0 -10
  43. package/dist/types/nua-llm-core/modules/agent/agent-turn.d.ts +0 -17
  44. package/dist/types/nua-llm-core/modules/agent/provider-formatters.d.ts +0 -22
  45. package/dist/types/nua-llm-core/modules/agent/run-agent.d.ts +0 -7
  46. package/dist/types/nua-llm-core/modules/agent/types.d.ts +0 -90
  47. package/dist/types/nua-llm-core/modules/cast/cast-request.d.ts +0 -32
  48. package/dist/types/nua-llm-core/modules/cast/envelope.d.ts +0 -9
  49. package/dist/types/nua-llm-core/modules/cast/list-schema.d.ts +0 -32
  50. package/dist/types/nua-llm-core/modules/cast/prompts/list-prompt.d.ts +0 -3
  51. package/dist/types/nua-llm-core/modules/cast/prompts/render-prompt.d.ts +0 -7
  52. package/dist/types/nua-llm-core/modules/cast/prompts/value-prompt.d.ts +0 -3
  53. package/dist/types/nua-llm-core/modules/cast/run-cast.d.ts +0 -44
  54. package/dist/types/nua-llm-core/modules/engine/engine-router.d.ts +0 -23
  55. package/dist/types/nua-llm-core/modules/engine/http/http-engine.d.ts +0 -13
  56. package/dist/types/nua-llm-core/modules/engine/http/provider-call.d.ts +0 -33
  57. package/dist/types/nua-llm-core/modules/engine/http/provider-config.d.ts +0 -70
  58. package/dist/types/nua-llm-core/modules/engine/http/provider-engines.d.ts +0 -35
  59. package/dist/types/nua-llm-core/modules/engine/llm-engine.d.ts +0 -73
  60. package/dist/types/nua-llm-core/modules/engine/local-agent/adapters/claude-code.d.ts +0 -2
  61. package/dist/types/nua-llm-core/modules/engine/local-agent/adapters/codex.d.ts +0 -2
  62. package/dist/types/nua-llm-core/modules/engine/local-agent/adapters/failure-classification.d.ts +0 -4
  63. package/dist/types/nua-llm-core/modules/engine/local-agent/adapters/index.d.ts +0 -3
  64. package/dist/types/nua-llm-core/modules/engine/local-agent/adapters/pi.d.ts +0 -2
  65. package/dist/types/nua-llm-core/modules/engine/local-agent/adapters/types.d.ts +0 -61
  66. package/dist/types/nua-llm-core/modules/engine/local-agent/agent-id.d.ts +0 -4
  67. package/dist/types/nua-llm-core/modules/engine/local-agent/create-local-agent.d.ts +0 -36
  68. package/dist/types/nua-llm-core/modules/engine/local-agent/detect.d.ts +0 -20
  69. package/dist/types/nua-llm-core/modules/engine/local-agent/local-agent-engine.d.ts +0 -32
  70. package/dist/types/nua-llm-core/modules/engine/local-agent/local-agent.d.ts +0 -25
  71. package/dist/types/nua-llm-core/modules/engine/local-agent/process-runner.d.ts +0 -16
  72. package/dist/types/nua-llm-core/modules/engine/local-agent/semaphore.d.ts +0 -8
  73. package/dist/types/nua-llm-core/modules/execution/llm-response-extraction.d.ts +0 -5
  74. package/dist/types/nua-llm-core/modules/json-schema-validation/ajv-instances.d.ts +0 -12
  75. package/dist/types/nua-llm-core/modules/json-schema-validation/nua-json-schema-value-validation.d.ts +0 -10
  76. package/dist/types/nua-llm-core/modules/json-schema-validation/validate-json-schema.d.ts +0 -2
  77. package/dist/types/nua-llm-core/modules/model-info/index.d.ts +0 -15
  78. package/dist/types/nua-llm-core/modules/streaming/sse-parser.d.ts +0 -7
  79. package/dist/types/nua-llm-core/nua-llm-client.d.ts +0 -37
  80. package/dist/types/nua.d.ts +0 -42
@@ -1,177 +0,0 @@
1
- 'use strict';
2
-
3
- var logger = {};
4
-
5
- var hasRequiredLogger;
6
- function requireLogger() {
7
- if (hasRequiredLogger) return logger;
8
- hasRequiredLogger = 1;
9
- Object.defineProperty(logger, "__esModule", { value: true });
10
- logger.logLlmCallError = logger.logLlmCallComplete = logger.logLlmCallStart = logger.generateSpanId = logger.ConsoleLogger = void 0;
11
- logger.pickHeaders = pickHeaders;
12
- logger.normalizeError = normalizeError;
13
- class ConsoleLogger {
14
- debug(message, context) {
15
- console.debug(`[DEBUG] ${message}`, context || "");
16
- }
17
- info(message, context) {
18
- console.info(`[INFO] ${message}`, context || "");
19
- }
20
- warn(message, context) {
21
- console.warn(`[WARN] ${message}`, context || "");
22
- }
23
- error(message, context) {
24
- console.error(`[ERROR] ${message}`, context || "");
25
- }
26
- }
27
- logger.ConsoleLogger = ConsoleLogger;
28
- const generateSpanId = () => crypto.randomUUID();
29
- logger.generateSpanId = generateSpanId;
30
- function pickHeaders(headers, allowlist, redactSet) {
31
- const result = {};
32
- for (const [key, value] of Object.entries(headers)) {
33
- const lowerKey = key.toLowerCase();
34
- if (redactSet?.has(lowerKey)) {
35
- result[key] = "[REDACTED]";
36
- } else if (allowlist.has(lowerKey)) {
37
- result[key] = Array.isArray(value) ? value.join(", ") : value ?? "";
38
- }
39
- }
40
- return result;
41
- }
42
- function normalizeError(error) {
43
- return error instanceof Error ? { message: error.message, stack: error.stack } : String(error);
44
- }
45
- const LLM_RESPONSE_HEADER_ALLOWLIST = /* @__PURE__ */ new Set([
46
- "x-request-id",
47
- "x-ratelimit-limit-requests",
48
- "x-ratelimit-limit-tokens",
49
- "x-ratelimit-remaining-requests",
50
- "x-ratelimit-remaining-tokens",
51
- "x-groq-region"
52
- ]);
53
- const logLlmCallStart = (logger2, spanId, service, method, request) => {
54
- logger2.info("LLM call started", {
55
- type: "llm_call_start",
56
- span_id: spanId,
57
- service,
58
- method,
59
- ...request
60
- });
61
- };
62
- logger.logLlmCallStart = logLlmCallStart;
63
- const logLlmCallComplete = (logger2, spanId, service, method, response, duration) => {
64
- const { headers, ...rest } = response;
65
- logger2.info("LLM call completed", {
66
- type: "llm_call_complete",
67
- span_id: spanId,
68
- service,
69
- method,
70
- ...rest,
71
- ...pickHeaders(headers, LLM_RESPONSE_HEADER_ALLOWLIST),
72
- duration_ms: duration
73
- });
74
- };
75
- logger.logLlmCallComplete = logLlmCallComplete;
76
- const logLlmCallError = (logger2, spanId, service, method, error, duration) => {
77
- logger2.error("LLM call failed", {
78
- type: "llm_call_error",
79
- span_id: spanId,
80
- service,
81
- method,
82
- error: normalizeError(error),
83
- duration_ms: duration
84
- });
85
- };
86
- logger.logLlmCallError = logLlmCallError;
87
- return logger;
88
- }
89
-
90
- var strictJsonSchema = {};
91
-
92
- var hasRequiredStrictJsonSchema;
93
- function requireStrictJsonSchema() {
94
- if (hasRequiredStrictJsonSchema) return strictJsonSchema;
95
- hasRequiredStrictJsonSchema = 1;
96
- Object.defineProperty(strictJsonSchema, "__esModule", { value: true });
97
- strictJsonSchema.toStrictSchema = toStrictSchema;
98
- const STRICT_UNSUPPORTED_KEYWORDS = /* @__PURE__ */ new Set([
99
- "patternProperties",
100
- "propertyNames",
101
- "unevaluatedProperties",
102
- "dependentRequired",
103
- "dependentSchemas",
104
- "if",
105
- "then",
106
- "else",
107
- "not",
108
- "allOf",
109
- "oneOf"
110
- ]);
111
- function toStrictSchema(schema) {
112
- return strictNode(schema);
113
- }
114
- function strictNode(node) {
115
- if (typeof node !== "object" || node === null || Array.isArray(node)) {
116
- return null;
117
- }
118
- const schema = node;
119
- for (const key of Object.keys(schema)) {
120
- if (STRICT_UNSUPPORTED_KEYWORDS.has(key))
121
- return null;
122
- }
123
- const result = { ...schema };
124
- delete result.$schema;
125
- const isObject = schema.type === "object" || Array.isArray(schema.type) && schema.type.includes("object") || schema.properties !== void 0;
126
- if (isObject) {
127
- const properties = schema.properties ?? {};
128
- if (schema.additionalProperties !== void 0 && schema.additionalProperties !== false) {
129
- return null;
130
- }
131
- const required = new Set(schema.required ?? []);
132
- const shapedProperties = {};
133
- for (const [name, child] of Object.entries(properties)) {
134
- if (!required.has(name))
135
- return null;
136
- const shaped = strictNode(child);
137
- if (!shaped)
138
- return null;
139
- shapedProperties[name] = shaped;
140
- }
141
- result.properties = shapedProperties;
142
- result.required = Object.keys(shapedProperties);
143
- result.additionalProperties = false;
144
- }
145
- if (schema.items !== void 0) {
146
- const shaped = strictNode(schema.items);
147
- if (!shaped)
148
- return null;
149
- result.items = shaped;
150
- }
151
- if (schema.prefixItems !== void 0)
152
- return null;
153
- if (schema.anyOf !== void 0) {
154
- const variants = schema.anyOf.map(strictNode);
155
- if (variants.some((v) => v === null))
156
- return null;
157
- result.anyOf = variants;
158
- }
159
- for (const defsKey of ["$defs", "definitions"]) {
160
- if (schema[defsKey] !== void 0) {
161
- const defs = {};
162
- for (const [name, child] of Object.entries(schema[defsKey])) {
163
- const shaped = strictNode(child);
164
- if (!shaped)
165
- return null;
166
- defs[name] = shaped;
167
- }
168
- result[defsKey] = defs;
169
- }
170
- }
171
- return result;
172
- }
173
- return strictJsonSchema;
174
- }
175
-
176
- exports.requireLogger = requireLogger;
177
- exports.requireStrictJsonSchema = requireStrictJsonSchema;
@@ -1,174 +0,0 @@
1
- var logger = {};
2
-
3
- var hasRequiredLogger;
4
- function requireLogger() {
5
- if (hasRequiredLogger) return logger;
6
- hasRequiredLogger = 1;
7
- Object.defineProperty(logger, "__esModule", { value: true });
8
- logger.logLlmCallError = logger.logLlmCallComplete = logger.logLlmCallStart = logger.generateSpanId = logger.ConsoleLogger = void 0;
9
- logger.pickHeaders = pickHeaders;
10
- logger.normalizeError = normalizeError;
11
- class ConsoleLogger {
12
- debug(message, context) {
13
- console.debug(`[DEBUG] ${message}`, context || "");
14
- }
15
- info(message, context) {
16
- console.info(`[INFO] ${message}`, context || "");
17
- }
18
- warn(message, context) {
19
- console.warn(`[WARN] ${message}`, context || "");
20
- }
21
- error(message, context) {
22
- console.error(`[ERROR] ${message}`, context || "");
23
- }
24
- }
25
- logger.ConsoleLogger = ConsoleLogger;
26
- const generateSpanId = () => crypto.randomUUID();
27
- logger.generateSpanId = generateSpanId;
28
- function pickHeaders(headers, allowlist, redactSet) {
29
- const result = {};
30
- for (const [key, value] of Object.entries(headers)) {
31
- const lowerKey = key.toLowerCase();
32
- if (redactSet?.has(lowerKey)) {
33
- result[key] = "[REDACTED]";
34
- } else if (allowlist.has(lowerKey)) {
35
- result[key] = Array.isArray(value) ? value.join(", ") : value ?? "";
36
- }
37
- }
38
- return result;
39
- }
40
- function normalizeError(error) {
41
- return error instanceof Error ? { message: error.message, stack: error.stack } : String(error);
42
- }
43
- const LLM_RESPONSE_HEADER_ALLOWLIST = /* @__PURE__ */ new Set([
44
- "x-request-id",
45
- "x-ratelimit-limit-requests",
46
- "x-ratelimit-limit-tokens",
47
- "x-ratelimit-remaining-requests",
48
- "x-ratelimit-remaining-tokens",
49
- "x-groq-region"
50
- ]);
51
- const logLlmCallStart = (logger2, spanId, service, method, request) => {
52
- logger2.info("LLM call started", {
53
- type: "llm_call_start",
54
- span_id: spanId,
55
- service,
56
- method,
57
- ...request
58
- });
59
- };
60
- logger.logLlmCallStart = logLlmCallStart;
61
- const logLlmCallComplete = (logger2, spanId, service, method, response, duration) => {
62
- const { headers, ...rest } = response;
63
- logger2.info("LLM call completed", {
64
- type: "llm_call_complete",
65
- span_id: spanId,
66
- service,
67
- method,
68
- ...rest,
69
- ...pickHeaders(headers, LLM_RESPONSE_HEADER_ALLOWLIST),
70
- duration_ms: duration
71
- });
72
- };
73
- logger.logLlmCallComplete = logLlmCallComplete;
74
- const logLlmCallError = (logger2, spanId, service, method, error, duration) => {
75
- logger2.error("LLM call failed", {
76
- type: "llm_call_error",
77
- span_id: spanId,
78
- service,
79
- method,
80
- error: normalizeError(error),
81
- duration_ms: duration
82
- });
83
- };
84
- logger.logLlmCallError = logLlmCallError;
85
- return logger;
86
- }
87
-
88
- var strictJsonSchema = {};
89
-
90
- var hasRequiredStrictJsonSchema;
91
- function requireStrictJsonSchema() {
92
- if (hasRequiredStrictJsonSchema) return strictJsonSchema;
93
- hasRequiredStrictJsonSchema = 1;
94
- Object.defineProperty(strictJsonSchema, "__esModule", { value: true });
95
- strictJsonSchema.toStrictSchema = toStrictSchema;
96
- const STRICT_UNSUPPORTED_KEYWORDS = /* @__PURE__ */ new Set([
97
- "patternProperties",
98
- "propertyNames",
99
- "unevaluatedProperties",
100
- "dependentRequired",
101
- "dependentSchemas",
102
- "if",
103
- "then",
104
- "else",
105
- "not",
106
- "allOf",
107
- "oneOf"
108
- ]);
109
- function toStrictSchema(schema) {
110
- return strictNode(schema);
111
- }
112
- function strictNode(node) {
113
- if (typeof node !== "object" || node === null || Array.isArray(node)) {
114
- return null;
115
- }
116
- const schema = node;
117
- for (const key of Object.keys(schema)) {
118
- if (STRICT_UNSUPPORTED_KEYWORDS.has(key))
119
- return null;
120
- }
121
- const result = { ...schema };
122
- delete result.$schema;
123
- const isObject = schema.type === "object" || Array.isArray(schema.type) && schema.type.includes("object") || schema.properties !== void 0;
124
- if (isObject) {
125
- const properties = schema.properties ?? {};
126
- if (schema.additionalProperties !== void 0 && schema.additionalProperties !== false) {
127
- return null;
128
- }
129
- const required = new Set(schema.required ?? []);
130
- const shapedProperties = {};
131
- for (const [name, child] of Object.entries(properties)) {
132
- if (!required.has(name))
133
- return null;
134
- const shaped = strictNode(child);
135
- if (!shaped)
136
- return null;
137
- shapedProperties[name] = shaped;
138
- }
139
- result.properties = shapedProperties;
140
- result.required = Object.keys(shapedProperties);
141
- result.additionalProperties = false;
142
- }
143
- if (schema.items !== void 0) {
144
- const shaped = strictNode(schema.items);
145
- if (!shaped)
146
- return null;
147
- result.items = shaped;
148
- }
149
- if (schema.prefixItems !== void 0)
150
- return null;
151
- if (schema.anyOf !== void 0) {
152
- const variants = schema.anyOf.map(strictNode);
153
- if (variants.some((v) => v === null))
154
- return null;
155
- result.anyOf = variants;
156
- }
157
- for (const defsKey of ["$defs", "definitions"]) {
158
- if (schema[defsKey] !== void 0) {
159
- const defs = {};
160
- for (const [name, child] of Object.entries(schema[defsKey])) {
161
- const shaped = strictNode(child);
162
- if (!shaped)
163
- return null;
164
- defs[name] = shaped;
165
- }
166
- result[defsKey] = defs;
167
- }
168
- }
169
- return result;
170
- }
171
- return strictJsonSchema;
172
- }
173
-
174
- export { requireStrictJsonSchema as a, requireLogger as r };
@@ -1,39 +0,0 @@
1
- import { Nua } from '../../nua';
2
- import type { LocalAgentId } from '../../nua-llm-core/index';
3
- /**
4
- * One way of running casts that the shared tests exercise:
5
- * - gateway: the Nuabase API at NUABASE_API_URL
6
- * - direct: LLM providers' APIs, with API keys
7
- * - local-agent: a coding-agent CLI on this machine, with its own login
8
- */
9
- export type TestMode = {
10
- name: string;
11
- } & ({
12
- kind: 'gateway';
13
- } | {
14
- kind: 'direct';
15
- } | {
16
- kind: 'local-agent';
17
- agent: LocalAgentId | 'auto';
18
- });
19
- /**
20
- * Returns the modes to run the shared tests in.
21
- * - gateway, unless SKIP_GATEWAY_TESTS is set.
22
- * - direct, when a provider API key is set, unless SKIP_DIRECT_TESTS is set.
23
- * - one local-agent mode per agent in NUA_LOCAL_AGENTS (e.g. "claude-code,codex", or "auto").
24
- */
25
- export declare function getTestModes(): TestMode[];
26
- /**
27
- * Creates a Nua client for the specified test mode.
28
- *
29
- * Gateway mode: Requires NUABASE_API_URL and NUABASE_API_KEY for a running Nuabase API
30
- * Direct mode: Requires one of GROQ_API_KEY, OPENROUTER_API_KEY, CEREBRAS_API_KEY, or GEMINI_API_KEY
31
- * Local-agent mode: Requires that agent installed and logged in on this machine
32
- */
33
- export declare function createTestClient(mode: TestMode): Promise<Nua>;
34
- /** The result `source` a mode produces: local agents run through the direct backend. */
35
- export declare function expectedSource(mode: TestMode): 'gateway' | 'direct';
36
- /** The part of a direct result's `meta` that says which engine answered. */
37
- export declare function expectedDirectMeta(mode: TestMode): Record<string, unknown>;
38
- /** Per-test time limit. A coding-agent CLI starts a process and may reason before answering. */
39
- export declare function testTimeoutMs(mode: TestMode): number;
@@ -1,2 +0,0 @@
1
- export { createTestClient, expectedDirectMeta, expectedSource, getTestModes, testTimeoutMs, } from './client-factory';
2
- export type { TestMode } from './client-factory';
@@ -1,29 +0,0 @@
1
- import { CastArrayParams, CastResult, CastValueParams, LlmBackend } from './types';
2
- import type { LlmProviderId, ModelInput } from '../nua-llm-core/index';
3
- import type { LocalAgent } from '../nua-llm-core/local-agent';
4
- /** API keys for the LLM providers direct mode may call. */
5
- export type ProviderApiKeys = {
6
- [key in LlmProviderId]?: {
7
- apiKey: string;
8
- };
9
- };
10
- /**
11
- * Either `providers`: API keys for LLM providers, with an optional default `model`.
12
- * Or `localAgent`: a coding-agent CLI on this machine, from `localAgent()` or
13
- * `findLocalAgent()` in "nuabase/local-agent".
14
- */
15
- export type DirectConfig = {
16
- providers: ProviderApiKeys;
17
- model?: ModelInput;
18
- localAgent?: never;
19
- } | {
20
- localAgent: LocalAgent;
21
- providers?: never;
22
- model?: never;
23
- };
24
- export declare class DirectBackend implements LlmBackend {
25
- private readonly client;
26
- constructor(config: DirectConfig);
27
- castValue<T>(params: CastValueParams): Promise<CastResult<T>>;
28
- castArray<T>(params: CastArrayParams): Promise<CastResult<T[]>>;
29
- }
@@ -1,24 +0,0 @@
1
- import { CastArrayParams, CastResult, CastValueParams, LlmBackend, QueueResult } from './types';
2
- type GatewayApiKeyConfig = {
3
- apiKey?: string;
4
- fetchToken?: never;
5
- baseUrl?: string;
6
- dangerouslyAllowBrowserApiKeyInLocalhost?: boolean;
7
- };
8
- type GatewayTokenConfig = {
9
- fetchToken: () => Promise<string>;
10
- apiKey?: never;
11
- baseUrl?: string;
12
- };
13
- export type GatewayConfig = GatewayApiKeyConfig | GatewayTokenConfig;
14
- export declare class GatewayBackend implements LlmBackend {
15
- private readonly baseUrl;
16
- private readonly authManager;
17
- constructor(config: GatewayConfig);
18
- castValue<T>(params: CastValueParams): Promise<CastResult<T>>;
19
- castArray<T>(params: CastArrayParams): Promise<CastResult<T[]>>;
20
- queueCastValue(params: CastValueParams): Promise<QueueResult>;
21
- queueCastArray(params: CastArrayParams): Promise<QueueResult>;
22
- private post;
23
- }
24
- export {};
@@ -1,68 +0,0 @@
1
- import type { AnswerOrigin, ModelInput, SchemaEnforcementKind } from '../nua-llm-core/index';
2
- export type CastValueParams = {
3
- prompt: string;
4
- data: unknown;
5
- outputName: string;
6
- outputSchema: object;
7
- model?: ModelInput;
8
- };
9
- export type CastArrayParams = {
10
- prompt: string;
11
- data: unknown[];
12
- primaryKey: string;
13
- outputName: string;
14
- outputSchema: object;
15
- model?: ModelInput;
16
- };
17
- export type NormalizedUsage = {
18
- promptTokens: number;
19
- completionTokens: number;
20
- totalTokens: number;
21
- };
22
- export type GatewayMeta = {
23
- requestId: string;
24
- cached: boolean;
25
- llmUsage: NormalizedUsage;
26
- cacheUsage: NormalizedUsage;
27
- };
28
- export type DirectMeta = AnswerOrigin & {
29
- /** How the output schema was enforced. The result is validated against the schema either way. */
30
- schemaEnforcement: SchemaEnforcementKind;
31
- };
32
- export type CastResultSource = 'gateway' | 'direct';
33
- type CastResultSuccess<T> = {
34
- success: true;
35
- data: T;
36
- usage: NormalizedUsage;
37
- model: string;
38
- latencyMs: number;
39
- } & ({
40
- source: 'gateway';
41
- meta: GatewayMeta;
42
- } | {
43
- source: 'direct';
44
- meta: DirectMeta;
45
- });
46
- type CastResultFailure = {
47
- success: false;
48
- error: string;
49
- source: CastResultSource;
50
- latencyMs: number;
51
- };
52
- export type CastResult<T> = CastResultSuccess<T> | CastResultFailure;
53
- export interface LlmBackend {
54
- castValue<T>(params: CastValueParams): Promise<CastResult<T>>;
55
- castArray<T>(params: CastArrayParams): Promise<CastResult<T[]>>;
56
- queueCastValue?(params: CastValueParams): Promise<QueueResult>;
57
- queueCastArray?(params: CastArrayParams): Promise<QueueResult>;
58
- }
59
- export type QueueResult = {
60
- success: true;
61
- jobId: string;
62
- source: 'gateway' | 'direct';
63
- } | {
64
- success: false;
65
- error: string;
66
- source: 'gateway' | 'direct';
67
- };
68
- export {};
@@ -1,7 +0,0 @@
1
- export { Nua } from './nua';
2
- export type { OutputDef, GetOptions, ListOptions, ListResultRow } from './nua';
3
- export type { LlmBackend, CastResult, CastValueParams, CastArrayParams, NormalizedUsage, GatewayMeta, DirectMeta, CastResultSource, QueueResult, } from './backend/types';
4
- export type { GatewayConfig } from './backend/gateway';
5
- export type { DirectConfig, ProviderApiKeys } from './backend/direct';
6
- export type { AnswerOrigin, LocalAgentId, ModelInput, SchemaEnforcementKind } from './nua-llm-core/index';
7
- export { z } from 'zod';
@@ -1,7 +0,0 @@
1
- export { Nua } from './nua';
2
- export type { OutputDef, GetOptions, ListOptions, ListResultRow } from './nua';
3
- export type { LlmBackend, CastResult, CastValueParams, CastArrayParams, NormalizedUsage, GatewayMeta, DirectMeta, CastResultSource, QueueResult, } from './backend/types';
4
- export type { GatewayConfig } from './backend/gateway';
5
- export type { DirectConfig, ProviderApiKeys } from './backend/direct';
6
- export type { AnswerOrigin, LocalAgentId, ModelInput, SchemaEnforcementKind } from './nua-llm-core/index';
7
- export { z } from 'zod';
@@ -1,14 +0,0 @@
1
- export declare const isDevelopmentLikeBrowserEnvironment: () => boolean;
2
- export type AuthConfig = {
3
- apiKey?: string;
4
- fetchToken?: () => Promise<string>;
5
- dangerouslyAllowBrowserApiKeyInLocalhost?: boolean;
6
- };
7
- export declare class AuthTokenManager {
8
- private readonly apiKey?;
9
- private readonly fetchToken?;
10
- private apiToken?;
11
- private pendingTokenPromise?;
12
- constructor(config: AuthConfig);
13
- getToken(): Promise<string>;
14
- }
@@ -1 +0,0 @@
1
- export declare function resolveConfigValue<T extends Record<string, any>>(config: T, key: keyof T, envVar: string): string | undefined;
@@ -1,6 +0,0 @@
1
- export type NuabaseError = {
2
- error: string;
3
- isError: true;
4
- isSuccess?: false;
5
- };
6
- export declare function parseErrorResponse(response: Response, urlPath: string): Promise<NuabaseError>;
@@ -1,6 +0,0 @@
1
- /**
2
- * Safely extracts an error message from an unknown value.
3
- * @param error The unknown value caught in a catch block.
4
- * @returns A string representing the error message.
5
- */
6
- export declare function getErrorMessageFromException(error: unknown): string;
@@ -1,2 +0,0 @@
1
- export { detectLocalAgents, findLocalAgent, isLocalAgentId, LOCAL_AGENT_IDS, localAgent, } from './nua-llm-core/local-agent';
2
- export type { LocalAgent, LocalAgentAuthMode, LocalAgentConfig, LocalAgentId, LocalAgentOptions, LocalAgentStatus, } from './nua-llm-core/local-agent';
@@ -1,2 +0,0 @@
1
- export { detectLocalAgents, findLocalAgent, isLocalAgentId, LOCAL_AGENT_IDS, localAgent, } from './nua-llm-core/local-agent';
2
- export type { LocalAgent, LocalAgentAuthMode, LocalAgentConfig, LocalAgentId, LocalAgentOptions, LocalAgentStatus, } from './nua-llm-core/local-agent';
@@ -1,23 +0,0 @@
1
- export * from "./nua-llm-client";
2
- export * from "./lib/logger";
3
- export * from "./lib/types";
4
- export * from "./lib/nua-errors";
5
- export { LLM_PROVIDER_IDS, normalizedUsageZero, providerConfigs, } from "./modules/engine/http/provider-config";
6
- export type { LlmProviderId } from "./modules/engine/http/provider-config";
7
- export { providerEngines } from "./modules/engine/http/provider-engines";
8
- export type { ProviderEngines, ProviderEnginesConfig } from "./modules/engine/http/provider-engines";
9
- export type { EngineRouter, Route } from "./modules/engine/engine-router";
10
- export type { AnswerOrigin, LlmEngine, SchemaEnforcementKind, } from "./modules/engine/llm-engine";
11
- export type { LocalAgentId } from "./modules/engine/local-agent/agent-id";
12
- export { validateJsonSchema } from "./modules/json-schema-validation/validate-json-schema";
13
- export { stableStringify } from "./lib/stable-stringify";
14
- export * from "./modules/model-info";
15
- export * from "./lib/schema-utils";
16
- export { listSchema, parseListSchema } from "./modules/cast/list-schema";
17
- export type { ListRowKeys, ListSchema } from "./modules/cast/list-schema";
18
- export type { CastResult, CastSuccess, CastFailure } from "./modules/cast/run-cast";
19
- export type { RenderedPrompt } from "./modules/cast/cast-request";
20
- export type { ToolDefinition, ToolExecutionResult, AgentTool, TextContent, ToolCallContent, AssistantContentBlock, UserMessage, AssistantMessage, ToolResultMessage, ConversationMessage, AgenticParsedResponse, AgentRunParams, AgentCompletionReason, AgentResult, AgentEvent, AgentEventHandler, } from "./modules/agent/types";
21
- export { runAgent } from "./modules/agent/run-agent";
22
- export { runAgentLoop } from "./modules/agent/agent-loop";
23
- export type { SendAgenticRequestFn } from "./modules/agent/agent-loop";
@@ -1,6 +0,0 @@
1
- /**
2
- * Safely extracts an error message from an unknown value.
3
- * @param error The unknown value caught in a catch block.
4
- * @returns A string representing the error message.
5
- */
6
- export declare function getErrorMessageFromException(error: unknown): string;
@@ -1,44 +0,0 @@
1
- export interface Logger {
2
- debug(message: string, context?: object): void;
3
- info(message: string, context?: object): void;
4
- warn(message: string, context?: object): void;
5
- error(message: string, context?: object): void;
6
- }
7
- export declare class ConsoleLogger implements Logger {
8
- debug(message: string, context?: object): void;
9
- info(message: string, context?: object): void;
10
- warn(message: string, context?: object): void;
11
- error(message: string, context?: object): void;
12
- }
13
- export declare const generateSpanId: () => string;
14
- /**
15
- * Generic header filtering with allowlist and optional redaction
16
- */
17
- export declare function pickHeaders(headers: Record<string, string | string[] | undefined>, allowlist: Set<string>, redactSet?: Set<string>): Record<string, string>;
18
- /**
19
- * Error normalization for logging
20
- */
21
- export declare function normalizeError(error: unknown): {
22
- message: string;
23
- stack?: string;
24
- } | string;
25
- interface LlmRequestLog {
26
- url: string;
27
- httpMethod: string;
28
- model: string;
29
- maxTokens: number;
30
- }
31
- interface LlmResponseLog {
32
- status: number;
33
- responseLength: number;
34
- headers: Record<string, string>;
35
- usage?: {
36
- promptTokens: number;
37
- completionTokens: number;
38
- totalTokens: number;
39
- };
40
- }
41
- export declare const logLlmCallStart: (logger: Logger, spanId: string, service: string, method: string, request: LlmRequestLog) => void;
42
- export declare const logLlmCallComplete: (logger: Logger, spanId: string, service: string, method: string, response: LlmResponseLog, duration: number) => void;
43
- export declare const logLlmCallError: (logger: Logger, spanId: string, service: string, method: string, error: unknown, duration: number) => void;
44
- export {};
@@ -1,12 +0,0 @@
1
- export type NuaError = NuaInternalError | NuaValidationError;
2
- export type NuaValidationError = {
3
- kind: "validation-error";
4
- message: string;
5
- };
6
- export declare const isNuaValidationError: (a: unknown) => a is NuaValidationError;
7
- export type NuaInternalError = {
8
- kind: "internal-error";
9
- message: string;
10
- };
11
- export declare const isNuaInternalError: (a: unknown) => a is NuaInternalError;
12
- export declare const isNuaError: (a: unknown) => a is NuaError;
@@ -1,2 +0,0 @@
1
- export declare const templateVarName: (varName: string) => string;
2
- export declare const replaceTemplateVarName: (str: string, varName: string, value: string) => string;
@@ -1 +0,0 @@
1
- export type JsonSchema = Record<string, unknown>;