meshagent-api 0.54.1__tar.gz → 0.55.0__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.
- {meshagent_api-0.54.1/meshagent_api.egg-info → meshagent_api-0.55.0}/PKG-INFO +1 -1
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/__init__.py +2 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/client.py +3 -1
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/managed_agents.py +135 -1
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/managed_agents_test.py +77 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/room_server_client.py +62 -2
- meshagent_api-0.55.0/meshagent/api/sqlite_replication_test.py +38 -0
- meshagent_api-0.55.0/meshagent/api/version.py +1 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0/meshagent_api.egg-info}/PKG-INFO +1 -1
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent_api.egg-info/SOURCES.txt +1 -0
- meshagent_api-0.54.1/meshagent/api/version.py +0 -1
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/LICENSE +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/MANIFEST.in +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/README.md +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/agent_content.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/aiohttp_redaction.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/chan.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/client_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/crdt.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/dataset_schema.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/entrypoint.js +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/error_codes.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/file_permissions.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/files.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/files_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/helpers.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/http.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/image_runtime.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/keys.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/llm_router_config.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/messaging.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/messaging_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/mime_types.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/mime_types_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/oauth.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/oauth_branding.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/oauth_scopes.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/oauth_scopes_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/participant.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/participant_token.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/participant_token_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/port_forward.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/port_forward_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/protocol.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/protocol_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/py.typed +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/reasoning_schema.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/registry_auth.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/room_ports.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/room_server_client_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/runtime.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/runtime_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/schema.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/schema_document.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/schema_document_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/schema_registry.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/schema_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/schema_util.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/service_spec_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/service_template_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/services.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/services_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/specs/service.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/sql.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/sql_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/sqlite_batch_integration_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/sqlite_transfer.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/sqlite_transfer_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/storage_policy_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/token_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/urls.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/webhooks.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/webhooks_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/websocket_protocol.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/websocket_protocol_test.py +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent_api.egg-info/dependency_links.txt +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent_api.egg-info/requires.txt +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent_api.egg-info/top_level.txt +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/pyproject.toml +0 -0
- {meshagent_api-0.54.1 → meshagent_api-0.55.0}/setup.cfg +0 -0
|
@@ -38,6 +38,7 @@ from .room_server_client import (
|
|
|
38
38
|
SqliteClient,
|
|
39
39
|
SqliteDatabaseClient,
|
|
40
40
|
SqliteDatabaseDetails,
|
|
41
|
+
SqliteReplicationSettings,
|
|
41
42
|
SqliteSqlCommand,
|
|
42
43
|
SqliteSqlExecution,
|
|
43
44
|
SqliteSqlQuery,
|
|
@@ -205,6 +206,7 @@ __all__ = [
|
|
|
205
206
|
"SqliteClient",
|
|
206
207
|
"SqliteDatabaseClient",
|
|
207
208
|
"SqliteDatabaseDetails",
|
|
209
|
+
"SqliteReplicationSettings",
|
|
208
210
|
"SqliteSqlCommand",
|
|
209
211
|
"SqliteSqlExecution",
|
|
210
212
|
"SqliteSqlQuery",
|
|
@@ -202,7 +202,9 @@ class RoomsPage(BaseModel):
|
|
|
202
202
|
continuation_token: Optional[str] = None
|
|
203
203
|
|
|
204
204
|
|
|
205
|
-
AccessSubjectType = Literal[
|
|
205
|
+
AccessSubjectType = Literal[
|
|
206
|
+
"user", "group", "agent", "service_account", "userset", "everyone"
|
|
207
|
+
]
|
|
206
208
|
AccessResourceType = Literal[
|
|
207
209
|
"project",
|
|
208
210
|
"room",
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import Annotated, Literal
|
|
3
|
+
from typing import Annotated, Any, Literal
|
|
4
|
+
from urllib.parse import urlsplit
|
|
4
5
|
|
|
6
|
+
import jsonschema
|
|
5
7
|
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
|
6
8
|
|
|
7
9
|
|
|
@@ -153,6 +155,128 @@ class ManagedAgentMetadata(BaseModel):
|
|
|
153
155
|
return value.strip().lower()
|
|
154
156
|
|
|
155
157
|
|
|
158
|
+
def _validate_python_tool_schema(schema: dict[str, Any], path: str = "input_schema"):
|
|
159
|
+
allowed = {
|
|
160
|
+
"type",
|
|
161
|
+
"title",
|
|
162
|
+
"description",
|
|
163
|
+
"properties",
|
|
164
|
+
"required",
|
|
165
|
+
"additionalProperties",
|
|
166
|
+
"items",
|
|
167
|
+
"$defs",
|
|
168
|
+
"$ref",
|
|
169
|
+
"anyOf",
|
|
170
|
+
"enum",
|
|
171
|
+
"const",
|
|
172
|
+
"format",
|
|
173
|
+
"pattern",
|
|
174
|
+
"minimum",
|
|
175
|
+
"maximum",
|
|
176
|
+
"exclusiveMinimum",
|
|
177
|
+
"exclusiveMaximum",
|
|
178
|
+
"multipleOf",
|
|
179
|
+
"minItems",
|
|
180
|
+
"maxItems",
|
|
181
|
+
}
|
|
182
|
+
if not isinstance(schema, dict):
|
|
183
|
+
raise ValueError(f"{path}: expected a schema object")
|
|
184
|
+
if not any(key in schema for key in ("type", "$ref", "anyOf")):
|
|
185
|
+
raise ValueError(f"{path}: schema requires type, $ref, or anyOf")
|
|
186
|
+
for key in schema:
|
|
187
|
+
if key not in allowed:
|
|
188
|
+
raise ValueError(f"{path}.{key}: unsupported strict-schema keyword")
|
|
189
|
+
if "$ref" in schema and (
|
|
190
|
+
not isinstance(schema["$ref"], str) or not schema["$ref"].startswith("#/$defs/")
|
|
191
|
+
):
|
|
192
|
+
raise ValueError(f"{path}: only local $defs references are supported")
|
|
193
|
+
schema_type = schema.get("type")
|
|
194
|
+
if schema_type == "object" or (
|
|
195
|
+
isinstance(schema_type, list) and "object" in schema_type
|
|
196
|
+
):
|
|
197
|
+
properties = schema.get("properties")
|
|
198
|
+
required = schema.get("required")
|
|
199
|
+
if schema.get("additionalProperties") is not False:
|
|
200
|
+
raise ValueError(f"{path}.additionalProperties must be false")
|
|
201
|
+
if not isinstance(properties, dict) or not isinstance(required, list):
|
|
202
|
+
raise ValueError(f"{path}: properties and required are required")
|
|
203
|
+
if not all(isinstance(name, str) for name in required) or (
|
|
204
|
+
len(set(required)) != len(required) or set(required) != set(properties)
|
|
205
|
+
):
|
|
206
|
+
raise ValueError(f"{path}.required must list every property exactly once")
|
|
207
|
+
for key in ("properties", "$defs"):
|
|
208
|
+
children = schema.get(key, {})
|
|
209
|
+
if isinstance(children, dict):
|
|
210
|
+
for name, child in children.items():
|
|
211
|
+
_validate_python_tool_schema(child, f"{path}.{key}.{name}")
|
|
212
|
+
if "items" in schema:
|
|
213
|
+
_validate_python_tool_schema(schema["items"], f"{path}.items")
|
|
214
|
+
for index, child in enumerate(schema.get("anyOf", [])):
|
|
215
|
+
_validate_python_tool_schema(child, f"{path}.anyOf[{index}]")
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
class ManagedAgentPythonTool(BaseModel):
|
|
219
|
+
model_config = ConfigDict(extra="forbid")
|
|
220
|
+
|
|
221
|
+
type: Literal["python"] = "python"
|
|
222
|
+
name: str = Field(pattern=r"^[A-Za-z_][A-Za-z0-9_]*$", max_length=64)
|
|
223
|
+
description: str = ""
|
|
224
|
+
input_schema: dict[str, Any]
|
|
225
|
+
source: str = Field(min_length=1, max_length=65536)
|
|
226
|
+
entrypoint: str | None = Field(
|
|
227
|
+
default=None, pattern=r"^[A-Za-z_][A-Za-z0-9_]*$", max_length=64
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
@field_validator("source")
|
|
231
|
+
@classmethod
|
|
232
|
+
def validate_source(cls, value: str) -> str:
|
|
233
|
+
if len(value.encode("utf-8")) > 65536:
|
|
234
|
+
raise ValueError("source must contain at most 65536 bytes")
|
|
235
|
+
return value
|
|
236
|
+
|
|
237
|
+
@field_validator("input_schema")
|
|
238
|
+
@classmethod
|
|
239
|
+
def validate_input_schema(cls, value: dict[str, Any]) -> dict[str, Any]:
|
|
240
|
+
if "anyOf" in value:
|
|
241
|
+
raise ValueError("root anyOf is not supported")
|
|
242
|
+
if value.get("type") != "object":
|
|
243
|
+
raise ValueError("input_schema must be an object schema")
|
|
244
|
+
try:
|
|
245
|
+
jsonschema.Draft202012Validator.check_schema(value)
|
|
246
|
+
except jsonschema.SchemaError as error:
|
|
247
|
+
raise ValueError(f"invalid input_schema: {error.message}") from error
|
|
248
|
+
_validate_python_tool_schema(value)
|
|
249
|
+
return value
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
class ManagedAgentHttpConnection(BaseModel):
|
|
253
|
+
model_config = ConfigDict(extra="forbid")
|
|
254
|
+
|
|
255
|
+
base_url: str
|
|
256
|
+
use_proxy_secret: str | None = None
|
|
257
|
+
|
|
258
|
+
@field_validator("base_url")
|
|
259
|
+
@classmethod
|
|
260
|
+
def validate_base_url(cls, value: str) -> str:
|
|
261
|
+
parsed = urlsplit(value)
|
|
262
|
+
if (
|
|
263
|
+
parsed.scheme not in ("http", "https")
|
|
264
|
+
or not parsed.hostname
|
|
265
|
+
or parsed.username is not None
|
|
266
|
+
or parsed.password is not None
|
|
267
|
+
or parsed.fragment
|
|
268
|
+
):
|
|
269
|
+
raise ValueError("URL must be HTTP(S), without credentials or fragment")
|
|
270
|
+
return value
|
|
271
|
+
|
|
272
|
+
@field_validator("use_proxy_secret")
|
|
273
|
+
@classmethod
|
|
274
|
+
def validate_proxy_secret(cls, value: str | None) -> str | None:
|
|
275
|
+
if value is not None and not value.strip():
|
|
276
|
+
raise ValueError("use_proxy_secret must not be empty")
|
|
277
|
+
return value
|
|
278
|
+
|
|
279
|
+
|
|
156
280
|
class ManagedAgentSpec(BaseModel):
|
|
157
281
|
model_config = ConfigDict(extra="forbid")
|
|
158
282
|
version: Literal["v1"] = "v1"
|
|
@@ -165,9 +289,19 @@ class ManagedAgentSpec(BaseModel):
|
|
|
165
289
|
thread_isolation: ManagedAgentThreadIsolation = "global"
|
|
166
290
|
instructions: str | None = None
|
|
167
291
|
toolkits: list[ManagedToolkit] | None = None
|
|
292
|
+
tools: list[ManagedAgentPythonTool] = Field(default_factory=list)
|
|
293
|
+
connections: dict[str, ManagedAgentHttpConnection] = Field(default_factory=dict)
|
|
168
294
|
output_modalities: list[str] | None = None
|
|
169
295
|
store: bool = True
|
|
170
296
|
|
|
297
|
+
@field_validator("tools")
|
|
298
|
+
@classmethod
|
|
299
|
+
def validate_tool_names(cls, value: list[ManagedAgentPythonTool]):
|
|
300
|
+
names = [tool.name for tool in value]
|
|
301
|
+
if len(set(names)) != len(names):
|
|
302
|
+
raise ValueError("duplicate Python tool name")
|
|
303
|
+
return value
|
|
304
|
+
|
|
171
305
|
@model_validator(mode="before")
|
|
172
306
|
@classmethod
|
|
173
307
|
def migrate_legacy_name(cls, value: object) -> object:
|
|
@@ -225,3 +225,80 @@ def test_managed_web_search_domain_filters_require_lists(field):
|
|
|
225
225
|
"toolkits": [{"type": "web_search", field: "example.com"}],
|
|
226
226
|
}
|
|
227
227
|
)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def test_embedded_python_tool_round_trip():
|
|
231
|
+
from meshagent.api.managed_agents import ManagedAgentPythonTool
|
|
232
|
+
|
|
233
|
+
tool = ManagedAgentPythonTool(
|
|
234
|
+
name="lookup",
|
|
235
|
+
input_schema={
|
|
236
|
+
"type": "object",
|
|
237
|
+
"properties": {"id": {"type": "string"}},
|
|
238
|
+
"required": ["id"],
|
|
239
|
+
"additionalProperties": False,
|
|
240
|
+
},
|
|
241
|
+
source="async def lookup(args): return args",
|
|
242
|
+
)
|
|
243
|
+
spec = ManagedAgentSpec(
|
|
244
|
+
metadata={"name": "lookup-agent"},
|
|
245
|
+
allowed_models=[],
|
|
246
|
+
tools=[tool],
|
|
247
|
+
connections={"crm": {"base_url": "https://example.com"}},
|
|
248
|
+
)
|
|
249
|
+
assert ManagedAgentSpec.model_validate_json(spec.model_dump_json()) == spec
|
|
250
|
+
assert spec.tools[0].entrypoint is None
|
|
251
|
+
assert spec.connections["crm"].use_proxy_secret is None
|
|
252
|
+
with pytest.raises(ValidationError, match="duplicate"):
|
|
253
|
+
ManagedAgentSpec.model_validate({**spec.model_dump(), "tools": [tool, tool]})
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
@pytest.mark.parametrize(
|
|
257
|
+
"schema",
|
|
258
|
+
[
|
|
259
|
+
{"type": "object", "properties": {}, "required": []},
|
|
260
|
+
{
|
|
261
|
+
"type": "object",
|
|
262
|
+
"properties": {"id": {"type": "string"}},
|
|
263
|
+
"required": [],
|
|
264
|
+
"additionalProperties": False,
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"type": "object",
|
|
268
|
+
"properties": {"nested": {"type": "object"}},
|
|
269
|
+
"required": ["nested"],
|
|
270
|
+
"additionalProperties": False,
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"type": "object",
|
|
274
|
+
"$ref": "https://example.com/schema",
|
|
275
|
+
"properties": {},
|
|
276
|
+
"required": [],
|
|
277
|
+
"additionalProperties": False,
|
|
278
|
+
},
|
|
279
|
+
],
|
|
280
|
+
)
|
|
281
|
+
def test_python_tools_reject_non_strict_schema(schema):
|
|
282
|
+
from meshagent.api.managed_agents import ManagedAgentPythonTool
|
|
283
|
+
|
|
284
|
+
with pytest.raises(ValidationError):
|
|
285
|
+
ManagedAgentPythonTool(
|
|
286
|
+
name="lookup",
|
|
287
|
+
input_schema=schema,
|
|
288
|
+
source="async def lookup(args): return args",
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
@pytest.mark.parametrize(
|
|
293
|
+
"url",
|
|
294
|
+
[
|
|
295
|
+
"file:///etc/passwd",
|
|
296
|
+
"https://user:secret@example.com",
|
|
297
|
+
"https://example.com/#secret",
|
|
298
|
+
],
|
|
299
|
+
)
|
|
300
|
+
def test_python_connections_reject_invalid_urls(url):
|
|
301
|
+
from meshagent.api.managed_agents import ManagedAgentHttpConnection
|
|
302
|
+
|
|
303
|
+
with pytest.raises(ValidationError):
|
|
304
|
+
ManagedAgentHttpConnection(base_url=url)
|
|
@@ -6570,6 +6570,11 @@ class SqliteSqlCancelResult:
|
|
|
6570
6570
|
status: Literal["cancelled", "cancelling", "not_cancellable"]
|
|
6571
6571
|
|
|
6572
6572
|
|
|
6573
|
+
class SqliteReplicationSettings(BaseModel):
|
|
6574
|
+
replication_mode: Literal["synchronous", "asynchronous"] = "synchronous"
|
|
6575
|
+
flush_interval_ms: int = Field(default=1000, ge=1, le=3600000)
|
|
6576
|
+
|
|
6577
|
+
|
|
6573
6578
|
class SqliteDatabaseDetails(BaseModel):
|
|
6574
6579
|
name: str
|
|
6575
6580
|
namespace: Optional[list[str]] = None
|
|
@@ -8342,11 +8347,19 @@ class SqliteDatabaseClient:
|
|
|
8342
8347
|
self.database = database
|
|
8343
8348
|
self.namespace = namespace
|
|
8344
8349
|
|
|
8345
|
-
async def create_database(
|
|
8350
|
+
async def create_database(
|
|
8351
|
+
self,
|
|
8352
|
+
*,
|
|
8353
|
+
mode: Optional[CreateMode] = "create",
|
|
8354
|
+
replication_mode: Optional[Literal["synchronous", "asynchronous"]] = None,
|
|
8355
|
+
flush_interval_ms: Optional[int] = None,
|
|
8356
|
+
) -> None:
|
|
8346
8357
|
await self._client.create_database(
|
|
8347
8358
|
name=self.database,
|
|
8348
8359
|
namespace=self.namespace,
|
|
8349
8360
|
mode=mode,
|
|
8361
|
+
replication_mode=replication_mode,
|
|
8362
|
+
flush_interval_ms=flush_interval_ms,
|
|
8350
8363
|
)
|
|
8351
8364
|
|
|
8352
8365
|
async def drop_database(self, *, ignore_missing: bool = False) -> None:
|
|
@@ -8758,14 +8771,61 @@ class SqliteClient:
|
|
|
8758
8771
|
name: str,
|
|
8759
8772
|
namespace: Optional[list[str]] = None,
|
|
8760
8773
|
mode: str = "create",
|
|
8774
|
+
replication_mode: Optional[Literal["synchronous", "asynchronous"]] = None,
|
|
8775
|
+
flush_interval_ms: Optional[int] = None,
|
|
8761
8776
|
) -> None:
|
|
8777
|
+
settings = {}
|
|
8778
|
+
if replication_mode is not None:
|
|
8779
|
+
settings["replication_mode"] = replication_mode
|
|
8780
|
+
if flush_interval_ms is not None:
|
|
8781
|
+
settings["flush_interval_ms"] = flush_interval_ms
|
|
8762
8782
|
response = await self._invoke(
|
|
8763
8783
|
operation="create_database",
|
|
8764
|
-
input={"name": name, "namespace": namespace, "mode": mode},
|
|
8784
|
+
input={"name": name, "namespace": namespace, "mode": mode, **settings},
|
|
8765
8785
|
)
|
|
8766
8786
|
if not isinstance(response, EmptyContent):
|
|
8767
8787
|
raise self._unexpected_response_error(operation="create_database")
|
|
8768
8788
|
|
|
8789
|
+
async def get_database_settings(
|
|
8790
|
+
self, *, name: str, namespace: Optional[list[str]] = None
|
|
8791
|
+
) -> SqliteReplicationSettings:
|
|
8792
|
+
response = await self._invoke(
|
|
8793
|
+
operation="get_database_settings",
|
|
8794
|
+
input={"name": name, "namespace": namespace},
|
|
8795
|
+
)
|
|
8796
|
+
if not isinstance(response, JsonContent):
|
|
8797
|
+
raise self._unexpected_response_error(operation="get_database_settings")
|
|
8798
|
+
return SqliteReplicationSettings.model_validate(response.json)
|
|
8799
|
+
|
|
8800
|
+
async def update_database_settings(
|
|
8801
|
+
self,
|
|
8802
|
+
*,
|
|
8803
|
+
name: str,
|
|
8804
|
+
namespace: Optional[list[str]] = None,
|
|
8805
|
+
replication_mode: Optional[Literal["synchronous", "asynchronous"]] = None,
|
|
8806
|
+
flush_interval_ms: Optional[int] = None,
|
|
8807
|
+
) -> SqliteReplicationSettings:
|
|
8808
|
+
values = {"name": name, "namespace": namespace}
|
|
8809
|
+
if replication_mode is not None:
|
|
8810
|
+
values["replication_mode"] = replication_mode
|
|
8811
|
+
if flush_interval_ms is not None:
|
|
8812
|
+
values["flush_interval_ms"] = flush_interval_ms
|
|
8813
|
+
response = await self._invoke(
|
|
8814
|
+
operation="update_database_settings", input=values
|
|
8815
|
+
)
|
|
8816
|
+
if not isinstance(response, JsonContent):
|
|
8817
|
+
raise self._unexpected_response_error(operation="update_database_settings")
|
|
8818
|
+
return SqliteReplicationSettings.model_validate(response.json)
|
|
8819
|
+
|
|
8820
|
+
async def flush_database(
|
|
8821
|
+
self, *, name: str, namespace: Optional[list[str]] = None
|
|
8822
|
+
) -> None:
|
|
8823
|
+
response = await self._invoke(
|
|
8824
|
+
operation="flush_database", input={"name": name, "namespace": namespace}
|
|
8825
|
+
)
|
|
8826
|
+
if not isinstance(response, JsonContent):
|
|
8827
|
+
raise self._unexpected_response_error(operation="flush_database")
|
|
8828
|
+
|
|
8769
8829
|
async def drop_database(
|
|
8770
8830
|
self,
|
|
8771
8831
|
*,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from unittest.mock import AsyncMock
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from meshagent.api.room_server_client import SqliteClient, SqliteReplicationSettings
|
|
6
|
+
from meshagent.api.messaging import EmptyContent, JsonContent
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@pytest.mark.asyncio
|
|
10
|
+
async def test_replication_settings_wire_format():
|
|
11
|
+
room = AsyncMock()
|
|
12
|
+
room.invoke.return_value = EmptyContent()
|
|
13
|
+
client = SqliteClient(room)
|
|
14
|
+
await client.create_database(
|
|
15
|
+
name="app", replication_mode="asynchronous", flush_interval_ms=250
|
|
16
|
+
)
|
|
17
|
+
assert room.invoke.call_args.kwargs["input"] == {
|
|
18
|
+
"name": "app",
|
|
19
|
+
"namespace": None,
|
|
20
|
+
"mode": "create",
|
|
21
|
+
"replication_mode": "asynchronous",
|
|
22
|
+
"flush_interval_ms": 250,
|
|
23
|
+
}
|
|
24
|
+
room.invoke.return_value = JsonContent(
|
|
25
|
+
json={"replication_mode": "asynchronous", "flush_interval_ms": 500}
|
|
26
|
+
)
|
|
27
|
+
settings = await client.update_database_settings(name="app", flush_interval_ms=500)
|
|
28
|
+
assert settings == SqliteReplicationSettings(
|
|
29
|
+
replication_mode="asynchronous", flush_interval_ms=500
|
|
30
|
+
)
|
|
31
|
+
assert room.invoke.call_args.kwargs["input"] == {
|
|
32
|
+
"name": "app",
|
|
33
|
+
"namespace": None,
|
|
34
|
+
"flush_interval_ms": 500,
|
|
35
|
+
}
|
|
36
|
+
assert await client.get_database_settings(name="app") == settings
|
|
37
|
+
await client.flush_database(name="app")
|
|
38
|
+
assert room.invoke.call_args.kwargs["tool"] == "flush_database"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.55.0"
|
|
@@ -58,6 +58,7 @@ meshagent/api/services_test.py
|
|
|
58
58
|
meshagent/api/sql.py
|
|
59
59
|
meshagent/api/sql_test.py
|
|
60
60
|
meshagent/api/sqlite_batch_integration_test.py
|
|
61
|
+
meshagent/api/sqlite_replication_test.py
|
|
61
62
|
meshagent/api/sqlite_transfer.py
|
|
62
63
|
meshagent/api/sqlite_transfer_test.py
|
|
63
64
|
meshagent/api/storage_policy_test.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.54.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{meshagent_api-0.54.1 → meshagent_api-0.55.0}/meshagent/api/sqlite_batch_integration_test.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|