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.
Files changed (80) hide show
  1. package/CHANGELOG.md +58 -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 +991 -11473
  7. package/dist/cjs/local-agent.cjs +809 -953
  8. package/dist/esm/chunks/strict-json-schema-Du2LLrVP.mjs +138 -0
  9. package/dist/esm/index.mjs +989 -11471
  10. package/dist/esm/local-agent.mjs +782 -954
  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 -24
  16. package/dist/cjs/chunks/logger-Co5uZG0A.cjs +0 -90
  17. package/dist/esm/chunks/logger-DnkHzkX_.mjs +0 -88
  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 -12
  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 -65
  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,90 +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
- exports.requireLogger = requireLogger;
@@ -1,88 +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
- export { 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>;
@@ -1 +0,0 @@
1
- export declare function stableStringify(value: unknown): string;
@@ -1,7 +0,0 @@
1
- import { JsonSchema } from "./schema-utils";
2
- /**
3
- * Converts a schema to OpenAI strict mode, or returns null when that would
4
- * change which values are valid (optional properties, open-ended objects,
5
- * unsupported keywords).
6
- */
7
- export declare function toStrictSchema(schema: JsonSchema): JsonSchema | null;
@@ -1,8 +0,0 @@
1
- export type UserDataPKValue = string | number;
2
- export type MappableInputDataRow = Record<string, unknown>;
3
- export type MappableInputData = MappableInputDataRow[];
4
- export type NormalizedUsage = {
5
- promptTokens: number;
6
- completionTokens: number;
7
- totalTokens: number;
8
- };
@@ -1,4 +0,0 @@
1
- import { NuaValidationError } from "./nua-errors";
2
- export type MappableInputDataRow = Record<string, unknown>;
3
- export type MappableInputData = MappableInputDataRow[];
4
- export declare function validateMappableInputData(data: unknown, primaryKey: string | null): NuaValidationError | MappableInputData;
@@ -1,7 +0,0 @@
1
- export { findLocalAgent, localAgent } from "./modules/engine/local-agent/create-local-agent";
2
- export type { LocalAgentAuthMode, LocalAgentConfig, LocalAgentOptions, } from "./modules/engine/local-agent/create-local-agent";
3
- export type { LocalAgent } from "./modules/engine/local-agent/local-agent";
4
- export { detectLocalAgents } from "./modules/engine/local-agent/detect";
5
- export type { LocalAgentStatus } from "./modules/engine/local-agent/detect";
6
- export { LOCAL_AGENT_IDS, isLocalAgentId } from "./modules/engine/local-agent/agent-id";
7
- export type { LocalAgentId } from "./modules/engine/local-agent/agent-id";
@@ -1,10 +0,0 @@
1
- import { AgentEventHandler, AgentResult, AgentTool, AgenticParsedResponse, ConversationMessage } from "./types";
2
- export type SendAgenticRequestFn = (messages: ConversationMessage[], tools: AgentTool[], systemPrompt?: string) => Promise<AgenticParsedResponse>;
3
- export declare function runAgentLoop(params: {
4
- messages: ConversationMessage[];
5
- tools: AgentTool[];
6
- systemPrompt?: string;
7
- maxTurns: number;
8
- sendRequest: SendAgenticRequestFn;
9
- onEvent?: AgentEventHandler;
10
- }): Promise<AgentResult>;
@@ -1,17 +0,0 @@
1
- import { Logger } from "../../lib/logger";
2
- import { ProviderTarget } from "../engine/http/provider-call";
3
- import { AgentEventHandler, AgenticParsedResponse, ConversationMessage, ToolDefinition } from "./types";
4
- export type AgentTurn = {
5
- target: ProviderTarget;
6
- maxTokens: number;
7
- messages: ConversationMessage[];
8
- tools: ToolDefinition[];
9
- systemPrompt?: string;
10
- /** When set, the reply is streamed and reported through it as it arrives. */
11
- onEvent?: AgentEventHandler;
12
- };
13
- /**
14
- * Sends one turn of a tool-calling conversation to an LLM provider's HTTP API.
15
- * Throws when the call fails; the agent loop reports that as the end of the conversation.
16
- */
17
- export declare function sendAgentTurn(turn: AgentTurn, logger: Logger): Promise<AgenticParsedResponse>;
@@ -1,22 +0,0 @@
1
- import { ProviderRequestBase } from "../engine/http/provider-config";
2
- import { AgentEventHandler, AgenticParsedResponse, ConversationMessage, ToolDefinition } from "./types";
3
- export declare function buildOpenAiAgenticRequest(options: {
4
- messages: ConversationMessage[];
5
- tools: ToolDefinition[];
6
- model: string;
7
- maxTokens: number;
8
- systemPrompt?: string;
9
- stream?: boolean;
10
- }, baseUrl: string, apiKey: string): ProviderRequestBase;
11
- export declare function parseOpenAiAgenticResponse(response: Response, errorLabel: string): Promise<AgenticParsedResponse>;
12
- export declare function buildGeminiAgenticRequest(options: {
13
- messages: ConversationMessage[];
14
- tools: ToolDefinition[];
15
- model: string;
16
- maxTokens: number;
17
- systemPrompt?: string;
18
- stream?: boolean;
19
- }, apiKey: string): ProviderRequestBase;
20
- export declare function parseGeminiAgenticResponse(response: Response): Promise<AgenticParsedResponse>;
21
- export declare function streamOpenAiAgenticResponse(response: Response, errorLabel: string, onEvent?: AgentEventHandler): Promise<AgenticParsedResponse>;
22
- export declare function streamGeminiAgenticResponse(response: Response, onEvent?: AgentEventHandler): Promise<AgenticParsedResponse>;
@@ -1,7 +0,0 @@
1
- import { ProviderEngines } from "../engine/http/provider-engines";
2
- import { AgentResult, AgentRunParams } from "./types";
3
- /**
4
- * Runs a multi-turn, tool-calling conversation on an LLM provider's API. It needs
5
- * the providers' API directly, so it takes provider engines rather than any engine router.
6
- */
7
- export declare function runAgent(providers: ProviderEngines, params: AgentRunParams): Promise<AgentResult>;