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
@@ -0,0 +1,94 @@
1
+ import { N as NormalizedUsage, A as AnswerOrigin, S as SchemaEnforcementKind, L as LlmProviderId, M as ModelInput } from './chunks/local-agent-Bj-QKikS.cjs';
2
+ import { LocalAgent } from './local-agent.cjs';
3
+ export { b as LocalAgentId } from './chunks/local-agent-Bj-QKikS.cjs';
4
+ import { z } from 'zod';
5
+ export { z } from 'zod';
6
+
7
+ type DirectMeta = AnswerOrigin & {
8
+ /** How the output schema was enforced. The result is validated against the schema either way. */
9
+ schemaEnforcement: SchemaEnforcementKind;
10
+ };
11
+ type CastResultSource = 'direct';
12
+ type CastResultSuccess<T> = {
13
+ success: true;
14
+ data: T;
15
+ usage: NormalizedUsage;
16
+ model: string;
17
+ latencyMs: number;
18
+ source: CastResultSource;
19
+ meta: DirectMeta;
20
+ };
21
+ type CastResultFailure = {
22
+ success: false;
23
+ /** What went wrong, as one sentence for a log: the attempts made and why the last one failed. */
24
+ error: string;
25
+ /**
26
+ * Why the last attempt failed, in the engine's own words where it gave any (a
27
+ * coding agent's or provider's message, fit to show the user), naming neither
28
+ * the engine nor the attempts. Without an attempt, why none was made.
29
+ */
30
+ reason: string;
31
+ /** Attempts made; 0 when the request was refused before any (such as an invalid schema). */
32
+ attempts: number;
33
+ source: CastResultSource;
34
+ latencyMs: number;
35
+ };
36
+ type CastResult<T> = CastResultSuccess<T> | CastResultFailure;
37
+
38
+ /** API keys for the LLM providers direct mode may call. */
39
+ type ProviderApiKeys = {
40
+ [key in LlmProviderId]?: {
41
+ apiKey: string;
42
+ };
43
+ };
44
+ /**
45
+ * Either `providers`: API keys for LLM providers, with an optional default `model`.
46
+ * Or `localAgent`: a coding-agent CLI on this machine, from `localAgent()` or
47
+ * `findLocalAgent()` in "nuabase/local-agent".
48
+ */
49
+ type DirectConfig = {
50
+ providers: ProviderApiKeys;
51
+ model?: ModelInput;
52
+ localAgent?: never;
53
+ } | {
54
+ localAgent: LocalAgent;
55
+ providers?: never;
56
+ model?: never;
57
+ };
58
+ /** `name` is the field each answer goes in; a literal name types list() rows by it. */
59
+ type OutputDef<TSchema extends z.ZodTypeAny, TName extends string = string> = {
60
+ name: TName;
61
+ schema: TSchema;
62
+ };
63
+ type GetOptions<TSchema extends z.ZodTypeAny> = {
64
+ input?: unknown;
65
+ output: OutputDef<TSchema>;
66
+ model?: ModelInput;
67
+ };
68
+ type ListOptions<TSchema extends z.ZodTypeAny, TData extends Record<string, unknown>, PrimaryKey extends keyof TData & string, TName extends string = string> = {
69
+ input: TData[];
70
+ primaryKey: PrimaryKey;
71
+ output: OutputDef<TSchema, TName>;
72
+ model?: ModelInput;
73
+ };
74
+ type ListResultRow<TSchema extends z.ZodTypeAny, PrimaryKey extends string, TName extends string = string> = {
75
+ [K in PrimaryKey]: string | number;
76
+ } & {
77
+ [K in TName]: z.infer<TSchema>;
78
+ };
79
+ declare class Nua {
80
+ private readonly client;
81
+ private constructor();
82
+ /**
83
+ * Runs casts in this process: on LLM providers' APIs with your API keys (`providers`), or
84
+ * on a coding-agent CLI installed on this machine (`localAgent`, set up with `localAgent()` or
85
+ * `findLocalAgent()` from "nuabase/local-agent").
86
+ */
87
+ static direct(config: DirectConfig): Nua;
88
+ get(prompt: string): Promise<CastResult<string>>;
89
+ get<TSchema extends z.ZodTypeAny>(prompt: string, options: GetOptions<TSchema>): Promise<CastResult<z.infer<TSchema>>>;
90
+ list<TSchema extends z.ZodTypeAny, TData extends Record<string, unknown>, PrimaryKey extends keyof TData & string, TName extends string = string>(prompt: string, options: ListOptions<TSchema, TData, PrimaryKey, TName>): Promise<CastResult<ListResultRow<TSchema, PrimaryKey, TName>[]>>;
91
+ }
92
+
93
+ export { AnswerOrigin, LlmProviderId, ModelInput, NormalizedUsage, Nua, SchemaEnforcementKind };
94
+ export type { CastResult, CastResultSource, DirectConfig, DirectMeta, GetOptions, ListOptions, ListResultRow, OutputDef, ProviderApiKeys };
@@ -0,0 +1,94 @@
1
+ import { N as NormalizedUsage, A as AnswerOrigin, S as SchemaEnforcementKind, L as LlmProviderId, M as ModelInput } from './chunks/local-agent-Bj-QKikS.mjs';
2
+ import { LocalAgent } from './local-agent.mjs';
3
+ export { b as LocalAgentId } from './chunks/local-agent-Bj-QKikS.mjs';
4
+ import { z } from 'zod';
5
+ export { z } from 'zod';
6
+
7
+ type DirectMeta = AnswerOrigin & {
8
+ /** How the output schema was enforced. The result is validated against the schema either way. */
9
+ schemaEnforcement: SchemaEnforcementKind;
10
+ };
11
+ type CastResultSource = 'direct';
12
+ type CastResultSuccess<T> = {
13
+ success: true;
14
+ data: T;
15
+ usage: NormalizedUsage;
16
+ model: string;
17
+ latencyMs: number;
18
+ source: CastResultSource;
19
+ meta: DirectMeta;
20
+ };
21
+ type CastResultFailure = {
22
+ success: false;
23
+ /** What went wrong, as one sentence for a log: the attempts made and why the last one failed. */
24
+ error: string;
25
+ /**
26
+ * Why the last attempt failed, in the engine's own words where it gave any (a
27
+ * coding agent's or provider's message, fit to show the user), naming neither
28
+ * the engine nor the attempts. Without an attempt, why none was made.
29
+ */
30
+ reason: string;
31
+ /** Attempts made; 0 when the request was refused before any (such as an invalid schema). */
32
+ attempts: number;
33
+ source: CastResultSource;
34
+ latencyMs: number;
35
+ };
36
+ type CastResult<T> = CastResultSuccess<T> | CastResultFailure;
37
+
38
+ /** API keys for the LLM providers direct mode may call. */
39
+ type ProviderApiKeys = {
40
+ [key in LlmProviderId]?: {
41
+ apiKey: string;
42
+ };
43
+ };
44
+ /**
45
+ * Either `providers`: API keys for LLM providers, with an optional default `model`.
46
+ * Or `localAgent`: a coding-agent CLI on this machine, from `localAgent()` or
47
+ * `findLocalAgent()` in "nuabase/local-agent".
48
+ */
49
+ type DirectConfig = {
50
+ providers: ProviderApiKeys;
51
+ model?: ModelInput;
52
+ localAgent?: never;
53
+ } | {
54
+ localAgent: LocalAgent;
55
+ providers?: never;
56
+ model?: never;
57
+ };
58
+ /** `name` is the field each answer goes in; a literal name types list() rows by it. */
59
+ type OutputDef<TSchema extends z.ZodTypeAny, TName extends string = string> = {
60
+ name: TName;
61
+ schema: TSchema;
62
+ };
63
+ type GetOptions<TSchema extends z.ZodTypeAny> = {
64
+ input?: unknown;
65
+ output: OutputDef<TSchema>;
66
+ model?: ModelInput;
67
+ };
68
+ type ListOptions<TSchema extends z.ZodTypeAny, TData extends Record<string, unknown>, PrimaryKey extends keyof TData & string, TName extends string = string> = {
69
+ input: TData[];
70
+ primaryKey: PrimaryKey;
71
+ output: OutputDef<TSchema, TName>;
72
+ model?: ModelInput;
73
+ };
74
+ type ListResultRow<TSchema extends z.ZodTypeAny, PrimaryKey extends string, TName extends string = string> = {
75
+ [K in PrimaryKey]: string | number;
76
+ } & {
77
+ [K in TName]: z.infer<TSchema>;
78
+ };
79
+ declare class Nua {
80
+ private readonly client;
81
+ private constructor();
82
+ /**
83
+ * Runs casts in this process: on LLM providers' APIs with your API keys (`providers`), or
84
+ * on a coding-agent CLI installed on this machine (`localAgent`, set up with `localAgent()` or
85
+ * `findLocalAgent()` from "nuabase/local-agent").
86
+ */
87
+ static direct(config: DirectConfig): Nua;
88
+ get(prompt: string): Promise<CastResult<string>>;
89
+ get<TSchema extends z.ZodTypeAny>(prompt: string, options: GetOptions<TSchema>): Promise<CastResult<z.infer<TSchema>>>;
90
+ list<TSchema extends z.ZodTypeAny, TData extends Record<string, unknown>, PrimaryKey extends keyof TData & string, TName extends string = string>(prompt: string, options: ListOptions<TSchema, TData, PrimaryKey, TName>): Promise<CastResult<ListResultRow<TSchema, PrimaryKey, TName>[]>>;
91
+ }
92
+
93
+ export { AnswerOrigin, LlmProviderId, ModelInput, NormalizedUsage, Nua, SchemaEnforcementKind };
94
+ export type { CastResult, CastResultSource, DirectConfig, DirectMeta, GetOptions, ListOptions, ListResultRow, OutputDef, ProviderApiKeys };
@@ -0,0 +1,150 @@
1
+ import { c as AgentEffort, d as Logger, b as LocalAgentId, a as LocalAgent, e as SessionApproval } from './chunks/local-agent-Bj-QKikS.cjs';
2
+ export { f as LOCAL_AGENT_IDS, g as LocalAgentCallOptions, i as isLocalAgentId } from './chunks/local-agent-Bj-QKikS.cjs';
3
+
4
+ /**
5
+ * - subscription: removes API-key env vars (ANTHROPIC_API_KEY, OPENAI_API_KEY, ...) from the
6
+ * agent's environment, so the CLI uses its own login and plan.
7
+ * - inherit: passes the environment through unchanged.
8
+ */
9
+ type LocalAgentAuthMode = "subscription" | "inherit";
10
+ type LocalAgentOptions = {
11
+ /** The agent's own model name (e.g. "haiku" for Claude Code) for calls that name no model. Defaults to the agent's default. */
12
+ model?: string;
13
+ /** How hard the model thinks, as the CLI's own reasoning or effort setting. Defaults to the CLI's default. */
14
+ effort?: AgentEffort;
15
+ /** Per-call limit in milliseconds. Defaults to 180000. */
16
+ timeoutMs?: number;
17
+ /** Maximum agent processes running at once. Defaults to 2. */
18
+ concurrency?: number;
19
+ /** Defaults to "subscription". */
20
+ auth?: LocalAgentAuthMode;
21
+ /** Where calls and cast retries are logged. Defaults to the console. */
22
+ logger?: Logger;
23
+ };
24
+ type LocalAgentConfig = LocalAgentOptions & {
25
+ agent: LocalAgentId;
26
+ /** Path to the agent executable. Defaults to looking it up on PATH. */
27
+ binaryPath?: string;
28
+ };
29
+ /**
30
+ * Sets up the named coding-agent CLI on this machine. Throws right away when the
31
+ * CLI cannot be found; a missing login shows up as the first call's error. Node.js only.
32
+ */
33
+ declare function localAgent(config: LocalAgentConfig): LocalAgent;
34
+ /**
35
+ * Sets up the first supported coding-agent CLI that is installed and logged in,
36
+ * trying Claude Code first. Rejects when none is. Node.js only.
37
+ */
38
+ declare function findLocalAgent(options?: LocalAgentOptions): Promise<LocalAgent>;
39
+
40
+ type LocalAgentStatus = {
41
+ agent: LocalAgentId;
42
+ installed: false;
43
+ loggedIn: false;
44
+ detail?: string;
45
+ } | {
46
+ agent: LocalAgentId;
47
+ installed: true;
48
+ loggedIn: boolean;
49
+ binaryPath: string;
50
+ version?: string;
51
+ detail?: string;
52
+ };
53
+ /**
54
+ * Reports which supported coding agents are installed and logged in, in
55
+ * preference order. Runs each CLI's version and login-status commands, which
56
+ * make no model calls.
57
+ */
58
+ declare function detectLocalAgents(binaryPaths?: Partial<Record<LocalAgentId, string>>): Promise<LocalAgentStatus[]>;
59
+
60
+ /**
61
+ * How a session can be started on this platform:
62
+ * - terminal: in a new terminal window.
63
+ * - command: by the user, running the session's `command` in a terminal.
64
+ * - none: the launcher is a POSIX shell script, which Windows can't run.
65
+ */
66
+ type AgentSessionMode = "terminal" | "command" | "none";
67
+ type AgentSessionConfig = {
68
+ agent: LocalAgentId;
69
+ /** Path to the agent executable. Defaults to looking it up on PATH. */
70
+ binaryPath?: string;
71
+ /** The project the agent works in. */
72
+ cwd: string;
73
+ /** The agent's own model name. Defaults to the agent's default. */
74
+ model?: string;
75
+ /** Defaults to "ask". */
76
+ approval?: SessionApproval;
77
+ /** The session's first message. */
78
+ prompt: string;
79
+ /** Where the prompt and launcher are written. Created if missing. */
80
+ dir: string;
81
+ /**
82
+ * The files' name without extension, which neither file may have yet.
83
+ * Defaults to `<UTC time>-<agent>-<4 hex digits>`.
84
+ */
85
+ name?: string;
86
+ /** Defaults to process.platform. */
87
+ platform?: NodeJS.Platform;
88
+ };
89
+ type AgentSessionFiles = {
90
+ promptPath: string;
91
+ launcherPath: string;
92
+ /** Runs the launcher from any POSIX terminal. */
93
+ command: string;
94
+ };
95
+ /**
96
+ * Why a session wasn't started. Nothing was written.
97
+ * - unsupported_platform: the platform can't run the launcher (agentSessionMode "none").
98
+ * - prompt_too_long: Linux caps one argument at 128 KiB, and the prompt is one.
99
+ * - agent_not_found: no binaryPath was given, and the agent isn't on PATH.
100
+ */
101
+ type AgentSessionRefusal = "unsupported_platform" | "prompt_too_long" | "agent_not_found";
102
+ /** What startAgentSession() did. */
103
+ type AgentSessionStart =
104
+ /** A new terminal window is running the agent on the prompt. */
105
+ {
106
+ kind: "opened";
107
+ files: AgentSessionFiles;
108
+ }
109
+ /**
110
+ * The files are written, and the user starts the session by running
111
+ * `files.command` in a terminal: this platform opens no terminal window.
112
+ */
113
+ | {
114
+ kind: "command";
115
+ files: AgentSessionFiles;
116
+ }
117
+ /**
118
+ * The files are written, but the terminal window didn't open, for the reason
119
+ * in `error`; the user can still run `files.command` in a terminal.
120
+ */
121
+ | {
122
+ kind: "open_failed";
123
+ files: AgentSessionFiles;
124
+ error: string;
125
+ } | {
126
+ kind: "refused";
127
+ reason: AgentSessionRefusal;
128
+ message: string;
129
+ };
130
+ /** Pure: how a session can be started on `platform`. */
131
+ declare function agentSessionMode(platform?: NodeJS.Platform): AgentSessionMode;
132
+ /**
133
+ * Writes the prompt and a launcher that starts the agent on it, and where the
134
+ * platform can, opens a terminal window running it. Expected failures come
135
+ * back as the result; it throws only for an unknown agent or a `name` already
136
+ * used. Node.js only.
137
+ */
138
+ declare function startAgentSession(config: AgentSessionConfig): Promise<AgentSessionStart>;
139
+ type SessionLauncherTarget = {
140
+ cwd: string;
141
+ binaryPath: string;
142
+ /** The agent's own options, which go before the prompt. */
143
+ agentArgs: readonly string[];
144
+ promptPath: string;
145
+ };
146
+ /** Pure: the shell script that starts the agent on the prompt in `promptPath`. */
147
+ declare function sessionLauncher({ cwd, binaryPath, agentArgs, promptPath }: SessionLauncherTarget): string;
148
+
149
+ export { AgentEffort, LocalAgent, LocalAgentId, Logger, SessionApproval, agentSessionMode, detectLocalAgents, findLocalAgent, localAgent, sessionLauncher, startAgentSession };
150
+ export type { AgentSessionConfig, AgentSessionFiles, AgentSessionMode, AgentSessionRefusal, AgentSessionStart, LocalAgentAuthMode, LocalAgentConfig, LocalAgentOptions, LocalAgentStatus, SessionLauncherTarget };
@@ -0,0 +1,150 @@
1
+ import { c as AgentEffort, d as Logger, b as LocalAgentId, a as LocalAgent, e as SessionApproval } from './chunks/local-agent-Bj-QKikS.mjs';
2
+ export { f as LOCAL_AGENT_IDS, g as LocalAgentCallOptions, i as isLocalAgentId } from './chunks/local-agent-Bj-QKikS.mjs';
3
+
4
+ /**
5
+ * - subscription: removes API-key env vars (ANTHROPIC_API_KEY, OPENAI_API_KEY, ...) from the
6
+ * agent's environment, so the CLI uses its own login and plan.
7
+ * - inherit: passes the environment through unchanged.
8
+ */
9
+ type LocalAgentAuthMode = "subscription" | "inherit";
10
+ type LocalAgentOptions = {
11
+ /** The agent's own model name (e.g. "haiku" for Claude Code) for calls that name no model. Defaults to the agent's default. */
12
+ model?: string;
13
+ /** How hard the model thinks, as the CLI's own reasoning or effort setting. Defaults to the CLI's default. */
14
+ effort?: AgentEffort;
15
+ /** Per-call limit in milliseconds. Defaults to 180000. */
16
+ timeoutMs?: number;
17
+ /** Maximum agent processes running at once. Defaults to 2. */
18
+ concurrency?: number;
19
+ /** Defaults to "subscription". */
20
+ auth?: LocalAgentAuthMode;
21
+ /** Where calls and cast retries are logged. Defaults to the console. */
22
+ logger?: Logger;
23
+ };
24
+ type LocalAgentConfig = LocalAgentOptions & {
25
+ agent: LocalAgentId;
26
+ /** Path to the agent executable. Defaults to looking it up on PATH. */
27
+ binaryPath?: string;
28
+ };
29
+ /**
30
+ * Sets up the named coding-agent CLI on this machine. Throws right away when the
31
+ * CLI cannot be found; a missing login shows up as the first call's error. Node.js only.
32
+ */
33
+ declare function localAgent(config: LocalAgentConfig): LocalAgent;
34
+ /**
35
+ * Sets up the first supported coding-agent CLI that is installed and logged in,
36
+ * trying Claude Code first. Rejects when none is. Node.js only.
37
+ */
38
+ declare function findLocalAgent(options?: LocalAgentOptions): Promise<LocalAgent>;
39
+
40
+ type LocalAgentStatus = {
41
+ agent: LocalAgentId;
42
+ installed: false;
43
+ loggedIn: false;
44
+ detail?: string;
45
+ } | {
46
+ agent: LocalAgentId;
47
+ installed: true;
48
+ loggedIn: boolean;
49
+ binaryPath: string;
50
+ version?: string;
51
+ detail?: string;
52
+ };
53
+ /**
54
+ * Reports which supported coding agents are installed and logged in, in
55
+ * preference order. Runs each CLI's version and login-status commands, which
56
+ * make no model calls.
57
+ */
58
+ declare function detectLocalAgents(binaryPaths?: Partial<Record<LocalAgentId, string>>): Promise<LocalAgentStatus[]>;
59
+
60
+ /**
61
+ * How a session can be started on this platform:
62
+ * - terminal: in a new terminal window.
63
+ * - command: by the user, running the session's `command` in a terminal.
64
+ * - none: the launcher is a POSIX shell script, which Windows can't run.
65
+ */
66
+ type AgentSessionMode = "terminal" | "command" | "none";
67
+ type AgentSessionConfig = {
68
+ agent: LocalAgentId;
69
+ /** Path to the agent executable. Defaults to looking it up on PATH. */
70
+ binaryPath?: string;
71
+ /** The project the agent works in. */
72
+ cwd: string;
73
+ /** The agent's own model name. Defaults to the agent's default. */
74
+ model?: string;
75
+ /** Defaults to "ask". */
76
+ approval?: SessionApproval;
77
+ /** The session's first message. */
78
+ prompt: string;
79
+ /** Where the prompt and launcher are written. Created if missing. */
80
+ dir: string;
81
+ /**
82
+ * The files' name without extension, which neither file may have yet.
83
+ * Defaults to `<UTC time>-<agent>-<4 hex digits>`.
84
+ */
85
+ name?: string;
86
+ /** Defaults to process.platform. */
87
+ platform?: NodeJS.Platform;
88
+ };
89
+ type AgentSessionFiles = {
90
+ promptPath: string;
91
+ launcherPath: string;
92
+ /** Runs the launcher from any POSIX terminal. */
93
+ command: string;
94
+ };
95
+ /**
96
+ * Why a session wasn't started. Nothing was written.
97
+ * - unsupported_platform: the platform can't run the launcher (agentSessionMode "none").
98
+ * - prompt_too_long: Linux caps one argument at 128 KiB, and the prompt is one.
99
+ * - agent_not_found: no binaryPath was given, and the agent isn't on PATH.
100
+ */
101
+ type AgentSessionRefusal = "unsupported_platform" | "prompt_too_long" | "agent_not_found";
102
+ /** What startAgentSession() did. */
103
+ type AgentSessionStart =
104
+ /** A new terminal window is running the agent on the prompt. */
105
+ {
106
+ kind: "opened";
107
+ files: AgentSessionFiles;
108
+ }
109
+ /**
110
+ * The files are written, and the user starts the session by running
111
+ * `files.command` in a terminal: this platform opens no terminal window.
112
+ */
113
+ | {
114
+ kind: "command";
115
+ files: AgentSessionFiles;
116
+ }
117
+ /**
118
+ * The files are written, but the terminal window didn't open, for the reason
119
+ * in `error`; the user can still run `files.command` in a terminal.
120
+ */
121
+ | {
122
+ kind: "open_failed";
123
+ files: AgentSessionFiles;
124
+ error: string;
125
+ } | {
126
+ kind: "refused";
127
+ reason: AgentSessionRefusal;
128
+ message: string;
129
+ };
130
+ /** Pure: how a session can be started on `platform`. */
131
+ declare function agentSessionMode(platform?: NodeJS.Platform): AgentSessionMode;
132
+ /**
133
+ * Writes the prompt and a launcher that starts the agent on it, and where the
134
+ * platform can, opens a terminal window running it. Expected failures come
135
+ * back as the result; it throws only for an unknown agent or a `name` already
136
+ * used. Node.js only.
137
+ */
138
+ declare function startAgentSession(config: AgentSessionConfig): Promise<AgentSessionStart>;
139
+ type SessionLauncherTarget = {
140
+ cwd: string;
141
+ binaryPath: string;
142
+ /** The agent's own options, which go before the prompt. */
143
+ agentArgs: readonly string[];
144
+ promptPath: string;
145
+ };
146
+ /** Pure: the shell script that starts the agent on the prompt in `promptPath`. */
147
+ declare function sessionLauncher({ cwd, binaryPath, agentArgs, promptPath }: SessionLauncherTarget): string;
148
+
149
+ export { AgentEffort, LocalAgent, LocalAgentId, Logger, SessionApproval, agentSessionMode, detectLocalAgents, findLocalAgent, localAgent, sessionLauncher, startAgentSession };
150
+ export type { AgentSessionConfig, AgentSessionFiles, AgentSessionMode, AgentSessionRefusal, AgentSessionStart, LocalAgentAuthMode, LocalAgentConfig, LocalAgentOptions, LocalAgentStatus, SessionLauncherTarget };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "nuabase",
3
3
  "description": "Nuabase TypeScript client to create typed functions from LLM prompts",
