Skip to content

Commit 309a509

Browse files
authored
feat: update to v0.2 ACP spec (#41)
* chore: restore code to add manifest spec version to package. * fix: add prereqs for docs and fix typo. * chore: update submodule versions * chore: update client to v0.2 ACP specification * fix: deleted files from previous version * fix: updated generator to match spec. used fixed spec to regenerate clients. * chore: updated clients to support api key auth from spec. * fix: updated version to dev * feat: remove security scheme from ACP spec and move to ACP SDK objects to support workflow server API key. * chore: remove unneeded imports. * chore: bump version for dev * fix: updated to latest 0.2.1 ACP spec. * chore: remove dev suffix from version and handle dev publishing entirely with tags. * chore: bump version to reflect new spec. * fix: address bug in sed command. * fix: working on sed command. * chore: add exceptions to package import. * fix: remove stale type * fix: add back code deleted in error. * fix: update property name to conform to 0.2 * fix: get values for output because typing does not work. * fix: handle workflow server return values correctly. Added unit test for LangGraph ACPNode integration. * chore: bump version. Fix docstring and remove extra file. * fix: added project URLs for pypi.
1 parent 5951e62 commit 309a509

File tree

89 files changed

+17964
-2853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+17964
-2853
lines changed

.github/workflows/pypi.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,21 @@ jobs:
4343
env:
4444
TAG_NAME: ${{ github.ref_name }}
4545
run: |
46-
TAG="${TAG_NAME##v}"
46+
TAG="${TAG_NAME#v}"
4747
PYPROJECT_VERSION=$(awk '/version/ { gsub("\"", ""); print $3; exit; }' pyproject.toml)
4848
49-
if [ ! "${PYPROJECT_VERSION}" = "${TAG}" ]; then
49+
if [ ! "${PYPROJECT_VERSION}" = "${TAG%.dev*}" ]; then
5050
echo "You created the \"${{ github.ref_name }}\" git tag; it is fine, BUT it does not match the pyproject.toml file"
5151
exit 1
5252
fi
5353

54-
echo "Building and publishing version: ${PYPROJECT_VERSION}" >> $GITHUB_STEP_SUMMARY
54+
# Update version to match in case it is a dev version
55+
if [ ! "${TAG%.dev*}" = "${TAG}" ]; then
56+
sed "s/version = \"${TAG%.dev*}\"/version = \"${TAG}\"/" pyproject.toml >pyproject.toml.bak \
57+
&& mv pyproject.toml.bak pyproject.toml
58+
fi
59+
60+
echo "Building and publishing version: ${TAG}" >> $GITHUB_STEP_SUMMARY
5561

5662
- name: Build package
5763
env:

Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ install:
1111
ACP_SPEC_DIR=acp-spec
1212
ACP_CLIENT_DIR:=acp-sync-client-generated
1313
ACP_SUBPACKAGE_PREFIX=acp_v
14-
ACP_SPEC_FILE:=$(ACP_SPEC_DIR)/openapi.yaml
14+
ACP_SPEC_FILE:=$(ACP_SPEC_DIR)/openapi.json
1515
GEN_ACP_SYNC_PACKAGE_PREFIX:=acp_client_v
1616
SDK_ACP_SYNC_PACKAGE_NAME:=sync_client
1717

@@ -21,7 +21,7 @@ $(ACP_SPEC_FILE):
2121
# Generate client and correct models for convenience.
2222
generate_acp_client $(ACP_CLIENT_DIR)/README.md : $(ACP_SPEC_FILE)
2323
export SPEC_FILE="$(ACP_SPEC_FILE)" ; \
24-
export SPEC_VERSION=$$(yq '.info.version | sub("\.\d+", "")' "$${SPEC_FILE}") ; \
24+
SPEC_VERSION=$$(jq -r '.info.version | capture("(?<version>\\d+)\\.\\d+"; "") | .version' "$${SPEC_FILE}") ; \
2525
export CLIENT_DIR="$(ACP_CLIENT_DIR)" ; \
2626
export GEN_PACKAGE_NAME="$(GEN_ACP_SYNC_PACKAGE_PREFIX)$${SPEC_VERSION}" ; \
2727
export SDK_SUBPACKAGE_NAME="agntcy_acp.$(ACP_SUBPACKAGE_PREFIX)$${SPEC_VERSION}" ; \
@@ -42,7 +42,7 @@ SDK_ACP_ASYNC_PACKAGE_NAME:=async_client
4242

4343
generate_acp_async_client $(ACP_ASYNC_CLIENT_DIR)/README.md : $(ACP_SPEC_FILE)
4444
export SPEC_FILE="$(ACP_SPEC_FILE)" ; \
45-
export SPEC_VERSION=$$(yq '.info.version | sub("\.\d+", "")' "$${SPEC_FILE}") ; \
45+
SPEC_VERSION=$$(jq -r '.info.version | capture("(?<version>\\d+)\\.\\d+"; "") | .version' "$${SPEC_FILE}") ; \
4646
export CLIENT_DIR="$(ACP_ASYNC_CLIENT_DIR)" ; \
4747
export GEN_PACKAGE_NAME="$(GEN_ACP_ASYNC_PACKAGE_PREFIX)$${SPEC_VERSION}" ; \
4848
export SDK_SUBPACKAGE_NAME="agntcy_acp.$(ACP_SUBPACKAGE_PREFIX)$${SPEC_VERSION}" ; \
@@ -64,17 +64,22 @@ $(AGNT_WKFW_SPEC_FILE):
6464
git submodule update $(AGENT_WORKFLOW_DIR)
6565

6666
generate_manifest_models: $(AGNT_WKFW_SPEC_FILE)
67-
ACP_SPEC_VERSION=$$(yq '.info.version | sub("\.\d+", "")' $(AGNT_WKFW_SPEC_FILE)) ; \
67+
ACP_SPEC_VERSION=$$(yq '.info.version | sub("\.\d+", "")' "$(AGNT_WKFW_SPEC_FILE)") ; \
6868
AGNT_WKFW_MODEL_PACKAGE_DIR="agntcy_acp/agws_v$${ACP_SPEC_VERSION}" ; \
69+
{ mkdir "$${AGNT_WKFW_MODEL_PACKAGE_DIR}" || true ; } ; \
6970
poetry run datamodel-codegen \
7071
--input $(AGNT_WKFW_SPEC_FILE) \
7172
--input-file-type openapi \
7273
--output-model-type pydantic_v2.BaseModel \
7374
--output "$${AGNT_WKFW_MODEL_PACKAGE_DIR}"/models.py \
74-
--disable-timestamp
75+
--disable-timestamp && \
76+
cp .spdx_header "$${AGNT_WKFW_MODEL_PACKAGE_DIR}/spec_version.py" && \
77+
echo VERSION="\""$$(yq '.info.version' "$(AGNT_WKFW_SPEC_FILE)")"\"" >>"$${AGNT_WKFW_MODEL_PACKAGE_DIR}/spec_version.py" && \
78+
echo MAJOR_VERSION="\"$${ACP_SPEC_VERSION}\"" >>"$${AGNT_WKFW_MODEL_PACKAGE_DIR}/spec_version.py" && \
79+
echo MINOR_VERSION="\""$$(yq '.info.version | sub("\d+\.", "")' "$(AGNT_WKFW_SPEC_FILE)")"\"" >>"$${AGNT_WKFW_MODEL_PACKAGE_DIR}/spec_version.py"
7580

7681
update_python_subpackage: $(ACP_CLIENT_DIR)/README.md $(ACP_ASYNC_CLIENT_DIR)/README.md
77-
ACP_SPEC_VERSION=$$(yq '.info.version | sub("\.\d+", "")' $(ACP_SPEC_FILE)) ; \
82+
ACP_SPEC_VERSION=$$(jq -r '.info.version | capture("(?<version>\\d+)\\.\\d+"; "") | .version' $(ACP_SPEC_FILE)) ; \
7883
ACP_CLIENT_PACKAGE_DIR="$(ACP_CLIENT_DIR)/$(GEN_ACP_SYNC_PACKAGE_PREFIX)$${ACP_SPEC_VERSION}" ; \
7984
ACP_ASYNC_CLIENT_PACKAGE_DIR="$(ACP_ASYNC_CLIENT_DIR)/$(GEN_ACP_ASYNC_PACKAGE_PREFIX)$${ACP_SPEC_VERSION}" ; \
8085
cp -pR "$${ACP_CLIENT_PACKAGE_DIR}/__init__.py" \
@@ -91,7 +96,7 @@ update_python_subpackage: $(ACP_CLIENT_DIR)/README.md $(ACP_ASYNC_CLIENT_DIR)/RE
9196
cp -pR "$${ACP_ASYNC_CLIENT_PACKAGE_DIR}/api" \
9297
"$${ACP_ASYNC_CLIENT_PACKAGE_DIR}/api_client.py" \
9398
"$${ACP_ASYNC_CLIENT_PACKAGE_DIR}/rest.py" \
94-
"agntcy_acp/$(ACP_SUBPACKAGE_PREFIX)$${ACP_SPEC_VERSION}/$(SDK_ACP_ASYNC_PACKAGE_NAME)/" && \
99+
"agntcy_acp/$(ACP_SUBPACKAGE_PREFIX)$${ACP_SPEC_VERSION}/$(SDK_ACP_ASYNC_PACKAGE_NAME)/"
95100

96101
update_docs: $(ACP_CLIENT_DIR)/README.md $(ACP_ASYNC_CLIENT_DIR)/README.md
97102
cp -p "$(ACP_CLIENT_DIR)"/docs/*.md docs/models/ && \

agntcy_acp/__init__.py

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
from os import getenv
55
from typing import Optional, Any, Dict, Union
66

7-
from .acp_v0.sync_client import ApiClient, AgentsApi, RunsApi, ThreadsApi
8-
from .acp_v0.async_client import AgentsApi as AsyncAgentsApi
9-
from .acp_v0.async_client import RunsApi as AsyncRunsApi
10-
from .acp_v0.async_client import ThreadsApi as AsyncThreadsApi
11-
from .acp_v0.async_client import ApiClient as AsyncApiClient
7+
from .acp_v0.sync_client.api_client import ApiClient
8+
from .acp_v0.sync_client.api import AgentsApi, ThreadsApi, StatelessRunsApi, ThreadRunsApi
9+
from .acp_v0.async_client.api import AgentsApi as AsyncAgentsApi
10+
from .acp_v0.async_client.api import StatelessRunsApi as AsyncStatelessRunsApi
11+
from .acp_v0.async_client.api import ThreadsApi as AsyncThreadsApi
12+
from .acp_v0.async_client.api import ThreadRunsApi as AsyncThreadRunsApi
13+
from .acp_v0.async_client.api_client import ApiClient as AsyncApiClient
1214
from .acp_v0 import ApiResponse
1315
from .acp_v0 import Configuration
1416
from .acp_v0.configuration import ServerVariablesT
@@ -26,19 +28,44 @@
2628
ApiKeyError,
2729
ApiAttributeError,
2830
ApiException,
31+
BadRequestException,
32+
NotFoundException,
33+
UnauthorizedException,
34+
ForbiddenException,
35+
ServiceException,
36+
ConflictException,
37+
UnprocessableEntityException,
2938
)
3039

31-
class ACPClient(AgentsApi, RunsApi, ThreadsApi):
40+
class ACPClient(AgentsApi, StatelessRunsApi, ThreadsApi, ThreadRunsApi):
3241
"""Client for ACP API.
3342
"""
3443
def __init__(self, api_client: Optional[ApiClient] = None):
3544
super().__init__(api_client)
45+
self.__workflow_server_update_api_client()
3646

37-
class AsyncACPClient(AsyncAgentsApi, AsyncRunsApi, AsyncThreadsApi):
47+
def __workflow_server_update_api_client(self):
48+
if self.api_client.configuration.api_key is not None:
49+
# Check for 'x-api-key' config and move to header.
50+
try:
51+
self.api_client.default_headers['x-api-key'] = self.api_client.configuration.api_key['x-api-key']
52+
except KeyError:
53+
pass # ignore
54+
55+
class AsyncACPClient(AsyncAgentsApi, AsyncStatelessRunsApi, AsyncThreadsApi, AsyncThreadRunsApi):
3856
"""Async client for ACP API.
3957
"""
4058
def __init__(self, api_client: Optional[AsyncApiClient] = None):
4159
super().__init__(api_client)
60+
self.__workflow_server_update_api_client()
61+
62+
def __workflow_server_update_api_client(self):
63+
if self.api_client.configuration.api_key is not None:
64+
# Check for 'x-api-key' config and move to header.
65+
try:
66+
self.api_client.default_headers['x-api-key'] = self.api_client.configuration.api_key['x-api-key']
67+
except KeyError:
68+
pass # ignore
4269

4370
__ENV_VAR_SPECIAL_CHAR_TABLE = str.maketrans("-.", "__")
4471

@@ -73,6 +100,7 @@ class ApiClientConfiguration(Configuration):
73100
:param ca_cert_data: verify the peer using concatenated CA certificate data
74101
in PEM (str) or DER (bytes) format.
75102
:param debug: Debug switch.
103+
76104
"""
77105
def __init__(
78106
self,
@@ -115,12 +143,13 @@ def fromEnvPrefix(
115143
debug: Optional[bool] = None,
116144
) -> "ApiClientConfiguration":
117145
"""Construct a configuration object using environment variables as
118-
default source of parameter values.
146+
default source of parameter values. For example, with env_var_prefix="MY_",
147+
the default host parameter value would be looked up in the "MY_HOST"
148+
environment variable if not provided.
119149
120150
:param env_var_prefix: String used as prefix for environment variable
121-
names. For example, with env_var_prefix="MY_", the default host parameter
122-
value would be looked up in the "MY_HOST" environment variable if not
123-
provided.
151+
names.
152+
124153
:return: Configuration object
125154
:rtype: ApiClientConfiguration
126155
"""
@@ -196,6 +225,13 @@ def fromEnvPrefix(
196225
"ApiKeyError",
197226
"ApiAttributeError",
198227
"ApiException",
228+
"BadRequestException",
229+
"NotFoundException",
230+
"UnauthorizedException",
231+
"ForbiddenException",
232+
"ServiceException",
233+
"ConflictException",
234+
"UnprocessableEntityException",
199235
"ACP_VERSION",
200236
"ACP_MAJOR_VERSION",
201237
"ACP_MINOR_VERSION",

agntcy_acp/acp_v0/__init__.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
1111
12-
The version of the OpenAPI document: 0.1
12+
The version of the OpenAPI document: 0.2.1
1313
Generated by OpenAPI Generator (https://openapi-generator.tech)
1414
1515
Do not edit the class manually.
@@ -20,7 +20,8 @@
2020

2121
# import apis into sdk package
2222
from agntcy_acp.acp_v0.sync_client.api.agents_api import AgentsApi
23-
from agntcy_acp.acp_v0.sync_client.api.runs_api import RunsApi
23+
from agntcy_acp.acp_v0.sync_client.api.stateless_runs_api import StatelessRunsApi
24+
from agntcy_acp.acp_v0.sync_client.api.thread_runs_api import ThreadRunsApi
2425
from agntcy_acp.acp_v0.sync_client.api.threads_api import ThreadsApi
2526

2627
# import ApiClient
@@ -43,19 +44,37 @@
4344
from agntcy_acp.acp_v0.models.agent_metadata import AgentMetadata
4445
from agntcy_acp.acp_v0.models.agent_ref import AgentRef
4546
from agntcy_acp.acp_v0.models.agent_search_request import AgentSearchRequest
47+
from agntcy_acp.acp_v0.models.config import Config
48+
from agntcy_acp.acp_v0.models.content import Content
49+
from agntcy_acp.acp_v0.models.content_one_of_inner import ContentOneOfInner
4650
from agntcy_acp.acp_v0.models.custom_run_result_update import CustomRunResultUpdate
51+
from agntcy_acp.acp_v0.models.message import Message
52+
from agntcy_acp.acp_v0.models.message_any_block import MessageAnyBlock
53+
from agntcy_acp.acp_v0.models.message_text_block import MessageTextBlock
4754
from agntcy_acp.acp_v0.models.run import Run
4855
from agntcy_acp.acp_v0.models.run_create import RunCreate
56+
from agntcy_acp.acp_v0.models.run_create_stateful import RunCreateStateful
57+
from agntcy_acp.acp_v0.models.run_create_stateless import RunCreateStateless
4958
from agntcy_acp.acp_v0.models.run_error import RunError
5059
from agntcy_acp.acp_v0.models.run_interrupt import RunInterrupt
5160
from agntcy_acp.acp_v0.models.run_output import RunOutput
5261
from agntcy_acp.acp_v0.models.run_output_stream import RunOutputStream
5362
from agntcy_acp.acp_v0.models.run_result import RunResult
5463
from agntcy_acp.acp_v0.models.run_search_request import RunSearchRequest
64+
from agntcy_acp.acp_v0.models.run_stateful import RunStateful
65+
from agntcy_acp.acp_v0.models.run_stateless import RunStateless
5566
from agntcy_acp.acp_v0.models.run_status import RunStatus
67+
from agntcy_acp.acp_v0.models.run_wait_response_stateful import RunWaitResponseStateful
68+
from agntcy_acp.acp_v0.models.run_wait_response_stateless import RunWaitResponseStateless
5669
from agntcy_acp.acp_v0.models.stream_event_payload import StreamEventPayload
70+
from agntcy_acp.acp_v0.models.stream_mode import StreamMode
5771
from agntcy_acp.acp_v0.models.streaming_mode import StreamingMode
5872
from agntcy_acp.acp_v0.models.streaming_modes import StreamingModes
5973
from agntcy_acp.acp_v0.models.thread import Thread
74+
from agntcy_acp.acp_v0.models.thread_checkpoint import ThreadCheckpoint
6075
from agntcy_acp.acp_v0.models.thread_create import ThreadCreate
76+
from agntcy_acp.acp_v0.models.thread_patch import ThreadPatch
6177
from agntcy_acp.acp_v0.models.thread_search_request import ThreadSearchRequest
78+
from agntcy_acp.acp_v0.models.thread_state import ThreadState
79+
from agntcy_acp.acp_v0.models.thread_status import ThreadStatus
80+
from agntcy_acp.acp_v0.models.value_run_result_update import ValueRunResultUpdate

agntcy_acp/acp_v0/async_client/__init__.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

agntcy_acp/acp_v0/async_client/api/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# import apis into api package
66
from agntcy_acp.acp_v0.async_client.api.agents_api import AgentsApi
7-
from agntcy_acp.acp_v0.async_client.api.runs_api import RunsApi
7+
from agntcy_acp.acp_v0.async_client.api.stateless_runs_api import StatelessRunsApi
8+
from agntcy_acp.acp_v0.async_client.api.thread_runs_api import ThreadRunsApi
89
from agntcy_acp.acp_v0.async_client.api.threads_api import ThreadsApi
910

agntcy_acp/acp_v0/async_client/api/agents_api.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
99
10-
The version of the OpenAPI document: 0.1
10+
The version of the OpenAPI document: 0.2.1
1111
Generated by OpenAPI Generator (https://openapi-generator.tech)
1212
1313
Do not edit the class manually.
@@ -365,7 +365,6 @@ async def get_agent_by_id(
365365
_response_types_map: Dict[str, Optional[str]] = {
366366
'200': "Agent",
367367
'404': "str",
368-
'422': "str",
369368
}
370369
response_data = await self.api_client.call_api(
371370
*_param,
@@ -434,7 +433,6 @@ async def get_agent_by_id_with_http_info(
434433
_response_types_map: Dict[str, Optional[str]] = {
435434
'200': "Agent",
436435
'404': "str",
437-
'422': "str",
438436
}
439437
response_data = await self.api_client.call_api(
440438
*_param,
@@ -503,7 +501,6 @@ async def get_agent_by_id_without_preload_content(
503501
_response_types_map: Dict[str, Optional[str]] = {
504502
'200': "Agent",
505503
'404': "str",
506-
'422': "str",
507504
}
508505
response_data = await self.api_client.call_api(
509506
*_param,

0 commit comments

Comments
 (0)