afm-cli 0.1.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.
- afm_cli-0.1.0/PKG-INFO +27 -0
- afm_cli-0.1.0/README.md +0 -0
- afm_cli-0.1.0/pyproject.toml +51 -0
- afm_cli-0.1.0/src/afm_cli/__init__.py +221 -0
- afm_cli-0.1.0/src/afm_cli/agent.py +586 -0
- afm_cli-0.1.0/src/afm_cli/cli.py +588 -0
- afm_cli-0.1.0/src/afm_cli/exceptions.py +155 -0
- afm_cli-0.1.0/src/afm_cli/interfaces/__init__.py +108 -0
- afm_cli-0.1.0/src/afm_cli/interfaces/base.py +166 -0
- afm_cli-0.1.0/src/afm_cli/interfaces/console_chat.py +217 -0
- afm_cli-0.1.0/src/afm_cli/interfaces/console_chat.tcss +105 -0
- afm_cli-0.1.0/src/afm_cli/interfaces/web_chat.py +417 -0
- afm_cli-0.1.0/src/afm_cli/interfaces/webhook.py +659 -0
- afm_cli-0.1.0/src/afm_cli/models.py +378 -0
- afm_cli-0.1.0/src/afm_cli/parser.py +250 -0
- afm_cli-0.1.0/src/afm_cli/providers.py +203 -0
- afm_cli-0.1.0/src/afm_cli/resources/chat-ui.html +251 -0
- afm_cli-0.1.0/src/afm_cli/schema_validator.py +183 -0
- afm_cli-0.1.0/src/afm_cli/templates.py +395 -0
- afm_cli-0.1.0/src/afm_cli/tools/__init__.py +22 -0
- afm_cli-0.1.0/src/afm_cli/tools/mcp.py +439 -0
- afm_cli-0.1.0/src/afm_cli/variables.py +317 -0
afm_cli-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: afm-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AFM (Agent-Flavored Markdown) interpreter using LangChain
|
|
5
|
+
Author: Radith Samarakoon
|
|
6
|
+
Author-email: Radith Samarakoon <jjeli1234@gmail.com>
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Requires-Dist: langchain>=1.2.8
|
|
12
|
+
Requires-Dist: pyyaml>=6.0
|
|
13
|
+
Requires-Dist: pydantic>=2.0
|
|
14
|
+
Requires-Dist: langchain-openai>=1.1.7
|
|
15
|
+
Requires-Dist: langchain-anthropic>=1.3.1
|
|
16
|
+
Requires-Dist: jsonschema>=4.26.0
|
|
17
|
+
Requires-Dist: fastapi>=0.128.1
|
|
18
|
+
Requires-Dist: httpx>=0.28.1
|
|
19
|
+
Requires-Dist: uvicorn>=0.40.0
|
|
20
|
+
Requires-Dist: mcp>=1.26.0
|
|
21
|
+
Requires-Dist: langchain-mcp-adapters>=0.2.1
|
|
22
|
+
Requires-Dist: click>=8.0.0
|
|
23
|
+
Requires-Dist: textual>=2.1.0
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Project-URL: Repository, https://github.com/RadCod3/reference-implementations-afm
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
afm_cli-0.1.0/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "afm-cli"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "AFM (Agent-Flavored Markdown) interpreter using LangChain"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [{ name = "Radith Samarakoon", email = "jjeli1234@gmail.com" }]
|
|
7
|
+
classifiers = [
|
|
8
|
+
"Development Status :: 3 - Alpha",
|
|
9
|
+
"Intended Audience :: Developers",
|
|
10
|
+
"License :: OSI Approved :: Apache Software License",
|
|
11
|
+
"Programming Language :: Python :: 3.11",
|
|
12
|
+
]
|
|
13
|
+
requires-python = ">=3.11"
|
|
14
|
+
urls = { Repository = "https://github.com/RadCod3/reference-implementations-afm" }
|
|
15
|
+
dependencies = [
|
|
16
|
+
"langchain>=1.2.8",
|
|
17
|
+
"pyyaml>=6.0",
|
|
18
|
+
"pydantic>=2.0",
|
|
19
|
+
"langchain-openai>=1.1.7",
|
|
20
|
+
"langchain-anthropic>=1.3.1",
|
|
21
|
+
"jsonschema>=4.26.0",
|
|
22
|
+
"fastapi>=0.128.1",
|
|
23
|
+
"httpx>=0.28.1",
|
|
24
|
+
"uvicorn>=0.40.0",
|
|
25
|
+
"mcp>=1.26.0",
|
|
26
|
+
"langchain-mcp-adapters>=0.2.1",
|
|
27
|
+
"click>=8.0.0",
|
|
28
|
+
"textual>=2.1.0",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.scripts]
|
|
32
|
+
afm = "afm_cli.cli:main"
|
|
33
|
+
|
|
34
|
+
[build-system]
|
|
35
|
+
requires = ["uv_build>=0.9.28,<0.10.0"]
|
|
36
|
+
build-backend = "uv_build"
|
|
37
|
+
|
|
38
|
+
[tool.pytest.ini_options]
|
|
39
|
+
testpaths = ["tests"]
|
|
40
|
+
pythonpath = ["src"]
|
|
41
|
+
asyncio_mode = "auto"
|
|
42
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
43
|
+
|
|
44
|
+
[dependency-groups]
|
|
45
|
+
dev = [
|
|
46
|
+
"ruff>=0.15.0",
|
|
47
|
+
"pytest>=8.0",
|
|
48
|
+
"pytest-cov>=7.0.0",
|
|
49
|
+
"pytest-asyncio>=1.3.0",
|
|
50
|
+
"textual-dev>=1.7.0",
|
|
51
|
+
]
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Copyright (c) 2025
|
|
2
|
+
# Licensed under the Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
"""LangChain AFM Interpreter.
|
|
5
|
+
|
|
6
|
+
A Python implementation of the AFM (Agent-Flavored Markdown) specification v0.3.0.
|
|
7
|
+
|
|
8
|
+
This package provides:
|
|
9
|
+
|
|
10
|
+
- **Parser**: Parse AFM files into structured Python objects
|
|
11
|
+
- **Agent**: Execute agents using LangChain
|
|
12
|
+
- **Interfaces**: Console chat, web chat, and webhook handlers
|
|
13
|
+
|
|
14
|
+
Example usage::
|
|
15
|
+
|
|
16
|
+
from afm_cli import parse_afm_file, Agent
|
|
17
|
+
from afm_cli.interfaces import run_console_chat
|
|
18
|
+
|
|
19
|
+
afm = parse_afm_file("my_agent.afm.md")
|
|
20
|
+
agent = Agent(afm)
|
|
21
|
+
run_console_chat(agent)
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from .agent import Agent
|
|
25
|
+
from .exceptions import (
|
|
26
|
+
AFMError,
|
|
27
|
+
AFMParseError,
|
|
28
|
+
AFMValidationError,
|
|
29
|
+
AgentConfigError,
|
|
30
|
+
AgentError,
|
|
31
|
+
InputValidationError,
|
|
32
|
+
InterfaceNotFoundError,
|
|
33
|
+
JSONAccessError,
|
|
34
|
+
MCPAuthenticationError,
|
|
35
|
+
MCPConnectionError,
|
|
36
|
+
MCPError,
|
|
37
|
+
MCPToolError,
|
|
38
|
+
OutputValidationError,
|
|
39
|
+
ProviderError,
|
|
40
|
+
TemplateCompilationError,
|
|
41
|
+
TemplateError,
|
|
42
|
+
TemplateEvaluationError,
|
|
43
|
+
VariableResolutionError,
|
|
44
|
+
)
|
|
45
|
+
from .interfaces import (
|
|
46
|
+
WebSubSubscriber,
|
|
47
|
+
ChatApp,
|
|
48
|
+
async_run_console_chat,
|
|
49
|
+
create_webchat_app,
|
|
50
|
+
create_webhook_app,
|
|
51
|
+
get_console_interface,
|
|
52
|
+
get_http_path,
|
|
53
|
+
get_interface_by_type,
|
|
54
|
+
get_interfaces,
|
|
55
|
+
get_primary_interface,
|
|
56
|
+
get_webchat_interface,
|
|
57
|
+
get_webhook_interface,
|
|
58
|
+
has_interface_type,
|
|
59
|
+
run_console_chat,
|
|
60
|
+
run_webchat_server,
|
|
61
|
+
run_webhook_server,
|
|
62
|
+
verify_webhook_signature,
|
|
63
|
+
)
|
|
64
|
+
from .models import (
|
|
65
|
+
AFMRecord,
|
|
66
|
+
AgentMetadata,
|
|
67
|
+
ClientAuthentication,
|
|
68
|
+
CompiledTemplate,
|
|
69
|
+
ConsoleChatInterface,
|
|
70
|
+
Exposure,
|
|
71
|
+
HeaderVariable,
|
|
72
|
+
HTTPExposure,
|
|
73
|
+
Interface,
|
|
74
|
+
InterfaceType,
|
|
75
|
+
JSONSchema,
|
|
76
|
+
LiteralSegment,
|
|
77
|
+
MCPServer,
|
|
78
|
+
Model,
|
|
79
|
+
PayloadVariable,
|
|
80
|
+
Provider,
|
|
81
|
+
Signature,
|
|
82
|
+
Subscription,
|
|
83
|
+
TemplateSegment,
|
|
84
|
+
ToolFilter,
|
|
85
|
+
Tools,
|
|
86
|
+
Transport,
|
|
87
|
+
TransportType,
|
|
88
|
+
WebChatInterface,
|
|
89
|
+
WebhookInterface,
|
|
90
|
+
get_filtered_tools,
|
|
91
|
+
)
|
|
92
|
+
from .parser import parse_afm, parse_afm_file, validate_and_extract_interfaces
|
|
93
|
+
from .providers import (
|
|
94
|
+
create_model_provider,
|
|
95
|
+
get_supported_providers,
|
|
96
|
+
)
|
|
97
|
+
from .schema_validator import (
|
|
98
|
+
build_output_schema_instruction,
|
|
99
|
+
coerce_output_to_schema,
|
|
100
|
+
extract_json_from_response,
|
|
101
|
+
json_schema_to_dict,
|
|
102
|
+
validate_input,
|
|
103
|
+
validate_output,
|
|
104
|
+
)
|
|
105
|
+
from .templates import access_json_field, compile_template, evaluate_template
|
|
106
|
+
from .tools import (
|
|
107
|
+
MCPClient,
|
|
108
|
+
MCPManager,
|
|
109
|
+
build_auth_headers,
|
|
110
|
+
filter_tools,
|
|
111
|
+
)
|
|
112
|
+
from .variables import (
|
|
113
|
+
contains_http_variable,
|
|
114
|
+
resolve_variables,
|
|
115
|
+
validate_http_variables,
|
|
116
|
+
)
|
|
117
|
+
from .cli import create_unified_app, main
|
|
118
|
+
|
|
119
|
+
__version__ = "0.1.0"
|
|
120
|
+
|
|
121
|
+
__all__ = [
|
|
122
|
+
# Version
|
|
123
|
+
"__version__",
|
|
124
|
+
# Parser Functions
|
|
125
|
+
"parse_afm",
|
|
126
|
+
"parse_afm_file",
|
|
127
|
+
"validate_and_extract_interfaces",
|
|
128
|
+
# Variables
|
|
129
|
+
"resolve_variables",
|
|
130
|
+
"contains_http_variable",
|
|
131
|
+
"validate_http_variables",
|
|
132
|
+
# Templates
|
|
133
|
+
"compile_template",
|
|
134
|
+
"evaluate_template",
|
|
135
|
+
"access_json_field",
|
|
136
|
+
# Models
|
|
137
|
+
"AFMRecord",
|
|
138
|
+
"AgentMetadata",
|
|
139
|
+
"Provider",
|
|
140
|
+
"Model",
|
|
141
|
+
"ClientAuthentication",
|
|
142
|
+
"Transport",
|
|
143
|
+
"TransportType",
|
|
144
|
+
"ToolFilter",
|
|
145
|
+
"MCPServer",
|
|
146
|
+
"Tools",
|
|
147
|
+
"JSONSchema",
|
|
148
|
+
"Signature",
|
|
149
|
+
"HTTPExposure",
|
|
150
|
+
"Exposure",
|
|
151
|
+
"Subscription",
|
|
152
|
+
"InterfaceType",
|
|
153
|
+
"ConsoleChatInterface",
|
|
154
|
+
"WebChatInterface",
|
|
155
|
+
"WebhookInterface",
|
|
156
|
+
"Interface",
|
|
157
|
+
"CompiledTemplate",
|
|
158
|
+
"LiteralSegment",
|
|
159
|
+
"PayloadVariable",
|
|
160
|
+
"HeaderVariable",
|
|
161
|
+
"TemplateSegment",
|
|
162
|
+
"get_filtered_tools",
|
|
163
|
+
# Exceptions
|
|
164
|
+
"AFMError",
|
|
165
|
+
"AFMParseError",
|
|
166
|
+
"AFMValidationError",
|
|
167
|
+
"VariableResolutionError",
|
|
168
|
+
"TemplateError",
|
|
169
|
+
"TemplateCompilationError",
|
|
170
|
+
"TemplateEvaluationError",
|
|
171
|
+
"JSONAccessError",
|
|
172
|
+
# Agent Class
|
|
173
|
+
"Agent",
|
|
174
|
+
# Provider Factory
|
|
175
|
+
"create_model_provider",
|
|
176
|
+
"get_supported_providers",
|
|
177
|
+
# Schema Validation
|
|
178
|
+
"validate_input",
|
|
179
|
+
"validate_output",
|
|
180
|
+
"coerce_output_to_schema",
|
|
181
|
+
"extract_json_from_response",
|
|
182
|
+
"json_schema_to_dict",
|
|
183
|
+
"build_output_schema_instruction",
|
|
184
|
+
"AgentError",
|
|
185
|
+
"AgentConfigError",
|
|
186
|
+
"ProviderError",
|
|
187
|
+
"InputValidationError",
|
|
188
|
+
"OutputValidationError",
|
|
189
|
+
"InterfaceNotFoundError",
|
|
190
|
+
# MCP Exceptions
|
|
191
|
+
"MCPError",
|
|
192
|
+
"MCPConnectionError",
|
|
193
|
+
"MCPToolError",
|
|
194
|
+
"MCPAuthenticationError",
|
|
195
|
+
# MCP Classes
|
|
196
|
+
"MCPClient",
|
|
197
|
+
"MCPManager",
|
|
198
|
+
"build_auth_headers",
|
|
199
|
+
"filter_tools",
|
|
200
|
+
# Interface Functions
|
|
201
|
+
"get_interfaces",
|
|
202
|
+
"get_interface_by_type",
|
|
203
|
+
"get_console_interface",
|
|
204
|
+
"get_webchat_interface",
|
|
205
|
+
"get_webhook_interface",
|
|
206
|
+
"get_primary_interface",
|
|
207
|
+
"has_interface_type",
|
|
208
|
+
"get_http_path",
|
|
209
|
+
"ChatApp",
|
|
210
|
+
"run_console_chat",
|
|
211
|
+
"async_run_console_chat",
|
|
212
|
+
"create_webchat_app",
|
|
213
|
+
"run_webchat_server",
|
|
214
|
+
"create_webhook_app",
|
|
215
|
+
"run_webhook_server",
|
|
216
|
+
"WebSubSubscriber",
|
|
217
|
+
"verify_webhook_signature",
|
|
218
|
+
# CLI
|
|
219
|
+
"main",
|
|
220
|
+
"create_unified_app",
|
|
221
|
+
]
|