4
- "version": "2.3.7",
4
+ "version": "3.0.0",
5
5
  "type": "module",
6
6
  "author": "Jasim A Basheer <jasim@nuabase.com>",
7
7
  "engines": {
8
- "node": ">=16.6.0"
8
+ "node": ">=18"
9
9
  },
10
10
  "keywords": [
11
11
  "typescript",
@@ -24,26 +24,26 @@
24
24
  },
25
25
  "homepage": "https://github.com/nuabase/nua-llm/tree/main/nua-client#readme",
26
26
  "main": "./dist/cjs/index.cjs",
27
- "types": "./dist/types/index.d.cts",
27
+ "types": "./dist/index.d.cts",
28
28
  "module": "./dist/esm/index.mjs",
29
29
  "exports": {
30
30
  ".": {
31
31
  "import": {
32
- "types": "./dist/types/index.d.mts",
32
+ "types": "./dist/index.d.mts",
33
33
  "default": "./dist/esm/index.mjs"
34
34
  },
35
35
  "require": {
36
- "types": "./dist/types/index.d.cts",
36
+ "types": "./dist/index.d.cts",
37
37
  "default": "./dist/cjs/index.cjs"
38
38
  }
39
39
  },
40
40
  "./local-agent": {
41
41
  "import": {
42
- "types": "./dist/types/local-agent.d.mts",
42
+ "types": "./dist/local-agent.d.mts",
43
43
  "default": "./dist/esm/local-agent.mjs"
44
44
  },
45
45
  "require": {
46
- "types": "./dist/types/local-agent.d.cts",
46
+ "types": "./dist/local-agent.d.cts",
47
47
  "default": "./dist/cjs/local-agent.cjs"
48
48
  }
49
49
  }
@@ -51,7 +51,7 @@
51
51
  "typesVersions": {
52
52
  "*": {
53
53
  "local-agent": [
54
- "./dist/types/local-agent.d.cts"
54
+ "./dist/local-agent.d.cts"
55
55
  ]
56
56
  }
57
57
  },
@@ -59,48 +59,37 @@
59
59
  "zod": "^4.1.5"
60
60
  },
