blocks-cli 0.1.37__tar.gz → 0.1.39__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.
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/PKG-INFO +1 -1
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/commands/create.py +45 -7
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/commands/push.py +6 -1
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/registration.py +5 -2
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/setup.py +1 -1
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/LICENSE +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/MANIFEST.in +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/README.md +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/__init__.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/api.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/builds.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/bundles.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/commands/__base__.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/commands/__init__.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/commands/configure.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/commands/init.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/commands/test.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/config/__init__.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/config/auth.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/config/config.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/console.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/fs.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli/package.py +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/blocks_cli.egg-info/SOURCES.txt +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/requirements.txt +0 -0
- {blocks-cli-0.1.37 → blocks-cli-0.1.39}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: blocks-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.39
|
|
4
4
|
Summary: CLI tool for Blocks, a platform for writing custom AI-enabled codebase automations in Python. Leverage a full codebase-aware API. Automatically trigger automations from Github, Slack, and other providers.
|
|
5
5
|
Home-page: https://github.com/BlocksOrg/sdk
|
|
6
6
|
Author: BlocksOrg
|
|
@@ -50,19 +50,57 @@ def create(
|
|
|
50
50
|
|
|
51
51
|
# Create main.py with basic template
|
|
52
52
|
with open(automation_dir / 'main.py', 'w') as f:
|
|
53
|
-
f.write('''
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
f.write('''import os
|
|
54
|
+
import slack_sdk
|
|
55
|
+
from enum import Enum
|
|
56
|
+
from blocks import agent, on
|
|
57
|
+
from smolagents import CodeAgent, WebSearchTool, LiteLLMModel
|
|
58
|
+
from pydantic import BaseModel
|
|
59
|
+
|
|
60
|
+
SLACK_TOKEN = os.getenv("SLACK_TOKEN")
|
|
61
|
+
|
|
62
|
+
class Models(str, Enum):
|
|
63
|
+
gpt_5 = "gpt-5"
|
|
64
|
+
claude4sonnet = "claude-sonnet-4-20250514"
|
|
65
|
+
|
|
66
|
+
class SmolAgentConfig(BaseModel):
|
|
67
|
+
model: Models = Models.gpt_5
|
|
68
|
+
|
|
69
|
+
@agent(name="{name}")
|
|
70
|
+
@on("slack.mention")
|
|
71
|
+
def {function_name}(input, config: SmolAgentConfig):
|
|
72
|
+
event = input.get("event")
|
|
73
|
+
text = event.get("text", "")
|
|
74
|
+
channel = event.get("channel", "")
|
|
75
|
+
ts = event.get("ts", "")
|
|
76
|
+
|
|
77
|
+
model = LiteLLMModel(
|
|
78
|
+
model_id=config.model,
|
|
79
|
+
)
|
|
80
|
+
agent = CodeAgent(tools=[WebSearchTool()], model=model)
|
|
81
|
+
agent.run(text)
|
|
82
|
+
|
|
83
|
+
client = slack_sdk.WebClient(token=SLACK_TOKEN)
|
|
84
|
+
client.chat_postMessage(channel=channel, text="Agent is thinking...", thread_ts=ts)
|
|
85
|
+
|
|
86
|
+
for _, step in enumerate(agent.memory.steps):
|
|
87
|
+
messages = step.to_messages()
|
|
88
|
+
for message in messages:
|
|
89
|
+
for content_message in message.content:
|
|
90
|
+
final_message = content_message.get("text", "")
|
|
91
|
+
if final_message and content_message.get("role") != "user":
|
|
92
|
+
client.chat_postMessage(channel=channel, text=final_message, thread_ts=ts)
|
|
59
93
|
'''.format(name=name, function_name=function_name))
|
|
60
94
|
|
|
61
95
|
sdk_version = get_latest_sdk_version()
|
|
62
96
|
latest_version = sdk_version.get("latest_version")
|
|
63
97
|
|
|
64
98
|
with open(automation_dir / 'requirements.txt', 'w') as f:
|
|
65
|
-
f.write('''blocks-sdk>={version}
|
|
99
|
+
f.write('''blocks-sdk>={version}
|
|
100
|
+
smolagents[toolkit]
|
|
101
|
+
litellm>=1.61.16,<=1.74.8
|
|
102
|
+
slack-sdk>=3.19.2
|
|
103
|
+
'''.format(version=latest_version))
|
|
66
104
|
|
|
67
105
|
console.print(f"Successfully created automation [green]{name}[/green] in [green]{automation_dir.absolute()}[/green]")
|
|
68
106
|
console.print(f"[green]{name}/\n main.py\n requirements.txt[/green]")
|
|
@@ -183,6 +183,10 @@ def push(
|
|
|
183
183
|
"task_kwargs": {},
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
# Extract is_agent flag if present
|
|
187
|
+
is_agent = task_kwargs.get("is_agent", False)
|
|
188
|
+
automation_config["is_agent"] = is_agent
|
|
189
|
+
|
|
186
190
|
# Add any additional args that weren't explicitly handled
|
|
187
191
|
additional_task_kwargs = {
|
|
188
192
|
k: v
|
|
@@ -198,7 +202,8 @@ def push(
|
|
|
198
202
|
"config_class",
|
|
199
203
|
"plugins",
|
|
200
204
|
"config_schema",
|
|
201
|
-
"required_env_vars"
|
|
205
|
+
"required_env_vars",
|
|
206
|
+
"is_agent"
|
|
202
207
|
]
|
|
203
208
|
}
|
|
204
209
|
automation_config["trigger_kwargs"] = trigger_kwargs
|
|
@@ -21,12 +21,15 @@ def get_blocks_state_and_module_from_file(file: Path):
|
|
|
21
21
|
automation_module = get_module_from_file(file)
|
|
22
22
|
has_blocks_import = hasattr(automation_module, "blocks")
|
|
23
23
|
has_task_import = hasattr(automation_module, "task")
|
|
24
|
+
has_agent_import = hasattr(automation_module, "agent")
|
|
24
25
|
|
|
25
|
-
if not any([has_blocks_import, has_task_import]):
|
|
26
|
-
raise Exception("No blocks or
|
|
26
|
+
if not any([has_blocks_import, has_task_import, has_agent_import]):
|
|
27
|
+
raise Exception("No blocks, task, or agent import found in the specified file, likely not an automation file.")
|
|
27
28
|
if has_blocks_import:
|
|
28
29
|
state = automation_module.state.dag
|
|
29
30
|
elif has_task_import:
|
|
30
31
|
state = automation_module.task.blocks_state
|
|
32
|
+
elif has_agent_import:
|
|
33
|
+
state = automation_module.agent.blocks_state
|
|
31
34
|
|
|
32
35
|
return state, automation_module
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|