agentkernel 0.2.12__tar.gz → 0.2.14__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.
- {agentkernel-0.2.12 → agentkernel-0.2.14}/PKG-INFO +35 -3
- {agentkernel-0.2.12 → agentkernel-0.2.14}/README.md +32 -2
- {agentkernel-0.2.12 → agentkernel-0.2.14}/pyproject.toml +7 -1
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/auth/handler.py +6 -4
- agentkernel-0.2.14/src/agentkernel/cli/ak.py +258 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/__init__.py +1 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/config.py +2 -1
- agentkernel-0.2.14/src/agentkernel/core/tool.py +156 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/framework/adk/__init__.py +1 -1
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/framework/adk/adk.py +113 -6
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/framework/crewai/__init__.py +1 -1
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/framework/crewai/crewai.py +64 -32
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/framework/langgraph/__init__.py +1 -1
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/framework/langgraph/langgraph.py +71 -22
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/framework/openai/__init__.py +1 -1
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/framework/openai/openai.py +33 -4
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/guardrail/guardrail.py +8 -0
- agentkernel-0.2.14/src/agentkernel/guardrail/walledai.py +230 -0
- agentkernel-0.2.14/src/agentkernel/skills/__init__.py +7 -0
- agentkernel-0.2.14/src/agentkernel/skills/ak-add-capabilities/SKILL.md +448 -0
- agentkernel-0.2.14/src/agentkernel/skills/ak-add-capabilities/evals/evals.json +166 -0
- agentkernel-0.2.14/src/agentkernel/skills/ak-add-integration/SKILL.md +338 -0
- agentkernel-0.2.14/src/agentkernel/skills/ak-add-integration/evals/evals.json +100 -0
- agentkernel-0.2.14/src/agentkernel/skills/ak-build/SKILL.md +378 -0
- agentkernel-0.2.14/src/agentkernel/skills/ak-build/evals/evals.json +177 -0
- agentkernel-0.2.14/src/agentkernel/skills/ak-cloud-deploy/SKILL.md +381 -0
- agentkernel-0.2.14/src/agentkernel/skills/ak-cloud-deploy/evals/evals.json +133 -0
- agentkernel-0.2.14/src/agentkernel/skills/ak-init/SKILL.md +346 -0
- agentkernel-0.2.14/src/agentkernel/skills/ak-init/evals/evals.json +142 -0
- agentkernel-0.2.14/src/agentkernel/skills/ak-test/SKILL.md +330 -0
- agentkernel-0.2.14/src/agentkernel/skills/ak-test/evals/evals.json +131 -0
- agentkernel-0.2.14/src/agentkernel/skills/skills.py +197 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/adk.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/api/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/api/a2a/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/api/a2a/a2a.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/api/a2a/handler.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/api/handler.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/api/http.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/api/mcp/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/api/mcp/akmcp.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/auth/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/aws.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/azure.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/cli/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/cli/cli.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/base.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/builder.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/hooks.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/model.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/module.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/runtime.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/service.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/session/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/session/base.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/session/cosmosdb.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/session/dynamodb.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/session/in_memory.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/session/redis.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/session/serde.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/util/config_yaml_util.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/core/util/key_value_cache.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/crewai.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/deployment/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/deployment/aws/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/deployment/aws/akauthorizer.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/deployment/aws/aklambda.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/deployment/azure/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/deployment/azure/akfunction.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/framework/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/gmail.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/guardrail/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/guardrail/bedrock.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/guardrail/openai.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/instagram.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/gmail/README.md +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/gmail/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/gmail/gmail_chat.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/instagram/README.md +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/instagram/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/instagram/instagram_chat.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/messenger/README.md +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/messenger/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/messenger/messenger_chat.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/slack/README.md +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/slack/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/slack/slack_chat.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/telegram/README.md +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/telegram/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/telegram/telegram_chat.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/whatsapp/README.md +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/whatsapp/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/integration/whatsapp/whatsapp_chat.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/langgraph.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/mcp.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/messenger.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/openai.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/slack.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/telegram.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/test/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/test/test.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/base.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/langfuse/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/langfuse/adk.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/langfuse/crewai.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/langfuse/langfuse.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/langfuse/langgraph.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/langfuse/openai.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/openllmetry/__init__.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/openllmetry/adk.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/openllmetry/crewai.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/openllmetry/langgraph.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/openllmetry/openai.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/openllmetry/openllmetry.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/trace/trace.py +0 -0
- {agentkernel-0.2.12 → agentkernel-0.2.14}/src/agentkernel/whatsapp.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: agentkernel
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.14
|
|
4
4
|
Summary: Agent Kernel - Unified AI Agents Runtime
|
|
5
5
|
Author: Yaala Labs
|
|
6
6
|
Author-email: Yaala Labs <agentkernel@yaalalabs.com>
|
|
@@ -56,6 +56,7 @@ Requires-Dist: ragas>=0.4.1 ; extra == 'test'
|
|
|
56
56
|
Requires-Dist: datasets>=2.14.0 ; extra == 'test'
|
|
57
57
|
Requires-Dist: pandas>=2.0.0 ; extra == 'test'
|
|
58
58
|
Requires-Dist: litellm>=1.74.9 ; extra == 'test'
|
|
59
|
+
Requires-Dist: walledai>=4.9.3 ; extra == 'walledai'
|
|
59
60
|
Requires-Dist: httpx>=0.27.0 ; extra == 'whatsapp'
|
|
60
61
|
Requires-Python: >=3.12, <3.14
|
|
61
62
|
Provides-Extra: a2a
|
|
@@ -78,6 +79,7 @@ Provides-Extra: redis
|
|
|
78
79
|
Provides-Extra: slack
|
|
79
80
|
Provides-Extra: telegram
|
|
80
81
|
Provides-Extra: test
|
|
82
|
+
Provides-Extra: walledai
|
|
81
83
|
Provides-Extra: whatsapp
|
|
82
84
|
Description-Content-Type: text/markdown
|
|
83
85
|
|
|
@@ -561,7 +563,7 @@ Configure input and output guardrails to validate agent requests and responses f
|
|
|
561
563
|
- **Type**
|
|
562
564
|
- **Field**: `guardrail.input.type`
|
|
563
565
|
- **Default**: `openai`
|
|
564
|
-
- **Options**: `openai`, `bedrock`
|
|
566
|
+
- **Options**: `openai`, `bedrock`, `walledai`
|
|
565
567
|
- **Description**: Guardrail provider type
|
|
566
568
|
- **Environment Variable**: `AK_GUARDRAIL__INPUT__TYPE`
|
|
567
569
|
|
|
@@ -599,7 +601,7 @@ Configure input and output guardrails to validate agent requests and responses f
|
|
|
599
601
|
- **Type**
|
|
600
602
|
- **Field**: `guardrail.output.type`
|
|
601
603
|
- **Default**: `openai`
|
|
602
|
-
- **Options**: `openai`, `bedrock`
|
|
604
|
+
- **Options**: `openai`, `bedrock`, `walledai`
|
|
603
605
|
- **Description**: Guardrail provider type
|
|
604
606
|
- **Environment Variable**: `AK_GUARDRAIL__OUTPUT__TYPE`
|
|
605
607
|
|
|
@@ -641,12 +643,20 @@ To use AWS Bedrock guardrails, install the AWS package:
|
|
|
641
643
|
pip install agentkernel[aws]
|
|
642
644
|
```
|
|
643
645
|
|
|
646
|
+
To use Walled AI guardrails, install the Walled AI package:
|
|
647
|
+
|
|
648
|
+
```bash
|
|
649
|
+
pip install agentkernel[walledai]
|
|
650
|
+
```
|
|
651
|
+
|
|
644
652
|
Create guardrail configuration:
|
|
645
653
|
|
|
646
654
|
**For OpenAI:** Create configuration files following the [OpenAI Guardrails format](https://guardrails.openai.com/).
|
|
647
655
|
|
|
648
656
|
**For Bedrock:** Create a guardrail in AWS Bedrock and note the guardrail ID and version.
|
|
649
657
|
|
|
658
|
+
**For Walled AI:** Set `WALLED_API_KEY`, use guardrail type `walledai`, and control PII masking with `pii`.
|
|
659
|
+
|
|
650
660
|
Configure guardrails in your configuration:
|
|
651
661
|
|
|
652
662
|
**OpenAI Example:**
|
|
@@ -679,6 +689,19 @@ guardrail:
|
|
|
679
689
|
version: "1"
|
|
680
690
|
```
|
|
681
691
|
|
|
692
|
+
**Walled AI Example:**
|
|
693
|
+
```yaml
|
|
694
|
+
guardrail:
|
|
695
|
+
input:
|
|
696
|
+
enabled: true
|
|
697
|
+
type: walledai
|
|
698
|
+
pii: true
|
|
699
|
+
output:
|
|
700
|
+
enabled: true
|
|
701
|
+
type: walledai
|
|
702
|
+
pii: true
|
|
703
|
+
```
|
|
704
|
+
|
|
682
705
|
#### Messaging Platform Integrations
|
|
683
706
|
|
|
684
707
|
Configure integrations with messaging platforms.
|
|
@@ -789,6 +812,11 @@ export AK_GUARDRAIL__OUTPUT__ENABLED=false
|
|
|
789
812
|
export AK_GUARDRAIL__OUTPUT__TYPE=openai
|
|
790
813
|
export AK_GUARDRAIL__OUTPUT__MODEL=gpt-4o-mini
|
|
791
814
|
export AK_GUARDRAIL__OUTPUT__CONFIG_PATH=/path/to/guardrails_output.json
|
|
815
|
+
# Walled AI guardrails
|
|
816
|
+
export WALLED_API_KEY=your-walledai-api-key
|
|
817
|
+
export AK_GUARDRAIL__INPUT__PII=true
|
|
818
|
+
export AK_GUARDRAIL__OUTPUT__PII=true
|
|
819
|
+
export AK_DEBUG=true
|
|
792
820
|
# Messaging platforms (optional)
|
|
793
821
|
export AK_SLACK__AGENT=my-agent
|
|
794
822
|
export AK_WHATSAPP__AGENT=my-agent
|
|
@@ -862,13 +890,17 @@ guardrail:
|
|
|
862
890
|
input:
|
|
863
891
|
enabled: false
|
|
864
892
|
type: openai
|
|
893
|
+
pii: true
|
|
865
894
|
model: gpt-4o-mini
|
|
866
895
|
config_path: /path/to/guardrails_input.json
|
|
867
896
|
output:
|
|
868
897
|
enabled: false
|
|
869
898
|
type: openai
|
|
899
|
+
pii: true
|
|
870
900
|
model: gpt-4o-mini
|
|
871
901
|
config_path: /path/to/guardrails_output.json
|
|
902
|
+
# For Walled AI, set type: walledai, WALLED_API_KEY,
|
|
903
|
+
# and optionally use input/output pii (default: true) to enable/disable PII masking.
|
|
872
904
|
slack:
|
|
873
905
|
agent: my-agent
|
|
874
906
|
agent_acknowledgement: "Processing your request..."
|
|
@@ -478,7 +478,7 @@ Configure input and output guardrails to validate agent requests and responses f
|
|
|
478
478
|
- **Type**
|
|
479
479
|
- **Field**: `guardrail.input.type`
|
|
480
480
|
- **Default**: `openai`
|
|
481
|
-
- **Options**: `openai`, `bedrock`
|
|
481
|
+
- **Options**: `openai`, `bedrock`, `walledai`
|
|
482
482
|
- **Description**: Guardrail provider type
|
|
483
483
|
- **Environment Variable**: `AK_GUARDRAIL__INPUT__TYPE`
|
|
484
484
|
|
|
@@ -516,7 +516,7 @@ Configure input and output guardrails to validate agent requests and responses f
|
|
|
516
516
|
- **Type**
|
|
517
517
|
- **Field**: `guardrail.output.type`
|
|
518
518
|
- **Default**: `openai`
|
|
519
|
-
- **Options**: `openai`, `bedrock`
|
|
519
|
+
- **Options**: `openai`, `bedrock`, `walledai`
|
|
520
520
|
- **Description**: Guardrail provider type
|
|
521
521
|
- **Environment Variable**: `AK_GUARDRAIL__OUTPUT__TYPE`
|
|
522
522
|
|
|
@@ -558,12 +558,20 @@ To use AWS Bedrock guardrails, install the AWS package:
|
|
|
558
558
|
pip install agentkernel[aws]
|
|
559
559
|
```
|
|
560
560
|
|
|
561
|
+
To use Walled AI guardrails, install the Walled AI package:
|
|
562
|
+
|
|
563
|
+
```bash
|
|
564
|
+
pip install agentkernel[walledai]
|
|
565
|
+
```
|
|
566
|
+
|
|
561
567
|
Create guardrail configuration:
|
|
562
568
|
|
|
563
569
|
**For OpenAI:** Create configuration files following the [OpenAI Guardrails format](https://guardrails.openai.com/).
|
|
564
570
|
|
|
565
571
|
**For Bedrock:** Create a guardrail in AWS Bedrock and note the guardrail ID and version.
|
|
566
572
|
|
|
573
|
+
**For Walled AI:** Set `WALLED_API_KEY`, use guardrail type `walledai`, and control PII masking with `pii`.
|
|
574
|
+
|
|
567
575
|
Configure guardrails in your configuration:
|
|
568
576
|
|
|
569
577
|
**OpenAI Example:**
|
|
@@ -596,6 +604,19 @@ guardrail:
|
|
|
596
604
|
version: "1"
|
|
597
605
|
```
|
|
598
606
|
|
|
607
|
+
**Walled AI Example:**
|
|
608
|
+
```yaml
|
|
609
|
+
guardrail:
|
|
610
|
+
input:
|
|
611
|
+
enabled: true
|
|
612
|
+
type: walledai
|
|
613
|
+
pii: true
|
|
614
|
+
output:
|
|
615
|
+
enabled: true
|
|
616
|
+
type: walledai
|
|
617
|
+
pii: true
|
|
618
|
+
```
|
|
619
|
+
|
|
599
620
|
#### Messaging Platform Integrations
|
|
600
621
|
|
|
601
622
|
Configure integrations with messaging platforms.
|
|
@@ -706,6 +727,11 @@ export AK_GUARDRAIL__OUTPUT__ENABLED=false
|
|
|
706
727
|
export AK_GUARDRAIL__OUTPUT__TYPE=openai
|
|
707
728
|
export AK_GUARDRAIL__OUTPUT__MODEL=gpt-4o-mini
|
|
708
729
|
export AK_GUARDRAIL__OUTPUT__CONFIG_PATH=/path/to/guardrails_output.json
|
|
730
|
+
# Walled AI guardrails
|
|
731
|
+
export WALLED_API_KEY=your-walledai-api-key
|
|
732
|
+
export AK_GUARDRAIL__INPUT__PII=true
|
|
733
|
+
export AK_GUARDRAIL__OUTPUT__PII=true
|
|
734
|
+
export AK_DEBUG=true
|
|
709
735
|
# Messaging platforms (optional)
|
|
710
736
|
export AK_SLACK__AGENT=my-agent
|
|
711
737
|
export AK_WHATSAPP__AGENT=my-agent
|
|
@@ -779,13 +805,17 @@ guardrail:
|
|
|
779
805
|
input:
|
|
780
806
|
enabled: false
|
|
781
807
|
type: openai
|
|
808
|
+
pii: true
|
|
782
809
|
model: gpt-4o-mini
|
|
783
810
|
config_path: /path/to/guardrails_input.json
|
|
784
811
|
output:
|
|
785
812
|
enabled: false
|
|
786
813
|
type: openai
|
|
814
|
+
pii: true
|
|
787
815
|
model: gpt-4o-mini
|
|
788
816
|
config_path: /path/to/guardrails_output.json
|
|
817
|
+
# For Walled AI, set type: walledai, WALLED_API_KEY,
|
|
818
|
+
# and optionally use input/output pii (default: true) to enable/disable PII masking.
|
|
789
819
|
slack:
|
|
790
820
|
agent: my-agent
|
|
791
821
|
agent_acknowledgement: "Processing your request..."
|
|
@@ -4,7 +4,7 @@ build-backend = "uv_build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "agentkernel"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.14"
|
|
8
8
|
description = "Agent Kernel - Unified AI Agents Runtime"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.12,<3.14"
|
|
@@ -67,6 +67,9 @@ adk = [
|
|
|
67
67
|
"litellm~=1.74.3",
|
|
68
68
|
"openinference-instrumentation-google-adk>=0.1.6",
|
|
69
69
|
]
|
|
70
|
+
walledai = [
|
|
71
|
+
"walledai>=4.9.3"
|
|
72
|
+
]
|
|
70
73
|
api = [
|
|
71
74
|
"fastapi>=0.118.0",
|
|
72
75
|
"uvicorn>=0.37.0",
|
|
@@ -113,6 +116,9 @@ mcp = [
|
|
|
113
116
|
"fastmcp>=2.12.4",
|
|
114
117
|
]
|
|
115
118
|
|
|
119
|
+
[project.scripts]
|
|
120
|
+
ak = "agentkernel.cli.ak:main"
|
|
121
|
+
|
|
116
122
|
[dependency-groups]
|
|
117
123
|
dev = [
|
|
118
124
|
"black>=23.0.0",
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import base64
|
|
2
|
-
import hashlib
|
|
3
|
-
import hmac
|
|
4
1
|
from abc import ABC, abstractmethod
|
|
5
2
|
from typing import Any, Dict, Optional
|
|
6
3
|
|
|
7
|
-
import jwt
|
|
8
4
|
from pydantic import BaseModel
|
|
9
5
|
|
|
10
6
|
|
|
@@ -43,6 +39,10 @@ class AuthValidator(ABC):
|
|
|
43
39
|
:param algorithm: Hash algorithm to use (default: sha256)
|
|
44
40
|
:return: True if signature is valid, False otherwise
|
|
45
41
|
"""
|
|
42
|
+
import base64
|
|
43
|
+
import hashlib
|
|
44
|
+
import hmac
|
|
45
|
+
|
|
46
46
|
mac = hmac.new(key=secret.encode(), msg=message, digestmod=getattr(hashlib, algorithm))
|
|
47
47
|
expected = base64.b64encode(mac.digest()).decode()
|
|
48
48
|
return hmac.compare_digest(expected, signature)
|
|
@@ -59,6 +59,8 @@ class AuthValidator(ABC):
|
|
|
59
59
|
:return: Decoded JWT claims dictionary
|
|
60
60
|
:raises: jwt exceptions if token is invalid
|
|
61
61
|
"""
|
|
62
|
+
import jwt
|
|
63
|
+
|
|
62
64
|
return jwt.decode(
|
|
63
65
|
token,
|
|
64
66
|
public_key,
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Agent Kernel CLI — `ak` command.
|
|
3
|
+
|
|
4
|
+
Provides the `ak` top-level CLI entry point with subcommands.
|
|
5
|
+
Currently supports `ak skill` for managing agent skills.
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
ak skill list List all available skills
|
|
9
|
+
ak skill info <name> Show full details for a skill
|
|
10
|
+
ak skill assistants List supported coding assistants
|
|
11
|
+
ak skill install Install all skills (default: copilot)
|
|
12
|
+
ak skill install <name> Install a specific skill
|
|
13
|
+
ak skill install --assistant <a> Install to a specific assistant's directory
|
|
14
|
+
ak skill install --target <path> Install to a custom directory
|
|
15
|
+
ak skill update Re-install skills (overwrite existing)
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import argparse
|
|
21
|
+
import sys
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
|
|
24
|
+
from agentkernel.skills import ASSISTANTS, DEFAULT_ASSISTANT, Skill
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class AK:
|
|
28
|
+
"""Agent Kernel CLI."""
|
|
29
|
+
|
|
30
|
+
def __init__(self) -> None:
|
|
31
|
+
self._parser = self._build_parser()
|
|
32
|
+
|
|
33
|
+
# ── Subcommand handlers ───────────────────────────────────────────
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def _resolve_target(args: argparse.Namespace) -> Path:
|
|
37
|
+
"""Resolve the target directory from --assistant or --target."""
|
|
38
|
+
if hasattr(args, "target") and args.target:
|
|
39
|
+
return Path(args.target)
|
|
40
|
+
assistant_name = getattr(args, "assistant", DEFAULT_ASSISTANT)
|
|
41
|
+
assistant = ASSISTANTS.get(assistant_name)
|
|
42
|
+
if not assistant:
|
|
43
|
+
print(f"Error: unknown assistant '{assistant_name}'.", file=sys.stderr)
|
|
44
|
+
print(f"Supported: {', '.join(ASSISTANTS.keys())}", file=sys.stderr)
|
|
45
|
+
sys.exit(1)
|
|
46
|
+
return Path(assistant.skills_dir)
|
|
47
|
+
|
|
48
|
+
def cmd_skill_list(self, args: argparse.Namespace) -> int:
|
|
49
|
+
"""Handle `ak skill list`."""
|
|
50
|
+
skills = Skill.list_all()
|
|
51
|
+
|
|
52
|
+
if not skills:
|
|
53
|
+
print("No skills available.")
|
|
54
|
+
return 1
|
|
55
|
+
|
|
56
|
+
print(f"\nAgent Kernel Skills ({len(skills)} available):\n")
|
|
57
|
+
|
|
58
|
+
max_name_len = max(len(s.name) for s in skills)
|
|
59
|
+
|
|
60
|
+
for skill in skills:
|
|
61
|
+
name = skill.name.ljust(max_name_len)
|
|
62
|
+
desc = skill.description
|
|
63
|
+
if len(desc) > 80:
|
|
64
|
+
desc = desc[:77] + "..."
|
|
65
|
+
print(f" {name} {desc}")
|
|
66
|
+
|
|
67
|
+
print(f"\nInstall with: ak skill install [<name>] [--assistant <name>]")
|
|
68
|
+
print(f"Details: ak skill info <name>")
|
|
69
|
+
return 0
|
|
70
|
+
|
|
71
|
+
def cmd_skill_info(self, args: argparse.Namespace) -> int:
|
|
72
|
+
"""Handle `ak skill info <name>`."""
|
|
73
|
+
skill = Skill.find(args.name)
|
|
74
|
+
if skill is None:
|
|
75
|
+
print(f"Error: skill '{args.name}' not found.", file=sys.stderr)
|
|
76
|
+
print("Run 'ak skill list' to see available skills.", file=sys.stderr)
|
|
77
|
+
return 1
|
|
78
|
+
|
|
79
|
+
print(f"\n {skill.name}")
|
|
80
|
+
print(f" {'─' * len(skill.name)}")
|
|
81
|
+
print(f" {skill.description}\n")
|
|
82
|
+
return 0
|
|
83
|
+
|
|
84
|
+
def cmd_skill_assistants(self, args: argparse.Namespace) -> int:
|
|
85
|
+
"""Handle `ak skill assistants`."""
|
|
86
|
+
print("\nSupported coding assistants:\n")
|
|
87
|
+
|
|
88
|
+
max_name = max(len(a.name) for a in ASSISTANTS.values())
|
|
89
|
+
max_dir = max(len(a.skills_dir) for a in ASSISTANTS.values())
|
|
90
|
+
|
|
91
|
+
for assistant in ASSISTANTS.values():
|
|
92
|
+
name = assistant.name.ljust(max_name)
|
|
93
|
+
sdir = assistant.skills_dir.ljust(max_dir)
|
|
94
|
+
default = " (default)" if assistant.name == DEFAULT_ASSISTANT else ""
|
|
95
|
+
print(f" {name} {sdir} {assistant.description}{default}")
|
|
96
|
+
|
|
97
|
+
print(f"\nUsage: ak skill install --assistant <name>")
|
|
98
|
+
return 0
|
|
99
|
+
|
|
100
|
+
def cmd_skill_install(self, args: argparse.Namespace) -> int:
|
|
101
|
+
"""Handle `ak skill install [<name>] [--assistant <name>] [--target <path>]`."""
|
|
102
|
+
target = self._resolve_target(args)
|
|
103
|
+
skill_name: str | None = args.name
|
|
104
|
+
|
|
105
|
+
if skill_name:
|
|
106
|
+
skill = Skill.find(skill_name)
|
|
107
|
+
if skill is None:
|
|
108
|
+
print(f"Error: skill '{skill_name}' not found.", file=sys.stderr)
|
|
109
|
+
print(f"Run 'ak skill list' to see available skills.", file=sys.stderr)
|
|
110
|
+
return 1
|
|
111
|
+
|
|
112
|
+
target.mkdir(parents=True, exist_ok=True)
|
|
113
|
+
print(f"Installing skill '{skill_name}' to {target}/")
|
|
114
|
+
success = skill.install(target, force=False)
|
|
115
|
+
return 0 if success else 1
|
|
116
|
+
else:
|
|
117
|
+
skills = Skill.list_all()
|
|
118
|
+
if not skills:
|
|
119
|
+
print("No skills available to install.")
|
|
120
|
+
return 1
|
|
121
|
+
|
|
122
|
+
target.mkdir(parents=True, exist_ok=True)
|
|
123
|
+
print(f"Installing {len(skills)} skills to {target}/\n")
|
|
124
|
+
|
|
125
|
+
success_count = 0
|
|
126
|
+
for skill in skills:
|
|
127
|
+
if skill.install(target, force=False):
|
|
128
|
+
success_count += 1
|
|
129
|
+
|
|
130
|
+
print(f"\n{success_count}/{len(skills)} skills installed.")
|
|
131
|
+
return 0
|
|
132
|
+
|
|
133
|
+
def cmd_skill_update(self, args: argparse.Namespace) -> int:
|
|
134
|
+
"""Handle `ak skill update [--assistant <name>] [--target <path>]`."""
|
|
135
|
+
target = self._resolve_target(args)
|
|
136
|
+
skills = Skill.list_all()
|
|
137
|
+
|
|
138
|
+
if not skills:
|
|
139
|
+
print("No skills available to update.")
|
|
140
|
+
return 1
|
|
141
|
+
|
|
142
|
+
target.mkdir(parents=True, exist_ok=True)
|
|
143
|
+
print(f"Updating {len(skills)} skills in {target}/\n")
|
|
144
|
+
|
|
145
|
+
success_count = 0
|
|
146
|
+
for skill in skills:
|
|
147
|
+
if skill.install(target, force=True):
|
|
148
|
+
success_count += 1
|
|
149
|
+
|
|
150
|
+
print(f"\n{success_count}/{len(skills)} skills updated.")
|
|
151
|
+
return 0 if success_count == len(skills) else 1
|
|
152
|
+
|
|
153
|
+
# ── Parser ────────────────────────────────────────────────────────
|
|
154
|
+
|
|
155
|
+
@staticmethod
|
|
156
|
+
def _build_parser() -> argparse.ArgumentParser:
|
|
157
|
+
"""Build the argument parser for the `ak` CLI."""
|
|
158
|
+
parser = argparse.ArgumentParser(
|
|
159
|
+
prog="ak",
|
|
160
|
+
description="Agent Kernel CLI",
|
|
161
|
+
)
|
|
162
|
+
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
|
163
|
+
|
|
164
|
+
# `ak skill` subcommand
|
|
165
|
+
skill_parser = subparsers.add_parser("skill", help="Manage agent skills")
|
|
166
|
+
skill_subparsers = skill_parser.add_subparsers(dest="skill_command", help="Skill commands")
|
|
167
|
+
|
|
168
|
+
# `ak skill list`
|
|
169
|
+
skill_subparsers.add_parser("list", help="List all available skills")
|
|
170
|
+
|
|
171
|
+
# `ak skill info <name>`
|
|
172
|
+
info_parser = skill_subparsers.add_parser("info", help="Show full details for a skill")
|
|
173
|
+
info_parser.add_argument(
|
|
174
|
+
"name",
|
|
175
|
+
help="Skill name to show details for",
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
# `ak skill assistants`
|
|
179
|
+
skill_subparsers.add_parser("assistants", help="List supported coding assistants")
|
|
180
|
+
|
|
181
|
+
# shared --assistant choices
|
|
182
|
+
assistant_names = list(ASSISTANTS.keys())
|
|
183
|
+
|
|
184
|
+
# `ak skill install`
|
|
185
|
+
install_parser = skill_subparsers.add_parser("install", help="Install skills to your project")
|
|
186
|
+
install_parser.add_argument(
|
|
187
|
+
"name",
|
|
188
|
+
nargs="?",
|
|
189
|
+
default=None,
|
|
190
|
+
help="Specific skill name to install (optional)",
|
|
191
|
+
)
|
|
192
|
+
install_group = install_parser.add_mutually_exclusive_group()
|
|
193
|
+
install_group.add_argument(
|
|
194
|
+
"--assistant",
|
|
195
|
+
choices=assistant_names,
|
|
196
|
+
default=DEFAULT_ASSISTANT,
|
|
197
|
+
help=f"Coding assistant to install for (default: {DEFAULT_ASSISTANT})",
|
|
198
|
+
)
|
|
199
|
+
install_group.add_argument(
|
|
200
|
+
"--target",
|
|
201
|
+
default=None,
|
|
202
|
+
help="Custom target directory (overrides --assistant)",
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
# `ak skill update`
|
|
206
|
+
update_parser = skill_subparsers.add_parser("update", help="Update (overwrite) installed skills")
|
|
207
|
+
update_group = update_parser.add_mutually_exclusive_group()
|
|
208
|
+
update_group.add_argument(
|
|
209
|
+
"--assistant",
|
|
210
|
+
choices=assistant_names,
|
|
211
|
+
default=DEFAULT_ASSISTANT,
|
|
212
|
+
help=f"Coding assistant to update for (default: {DEFAULT_ASSISTANT})",
|
|
213
|
+
)
|
|
214
|
+
update_group.add_argument(
|
|
215
|
+
"--target",
|
|
216
|
+
default=None,
|
|
217
|
+
help="Custom target directory (overrides --assistant)",
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
return parser
|
|
221
|
+
|
|
222
|
+
# ── Entry point ───────────────────────────────────────────────────
|
|
223
|
+
|
|
224
|
+
def run(self, argv: list[str] | None = None) -> None:
|
|
225
|
+
"""Parse arguments and dispatch to the appropriate subcommand."""
|
|
226
|
+
args = self._parser.parse_args(argv)
|
|
227
|
+
|
|
228
|
+
if args.command is None:
|
|
229
|
+
self._parser.print_help()
|
|
230
|
+
sys.exit(0)
|
|
231
|
+
|
|
232
|
+
if args.command == "skill":
|
|
233
|
+
if args.skill_command is None:
|
|
234
|
+
self._parser.parse_args(["skill", "--help"])
|
|
235
|
+
sys.exit(0)
|
|
236
|
+
|
|
237
|
+
handlers = {
|
|
238
|
+
"list": self.cmd_skill_list,
|
|
239
|
+
"info": self.cmd_skill_info,
|
|
240
|
+
"assistants": self.cmd_skill_assistants,
|
|
241
|
+
"install": self.cmd_skill_install,
|
|
242
|
+
"update": self.cmd_skill_update,
|
|
243
|
+
}
|
|
244
|
+
handler = handlers.get(args.skill_command)
|
|
245
|
+
if handler:
|
|
246
|
+
sys.exit(handler(args))
|
|
247
|
+
else:
|
|
248
|
+
self._parser.print_help()
|
|
249
|
+
sys.exit(0)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def main() -> None:
|
|
253
|
+
"""Entry point for the `ak` CLI."""
|
|
254
|
+
AK().run()
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
if __name__ == "__main__":
|
|
258
|
+
main()
|
|
@@ -149,7 +149,8 @@ class _TestConfig(BaseModel):
|
|
|
149
149
|
|
|
150
150
|
class _GuardrailParamConfig(BaseModel):
|
|
151
151
|
enabled: bool = Field(default=False, description="Enable Guardrail")
|
|
152
|
-
type: str = Field(default="openai", pattern="^(openai|bedrock)$")
|
|
152
|
+
type: str = Field(default="openai", pattern="^(openai|bedrock|walledai)$")
|
|
153
|
+
pii: bool = Field(default=True, description="Enable PII redaction/unmasking (WalledAI only)")
|
|
153
154
|
config_path: Optional[str] = Field(default=None, description="Path to guardrail configuration file (OpenAI only)")
|
|
154
155
|
model: Optional[str] = Field(default="gpt-4o-mini", description="LLM model name to use for guardrail (OpenAI only)")
|
|
155
156
|
id: Optional[str] = Field(default=None, description="AWS Bedrock guardrail ID (Bedrock only)")
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Generic tool binding support for Agent Kernel.
|
|
3
|
+
|
|
4
|
+
This module provides the ToolBuilder classes that enable framework-agnostic
|
|
5
|
+
tool function definitions.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import contextvars
|
|
9
|
+
import uuid
|
|
10
|
+
from typing import Any, Callable, ClassVar, Self
|
|
11
|
+
|
|
12
|
+
from .base import Agent, AgentRequest, Session
|
|
13
|
+
from .runtime import Runtime
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ToolContext:
|
|
17
|
+
"""
|
|
18
|
+
Execution context for tool functions.
|
|
19
|
+
|
|
20
|
+
Provides access to the execution context of the tool, including the runtime, session, agent,
|
|
21
|
+
and the request being processed. This allows tool functions to interact with the broader
|
|
22
|
+
agent execution environment in a consistent way across different frameworks.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
_context: ClassVar[contextvars.ContextVar[Self | None]] = contextvars.ContextVar("tool_context", default=None)
|
|
26
|
+
_cache: ClassVar[dict[str, Self]] = {}
|
|
27
|
+
|
|
28
|
+
def __init__(self, runtime: Runtime, agent: Agent, session: Session, requests: list[AgentRequest]):
|
|
29
|
+
"""
|
|
30
|
+
Initialize the ToolContext with the given runtime, agent, session, and requests.
|
|
31
|
+
:param runtime: The Runtime instance representing the current execution context.
|
|
32
|
+
:param agent: The Agent instance representing the current agent.
|
|
33
|
+
:param session: The Session instance representing the current session.
|
|
34
|
+
:param requests: The list of AgentRequest instances representing the current requests being processed.
|
|
35
|
+
"""
|
|
36
|
+
self._id = uuid.uuid4().hex
|
|
37
|
+
self._runtime: Runtime = runtime
|
|
38
|
+
self._agent: Agent = agent
|
|
39
|
+
self._session: Session = session
|
|
40
|
+
self._requests: list[AgentRequest] = requests
|
|
41
|
+
self._token: contextvars.Token[Self | None] | None = None
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def id(self) -> str:
|
|
45
|
+
"""
|
|
46
|
+
Get the unique identifier for this ToolContext instance.
|
|
47
|
+
:return: The unique identifier as a string.
|
|
48
|
+
"""
|
|
49
|
+
return self._id
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def runtime(self) -> Runtime:
|
|
53
|
+
"""
|
|
54
|
+
Get the Runtime instance representing the current execution context.
|
|
55
|
+
:return: The current Runtime instance.
|
|
56
|
+
"""
|
|
57
|
+
return self._runtime
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def agent(self) -> Agent:
|
|
61
|
+
"""
|
|
62
|
+
Get the Agent instance representing the current agent.
|
|
63
|
+
:return: The current Agent instance.
|
|
64
|
+
"""
|
|
65
|
+
return self._agent
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def session(self) -> Session:
|
|
69
|
+
"""
|
|
70
|
+
Get the Session instance representing the current session.
|
|
71
|
+
:return: The current Session instance.
|
|
72
|
+
"""
|
|
73
|
+
return self._session
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def requests(self) -> list[AgentRequest]:
|
|
77
|
+
"""
|
|
78
|
+
Get the list of AgentRequest instances representing the current requests being processed.
|
|
79
|
+
:return: The current list of AgentRequest instances.
|
|
80
|
+
"""
|
|
81
|
+
return self._requests
|
|
82
|
+
|
|
83
|
+
@classmethod
|
|
84
|
+
def get(cls) -> Self:
|
|
85
|
+
"""
|
|
86
|
+
Get the current ToolContext instance from the context variable.
|
|
87
|
+
|
|
88
|
+
:return: The current ToolContext instance.
|
|
89
|
+
:raises RuntimeError: If there is no ToolContext set in the current context.
|
|
90
|
+
"""
|
|
91
|
+
context = cls._context.get()
|
|
92
|
+
if context is None:
|
|
93
|
+
raise RuntimeError("No ToolContext is set in the current context")
|
|
94
|
+
return context
|
|
95
|
+
|
|
96
|
+
def set(self) -> Self:
|
|
97
|
+
"""
|
|
98
|
+
Set this ToolContext instance in the context variable.
|
|
99
|
+
"""
|
|
100
|
+
self._token = ToolContext._context.set(self)
|
|
101
|
+
|
|
102
|
+
return self
|
|
103
|
+
|
|
104
|
+
def reset(self) -> None:
|
|
105
|
+
"""
|
|
106
|
+
Reset the context variable to the previous value before this ToolContext was set.
|
|
107
|
+
"""
|
|
108
|
+
if self._token is not None:
|
|
109
|
+
ToolContext._context.reset(self._token)
|
|
110
|
+
self._token = None
|
|
111
|
+
|
|
112
|
+
def __enter__(self) -> Self:
|
|
113
|
+
"""
|
|
114
|
+
Add the ToolContext instance in to the cache.
|
|
115
|
+
"""
|
|
116
|
+
ToolContext._cache[self.id] = self
|
|
117
|
+
return self
|
|
118
|
+
|
|
119
|
+
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
|
|
120
|
+
"""
|
|
121
|
+
Remove the ToolContext instance from the cache.
|
|
122
|
+
"""
|
|
123
|
+
ToolContext._cache.pop(self.id, None)
|
|
124
|
+
|
|
125
|
+
@classmethod
|
|
126
|
+
def fetch(cls, id: str) -> Self:
|
|
127
|
+
"""
|
|
128
|
+
Fetch a cached ToolContext instance by its ID.
|
|
129
|
+
:param id: The unique identifier of the ToolContext instance to fetch.
|
|
130
|
+
:return: The cached ToolContext instance.
|
|
131
|
+
:raises KeyError: If no ToolContext instance is found for the given ID.
|
|
132
|
+
"""
|
|
133
|
+
if id not in cls._cache:
|
|
134
|
+
raise KeyError(f"No ToolContext found for id: {id}")
|
|
135
|
+
return cls._cache[id]
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class ToolBuilder:
|
|
139
|
+
"""
|
|
140
|
+
Base class for framework-specific tool builders.
|
|
141
|
+
|
|
142
|
+
Provides common functionality that bind regular synchronous and asynchronous functions
|
|
143
|
+
into framework specific tool functions. It also makes sure execution context behaves in the
|
|
144
|
+
same manner across different frameworks.
|
|
145
|
+
"""
|
|
146
|
+
|
|
147
|
+
@classmethod
|
|
148
|
+
def bind(cls, funcs: list[Callable]) -> list[Any]:
|
|
149
|
+
"""
|
|
150
|
+
Bind a list of generic tool functions to framework-specific tool definitions.
|
|
151
|
+
|
|
152
|
+
:param funcs: List of generic tool functions to bind.
|
|
153
|
+
:return: List of framework-specific tool definitions.
|
|
154
|
+
:raises NotImplementedError: If called on the base ToolBuilder class.
|
|
155
|
+
"""
|
|
156
|
+
raise NotImplementedError("bind() must be implemented by framework-specific subclasses")
|