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,25 +0,0 @@
1
- import { Logger } from "../../../lib/logger";
2
- import { ModelInput } from "../../model-info";
3
- import { EngineRouter, Route } from "../engine-router";
4
- import { LocalAgentId } from "./agent-id";
5
- import { AgentRunner } from "./local-agent-engine";
6
- /**
7
- * A coding-agent CLI on this machine, set up once and ready to run casts.
8
- * Created by localAgent() or findLocalAgent().
9
- */
10
- export declare class LocalAgent implements EngineRouter {
11
- private readonly runner;
12
- /** The CLI's own model name for calls that name no model; undefined uses the CLI's default. */
13
- private readonly defaultModel;
14
- readonly agent: LocalAgentId;
15
- readonly logger: Logger;
16
- constructor(runner: AgentRunner,
17
- /** The CLI's own model name for calls that name no model; undefined uses the CLI's default. */
18
- defaultModel: string | undefined);
19
- /**
20
- * No model choice runs the default model. An alias runs the CLI's equivalent
21
- * model, if it has one. Provider models cannot run on a local agent.
22
- */
23
- route(model: ModelInput | undefined): Route;
24
- private routeTo;
25
- }
@@ -1,16 +0,0 @@
1
- import { AgentInvocation, AgentProcessResult } from "./adapters/types";
2
- export type RunInvocationOptions = {
3
- binaryPath: string;
4
- invocation: AgentInvocation;
5
- timeoutMs: number;
6
- /** Env var names removed from the child's environment. */
7
- unsetEnv?: string[];
8
- };
9
- /**
10
- * Runs one CLI invocation in a fresh temporary directory, so the agent sees no
11
- * project files, hooks, MCP config, or instructions, and removes the directory
12
- * afterwards. Rejects only when the process cannot be started.
13
- */
14
- export declare function runInvocation(options: RunInvocationOptions): Promise<AgentProcessResult>;
15
- /** Finds an executable on PATH, honouring PATHEXT on Windows. */
16
- export declare function findOnPath(binaryName: string): string | null;
@@ -1,8 +0,0 @@
1
- /** Runs at most `limit` tasks at once; the rest wait in order. */
2
- export declare class Semaphore {
3
- private readonly limit;
4
- private active;
5
- private readonly waiting;
6
- constructor(limit: number);
7
- run<T>(task: () => Promise<T>): Promise<T>;
8
- }
@@ -1,5 +0,0 @@
1
- export declare function extractThinkingFromResponse(input: string): {
2
- thinking: string;
3
- cleanedResponse: string;
4
- };
5
- export declare function parseJsonFromLlmResponse(input: string): object;
@@ -1,12 +0,0 @@
1
- import Ajv from "ajv";
2
- import Ajv2019 from "ajv/dist/2019.js";
3
- import Ajv2020 from "ajv/dist/2020.js";
4
- declare class AjvInstances {
5
- readonly draft07: Ajv;
6
- readonly draft2019: Ajv2019;
7
- readonly draft2020: Ajv2020;
8
- constructor();
9
- getInstanceForSchema(schema: object): Ajv | Ajv2019 | Ajv2020;
10
- }
11
- export declare const ajvInstances: AjvInstances;
12
- export {};
@@ -1,10 +0,0 @@
1
- export type ValidationResult = {
2
- success: boolean;
3
- data?: object;
4
- error?: string;
5
- };
6
- /**
7
- * Creates a validation function for checking JSON data against a schema using AJV.
8
- * Returns a closure that validates unknown data and returns a typed ValidationResult.
9
- */
10
- export declare function buildNuaJsonSchemaValueValidation(llmRequestId: string, parsedSchema: object): (json: object) => ValidationResult;
@@ -1,2 +0,0 @@
1
- import { NuaValidationError } from "../../lib/nua-errors";
2
- export declare const validateJsonSchema: (schema: Object) => true | NuaValidationError;
@@ -1,15 +0,0 @@
1
- import { NuaValidationError } from "../../lib/nua-errors";
2
- import { LlmProviderId } from "../engine/http/provider-config";
3
- export type ProviderModel = {
4
- provider: LlmProviderId;
5
- model: string;
6
- };
7
- export type ModelAliasName = "fast" | "gemini" | "qwen" | "sonnet" | "opus" | "haiku" | "kimi" | "gpt";
8
- export type ModelInput = ProviderModel | {
9
- alias: ModelAliasName;
10
- };
11
- export declare const MODEL_ALIASES: Record<ModelAliasName, ProviderModel[]>;
12
- export declare const MODEL_ALIAS_NAMES: ModelAliasName[];
13
- export declare function isLlmProviderId(value: unknown): value is LlmProviderId;
14
- export declare function isModelAliasName(value: unknown): value is ModelAliasName;
15
- export declare function resolveModelInput(input: ModelInput | null | undefined, configuredProviders: ReadonlySet<LlmProviderId>): ProviderModel | NuaValidationError;
@@ -1,7 +0,0 @@
1
- /**
2
- * Generic SSE (Server-Sent Events) stream parser.
3
- * Reads a ReadableStream<Uint8Array> and yields each `data:` payload as a string.
4
- * Handles OpenAI's `[DONE]` sentinel and Gemini's stream-close-means-done.
5
- * Uses only web-standard APIs (no node: imports).
6
- */
7
- export declare function parseSSEStream(stream: ReadableStream<Uint8Array>): AsyncGenerator<string>;
@@ -1,37 +0,0 @@
1
- import { ListSchema } from "./modules/cast/list-schema";
2
- import { CastResult } from "./modules/cast/run-cast";
3
- import { EngineRouter } from "./modules/engine/engine-router";
4
- import { ModelInput } from "./modules/model-info";
5
- export type CastValueParams = {
6
- model?: ModelInput;
7
- maxTokens?: number;
8
- input: {
9
- prompt: string;
10
- data?: unknown;
11
- };
12
- output: {
13
- name: string;
14
- schema: object;
15
- };
16
- };
17
- export type CastArrayParams = {
18
- model?: ModelInput;
19
- maxTokens?: number;
20
- input: {
21
- prompt: string;
22
- data: unknown[];
23
- };
24
- /** Built with listSchema(); it names each row's primary key and output field. */
25
- output: ListSchema;
26
- };
27
- /**
28
- * Turns a prompt, data and a JSON schema into a validated value. Where the calls
29
- * run is up to the engine router it is given: providerEngines() for LLM
30
- * providers' APIs, or localAgent() from "nua-llm-core/local-agent".
31
- */
32
- export declare class NuaLlmClient {
33
- private readonly engines;
34
- constructor(engines: EngineRouter);
35
- castValue<T = unknown>(params: CastValueParams): Promise<CastResult<T>>;
36
- castArray<T = unknown>(params: CastArrayParams): Promise<CastResult<T[]>>;
37
- }
@@ -1,42 +0,0 @@
1
- import { DirectConfig } from './backend/direct';
2
- import { GatewayConfig } from './backend/gateway';
3
- import { CastResult, QueueResult } from './backend/types';
4
- import type { ModelInput } from './nua-llm-core/index';
5
- import { z } from 'zod';
6
- export type OutputDef<TSchema extends z.ZodTypeAny> = {
7
- name: string;
8
- schema: TSchema;
9
- };
10
- export type GetOptions<TSchema extends z.ZodTypeAny> = {
11
- input?: unknown;
12
- output: OutputDef<TSchema>;
13
- model?: ModelInput;
14
- };
15
- export type ListOptions<TSchema extends z.ZodTypeAny, TData extends Record<string, unknown>, PrimaryKey extends keyof TData & string> = {
16
- input: TData[];
17
- primaryKey: PrimaryKey;
18
- output: OutputDef<TSchema>;
19
- model?: ModelInput;
20
- };
21
- export type ListResultRow<TSchema extends z.ZodTypeAny, PrimaryKey extends string> = {
22
- [K in PrimaryKey]: string | number;
23
- } & {
24
- [outputName: string]: z.infer<TSchema>;
25
- };
26
- export declare class Nua {
27
- private readonly backend;
28
- private constructor();
29
- static gateway(config: GatewayConfig): Nua;
30
- /**
31
- * Runs casts in this process: on LLM providers' APIs with your API keys (`providers`), or
32
- * on a coding-agent CLI installed on this machine (`localAgent`, set up with `localAgent()` or
33
- * `findLocalAgent()` from "nuabase/local-agent").
34
- */
35
- static direct(config: DirectConfig): Nua;
36
- get(prompt: string): Promise<CastResult<string>>;
37
- get<TSchema extends z.ZodTypeAny>(prompt: string, options: GetOptions<TSchema>): Promise<CastResult<z.infer<TSchema>>>;
38
- list<TSchema extends z.ZodTypeAny, TData extends Record<string, unknown>, PrimaryKey extends keyof TData & string>(prompt: string, options: ListOptions<TSchema, TData, PrimaryKey>): Promise<CastResult<ListResultRow<TSchema, PrimaryKey>[]>>;
39
- queueGet(prompt: string): Promise<QueueResult>;
40
- queueGet<TSchema extends z.ZodTypeAny>(prompt: string, options: GetOptions<TSchema>): Promise<QueueResult>;
41
- queueList<TSchema extends z.ZodTypeAny, TData extends Record<string, unknown>, PrimaryKey extends keyof TData & string>(prompt: string, options: ListOptions<TSchema, TData, PrimaryKey>): Promise<QueueResult>;
42
- }