hedit 0.7.11.dev18__tar.gz → 0.7.11.dev19__tar.gz

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 (93) hide show
  1. {hedit-0.7.11.dev18/hedit.egg-info → hedit-0.7.11.dev19}/PKG-INFO +2 -1
  2. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19/hedit.egg-info}/PKG-INFO +2 -1
  3. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/hedit.egg-info/SOURCES.txt +1 -0
  4. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/hedit.egg-info/requires.txt +1 -0
  5. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/pyproject.toml +4 -3
  6. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/agents/validation_agent.py +5 -5
  7. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/agents/workflow.py +8 -8
  8. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/api/main.py +20 -42
  9. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/cli/local_executor.py +67 -53
  10. hedit-0.7.11.dev19/src/lsp/__init__.py +20 -0
  11. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/lsp/daemon.py +0 -1
  12. hedit-0.7.11.dev19/src/lsp/engine.py +292 -0
  13. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/validation/__init__.py +7 -2
  14. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/validation/hed_lsp.py +8 -8
  15. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/version.py +1 -1
  16. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_integration_anthropic.py +2 -0
  17. hedit-0.7.11.dev18/src/lsp/__init__.py +0 -13
  18. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/LICENSE +0 -0
  19. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/PKG_README.md +0 -0
  20. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/README.md +0 -0
  21. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/hedit.egg-info/dependency_links.txt +0 -0
  22. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/hedit.egg-info/entry_points.txt +0 -0
  23. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/hedit.egg-info/top_level.txt +0 -0
  24. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/setup.cfg +0 -0
  25. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/__init__.py +0 -0
  26. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/agents/__init__.py +0 -0
  27. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/agents/annotation_agent.py +0 -0
  28. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/agents/assessment_agent.py +0 -0
  29. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/agents/evaluation_agent.py +0 -0
  30. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/agents/feedback_summarizer.py +0 -0
  31. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/agents/feedback_triage_agent.py +0 -0
  32. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/agents/state.py +0 -0
  33. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/agents/vision_agent.py +0 -0
  34. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/api/__init__.py +0 -0
  35. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/api/models.py +0 -0
  36. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/api/security.py +0 -0
  37. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/cli/__init__.py +0 -0
  38. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/cli/api_executor.py +0 -0
  39. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/cli/client.py +0 -0
  40. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/cli/commands/__init__.py +0 -0
  41. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/cli/commands/lsp.py +0 -0
  42. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/cli/config.py +0 -0
  43. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/cli/executor.py +0 -0
  44. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/cli/main.py +0 -0
  45. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/cli/output.py +0 -0
  46. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/data/__init__.py +0 -0
  47. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/data/hed-docs/02_Terminology.md +0 -0
  48. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/data/hed-docs/HedAnnotationSemantics.md +0 -0
  49. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/data/hed-docs/manifest.json +0 -0
  50. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/lsp/client.py +0 -0
  51. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/lsp/protocol.py +0 -0
  52. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/scripts/__init__.py +0 -0
  53. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/scripts/process_feedback.py +0 -0
  54. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/telemetry/__init__.py +0 -0
  55. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/telemetry/collector.py +0 -0
  56. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/telemetry/schema.py +0 -0
  57. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/telemetry/storage.py +0 -0
  58. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/utils/__init__.py +0 -0
  59. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/utils/anthropic_llm.py +0 -0
  60. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/utils/error_remediation.py +0 -0
  61. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/utils/github_client.py +0 -0
  62. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/utils/hed_comprehensive_guide.py +0 -0
  63. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/utils/hed_docs_loader.py +0 -0
  64. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/utils/image_processing.py +0 -0
  65. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/utils/json_schema_loader.py +0 -0
  66. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/utils/llm_usage.py +0 -0
  67. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/utils/schema_loader.py +0 -0
  68. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/src/validation/hed_validator.py +0 -0
  69. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_annotation_agent.py +0 -0
  70. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_anthropic_llm.py +0 -0
  71. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_api_endpoints.py +0 -0
  72. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_cli_client.py +0 -0
  73. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_cli_config.py +0 -0
  74. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_cli_integration.py +0 -0
  75. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_cli_main.py +0 -0
  76. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_cli_usage_report.py +0 -0
  77. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_comprehensive_guide.py +0 -0
  78. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_error_remediation.py +0 -0
  79. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_feedback_integration.py +0 -0
  80. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_feedback_triage.py +0 -0
  81. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_fetch_hed_docs.py +0 -0
  82. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_github_client.py +0 -0
  83. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_hed_docs_loader.py +0 -0
  84. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_json_schema_loader.py +0 -0
  85. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_llm_usage.py +0 -0
  86. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_no_extend_propagation.py +0 -0
  87. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_schema_loader.py +0 -0
  88. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_security.py +0 -0
  89. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_state.py +0 -0
  90. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_telemetry.py +0 -0
  91. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_validation.py +0 -0
  92. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_validation_agent.py +0 -0
  93. {hedit-0.7.11.dev18 → hedit-0.7.11.dev19}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hedit
3
- Version: 0.7.11.dev18
3
+ Version: 0.7.11.dev19
4
4
  Summary: Multi-agent system for HED annotation generation and validation
5
5
  Author-email: Annotation Garden Initiative <info@annotation.garden>
6
6
  License-Expression: MIT
@@ -48,6 +48,7 @@ Requires-Dist: hedit[api]; extra == "dev"
48
48
  Requires-Dist: pytest>=8.3.0; extra == "dev"
49
49
  Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
50
50
  Requires-Dist: pytest-asyncio>=0.24.0; extra == "dev"
51
+ Requires-Dist: respx>=0.22.0; extra == "dev"
51
52
  Requires-Dist: ruff>=0.7.0; extra == "dev"
52
53
  Requires-Dist: black>=24.8.0; extra == "dev"
53
54
  Requires-Dist: mypy>=1.11.0; extra == "dev"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hedit
3
- Version: 0.7.11.dev18
3
+ Version: 0.7.11.dev19
4
4
  Summary: Multi-agent system for HED annotation generation and validation
