gitnexus 1.6.6-rc.57 → 1.6.6-rc.59

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 (42) hide show
  1. package/dist/_shared/pipeline.d.ts +1 -1
  2. package/dist/_shared/pipeline.d.ts.map +1 -1
  3. package/dist/cli/analyze.js +3 -2
  4. package/dist/cli/format-elapsed.d.ts +1 -0
  5. package/dist/cli/format-elapsed.js +9 -0
  6. package/dist/core/ingestion/languages/cpp/two-phase-lookup.js +28 -6
  7. package/dist/core/ingestion/pipeline-phases/communities.js +2 -2
  8. package/dist/core/ingestion/pipeline-phases/mro.d.ts +1 -1
  9. package/dist/core/ingestion/pipeline-phases/mro.js +3 -3
  10. package/dist/core/ingestion/pipeline-phases/processes.js +2 -2
  11. package/dist/core/ingestion/scope-resolution/pipeline/phase.js +79 -0
  12. package/dist/core/ingestion/scope-resolution/pipeline/run.d.ts +11 -0
  13. package/dist/core/ingestion/scope-resolution/pipeline/run.js +11 -1
  14. package/dist/core/run-analyze.js +1 -0
  15. package/package.json +1 -1
  16. package/web/assets/{agent-Bxuh7ijU.js → agent-CXodIfqQ.js} +1 -1
  17. package/web/assets/{architectureDiagram-UL44E2DR-dt95Hukn.js → architectureDiagram-UL44E2DR-F3Kv6WXi.js} +1 -1
  18. package/web/assets/{chunk-LCXTWHL2-Cdh9EATr.js → chunk-LCXTWHL2-e71Tved8.js} +1 -1
  19. package/web/assets/{chunk-RG4AUYOV-rInVBoUc.js → chunk-RG4AUYOV-DwTKtFRu.js} +1 -1
  20. package/web/assets/{classDiagram-KGZ6W3CR-CNEUBLxN.js → classDiagram-KGZ6W3CR-CGBaLeR5.js} +1 -1
  21. package/web/assets/{classDiagram-v2-72OJOZXJ-B-fGOm10.js → classDiagram-v2-72OJOZXJ-S_nvP2j8.js} +1 -1
  22. package/web/assets/{diagram-3NCE3AQN-BPub5g8u.js → diagram-3NCE3AQN-YgVu4TcC.js} +1 -1
  23. package/web/assets/{diagram-GF46GFSD-DWRcV0eU.js → diagram-GF46GFSD-C2mcjI8i.js} +1 -1
  24. package/web/assets/{diagram-QXG6HAR7-DVl5ccGA.js → diagram-QXG6HAR7-iovcKZin.js} +1 -1
  25. package/web/assets/{diagram-WEQXMOUZ-C10j2lOR.js → diagram-WEQXMOUZ-CpmOrC5F.js} +1 -1
  26. package/web/assets/{erDiagram-L5TCEMPS-B5LF-WPa.js → erDiagram-L5TCEMPS-CqFj0qUx.js} +1 -1
  27. package/web/assets/{flowDiagram-H6V6AXG4-BiZxDBYI.js → flowDiagram-H6V6AXG4-C05kmqzJ.js} +1 -1
  28. package/web/assets/{index-De0ddoRo.js → index-CIYHLoJU.js} +5 -5
  29. package/web/assets/{infoDiagram-3YFTVSEB-DziuNyk-.js → infoDiagram-3YFTVSEB-Czl4jEnZ.js} +1 -1
  30. package/web/assets/{ishikawaDiagram-BNXS4ZKH-C1tcZRup.js → ishikawaDiagram-BNXS4ZKH-BxjNLT9R.js} +1 -1
  31. package/web/assets/{kanban-definition-75IXJCU3-BCP9-jRe.js → kanban-definition-75IXJCU3-NWlMjXqS.js} +1 -1
  32. package/web/assets/{mindmap-definition-2TDM6QVE-CL1z-RaS.js → mindmap-definition-2TDM6QVE-BUQNti69.js} +1 -1
  33. package/web/assets/{pieDiagram-CU6KROY3-CiADzOzf.js → pieDiagram-CU6KROY3-Db6qcsuD.js} +1 -1
  34. package/web/assets/{requirementDiagram-JXO7QTGE-ySEK2fPh.js → requirementDiagram-JXO7QTGE-inK4x9gj.js} +1 -1
  35. package/web/assets/{sequenceDiagram-VS2MUI6T-iBHND5Yr.js → sequenceDiagram-VS2MUI6T-BoU-CY5h.js} +1 -1
  36. package/web/assets/{stateDiagram-7D4R322I-vnAKTAk0.js → stateDiagram-7D4R322I-D8GDQFzc.js} +1 -1
  37. package/web/assets/{stateDiagram-v2-36443NZ5-Bm8k2tfP.js → stateDiagram-v2-36443NZ5-ChXmmgfq.js} +1 -1
  38. package/web/assets/{timeline-definition-O6YCAMPW-8wFMD-XJ.js → timeline-definition-O6YCAMPW-CsxteyaC.js} +1 -1
  39. package/web/assets/{vennDiagram-MWXL3ELB-DyRyc0li.js → vennDiagram-MWXL3ELB-CnBtST5h.js} +1 -1
  40. package/web/assets/{wardleyDiagram-CUQ6CDDI-Bc0TgYTn.js → wardleyDiagram-CUQ6CDDI-BhdtK7NU.js} +1 -1
  41. package/web/assets/{xychartDiagram-N2JHSOCM-wihPCGcn.js → xychartDiagram-N2JHSOCM-DgPjrTso.js} +1 -1
  42. package/web/index.html +1 -1
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Pipeline progress types — shared between CLI and web.
3
3
  */
