ironshell 1.5.1__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.
@@ -0,0 +1,349 @@
1
+ Metadata-Version: 2.4
2
+ Name: ironshell
3
+ Version: 1.5.1
4
+ Summary: IronShell - AI-powered typed shell with workflow orchestration and cloud deployment
5
+ Author-email: nervosys <contact@nervosys.ai>
6
+ License: AGPL-3.0-or-later
7
+ Project-URL: Homepage, https://github.com/nervosys/IronShell
8
+ Project-URL: Documentation, https://github.com/nervosys/IronShell/blob/master/integrations/python/README.md
9
+ Project-URL: Repository, https://github.com/nervosys/IronShell
10
+ Project-URL: Issues, https://github.com/nervosys/IronShell/issues
11
+ Keywords: shell,ai,agent,pipeline,llm,automation,workflow,serverless,cloud
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Interpreters
21
+ Classifier: Topic :: System :: Shells
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: System :: Distributed Computing
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ Requires-Dist: typing-extensions>=4.0
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=7.0; extra == "dev"
29
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
30
+ Requires-Dist: black>=23.0; extra == "dev"
31
+ Requires-Dist: mypy>=1.0; extra == "dev"
32
+ Requires-Dist: ruff>=0.1; extra == "dev"
33
+ Provides-Extra: langchain
34
+ Requires-Dist: langchain>=0.1; extra == "langchain"
35
+ Requires-Dist: pydantic>=2.0; extra == "langchain"
36
+ Provides-Extra: llamaindex
37
+ Requires-Dist: llama-index>=0.10; extra == "llamaindex"
38
+ Provides-Extra: cloud
39
+ Requires-Dist: boto3>=1.28.0; extra == "cloud"
40
+ Requires-Dist: azure-functions>=1.15.0; extra == "cloud"
41
+ Requires-Dist: functions-framework>=3.0; extra == "cloud"
42
+ Requires-Dist: fastapi>=0.100.0; extra == "cloud"
43
+ Requires-Dist: uvicorn>=0.23.0; extra == "cloud"
44
+ Provides-Extra: all
45
+ Requires-Dist: langchain>=0.1; extra == "all"
46
+ Requires-Dist: pydantic>=2.0; extra == "all"
47
+ Requires-Dist: llama-index>=0.10; extra == "all"
48
+ Requires-Dist: boto3>=1.28.0; extra == "all"
49
+ Requires-Dist: azure-functions>=1.15.0; extra == "all"
50
+ Requires-Dist: functions-framework>=3.0; extra == "all"
51
+ Requires-Dist: fastapi>=0.100.0; extra == "all"
52
+ Requires-Dist: uvicorn>=0.23.0; extra == "all"
53
+
54
+ # IronShell Python SDK
55
+
56
+ Python bindings for IronShell - AI-powered typed shell with workflow orchestration and cloud deployment.
57
+
58
+ ## Installation
59
+
60
+ ```bash
61
+ # Core SDK
62
+ pip install ironshell
63
+
64
+ # With LangChain integration
65
+ pip install ironshell[langchain]
66
+
67
+ # With cloud deployment support
68
+ pip install ironshell[cloud]
69
+
70
+ # Everything
71
+ pip install ironshell[all]
72
+ ```
73
+
74
+ Or from a checkout of the repository:
75
+
76
+ ```bash
77
+ pip install ./integrations/python
78
+ ```
79
+
80
+ Requires the `ish` binary on `PATH`. Install it with
81
+ `cargo install iron-shell`, or take a prebuilt binary from the
82
+ [releases page](https://github.com/nervosys/IronShell/releases).
83
+
84
+ > **Versioning:** this SDK versions independently of the `ish` shell. The SDK in
85
+ > this repository is 1.5.1; PyPI carries 1.5.0, a manual upload, because CI has
86
+ > never published it. `pip install ./integrations/python` installs the current one.
87
+
88
+ ## Quick Start
89
+
90
+ ```python
91
+ from ironshell import IronShellRuntime, Agent
92
+
93
+ # Create runtime
94
+ runtime = IronShellRuntime()
95
+
96
+ # Evaluate IronShell code
97
+ result = runtime.eval('[1, 2, 3] | map(fn(x) => x * 2)')
98
+ print(result) # [2, 4, 6]
99
+
100
+ # Create and run an agent
101
+ agent = runtime.create_agent(
102
+ name="researcher",
103
+ tools=["http_get", "search"]
104
+ )
105
+
106
+ result = await agent.run("Find the latest Python release version")
107
+ print(result)
108
+ ```
109
+
110
+ ## Features
111
+
112
+ - **Evaluation**: Execute IronShell code from Python
113
+ - **Pipelines**: Process data with typed pipelines
114
+ - **Agents**: Create and orchestrate AI agents
115
+ - **Swarms**: Multi-agent coordination
116
+ - **Workflows**: MapReduce, Saga, Fan-Out patterns
117
+ - **Metrics**: Prometheus metrics, tracing, health checks
118
+ - **Distributed**: Service discovery, leader election, load balancing
119
+ - **Cloud**: Deploy as serverless functions (AWS, Azure, GCP, K8s)
120
+ - **LangChain**: Full LangChain tool integration
121
+
122
+ ## Workflow Orchestration
123
+
124
+ ```python
125
+ from ironshell.workflows import (
126
+ MapReduceWorkflow,
127
+ SagaWorkflow,
128
+ PipelineWorkflow,
129
+ CircuitBreaker,
130
+ )
131
+
132
+ # MapReduce for parallel processing
133
+ workflow = MapReduceWorkflow(
134
+ name="word_count",
135
+ map_fn=lambda text: len(text.split()),
136
+ reduce_fn=lambda a, b: a + b,
137
+ )
138
+ result = await workflow.run(["hello world", "foo bar baz"])
139
+ print(result.result) # 5
140
+
141
+ # Saga with compensation
142
+ saga = SagaWorkflow("order")
143
+ saga.add_saga_step("reserve", reserve_inventory, rollback_reservation)
144
+ saga.add_saga_step("charge", charge_payment, refund_payment)
145
+ saga.add_saga_step("ship", ship_order, cancel_shipment)
146
+ result = await saga.run(order_data)
147
+
148
+ # Circuit breaker for fault tolerance
149
+ breaker = CircuitBreaker(name="api", failure_threshold=5)
150
+ result = breaker.call(lambda: api_request())
151
+ ```
152
+
153
+ ## Metrics & Observability
154
+
155
+ ```python
156
+ from ironshell.metrics import (
157
+ MetricsCollector,
158
+ Counter,
159
+ Gauge,
160
+ Histogram,
161
+ Tracer,
162
+ )
163
+
164
+ # Create metrics
165
+ collector = MetricsCollector(namespace="myapp")
166
+ requests = collector.counter("requests_total")
167
+ latency = collector.histogram("request_latency_seconds")
168
+
169
+ # Track metrics
170
+ requests.inc()
171
+ latency.observe(0.125)
172
+
173
+ # Export to Prometheus
174
+ print(collector.to_prometheus())
175
+
176
+ # Distributed tracing
177
+ tracer = collector.tracer("my-service")
178
+ with tracer.start_span("handle_request") as span:
179
+ span.set_attribute("user_id", "123")
180
+ # ... process request
181
+ ```
182
+
183
+ ## Distributed Agents
184
+
185
+ ```python
186
+ from ironshell.distributed import (
187
+ ServiceRegistry,
188
+ LeaderElection,
189
+ LoadBalancer,
190
+ DistributedSwarm,
191
+ )
192
+
193
+ # Service discovery
194
+ registry = ServiceRegistry()
195
+ registry.register("agent-nlp", "host1", 8080)
196
+ registry.register("agent-nlp", "host2", 8080)
197
+
198
+ # Load balancing
199
+ lb = LoadBalancer(registry, strategy="round_robin")
200
+ service = lb.select_service("agent-nlp")
201
+
202
+ # Leader election
203
+ election = LeaderElection("node-1", registry, "cluster")
204
+ await election.run_election()
205
+ if election.is_leader:
206
+ print("I am the leader!")
207
+
208
+ # Distributed swarm
209
+ swarm = DistributedSwarm("my-swarm", registry)
210
+ swarm.add_local_agent(my_agent)
211
+ result = await swarm.dispatch(goal="analyze data", capability="nlp")
212
+ ```
213
+
214
+ ## Cloud Deployment
215
+
216
+ Deploy agents as serverless functions:
217
+
218
+ ```python
219
+ from ironshell.cloud import (
220
+ CloudProvider,
221
+ FunctionConfig,
222
+ DeploymentConfig,
223
+ deploy_agent,
224
+ )
225
+
226
+ # Configure function
227
+ config = DeploymentConfig(
228
+ provider=CloudProvider.AWS_LAMBDA,
229
+ region="us-east-1",
230
+ function_config=FunctionConfig(
231
+ name="my-agent",
232
+ memory_mb=512,
233
+ timeout_seconds=60,
234
+ ),
235
+ )
236
+
237
+ # Generate deployment files
238
+ agent_code = '''
239
+ def create_agent(runtime):
240
+ return Agent(name="analyst", runtime=runtime)
241
+ '''
242
+
243
+ files = deploy_agent(config, agent_code, output_dir="./deploy")
244
+ # Creates: handler.py, template.yaml, samconfig.toml, requirements.txt
245
+ ```
246
+
247
+ Supported platforms:
248
+ - **AWS Lambda** (SAM template)
249
+ - **Azure Functions** (Bicep)
250
+ - **GCP Cloud Functions** (Terraform)
251
+ - **Kubernetes/Knative** (manifests + Skaffold)
252
+
253
+ ## LangChain Integration
254
+
255
+ ```python
256
+ from ironshell.langchain import (
257
+ get_all_ironshell_tools,
258
+ IronShellWorkflowTool,
259
+ IronShellMapReduceTool,
260
+ IronShellMetricsTool,
261
+ )
262
+
263
+ # Get all tools for LangChain agent
264
+ tools = get_all_ironshell_tools()
265
+
266
+ # Use with LangChain
267
+ from langchain.agents import initialize_agent
268
+ agent = initialize_agent(tools, llm, agent="zero-shot-react-description")
269
+ agent.run("Process this data with MapReduce: [1,2,3,4,5]")
270
+ ```
271
+
272
+ ## API Reference
273
+
274
+ ### IronShellRuntime
275
+
276
+ ```python
277
+ runtime = IronShellRuntime()
278
+
279
+ # Evaluate code
280
+ result = runtime.eval(code: str) -> Any
281
+
282
+ # Create agent
283
+ agent = runtime.create_agent(
284
+ name: str,
285
+ model: str = "openai:gpt-4o-mini",
286
+ tools: List[str] = [],
287
+ max_steps: int = 10
288
+ ) -> Agent
289
+
290
+ # Run swarm (sent to the swarm builtin as {goal, tools, max_steps};
291
+ # tools is the union of the agents' tools; policy must be "round_robin",
292
+ # and agents must use the default model and max_steps, else ValueError)
293
+ result = await runtime.run_swarm(
294
+ agents: List[Agent],
295
+ goal: str,
296
+ policy: str = "round_robin",
297
+ max_iterations: int = 10
298
+ ) -> SwarmResult # result.result is the builtin's combined answer
299
+ ```
300
+
301
+ ### Agent
302
+
303
+ ```python
304
+ agent = Agent(name="agent1") # model must stay at the default openai:gpt-4o-mini
305
+
306
+ # Run agent (sent as agent({goal, tools, max_steps}); result.result is the
307
+ # final answer, and trace and steps_taken are empty)
308
+ result = await agent.run(goal: str) -> AgentResult
309
+
310
+ # Get trace
311
+ trace = agent.trace # List of steps taken
312
+ ```
313
+
314
+ ### A2UI Events
315
+
316
+ ```python
317
+ # Subscribe to events
318
+ def on_event(event: A2UIEvent):
319
+ print(f"Event: {event.type}")
320
+
321
+ runtime.subscribe_a2ui(on_event)
322
+
323
+ # Event types
324
+ # - Notify: Notifications
325
+ # - Progress: Progress updates
326
+ # - Prompt: User prompts
327
+ # - AgentThinking: Agent reasoning
328
+ ```
329
+
330
+ ## Development
331
+
332
+ ```bash
333
+ # Clone repository
334
+ git clone https://github.com/nervosys/IronShell.git
335
+ cd IronShell/integrations/python
336
+
337
+ # Install development dependencies
338
+ pip install -e ".[dev]"
339
+
340
+ # Run tests
341
+ pytest
342
+
343
+ # Build package
344
+ python -m build
345
+ ```
346
+
347
+ ## License
348
+
349
+ AGPL-3.0-or-later with commercial dual-license option — see [LICENSE](../../LICENSE) for details.
@@ -0,0 +1,296 @@
1
+ # IronShell Python SDK
2
+
3
+ Python bindings for IronShell - AI-powered typed shell with workflow orchestration and cloud deployment.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Core SDK
9
+ pip install ironshell
10
+
11
+ # With LangChain integration
12
+ pip install ironshell[langchain]
13
+
14
+ # With cloud deployment support
15
+ pip install ironshell[cloud]
16
+
17
+ # Everything
18
+ pip install ironshell[all]
19
+ ```
20
+
21
+ Or from a checkout of the repository:
22
+
23
+ ```bash
24
+ pip install ./integrations/python
25
+ ```
26
+
27
+ Requires the `ish` binary on `PATH`. Install it with
28
+ `cargo install iron-shell`, or take a prebuilt binary from the
29
+ [releases page](https://github.com/nervosys/IronShell/releases).
30
+
31
+ > **Versioning:** this SDK versions independently of the `ish` shell. The SDK in
32
+ > this repository is 1.5.1; PyPI carries 1.5.0, a manual upload, because CI has
33
+ > never published it. `pip install ./integrations/python` installs the current one.
34
+
35
+ ## Quick Start
36
+
37
+ ```python
38
+ from ironshell import IronShellRuntime, Agent
39
+
40
+ # Create runtime
41
+ runtime = IronShellRuntime()
42
+
43
+ # Evaluate IronShell code
44
+ result = runtime.eval('[1, 2, 3] | map(fn(x) => x * 2)')
45
+ print(result) # [2, 4, 6]
46
+
47
+ # Create and run an agent
48
+ agent = runtime.create_agent(
49
+ name="researcher",
50
+ tools=["http_get", "search"]
51
+ )
52
+
53
+ result = await agent.run("Find the latest Python release version")
54
+ print(result)
55
+ ```
56
+
57
+ ## Features
58
+
59
+ - **Evaluation**: Execute IronShell code from Python
60
+ - **Pipelines**: Process data with typed pipelines
61
+ - **Agents**: Create and orchestrate AI agents
62
+ - **Swarms**: Multi-agent coordination
63
+ - **Workflows**: MapReduce, Saga, Fan-Out patterns
64
+ - **Metrics**: Prometheus metrics, tracing, health checks
65
+ - **Distributed**: Service discovery, leader election, load balancing
66
+ - **Cloud**: Deploy as serverless functions (AWS, Azure, GCP, K8s)
67
+ - **LangChain**: Full LangChain tool integration
68
+
69
+ ## Workflow Orchestration
70
+
71
+ ```python
72
+ from ironshell.workflows import (
73
+ MapReduceWorkflow,
74
+ SagaWorkflow,
75
+ PipelineWorkflow,
76
+ CircuitBreaker,
77
+ )
78
+
79
+ # MapReduce for parallel processing
80
+ workflow = MapReduceWorkflow(
81
+ name="word_count",
82
+ map_fn=lambda text: len(text.split()),
83
+ reduce_fn=lambda a, b: a + b,
84
+ )
85
+ result = await workflow.run(["hello world", "foo bar baz"])
86
+ print(result.result) # 5
87
+
88
+ # Saga with compensation
89
+ saga = SagaWorkflow("order")
90
+ saga.add_saga_step("reserve", reserve_inventory, rollback_reservation)
91
+ saga.add_saga_step("charge", charge_payment, refund_payment)
92
+ saga.add_saga_step("ship", ship_order, cancel_shipment)
93
+ result = await saga.run(order_data)
94
+
95
+ # Circuit breaker for fault tolerance
96
+ breaker = CircuitBreaker(name="api", failure_threshold=5)
97
+ result = breaker.call(lambda: api_request())
98
+ ```
99
+
100
+ ## Metrics & Observability
101
+
102
+ ```python
103
+ from ironshell.metrics import (
104
+ MetricsCollector,
105
+ Counter,
106
+ Gauge,
107
+ Histogram,
108
+ Tracer,
109
+ )
110
+
111
+ # Create metrics
112
+ collector = MetricsCollector(namespace="myapp")
113
+ requests = collector.counter("requests_total")
114
+ latency = collector.histogram("request_latency_seconds")
115
+
116
+ # Track metrics
117
+ requests.inc()
118
+ latency.observe(0.125)
119
+
120
+ # Export to Prometheus
121
+ print(collector.to_prometheus())
122
+
123
+ # Distributed tracing
124
+ tracer = collector.tracer("my-service")
125
+ with tracer.start_span("handle_request") as span:
126
+ span.set_attribute("user_id", "123")
127
+ # ... process request
128
+ ```
129
+
130
+ ## Distributed Agents
131
+
132
+ ```python
133
+ from ironshell.distributed import (
134
+ ServiceRegistry,
135
+ LeaderElection,
136
+ LoadBalancer,
137
+ DistributedSwarm,
138
+ )
139
+
140
+ # Service discovery
141
+ registry = ServiceRegistry()
142
+ registry.register("agent-nlp", "host1", 8080)
143
+ registry.register("agent-nlp", "host2", 8080)
144
+
145
+ # Load balancing
146
+ lb = LoadBalancer(registry, strategy="round_robin")
147
+ service = lb.select_service("agent-nlp")
148
+
149
+ # Leader election
150
+ election = LeaderElection("node-1", registry, "cluster")
151
+ await election.run_election()
152
+ if election.is_leader:
153
+ print("I am the leader!")
154
+
155
+ # Distributed swarm
156
+ swarm = DistributedSwarm("my-swarm", registry)
157
+ swarm.add_local_agent(my_agent)
158
+ result = await swarm.dispatch(goal="analyze data", capability="nlp")
159
+ ```
160
+
161
+ ## Cloud Deployment
162
+
163
+ Deploy agents as serverless functions:
164
+
165
+ ```python
166
+ from ironshell.cloud import (
167
+ CloudProvider,
168
+ FunctionConfig,
169
+ DeploymentConfig,
170
+ deploy_agent,
171
+ )
172
+
173
+ # Configure function
174
+ config = DeploymentConfig(
175
+ provider=CloudProvider.AWS_LAMBDA,
176
+ region="us-east-1",
177
+ function_config=FunctionConfig(
178
+ name="my-agent",
179
+ memory_mb=512,
180
+ timeout_seconds=60,
181
+ ),
182
+ )
183
+
184
+ # Generate deployment files
185
+ agent_code = '''
186
+ def create_agent(runtime):
187
+ return Agent(name="analyst", runtime=runtime)
188
+ '''
189
+
190
+ files = deploy_agent(config, agent_code, output_dir="./deploy")
191
+ # Creates: handler.py, template.yaml, samconfig.toml, requirements.txt
192
+ ```
193
+
194
+ Supported platforms:
195
+ - **AWS Lambda** (SAM template)
196
+ - **Azure Functions** (Bicep)
197
+ - **GCP Cloud Functions** (Terraform)
198
+ - **Kubernetes/Knative** (manifests + Skaffold)
199
+
200
+ ## LangChain Integration
201
+
202
+ ```python
203
+ from ironshell.langchain import (
204
+ get_all_ironshell_tools,
205
+ IronShellWorkflowTool,
206
+ IronShellMapReduceTool,
207
+ IronShellMetricsTool,
208
+ )
209
+
210
+ # Get all tools for LangChain agent
211
+ tools = get_all_ironshell_tools()
212
+
213
+ # Use with LangChain
214
+ from langchain.agents import initialize_agent
215
+ agent = initialize_agent(tools, llm, agent="zero-shot-react-description")
216
+ agent.run("Process this data with MapReduce: [1,2,3,4,5]")
217
+ ```
218
+
219
+ ## API Reference
220
+
221
+ ### IronShellRuntime
222
+
223
+ ```python
224
+ runtime = IronShellRuntime()
225
+
226
+ # Evaluate code
227
+ result = runtime.eval(code: str) -> Any
228
+
229
+ # Create agent
230
+ agent = runtime.create_agent(
231
+ name: str,
232
+ model: str = "openai:gpt-4o-mini",
233
+ tools: List[str] = [],
234
+ max_steps: int = 10
235
+ ) -> Agent
236
+
237
+ # Run swarm (sent to the swarm builtin as {goal, tools, max_steps};
238
+ # tools is the union of the agents' tools; policy must be "round_robin",
239
+ # and agents must use the default model and max_steps, else ValueError)
240
+ result = await runtime.run_swarm(
241
+ agents: List[Agent],
242
+ goal: str,
243
+ policy: str = "round_robin",
244
+ max_iterations: int = 10
245
+ ) -> SwarmResult # result.result is the builtin's combined answer
246
+ ```
247
+
248
+ ### Agent
249
+
250
+ ```python
251
+ agent = Agent(name="agent1") # model must stay at the default openai:gpt-4o-mini
252
+
253
+ # Run agent (sent as agent({goal, tools, max_steps}); result.result is the
254
+ # final answer, and trace and steps_taken are empty)
255
+ result = await agent.run(goal: str) -> AgentResult
256
+
257
+ # Get trace
258
+ trace = agent.trace # List of steps taken
259
+ ```
260
+
261
+ ### A2UI Events
262
+
263
+ ```python
264
+ # Subscribe to events
265
+ def on_event(event: A2UIEvent):
266
+ print(f"Event: {event.type}")
267
+
268
+ runtime.subscribe_a2ui(on_event)
269
+
270
+ # Event types
271
+ # - Notify: Notifications
272
+ # - Progress: Progress updates
273
+ # - Prompt: User prompts
274
+ # - AgentThinking: Agent reasoning
275
+ ```
276
+
277
+ ## Development
278
+
279
+ ```bash
280
+ # Clone repository
281
+ git clone https://github.com/nervosys/IronShell.git
282
+ cd IronShell/integrations/python
283
+
284
+ # Install development dependencies
285
+ pip install -e ".[dev]"
286
+
287
+ # Run tests
288
+ pytest
289
+
290
+ # Build package
291
+ python -m build
292
+ ```
293
+
294
+ ## License
295
+
296
+ AGPL-3.0-or-later with commercial dual-license option — see [LICENSE](../../LICENSE) for details.