ankka 0.4.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.
Files changed (69) hide show
  1. ankka/__init__.py +18 -0
  2. ankka/_conformance.py +56 -0
  3. ankka/_proto/__init__.py +0 -0
  4. ankka/_proto/ankka/__init__.py +0 -0
  5. ankka/_proto/ankka/protocol/__init__.py +0 -0
  6. ankka/_proto/ankka/protocol/v1/__init__.py +0 -0
  7. ankka/_proto/ankka/protocol/v1/agent_pb2.py +59 -0
  8. ankka/_proto/ankka/protocol/v1/agent_pb2.pyi +118 -0
  9. ankka/_proto/ankka/protocol/v1/agent_pb2_grpc.py +183 -0
  10. ankka/_proto/ankka/protocol/v1/client_pb2.py +52 -0
  11. ankka/_proto/ankka/protocol/v1/client_pb2.pyi +84 -0
  12. ankka/_proto/ankka/protocol/v1/client_pb2_grpc.py +270 -0
  13. ankka/_proto/ankka/protocol/v1/consumer_pb2.py +43 -0
  14. ankka/_proto/ankka/protocol/v1/consumer_pb2.pyi +36 -0
  15. ankka/_proto/ankka/protocol/v1/consumer_pb2_grpc.py +97 -0
  16. ankka/_proto/ankka/protocol/v1/discovery_pb2.py +83 -0
  17. ankka/_proto/ankka/protocol/v1/discovery_pb2.pyi +232 -0
  18. ankka/_proto/ankka/protocol/v1/discovery_pb2_grpc.py +142 -0
  19. ankka/_proto/ankka/protocol/v1/endpoint_pb2.py +49 -0
  20. ankka/_proto/ankka/protocol/v1/endpoint_pb2.pyi +81 -0
  21. ankka/_proto/ankka/protocol/v1/endpoint_pb2_grpc.py +140 -0
  22. ankka/_proto/ankka/protocol/v1/event_sourced_pb2.py +51 -0
  23. ankka/_proto/ankka/protocol/v1/event_sourced_pb2.pyi +75 -0
  24. ankka/_proto/ankka/protocol/v1/event_sourced_pb2_grpc.py +97 -0
  25. ankka/_proto/ankka/protocol/v1/key_value_pb2.py +47 -0
  26. ankka/_proto/ankka/protocol/v1/key_value_pb2.pyi +54 -0
  27. ankka/_proto/ankka/protocol/v1/key_value_pb2_grpc.py +97 -0
  28. ankka/_proto/ankka/protocol/v1/payload_pb2.py +60 -0
  29. ankka/_proto/ankka/protocol/v1/payload_pb2.pyi +106 -0
  30. ankka/_proto/ankka/protocol/v1/payload_pb2_grpc.py +24 -0
  31. ankka/_proto/ankka/protocol/v1/timed_action_pb2.py +41 -0
  32. ankka/_proto/ankka/protocol/v1/timed_action_pb2.pyi +27 -0
  33. ankka/_proto/ankka/protocol/v1/timed_action_pb2_grpc.py +97 -0
  34. ankka/_proto/ankka/protocol/v1/view_pb2.py +41 -0
  35. ankka/_proto/ankka/protocol/v1/view_pb2.pyi +31 -0
  36. ankka/_proto/ankka/protocol/v1/view_pb2_grpc.py +97 -0
  37. ankka/_proto/ankka/protocol/v1/workflow_pb2.py +59 -0
  38. ankka/_proto/ankka/protocol/v1/workflow_pb2.pyi +106 -0
  39. ankka/_proto/ankka/protocol/v1/workflow_pb2_grpc.py +97 -0
  40. ankka/agent.py +200 -0
  41. ankka/client.py +257 -0
  42. ankka/codec.py +502 -0
  43. ankka/consumer.py +71 -0
  44. ankka/context.py +119 -0
  45. ankka/effects/__init__.py +1 -0
  46. ankka/effects/agent.py +99 -0
  47. ankka/effects/common.py +103 -0
  48. ankka/effects/consumer.py +40 -0
  49. ankka/effects/event_sourced.py +83 -0
  50. ankka/effects/key_value.py +66 -0
  51. ankka/effects/timed_action.py +28 -0
  52. ankka/effects/view.py +37 -0
  53. ankka/effects/workflow.py +149 -0
  54. ankka/endpoint.py +216 -0
  55. ankka/event_sourced_entity.py +217 -0
  56. ankka/key_value_entity.py +88 -0
  57. ankka/py.typed +0 -0
  58. ankka/server.py +635 -0
  59. ankka/service.py +128 -0
  60. ankka/testkit/__init__.py +31 -0
  61. ankka/testkit/integration.py +252 -0
  62. ankka/testkit/unit.py +555 -0
  63. ankka/timed_action.py +64 -0
  64. ankka/view.py +94 -0
  65. ankka/workflow.py +227 -0
  66. ankka-0.4.0.dist-info/METADATA +50 -0
  67. ankka-0.4.0.dist-info/RECORD +69 -0
  68. ankka-0.4.0.dist-info/WHEEL +4 -0
  69. ankka-0.4.0.dist-info/entry_points.txt +2 -0