4
- export type PipelinePhase = 'idle' | 'extracting' | 'structure' | 'parsing' | 'imports' | 'calls' | 'heritage' | 'communities' | 'processes' | 'enriching' | 'complete' | 'error';
4
+ export type PipelinePhase = 'idle' | 'extracting' | 'structure' | 'parsing' | 'imports' | 'calls' | 'heritage' | 'scopeResolution' | 'communities' | 'processes' | 'enriching' | 'complete' | 'error';
5
5
  export interface PipelineProgress {
6
6
  phase: PipelinePhase;
7
7
  percent: number;
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,YAAY,GACZ,WAAW,GACX,SAAS,GACT,SAAS,GACT,OAAO,GACP,UAAU,GACV,aAAa,GACb,WAAW,GACX,WAAW,GACX,UAAU,GACV,OAAO,CAAC;AAEZ,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,aAAa,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH"}
1
+ {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,YAAY,GACZ,WAAW,GACX,SAAS,GACT,SAAS,GACT,OAAO,GACP,UAAU,GACV,iBAAiB,GACjB,aAAa,GACb,WAAW,GACX,WAAW,GACX,UAAU,GACV,OAAO,CAAC;AAEZ,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,aAAa,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH"}
@@ -21,6 +21,7 @@ import { warnMissingOptionalGrammars } from './optional-grammars.js';
21
21
  import { glob } from 'glob';
22
22
  import fs from 'fs/promises';
23
23
  import { cliError } from './cli-message.js';
24
+ import { formatElapsed } from './format-elapsed.js';
24
25
  import { isHfDownloadFailure } from '../core/embeddings/hf-env.js';
25
26
  // Capture stderr.write at module load BEFORE anything (LadybugDB native
26
27
  // init, progress bar, console redirection) can monkey-patch it. The
@@ -679,13 +680,13 @@ const analyzeCommandImpl = async (inputPath, options) => {
679
680
  phaseStart = Date.now();
680
681
  }
681
682
  const elapsed = Math.round((Date.now() - phaseStart) / 1000);
682
- const display = elapsed >= 3 ? `${phaseLabel} (${elapsed}s)` : phaseLabel;
683
+ const display = elapsed >= 3 ? `${phaseLabel} (${formatElapsed(elapsed)})` : phaseLabel;
683
684
  bar.update(value, { phase: display });
684
685
  };
685
686
  const elapsedTimer = setInterval(() => {
686
687
  const elapsed = Math.round((Date.now() - phaseStart) / 1000);
687
688
  if (elapsed >= 3) {
688
- bar.update({ phase: `${lastPhaseLabel} (${elapsed}s)` });
689
+ bar.update({ phase: `${lastPhaseLabel} (${formatElapsed(elapsed)})` });
689
690
  }
690
691
  }, 1000);
691
692
  const t0 = Date.now();
@@ -0,0 +1 @@
1
+ export declare function formatElapsed(secs: number): string;
@@ -0,0 +1,9 @@
1
+ export function formatElapsed(secs) {
2
+ if (secs < 60)
3
+ return `${secs}s`;
4
+ if (secs < 3600)
5
+ return `${Math.floor(secs / 60)}m ${secs % 60}s`;
6
+ const h = Math.floor(secs / 3600);
7
+ const m = Math.floor((secs % 3600) / 60);
8
+ return `${h}h ${m}m`;
9
+ }
@@ -153,12 +153,34 @@ export function populateCppDependentBases(parsedFiles) {
153
153
  }
154
154
  // Multiple classes share the same simple name — prefer the one
155
155
  // whose namespace matches the deriving class's namespace.
156
- // V1: exact dot-prefix match only. Cross-namespace inheritance
157
- // (e.g., `ns::outer::Derived` extending bare `Inner` defined in
158
- // `ns::outer::inner`) and inline-namespace cases are deferred to
159
- // V2; the conservative skip-on-ambiguity below avoids false
160
- // associations in those edge cases.
161
- const nsMatch = candidates.find((c) => c.nsPrefix === classEntry.nsPrefix);
156
+ // V2: filter by prefix-match capped at one level deeper, then
157
+ // accept only if exactly one candidate survives. This lets
158
+ // Derived<T> in ns::outer find Inner<T> in ns::outer::inner
159
+ // (or ns::v1 for inline-namespace variants) while rejecting
160
+ // sibling collisions (e.g. detail::Inner vs public_api::Inner).
161
+ //
162
+ // The one-segment cap limits walk depth: ns → ns.a ✓, ns → ns.a.b ✗.
163
+ // Global-scope deriving classes match any single-segment namespace.
164
+ //
165
+ // LIMITATION: True ISO behavior would use the base specifier's
166
+ // syntactic qualifier (available at captures.ts:611 as
167
+ // qualified_identifier scope) to navigate from the current scope,
168
+ // which would resolve `detail::Inner` vs `public_api::Inner`
169
+ // unambiguously. Threading the qualifier is tracked in #1815.
170
+ // Until then, sibling collisions correctly suppress.
171
+ const nsMatches = candidates.filter((c) => {
172
+ if (c.nsPrefix === classEntry.nsPrefix)
173
+ return true;
174
+ if (classEntry.nsPrefix === '') {
175
+ return c.nsPrefix !== '' && !c.nsPrefix.includes('.');
176
+ }
177
+ if (c.nsPrefix.startsWith(classEntry.nsPrefix + '.')) {
178
+ const suffix = c.nsPrefix.slice(classEntry.nsPrefix.length + 1);
179
+ return !suffix.includes('.');
180
+ }
181
+ return false;
182
+ });
183
+ const nsMatch = nsMatches.length === 1 ? nsMatches[0] : undefined;
162
184
  if (nsMatch !== undefined) {
163
185
  bases.add(nsMatch.nodeId);
164
186
  }
@@ -19,12 +19,12 @@ export const communitiesPhase = {
19
19
  const { totalFiles } = getPhaseOutput(deps, 'structure');
20
20
  ctx.onProgress({
21
21
  phase: 'communities',
22
- percent: 84,
22
+ percent: 98,
23
23
  message: 'Detecting code communities...',
24
24
  stats: { filesProcessed: totalFiles, totalFiles, nodesCreated: ctx.graph.nodeCount },
25
25
  });
26
26
  const communityResult = await processCommunities(ctx.graph, (message, progress) => {
27
- const communityProgress = 84 + progress * 0.09;
27
+ const communityProgress = 98 + progress * 0.01;
28
28
  ctx.onProgress({
29
29
  phase: 'communities',
30
30
  percent: Math.round(communityProgress),
@@ -4,7 +4,7 @@
4
4
  * Computes Method Resolution Order (MRO) and creates METHOD_OVERRIDES
5
5
  * and METHOD_IMPLEMENTS edges.
6
6
  *
7
- * @deps crossFile
7
+ * @deps crossFile, scopeResolution
8
8
  * @reads graph (all nodes and relationships)
9
9
  * @writes graph (METHOD_OVERRIDES, METHOD_IMPLEMENTS edges)
10
10
  */
@@ -4,7 +4,7 @@
4
4
  * Computes Method Resolution Order (MRO) and creates METHOD_OVERRIDES
5
5
  * and METHOD_IMPLEMENTS edges.
6
6
  *
7
- * @deps crossFile
7
+ * @deps crossFile, scopeResolution
8
8
  * @reads graph (all nodes and relationships)
9
9
  * @writes graph (METHOD_OVERRIDES, METHOD_IMPLEMENTS edges)
10
10
  */
@@ -14,12 +14,12 @@ import { isDev } from '../utils/env.js';
14
14
  import { logger } from '../../logger.js';
15
15
  export const mroPhase = {
16
16
  name: 'mro',
17
- deps: ['crossFile', 'structure'],
17
+ deps: ['crossFile', 'scopeResolution', 'structure'],
18
18
  async execute(ctx, deps) {
19
19
  const { totalFiles } = getPhaseOutput(deps, 'structure');
20
20
  ctx.onProgress({
21
21
  phase: 'enriching',
22
- percent: 83,
22
+ percent: 98,
23
23
  message: 'Computing method resolution order...',
24
24
  stats: { filesProcessed: totalFiles, totalFiles, nodesCreated: ctx.graph.nodeCount },
25
25
  });
@@ -25,7 +25,7 @@ export const processesPhase = {
25
25
  const { toolDefs } = getPhaseOutput(deps, 'tools');
26
26
  ctx.onProgress({
27
27
  phase: 'processes',
28
- percent: 94,
28
+ percent: 99,
29
29
  message: 'Detecting execution flows...',
30
30
  stats: { filesProcessed: totalFiles, totalFiles, nodesCreated: ctx.graph.nodeCount },
31
31
  });
@@ -36,7 +36,7 @@ export const processesPhase = {
36
36
  });
37
37
  const dynamicMaxProcesses = Math.max(20, Math.min(300, Math.round(symbolCount / 10)));
38
38
  const processResult = await processProcesses(ctx.graph, communityResult.memberships, (message, progress) => {
39
- const processProgress = 94 + progress * 0.05;
39
+ const processProgress = 99 + progress * 0.01;
40
40
  ctx.onProgress({
41
41
  phase: 'processes',
42
42
  percent: Math.round(processProgress),
@@ -87,6 +87,30 @@ export const scopeResolutionPhase = {
87
87
  let anyRan = false;
88
88
  const resolutionOutcomes = [];
89
89
  const perLanguage = new Map();
90
+ // Pre-count files and languages for progress reporting. This avoids
91
+ // a frozen progress bar during long scope-resolution runs (#1741).
92
+ let totalScopeFiles = 0;
93
+ let totalScopeLangs = 0;
94
+ for (const [lang] of SCOPE_RESOLVERS) {
95
+ if (!isRegistryPrimary(lang))
96
+ continue;
97
+ const count = scannedFiles.filter((f) => getLanguageFromFilename(f.path) === lang).length;
98
+ if (count > 0) {
99
+ totalScopeLangs++;
100
+ totalScopeFiles += count;
101
+ }
102
+ }
103
+ const SCOPE_PCT_START = 90;
104
+ const SCOPE_PCT_RANGE = 8; // 90-98 internal → 54-59% display
105
+ let processedScopeFiles = 0;
106
+ let currentLangIdx = 0;
107
+ if (totalScopeFiles > 0) {
108
+ ctx.onProgress({
109
+ phase: 'scopeResolution',
110
+ percent: SCOPE_PCT_START,
111
+ message: 'Resolving types',
112
+ });
113
+ }
90
114
  for (const [lang, provider] of SCOPE_RESOLVERS) {
91
115
  if (!isRegistryPrimary(lang))
92
116
  continue;
@@ -108,6 +132,19 @@ export const scopeResolutionPhase = {
108
132
  const resolutionConfig = provider.loadResolutionConfig !== undefined
109
133
  ? await provider.loadResolutionConfig(ctx.repoPath)
110
134
  : undefined;
135
+ const langFileCount = files.length;
136
+ const langLabel = lang.charAt(0).toUpperCase() + lang.slice(1);
137
+ currentLangIdx++;
138
+ const langTag = totalScopeLangs > 1 ? `${langLabel} [${currentLangIdx}/${totalScopeLangs}]` : langLabel;
139
+ if (totalScopeFiles > 0) {
140
+ const pct = SCOPE_PCT_START + Math.round((processedScopeFiles / totalScopeFiles) * SCOPE_PCT_RANGE);
141
+ ctx.onProgress({
142
+ phase: 'scopeResolution',
143
+ percent: pct,
144
+ message: 'Resolving types',
145
+ detail: `${langTag}, ${langFileCount.toLocaleString()} files`,
146
+ });
147
+ }
111
148
  const stats = runScopeResolution({
112
149
  graph: ctx.graph,
113
150
  model,
@@ -123,6 +160,39 @@ export const scopeResolutionPhase = {
123
160
  logger.warn(`[scope-resolution:${lang}] ${msg}`);
124
161
  }
125
162
  },
163
+ onProgress: totalScopeFiles > 0
164
+ ? (subPhase, current, total) => {
165
+ let langRatio;
166
+ switch (subPhase) {
167
+ case 'extracting':
168
+ langRatio = total > 0 ? (current / total) * 0.5 : 0;
169
+ break;
170
+ case 'analyzing types':
171
+ langRatio = 0.5;
172
+ break;
173
+ case 'resolving references':
174
+ langRatio = 0.7;
175
+ break;
176
+ case 'linking symbols':
177
+ langRatio = 0.85;
178
+ break;
179
+ default: {
180
+ const _exhaustive = subPhase;
181
+ langRatio = 0.85;
182
+ }
183
+ }
184
+ const overallRatio = Math.min(1, (processedScopeFiles + langRatio * langFileCount) / totalScopeFiles);
185
+ const pct = SCOPE_PCT_START + Math.round(overallRatio * SCOPE_PCT_RANGE);
186
+ ctx.onProgress({
187
+ phase: 'scopeResolution',
188
+ percent: pct,
189
+ message: 'Resolving types',
190
+ detail: subPhase === 'extracting'
191
+ ? `${langTag} — extracting ${current.toLocaleString()}/${total.toLocaleString()} files`
192
+ : `${langTag} — ${subPhase}`,
193
+ });
194
+ }
195
+ : undefined,
126
196
  }, provider);
127
197
  // Release file contents and pre-extracted entries after each language
128
198
  // to reduce memory pressure. For large codebases (16K+ PHP files),
@@ -133,6 +203,7 @@ export const scopeResolutionPhase = {
133
203
  for (const fp of filePaths) {
134
204
  preExtractedByPath.delete(fp);
135
205
  }
206
+ processedScopeFiles += langFileCount;
136
207
  anyRan = true;
137
208
  totalFiles += stats.filesProcessed;
138
209
  totalImports += stats.importsEmitted;
@@ -146,6 +217,14 @@ export const scopeResolutionPhase = {
146
217
  logger.info(`[scope-resolution:${lang}] ${stats.filesProcessed} files → ${stats.importsEmitted} IMPORTS + ${stats.referenceEdgesEmitted} reference edges (${stats.resolve.unresolved} unresolved sites, ${stats.referenceSkipped} skipped)`);
147
218
  }
148
219
  }
220
+ if (totalScopeFiles > 0 && anyRan) {
221
+ ctx.onProgress({
222
+ phase: 'scopeResolution',
223
+ percent: SCOPE_PCT_START + SCOPE_PCT_RANGE,
224
+ message: 'Resolving types',
225
+ detail: 'complete',
226
+ });
227
+ }
149
228
  // Dispose the cross-phase Tree cache — scope-resolution is the
150
229
  // only consumer. Holding Trees past this point is pure memory
151
230
  // pressure: downstream phases (mro, community, csv-generator)
@@ -28,6 +28,7 @@ import type { MutableSemanticModel } from '../../model/semantic-model.js';
28
28
  import { type ResolveStats } from '../../resolve-references.js';
29
29
  import type { ScopeResolver } from '../contract/scope-resolver.js';
30
30
  import type { ResolutionOutcome, ResolutionOutcomeRecorder } from '../resolution-outcome.js';
31
+ export type ScopeResolutionSubPhase = 'extracting' | 'analyzing types' | 'resolving references' | 'linking symbols';
31
32
  interface RunScopeResolutionInput {
32
33
  readonly graph: KnowledgeGraph;
33
34
  /**
@@ -84,6 +85,16 @@ interface RunScopeResolutionInput {
84
85
  * intentionally suppress an edge; the graph remains unchanged.
85
86
  */
86
87
  readonly recordResolutionOutcome?: ResolutionOutcomeRecorder;
88
+ /**
89
+ * Optional progress callback for UI updates during long-running scope
90
+ * resolution. Called periodically during the extract loop and at each
91
+ * sub-phase boundary (finalize, resolve, emit).
92
+ *
93
+ * @param subPhase Current sub-phase name for display
94
+ * @param current Files processed so far (during extract) or total files (at phase boundaries)
95
+ * @param total Total files in this language
96
+ */
97
+ readonly onProgress?: (subPhase: ScopeResolutionSubPhase, current: number, total: number) => void;
87
98
  }
88
99
  interface RunScopeResolutionStats {
89
100
  readonly filesProcessed: number;
@@ -116,7 +116,10 @@ export function runScopeResolution(input, provider) {
116
116
  const treeCache = input.treeCache;
117
117
  const preExtracted = input.preExtractedParsedFiles;
118
118
  let preExtractedHits = 0;
119
- for (const file of files) {
119
+ const progressInterval = files.length > 0 ? Math.max(1, Math.floor(files.length / 50)) : 1;
120
+ input.onProgress?.('extracting', 0, files.length);
121
+ for (let fileIdx = 0; fileIdx < files.length; fileIdx++) {
122
+ const file = files[fileIdx];
120
123
  let parsed;
121
124
  // Fast path: a worker (during the parse phase) already produced a
122
125
  // ParsedFile for this file via `extractParsedFile`. Reuse it
@@ -136,6 +139,10 @@ export function runScopeResolution(input, provider) {
136
139
  }
137
140
  provider.populateOwners(parsed);
138
141
  parsedFiles.push(parsed);
142
+ if (input.onProgress &&
143
+ ((fileIdx + 1) % progressInterval === 0 || fileIdx === files.length - 1)) {
144
+ input.onProgress('extracting', fileIdx + 1, files.length);
145
+ }
139
146
  }
140
147
  if (PROF && preExtracted !== undefined) {
141
148
  logger.warn(`[scope-resolution prof] pre-extracted hits: ${preExtractedHits}/${files.length}`);
@@ -167,6 +174,7 @@ export function runScopeResolution(input, provider) {
167
174
  }
168
175
  const tExtract = PROF ? process.hrtime.bigint() : 0n;
169
176
  // ── Phase 2: finalize → ScopeResolutionIndexes ─────────────────────────
177
+ input.onProgress?.('analyzing types', files.length, files.length);
170
178
  const allFilePaths = new Set(parsedFiles.map((f) => f.filePath));
171
179
  const nodeLookup = buildGraphNodeLookup(graph);
172
180
  const resolutionConfig = input.resolutionConfig;
@@ -237,6 +245,7 @@ export function runScopeResolution(input, provider) {
237
245
  // VALIDATE_SEMANTIC_MODEL=1.
238
246
  validateBindingsImmutability(indexes, onWarn);
239
247
  // ── Phase 3: resolve references via Registry.lookup ────────────────────
248
+ input.onProgress?.('resolving references', files.length, files.length);
240
249
  const registryProviders = {
241
250
  arityCompatibility: provider.arityCompatibility,
242
251
  };
@@ -247,6 +256,7 @@ export function runScopeResolution(input, provider) {
247
256
  });
248
257
  const tResolve = PROF ? process.hrtime.bigint() : 0n;
249
258
  // ── Phase 4: emit graph edges (LOAD-BEARING ORDER — see I1) ────────────
259
+ input.onProgress?.('linking symbols', files.length, files.length);
250
260
  const handledSites = new Set(preEmittedInheritanceSites);
251
261
  const receiverExtras = emitReceiverBoundCalls(graph, indexes, parsedFiles, nodeLookup, handledSites, provider, workspaceIndex, readonlyModel, {
252
262
  recordResolutionOutcome,
@@ -35,6 +35,7 @@ export const PHASE_LABELS = {
35
35
  imports: 'Resolving imports',
36
36
  calls: 'Tracing calls',
37
37
  heritage: 'Extracting inheritance',
38
+ scopeResolution: 'Resolving types',
38
39
  communities: 'Detecting communities',
39
40
  processes: 'Detecting processes',
40
41
  complete: 'Pipeline complete',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.6-rc.57",
3
+ "version": "1.6.6-rc.59",
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",
@@ -1,4 +1,4 @@
1
- import{r as e,t}from"./chunk-CilyBKbf.js";import{o as n,s as r}from"./index-De0ddoRo.js";import{buildDynamicSystemPrompt as i}from"./context-builder-_HS0v2ma.js";var a=Object.defineProperty,o=(e,t)=>{let n={};for(var r in e)a(n,r,{get:e[r],enumerable:!0});return t||a(n,Symbol.toStringTag,{value:`Module`}),n};function s(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 s(`${e}.${t}`)},isInstance(e){return typeof e==`object`&&!!e&&t in e&&e[t]===!0}}}var c=s(`langchain`),l=o({ContextOverflowError:()=>m,LangChainError:()=>f,ModelAbortError:()=>p,addLangChainErrorFields:()=>u,ns:()=>d});function u(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 d=c.sub(`error`),f=class extends d.brand(Error){name=`LangChainError`;constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},p=class extends d.brand(f,`model-abort`){name=`ModelAbortError`;partialOutput;constructor(e,t){super(e),this.partialOutput=t}},m=class e extends d.brand(f,`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 h(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`tool_call`)}function g(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 _=class extends Error{output;constructor(e,t){super(e),this.output=t}};function v(e,t=b){e=e.trim();let n=e.indexOf("```");if(n===-1)return t(e);let r=e.substring(n+3);r.startsWith(`json
1
+ import{r as e,t}from"./chunk-CilyBKbf.js";import{o as n,s as r}from"./index-CIYHLoJU.js";import{buildDynamicSystemPrompt as i}from"./context-builder-_HS0v2ma.js";var a=Object.defineProperty,o=(e,t)=>{let n={};for(var r in e)a(n,r,{get:e[r],enumerable:!0});return t||a(n,Symbol.toStringTag,{value:`Module`}),n};function s(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 s(`${e}.${t}`)},isInstance(e){return typeof e==`object`&&!!e&&t in e&&e[t]===!0}}}var c=s(`langchain`),l=o({ContextOverflowError:()=>m,LangChainError:()=>f,ModelAbortError:()=>p,addLangChainErrorFields:()=>u,ns:()=>d});function u(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 d=c.sub(`error`),f=class extends d.brand(Error){name=`LangChainError`;constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},p=class extends d.brand(f,`model-abort`){name=`ModelAbortError`;partialOutput;constructor(e,t){super(e),this.partialOutput=t}},m=class e extends d.brand(f,`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 h(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`tool_call`)}function g(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 _=class extends Error{output;constructor(e,t){super(e),this.output=t}};function v(e,t=b){e=e.trim();let n=e.indexOf("```");if(n===-1)return t(e);let r=e.substring(n+3);r.startsWith(`json
2
2
  `)?r=r.substring(5):r.startsWith(`json`)?r=r.substring(4):r.startsWith(`
3
3
  `)&&(r=r.substring(1));let i=r.indexOf("```"),a=r;return i!==-1&&(a=r.substring(0,i)),t(a.trim())}function y(e){try{return JSON.parse(e)}catch{}let t=e.trim();if(t.length===0)throw Error(`Unexpected end of JSON input`);let n=0;function r(){for(;n<t.length&&/\s/.test(t[n]);)n+=1}function i(){if(t[n]!==`"`)throw Error(`Expected '"' at position ${n}, got '${t[n]}'`);n+=1;let e=``,r=!1;for(;n<t.length;){let i=t[n];if(r){if(i===`n`)e+=`
4
4
  `;else if(i===`t`)e+=` `;else if(i===`r`)e+=`\r`;else if(i===`\\`)e+=`\\`;else if(i===`"`)e+=`"`;else if(i===`b`)e+=`\b`;else if(i===`f`)e+=`\f`;else if(i===`/`)e+=`/`;else if(i===`u`){let r=t.substring(n+1,n+5);if(/^[0-9A-Fa-f]{0,4}$/.test(r))r.length===4?e+=String.fromCharCode(Number.parseInt(r,16)):e+=`u${r}`,n+=r.length;else throw Error(`Invalid unicode escape sequence '\\u${r}' at position ${n}`)}else throw Error(`Invalid escape sequence '\\${i}' at position ${n}`);r=!1}else if(i===`\\`)r=!0;else if(i===`"`)return n+=1,e;else e+=i;n+=1}return r&&(e+=`\\`),e}function a(){let e=n,r=``;if(t[n]===`-`&&(r+=`-`,n+=1),n<t.length&&t[n]===`0`&&(r+=`0`,n+=1,t[n]>=`0`&&t[n]<=`9`))throw Error(`Invalid number at position ${e}`);if(n<t.length&&t[n]>=`1`&&t[n]<=`9`)for(;n<t.length&&t[n]>=`0`&&t[n]<=`9`;)r+=t[n],n+=1;if(n<t.length&&t[n]===`.`)for(r+=`.`,n+=1;n<t.length&&t[n]>=`0`&&t[n]<=`9`;)r+=t[n],n+=1;if(n<t.length&&(t[n]===`e`||t[n]===`E`))for(r+=t[n],n+=1,n<t.length&&(t[n]===`+`||t[n]===`-`)&&(r+=t[n],n+=1);n<t.length&&t[n]>=`0`&&t[n]<=`9`;)r+=t[n],n+=1;if(r===`-`)return-0;let i=Number.parseFloat(r);if(Number.isNaN(i))throw n=e,Error(`Invalid number '${r}' at position ${e}`);return i}function o(){if(r(),n>=t.length)throw Error(`Unexpected end of input at position ${n}`);let e=t[n];if(e===`{`)return c();if(e===`[`)return s();if(e===`"`)return i();if(`null`.startsWith(t.substring(n,n+4)))return n+=Math.min(4,t.length-n),null;if(`true`.startsWith(t.substring(n,n+4)))return n+=Math.min(4,t.length-n),!0;if(`false`.startsWith(t.substring(n,n+5)))return n+=Math.min(5,t.length-n),!1;if(e===`-`||e>=`0`&&e<=`9`)return a();throw Error(`Unexpected character '${e}' at position ${n}`)}function s(){if(t[n]!==`[`)throw Error(`Expected '[' at position ${n}, got '${t[n]}'`);let e=[];if(n+=1,r(),n>=t.length)return e;if(t[n]===`]`)return n+=1,e;for(;n<t.length;){if(r(),n>=t.length||(e.push(o()),r(),n>=t.length))return e;if(t[n]===`]`)return n+=1,e;if(t[n]===`,`){n+=1;continue}throw Error(`Expected ',' or ']' at position ${n}, got '${t[n]}'`)}return e}function c(){if(t[n]!==`{`)throw Error(`Expected '{' at position ${n}, got '${t[n]}'`);let e={};if(n+=1,r(),n>=t.length)return e;if(t[n]===`}`)return n+=1,e;for(;n<t.length;){if(r(),n>=t.length)return e;let a=i();if(r(),n>=t.length)return e;if(t[n]!==`:`)throw Error(`Expected ':' at position ${n}, got '${t[n]}'`);if(n+=1,r(),n>=t.length||(e[a]=o(),r(),n>=t.length))return e;if(t[n]===`}`)return n+=1,e;if(t[n]===`,`){n+=1;continue}throw Error(`Expected ',' or '}' at position ${n}, got '${t[n]}'`)}return e}let l=o();if(r(),n<t.length)throw Error(`Unexpected character '${t[n]}' at position ${n}`);return l}function b(e){try{return e===void 0?null:y(e)}catch{return null}}var ee=t(((e,t)=>{t.exports=function(e,t){if(typeof e!=`string`)throw TypeError(`Expected a string`);return t=t===void 0?`_`:t,e.replace(/([a-z\d])([A-Z])/g,`$1`+t+`$2`).replace(/([A-Z]+)([A-Z][a-z\d]+)/g,`$1`+t+`$2`).toLowerCase()}})),te=t(((e,t)=>{var n=/[\p{Lu}]/u,r=/[\p{Ll}]/u,i=/^[\p{Lu}](?![\p{Lu}])/gu,a=/([\p{Alpha}\p{N}_]|$)/u,o=/[_.\- ]+/,s=RegExp(`^`+o.source),c=new RegExp(o.source+a.source,`gu`),l=RegExp(`\\d+`+a.source,`gu`),u=(e,t,i)=>{let a=!1,o=!1,s=!1;for(let c=0;c<e.length;c++){let l=e[c];a&&n.test(l)?(e=e.slice(0,c)+`-`+e.slice(c),a=!1,s=o,o=!0,c++):o&&s&&r.test(l)?(e=e.slice(0,c-1)+`-`+e.slice(c-1),s=o,o=!1,a=!0):(a=t(l)===l&&i(l)!==l,s=o,o=i(l)===l&&t(l)!==l)}return e},d=(e,t)=>(i.lastIndex=0,e.replace(i,e=>t(e))),f=(e,t)=>(c.lastIndex=0,l.lastIndex=0,e.replace(c,(e,n)=>t(n)).replace(l,e=>t(e))),p=(e,t)=>{if(!(typeof e==`string`||Array.isArray(e)))throw TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},e=Array.isArray(e)?e.map(e=>e.trim()).filter(e=>e.length).join(`-`):e.trim(),e.length===0)return``;let n=t.locale===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t.locale),r=t.locale===!1?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t.locale);return e.length===1?t.pascalCase?r(e):n(e):(e!==n(e)&&(e=u(e,n,r)),e=e.replace(s,``),e=t.preserveConsecutiveUppercase?d(e,n):n(e),t.pascalCase&&(e=r(e.charAt(0))+e.slice(1)),f(e,r))};t.exports=p,t.exports.default=p})),ne=e(ee(),1),x=e(te(),1);function re(e,t){return t?.[e]||(0,ne.default)(e)}function ie(e,t){return t?.[e]||(0,x.default)(e)}function ae(e,t,n){let r={};for(let i in e)Object.hasOwn(e,i)&&(r[t(i,n)]=e[i]);return r}var oe=`__lc_escaped__`;function se(e){return`lc`in e||Object.keys(e).length===1&&`__lc_escaped__`in e}function ce(e){return{[oe]:e}}function le(e){return Object.keys(e).length===1&&`__lc_escaped__`in e}function S(e){return typeof e==`object`&&!!e&&`lc_serializable`in e&&typeof e.toJSON==`function`}function ue(e){let t;return t=typeof e==`object`&&e?`lc_id`in e&&Array.isArray(e.lc_id)?e.lc_id:[e.constructor?.name??`Object`]:[typeof e],{lc:1,type:`not_implemented`,id:t}}function de(e,t=new WeakSet){if(typeof e==`object`&&e&&!Array.isArray(e)){if(t.has(e))return ue(e);if(S(e))return e;t.add(e);let n=e;if(se(n))return t.delete(e),ce(n);let r={};for(let[e,i]of Object.entries(n))r[e]=de(i,t);return t.delete(e),r}return Array.isArray(e)?e.map(e=>de(e,t)):e}function fe(e){if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e;if(le(t))return t[oe];let n={};for(let[e,r]of Object.entries(t))n[e]=fe(r);return n}return Array.isArray(e)?e.map(e=>fe(e)):e}var pe=o({Serializable:()=>_e,get_lc_unique_name:()=>ge});function me(e){return Array.isArray(e)?[...e]:{...e}}function he(e,t){let n=me(e);for(let[e,r]of Object.entries(t)){let[t,...i]=e.split(`.`).reverse(),a=n;for(let e of i.reverse()){if(a[e]===void 0)break;a[e]=me(a[e]),a=a[e]}a[t]!==void 0&&(a[t]={lc:1,type:`secret`,id:[r]})}return n}function ge(e){let t=Object.getPrototypeOf(e);return typeof e.lc_name==`function`&&(typeof t.lc_name!=`function`||e.lc_name()!==t.lc_name())?e.lc_name():e.name}var _e=class e{lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,ge(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}constructor(e,...t){this.lc_serializable_keys===void 0?this.lc_kwargs=e??{}:this.lc_kwargs=Object.fromEntries(Object.entries(e||{}).filter(([e])=>this.lc_serializable_keys?.includes(e)))}toJSON(){if(!this.lc_serializable||this.lc_kwargs instanceof e||typeof this.lc_kwargs!=`object`||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let t={},n={},r=Object.keys(this.lc_kwargs).reduce((e,t)=>(e[t]=t in this?this[t]:this.lc_kwargs[t],e),{});for(let e=Object.getPrototypeOf(this);e;e=Object.getPrototypeOf(e))Object.assign(t,Reflect.get(e,`lc_aliases`,this)),Object.assign(n,Reflect.get(e,`lc_secrets`,this)),Object.assign(r,Reflect.get(e,`lc_attributes`,this));Object.keys(n).forEach(e=>{let t=this,n=r,[i,...a]=e.split(`.`).reverse();for(let e of a.reverse()){if(!(e in t)||t[e]===void 0)return;(!(e in n)||n[e]===void 0)&&(typeof t[e]==`object`&&t[e]!=null?n[e]={}:Array.isArray(t[e])&&(n[e]=[])),t=t[e],n=n[e]}i in t&&t[i]!==void 0&&(n[i]=n[i]||t[i])});let i={},a=new WeakSet;a.add(this);for(let[e,t]of Object.entries(r))i[e]=de(t,a);let o=ae(Object.keys(n).length?he(i,n):i,re,t);return{lc:1,type:`constructor`,id:this.lc_id,kwargs:o}}toJSONNotImplemented(){return{lc:1,type:`not_implemented`,id:this.lc_id}}};function ve(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`&&`source_type`in e&&(e.source_type===`url`||e.source_type===`base64`||e.source_type===`text`||e.source_type===`id`)}function ye(e){return ve(e)&&e.source_type===`url`&&`url`in e&&typeof e.url==`string`}function be(e){return ve(e)&&e.source_type===`base64`&&`data`in e&&typeof e.data==`string`}function xe(e){return ve(e)&&e.source_type===`text`&&`text`in e&&typeof e.text==`string`}function Se(e){return ve(e)&&e.source_type===`id`&&`id`in e&&typeof e.id==`string`}function Ce(e){if(ve(e)){if(e.source_type===`url`)return{type:`image_url`,image_url:{url:e.url}};if(e.source_type===`base64`){if(!e.mime_type)throw Error(`mime_type key is required for base64 data.`);return{type:`image_url`,image_url:{url:`data:${e.mime_type};base64,${e.data}`}}}}throw Error(`Unsupported source type. Only 'url' and 'base64' are supported.`)}function we(e){let t=e.split(`;`)[0].split(`/`);if(t.length!==2)throw Error(`Invalid mime type: "${e}" - does not match type/subtype format.`);let n=t[0].trim(),r=t[1].trim();if(n===``||r===``)throw Error(`Invalid mime type: "${e}" - type or subtype is empty.`);let i={};for(let t of e.split(`;`).slice(1)){let n=t.split(`=`);if(n.length!==2)throw Error(`Invalid parameter syntax in mime type: "${e}".`);let r=n[0].trim(),a=n[1].trim();if(r===``)throw Error(`Invalid parameter syntax in mime type: "${e}".`);i[r]=a}return{type:n,subtype:r,parameters:i}}function Te({dataUrl:e,asTypedArray:t=!1}){let n=e.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/),r;if(n){r=n[1].toLowerCase();let e=t?Uint8Array.from(atob(n[2]),e=>e.charCodeAt(0)):n[2];return{mime_type:r,data:e}}}function Ee(e,t){if(e.type===`text`){if(!t.fromStandardTextBlock)throw Error(`Converter for ${t.providerName} does not implement \`fromStandardTextBlock\` method.`);return t.fromStandardTextBlock(e)}if(e.type===`image`){if(!t.fromStandardImageBlock)throw Error(`Converter for ${t.providerName} does not implement \`fromStandardImageBlock\` method.`);return t.fromStandardImageBlock(e)}if(e.type===`audio`){if(!t.fromStandardAudioBlock)throw Error(`Converter for ${t.providerName} does not implement \`fromStandardAudioBlock\` method.`);return t.fromStandardAudioBlock(e)}if(e.type===`file`){if(!t.fromStandardFileBlock)throw Error(`Converter for ${t.providerName} does not implement \`fromStandardFileBlock\` method.`);return t.fromStandardFileBlock(e)}throw Error(`Unable to convert content block type '${e.type}' to provider-specific format: not recognized.`)}function C(e,t){return w(e)&&e.type===t}function w(e){return typeof e==`object`&&!!e}function De(e){return Array.isArray(e)}function T(e){return typeof e==`string`}function Oe(e){return typeof e==`number`}function ke(e){return e instanceof Uint8Array}function E(e){try{return JSON.parse(e)}catch{return}}var Ae=e=>e();function je(e){if(e.type===`char_location`&&T(e.document_title)&&Oe(e.start_char_index)&&Oe(e.end_char_index)&&T(e.cited_text)){let{document_title:t,start_char_index:n,end_char_index:r,cited_text:i,...a}=e;return{...a,type:`citation`,source:`char`,title:t??void 0,startIndex:n,endIndex:r,citedText:i}}if(e.type===`page_location`&&T(e.document_title)&&Oe(e.start_page_number)&&Oe(e.end_page_number)&&T(e.cited_text)){let{document_title:t,start_page_number:n,end_page_number:r,cited_text:i,...a}=e;return{...a,type:`citation`,source:`page`,title:t??void 0,startIndex:n,endIndex:r,citedText:i}}if(e.type===`content_block_location`&&T(e.document_title)&&Oe(e.start_block_index)&&Oe(e.end_block_index)&&T(e.cited_text)){let{document_title:t,start_block_index:n,end_block_index:r,cited_text:i,...a}=e;return{...a,type:`citation`,source:`block`,title:t??void 0,startIndex:n,endIndex:r,citedText:i}}if(e.type===`web_search_result_location`&&T(e.url)&&T(e.title)&&T(e.encrypted_index)&&T(e.cited_text)){let{url:t,title:n,encrypted_index:r,cited_text:i,...a}=e;return{...a,type:`citation`,source:`url`,url:t,title:n,startIndex:Number(r),endIndex:Number(r),citedText:i}}if(e.type===`search_result_location`&&T(e.source)&&T(e.title)&&Oe(e.start_block_index)&&Oe(e.end_block_index)&&T(e.cited_text)){let{source:t,title:n,start_block_index:r,end_block_index:i,cited_text:a,...o}=e;return{...o,type:`citation`,source:`search`,url:t,title:n??void 0,startIndex:r,endIndex:i,citedText:a}}}function Me(e){if(C(e,`document`)&&w(e.source)&&`type`in e.source){if(e.source.type===`base64`&&T(e.source.media_type)&&T(e.source.data))return{type:`file`,mimeType:e.source.media_type,data:e.source.data};if(e.source.type===`url`&&T(e.source.url))return{type:`file`,url:e.source.url};if(e.source.type===`file`&&T(e.source.file_id))return{type:`file`,fileId:e.source.file_id};if(e.source.type===`text`&&T(e.source.data))return{type:`file`,mimeType:String(e.source.media_type??`text/plain`),data:e.source.data}}else if(C(e,`image`)&&w(e.source)&&`type`in e.source){if(e.source.type===`base64`&&T(e.source.media_type)&&T(e.source.data))return{type:`image`,mimeType:e.source.media_type,data:e.source.data};if(e.source.type===`url`&&T(e.source.url))return{type:`image`,url:e.source.url};if(e.source.type===`file`&&T(e.source.file_id))return{type:`image`,fileId:e.source.file_id}}}function Ne(e){function*t(){for(let t of e){let e=Me(t);e?yield e:yield t}}return Array.from(t())}function Pe(e){function*t(){let t=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content;for(let n of t){if(C(n,`text`)&&T(n.text)){let{text:e,citations:t,...r}=n;if(De(t)&&t.length){let n=t.reduce((e,t)=>{let n=je(t);return n?[...e,n]:e},[]);yield{...r,type:`text`,text:e,annotations:n};continue}else{yield{...r,type:`text`,text:e};continue}}else if(C(n,`thinking`)&&T(n.thinking)){let{thinking:e,signature:t,...r}=n;yield{...r,type:`reasoning`,reasoning:e,signature:t};continue}else if(C(n,`redacted_thinking`)){yield{type:`non_standard`,value:n};continue}else if(C(n,`tool_use`)&&T(n.name)&&T(n.id)){yield{type:`tool_call`,id:n.id,name:n.name,args:n.input};continue}else if(C(n,`input_json_delta`)){if(Ie(e)&&e.tool_call_chunks?.length){let t=e.tool_call_chunks[0];yield{type:`tool_call_chunk`,id:t.id,name:t.name,args:t.args,index:t.index};continue}}else if(C(n,`server_tool_use`)&&T(n.name)&&T(n.id)){let{name:e,id:t}=n;if(e===`web_search`){yield{id:t,type:`server_tool_call`,name:`web_search`,args:{query:Ae(()=>{if(typeof n.input==`string`)return n.input;if(w(n.input)&&T(n.input.query))return n.input.query;if(T(n.partial_json)){let e=E(n.partial_json);if(e?.query)return e.query}return``})}};continue}else if(n.name===`code_execution`){yield{id:t,type:`server_tool_call`,name:`code_execution`,args:{code:Ae(()=>{if(typeof n.input==`string`)return n.input;if(w(n.input)&&T(n.input.code))return n.input.code;if(T(n.partial_json)){let e=E(n.partial_json);if(e?.code)return e.code}return``})}};continue}}else if(C(n,`web_search_tool_result`)&&T(n.tool_use_id)&&De(n.content)){let{content:e,tool_use_id:t}=n;yield{type:`server_tool_call_result`,name:`web_search`,toolCallId:t,status:`success`,output:{urls:e.reduce((e,t)=>C(t,`web_search_result`)?[...e,t.url]:e,[])}};continue}else if(C(n,`code_execution_tool_result`)&&T(n.tool_use_id)&&w(n.content)){yield{type:`server_tool_call_result`,name:`code_execution`,toolCallId:n.tool_use_id,status:`success`,output:n.content};continue}else if(C(n,`mcp_tool_use`)){yield{id:n.id,type:`server_tool_call`,name:`mcp_tool_use`,args:n.input};continue}else if(C(n,`mcp_tool_result`)&&T(n.tool_use_id)&&w(n.content)){yield{type:`server_tool_call_result`,name:`mcp_tool_use`,toolCallId:n.tool_use_id,status:`success`,output:n.content};continue}else if(C(n,`container_upload`)){yield{type:`server_tool_call`,name:`container_upload`,args:n.input};continue}else if(C(n,`search_result`)){yield{id:n.id,type:`non_standard`,value:n};continue}else if(C(n,`tool_result`)){yield{id:n.id,type:`non_standard`,value:n};continue}else{let e=Me(n);if(e){yield e;continue}}yield{type:`non_standard`,value:n}}}return Array.from(t())}var Fe={translateContent:Pe,translateContentChunk:Pe};function Ie(e){return typeof e?._getType==`function`&&typeof e.concat==`function`&&e._getType()===`ai`}function Le(e){return ye(e)?{type:e.type,mimeType:e.mime_type,url:e.url,metadata:e.metadata}:be(e)?{type:e.type,mimeType:e.mime_type??`application/octet-stream`,data:e.data,metadata:e.metadata}:Se(e)?{type:e.type,mimeType:e.mime_type,fileId:e.id,metadata:e.metadata}:e}function Re(e){return e.map(Le)}function ze(e){return!!(C(e,`image_url`)&&w(e.image_url)||C(e,`input_audio`)&&w(e.input_audio)||C(e,`file`)&&w(e.file))}function Be(e){if(C(e,`image_url`)&&w(e.image_url)&&T(e.image_url.url)){let t=Te({dataUrl:e.image_url.url});return t?{type:`image`,mimeType:t.mime_type,data:t.data}:{type:`image`,url:e.image_url.url}}else if(C(e,`input_audio`)&&w(e.input_audio)&&T(e.input_audio.data)&&T(e.input_audio.format))return{type:`audio`,data:e.input_audio.data,mimeType:`audio/${e.input_audio.format}`};else if(C(e,`file`)&&w(e.file)&&T(e.file.data)){let t=Te({dataUrl:e.file.data});if(t)return{type:`file`,data:t.data,mimeType:t.mime_type};if(T(e.file.file_id))return{type:`file`,fileId:e.file.file_id}}return e}function Ve(e){let t=[];typeof e.content==`string`?e.content.length>0&&t.push({type:`text`,text:e.content}):t.push(...Ue(e.content));for(let n of e.tool_calls??[])t.push({type:`tool_call`,id:n.id,name:n.name,args:n.args});return t}function He(e){let t=[];typeof e.content==`string`?e.content.length>0&&t.push({type:`text`,text:e.content}):t.push(...Ue(e.content));for(let n of e.tool_calls??[])t.push({type:`tool_call`,id:n.id,name:n.name,args:n.args});return t}function Ue(e){let t=[];for(let n of e)ze(n)?t.push(Be(n)):t.push(n);return t}function We(e){if(e.type===`url_citation`){let{url:t,title:n,start_index:r,end_index:i}=e;return{type:`citation`,url:t,title:n,startIndex:r,endIndex:i}}if(e.type===`file_citation`){let{file_id:t,filename:n,index:r}=e;return{type:`citation`,title:n,startIndex:r,endIndex:r,fileId:t}}return e}function Ge(e){function*t(){w(e.additional_kwargs?.reasoning)&&De(e.additional_kwargs.reasoning.summary)&&(yield{type:`reasoning`,reasoning:e.additional_kwargs.reasoning.summary.reduce((e,t)=>w(t)&&T(t.text)?`${e}${t.text}`:e,``)});let t=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content;for(let e of t)if(C(e,`text`)){let{text:t,annotations:n,phase:r,extras:i,...a}=e,o=w(i)?{...i}:{};T(r)&&(o.phase=r);let s=Object.keys(o).length>0?{extras:o}:{};Array.isArray(n)?yield{...a,...s,type:`text`,text:String(t),annotations:n.map(We)}:yield{...a,...s,type:`text`,text:String(t)}}for(let t of e.tool_calls??[])yield{type:`tool_call`,id:t.id,name:t.name,args:t.args};if(w(e.additional_kwargs)&&De(e.additional_kwargs.tool_outputs))for(let t of e.additional_kwargs.tool_outputs){if(C(t,`web_search_call`)){let e={};if(w(t.action)&&T(t.action.query)&&(e.query=t.action.query),yield{id:t.id,type:`server_tool_call`,name:`web_search`,args:e},t.status===`completed`||t.status===`failed`){let e={};w(t.action)&&(e.action=t.action),yield{type:`server_tool_call_result`,toolCallId:T(t.id)?t.id:``,status:t.status===`completed`?`success`:`error`,output:e}}continue}else if(C(t,`file_search_call`)){yield{id:t.id,type:`server_tool_call`,name:`file_search`,args:{queries:De(t.queries)?t.queries:[]}},(t.status===`completed`||t.status===`failed`)&&(yield{type:`server_tool_call_result`,toolCallId:T(t.id)?t.id:``,status:t.status===`completed`?`success`:`error`,output:De(t.results)?{results:t.results}:{}});continue}else if(C(t,`computer_call`)){yield{type:`non_standard`,value:t};continue}else if(C(t,`code_interpreter_call`)){if(T(t.code)&&(yield{id:t.id,type:`server_tool_call`,name:`code_interpreter`,args:{code:t.code}}),De(t.outputs)){let e=Ae(()=>{if(t.status!==`in_progress`){if(t.status===`completed`)return 0;if(t.status===`incomplete`)return 127;if(t.status!==`interpreting`&&t.status===`failed`)return 1}});for(let n of t.outputs)if(C(n,`logs`)){yield{type:`server_tool_call_result`,toolCallId:t.id??``,status:`success`,output:{type:`code_interpreter_output`,returnCode:e??0,stderr:[0,void 0].includes(e)?void 0:String(n.logs),stdout:[0,void 0].includes(e)?String(n.logs):void 0}};continue}}continue}else if(C(t,`mcp_call`)){yield{id:t.id,type:`server_tool_call`,name:`mcp_call`,args:t.input};continue}else if(C(t,`mcp_list_tools`)){yield{id:t.id,type:`server_tool_call`,name:`mcp_list_tools`,args:t.input};continue}else if(C(t,`mcp_approval_request`)){yield{type:`non_standard`,value:t};continue}else if(C(t,`tool_search_call`)){let e={};w(t.arguments)&&Object.assign(e,t.arguments);let n={};T(t.execution)&&(n.execution=t.execution),T(t.status)&&(n.status=t.status),T(t.call_id)&&(n.call_id=t.call_id),yield{id:T(t.id)?t.id:``,type:`server_tool_call`,name:`tool_search`,args:e,...Object.keys(n).length>0?{extras:n}:{}};continue}else if(C(t,`tool_search_output`)){let e={name:`tool_search`};T(t.execution)&&(e.execution=t.execution),yield{type:`server_tool_call_result`,toolCallId:T(t.id)?t.id:``,status:t.status===`completed`?`success`:t.status===`failed`?`error`:`success`,output:{tools:De(t.tools)?t.tools:[]},extras:e};continue}else if(C(t,`image_generation_call`)){T(t.result)&&(yield{type:`image`,mimeType:`image/png`,data:t.result,id:T(t.id)?t.id:void 0,metadata:{status:T(t.status)?t.status:void 0}}),yield{type:`non_standard`,value:t};continue}w(t)&&(yield{type:`non_standard`,value:t})}}return Array.from(t())}function Ke(e){function*t(){yield*Ge(e);for(let t of e.tool_call_chunks??[])yield{type:`tool_call_chunk`,id:t.id,name:t.name,args:t.args}}return Array.from(t())}var qe={translateContent:e=>typeof e.content==`string`?Ve(e):Ge(e),translateContentChunk:e=>typeof e.content==`string`?He(e):Ke(e)};function Je(e){return typeof e==`object`&&!!e&&`type`in e&&`content`in e&&(typeof e.content==`string`||Array.isArray(e.content))}function Ye(e,t=`pretty`){return t===`pretty`?Xe(e):JSON.stringify(e)}function Xe(e){let t=[],n=` ${e.type.charAt(0).toUpperCase()+e.type.slice(1)} Message `,r=Math.floor((80-n.length)/2),i=`=`.repeat(r),a=n.length%2==0?i:`${i}=`;if(t.push(`${i}${n}${a}`),e.type===`ai`){let n=e;if(n.tool_calls&&n.tool_calls.length>0){t.push(`Tool Calls:`);for(let e of n.tool_calls){t.push(` ${e.name} (${e.id})`),t.push(` Call ID: ${e.id}`),t.push(` Args:`);for(let[n,r]of Object.entries(e.args))t.push(` ${n}: ${typeof r==`object`?JSON.stringify(r):r}`)}}}if(e.type===`tool`){let n=e;n.name&&t.push(`Name: ${n.name}`)}return typeof e.content==`string`&&e.content.trim()&&(t.length>1&&t.push(``),t.push(e.content)),t.join(`