5
5
  Author-email: Annotation Garden Initiative <info@annotation.garden>
6
6
  License-Expression: MIT
@@ -48,6 +48,7 @@ Requires-Dist: hedit[api]; extra == "dev"
48
48
  Requires-Dist: pytest>=8.3.0; extra == "dev"
49
49
  Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
50
50
  Requires-Dist: pytest-asyncio>=0.24.0; extra == "dev"
51
+ Requires-Dist: respx>=0.22.0; extra == "dev"
51
52
  Requires-Dist: ruff>=0.7.0; extra == "dev"
52
53
  Requires-Dist: black>=24.8.0; extra == "dev"
53
54
  Requires-Dist: mypy>=1.11.0; extra == "dev"
@@ -41,6 +41,7 @@ src/data/hed-docs/manifest.json
41
41
  src/lsp/__init__.py
42
42
  src/lsp/client.py
43
43
  src/lsp/daemon.py
44
+ src/lsp/engine.py
44
45
  src/lsp/protocol.py
45
46
  src/scripts/__init__.py
46
47
  src/scripts/process_feedback.py
@@ -21,6 +21,7 @@ hedit[api]
21
21
  pytest>=8.3.0
22
22
  pytest-cov>=5.0.0
23
23
  pytest-asyncio>=0.24.0
24
+ respx>=0.22.0
24
25
  ruff>=0.7.0
25
26
  black>=24.8.0
26
27
  mypy>=1.11.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hedit"
7
- version = "0.7.11.dev18"
7
+ version = "0.7.11.dev19"
8
8
  description = "Multi-agent system for HED annotation generation and validation"
9
9
  readme = "PKG_README.md"
10
10
  requires-python = ">=3.12"
@@ -49,8 +49,8 @@ Issues = "https://github.com/Annotation-Garden/hedit/issues"
49
49
 
50
50
  [project.optional-dependencies]
51
51
  # Standalone mode: run LangGraph workflow locally without backend (~2GB)
