intentkit 0.7.5.dev6__py3-none-any.whl → 0.7.5.dev8__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.
Potentially problematic release.
This version of intentkit might be problematic. Click here for more details.
- intentkit/__init__.py +1 -1
- intentkit/core/agent.py +48 -107
- intentkit/models/agent.py +241 -114
- {intentkit-0.7.5.dev6.dist-info → intentkit-0.7.5.dev8.dist-info}/METADATA +1 -1
- {intentkit-0.7.5.dev6.dist-info → intentkit-0.7.5.dev8.dist-info}/RECORD +7 -7
- {intentkit-0.7.5.dev6.dist-info → intentkit-0.7.5.dev8.dist-info}/WHEEL +0 -0
- {intentkit-0.7.5.dev6.dist-info → intentkit-0.7.5.dev8.dist-info}/licenses/LICENSE +0 -0
intentkit/__init__.py
CHANGED
intentkit/core/agent.py
CHANGED
|
@@ -4,9 +4,6 @@ from datetime import datetime, timedelta, timezone
|
|
|
4
4
|
from decimal import Decimal
|
|
5
5
|
from typing import Any, Dict, List, Optional
|
|
6
6
|
|
|
7
|
-
from aiogram import Bot
|
|
8
|
-
from aiogram.exceptions import TelegramConflictError, TelegramUnauthorizedError
|
|
9
|
-
from aiogram.utils.token import TokenValidationError
|
|
10
7
|
from sqlalchemy import func, select, text, update
|
|
11
8
|
|
|
12
9
|
from intentkit.abstracts.skill import SkillStoreABC
|
|
@@ -16,7 +13,6 @@ from intentkit.models.agent import (
|
|
|
16
13
|
Agent,
|
|
17
14
|
AgentAutonomous,
|
|
18
15
|
AgentCreate,
|
|
19
|
-
AgentResponse,
|
|
20
16
|
AgentTable,
|
|
21
17
|
AgentUpdate,
|
|
22
18
|
)
|
|
@@ -35,103 +31,63 @@ from intentkit.utils.slack_alert import send_slack_message
|
|
|
35
31
|
logger = logging.getLogger(__name__)
|
|
36
32
|
|
|
37
33
|
|
|
38
|
-
async def
|
|
39
|
-
agent: Agent,
|
|
34
|
+
async def process_agent_wallet(
|
|
35
|
+
agent: Agent, old_wallet_provider: str | None = None
|
|
40
36
|
) -> AgentData:
|
|
41
|
-
"""Process
|
|
37
|
+
"""Process agent wallet initialization and validation.
|
|
42
38
|
|
|
43
39
|
Args:
|
|
44
40
|
agent: The agent that was created or updated
|
|
45
|
-
|
|
46
|
-
slack_message: Optional custom message for Slack notification
|
|
41
|
+
old_wallet_provider: Previous wallet provider (None, "cdp", or "readonly")
|
|
47
42
|
|
|
48
43
|
Returns:
|
|
49
44
|
AgentData: The processed agent data
|
|
45
|
+
|
|
46
|
+
Raises:
|
|
47
|
+
IntentKitAPIError: If attempting to change between cdp and readonly providers
|
|
50
48
|
"""
|
|
51
|
-
|
|
49
|
+
current_wallet_provider = agent.wallet_provider
|
|
50
|
+
|
|
51
|
+
# 1. Check if changing between cdp and readonly (not allowed)
|
|
52
|
+
if (
|
|
53
|
+
old_wallet_provider is not None
|
|
54
|
+
and old_wallet_provider != current_wallet_provider
|
|
55
|
+
):
|
|
56
|
+
raise IntentKitAPIError(
|
|
57
|
+
400,
|
|
58
|
+
"WalletProviderChangeNotAllowed",
|
|
59
|
+
"Cannot change wallet provider between cdp and readonly",
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# 2. If wallet provider hasn't changed, return existing agent data
|
|
63
|
+
if (
|
|
64
|
+
old_wallet_provider is not None
|
|
65
|
+
and old_wallet_provider == current_wallet_provider
|
|
66
|
+
):
|
|
67
|
+
return await AgentData.get(agent.id)
|
|
68
|
+
|
|
69
|
+
# 3. For new agents (old_wallet_provider is None), check if wallet already exists
|
|
70
|
+
agent_data = await AgentData.get(agent.id)
|
|
71
|
+
if agent_data.evm_wallet_address:
|
|
72
|
+
return agent_data
|
|
73
|
+
|
|
74
|
+
# 4. Initialize wallet based on provider type
|
|
75
|
+
if config.cdp_api_key_id and current_wallet_provider == "cdp":
|
|
52
76
|
cdp_client = await get_cdp_client(agent.id, agent_store)
|
|
53
77
|
await cdp_client.get_wallet_provider()
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
# FIXME: refuse to change wallet provider
|
|
57
|
-
if agent.wallet_provider == "readonly":
|
|
78
|
+
agent_data = await AgentData.get(agent.id)
|
|
79
|
+
elif current_wallet_provider == "readonly":
|
|
58
80
|
agent_data = await AgentData.patch(
|
|
59
81
|
agent.id,
|
|
60
82
|
{
|
|
61
83
|
"evm_wallet_address": agent.readonly_wallet_address,
|
|
62
84
|
},
|
|
63
85
|
)
|
|
64
|
-
else:
|
|
65
|
-
agent_data = await AgentData.get(agent.id)
|
|
66
|
-
|
|
67
|
-
# Send Slack notification
|
|
68
|
-
slack_message = slack_message or ("Agent Created" if is_new else "Agent Updated")
|
|
69
|
-
try:
|
|
70
|
-
_send_agent_notification(agent, agent_data, slack_message)
|
|
71
|
-
except Exception as e:
|
|
72
|
-
logger.error("Failed to send Slack notification: %s", e)
|
|
73
86
|
|
|
74
87
|
return agent_data
|
|
75
88
|
|
|
76
89
|
|
|
77
|
-
|
|
78
|
-
agent: AgentUpdate, existing_agent: Optional[Agent], agent_data: AgentData
|
|
79
|
-
) -> AgentData:
|
|
80
|
-
"""Process telegram configuration for an agent.
|
|
81
|
-
|
|
82
|
-
Args:
|
|
83
|
-
agent: The agent with telegram configuration
|
|
84
|
-
existing_agent: The existing agent (if updating)
|
|
85
|
-
agent_data: The agent data to update
|
|
86
|
-
|
|
87
|
-
Returns:
|
|
88
|
-
AgentData: The updated agent data
|
|
89
|
-
"""
|
|
90
|
-
changes = agent.model_dump(exclude_unset=True)
|
|
91
|
-
if not changes.get("telegram_entrypoint_enabled"):
|
|
92
|
-
return agent_data
|
|
93
|
-
|
|
94
|
-
if not changes.get("telegram_config") or not changes.get("telegram_config").get(
|
|
95
|
-
"token"
|
|
96
|
-
):
|
|
97
|
-
return agent_data
|
|
98
|
-
|
|
99
|
-
tg_bot_token = changes.get("telegram_config").get("token")
|
|
100
|
-
|
|
101
|
-
if existing_agent and existing_agent.telegram_config.get("token") == tg_bot_token:
|
|
102
|
-
return agent_data
|
|
103
|
-
|
|
104
|
-
try:
|
|
105
|
-
bot = Bot(token=tg_bot_token)
|
|
106
|
-
bot_info = await bot.get_me()
|
|
107
|
-
agent_data.telegram_id = str(bot_info.id)
|
|
108
|
-
agent_data.telegram_username = bot_info.username
|
|
109
|
-
agent_data.telegram_name = bot_info.first_name
|
|
110
|
-
if bot_info.last_name:
|
|
111
|
-
agent_data.telegram_name = f"{bot_info.first_name} {bot_info.last_name}"
|
|
112
|
-
await agent_data.save()
|
|
113
|
-
try:
|
|
114
|
-
await bot.close()
|
|
115
|
-
except Exception:
|
|
116
|
-
pass
|
|
117
|
-
return agent_data
|
|
118
|
-
except (
|
|
119
|
-
TelegramUnauthorizedError,
|
|
120
|
-
TelegramConflictError,
|
|
121
|
-
TokenValidationError,
|
|
122
|
-
) as req_err:
|
|
123
|
-
logger.error(
|
|
124
|
-
f"Unauthorized err getting telegram bot username with token {tg_bot_token}: {req_err}",
|
|
125
|
-
)
|
|
126
|
-
return agent_data
|
|
127
|
-
except Exception as e:
|
|
128
|
-
logger.error(
|
|
129
|
-
f"Error getting telegram bot username with token {tg_bot_token}: {e}",
|
|
130
|
-
)
|
|
131
|
-
return agent_data
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
def _send_agent_notification(agent: Agent, agent_data: AgentData, message: str) -> None:
|
|
90
|
+
def send_agent_notification(agent: Agent, agent_data: AgentData, message: str) -> None:
|
|
135
91
|
"""Send a notification about agent creation or update.
|
|
136
92
|
|
|
137
93
|
Args:
|
|
@@ -239,7 +195,7 @@ def _send_agent_notification(agent: Agent, agent_data: AgentData, message: str)
|
|
|
239
195
|
|
|
240
196
|
async def deploy_agent(
|
|
241
197
|
agent_id: str, agent: AgentUpdate, owner: Optional[str] = None
|
|
242
|
-
) ->
|
|
198
|
+
) -> Agent:
|
|
243
199
|
"""Override an existing agent.
|
|
244
200
|
|
|
245
201
|
Use input to override agent configuration. If some fields are not provided, they will be reset to default values.
|
|
@@ -250,7 +206,7 @@ async def deploy_agent(
|
|
|
250
206
|
owner: Optional owner for the agent
|
|
251
207
|
|
|
252
208
|
Returns:
|
|
253
|
-
|
|
209
|
+
Agent: Updated agent configuration
|
|
254
210
|
|
|
255
211
|
Raises:
|
|
256
212
|
HTTPException:
|
|
@@ -261,29 +217,21 @@ async def deploy_agent(
|
|
|
261
217
|
"""
|
|
262
218
|
existing_agent = await Agent.get(agent_id)
|
|
263
219
|
if not existing_agent:
|
|
264
|
-
|
|
265
|
-
|
|
220
|
+
new_agent = AgentCreate.model_validate(agent)
|
|
221
|
+
new_agent.id = agent_id
|
|
266
222
|
if owner:
|
|
267
|
-
|
|
223
|
+
new_agent.owner = owner
|
|
268
224
|
else:
|
|
269
|
-
|
|
225
|
+
new_agent.owner = "system"
|
|
270
226
|
# Check for existing agent by upstream_id, forward compatibility, raise error after 3.0
|
|
271
|
-
existing = await
|
|
227
|
+
existing = await new_agent.get_by_upstream_id()
|
|
272
228
|
if existing:
|
|
273
|
-
|
|
274
|
-
agent_response = await AgentResponse.from_agent(existing, agent_data)
|
|
275
|
-
return agent_response
|
|
229
|
+
return existing
|
|
276
230
|
|
|
277
231
|
# Create new agent
|
|
278
|
-
latest_agent = await
|
|
279
|
-
# Process common post-creation actions
|
|
280
|
-
agent_data = await _process_agent_post_actions(
|
|
281
|
-
latest_agent, True, "Agent Created"
|
|
282
|
-
)
|
|
283
|
-
agent_data = await _process_telegram_config(input, None, agent_data)
|
|
284
|
-
agent_response = await AgentResponse.from_agent(latest_agent, agent_data)
|
|
232
|
+
latest_agent = await new_agent.create()
|
|
285
233
|
|
|
286
|
-
return
|
|
234
|
+
return latest_agent
|
|
287
235
|
|
|
288
236
|
if owner and owner != existing_agent.owner:
|
|
289
237
|
raise IntentKitAPIError(403, "Forbidden", "forbidden")
|
|
@@ -291,14 +239,7 @@ async def deploy_agent(
|
|
|
291
239
|
# Update agent
|
|
292
240
|
latest_agent = await agent.override(agent_id)
|
|
293
241
|
|
|
294
|
-
|
|
295
|
-
agent_data = await _process_agent_post_actions(
|
|
296
|
-
latest_agent, False, "Agent Overridden"
|
|
297
|
-
)
|
|
298
|
-
agent_data = await _process_telegram_config(agent, existing_agent, agent_data)
|
|
299
|
-
agent_response = await AgentResponse.from_agent(latest_agent, agent_data)
|
|
300
|
-
|
|
301
|
-
return agent_response
|
|
242
|
+
return latest_agent
|
|
302
243
|
|
|
303
244
|
|
|
304
245
|
async def agent_action_cost(agent_id: str) -> Dict[str, Decimal]:
|
intentkit/models/agent.py
CHANGED
|
@@ -22,6 +22,7 @@ from intentkit.utils.error import IntentKitAPIError
|
|
|
22
22
|
from pydantic import BaseModel, ConfigDict, field_validator
|
|
23
23
|
from pydantic import Field as PydanticField
|
|
24
24
|
from pydantic.json_schema import SkipJsonSchema
|
|
25
|
+
from pydantic.main import IncEx
|
|
25
26
|
from sqlalchemy import (
|
|
26
27
|
Boolean,
|
|
27
28
|
Column,
|
|
@@ -1257,20 +1258,22 @@ class Agent(AgentCreate, AgentPublicInfo):
|
|
|
1257
1258
|
yaml_lines.append(indented_yaml.rstrip())
|
|
1258
1259
|
elif hasattr(value, "model_dump"):
|
|
1259
1260
|
# Handle individual Pydantic model
|
|
1260
|
-
|
|
1261
|
+
yaml_lines.append(f"{field_name}:")
|
|
1261
1262
|
yaml_value = yaml.dump(
|
|
1262
|
-
|
|
1263
|
+
value.model_dump(exclude_none=True),
|
|
1263
1264
|
default_flow_style=False,
|
|
1264
1265
|
allow_unicode=True,
|
|
1265
1266
|
)
|
|
1266
|
-
yaml_lines
|
|
1267
|
+
# Indent all lines and append to yaml_lines
|
|
1268
|
+
indented_yaml = "\n".join(
|
|
1269
|
+
f" {line}" for line in yaml_value.split("\n") if line.strip()
|
|
1270
|
+
)
|
|
1271
|
+
yaml_lines.append(indented_yaml)
|
|
1267
1272
|
else:
|
|
1268
|
-
# Handle Decimal
|
|
1273
|
+
# Handle Decimal and other types
|
|
1269
1274
|
if isinstance(value, Decimal):
|
|
1270
|
-
|
|
1271
|
-
yaml_lines.append(f"{field_name}: {value}")
|
|
1275
|
+
yaml_lines.append(f"{field_name}: {str(value)}")
|
|
1272
1276
|
else:
|
|
1273
|
-
# Handle other non-string values
|
|
1274
1277
|
yaml_value = yaml.dump(
|
|
1275
1278
|
{field_name: value},
|
|
1276
1279
|
default_flow_style=False,
|
|
@@ -1495,68 +1498,111 @@ class Agent(AgentCreate, AgentPublicInfo):
|
|
|
1495
1498
|
|
|
1496
1499
|
|
|
1497
1500
|
class AgentResponse(Agent):
|
|
1498
|
-
"""
|
|
1501
|
+
"""Agent response model that excludes sensitive fields from JSON output and schema."""
|
|
1499
1502
|
|
|
1500
1503
|
model_config = ConfigDict(
|
|
1501
|
-
|
|
1504
|
+
title="AgentPublic",
|
|
1502
1505
|
from_attributes=True,
|
|
1503
|
-
json_encoders={
|
|
1504
|
-
|
|
1505
|
-
},
|
|
1506
|
+
# json_encoders={
|
|
1507
|
+
# datetime: lambda v: v.isoformat(timespec="milliseconds"),
|
|
1508
|
+
# },
|
|
1506
1509
|
)
|
|
1507
1510
|
|
|
1508
|
-
#
|
|
1511
|
+
# Override privacy fields to exclude them from JSON schema
|
|
1512
|
+
purpose: Annotated[Optional[str], SkipJsonSchema] = None
|
|
1513
|
+
personality: Annotated[Optional[str], SkipJsonSchema] = None
|
|
1514
|
+
principles: Annotated[Optional[str], SkipJsonSchema] = None
|
|
1515
|
+
prompt: Annotated[Optional[str], SkipJsonSchema] = None
|
|
1516
|
+
prompt_append: Annotated[Optional[str], SkipJsonSchema] = None
|
|
1517
|
+
temperature: Annotated[Optional[float], SkipJsonSchema] = None
|
|
1518
|
+
frequency_penalty: Annotated[Optional[float], SkipJsonSchema] = None
|
|
1519
|
+
telegram_entrypoint_prompt: Annotated[Optional[str], SkipJsonSchema] = None
|
|
1520
|
+
telegram_config: Annotated[Optional[dict], SkipJsonSchema] = None
|
|
1521
|
+
xmtp_entrypoint_prompt: Annotated[Optional[str], SkipJsonSchema] = None
|
|
1522
|
+
|
|
1523
|
+
# Additional fields specific to AgentResponse
|
|
1509
1524
|
cdp_wallet_address: Annotated[
|
|
1510
|
-
Optional[str],
|
|
1525
|
+
Optional[str],
|
|
1526
|
+
PydanticField(
|
|
1527
|
+
default=None,
|
|
1528
|
+
description="CDP wallet address of the agent",
|
|
1529
|
+
),
|
|
1511
1530
|
]
|
|
1512
1531
|
evm_wallet_address: Annotated[
|
|
1513
|
-
Optional[str],
|
|
1532
|
+
Optional[str],
|
|
1533
|
+
PydanticField(
|
|
1534
|
+
default=None,
|
|
1535
|
+
description="EVM wallet address of the agent",
|
|
1536
|
+
),
|
|
1514
1537
|
]
|
|
1515
1538
|
solana_wallet_address: Annotated[
|
|
1516
|
-
Optional[str],
|
|
1539
|
+
Optional[str],
|
|
1540
|
+
PydanticField(
|
|
1541
|
+
default=None,
|
|
1542
|
+
description="Solana wallet address of the agent",
|
|
1543
|
+
),
|
|
1517
1544
|
]
|
|
1518
1545
|
has_twitter_linked: Annotated[
|
|
1519
1546
|
bool,
|
|
1520
|
-
PydanticField(
|
|
1547
|
+
PydanticField(
|
|
1548
|
+
default=False,
|
|
1549
|
+
description="Whether the agent has Twitter linked",
|
|
1550
|
+
),
|
|
1521
1551
|
]
|
|
1522
1552
|
linked_twitter_username: Annotated[
|
|
1523
1553
|
Optional[str],
|
|
1524
|
-
PydanticField(
|
|
1554
|
+
PydanticField(
|
|
1555
|
+
default=None,
|
|
1556
|
+
description="Linked Twitter username",
|
|
1557
|
+
),
|
|
1525
1558
|
]
|
|
1526
1559
|
linked_twitter_name: Annotated[
|
|
1527
1560
|
Optional[str],
|
|
1528
|
-
PydanticField(
|
|
1561
|
+
PydanticField(
|
|
1562
|
+
default=None,
|
|
1563
|
+
description="Linked Twitter display name",
|
|
1564
|
+
),
|
|
1529
1565
|
]
|
|
1530
1566
|
has_twitter_self_key: Annotated[
|
|
1531
1567
|
bool,
|
|
1532
1568
|
PydanticField(
|
|
1533
|
-
|
|
1569
|
+
default=False,
|
|
1570
|
+
description="Whether the agent has Twitter self key",
|
|
1534
1571
|
),
|
|
1535
1572
|
]
|
|
1536
1573
|
has_telegram_self_key: Annotated[
|
|
1537
1574
|
bool,
|
|
1538
1575
|
PydanticField(
|
|
1539
|
-
|
|
1576
|
+
default=False,
|
|
1577
|
+
description="Whether the agent has Telegram self key",
|
|
1540
1578
|
),
|
|
1541
1579
|
]
|
|
1542
1580
|
linked_telegram_username: Annotated[
|
|
1543
1581
|
Optional[str],
|
|
1544
|
-
PydanticField(
|
|
1582
|
+
PydanticField(
|
|
1583
|
+
default=None,
|
|
1584
|
+
description="Linked Telegram username",
|
|
1585
|
+
),
|
|
1545
1586
|
]
|
|
1546
1587
|
linked_telegram_name: Annotated[
|
|
1547
1588
|
Optional[str],
|
|
1548
|
-
PydanticField(
|
|
1589
|
+
PydanticField(
|
|
1590
|
+
default=None,
|
|
1591
|
+
description="Linked Telegram display name",
|
|
1592
|
+
),
|
|
1549
1593
|
]
|
|
1550
1594
|
accept_image_input: Annotated[
|
|
1551
1595
|
bool,
|
|
1552
1596
|
PydanticField(
|
|
1553
|
-
|
|
1597
|
+
default=False,
|
|
1598
|
+
description="Whether the agent accepts image input",
|
|
1554
1599
|
),
|
|
1555
1600
|
]
|
|
1556
1601
|
accept_image_input_private: Annotated[
|
|
1557
1602
|
bool,
|
|
1558
1603
|
PydanticField(
|
|
1559
|
-
|
|
1604
|
+
default=False,
|
|
1605
|
+
description="Whether the agent accepts image input in private mode",
|
|
1560
1606
|
),
|
|
1561
1607
|
]
|
|
1562
1608
|
|
|
@@ -1589,76 +1635,6 @@ class AgentResponse(Agent):
|
|
|
1589
1635
|
Returns:
|
|
1590
1636
|
AgentResponse: Response model with additional processed data
|
|
1591
1637
|
"""
|
|
1592
|
-
# Get base data from agent
|
|
1593
|
-
data = agent.model_dump()
|
|
1594
|
-
|
|
1595
|
-
# Hide the sensitive fields
|
|
1596
|
-
data.pop("purpose", None)
|
|
1597
|
-
data.pop("personality", None)
|
|
1598
|
-
data.pop("principles", None)
|
|
1599
|
-
data.pop("prompt", None)
|
|
1600
|
-
data.pop("prompt_append", None)
|
|
1601
|
-
data.pop("temperature", None)
|
|
1602
|
-
data.pop("frequency_penalty", None)
|
|
1603
|
-
data.pop("telegram_entrypoint_prompt", None)
|
|
1604
|
-
data.pop("telegram_config", None)
|
|
1605
|
-
data.pop("xmtp_entrypoint_prompt", None)
|
|
1606
|
-
|
|
1607
|
-
# Filter sensitive fields from autonomous list
|
|
1608
|
-
if data.get("autonomous"):
|
|
1609
|
-
filtered_autonomous = []
|
|
1610
|
-
for item in data["autonomous"]:
|
|
1611
|
-
if isinstance(item, dict):
|
|
1612
|
-
# Create proper AgentAutonomous instance with only public fields
|
|
1613
|
-
filtered_autonomous.append(
|
|
1614
|
-
AgentAutonomous(
|
|
1615
|
-
id=item.get("id"),
|
|
1616
|
-
name=item.get("name"),
|
|
1617
|
-
enabled=item.get("enabled"),
|
|
1618
|
-
# Set required prompt field to empty string for public view
|
|
1619
|
-
prompt="",
|
|
1620
|
-
)
|
|
1621
|
-
)
|
|
1622
|
-
data["autonomous"] = filtered_autonomous
|
|
1623
|
-
|
|
1624
|
-
# Convert examples dictionaries to AgentExample instances
|
|
1625
|
-
if data.get("examples"):
|
|
1626
|
-
examples_list = []
|
|
1627
|
-
for item in data["examples"]:
|
|
1628
|
-
if isinstance(item, dict):
|
|
1629
|
-
# Create proper AgentExample instance
|
|
1630
|
-
examples_list.append(
|
|
1631
|
-
AgentExample(
|
|
1632
|
-
name=item.get("name", ""),
|
|
1633
|
-
description=item.get("description", ""),
|
|
1634
|
-
prompt=item.get("prompt", ""),
|
|
1635
|
-
)
|
|
1636
|
-
)
|
|
1637
|
-
data["examples"] = examples_list
|
|
1638
|
-
|
|
1639
|
-
# Filter sensitive fields from skills dictionary
|
|
1640
|
-
if data.get("skills"):
|
|
1641
|
-
filtered_skills = {}
|
|
1642
|
-
for skill_name, skill_config in data["skills"].items():
|
|
1643
|
-
if isinstance(skill_config, dict):
|
|
1644
|
-
# Only include skills that are enabled
|
|
1645
|
-
if skill_config.get("enabled") is True:
|
|
1646
|
-
filtered_config = {"enabled": True}
|
|
1647
|
-
# Only keep states with public or private values
|
|
1648
|
-
if "states" in skill_config and isinstance(
|
|
1649
|
-
skill_config["states"], dict
|
|
1650
|
-
):
|
|
1651
|
-
filtered_states = {}
|
|
1652
|
-
for state_key, state_value in skill_config[
|
|
1653
|
-
"states"
|
|
1654
|
-
].items():
|
|
1655
|
-
if state_value in ["public", "private"]:
|
|
1656
|
-
filtered_states[state_key] = state_value
|
|
1657
|
-
if filtered_states:
|
|
1658
|
-
filtered_config["states"] = filtered_states
|
|
1659
|
-
filtered_skills[skill_name] = filtered_config
|
|
1660
|
-
data["skills"] = filtered_skills
|
|
1661
|
-
|
|
1662
1638
|
# Process CDP wallet address
|
|
1663
1639
|
cdp_wallet_address = agent_data.evm_wallet_address if agent_data else None
|
|
1664
1640
|
evm_wallet_address = agent_data.evm_wallet_address if agent_data else None
|
|
@@ -1684,10 +1660,10 @@ class AgentResponse(Agent):
|
|
|
1684
1660
|
agent_data and agent_data.twitter_self_key_refreshed_at
|
|
1685
1661
|
)
|
|
1686
1662
|
|
|
1687
|
-
# Process Telegram self-key status
|
|
1663
|
+
# Process Telegram self-key status
|
|
1688
1664
|
linked_telegram_username = None
|
|
1689
1665
|
linked_telegram_name = None
|
|
1690
|
-
telegram_config =
|
|
1666
|
+
telegram_config = agent.telegram_config or {}
|
|
1691
1667
|
has_telegram_self_key = bool(
|
|
1692
1668
|
telegram_config and "token" in telegram_config and telegram_config["token"]
|
|
1693
1669
|
)
|
|
@@ -1704,22 +1680,173 @@ class AgentResponse(Agent):
|
|
|
1704
1680
|
or agent.has_image_parser_skill(is_private=True)
|
|
1705
1681
|
)
|
|
1706
1682
|
|
|
1707
|
-
#
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1683
|
+
# Create AgentResponse instance directly from agent with additional fields
|
|
1684
|
+
return cls(
|
|
1685
|
+
# Copy all fields from agent
|
|
1686
|
+
**agent.model_dump(),
|
|
1687
|
+
# Add computed fields
|
|
1688
|
+
cdp_wallet_address=cdp_wallet_address,
|
|
1689
|
+
evm_wallet_address=evm_wallet_address,
|
|
1690
|
+
solana_wallet_address=solana_wallet_address,
|
|
1691
|
+
has_twitter_linked=has_twitter_linked,
|
|
1692
|
+
linked_twitter_username=linked_twitter_username,
|
|
1693
|
+
linked_twitter_name=linked_twitter_name,
|
|
1694
|
+
has_twitter_self_key=has_twitter_self_key,
|
|
1695
|
+
has_telegram_self_key=has_telegram_self_key,
|
|
1696
|
+
linked_telegram_username=linked_telegram_username,
|
|
1697
|
+
linked_telegram_name=linked_telegram_name,
|
|
1698
|
+
accept_image_input=accept_image_input,
|
|
1699
|
+
accept_image_input_private=accept_image_input_private,
|
|
1700
|
+
)
|
|
1701
|
+
|
|
1702
|
+
def model_dump(
|
|
1703
|
+
self,
|
|
1704
|
+
*,
|
|
1705
|
+
mode: str | Literal["json", "python"] = "python",
|
|
1706
|
+
include: IncEx | None = None,
|
|
1707
|
+
exclude: IncEx | None = None,
|
|
1708
|
+
context: Any | None = None,
|
|
1709
|
+
by_alias: bool = False,
|
|
1710
|
+
exclude_unset: bool = False,
|
|
1711
|
+
exclude_defaults: bool = False,
|
|
1712
|
+
exclude_none: bool = False,
|
|
1713
|
+
round_trip: bool = False,
|
|
1714
|
+
warnings: bool | Literal["none", "warn", "error"] = True,
|
|
1715
|
+
serialize_as_any: bool = False,
|
|
1716
|
+
) -> dict[str, Any]:
|
|
1717
|
+
"""Override model_dump to exclude privacy fields and filter data."""
|
|
1718
|
+
# Get the base model dump
|
|
1719
|
+
data = super().model_dump(
|
|
1720
|
+
mode=mode,
|
|
1721
|
+
include=include,
|
|
1722
|
+
exclude=exclude,
|
|
1723
|
+
context=context,
|
|
1724
|
+
by_alias=by_alias,
|
|
1725
|
+
exclude_unset=exclude_unset,
|
|
1726
|
+
exclude_defaults=exclude_defaults,
|
|
1727
|
+
exclude_none=exclude_none,
|
|
1728
|
+
round_trip=round_trip,
|
|
1729
|
+
warnings=warnings,
|
|
1730
|
+
serialize_as_any=serialize_as_any,
|
|
1731
|
+
)
|
|
1732
|
+
|
|
1733
|
+
# Remove privacy fields that might still be present
|
|
1734
|
+
privacy_fields = {
|
|
1735
|
+
"purpose",
|
|
1736
|
+
"personality",
|
|
1737
|
+
"principles",
|
|
1738
|
+
"prompt",
|
|
1739
|
+
"prompt_append",
|
|
1740
|
+
"temperature",
|
|
1741
|
+
"frequency_penalty",
|
|
1742
|
+
"telegram_entrypoint_prompt",
|
|
1743
|
+
"telegram_config",
|
|
1744
|
+
"xmtp_entrypoint_prompt",
|
|
1745
|
+
}
|
|
1746
|
+
for field in privacy_fields:
|
|
1747
|
+
data.pop(field, None)
|
|
1748
|
+
|
|
1749
|
+
# Filter autonomous list to only keep safe fields
|
|
1750
|
+
if "autonomous" in data and data["autonomous"]:
|
|
1751
|
+
filtered_autonomous = []
|
|
1752
|
+
for item in data["autonomous"]:
|
|
1753
|
+
if isinstance(item, dict):
|
|
1754
|
+
# Only keep safe fields: id, name, description, enabled
|
|
1755
|
+
filtered_item = {
|
|
1756
|
+
key: item[key]
|
|
1757
|
+
for key in ["id", "name", "description", "enabled"]
|
|
1758
|
+
if key in item
|
|
1759
|
+
}
|
|
1760
|
+
filtered_autonomous.append(filtered_item)
|
|
1761
|
+
else:
|
|
1762
|
+
# Handle AgentAutonomous objects
|
|
1763
|
+
item_dict = (
|
|
1764
|
+
item.model_dump() if hasattr(item, "model_dump") else dict(item)
|
|
1765
|
+
)
|
|
1766
|
+
# Only keep safe fields: id, name, description, enabled
|
|
1767
|
+
filtered_item = {
|
|
1768
|
+
key: item_dict[key]
|
|
1769
|
+
for key in ["id", "name", "description", "enabled"]
|
|
1770
|
+
if key in item_dict
|
|
1771
|
+
}
|
|
1772
|
+
filtered_autonomous.append(filtered_item)
|
|
1773
|
+
data["autonomous"] = filtered_autonomous
|
|
1774
|
+
|
|
1775
|
+
# Convert examples to AgentExample instances if they're dictionaries
|
|
1776
|
+
if "examples" in data and data["examples"]:
|
|
1777
|
+
converted_examples = []
|
|
1778
|
+
for example in data["examples"]:
|
|
1779
|
+
if isinstance(example, dict):
|
|
1780
|
+
converted_examples.append(AgentExample(**example).model_dump())
|
|
1781
|
+
else:
|
|
1782
|
+
converted_examples.append(
|
|
1783
|
+
example.model_dump()
|
|
1784
|
+
if hasattr(example, "model_dump")
|
|
1785
|
+
else example
|
|
1786
|
+
)
|
|
1787
|
+
data["examples"] = converted_examples
|
|
1788
|
+
|
|
1789
|
+
# Filter skills to only include enabled ones with specific configurations
|
|
1790
|
+
if "skills" in data and data["skills"]:
|
|
1791
|
+
filtered_skills = {}
|
|
1792
|
+
for skill_name, skill_config in data["skills"].items():
|
|
1793
|
+
if (
|
|
1794
|
+
isinstance(skill_config, dict)
|
|
1795
|
+
and skill_config.get("enabled") is True
|
|
1796
|
+
):
|
|
1797
|
+
# Filter out disabled states from the skill configuration
|
|
1798
|
+
original_states = skill_config.get("states", {})
|
|
1799
|
+
filtered_states = {
|
|
1800
|
+
state_name: state_value
|
|
1801
|
+
for state_name, state_value in original_states.items()
|
|
1802
|
+
if state_value != "disabled"
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
# Only include the skill if it has at least one non-disabled state
|
|
1806
|
+
if filtered_states:
|
|
1807
|
+
filtered_config = {
|
|
1808
|
+
"enabled": skill_config["enabled"],
|
|
1809
|
+
"states": filtered_states,
|
|
1810
|
+
}
|
|
1811
|
+
# Add other non-sensitive config fields if needed
|
|
1812
|
+
for key in ["public", "private"]:
|
|
1813
|
+
if key in skill_config:
|
|
1814
|
+
filtered_config[key] = skill_config[key]
|
|
1815
|
+
filtered_skills[skill_name] = filtered_config
|
|
1816
|
+
data["skills"] = filtered_skills
|
|
1817
|
+
|
|
1818
|
+
return data
|
|
1819
|
+
|
|
1820
|
+
def model_dump_json(
|
|
1821
|
+
self,
|
|
1822
|
+
*,
|
|
1823
|
+
indent: int | str | None = None,
|
|
1824
|
+
include: IncEx | None = None,
|
|
1825
|
+
exclude: IncEx | None = None,
|
|
1826
|
+
context: Any | None = None,
|
|
1827
|
+
by_alias: bool = False,
|
|
1828
|
+
exclude_unset: bool = False,
|
|
1829
|
+
exclude_defaults: bool = False,
|
|
1830
|
+
exclude_none: bool = False,
|
|
1831
|
+
round_trip: bool = False,
|
|
1832
|
+
warnings: bool | Literal["none", "warn", "error"] = True,
|
|
1833
|
+
serialize_as_any: bool = False,
|
|
1834
|
+
) -> str:
|
|
1835
|
+
"""Override model_dump_json to exclude privacy fields and filter sensitive data."""
|
|
1836
|
+
# Get the filtered data using the same logic as model_dump
|
|
1837
|
+
data = self.model_dump(
|
|
1838
|
+
mode="json",
|
|
1839
|
+
include=include,
|
|
1840
|
+
exclude=exclude,
|
|
1841
|
+
context=context,
|
|
1842
|
+
by_alias=by_alias,
|
|
1843
|
+
exclude_unset=exclude_unset,
|
|
1844
|
+
exclude_defaults=exclude_defaults,
|
|
1845
|
+
exclude_none=exclude_none,
|
|
1846
|
+
round_trip=round_trip,
|
|
1847
|
+
warnings=warnings,
|
|
1848
|
+
serialize_as_any=serialize_as_any,
|
|
1723
1849
|
)
|
|
1724
1850
|
|
|
1725
|
-
|
|
1851
|
+
# Use json.dumps to serialize the filtered data with proper indentation
|
|
1852
|
+
return json.dumps(data, indent=indent, ensure_ascii=False)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: intentkit
|
|
3
|
-
Version: 0.7.5.
|
|
3
|
+
Version: 0.7.5.dev8
|
|
4
4
|
Summary: Intent-based AI Agent Platform - Core Package
|
|
5
5
|
Project-URL: Homepage, https://github.com/crestalnetwork/intentkit
|
|
6
6
|
Project-URL: Repository, https://github.com/crestalnetwork/intentkit
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
intentkit/__init__.py,sha256=
|
|
1
|
+
intentkit/__init__.py,sha256=Gm9kCv3JF6RqzKvr67-s5ZMqXt-C4r66bA_y3LPt0BA,383
|
|
2
2
|
intentkit/abstracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
intentkit/abstracts/agent.py,sha256=108gb5W8Q1Sy4G55F2_ZFv2-_CnY76qrBtpIr0Oxxqk,1489
|
|
4
4
|
intentkit/abstracts/api.py,sha256=ZUc24vaQvQVbbjznx7bV0lbbQxdQPfEV8ZxM2R6wZWo,166
|
|
@@ -13,7 +13,7 @@ intentkit/clients/web3.py,sha256=A-w4vBPXHpDh8svsEFj_LkmvRgoDTZw4E-84S-UC9ws,102
|
|
|
13
13
|
intentkit/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
intentkit/config/config.py,sha256=xDbm5KSXt4rZh2Nak0bmrYv5Rf__mJz8aJ9PHzar-Lk,8941
|
|
15
15
|
intentkit/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
-
intentkit/core/agent.py,sha256=
|
|
16
|
+
intentkit/core/agent.py,sha256=eLUQnVgMA7y-785kqRqPNE76wWVtYSuy-HfII5w7cXs,29453
|
|
17
17
|
intentkit/core/api.py,sha256=WfoaHNquujYJIpNPuTR1dSaaxog0S3X2W4lG9Ehmkm4,3284
|
|
18
18
|
intentkit/core/chat.py,sha256=YN20CnDazWLjiOZFOHgV6uHmA2DKkvPCsD5Q5sfNcZg,1685
|
|
19
19
|
intentkit/core/client.py,sha256=J5K7f08-ucszBKAbn9K3QNOFKIC__7amTbKYii1jFkI,3056
|
|
@@ -21,7 +21,7 @@ intentkit/core/credit.py,sha256=b4f4T6G6eeBTMe0L_r8awWtXgUnqiog4IUaymDPYym0,7558
|
|
|
21
21
|
intentkit/core/engine.py,sha256=mnsaQqRz1NBgg5Tc0vynDCLwn4G_fbpvCbuVv-7Q15g,36165
|
|
22
22
|
intentkit/core/node.py,sha256=7h9zgDSd928bzUi3m3EZnKkhbwqlbRAQUr_uz7gKB5Y,8880
|
|
23
23
|
intentkit/core/prompt.py,sha256=ssiyKHDNIjQOLU0KwUlIFX3jy51TqgeKOxrwnW4HBkw,15875
|
|
24
|
-
intentkit/models/agent.py,sha256=
|
|
24
|
+
intentkit/models/agent.py,sha256=PgNNa9QqmqAEOqvJoIZxGWE-JrgFAe3VEdD0EUgaZSM,67182
|
|
25
25
|
intentkit/models/agent_data.py,sha256=5zq3EPKnygT2P1OHc2IfEmL8hXkjeBND6sJ0JJsvQJg,28370
|
|
26
26
|
intentkit/models/agent_public.json,sha256=0X8Bd2WOobDJLsok8avWNzmzu4uvKSGEyy6Myn53eT4,2802
|
|
27
27
|
intentkit/models/agent_schema.json,sha256=hFGUE57JIiN8V4olgLf2LBXPejA2QLiQoFc6riM1UFo,17139
|
|
@@ -418,7 +418,7 @@ intentkit/utils/random.py,sha256=DymMxu9g0kuQLgJUqalvgksnIeLdS-v0aRk5nQU0mLI,452
|
|
|
418
418
|
intentkit/utils/s3.py,sha256=9trQNkKQ5VgxWsewVsV8Y0q_pXzGRvsCYP8xauyUYkg,8549
|
|
419
419
|
intentkit/utils/slack_alert.py,sha256=s7UpRgyzLW7Pbmt8cKzTJgMA9bm4EP-1rQ5KXayHu6E,2264
|
|
420
420
|
intentkit/utils/tx.py,sha256=2yLLGuhvfBEY5n_GJ8wmIWLCzn0FsYKv5kRNzw_sLUI,1454
|
|
421
|
-
intentkit-0.7.5.
|
|
422
|
-
intentkit-0.7.5.
|
|
423
|
-
intentkit-0.7.5.
|
|
424
|
-
intentkit-0.7.5.
|
|
421
|
+
intentkit-0.7.5.dev8.dist-info/METADATA,sha256=mO4A4R9i7xMY7UZHPINFnV1vroR3zDqSfryXTSHfHms,6409
|
|
422
|
+
intentkit-0.7.5.dev8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
423
|
+
intentkit-0.7.5.dev8.dist-info/licenses/LICENSE,sha256=Bln6DhK-LtcO4aXy-PBcdZv2f24MlJFm_qn222biJtE,1071
|
|
424
|
+
intentkit-0.7.5.dev8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|