agent-folder-workspace 0.1.0__py3-none-any.whl
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.
- agent_folder_workspace/__init__.py +42 -0
- agent_folder_workspace/__main__.py +6 -0
- agent_folder_workspace/adapters/__init__.py +5 -0
- agent_folder_workspace/adapters/base.py +93 -0
- agent_folder_workspace/adapters/legacy_office.py +552 -0
- agent_folder_workspace/adapters/manager.py +178 -0
- agent_folder_workspace/adapters/odf.py +636 -0
- agent_folder_workspace/adapters/ooxml.py +645 -0
- agent_folder_workspace/adapters/pdf.py +680 -0
- agent_folder_workspace/adapters/sqlite.py +326 -0
- agent_folder_workspace/adapters/structured.py +280 -0
- agent_folder_workspace/adapters/text.py +145 -0
- agent_folder_workspace/alternative_backends.py +329 -0
- agent_folder_workspace/backend_conversion_worker.py +232 -0
- agent_folder_workspace/backend_probe_worker.py +347 -0
- agent_folder_workspace/backends.py +321 -0
- agent_folder_workspace/cache.py +395 -0
- agent_folder_workspace/cfb.py +425 -0
- agent_folder_workspace/cli.py +139 -0
- agent_folder_workspace/config.py +37 -0
- agent_folder_workspace/cursors.py +46 -0
- agent_folder_workspace/errors.py +27 -0
- agent_folder_workspace/ids.py +42 -0
- agent_folder_workspace/installer.py +180 -0
- agent_folder_workspace/legacy.py +697 -0
- agent_folder_workspace/mcp_server.py +179 -0
- agent_folder_workspace/models.py +158 -0
- agent_folder_workspace/opencode/plugin/agent-folder-workspace.ts.tmpl +41 -0
- agent_folder_workspace/opencode/skill/SKILL.md +24 -0
- agent_folder_workspace/parser_workers.py +690 -0
- agent_folder_workspace/path_safety.py +28 -0
- agent_folder_workspace/probe_fixtures/probe.doc +0 -0
- agent_folder_workspace/probe_fixtures/probe.ppt +0 -0
- agent_folder_workspace/probe_fixtures/probe.xls +0 -0
- agent_folder_workspace/py.typed +1 -0
- agent_folder_workspace/registry.py +394 -0
- agent_folder_workspace/schemas/CapabilityReportV1.schema.json +121 -0
- agent_folder_workspace/schemas/ContentPageV1.schema.json +138 -0
- agent_folder_workspace/schemas/DiagnosticV1.schema.json +49 -0
- agent_folder_workspace/schemas/NodePageV1.schema.json +340 -0
- agent_folder_workspace/schemas/NodeV1.schema.json +289 -0
- agent_folder_workspace/schemas/SearchPageV1.schema.json +95 -0
- agent_folder_workspace/workspace.py +1141 -0
- agent_folder_workspace-0.1.0.dist-info/METADATA +407 -0
- agent_folder_workspace-0.1.0.dist-info/RECORD +48 -0
- agent_folder_workspace-0.1.0.dist-info/WHEEL +4 -0
- agent_folder_workspace-0.1.0.dist-info/entry_points.txt +2 -0
- agent_folder_workspace-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Lazy, offline folder exploration for agents."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from agent_folder_workspace.config import BackendPolicy, WorkspaceConfig
|
|
6
|
+
from agent_folder_workspace.errors import (
|
|
7
|
+
FolderWorkspaceError,
|
|
8
|
+
InputValidationError,
|
|
9
|
+
NodeNotFoundError,
|
|
10
|
+
ResourceLimitError,
|
|
11
|
+
StaleCursorError,
|
|
12
|
+
)
|
|
13
|
+
from agent_folder_workspace.ids import stable_node_id
|
|
14
|
+
from agent_folder_workspace.models import (
|
|
15
|
+
CapabilityReportV1,
|
|
16
|
+
ContentPageV1,
|
|
17
|
+
DiagnosticV1,
|
|
18
|
+
NodePageV1,
|
|
19
|
+
NodeV1,
|
|
20
|
+
SearchPageV1,
|
|
21
|
+
)
|
|
22
|
+
from agent_folder_workspace.workspace import FolderWorkspace
|
|
23
|
+
|
|
24
|
+
__version__ = "0.1.0"
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"BackendPolicy",
|
|
28
|
+
"CapabilityReportV1",
|
|
29
|
+
"ContentPageV1",
|
|
30
|
+
"DiagnosticV1",
|
|
31
|
+
"FolderWorkspace",
|
|
32
|
+
"FolderWorkspaceError",
|
|
33
|
+
"InputValidationError",
|
|
34
|
+
"NodeNotFoundError",
|
|
35
|
+
"NodePageV1",
|
|
36
|
+
"NodeV1",
|
|
37
|
+
"ResourceLimitError",
|
|
38
|
+
"SearchPageV1",
|
|
39
|
+
"StaleCursorError",
|
|
40
|
+
"WorkspaceConfig",
|
|
41
|
+
"stable_node_id",
|
|
42
|
+
]
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""Shared adapter contracts."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import mmap
|
|
6
|
+
from dataclasses import dataclass, field
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any, Protocol
|
|
9
|
+
|
|
10
|
+
from agent_folder_workspace.config import WorkspaceConfig
|
|
11
|
+
from agent_folder_workspace.models import ContentStatus, DiagnosticV1, NodeKind, NodeV1
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass(frozen=True, slots=True)
|
|
15
|
+
class VirtualNodeSpec:
|
|
16
|
+
name: str
|
|
17
|
+
kind: NodeKind
|
|
18
|
+
logical_path: str
|
|
19
|
+
child_count: int | None = None
|
|
20
|
+
size: int | None = None
|
|
21
|
+
metadata: dict[str, Any] = field(default_factory=dict)
|
|
22
|
+
source_part: str | None = None
|
|
23
|
+
source_offset: int | None = None
|
|
24
|
+
source_length: int | None = None
|
|
25
|
+
adapter: str | None = None
|
|
26
|
+
content_status: ContentStatus = ContentStatus.READY
|
|
27
|
+
diagnostics: list[DiagnosticV1] = field(default_factory=list)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass(frozen=True, slots=True)
|
|
31
|
+
class ReadResult:
|
|
32
|
+
items: list[Any]
|
|
33
|
+
total: int
|
|
34
|
+
text: str | None = None
|
|
35
|
+
diagnostics: list[DiagnosticV1] = field(default_factory=list)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Adapter(Protocol):
|
|
39
|
+
def children(
|
|
40
|
+
self, node: NodeV1, source: Path, config: WorkspaceConfig
|
|
41
|
+
) -> list[VirtualNodeSpec]: ...
|
|
42
|
+
|
|
43
|
+
def read(
|
|
44
|
+
self,
|
|
45
|
+
node: NodeV1,
|
|
46
|
+
source: Path,
|
|
47
|
+
offset: int,
|
|
48
|
+
limit: int,
|
|
49
|
+
config: WorkspaceConfig,
|
|
50
|
+
) -> ReadResult: ...
|
|
51
|
+
|
|
52
|
+
def read_binary_part(
|
|
53
|
+
self,
|
|
54
|
+
node: NodeV1,
|
|
55
|
+
source: Path,
|
|
56
|
+
offset: int,
|
|
57
|
+
length: int,
|
|
58
|
+
config: WorkspaceConfig,
|
|
59
|
+
) -> tuple[bytes, int]: ...
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class BaseAdapter:
|
|
63
|
+
def children(
|
|
64
|
+
self, node: NodeV1, source: Path, config: WorkspaceConfig
|
|
65
|
+
) -> list[VirtualNodeSpec]:
|
|
66
|
+
return []
|
|
67
|
+
|
|
68
|
+
def read(
|
|
69
|
+
self,
|
|
70
|
+
node: NodeV1,
|
|
71
|
+
source: Path,
|
|
72
|
+
offset: int,
|
|
73
|
+
limit: int,
|
|
74
|
+
config: WorkspaceConfig,
|
|
75
|
+
) -> ReadResult:
|
|
76
|
+
return ReadResult(items=[], total=0)
|
|
77
|
+
|
|
78
|
+
def read_binary_part(
|
|
79
|
+
self,
|
|
80
|
+
node: NodeV1,
|
|
81
|
+
source: Path,
|
|
82
|
+
offset: int,
|
|
83
|
+
length: int,
|
|
84
|
+
config: WorkspaceConfig,
|
|
85
|
+
) -> tuple[bytes, int]:
|
|
86
|
+
total = source.stat().st_size
|
|
87
|
+
if total == 0 or offset >= total:
|
|
88
|
+
return b"", total
|
|
89
|
+
with (
|
|
90
|
+
source.open("rb") as handle,
|
|
91
|
+
mmap.mmap(handle.fileno(), length=0, access=mmap.ACCESS_READ) as mapped,
|
|
92
|
+
):
|
|
93
|
+
return bytes(mapped[offset : offset + length]), total
|