agentlink-cli 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.
- agentlink_cli-0.1.0.dist-info/METADATA +136 -0
- agentlink_cli-0.1.0.dist-info/RECORD +55 -0
- agentlink_cli-0.1.0.dist-info/WHEEL +4 -0
- agentlink_cli-0.1.0.dist-info/entry_points.txt +3 -0
- connector/__init__.py +3 -0
- connector/acp/__init__.py +6 -0
- connector/acp/adapter.py +1221 -0
- connector/acp/config_options.py +175 -0
- connector/acp/discovery.py +385 -0
- connector/acp/manifest.py +110 -0
- connector/acp/manifests/__init__.py +1 -0
- connector/acp/manifests/codebuddy.json +37 -0
- connector/acp/manifests/cursor.json +39 -0
- connector/acp/manifests/gemini.json +33 -0
- connector/acp/manifests/grok_build.json +31 -0
- connector/acp/reducer.py +615 -0
- connector/acp/rpc.py +308 -0
- connector/adapter.py +39 -0
- connector/attachments.py +36 -0
- connector/capabilities.py +603 -0
- connector/claude/__init__.py +8 -0
- connector/claude/history_adapter.py +642 -0
- connector/claude/normalized.py +23 -0
- connector/claude/normalizers.py +97 -0
- connector/claude/path_utils.py +13 -0
- connector/claude/preferences.py +38 -0
- connector/claude/sdk_adapter.py +1376 -0
- connector/claude/timeline_identity.py +47 -0
- connector/claude/timeline_reducer.py +379 -0
- connector/claude/trust.py +69 -0
- connector/cli.py +280 -0
- connector/codex/__init__.py +3 -0
- connector/codex/adapter.py +1150 -0
- connector/codex/history.py +199 -0
- connector/codex/reducer.py +1309 -0
- connector/codex/rpc.py +261 -0
- connector/control.py +298 -0
- connector/json_rpc.py +143 -0
- connector/launch.py +310 -0
- connector/local/__init__.py +6 -0
- connector/local/common.py +118 -0
- connector/local/file_ops.py +144 -0
- connector/local/ops.py +92 -0
- connector/local/shell.py +225 -0
- connector/local/terminal.py +658 -0
- connector/local_ops.py +5 -0
- connector/local_runtime.py +139 -0
- connector/logging.py +50 -0
- connector/perf.py +89 -0
- connector/protocol.py +26 -0
- connector/registry.py +49 -0
- connector/runtime.py +1309 -0
- connector/sync_state.py +155 -0
- connector/time.py +7 -0
- connector/version.py +13 -0
connector/sync_state.py
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import sqlite3
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from connector.time import utc_now
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(frozen=True, slots=True)
|
|
14
|
+
class RuntimeSyncState:
|
|
15
|
+
fingerprint: dict[str, Any] | None = None
|
|
16
|
+
cursor: dict[str, Any] | None = None
|
|
17
|
+
metadata: dict[str, Any] | None = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class SyncStateStore:
|
|
21
|
+
def get(self, runtime: str, connector_id: str, external_session_id: str) -> RuntimeSyncState | None:
|
|
22
|
+
raise NotImplementedError
|
|
23
|
+
|
|
24
|
+
def set(
|
|
25
|
+
self,
|
|
26
|
+
runtime: str,
|
|
27
|
+
connector_id: str,
|
|
28
|
+
external_session_id: str,
|
|
29
|
+
*,
|
|
30
|
+
fingerprint: dict[str, Any] | None = None,
|
|
31
|
+
cursor: dict[str, Any] | None = None,
|
|
32
|
+
metadata: dict[str, Any] | None = None,
|
|
33
|
+
) -> None:
|
|
34
|
+
raise NotImplementedError
|
|
35
|
+
|
|
36
|
+
def delete_runtime(self, runtime: str, connector_id: str) -> None:
|
|
37
|
+
raise NotImplementedError
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class SqliteSyncStateStore(SyncStateStore):
|
|
41
|
+
def __init__(self, path: str | Path) -> None:
|
|
42
|
+
self.path = Path(path).expanduser()
|
|
43
|
+
self.path.parent.mkdir(parents=True, exist_ok=True)
|
|
44
|
+
self._init_schema()
|
|
45
|
+
|
|
46
|
+
@classmethod
|
|
47
|
+
def default_path(cls) -> Path:
|
|
48
|
+
return Path(
|
|
49
|
+
os.environ.get(
|
|
50
|
+
"AGENT_CONNECTOR_STATE_DB",
|
|
51
|
+
Path.home() / ".agent-server" / "connector-state.sqlite3",
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def get(self, runtime: str, connector_id: str, external_session_id: str) -> RuntimeSyncState | None:
|
|
56
|
+
with self._connect() as conn:
|
|
57
|
+
row = conn.execute(
|
|
58
|
+
"""
|
|
59
|
+
SELECT fingerprint_json, cursor_json, metadata_json
|
|
60
|
+
FROM runtime_sync_state
|
|
61
|
+
WHERE runtime = ? AND connector_id = ? AND external_session_id = ?
|
|
62
|
+
""",
|
|
63
|
+
(runtime, connector_id, external_session_id),
|
|
64
|
+
).fetchone()
|
|
65
|
+
if row is None:
|
|
66
|
+
return None
|
|
67
|
+
return RuntimeSyncState(
|
|
68
|
+
fingerprint=_loads(row["fingerprint_json"]),
|
|
69
|
+
cursor=_loads(row["cursor_json"]),
|
|
70
|
+
metadata=_loads(row["metadata_json"]),
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
def set(
|
|
74
|
+
self,
|
|
75
|
+
runtime: str,
|
|
76
|
+
connector_id: str,
|
|
77
|
+
external_session_id: str,
|
|
78
|
+
*,
|
|
79
|
+
fingerprint: dict[str, Any] | None = None,
|
|
80
|
+
cursor: dict[str, Any] | None = None,
|
|
81
|
+
metadata: dict[str, Any] | None = None,
|
|
82
|
+
) -> None:
|
|
83
|
+
now = utc_now()
|
|
84
|
+
with self._connect() as conn:
|
|
85
|
+
conn.execute(
|
|
86
|
+
"""
|
|
87
|
+
INSERT INTO runtime_sync_state (
|
|
88
|
+
runtime,
|
|
89
|
+
connector_id,
|
|
90
|
+
external_session_id,
|
|
91
|
+
fingerprint_json,
|
|
92
|
+
cursor_json,
|
|
93
|
+
metadata_json,
|
|
94
|
+
updated_at
|
|
95
|
+
)
|
|
96
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
97
|
+
ON CONFLICT(runtime, connector_id, external_session_id) DO UPDATE SET
|
|
98
|
+
fingerprint_json = excluded.fingerprint_json,
|
|
99
|
+
cursor_json = excluded.cursor_json,
|
|
100
|
+
metadata_json = excluded.metadata_json,
|
|
101
|
+
updated_at = excluded.updated_at
|
|
102
|
+
""",
|
|
103
|
+
(
|
|
104
|
+
runtime,
|
|
105
|
+
connector_id,
|
|
106
|
+
external_session_id,
|
|
107
|
+
_dumps(fingerprint),
|
|
108
|
+
_dumps(cursor),
|
|
109
|
+
_dumps(metadata),
|
|
110
|
+
now,
|
|
111
|
+
),
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
def delete_runtime(self, runtime: str, connector_id: str) -> None:
|
|
115
|
+
with self._connect() as conn:
|
|
116
|
+
conn.execute(
|
|
117
|
+
"DELETE FROM runtime_sync_state WHERE runtime = ? AND connector_id = ?",
|
|
118
|
+
(runtime, connector_id),
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
def _connect(self) -> sqlite3.Connection:
|
|
122
|
+
conn = sqlite3.connect(self.path)
|
|
123
|
+
conn.row_factory = sqlite3.Row
|
|
124
|
+
return conn
|
|
125
|
+
|
|
126
|
+
def _init_schema(self) -> None:
|
|
127
|
+
with self._connect() as conn:
|
|
128
|
+
conn.execute("PRAGMA journal_mode=WAL")
|
|
129
|
+
conn.execute(
|
|
130
|
+
"""
|
|
131
|
+
CREATE TABLE IF NOT EXISTS runtime_sync_state (
|
|
132
|
+
runtime TEXT NOT NULL,
|
|
133
|
+
connector_id TEXT NOT NULL,
|
|
134
|
+
external_session_id TEXT NOT NULL,
|
|
135
|
+
fingerprint_json TEXT,
|
|
136
|
+
cursor_json TEXT,
|
|
137
|
+
metadata_json TEXT,
|
|
138
|
+
updated_at TEXT NOT NULL,
|
|
139
|
+
PRIMARY KEY (runtime, connector_id, external_session_id)
|
|
140
|
+
)
|
|
141
|
+
"""
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def _dumps(value: dict[str, Any] | None) -> str | None:
|
|
146
|
+
if value is None:
|
|
147
|
+
return None
|
|
148
|
+
return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def _loads(value: str | None) -> dict[str, Any] | None:
|
|
152
|
+
if not value:
|
|
153
|
+
return None
|
|
154
|
+
loaded = json.loads(value)
|
|
155
|
+
return loaded if isinstance(loaded, dict) else None
|
connector/time.py
ADDED
connector/version.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
+
|
|
5
|
+
FALLBACK_VERSION = "0.1.0"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def connector_version() -> str:
|
|
9
|
+
"""Return the installed AgentLink CLI version, with a source-tree fallback."""
|
|
10
|
+
try:
|
|
11
|
+
return version("agentlink-cli")
|
|
12
|
+
except PackageNotFoundError:
|
|
13
|
+
return FALLBACK_VERSION
|