52
- # Note: hed-lsp CLI is recommended for semantic tag suggestions
53
- # Install separately: https://github.com/hed-standard/hed-lsp
52
+ # Tag suggestions come from the hed-lsp HTTP daemon (HED_LSP_URL, default
53
+ # https://hedtools.org/hed-lsp); no local hed-lsp install is needed.
54
54
  standalone = [
55
55
  "langgraph>=0.2.0",
56
56
  "langchain>=0.3.0",
@@ -78,6 +78,7 @@ dev = [
78
78
  "pytest>=8.3.0",
79
79
  "pytest-cov>=5.0.0",
80
80
  "pytest-asyncio>=0.24.0",
81
+ "respx>=0.22.0", # HTTP fixtures for error and retry paths only
81
82
  "ruff>=0.7.0",
82
83
  "black>=24.8.0",
83
84
  "mypy>=1.11.0",
@@ -2,7 +2,7 @@
2
2
 
3
3
  This agent validates HED annotation strings using HED validation tools
4
4
  and provides detailed feedback for corrections. When invalid tags are found,
5
- it uses hed-lsp CLI to suggest valid alternatives.
5
+ it asks the hed-lsp engine to suggest valid alternatives.
6
6
  """
7
7
 
8
8
  from __future__ import annotations
@@ -12,7 +12,7 @@ import re
12
12
  from pathlib import Path
13
13
 
14
14
  from src.agents.state import HedAnnotationState
15
- from src.lsp import HedLspClient
15
+ from src.lsp import TagSuggester
16
16
  from src.utils.error_remediation import get_remediator
17
17
  from src.utils.schema_loader import HedSchemaLoader
18
18
  from src.validation.hed_validator import (
@@ -62,7 +62,7 @@ class ValidationAgent:
62
62
  """Agent that validates HED annotations using HED validation tools.
63
63
 
64
64
  Supports JavaScript (detailed feedback) and Python (always available fallback)
65
- validator backends. Uses hed-lsp CLI for suggesting valid tag alternatives
65
+ validator backends. Uses the hed-lsp engine for suggesting valid tag alternatives
66
66
  when available.
67
67
  """
68
68
 
@@ -81,7 +81,7 @@ class ValidationAgent:
81
81
  use_javascript: bool = True,
82
82
  validator_path: Path | None = None,
83
83
  tests_json_path: Path | str | None = None,
84
- lsp_client: HedLspClient | None = None,
84
+ lsp_client: TagSuggester | None = None,
85
85
  ) -> None:
86
86
  """Initialize the validation agent.
87
87
 
@@ -90,7 +90,7 @@ class ValidationAgent:
90
90
  use_javascript: Whether to use JavaScript validator (more detailed)
91
91
  validator_path: Path to hed-javascript repository (required if use_javascript=True)
92
92
  tests_json_path: Optional path to javascriptTests.json for error remediation
93
- lsp_client: Pre-built HedLspClient for tag-replacement suggestions
93
+ lsp_client: Suggestion client (HedEngineClient or HedLspClient) for tag-replacement suggestions
94
94
  when validation finds invalid tags. None disables suggestions.
95
95
  """
96
96
  self.schema_loader = schema_loader
@@ -18,7 +18,7 @@ from src.agents.evaluation_agent import EvaluationAgent
18
18
  from src.agents.feedback_summarizer import FeedbackSummarizer
19
19
  from src.agents.state import HedAnnotationState
20
20
  from src.agents.validation_agent import ValidationAgent
21
- from src.lsp import HedLspClient
21
+ from src.lsp import TagSuggester
22
22
  from src.utils import extract_text_content
23
23
  from src.utils.schema_loader import HedSchemaLoader
24
24
 
@@ -51,7 +51,7 @@ class HedAnnotationWorkflow:
51
51
  validator_path: Path | None = None,
52
52
  use_js_validator: bool = True,
53
53
  enable_semantic_search: bool = True,
54
- lsp_client: HedLspClient | None = None,
54
+ lsp_client: TagSuggester | None = None,
55
55
  ) -> None:
56
56
  """Initialize the workflow.
57
57
 
@@ -73,7 +73,7 @@ class HedAnnotationWorkflow:
73
73
  enable_semantic_search: Whether to include the semantic_preprocess
74
74
  node in the graph. The node is only useful when an
75
75
  `lsp_client` is also provided.
76
- lsp_client: Pre-built, already-initialized HedLspClient. The
76
+ lsp_client: Suggestion client (HedEngineClient or HedLspClient). The
77
77
  caller (FastAPI lifespan, CLI executor) owns the client's
78
78
  lifetime. None disables LSP-backed tag enrichment.
79
79
  """
@@ -81,7 +81,7 @@ class HedAnnotationWorkflow:
81
81
  self.schema_dir = schema_dir
82
82
  # Keyword extraction always runs; LSP enrichment requires an injected client
83
83
  self.enable_semantic_search = enable_semantic_search
84
- self.lsp_client: HedLspClient | None = lsp_client
84
+ self.lsp_client: TagSuggester | None = lsp_client
85
85
 
86
86
  # Initialize legacy schema loader for validation
87
87
  self.schema_loader = HedSchemaLoader()
@@ -229,7 +229,7 @@ class HedAnnotationWorkflow:
229
229
 
230
230
  This node runs before annotation to provide semantic hints based on
231
231
  the input description. It uses the feedback LLM to extract keywords,
232
- then passes those keywords to hed-lsp CLI for tag suggestions.
232
+ then passes those keywords to the hed-lsp engine for tag suggestions.
233
233
  Only runs on the first iteration.
234
234
 
235
235
  Args:
@@ -248,9 +248,9 @@ class HedAnnotationWorkflow:
248
248
  # Step 1: Extract keywords from the description using LLM
249
249
  keywords = await self._extract_keywords(state["input_description"])
250
250
 
251
- # Step 2: One batched hed/suggest call over the persistent LSP
252
- # connection. The previous per-keyword loop spawned the hed-suggest
253
- # CLI once per keyword and dominated request latency (~6 s/spawn).
251
+ # Step 2: One batched suggest call to the hed-lsp engine (HTTP
252
+ # daemon or local LSP socket). The previous per-keyword loop spawned
253
+ # the hed-suggest CLI once per keyword (~6 s/spawn).
254
254
  semantic_hints: list[dict] = []
255
255
 
256
256
  if keywords and self.lsp_client is not None:
@@ -38,7 +38,7 @@ from src.api.models import (
38
38
  ValidationResponse,
39
39
  )
40
40
  from src.api.security import api_key_auth, audit_logger
41
- from src.lsp import HedLspClient
41
+ from src.lsp import HedEngineClient, TagSuggester
42
42
  from src.telemetry import LocalFileStorage, TelemetryCollector, TelemetryEvent
43
43
  from src.utils.anthropic_llm import (
44
44
  DEFAULT_MODEL,
@@ -58,10 +58,9 @@ workflow: HedAnnotationWorkflow | None = None
58
58
  vision_agent: VisionAgent | None = None
59
59
  schema_loader: HedSchemaLoader | None = None
60
60
 
61
- # Persistent LSP client; lifetime = process lifetime. Spawned in lifespan
62
- # so every request reuses one warm Node child instead of cold-booting
63
- # hed-suggest per keyword.
64
- lsp_client: HedLspClient | None = None
61
+ # Tag-suggestion client for the hed-lsp daemon (HED_LSP_URL); lifetime =
62
+ # process lifetime, so every request reuses one HTTP connection pool.
63
+ lsp_client: TagSuggester | None = None
65
64
 
66
65
  # Telemetry collector (initialized in lifespan)
67
66
  telemetry_collector: TelemetryCollector | None = None
@@ -115,8 +114,8 @@ def _describe_llm_error(exc: Exception) -> tuple[int, str, str]:
115
114
 
116
115
  # Sentinel used by the workflow factories to mean "fall back to the
117
116
  # server-wide lsp_client global". Per-request callers can pass an
118
- # explicit None to opt out, or another HedLspClient instance to override.
119
- _USE_GLOBAL_LSP: HedLspClient = object() # type: ignore[assignment]
117
+ # explicit None to opt out, or another TagSuggester instance to override.
118
+ _USE_GLOBAL_LSP: TagSuggester = object() # type: ignore[assignment]
120
119
 
121
120
 
122
121
  def _usage_summary(ledger: UsageLedger) -> UsageSummary | None:
@@ -155,8 +154,8 @@ def _override_header(req: Request, name: str) -> str | None:
155
154
 
156
155
 
157
156
  def _resolve_lsp_client(
158
- explicit: HedLspClient | None,
159
- ) -> HedLspClient | None:
157
+ explicit: TagSuggester | None,
158
+ ) -> TagSuggester | None:
160
159
  """Pick the per-request LSP client.
161
160
 
162
161
  Explicit values (including ``None``) win. The sentinel
@@ -175,7 +174,7 @@ def create_anthropic_workflow(
175
174
  schema_dir: str | Path | None = None,
176
175
  validator_path: str | Path | None = None,
177
176
  use_js_validator: bool = True,
178
- lsp_client: HedLspClient | None = _USE_GLOBAL_LSP,
177
+ lsp_client: TagSuggester | None = _USE_GLOBAL_LSP,
179
178
  ) -> HedAnnotationWorkflow:
180
179
  """Create a workflow with Anthropic Claude LLMs.
181
180
 
@@ -285,7 +284,7 @@ def create_byok_workflow(
285
284
  model: str | None = None,
286
285
  eval_model: str | None = None,
287
286
  temperature: float | None = None,
288
- lsp_client: HedLspClient | None = _USE_GLOBAL_LSP,
287
+ lsp_client: TagSuggester | None = _USE_GLOBAL_LSP,
289
288
  ) -> HedAnnotationWorkflow:
290
289
  """Create a workflow for BYOK mode using the user's Anthropic key.
291
290
 
@@ -428,43 +427,22 @@ async def lifespan(app: FastAPI):
428
427
  print(f"Schema directory: {schema_dir or 'GitHub (dynamic fetch)'}")
429
428
  print(f"Validator path: {validator_path or 'None (using Python validator)'}")
430
429
 
431
- # Spawn the persistent hed-lsp child once for the lifetime of the
432
- # process. Per-request workflows reuse this single warm connection
433
- # instead of cold-booting hed-suggest per keyword. Set HED_LSP_DISABLE=1
434
- # to fall back to keyword-only preprocessing (no LSP enrichment).
435
- # Failures here are logged via the structured logger (not print) so
436
- # operators can detect a silently-degraded server from log
437
- # aggregation.
430
+ # Tag suggestions come from the hed-lsp daemon over HTTP (HED_LSP_URL,
431
+ # default the public instance; on hedtools, http://hed-lsp:38530 over the
432
+ # hed-lsp Docker network). No connection is made here: when the daemon
433
+ # cannot be reached, suggestions are skipped with one warning per
434
+ # process. Set HED_LSP_DISABLE=1 to run without suggestions.
438
435
  global lsp_client
439
436
  lsp_logger = logging.getLogger("hedit.lsp")
440
437
  if os.getenv("HED_LSP_DISABLE", "").lower() in ("1", "true", "yes"):
441
438
  lsp_logger.info("LSP client disabled via HED_LSP_DISABLE")
442
439
  lsp_client = None
443
440
  else:
444
- server_js_env = os.getenv("HED_LSP_SERVER_JS")
445
- default_server_js = Path("/app/hed-lsp/server/out/server.js")
446
- server_js_path = Path(server_js_env) if server_js_env else default_server_js
447
- if not server_js_path.exists():
448
- lsp_logger.error(
449
- "LSP server.js not found at %s; set HED_LSP_SERVER_JS or install "
450
- "hed-lsp. Continuing without LSP enrichment.",
451
- server_js_path,
452
- )
453
- lsp_client = None
454
- else:
455
- try:
456
- lsp_client = await HedLspClient.spawn_stdio(
457
- server_js_path,
458
- schema_version=os.getenv("HED_SCHEMA_VERSION", "8.4.0"),
459
- )
460
- lsp_logger.info("LSP client connected (server.js=%s)", server_js_path)
461
- except (RuntimeError, OSError, TimeoutError) as exc:
462
- lsp_logger.error(
463
- "LSP client spawn failed; continuing without LSP enrichment. "
464
- "Set HED_LSP_DISABLE=1 to suppress this error.",
465
- exc_info=exc,
466
- )
467
- lsp_client = None
441
+ engine_client = HedEngineClient(
442
+ schema_version=os.getenv("HED_SCHEMA_VERSION", "8.4.0"),
443
+ )
444
+ lsp_client = engine_client
445
+ lsp_logger.info("Tag suggestions from the hed-lsp daemon at %s", engine_client.base_url)
468
446
 
469
447
  # Initialize workflow (Claude Platform on AWS - unified workflow creation)
470
448
  if not os.getenv("ANTHROPIC_API_KEY"):
@@ -24,7 +24,7 @@ logger = logging.getLogger(__name__)
24
24
  if TYPE_CHECKING:
25
25
  from src.agents.vision_agent import VisionAgent
26
26
  from src.agents.workflow import HedAnnotationWorkflow
27
- from src.lsp import HedLspClient
27
+ from src.lsp import TagSuggester
28
28
 
29
29
  # Flag to track if standalone dependencies are available
30
30
  _STANDALONE_AVAILABLE: bool | None = None
@@ -106,13 +106,14 @@ class LocalExecutionBackend(ExecutionBackend):
106
106
  self._workflow: HedAnnotationWorkflow | None = None
107
107
  self._vision_agent: VisionAgent | None = None
108
108
 
109
- # LSP client resolution is async, so it happens on first use; None
110
- # means "not yet attempted". After resolution it's either a live
111
- # HedLspClient (daemon was running) or stays None (use without LSP).
112
- self._lsp_client: HedLspClient | None = None
109
+ # Suggestion client resolution is async, so it happens on first use.
110
+ # After resolution it is a HedLspClient on the local `hedit lsp`
111
+ # daemon's socket when that daemon runs, otherwise a HedEngineClient
112
+ # for the hed-lsp HTTP daemon, or None when HEDIT_LSP=0.
113
+ self._lsp_client: TagSuggester | None = None
113
114
  self._lsp_resolved = False
114
- # When True, we created the client ourselves (one-shot spawn) and
115
- # are responsible for shutting it down at executor close.
115
+ # True for the HTTP client, which this executor created and closes
116
+ # at the end of each command (it reopens on the next one).
116
117
  self._owns_lsp_client = False
117
118
 
118
119
  @property
@@ -199,13 +200,13 @@ class LocalExecutionBackend(ExecutionBackend):
199
200
  return self._workflow
200
201
 
201
202
  async def _ensure_lsp_client(self) -> None:
202
- """Decide whether to use a hed-lsp client for this command.
203
+ """Decide which tag-suggestion client this command uses.
203
204
 
204
- Opt-in behavior: if a daemon socket is present at the per-user
205
- runtime dir, connect and use it. Otherwise leave the client as
206
- None — the workflow will run without LSP enrichment. Users who
207
- want LSP enrichment without a daemon can run `hedit lsp start`
208
- first. Setting HEDIT_LSP=0 disables LSP entirely.
205
+ If the opt-in local daemon (`hedit lsp start`) is running, connect
206
+ to its Unix socket. Otherwise use the hed-lsp HTTP daemon at
207
+ `HED_LSP_URL` (default: the public instance). When that daemon
208
+ cannot be reached, suggestions are skipped with one warning.
209
+ Setting HEDIT_LSP=0 disables suggestions entirely.
209
210
  """
210
211
  if self._lsp_resolved:
211
212
  return
@@ -214,24 +215,31 @@ class LocalExecutionBackend(ExecutionBackend):
214
215
  if os.environ.get("HEDIT_LSP", "").lower() in ("0", "false", "no"):
215
216
  return
216
217
 
217
- from src.lsp import HedLspClient as _Client
218
+ from src.lsp import HedEngineClient, HedLspClient
218
219
  from src.lsp.daemon import socket_file_path
219
220
 
220
221
  socket = socket_file_path()
221
- if not socket.exists():
222
- return
223
- try:
224
- self._lsp_client = await _Client.connect_unix(socket)
225
- except (ConnectionRefusedError, FileNotFoundError, OSError, TimeoutError) as exc:
226
- # Stale socket file or daemon refusing connections — fall back
227
- # to no-LSP. Log at debug since this is a normal degraded path
228
- # when the daemon was started and then crashed.
229
- logger.debug(
230
- "Could not connect to hedit-lspd at %s (%s); running without LSP enrichment",
231
- socket,
232
- exc,
233
- )
234
- self._lsp_client = None
222
+ if socket.exists():
223
+ try:
224
+ self._lsp_client = await HedLspClient.connect_unix(socket)
225
+ return
226
+ except (ConnectionRefusedError, FileNotFoundError, OSError, TimeoutError) as exc:
227
+ # Stale socket file or daemon refusing connections; fall back
228
+ # to the HTTP daemon. Debug level, since this is a normal
229
+ # degraded path when the daemon was started and then crashed.
230
+ logger.debug(
231
+ "Could not connect to hedit-lspd at %s (%s); using the hed-lsp HTTP daemon",
232
+ socket,
233
+ exc,
234
+ )
235
+
236
+ self._lsp_client = HedEngineClient()
237
+ self._owns_lsp_client = True
238
+
239
+ async def _close_owned_lsp_client(self) -> None:
240
+ """Close the HTTP client's connections before the command's event loop ends."""
241
+ if self._owns_lsp_client and self._lsp_client is not None:
242
+ await self._lsp_client.shutdown()
235
243
 
236
244
  def _get_vision_agent(self) -> VisionAgent:
237
245
  """Get or create the vision agent."""
@@ -339,14 +347,17 @@ class LocalExecutionBackend(ExecutionBackend):
339
347
 
340
348
  async def _run() -> Any:
341
349
  await self._ensure_lsp_client()
342
- workflow = self._get_workflow()
343
- return await workflow.run(
344
- input_description=description,
345
- schema_version=schema_version,
346
- max_validation_attempts=max_validation_attempts,
347
- run_assessment=run_assessment,
348
- no_extend=no_extend,
349
- )
350
+ try:
351
+ workflow = self._get_workflow()
352
+ return await workflow.run(
353
+ input_description=description,
354
+ schema_version=schema_version,
355
+ max_validation_attempts=max_validation_attempts,
356
+ run_assessment=run_assessment,
357
+ no_extend=no_extend,
358
+ )
359
+ finally:
360
+ await self._close_owned_lsp_client()
350
361
 
351
362
  try:
352
363
  with usage_scope() as ledger:
@@ -398,23 +409,26 @@ class LocalExecutionBackend(ExecutionBackend):
398
409
  async def _run() -> tuple[str, dict[str, Any], Any]:
399
410
  await self._ensure_lsp_client()
400
411
  vision_agent = self._get_vision_agent()
401
- workflow = self._get_workflow()
402
-
403
- # Step 1: Generate image description
404
- vision_result = await vision_agent.describe_image(
405
- image_data=image_uri,
406
- custom_prompt=prompt,
407
- )
408
- description = vision_result["description"]
409
-
410
- # Step 2: Generate HED annotation from description
411
- final_state = await workflow.run(
412
- input_description=description,
413
- schema_version=schema_version,
414
- max_validation_attempts=max_validation_attempts,
415
- run_assessment=run_assessment,
416
- no_extend=no_extend,
417
- )
412
+ try:
413
+ workflow = self._get_workflow()
414
+
415
+ # Step 1: Generate image description
416
+ vision_result = await vision_agent.describe_image(
417
+ image_data=image_uri,
418
+ custom_prompt=prompt,
419
+ )
420
+ description = vision_result["description"]
421
+
422
+ # Step 2: Generate HED annotation from description
423
+ final_state = await workflow.run(
424
+ input_description=description,
425
+ schema_version=schema_version,
426
+ max_validation_attempts=max_validation_attempts,
427
+ run_assessment=run_assessment,
428
+ no_extend=no_extend,
429
+ )
430
+ finally:
431
+ await self._close_owned_lsp_client()
418
432
 
419
433
  return description, vision_result, final_state
420
434
 
@@ -0,0 +1,20 @@
1
+ """Clients for the hed-lsp tag-suggestion engine.
2
+
3
+ `HedEngineClient` calls the hed-lsp HTTP daemon (`HED_LSP_URL`) and is
4
+ the default for the API server and the CLI. `HedLspClient` speaks the
5
+ LSP wire protocol (JSON-RPC over Content-Length framing) to a local
6
+ server, either a spawned Node child or the opt-in `hedit lsp` daemon's
7
+ Unix socket. Both return the same `HedSuggestResult`, and callers type
8
+ them as `TagSuggester`.
9
+ """
10
+
11
+ from src.lsp.client import HedLspClient, HedSuggestion, HedSuggestResult
12
+ from src.lsp.engine import HedEngineClient, TagSuggester
13
+
14
+ __all__ = [
15
+ "HedEngineClient",
16
+ "HedLspClient",
17
+ "HedSuggestion",
18
+ "HedSuggestResult",
19
+ "TagSuggester",
20
+ ]
@@ -345,7 +345,6 @@ def _resolve_server_js() -> Path:
345
345
  if env:
346
346
  return Path(env)
347
347
  candidates = [
348
- Path("/app/hed-lsp/server/out/server.js"),
349
348
  Path.home() / "Documents/git/hed/hed-lsp/server/out/server.js",
350
349
  ]
351
350
  for candidate in candidates:
@@ -0,0 +1,292 @@
1
+ """HTTP client for the hed-lsp daemon (`POST /v1/suggest`).
2
+
3
+ The hed-lsp daemon serves the HED engine over HTTP, so HEDit no longer
4
+ has to build hed-lsp and hold a Node child per process. `HedEngineClient`
5
+ has the same `suggest()` signature and result types as `HedLspClient`,
6
+ so the workflow and validation agent accept either.
7
+
8
+ The daemon URL comes from `HED_LSP_URL` (default: the public instance at
9
+ https://hedtools.org/hed-lsp). On hedtools the containers reach the
10
+ daemon over the `hed-lsp` Docker network instead, which gives HEDit its
11
+ own client address for the daemon's rate limit.
12
+
13
+ When the daemon cannot be reached, `suggest()` returns a failure result
14
+ and callers skip suggestions, as they do without any client. The first
15
+ failure in a process is logged as a warning, later ones at debug. After a
16
+ transport error or timeout, calls are skipped for 60 s, and a malformed
17
+ `HED_LSP_URL` turns suggestions off instead of raising.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ import asyncio
23
+ import logging
24
+ import os
25
+ import time
26
+ from typing import Any, Protocol
27
+
28
+ import httpx
29
+
30
+ from src.lsp.client import HedSuggestion, HedSuggestResult
31
+
32
+ logger = logging.getLogger(__name__)
33
+
34
+ DEFAULT_HED_LSP_URL = "https://hedtools.org/hed-lsp"
35
+ DEFAULT_TIMEOUT_SECONDS = 10.0
36
+ # Connecting gets a shorter budget than the whole call, so a daemon that is
37
+ # down (or a dropped route) costs seconds, not the full timeout.
38
+ DEFAULT_CONNECT_TIMEOUT_SECONDS = 2.0
39
+ # After a transport error or timeout, calls are skipped for this long, so a
40
+ # hung or unreachable daemon does not add its timeout to every request.
41
+ UNAVAILABLE_COOLDOWN_SECONDS = 60.0
42
+ # A 429 or 503 is retried once, and only when the daemon asks for a wait
43
+ # this short; a longer wait (a schema in backoff, an exhausted bucket) is
44
+ # not worth holding an annotation request for.
45
+ MAX_RETRY_AFTER_SECONDS = 5.0
46
+ # Batch limits of the daemon contract (MAX_QUERIES, MAX_SEMANTIC_QUERIES);
47
+ # larger batches are split so they are never refused as BATCH_TOO_LARGE.
48
+ MAX_QUERIES_PER_REQUEST = 50
49
+ MAX_SEMANTIC_QUERIES_PER_REQUEST = 20
50
+
51
+ _RETRYABLE_STATUSES = frozenset({429, 503})
52
+
53
+ # One warning per process when the daemon fails; later failures go to debug
54
+ # so an unreachable daemon does not flood the log with one line per request.
55
+ _failure_warned = False
56
+
57
+
58
+ class TagSuggester(Protocol):
59
+ """What the workflow and validation agent need from a suggestion client."""
60
+
61
+ async def suggest(self, *queries: str, use_semantic: bool | None = None) -> HedSuggestResult:
62
+ """Return tag suggestions for each query."""
63
+
64
+ async def shutdown(self) -> None:
65
+ """Release the client's resources."""
66
+
67
+
68
+ def _log_failure(message: str) -> None:
69
+ global _failure_warned
70
+ if not _failure_warned:
71
+ _failure_warned = True
72
+ logger.warning(
73
+ "%s; continuing without tag suggestions (later failures are logged at debug)",
74
+ message,
75
+ )
76
+ else:
77
+ logger.debug("%s", message)
78
+
79
+
80
+ def _parse_retry_after(value: str | None) -> float | None:
81
+ """Return `Retry-After` in seconds, or None when absent or not a number.
82
+
83
+ The daemon always sends whole seconds; an HTTP date is treated as
84
+ unknown, which means no retry.
85
+ """
86
+ if value is None:
87
+ return None
88
+ try:
89
+ seconds = float(value.strip())
90
+ except ValueError:
91
+ return None
92
+ return seconds if seconds >= 0 else None
93
+
94
+
95
+ class HedEngineClient:
96
+ """Tag suggestions from the hed-lsp daemon over HTTP."""
97
+
98
+ def __init__(
99
+ self,
100
+ base_url: str | None = None,
101
+ *,
102
+ schema_version: str = "8.4.0",
103
+ max_results: int = 10,
104
+ timeout: float = DEFAULT_TIMEOUT_SECONDS,
105
+ connect_timeout: float = DEFAULT_CONNECT_TIMEOUT_SECONDS,
106
+ max_retry_after: float = MAX_RETRY_AFTER_SECONDS,
107
+ cooldown: float = UNAVAILABLE_COOLDOWN_SECONDS,
108
+ ) -> None:
109
+ url = base_url or os.environ.get("HED_LSP_URL") or DEFAULT_HED_LSP_URL
110
+ self._base_url = url.rstrip("/")
111
+ self._schema_version = schema_version
112
+ self._max_results = max_results
113
+ self._timeout = httpx.Timeout(timeout, connect=connect_timeout)
114
+ self._max_retry_after = max_retry_after
115
+ self._cooldown = cooldown
116
+ # Monotonic time before which calls are skipped after a transport error.
117
+ self._unavailable_until = 0.0
118
+ # A URL that cannot be used makes this client behave as no client:
119
+ # every call returns a failure result, and suggest() never raises.
120
+ self._config_error = _check_url(self._base_url)
121
+ if self._config_error is not None:
122
+ _log_failure(self._config_error)
123
+ # The HTTP client is bound to the event loop it was created on; the
124
+ # CLI may run commands on separate loops, so it is rebuilt per loop.
125
+ self._http: httpx.AsyncClient | None = None
126
+ self._http_loop: asyncio.AbstractEventLoop | None = None
127
+
128
+ @property
129
+ def base_url(self) -> str:
130
+ """The daemon URL this client calls."""
131
+ return self._base_url
132
+
133
+ async def _client(self) -> httpx.AsyncClient:
134
+ loop = asyncio.get_running_loop()
135
+ if self._http is None or self._http_loop is not loop or self._http.is_closed:
136
+ if self._http is not None and self._http_loop is loop:
137
+ await self._http.aclose()
138
+ self._http = httpx.AsyncClient(
139
+ base_url=self._base_url,
140
+ timeout=self._timeout,
141
+ headers={"Accept": "application/json"},
142
+ )
143
+ self._http_loop = loop
144
+ return self._http
145
+
146
+ async def _post_suggest(self, body: dict[str, Any]) -> httpx.Response:
147
+ """POST one suggest request, retrying once on a short 429 or 503."""
148
+ client = await self._client()
149
+ response = await client.post("/v1/suggest", json=body)
150
+ if response.status_code in _RETRYABLE_STATUSES:
151
+ wait = _parse_retry_after(response.headers.get("Retry-After"))
152
+ if wait is not None and wait <= self._max_retry_after:
153
+ await asyncio.sleep(wait)
154
+ response = await client.post("/v1/suggest", json=body)
155
+ return response
156
+
157
+ async def suggest(
158
+ self,
159
+ *queries: str,
160
+ use_semantic: bool | None = None,
161
+ ) -> HedSuggestResult:
162
+ """Ask the daemon for tag suggestions and return all of them.
163
+
164
+ Mirrors `HedLspClient.suggest`: `raw` maps each query to its tags
165
+ in the daemon's order, and `suggestions` is the flat list of
166
+ unique tags. A query the daemon rejects on its own item (blank,
167
+ too long) is left out; the others still return.
168
+ """
169
+ if not queries:
170
+ return HedSuggestResult(success=False, error="No queries provided")
171
+ if self._config_error is not None:
172
+ return HedSuggestResult(success=False, error=self._config_error)
173
+ if time.monotonic() < self._unavailable_until:
174
+ message = f"hed-lsp daemon at {self._base_url} skipped during cool-down"
175
+ logger.debug("%s", message)
176
+ return HedSuggestResult(success=False, error=message)
177
+
178
+ chunk_size = MAX_SEMANTIC_QUERIES_PER_REQUEST if use_semantic else MAX_QUERIES_PER_REQUEST
179
+ raw_clean: dict[str, list[str]] = {}
180
+ suggestions: list[HedSuggestion] = []
181
+ seen: set[str] = set()
182
+
183
+ def failure(message: str) -> HedSuggestResult:
184
+ # Keep what earlier chunks returned; the result is still a failure.
185
+ _log_failure(message)
186
+ return HedSuggestResult(
187
+ success=False, suggestions=suggestions, error=message, raw=raw_clean
188
+ )
189
+
190
+ for start in range(0, len(queries), chunk_size):
191
+ chunk = list(queries[start : start + chunk_size])
192
+ body: dict[str, Any] = {
193
+ "queries": chunk,
194
+ "schema": self._schema_version,
195
+ "top": self._max_results,
196
+ }
197
+ if use_semantic is not None:
198
+ body["semantic"] = use_semantic
199
+
200
+ try:
201
+ response = await self._post_suggest(body)
202
+ except httpx.TransportError as exc:
203
+ self._unavailable_until = time.monotonic() + self._cooldown
204
+ return failure(
205
+ f"hed-lsp daemon at {self._base_url} unreachable: {exc!r}; "
206
+ f"skipping calls for {self._cooldown:g} s"
207
+ )
208
+ except httpx.HTTPError as exc:
209
+ return failure(f"hed-lsp daemon at {self._base_url} request failed: {exc!r}")
210
+
211
+ if response.status_code != 200:
212
+ return failure(
213
+ f"hed-lsp daemon at {self._base_url} answered {response.status_code}"
214
+ f" ({_error_code(response)})"
215
+ )
216
+
217
+ try:
218
+ payload = response.json()
219
+ except ValueError:
220
+ return failure(
221
+ f"hed-lsp daemon at {self._base_url} returned a body that is not JSON"
222
+ )
223
+
224
+ results = payload.get("results") if isinstance(payload, dict) else None
225
+ if not isinstance(results, list):
226
+ return failure(
227
+ f"Unexpected /v1/suggest response shape from {self._base_url}: "
228
+ f"{type(payload).__name__}"
229
+ )
230
+
231
+ for item in results:
232
+ if not isinstance(item, dict):
233
+ continue
234
+ index = item.get("index")
235
+ if not isinstance(index, int) or not 0 <= index < len(chunk):
236
+ continue
237
+ if "error" in item:
238
+ logger.debug(
239
+ "hed-lsp daemon rejected query %r: %s", chunk[index], item["error"]
240
+ )
241
+ continue
242
+ tags = [
243
+ entry["tag"]
244
+ for entry in item.get("suggestions") or []
245
+ if isinstance(entry, dict)
246
+ and isinstance(entry.get("tag"), str)
247
+ and entry["tag"]
248
+ ]
249
+ raw_clean[chunk[index]] = tags
250
+ for tag in tags:
251
+ if tag not in seen:
252
+ seen.add(tag)
253
+ suggestions.append(HedSuggestion(tag=tag))
254
+
255
+ return HedSuggestResult(success=True, suggestions=suggestions, raw=raw_clean)
256
+
257
+ async def shutdown(self) -> None:
258
+ """Close the HTTP connection pool."""
259
+ if self._http is not None:
260
+ try:
261
+ await self._http.aclose()
262
+ except RuntimeError as exc:
263
+ # The pool was created on a loop that has since closed.
264
+ logger.debug("hed-lsp HTTP client close error: %s", exc)
265
+ self._http = None
266
+ self._http_loop = None
267
+
268
+
269
+ def _check_url(url: str) -> str | None:
270
+ """Why `url` cannot be used as the daemon URL, or None when it can."""
271
+ try:
272
+ parsed = httpx.URL(url)
273
+ except httpx.InvalidURL as exc:
274
+ return f"HED_LSP_URL {url!r} is not a valid URL ({exc}); tag suggestions are off"
275
+ if parsed.scheme not in ("http", "https") or not parsed.host:
276
+ return (
277
+ f"HED_LSP_URL {url!r} must be an http or https URL with a host; tag suggestions are off"
278
+ )
279
+ return None
280
+
281
+
282
+ def _error_code(response: httpx.Response) -> str:
283
+ """The daemon's error code from an error body, or the reason phrase."""
284
+ try:
285
+ payload = response.json()
286
+ except ValueError:
287
+ return response.reason_phrase or "no error body"
288
+ if isinstance(payload, dict):
289
+ error = payload.get("error")
290
+ if isinstance(error, dict) and isinstance(error.get("code"), str):
291
+ return error["code"]
292
+ return response.reason_phrase or "no error code"
@@ -4,9 +4,12 @@ This module provides HED validation and tag suggestion capabilities:
4
4
 
5
5
  - HedPythonValidator: Validates HED strings using hed-python library
6
6
  - HedJavaScriptValidator: Validates HED strings using hed-javascript (legacy)
7
- - HedLspClient: Persistent async client for the hed-lsp Node server
7
+ - HedEngineClient: Tag suggestions from the hed-lsp HTTP daemon (HED_LSP_URL);
8
+ the default suggestion path for the API server and the CLI
9
+ - HedLspClient: Client for a local hed-lsp server (the opt-in `hedit lsp` daemon)
8
10
  - get_validator: Factory function to get the appropriate validator
9
- - is_hed_lsp_available: Whether node + hed-lsp server.js are reachable
11
+ - is_hed_lsp_available: Whether node + a local hed-lsp server.js are reachable
12
+ (needed only for `hedit lsp start`)
10
13
 
11
14
  Note: Imports are lazy to avoid requiring hed-python for hed-lsp functionality.
12
15
  """
@@ -15,6 +18,7 @@ from typing import TYPE_CHECKING
15
18
 
16
19
  # HED-LSP imports (no heavy dependencies)
17
20
  from src.validation.hed_lsp import (
21
+ HedEngineClient,
18
22
  HedLspClient,
19
23
  HedSuggestion,
20
24
  HedSuggestResult,
@@ -42,6 +46,7 @@ __all__ = [
42
46
  "ValidationIssue",
43
47
  "ValidationResult",
44
48
  # HED-LSP (lightweight)
49
+ "HedEngineClient",
45
50
  "HedLspClient",
46
51
  "HedSuggestion",
47
52
  "HedSuggestResult",
@@ -1,11 +1,10 @@
1
1
  """Legacy import shim for the hed-lsp Python integration.
2
2
 
3
3
  Historically this module wrapped the `hed-suggest` CLI as a synchronous
4
- subprocess. That path was retired in favor of `src.lsp.HedLspClient`,
5
- which holds one persistent JSON-RPC connection to the hed-lsp server
6
- and answers batched queries in milliseconds. This file now re-exports
7
- the small set of helpers we still use and locates a server.js install
8
- for downstream callers (FastAPI lifespan, CLI executors).
4
+ subprocess. Tag suggestions now come from the hed-lsp HTTP daemon through
5
+ `src.lsp.HedEngineClient` (API server and CLI), or from the opt-in local
6
+ `hedit lsp` daemon through `src.lsp.HedLspClient`. This file re-exports
7
+ those clients and locates a local hed-lsp server.js for `hedit lsp start`.
9
8
  """
10
9
 
11
10
  from __future__ import annotations
@@ -14,9 +13,10 @@ import os
14
13
  import shutil
15
14
  from pathlib import Path
16
15
 
17
- from src.lsp import HedLspClient, HedSuggestion, HedSuggestResult
16
+ from src.lsp import HedEngineClient, HedLspClient, HedSuggestion, HedSuggestResult
18
17
 
19
18
  __all__ = [
19
+ "HedEngineClient",
20
20
  "HedLspClient",
21
21
  "HedSuggestion",
22
22
  "HedSuggestResult",
@@ -30,7 +30,6 @@ def _server_js_candidates() -> list[Path]:
30
30
  if env:
31
31
  return [Path(env)]
32
32
  return [
33
- Path("/app/hed-lsp/server/out/server.js"),
34
33
  Path.home() / "Documents/git/hed/hed-lsp/server/out/server.js",
35
34
  Path.home() / "git/hed/hed-lsp/server/out/server.js",
36
35
  ]
@@ -48,6 +47,7 @@ def is_hed_lsp_available() -> bool:
48
47
  """Whether a `node` interpreter and the hed-lsp server.js are reachable.
49
48
 
50
49
  Cheap check used by callers (CLI, tests) that want to decide whether
51
- to spawn a `HedLspClient` without actually attempting to spawn one.
50
+ to spawn a local `HedLspClient` without actually attempting to spawn one.
51
+ The HTTP daemon used by default (`HedEngineClient`) needs neither.
52
52
  """
53
53
  return shutil.which("node") is not None and find_lsp_server_js() is not None
@@ -1,6 +1,6 @@
1
1
  """Version information for HEDit."""
2
2
 
3
- __version__ = "0.7.11.dev18"
3
+ __version__ = "0.7.11.dev19"
4
4
  __version_info__ = (0, 7, 11, "dev")
5
5
 
6
6
 
@@ -436,6 +436,8 @@ class TestAPIEndpointIntegration:
436
436
  os.environ["REQUIRE_API_AUTH"] = "true"
437
437
  os.environ["API_KEYS"] = "integration-test-api-key"
438
438
  os.environ["USE_JS_VALIDATOR"] = "false"
439
+ # No tag-suggestion traffic to the public hed-lsp daemon from tests
440
+ os.environ["HED_LSP_DISABLE"] = "1"
439
441
 
440
442
  # Clear schema paths - app now handles None gracefully and fetches from GitHub
441
443
  for key in ["HED_SCHEMA_DIR", "HED_VALIDATOR_PATH"]:
@@ -1,13 +0,0 @@
1
- """Persistent client for the hed-lsp Node server.
2
-
3
- The hed-lsp server is a long-running LSP process that loads the HED
4
- schema and embedding model once at boot. This module speaks the LSP
5
- wire protocol (JSON-RPC over Content-Length framing) so the Python
6
- backend can hold one connection for the lifetime of the process and
7
- issue batched `hed/suggest` requests in milliseconds, instead of
8
- spawning the `hed-suggest` CLI per query (~6 s per spawn).
9
- """
10
-
11
- from src.lsp.client import HedLspClient, HedSuggestion, HedSuggestResult
12
-
13
- __all__ = ["HedLspClient", "HedSuggestion", "HedSuggestResult"]
File without changes
File without changes
File without changes
File without changes