gitnexus 1.6.10-rc.71 → 1.6.10-rc.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/core/embeddings/node-module-compat.d.ts +4 -2
- package/dist/core/embeddings/node-module-compat.js +4 -2
- package/dist/core/embeddings/onnxruntime-common-resolver.js +5 -5
- package/dist/core/embeddings/onnxruntime-node-resolver.js +2 -2
- package/dist/core/embeddings/runtime-install.js +1 -1
- package/dist/core/ingestion/workers/worker-pool.d.ts +14 -0
- package/dist/core/ingestion/workers/worker-pool.js +43 -23
- package/package.json +2 -3
- package/web/assets/{agent-A0etRnOc.js → agent-qSSvO6_H.js} +1 -1
- package/web/assets/{index-B4E0OhHQ.js → index-Bupak9MW.js} +4 -4
- package/web/assets/src-Cv1eWg0o.js +1 -0
- package/web/index.html +2 -2
- package/web/assets/src-BNCXICdA.js +0 -1
package/README.md
CHANGED
|
@@ -548,7 +548,7 @@ For repositories with very large source files, `GITNEXUS_WORKER_SUB_BATCH_MAX_BY
|
|
|
548
548
|
|
|
549
549
|
### Worker pool resilience tuning
|
|
550
550
|
|
|
551
|
-
|
|
551
|
+
Four env vars expose the pool's resilience layers (respawn budget, cumulative-timeout cap, circuit breaker, startup handshake). Defaults are tuned for typical repos; bump them when an analyze legitimately needs more retries, or lower them to fail-fast on a known-bad shape.
|
|
552
552
|
|
|
553
553
|
| Variable | Default | Effect |
|
|
554
554
|
| ----------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
@@ -556,6 +556,7 @@ Three env vars expose the pool's resilience layers (respawn budget, cumulative-t
|
|
|
556
556
|
| `GITNEXUS_WORKER_MAX_CUMULATIVE_TIMEOUT_MS` | `5 × subBatchTimeoutMs` | Total retry wall-time budget per job before quarantining. Bounds exponentially-growing retry waits. |
|
|
557
557
|
| `GITNEXUS_WORKER_CONSECUTIVE_FAILURE_THRESHOLD` | `max(3, poolSize)` | Per-slot consecutive deaths before the pool's circuit breaker trips. After tripping, dispatches require a fresh pool. |
|
|
558
558
|
| `GITNEXUS_WORKER_SHUTDOWN_DRAIN_MS` | `30000` | Max wait at pool shutdown for a retired worker still inside native code — terminated at its next JS-safe point instead of mid-native-call, which would abort the process (`Napi::Error`, #2432). |
|
|
559
|
+
| `GITNEXUS_WORKER_READY_TIMEOUT_MS` | `5000` | Startup budget for a parse worker to load its grammar bindings and report `{type:'ready'}`. Slots that miss it are treated as startup crashes. Raise it on a slow or heavily loaded host where a full pool cold-starting concurrently needs more than 5s. |
|
|
559
560
|
| `GITNEXUS_CPP_CAPTURE_BUDGET_MS` | `20000` | Per-file wall-clock budget for C++ capture extraction; on breach the file keeps partial captures with a warning (#2432). `0` expires immediately. |
|
|
560
561
|
|
|
561
562
|
### Graph cleanup tuning
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `module.registerHooks` — the synchronous ESM/CJS resolution-hook API the
|
|
5
5
|
* embedding-stack resolvers rely on — was added in Node 22.15.0 (and 23.5.0 on
|
|
6
|
-
* the 23.x line). The gitnexus engines floor is
|
|
7
|
-
*
|
|
6
|
+
* the 23.x line). The gitnexus engines floor is `^22.18.0 || >=24.11.0`, so
|
|
7
|
+
* every supported runtime exposes it — but `engines` is advisory (not
|
|
8
|
+
* engine-strict), so a below-floor Node (22.0–22.14, or the unsupported
|
|
9
|
+
* 23.0–23.4 line) can still run, where the export is absent.
|
|
8
10
|
*
|
|
9
11
|
* In this `"type": "module"` package, a *static named* import of a missing
|
|
10
12
|
* builtin export (`import { registerHooks } from 'node:module'`) is a
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `module.registerHooks` — the synchronous ESM/CJS resolution-hook API the
|
|
5
5
|
* embedding-stack resolvers rely on — was added in Node 22.15.0 (and 23.5.0 on
|
|
6
|
-
* the 23.x line). The gitnexus engines floor is
|
|
7
|
-
*
|
|
6
|
+
* the 23.x line). The gitnexus engines floor is `^22.18.0 || >=24.11.0`, so
|
|
7
|
+
* every supported runtime exposes it — but `engines` is advisory (not
|
|
8
|
+
* engine-strict), so a below-floor Node (22.0–22.14, or the unsupported
|
|
9
|
+
* 23.0–23.4 line) can still run, where the export is absent.
|
|
8
10
|
*
|
|
9
11
|
* In this `"type": "module"` package, a *static named* import of a missing
|
|
10
12
|
* builtin export (`import { registerHooks } from 'node:module'`) is a
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
* per-resolution cost is a single string comparison.
|
|
53
53
|
*
|
|
54
54
|
* `module.registerHooks` is marked `@experimental` and requires Node >= 22.15
|
|
55
|
-
* (the gitnexus engines floor
|
|
56
|
-
* this is a graceful no-op: embeddings then resolve onnxruntime-common exactly
|
|
55
|
+
* (below the gitnexus engines floor of `^22.18.0 || >=24.11.0`). On below-floor
|
|
56
|
+
* runtimes it is absent and this is a graceful no-op: embeddings then resolve onnxruntime-common exactly
|
|
57
57
|
* as before — fine on hoisted layouts. Any failure during installation is
|
|
58
58
|
* swallowed.
|
|
59
59
|
*/
|
|
@@ -99,9 +99,9 @@ export const ensureOnnxRuntimeCommonResolvable = () => {
|
|
|
99
99
|
// initEmbedder() call, and the hook is process-global — once is enough.
|
|
100
100
|
attempted = true;
|
|
101
101
|
try {
|
|
102
|
-
// Node < 22.15 / < 23.5 (the gitnexus engines floor
|
|
103
|
-
// synchronous hooks API. Degrade gracefully —
|
|
104
|
-
// hoisted layouts.
|
|
102
|
+
// Node < 22.15 / < 23.5 (below the gitnexus engines floor of
|
|
103
|
+
// ^22.18.0 || >=24.11.0): no synchronous hooks API. Degrade gracefully —
|
|
104
|
+
// the import still works on hoisted layouts.
|
|
105
105
|
const registerHooks = getRegisterHooks();
|
|
106
106
|
if (typeof registerHooks !== 'function')
|
|
107
107
|
return;
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
* So CUDA-12 hosts, Windows (DirectML), macOS, and CPU-only hosts are
|
|
37
37
|
* untouched. Idempotent; any failure is swallowed and leaves the default
|
|
38
38
|
* resolution exactly as before. `module.registerHooks` requires Node >= 22.15
|
|
39
|
-
* (the gitnexus engines floor
|
|
40
|
-
* a no-op, but the default copy's CUDA major is still probed so an
|
|
39
|
+
* (below the gitnexus engines floor of `^22.18.0 || >=24.11.0`); on below-floor
|
|
40
|
+
* runtimes the redirect is a no-op, but the default copy's CUDA major is still probed so an
|
|
41
41
|
* already-matching host (e.g. CUDA 12 + transformers' CUDA-12 build) keeps
|
|
42
42
|
* auto-selecting the GPU.
|
|
43
43
|
* `npm link` / symlinked local-dev checkouts are a known caveat: `resolveOurOrtNodeDir`/
|
|
@@ -170,7 +170,7 @@ export const ensureEmbeddingStackResolvable = () => {
|
|
|
170
170
|
return;
|
|
171
171
|
hookAttempted = true;
|
|
172
172
|
try {
|
|
173
|
-
// Node < 22.15 / < 23.5 (engines floor
|
|
173
|
+
// Node < 22.15 / < 23.5 (below the engines floor of ^22.18.0 || >=24.11.0): no synchronous hooks
|
|
174
174
|
// API. Degrade gracefully — normally-installed stacks still resolve; only
|
|
175
175
|
// the runtime-prefix fallback is unavailable. Reachable now that the import
|
|
176
176
|
// is a namespace access (see node-module-compat.ts) rather than a static
|
|
@@ -99,6 +99,19 @@ export interface WorkerPoolOptions {
|
|
|
99
99
|
* created. Default `Math.max(3, poolSize)`.
|
|
100
100
|
*/
|
|
101
101
|
consecutiveFailureThreshold?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Startup budget in milliseconds for a replacement worker to emit the
|
|
104
|
+
* `{type:'ready'}` handshake before the pool treats it as a startup
|
|
105
|
+
* crash (see {@link waitForWorkerReady}). Default 5000; also overridable
|
|
106
|
+
* via `GITNEXUS_WORKER_READY_TIMEOUT_MS`, mirroring
|
|
107
|
+
* `GITNEXUS_WORKER_SUB_BATCH_TIMEOUT_MS`. On a slow or heavily loaded
|
|
108
|
+
* host, a full pool of workers cold-starting concurrently can
|
|
109
|
+
* legitimately need more than 5s to load the native grammar bindings —
|
|
110
|
+
* without the override every slot times out and the pool misclassifies
|
|
111
|
+
* the slow start as a deterministic startup crash-loop, aborting the
|
|
112
|
+
* whole analyze.
|
|
113
|
+
*/
|
|
114
|
+
workerReadyTimeoutMs?: number;
|
|
102
115
|
/**
|
|
103
116
|
* Test-only injection point for the Worker constructor. When provided,
|
|
104
117
|
* the pool uses this factory instead of `new Worker(workerUrl)`. Production
|
|
@@ -207,6 +220,7 @@ interface ResolvedWorkerPoolOptions {
|
|
|
207
220
|
maxCumulativeTimeoutMs: number;
|
|
208
221
|
consecutiveFailureThreshold: number;
|
|
209
222
|
shutdownDrainMs: number;
|
|
223
|
+
workerReadyTimeoutMs: number;
|
|
210
224
|
}
|
|
211
225
|
export declare function resolveWorkerPoolOptions(options?: WorkerPoolOptions, poolSize?: number): ResolvedWorkerPoolOptions;
|
|
212
226
|
/**
|
|
@@ -116,17 +116,7 @@ const DEFAULT_TIMEOUT_BACKOFF_FACTOR = 2;
|
|
|
116
116
|
const DEFAULT_MAX_RESPAWNS_PER_SLOT = 3;
|
|
117
117
|
const DEFAULT_MAX_CUMULATIVE_TIMEOUT_FACTOR = 5;
|
|
118
118
|
const DEFAULT_CONSECUTIVE_FAILURE_THRESHOLD_FLOOR = 3;
|
|
119
|
-
|
|
120
|
-
* Bounded wait for a replacement worker to emit the `{type:'ready'}`
|
|
121
|
-
* handshake from `parse-worker.ts`. Trusting Node's `online` event alone
|
|
122
|
-
* lets a worker that crashes during top-of-script init slip past pool
|
|
123
|
-
* startup — the pool only notices on the first dispatch's idle timeout
|
|
124
|
-
* (default 30s). 5 seconds is a generous budget for parser + grammar
|
|
125
|
-
* imports; if the worker hasn't reported ready by then, it's almost
|
|
126
|
-
* certainly stuck or crashed and the pool should surface the failure
|
|
127
|
-
* fast rather than wait out the dispatch idle timeout.
|
|
128
|
-
*/
|
|
129
|
-
const WORKER_READY_TIMEOUT_MS = 5_000;
|
|
119
|
+
const DEFAULT_WORKER_READY_TIMEOUT_MS = 5_000;
|
|
130
120
|
/**
|
|
131
121
|
* Default upper bound on auto-resolved pool size. Past 16 workers the
|
|
132
122
|
* dominant cost shifts from worker-side parsing to main-thread merge /
|
|
@@ -257,6 +247,9 @@ export function resolveWorkerPoolOptions(options = {}, poolSize) {
|
|
|
257
247
|
shutdownDrainMs: nonNegativeInteger(options.shutdownDrainMs) ??
|
|
258
248
|
nonNegativeInteger(process.env.GITNEXUS_WORKER_SHUTDOWN_DRAIN_MS) ??
|
|
259
249
|
DEFAULT_SHUTDOWN_DRAIN_MS,
|
|
250
|
+
workerReadyTimeoutMs: positiveInteger(options.workerReadyTimeoutMs) ??
|
|
251
|
+
positiveInteger(process.env.GITNEXUS_WORKER_READY_TIMEOUT_MS) ??
|
|
252
|
+
DEFAULT_WORKER_READY_TIMEOUT_MS,
|
|
260
253
|
};
|
|
261
254
|
}
|
|
262
255
|
/**
|
|
@@ -352,6 +345,27 @@ function captureWorkerStderr(worker) {
|
|
|
352
345
|
// A stderr stream error must never crash the pool.
|
|
353
346
|
stream.on('error', () => undefined);
|
|
354
347
|
}
|
|
348
|
+
/**
|
|
349
|
+
* Forward a worker's piped stdout to the parent process's stdout, so worker
|
|
350
|
+
* logs stay visible now that the production factory spawns with
|
|
351
|
+
* `{ stdout: true }`. Workers with INHERITED stdout have been observed to
|
|
352
|
+
* crash silently during top-of-script init (exit code 1, nothing on stderr,
|
|
353
|
+
* roughly half of a concurrently spawned pool) on macOS 26.5 under both
|
|
354
|
+
* Node 22 and 26; piping stdout eliminates the crash entirely. Piping also
|
|
355
|
+
* matches the existing stderr handling, so worker output no longer races the
|
|
356
|
+
* parent's raw fd. No-op when the worker has no `stdout` stream (test
|
|
357
|
+
* factories).
|
|
358
|
+
*/
|
|
359
|
+
function forwardWorkerStdout(worker) {
|
|
360
|
+
const stream = worker.stdout;
|
|
361
|
+
if (!stream)
|
|
362
|
+
return;
|
|
363
|
+
stream.on('data', (chunk) => {
|
|
364
|
+
process.stdout.write(chunk);
|
|
365
|
+
});
|
|
366
|
+
// A stdout stream error must never crash the pool.
|
|
367
|
+
stream.on('error', () => undefined);
|
|
368
|
+
}
|
|
355
369
|
/** Captured stderr tail for a worker, trimmed; '' when nothing was captured. */
|
|
356
370
|
function workerStderrTail(worker) {
|
|
357
371
|
return workerStderrTails.get(worker)?.text.trim() ?? '';
|
|
@@ -388,13 +402,14 @@ function workerErrorReason(workerIndex, message, stack) {
|
|
|
388
402
|
* (parser/grammar import failure, missing native binding) slip past
|
|
389
403
|
* pool startup. The pool then only noticed the dead replacement on the
|
|
390
404
|
* first dispatch's idle timeout (default 30s) — a long stall masking
|
|
391
|
-
* an actual crash. This handshake bounds the wait at
|
|
392
|
-
* {@link
|
|
393
|
-
* `error` / `exit` / `messageerror` events directly.
|
|
394
|
-
* wired the same way: a V8 deserialization failure
|
|
395
|
-
* treated as worker death and rejects the readiness
|
|
405
|
+
* an actual crash. This handshake bounds the wait at `readyTimeoutMs`
|
|
406
|
+
* (see {@link WorkerPoolOptions.workerReadyTimeoutMs}) and surfaces init
|
|
407
|
+
* failures as `error` / `exit` / `messageerror` events directly.
|
|
408
|
+
* `messageerror` is wired the same way: a V8 deserialization failure
|
|
409
|
+
* during startup is treated as worker death and rejects the readiness
|
|
410
|
+
* promise.
|
|
396
411
|
*/
|
|
397
|
-
function waitForWorkerReady(worker) {
|
|
412
|
+
function waitForWorkerReady(worker, readyTimeoutMs) {
|
|
398
413
|
return new Promise((resolve, reject) => {
|
|
399
414
|
const cleanup = () => {
|
|
400
415
|
clearTimeout(timer);
|
|
@@ -432,8 +447,8 @@ function waitForWorkerReady(worker) {
|
|
|
432
447
|
// access can fire from the listeners.
|
|
433
448
|
const timer = setTimeout(() => {
|
|
434
449
|
cleanup();
|
|
435
|
-
reject(new Error(withStderr(worker, `Replacement worker did not report ready within ${
|
|
436
|
-
},
|
|
450
|
+
reject(new Error(withStderr(worker, `Replacement worker did not report ready within ${readyTimeoutMs}ms — likely crashed during top-of-script init (slow host? raise GITNEXUS_WORKER_READY_TIMEOUT_MS)`)));
|
|
451
|
+
}, readyTimeoutMs);
|
|
437
452
|
worker.on('message', onMessage);
|
|
438
453
|
worker.once('error', onError);
|
|
439
454
|
worker.once('exit', onExit);
|
|
@@ -563,6 +578,10 @@ export const createWorkerPool = (workerUrl, poolSize, options) => {
|
|
|
563
578
|
: undefined;
|
|
564
579
|
const spawnWorker = options?.workerFactory ??
|
|
565
580
|
((url) => new Worker(url, {
|
|
581
|
+
// Piped (not inherited) stdio: stderr for crash capture (#1741),
|
|
582
|
+
// stdout because inherited stdout triggers silent startup crashes on
|
|
583
|
+
// some hosts (see forwardWorkerStdout).
|
|
584
|
+
stdout: true,
|
|
566
585
|
stderr: true,
|
|
567
586
|
workerData: workerStoreData,
|
|
568
587
|
// The CFG visitors build per-function control-flow graphs by RECURSIVE
|
|
@@ -576,10 +595,11 @@ export const createWorkerPool = (workerUrl, poolSize, options) => {
|
|
|
576
595
|
// try/catch) and only that function's PDG is skipped, never a crash.
|
|
577
596
|
resourceLimits: { stackSizeMb: 16 },
|
|
578
597
|
}));
|
|
579
|
-
/** Spawn + wire
|
|
598
|
+
/** Spawn + wire stdio capture/forwarding in one step (used by all spawn sites). */
|
|
580
599
|
const spawnAndCapture = (url) => {
|
|
581
600
|
const worker = spawnWorker(url);
|
|
582
601
|
captureWorkerStderr(worker);
|
|
602
|
+
forwardWorkerStdout(worker);
|
|
583
603
|
return worker;
|
|
584
604
|
};
|
|
585
605
|
const workers = new Array(size);
|
|
@@ -707,7 +727,7 @@ export const createWorkerPool = (workerUrl, poolSize, options) => {
|
|
|
707
727
|
if (!worker)
|
|
708
728
|
return; // terminated mid-startup
|
|
709
729
|
try {
|
|
710
|
-
await waitForWorkerReady(worker);
|
|
730
|
+
await waitForWorkerReady(worker, poolOptions.workerReadyTimeoutMs);
|
|
711
731
|
anyWorkerReachedReady = true;
|
|
712
732
|
return; // ready — slot stays in activeSlots
|
|
713
733
|
}
|
|
@@ -751,7 +771,7 @@ export const createWorkerPool = (workerUrl, poolSize, options) => {
|
|
|
751
771
|
const initialReadyGate = Promise.allSettled(workers.map((_, i) => bringSlotReady(i))).then(() => undefined);
|
|
752
772
|
const dispatch = async (items, onProgress, chunkHash) => {
|
|
753
773
|
// Await the initial-spawn readiness gate (F13). On first dispatch
|
|
754
|
-
// this blocks for up to
|
|
774
|
+
// this blocks for up to poolOptions.workerReadyTimeoutMs while every initial
|
|
755
775
|
// worker's `{type:'ready'}` handshake is checked; on subsequent
|
|
756
776
|
// dispatches the promise is already settled and resolves
|
|
757
777
|
// synchronously. Slots whose initial worker crashed in top-of-
|
|
@@ -914,7 +934,7 @@ export const createWorkerPool = (workerUrl, poolSize, options) => {
|
|
|
914
934
|
return false;
|
|
915
935
|
const replacement = spawnAndCapture(workerUrl);
|
|
916
936
|
try {
|
|
917
|
-
await waitForWorkerReady(replacement);
|
|
937
|
+
await waitForWorkerReady(replacement, poolOptions.workerReadyTimeoutMs);
|
|
918
938
|
}
|
|
919
939
|
catch (err) {
|
|
920
940
|
await replacement.terminate().catch(() => undefined);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gitnexus",
|
|
3
|
-
"version": "1.6.10-rc.
|
|
3
|
+
"version": "1.6.10-rc.73",
|
|
4
4
|
"description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
|
|
5
5
|
"author": "Abhigyan Patwari",
|
|
6
6
|
"license": "PolyForm-Noncommercial-1.0.0",
|
|
@@ -107,7 +107,6 @@
|
|
|
107
107
|
"@types/express": "^5.0.6",
|
|
108
108
|
"@types/js-yaml": "^4.0.9",
|
|
109
109
|
"@types/node": "^26.0.0",
|
|
110
|
-
"@types/uuid": "^11.0.0",
|
|
111
110
|
"@vitest/coverage-v8": "^4.0.18",
|
|
112
111
|
"gitnexus-shared": "file:../gitnexus-shared",
|
|
113
112
|
"tsx": "^4.0.0",
|
|
@@ -120,6 +119,6 @@
|
|
|
120
119
|
}
|
|
121
120
|
},
|
|
122
121
|
"engines": {
|
|
123
|
-
"node": "
|
|
122
|
+
"node": "^22.18.0 || >=24.11.0"
|
|
124
123
|
}
|
|
125
124
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import"./src-
|
|
1
|
+
import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import"./src-Cv1eWg0o.js";import{i as n,t as r}from"./sdk-CzHHH8tD.js";import{CHAT_ONLY_PROMPT_NOTE as i,buildDynamicSystemPrompt as a}from"./context-builder-BHiFUA8O.js";var o=`File.Folder.Function.Class.Interface.Method.CodeElement.Community.Process.Section.Struct.Enum.Macro.Typedef.Union.Namespace.Trait.Impl.TypeAlias.Const.Static.Variable.Property.Record.Delegate.Annotation.Constructor.Template.Module.Route.Tool.BasicBlock`.split(`.`),s=`CONTAINS.DEFINES.IMPORTS.CALLS.EXTENDS.IMPLEMENTS.HAS_METHOD.HAS_PROPERTY.ACCESSES.METHOD_OVERRIDES.OVERRIDES.METHOD_IMPLEMENTS.MEMBER_OF.STEP_IN_PROCESS.HANDLES_ROUTE.FETCHES.HANDLES_TOOL.ENTRY_POINT_OF.WRAPS.QUERIES.INJECTS.CFG.REACHING_DEF.TAINTED.SANITIZES.TAINT_PATH.CDG.POST_DOMINATE`.split(`.`),c=new Set([`date-time`,`time`,`date`,`duration`,`email`,`hostname`,`uri`,`ipv4`,`ipv6`,`uuid`]);function l(e){return JSON.parse(JSON.stringify(e))}function u(e){return d(l(e))}function d(e){let t={},r=n(e,`$ref`);if(r!==void 0)return t.$ref=r,t;let i=n(e,`$defs`);if(i!==void 0){let e={};t.$defs=e;for(let[t,n]of Object.entries(i))e[t]=d(n)}let a=n(e,`type`),o=n(e,`anyOf`),s=n(e,`oneOf`),l=n(e,`allOf`);if(Array.isArray(o))t.anyOf=o.map(e=>d(e));else if(Array.isArray(s))t.anyOf=s.map(e=>d(e));else if(Array.isArray(l))t.allOf=l.map(e=>d(e));else{if(a===void 0)throw Error(`JSON schema must have a type defined if anyOf/oneOf/allOf are not used`);t.type=a}let u=n(e,`description`);u!==void 0&&(t.description=u);let f=n(e,`title`);if(f!==void 0&&(t.title=f),a===`object`){let r=n(e,`properties`)||{};t.properties=Object.fromEntries(Object.entries(r).map(([e,t])=>[e,d(t)])),n(e,`additionalProperties`),t.additionalProperties=!1;let i=n(e,`required`);i!==void 0&&(t.required=i)}else if(a===`string`){let r=n(e,`format`);r!==void 0&&c.has(r)?t.format=r:r!==void 0&&(e.format=r)}else if(a===`array`){let r=n(e,`items`);r!==void 0&&(t.items=d(r));let i=n(e,`minItems`);i!==void 0&&(i===0||i===1)?t.minItems=i:i!==void 0&&(e.minItems=i)}if(Object.keys(e).length>0){let n=t.description;t.description=(n?n+`
|
|
2
2
|
|
|
3
3
|
`:``)+`{`+Object.entries(e).map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(`, `)+`}`}return t}var f=Object.defineProperty,p=(e,t)=>{let n={};for(var r in e)f(n,r,{get:e[r],enumerable:!0});return t||f(n,Symbol.toStringTag,{value:`Module`}),n};function m(e){let t=Symbol.for(e);return{brand(n,r){let i=r?Symbol.for(`${e}.${r}`):t;class a extends n{[i]=!0;constructor(...e){super(...e)}static isInstance(e){return typeof e==`object`&&!!e&&i in e&&e[i]===!0}}return Object.defineProperty(a,"name",{value:n.name}),a},sub(t){return m(`${e}.${t}`)},isInstance(e){return typeof e==`object`&&!!e&&t in e&&e[t]===!0}}}var h=m(`langchain`),g=p({ContextOverflowError:()=>x,LangChainError:()=>y,ModelAbortError:()=>b,addLangChainErrorFields:()=>_,ns:()=>v});function _(e,t){return e.lc_error_code=t,e.message=`${e.message}\n\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${t}/\n`,e}var v=h.sub(`error`),y=class extends v.brand(Error){name=`LangChainError`;constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},b=class extends v.brand(y,`model-abort`){name=`ModelAbortError`;partialOutput;constructor(e,t){super(e),this.partialOutput=t}},x=class e extends v.brand(y,`context-overflow`){name=`ContextOverflowError`;cause;constructor(e){super(e??`Input exceeded the model's context window.`)}static fromError(t){let n=new e(t.message);return n.cause=t,n}};function S(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`tool_call`)}function ee(e){return!!(e&&typeof e==`object`&&`toolCall`in e&&e.toolCall!=null&&typeof e.toolCall==`object`&&`id`in e.toolCall&&typeof e.toolCall.id==`string`)}var C=class extends Error{output;constructor(e,t){super(e),this.output=t}};function te(e,t=re){e=e.trim();let n=e.indexOf("```");if(n===-1)return t(e);let r=e.substring(n+3);r.startsWith(`json
|
|
4
4
|
`)?r=r.substring(5):r.startsWith(`json`)?r=r.substring(4):r.startsWith(`
|