61
61
  "devDependencies": {
62
- "ajv": "^8.17.1",
62
+ "@arethetypeswrong/cli": "^0.18.5",
63
63
  "@eslint/js": "^9.35.0",
64
64
  "@ianvs/prettier-plugin-sort-imports": "^4.7.0",
65
65
  "@rollup/plugin-commonjs": "^28.0.6",
66
- "@rollup/plugin-json": "^6.1.0",
67
66
  "@rollup/plugin-node-resolve": "^16.0.1",
68
67
  "@rollup/plugin-replace": "^6.0.2",
69
- "@types/fs-extra": "^11",
70
68
  "@types/jest": "^30.0.0",
71
69
  "@types/node": "^24.3.3",
72
70
  "@types/signale": "^1",
73
- "@types/yargs": "^17.0.33",
74
- "chalk": "^5.6.2",
75
71
  "esbuild": "^0.25.9",
76
72
  "eslint": "^9.35.0",
77
- "eventsource": "^4.0.0",
78
- "fs-extra": "^11.3.1",
79
73
  "jest": "^30.1.3",
80
74
  "knip": "^5.63.1",
81
- "new-github-release-url": "^2.0.0",
82
- "open": "^10.2.0",
83
75
  "prettier": "^3.6.2",
84
76
  "rimraf": "^6.0.1",
85
77
  "rollup": "^4.50.1",
78
+ "rollup-plugin-dts": "^6.5.1",
86
79
  "rollup-plugin-esbuild": "^6.2.1",
87
80
  "rollup-plugin-node-externals": "^8.1.1",
88
81
  "signale": "^1.4.0",
89
- "simple-git": "^3.28.0",
90
82
  "ts-jest": "^29.4.1",
91
83
  "tsx": "^4.20.5",
92
84
  "typescript": "^5.9.2",
93
85
  "typescript-eslint": "^8.43.0",
94
- "version-next": "^1.0.2",
95
- "yargs": "^18.0.0",
96
- "zod": "^4.1.5",
86
+ "zod": "^4.6.7",
97
87
  "zx": "^8.8.1",
98
88
  "nua-llm-core": "1.0.0"
99
89
  },
100
90
  "scripts": {
101
91
  "clean": "rimraf dist",
102
- "generate-dts": "tsx scripts/generate-dts",
103
- "build": "pnpm run clean && rollup -c rollup.config.js && pnpm run generate-dts",
92
+ "build": "pnpm run clean && rollup -c rollup.config.js",
104
93
  "pack:test": "tsx scripts/pack-test",
105
94
  "prettier:check": "prettier --check \"**/*.{ts,tsx}\"",
106
95
  "prettier:write": "prettier --write \"**/*.{ts,tsx}\"",
@@ -108,7 +97,6 @@
108
97
  "lint": "eslint --cache .",
109
98
  "jest": "jest",
110
99
  "test": "pnpm run prettier:check && pnpm run typecheck && pnpm run lint && pnpm run jest && pnpm run build && pnpm run pack:test",
111
- "release": "pnpm test && tsx scripts/release",
112
100
  "knip": "knip"
113
101
  }
114
102
  }