ankka/__init__.py ADDED
@@ -0,0 +1,18 @@
1
+ """The ankka SDK for Python: components in Python, hosted by the ankka sidecar."""
2
+
3
+ __version__ = "0.4.0"
4
+
5
+ from ankka.codec import Codec, Done, DONE, json_codec # noqa: E402
6
+ from ankka.context import CommandContext, Metadata, Principal, RequestContext # noqa: E402
7
+ from ankka.effects.common import DeleteNow, Error, ErrorCode, ExpireAfter # noqa: E402
8
+ from ankka.effects.event_sourced import EventSourcedEffect, ReadOnlyEffect # noqa: E402
9
+ from ankka.endpoint import Acl, Endpoint, HttpProblem, delete, get, patch, post, put, sse # noqa: E402
10
+ from ankka.event_sourced_entity import EventSourcedEntity, RegistrationError, command, query # noqa: E402
11
+ from ankka.service import Ankka, ServiceBuilder # noqa: E402
12
+
13
+ __all__ = [
14
+ "Acl", "Ankka", "Codec", "CommandContext", "DeleteNow", "Done", "DONE", "Endpoint", "Error",
15
+ "ErrorCode", "EventSourcedEffect", "EventSourcedEntity", "ExpireAfter", "HttpProblem", "Metadata",
16
+ "Principal", "ReadOnlyEffect", "RegistrationError", "RequestContext", "ServiceBuilder",
17
+ "command", "delete", "get", "json_codec", "patch", "post", "put", "query", "sse",
18
+ ]
ankka/_conformance.py ADDED
@@ -0,0 +1,56 @@
1
+ """`uv run conformance`: serve the Python reference service and run the platform's conformance
2
+ suite against it, exiting with sbt's status. Needs Docker (the suite starts Postgres) and sbt on
3
+ PATH. The reference service is the SDK's example, so the SDK checkout is put on the path."""
4
+
5
+ from __future__ import annotations
6
+
7
+ import asyncio
8
+ import logging
9
+ import os
10
+ import subprocess
11
+ import sys
12
+ import threading
13
+ from pathlib import Path
14
+
15
+ SDK = Path(__file__).resolve().parents[2]
16
+ REPO = SDK.parent.parent
17
+ PORT = int(os.environ.get("ANKKA_PROCESS_PORT", "9010"))
18
+
19
+
20
+ def _serve(ready: threading.Event, stop: threading.Event) -> None:
21
+ sys.path.insert(0, str(SDK))
22
+ from examples.shopping_cart.conformance import reference_service
23
+
24
+ async def run() -> None:
25
+ server = reference_service().server()
26
+ await server.start("127.0.0.1", PORT)
27
+ ready.set()
28
+ while not stop.is_set():
29
+ await asyncio.sleep(0.2)
30
+ await server.stop(grace=1.0)
31
+
32
+ asyncio.run(run())
33
+
34
+
35
+ def main() -> int:
36
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s - %(message)s")
37
+ ready, stop = threading.Event(), threading.Event()
38
+ thread = threading.Thread(target=_serve, args=(ready, stop), daemon=True)
39
+ thread.start()
40
+ if not ready.wait(30):
41
+ print("the reference service did not start", file=sys.stderr)
42
+ return 1
43
+ command = [
44
+ "sbt",
45
+ f"-Dankka.conformance.target=127.0.0.1:{PORT}",
46
+ *(["-Dankka.benchmarks=on"] if os.environ.get("ANKKA_BENCHMARKS") else []),
47
+ "-Dankka.cluster.tests=off",
48
+ "-Dankka.template.tests=off",
49
+ "sidecar/testOnly *ConformanceSuite" + (f" -- {only}" if (only := os.environ.get("ANKKA_CONFORMANCE_ONLY")) else ""),
50
+ ]
51
+ print("running:", " ".join(command), "in", REPO, flush=True)
52
+ try:
53
+ return subprocess.run(command, cwd=REPO).returncode
54
+ finally:
55
+ stop.set()
56
+ thread.join(5)
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,59 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: ankka/protocol/v1/agent.proto
5
+ # Protobuf Python Version: 7.35.1
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 7,
15
+ 35,
16
+ 1,
17
+ '',
18
+ 'ankka/protocol/v1/agent.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+ from ankka._proto.ankka.protocol.v1 import payload_pb2 as ankka_dot_protocol_dot_v1_dot_payload__pb2
26
+
27
+
28
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1d\x61nkka/protocol/v1/agent.proto\x12\x11\x61nkka.protocol.v1\x1a\x1f\x61nkka/protocol/v1/payload.proto\"\xa1\x01\n\x0bPlanRequest\x12\x14\n\x0c\x63omponent_id\x18\x01 \x01(\t\x12\x12\n\nsession_id\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12+\n\x07payload\x18\x04 \x01(\x0b\x32\x1a.ankka.protocol.v1.Payload\x12-\n\x08metadata\x18\x05 \x01(\x0b\x32\x1b.ankka.protocol.v1.Metadata\"s\n\tPlanReply\x12,\n\x04plan\x18\x01 \x01(\x0b\x32\x1c.ankka.protocol.v1.AgentPlanH\x00\x12-\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32\x1a.ankka.protocol.v1.FailureH\x00\x42\t\n\x07message\"\x92\x04\n\tAgentPlan\x12\x12\n\x05model\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x13\n\x06system\x18\x02 \x01(\tH\x01\x88\x01\x01\x12\x11\n\x04user\x18\x03 \x01(\tH\x02\x88\x01\x01\x12\x0f\n\x07\x63ontext\x18\x04 \x03(\t\x12\x33\n\x06memory\x18\x05 \x01(\x0e\x32#.ankka.protocol.v1.AgentPlan.Memory\x12\r\n\x05tools\x18\x06 \x03(\t\x12\x42\n\x0eresponse_shape\x18\x07 \x01(\x0b\x32*.ankka.protocol.v1.AgentPlan.ResponseShape\x12\x12\n\nguardrails\x18\x08 \x03(\t\x12.\n\x07\x66\x61ilure\x18\t \x01(\x0b\x32\x18.ankka.protocol.v1.ErrorH\x03\x88\x01\x01\x1a\xa0\x01\n\rResponseShape\x12(\n\x04text\x18\x01 \x01(\x0b\x32\x18.ankka.protocol.v1.EmptyH\x00\x12?\n\x04json\x18\x02 \x01(\x0b\x32/.ankka.protocol.v1.AgentPlan.ResponseShape.JsonH\x00\x1a\x1b\n\x04Json\x12\x13\n\x0bschema_hint\x18\x01 \x01(\tB\x07\n\x05shape\"\x1f\n\x06Memory\x12\x0b\n\x07SESSION\x10\x00\x12\x08\n\x04NONE\x10\x01\x42\x08\n\x06_modelB\t\n\x07_systemB\x07\n\x05_userB\n\n\x08_failure\"]\n\x0bToolRequest\x12\x14\n\x0c\x63omponent_id\x18\x01 \x01(\t\x12\x12\n\nsession_id\x18\x02 \x01(\t\x12\x0c\n\x04tool\x18\x03 \x01(\t\x12\x16\n\x0e\x61rguments_json\x18\x04 \x01(\t\"5\n\nToolResult\x12\x0c\n\x02ok\x18\x01 \x01(\tH\x00\x12\x0f\n\x05\x65rror\x18\x02 \x01(\tH\x00\x42\x08\n\x06result\"\xb7\x01\n\x10GuardrailRequest\x12\x14\n\x0c\x63omponent_id\x18\x01 \x01(\t\x12\x12\n\nsession_id\x18\x02 \x01(\t\x12\x11\n\tguardrail\x18\x03 \x01(\t\x12\x38\n\x05stage\x18\x04 \x01(\x0e\x32).ankka.protocol.v1.GuardrailRequest.Stage\x12\x0c\n\x04text\x18\x05 \x01(\t\"\x1e\n\x05Stage\x12\t\n\x05INPUT\x10\x00\x12\n\n\x06OUTPUT\x10\x01\"V\n\x0fGuardrailResult\x12(\n\x04pass\x18\x01 \x01(\x0b\x32\x18.ankka.protocol.v1.EmptyH\x00\x12\x0f\n\x05\x62lock\x18\x02 \x01(\tH\x00\x42\x08\n\x06result2\xf5\x01\n\x05\x41gent\x12\x44\n\x04Plan\x12\x1e.ankka.protocol.v1.PlanRequest\x1a\x1c.ankka.protocol.v1.PlanReply\x12K\n\nInvokeTool\x12\x1e.ankka.protocol.v1.ToolRequest\x1a\x1d.ankka.protocol.v1.ToolResult\x12Y\n\x0e\x43heckGuardrail\x12#.ankka.protocol.v1.GuardrailRequest\x1a\".ankka.protocol.v1.GuardrailResultb\x06proto3')
29
+
30
+ _globals = globals()
31
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
32
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'ankka.protocol.v1.agent_pb2', _globals)
33
+ if not _descriptor._USE_C_DESCRIPTORS:
34
+ DESCRIPTOR._loaded_options = None
35
+ _globals['_PLANREQUEST']._serialized_start=86
36
+ _globals['_PLANREQUEST']._serialized_end=247
37
+ _globals['_PLANREPLY']._serialized_start=249
38
+ _globals['_PLANREPLY']._serialized_end=364
39
+ _globals['_AGENTPLAN']._serialized_start=367
40
+ _globals['_AGENTPLAN']._serialized_end=897
41
+ _globals['_AGENTPLAN_RESPONSESHAPE']._serialized_start=662
42
+ _globals['_AGENTPLAN_RESPONSESHAPE']._serialized_end=822
43
+ _globals['_AGENTPLAN_RESPONSESHAPE_JSON']._serialized_start=786
44
+ _globals['_AGENTPLAN_RESPONSESHAPE_JSON']._serialized_end=813
45
+ _globals['_AGENTPLAN_MEMORY']._serialized_start=824
46
+ _globals['_AGENTPLAN_MEMORY']._serialized_end=855
47
+ _globals['_TOOLREQUEST']._serialized_start=899
48
+ _globals['_TOOLREQUEST']._serialized_end=992
49
+ _globals['_TOOLRESULT']._serialized_start=994
50
+ _globals['_TOOLRESULT']._serialized_end=1047
51
+ _globals['_GUARDRAILREQUEST']._serialized_start=1050
52
+ _globals['_GUARDRAILREQUEST']._serialized_end=1233
53
+ _globals['_GUARDRAILREQUEST_STAGE']._serialized_start=1203
54
+ _globals['_GUARDRAILREQUEST_STAGE']._serialized_end=1233
55
+ _globals['_GUARDRAILRESULT']._serialized_start=1235
56
+ _globals['_GUARDRAILRESULT']._serialized_end=1321
57
+ _globals['_AGENT']._serialized_start=1324
58
+ _globals['_AGENT']._serialized_end=1569
59
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,118 @@
1
+ from ankka._proto.ankka.protocol.v1 import payload_pb2 as _payload_pb2
2
+ from google.protobuf.internal import containers as _containers
3
+ from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
4
+ from google.protobuf import descriptor as _descriptor
5
+ from google.protobuf import message as _message
6
+ from collections.abc import Iterable as _Iterable, Mapping as _Mapping
7
+ from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union
8
+
9
+ DESCRIPTOR: _descriptor.FileDescriptor
10
+
11
+ class PlanRequest(_message.Message):
12
+ __slots__ = ("component_id", "session_id", "name", "payload", "metadata")
13
+ COMPONENT_ID_FIELD_NUMBER: _ClassVar[int]
14
+ SESSION_ID_FIELD_NUMBER: _ClassVar[int]
15
+ NAME_FIELD_NUMBER: _ClassVar[int]
16
+ PAYLOAD_FIELD_NUMBER: _ClassVar[int]
17
+ METADATA_FIELD_NUMBER: _ClassVar[int]
18
+ component_id: str
19
+ session_id: str
20
+ name: str
21
+ payload: _payload_pb2.Payload
22
+ metadata: _payload_pb2.Metadata
23
+ def __init__(self, component_id: _Optional[str] = ..., session_id: _Optional[str] = ..., name: _Optional[str] = ..., payload: _Optional[_Union[_payload_pb2.Payload, _Mapping]] = ..., metadata: _Optional[_Union[_payload_pb2.Metadata, _Mapping]] = ...) -> None: ...
24
+
25
+ class PlanReply(_message.Message):
26
+ __slots__ = ("plan", "failure")
27
+ PLAN_FIELD_NUMBER: _ClassVar[int]
28
+ FAILURE_FIELD_NUMBER: _ClassVar[int]
29
+ plan: AgentPlan
30
+ failure: _payload_pb2.Failure
31
+ def __init__(self, plan: _Optional[_Union[AgentPlan, _Mapping]] = ..., failure: _Optional[_Union[_payload_pb2.Failure, _Mapping]] = ...) -> None: ...
32
+
33
+ class AgentPlan(_message.Message):
34
+ __slots__ = ("model", "system", "user", "context", "memory", "tools", "response_shape", "guardrails", "failure")
35
+ class Memory(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
36
+ __slots__ = ()
37
+ SESSION: _ClassVar[AgentPlan.Memory]
38
+ NONE: _ClassVar[AgentPlan.Memory]
39
+ SESSION: AgentPlan.Memory
40
+ NONE: AgentPlan.Memory
41
+ class ResponseShape(_message.Message):
42
+ __slots__ = ("text", "json")
43
+ class Json(_message.Message):
44
+ __slots__ = ("schema_hint",)
45
+ SCHEMA_HINT_FIELD_NUMBER: _ClassVar[int]
46
+ schema_hint: str
47
+ def __init__(self, schema_hint: _Optional[str] = ...) -> None: ...
48
+ TEXT_FIELD_NUMBER: _ClassVar[int]
49
+ JSON_FIELD_NUMBER: _ClassVar[int]
50
+ text: _payload_pb2.Empty
51
+ json: AgentPlan.ResponseShape.Json
52
+ def __init__(self, text: _Optional[_Union[_payload_pb2.Empty, _Mapping]] = ..., json: _Optional[_Union[AgentPlan.ResponseShape.Json, _Mapping]] = ...) -> None: ...
53
+ MODEL_FIELD_NUMBER: _ClassVar[int]
54
+ SYSTEM_FIELD_NUMBER: _ClassVar[int]
55
+ USER_FIELD_NUMBER: _ClassVar[int]
56
+ CONTEXT_FIELD_NUMBER: _ClassVar[int]
57
+ MEMORY_FIELD_NUMBER: _ClassVar[int]
58
+ TOOLS_FIELD_NUMBER: _ClassVar[int]
59
+ RESPONSE_SHAPE_FIELD_NUMBER: _ClassVar[int]
60
+ GUARDRAILS_FIELD_NUMBER: _ClassVar[int]
61
+ FAILURE_FIELD_NUMBER: _ClassVar[int]
62
+ model: str
63
+ system: str
64
+ user: str
65
+ context: _containers.RepeatedScalarFieldContainer[str]
66
+ memory: AgentPlan.Memory
67
+ tools: _containers.RepeatedScalarFieldContainer[str]
68
+ response_shape: AgentPlan.ResponseShape
69
+ guardrails: _containers.RepeatedScalarFieldContainer[str]
70
+ failure: _payload_pb2.Error
71
+ def __init__(self, model: _Optional[str] = ..., system: _Optional[str] = ..., user: _Optional[str] = ..., context: _Optional[_Iterable[str]] = ..., memory: _Optional[_Union[AgentPlan.Memory, str]] = ..., tools: _Optional[_Iterable[str]] = ..., response_shape: _Optional[_Union[AgentPlan.ResponseShape, _Mapping]] = ..., guardrails: _Optional[_Iterable[str]] = ..., failure: _Optional[_Union[_payload_pb2.Error, _Mapping]] = ...) -> None: ...
72
+
73
+ class ToolRequest(_message.Message):
74
+ __slots__ = ("component_id", "session_id", "tool", "arguments_json")
75
+ COMPONENT_ID_FIELD_NUMBER: _ClassVar[int]
76
+ SESSION_ID_FIELD_NUMBER: _ClassVar[int]
77
+ TOOL_FIELD_NUMBER: _ClassVar[int]
78
+ ARGUMENTS_JSON_FIELD_NUMBER: _ClassVar[int]
79
+ component_id: str
80
+ session_id: str
81
+ tool: str
82
+ arguments_json: str
83
+ def __init__(self, component_id: _Optional[str] = ..., session_id: _Optional[str] = ..., tool: _Optional[str] = ..., arguments_json: _Optional[str] = ...) -> None: ...
84
+
85
+ class ToolResult(_message.Message):
86
+ __slots__ = ("ok", "error")
87
+ OK_FIELD_NUMBER: _ClassVar[int]
88
+ ERROR_FIELD_NUMBER: _ClassVar[int]
89
+ ok: str
90
+ error: str
91
+ def __init__(self, ok: _Optional[str] = ..., error: _Optional[str] = ...) -> None: ...
92
+
93
+ class GuardrailRequest(_message.Message):
94
+ __slots__ = ("component_id", "session_id", "guardrail", "stage", "text")
95
+ class Stage(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
96
+ __slots__ = ()
97
+ INPUT: _ClassVar[GuardrailRequest.Stage]
98
+ OUTPUT: _ClassVar[GuardrailRequest.Stage]
99
+ INPUT: GuardrailRequest.Stage
100
+ OUTPUT: GuardrailRequest.Stage
101
+ COMPONENT_ID_FIELD_NUMBER: _ClassVar[int]
102
+ SESSION_ID_FIELD_NUMBER: _ClassVar[int]
103
+ GUARDRAIL_FIELD_NUMBER: _ClassVar[int]
104
+ STAGE_FIELD_NUMBER: _ClassVar[int]
105
+ TEXT_FIELD_NUMBER: _ClassVar[int]
106
+ component_id: str
107
+ session_id: str
108
+ guardrail: str
109
+ stage: GuardrailRequest.Stage
110
+ text: str
111
+ def __init__(self, component_id: _Optional[str] = ..., session_id: _Optional[str] = ..., guardrail: _Optional[str] = ..., stage: _Optional[_Union[GuardrailRequest.Stage, str]] = ..., text: _Optional[str] = ...) -> None: ...
112
+
113
+ class GuardrailResult(_message.Message):
114
+ __slots__ = ("block",)
115
+ PASS_FIELD_NUMBER: _ClassVar[int]
116
+ BLOCK_FIELD_NUMBER: _ClassVar[int]
117
+ block: str
118
+ def __init__(self, block: _Optional[str] = ..., **kwargs) -> None: ...
@@ -0,0 +1,183 @@
1
+ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2
+ """Client and server classes corresponding to protobuf-defined services."""
3
+ import grpc
4
+ import warnings
5
+
6
+ from ankka._proto.ankka.protocol.v1 import agent_pb2 as ankka_dot_protocol_dot_v1_dot_agent__pb2
7
+
8
+ GRPC_GENERATED_VERSION = '1.84.0'
9
+ GRPC_VERSION = grpc.__version__
10
+ _version_not_supported = False
11
+
12
+ try:
13
+ from grpc._utilities import first_version_is_lower
14
+ _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
15
+ except ImportError:
16
+ _version_not_supported = True
17
+
18
+ if _version_not_supported:
19
+ raise RuntimeError(
20
+ f'The grpc package installed is at version {GRPC_VERSION},'
21
+ + ' but the generated code in ankka/protocol/v1/agent_pb2_grpc.py depends on'
22
+ + f' grpcio>={GRPC_GENERATED_VERSION}.'
23
+ + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
24
+ + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
25
+ )
26
+
27
+
28
+ class AgentStub:
29
+ """Missing associated documentation comment in .proto file."""
30
+
31
+ def __init__(self, channel):
32
+ """Constructor.
33
+
34
+ Args:
35
+ channel: A grpc.Channel.
36
+ """
37
+ self.Plan = channel.unary_unary(
38
+ '/ankka.protocol.v1.Agent/Plan',
39
+ request_serializer=ankka_dot_protocol_dot_v1_dot_agent__pb2.PlanRequest.SerializeToString,
40
+ response_deserializer=ankka_dot_protocol_dot_v1_dot_agent__pb2.PlanReply.FromString,
41
+ _registered_method=True)
42
+ self.InvokeTool = channel.unary_unary(
43
+ '/ankka.protocol.v1.Agent/InvokeTool',
44
+ request_serializer=ankka_dot_protocol_dot_v1_dot_agent__pb2.ToolRequest.SerializeToString,
45
+ response_deserializer=ankka_dot_protocol_dot_v1_dot_agent__pb2.ToolResult.FromString,
46
+ _registered_method=True)
47
+ self.CheckGuardrail = channel.unary_unary(
48
+ '/ankka.protocol.v1.Agent/CheckGuardrail',
49
+ request_serializer=ankka_dot_protocol_dot_v1_dot_agent__pb2.GuardrailRequest.SerializeToString,
50
+ response_deserializer=ankka_dot_protocol_dot_v1_dot_agent__pb2.GuardrailResult.FromString,
51
+ _registered_method=True)
52
+
53
+
54
+ class AgentServicer:
55
+ """Missing associated documentation comment in .proto file."""
56
+
57
+ def Plan(self, request, context):
58
+ """Missing associated documentation comment in .proto file."""
59
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
60
+ context.set_details('Method not implemented!')
61
+ raise NotImplementedError('Method not implemented!')
62
+
63
+ def InvokeTool(self, request, context):
64
+ """Missing associated documentation comment in .proto file."""
65
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
66
+ context.set_details('Method not implemented!')
67
+ raise NotImplementedError('Method not implemented!')
68
+
69
+ def CheckGuardrail(self, request, context):
70
+ """Missing associated documentation comment in .proto file."""
71
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
72
+ context.set_details('Method not implemented!')
73
+ raise NotImplementedError('Method not implemented!')
74
+
75
+
76
+ def add_AgentServicer_to_server(servicer, server):
77
+ rpc_method_handlers = {
78
+ 'Plan': grpc.unary_unary_rpc_method_handler(
79
+ servicer.Plan,
80
+ request_deserializer=ankka_dot_protocol_dot_v1_dot_agent__pb2.PlanRequest.FromString,
81
+ response_serializer=ankka_dot_protocol_dot_v1_dot_agent__pb2.PlanReply.SerializeToString,
82
+ ),
83
+ 'InvokeTool': grpc.unary_unary_rpc_method_handler(
84
+ servicer.InvokeTool,
85
+ request_deserializer=ankka_dot_protocol_dot_v1_dot_agent__pb2.ToolRequest.FromString,
86
+ response_serializer=ankka_dot_protocol_dot_v1_dot_agent__pb2.ToolResult.SerializeToString,
87
+ ),
88
+ 'CheckGuardrail': grpc.unary_unary_rpc_method_handler(
89
+ servicer.CheckGuardrail,
90
+ request_deserializer=ankka_dot_protocol_dot_v1_dot_agent__pb2.GuardrailRequest.FromString,
91
+ response_serializer=ankka_dot_protocol_dot_v1_dot_agent__pb2.GuardrailResult.SerializeToString,
92
+ ),
93
+ }
94
+ generic_handler = grpc.method_handlers_generic_handler(
95
+ 'ankka.protocol.v1.Agent', rpc_method_handlers)
96
+ server.add_generic_rpc_handlers((generic_handler,))
97
+ server.add_registered_method_handlers('ankka.protocol.v1.Agent', rpc_method_handlers)
98
+
99
+
100
+ # This class is part of an EXPERIMENTAL API.
101
+ class Agent:
102
+ """Missing associated documentation comment in .proto file."""
103
+
104
+ @staticmethod
105
+ def Plan(request,
106
+ target,
107
+ options=(),
108
+ channel_credentials=None,
109
+ call_credentials=None,
110
+ insecure=False,
111
+ compression=None,
112
+ wait_for_ready=None,
113
+ timeout=None,
114
+ metadata=None):
115
+ return grpc.experimental.unary_unary(
116
+ request,
117
+ target,
118
+ '/ankka.protocol.v1.Agent/Plan',
119
+ ankka_dot_protocol_dot_v1_dot_agent__pb2.PlanRequest.SerializeToString,
120
+ ankka_dot_protocol_dot_v1_dot_agent__pb2.PlanReply.FromString,
121
+ options,
122
+ channel_credentials,
123
+ insecure,
124
+ call_credentials,
125
+ compression,
126
+ wait_for_ready,
127
+ timeout,
128
+ metadata,
129
+ _registered_method=True)
130
+
131
+ @staticmethod
132
+ def InvokeTool(request,
133
+ target,
134
+ options=(),
135
+ channel_credentials=None,
136
+ call_credentials=None,
137
+ insecure=False,
138
+ compression=None,
139
+ wait_for_ready=None,
140
+ timeout=None,
141
+ metadata=None):
142
+ return grpc.experimental.unary_unary(
143
+ request,
144
+ target,
145
+ '/ankka.protocol.v1.Agent/InvokeTool',
146
+ ankka_dot_protocol_dot_v1_dot_agent__pb2.ToolRequest.SerializeToString,
147
+ ankka_dot_protocol_dot_v1_dot_agent__pb2.ToolResult.FromString,
148
+ options,
149
+ channel_credentials,
150
+ insecure,
151
+ call_credentials,
152
+ compression,
153
+ wait_for_ready,
154
+ timeout,
155
+ metadata,
156
+ _registered_method=True)
157
+
158
+ @staticmethod
159
+ def CheckGuardrail(request,
160
+ target,
161
+ options=(),
162
+ channel_credentials=None,
163
+ call_credentials=None,
164
+ insecure=False,
165
+ compression=None,
166
+ wait_for_ready=None,
167
+ timeout=None,
168
+ metadata=None):
169
+ return grpc.experimental.unary_unary(
170
+ request,
171
+ target,
172
+ '/ankka.protocol.v1.Agent/CheckGuardrail',
173
+ ankka_dot_protocol_dot_v1_dot_agent__pb2.GuardrailRequest.SerializeToString,
174
+ ankka_dot_protocol_dot_v1_dot_agent__pb2.GuardrailResult.FromString,
175
+ options,
176
+ channel_credentials,
177
+ insecure,
178
+ call_credentials,
179
+ compression,
180
+ wait_for_ready,
181
+ timeout,
182
+ metadata,
183
+ _registered_method=True)
@@ -0,0 +1,52 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: ankka/protocol/v1/client.proto
5
+ # Protobuf Python Version: 7.35.1
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 7,
15
+ 35,
16
+ 1,
17
+ '',
18
+ 'ankka/protocol/v1/client.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+ from ankka._proto.ankka.protocol.v1 import payload_pb2 as ankka_dot_protocol_dot_v1_dot_payload__pb2
26
+ from ankka._proto.ankka.protocol.v1 import discovery_pb2 as ankka_dot_protocol_dot_v1_dot_discovery__pb2
27
+
28
+
29
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1e\x61nkka/protocol/v1/client.proto\x12\x11\x61nkka.protocol.v1\x1a\x1f\x61nkka/protocol/v1/payload.proto\x1a!ankka/protocol/v1/discovery.proto\"\xc9\x01\n\rInvokeRequest\x12%\n\x04kind\x18\x01 \x01(\x0e\x32\x17.ankka.protocol.v1.Kind\x12\x14\n\x0c\x63omponent_id\x18\x02 \x01(\t\x12\x11\n\tentity_id\x18\x03 \x01(\t\x12\x0c\n\x04name\x18\x04 \x01(\t\x12+\n\x07payload\x18\x05 \x01(\x0b\x32\x1a.ankka.protocol.v1.Payload\x12-\n\x08metadata\x18\x06 \x01(\x0b\x32\x1b.ankka.protocol.v1.Metadata\"u\n\x0bInvokeReply\x12\x31\n\x05reply\x18\x01 \x01(\x0b\x32 .ankka.protocol.v1.Outcome.ReplyH\x00\x12)\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x18.ankka.protocol.v1.ErrorH\x00\x42\x08\n\x06result\"\x81\x01\n\x0bStreamToken\x12\x0e\n\x04text\x18\x01 \x01(\tH\x00\x12-\n\tcompleted\x18\x02 \x01(\x0b\x32\x18.ankka.protocol.v1.EmptyH\x00\x12*\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32\x18.ankka.protocol.v1.ErrorH\x00\x42\x07\n\x05token\"Z\n\x0cQueryRequest\x12\x0f\n\x07view_id\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12+\n\x07payload\x18\x03 \x01(\x0b\x32\x1a.ankka.protocol.v1.Payload\"m\n\nQueryReply\x12*\n\x04rows\x18\x01 \x01(\x0b\x32\x1a.ankka.protocol.v1.PayloadH\x00\x12)\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x18.ankka.protocol.v1.ErrorH\x00\x42\x08\n\x06result\"\xd7\x01\n\x0fScheduleRequest\x12\x10\n\x08timer_id\x18\x01 \x01(\t\x12\x14\n\x0c\x64\x65lay_millis\x18\x02 \x01(\x03\x12%\n\x04kind\x18\x03 \x01(\x0e\x32\x17.ankka.protocol.v1.Kind\x12\x14\n\x0c\x63omponent_id\x18\x04 \x01(\t\x12\x16\n\tentity_id\x18\x05 \x01(\tH\x00\x88\x01\x01\x12\x0c\n\x04name\x18\x06 \x01(\t\x12+\n\x07payload\x18\x07 \x01(\x0b\x32\x1a.ankka.protocol.v1.PayloadB\x0c\n\n_entity_id\"!\n\rCancelRequest\x12\x10\n\x08timer_id\x18\x01 \x01(\t2\x81\x03\n\x06\x43lient\x12J\n\x06Invoke\x12 .ankka.protocol.v1.InvokeRequest\x1a\x1e.ankka.protocol.v1.InvokeReply\x12R\n\x0cInvokeStream\x12 .ankka.protocol.v1.InvokeRequest\x1a\x1e.ankka.protocol.v1.StreamToken0\x01\x12G\n\x05Query\x12\x1f.ankka.protocol.v1.QueryRequest\x1a\x1d.ankka.protocol.v1.QueryReply\x12H\n\x08Schedule\x12\".ankka.protocol.v1.ScheduleRequest\x1a\x18.ankka.protocol.v1.Empty\x12\x44\n\x06\x43\x61ncel\x12 .ankka.protocol.v1.CancelRequest\x1a\x18.ankka.protocol.v1.Emptyb\x06proto3')
30
+
31
+ _globals = globals()
32
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
33
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'ankka.protocol.v1.client_pb2', _globals)
34
+ if not _descriptor._USE_C_DESCRIPTORS:
35
+ DESCRIPTOR._loaded_options = None
36
+ _globals['_INVOKEREQUEST']._serialized_start=122
37
+ _globals['_INVOKEREQUEST']._serialized_end=323
38
+ _globals['_INVOKEREPLY']._serialized_start=325
39
+ _globals['_INVOKEREPLY']._serialized_end=442
40
+ _globals['_STREAMTOKEN']._serialized_start=445
41
+ _globals['_STREAMTOKEN']._serialized_end=574
42
+ _globals['_QUERYREQUEST']._serialized_start=576
43
+ _globals['_QUERYREQUEST']._serialized_end=666
44
+ _globals['_QUERYREPLY']._serialized_start=668
45
+ _globals['_QUERYREPLY']._serialized_end=777
46
+ _globals['_SCHEDULEREQUEST']._serialized_start=780
47
+ _globals['_SCHEDULEREQUEST']._serialized_end=995
48
+ _globals['_CANCELREQUEST']._serialized_start=997
49
+ _globals['_CANCELREQUEST']._serialized_end=1030
50
+ _globals['_CLIENT']._serialized_start=1033
51
+ _globals['_CLIENT']._serialized_end=1418
52
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,84 @@
1
+ from ankka._proto.ankka.protocol.v1 import payload_pb2 as _payload_pb2
2
+ from ankka._proto.ankka.protocol.v1 import discovery_pb2 as _discovery_pb2
3
+ from google.protobuf import descriptor as _descriptor
4
+ from google.protobuf import message as _message
5
+ from collections.abc import Mapping as _Mapping
6
+ from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union
7
+
8
+ DESCRIPTOR: _descriptor.FileDescriptor
9
+
10
+ class InvokeRequest(_message.Message):
11
+ __slots__ = ("kind", "component_id", "entity_id", "name", "payload", "metadata")
12
+ KIND_FIELD_NUMBER: _ClassVar[int]
13
+ COMPONENT_ID_FIELD_NUMBER: _ClassVar[int]
14
+ ENTITY_ID_FIELD_NUMBER: _ClassVar[int]
15
+ NAME_FIELD_NUMBER: _ClassVar[int]
16
+ PAYLOAD_FIELD_NUMBER: _ClassVar[int]
17
+ METADATA_FIELD_NUMBER: _ClassVar[int]
18
+ kind: _discovery_pb2.Kind
19
+ component_id: str
20
+ entity_id: str
21
+ name: str
22
+ payload: _payload_pb2.Payload
23
+ metadata: _payload_pb2.Metadata
24
+ def __init__(self, kind: _Optional[_Union[_discovery_pb2.Kind, str]] = ..., component_id: _Optional[str] = ..., entity_id: _Optional[str] = ..., name: _Optional[str] = ..., payload: _Optional[_Union[_payload_pb2.Payload, _Mapping]] = ..., metadata: _Optional[_Union[_payload_pb2.Metadata, _Mapping]] = ...) -> None: ...
25
+
26
+ class InvokeReply(_message.Message):
27
+ __slots__ = ("reply", "error")
28
+ REPLY_FIELD_NUMBER: _ClassVar[int]
29
+ ERROR_FIELD_NUMBER: _ClassVar[int]
30
+ reply: _payload_pb2.Outcome.Reply
31
+ error: _payload_pb2.Error
32
+ def __init__(self, reply: _Optional[_Union[_payload_pb2.Outcome.Reply, _Mapping]] = ..., error: _Optional[_Union[_payload_pb2.Error, _Mapping]] = ...) -> None: ...
33
+
34
+ class StreamToken(_message.Message):
35
+ __slots__ = ("text", "completed", "failed")
36
+ TEXT_FIELD_NUMBER: _ClassVar[int]
37
+ COMPLETED_FIELD_NUMBER: _ClassVar[int]
38
+ FAILED_FIELD_NUMBER: _ClassVar[int]
39
+ text: str
40
+ completed: _payload_pb2.Empty
41
+ failed: _payload_pb2.Error
42
+ def __init__(self, text: _Optional[str] = ..., completed: _Optional[_Union[_payload_pb2.Empty, _Mapping]] = ..., failed: _Optional[_Union[_payload_pb2.Error, _Mapping]] = ...) -> None: ...
43
+
44
+ class QueryRequest(_message.Message):
45
+ __slots__ = ("view_id", "name", "payload")
46
+ VIEW_ID_FIELD_NUMBER: _ClassVar[int]
47
+ NAME_FIELD_NUMBER: _ClassVar[int]
48
+ PAYLOAD_FIELD_NUMBER: _ClassVar[int]
49
+ view_id: str
50
+ name: str
51
+ payload: _payload_pb2.Payload
52
+ def __init__(self, view_id: _Optional[str] = ..., name: _Optional[str] = ..., payload: _Optional[_Union[_payload_pb2.Payload, _Mapping]] = ...) -> None: ...
53
+
54
+ class QueryReply(_message.Message):
55
+ __slots__ = ("rows", "error")
56
+ ROWS_FIELD_NUMBER: _ClassVar[int]
57
+ ERROR_FIELD_NUMBER: _ClassVar[int]
58
+ rows: _payload_pb2.Payload
59
+ error: _payload_pb2.Error
60
+ def __init__(self, rows: _Optional[_Union[_payload_pb2.Payload, _Mapping]] = ..., error: _Optional[_Union[_payload_pb2.Error, _Mapping]] = ...) -> None: ...
61
+
62
+ class ScheduleRequest(_message.Message):
63
+ __slots__ = ("timer_id", "delay_millis", "kind", "component_id", "entity_id", "name", "payload")
64
+ TIMER_ID_FIELD_NUMBER: _ClassVar[int]
65
+ DELAY_MILLIS_FIELD_NUMBER: _ClassVar[int]
66
+ KIND_FIELD_NUMBER: _ClassVar[int]
67
+ COMPONENT_ID_FIELD_NUMBER: _ClassVar[int]
68
+ ENTITY_ID_FIELD_NUMBER: _ClassVar[int]
69
+ NAME_FIELD_NUMBER: _ClassVar[int]
70
+ PAYLOAD_FIELD_NUMBER: _ClassVar[int]
71
+ timer_id: str
72
+ delay_millis: int
73
+ kind: _discovery_pb2.Kind
74
+ component_id: str
75
+ entity_id: str
76
+ name: str
77
+ payload: _payload_pb2.Payload
78
+ def __init__(self, timer_id: _Optional[str] = ..., delay_millis: _Optional[int] = ..., kind: _Optional[_Union[_discovery_pb2.Kind, str]] = ..., component_id: _Optional[str] = ..., entity_id: _Optional[str] = ..., name: _Optional[str] = ..., payload: _Optional[_Union[_payload_pb2.Payload, _Mapping]] = ...) -> None: ...
79
+
80
+ class CancelRequest(_message.Message):
81
+ __slots__ = ("timer_id",)
82
+ TIMER_ID_FIELD_NUMBER: _ClassVar[int]
83
+ timer_id: str
84
+ def __init__(self, timer_id: _Optional[str] = ...) -> None: ...