stemcode-sdk 1.1.23__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,387 @@
1
+ ## Ignore Visual Studio temporary files, build results, and
2
+ ## files generated by popular Visual Studio add-ons.
3
+ ##
4
+ ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5
+
6
+ # User-specific files
7
+ *.rsuser
8
+ *.suo
9
+ *.user
10
+ *.userosscache
11
+ *.sln.docstates
12
+
13
+ # User-specific files (MonoDevelop/Xamarin Studio)
14
+ *.userprefs
15
+
16
+ # Mono auto generated files
17
+ mono_crash.*
18
+
19
+ # Build results
20
+ [Dd]ebug/
21
+ [Dd]ebugPublic/
22
+ [Rr]elease/
23
+ [Rr]eleases/
24
+ x64/
25
+ x86/
26
+ [Ww][Ii][Nn]32/
27
+ [Aa][Rr][Mm]/
28
+ [Aa][Rr][Mm]64/
29
+ bld/
30
+ [Bb]in/
31
+ !packaging/npm/bin/
32
+ !packaging/npm/bin/stemcode.js
33
+ [Oo]bj/
34
+ [Oo]ut/
35
+ [Ll]og/
36
+ [Ll]ogs/
37
+
38
+ # Visual Studio 2015/2017 cache/options directory
39
+ .vs/
40
+ # Uncomment if you have tasks that create the project's static files in wwwroot
41
+ #wwwroot/
42
+
43
+ # Visual Studio 2017 auto generated files
44
+ Generated\ Files/
45
+
46
+ # MSTest test Results
47
+ [Tt]est[Rr]esult*/
48
+ [Bb]uild[Ll]og.*
49
+
50
+ # NUnit
51
+ *.VisualState.xml
52
+ TestResult.xml
53
+ nunit-*.xml
54
+
55
+ # Build Results of an ATL Project
56
+ [Dd]ebugPS/
57
+ [Rr]eleasePS/
58
+ dlldata.c
59
+
60
+ # Benchmark Results
61
+ BenchmarkDotNet.Artifacts/
62
+
63
+ # .NET Core
64
+ project.lock.json
65
+ project.fragment.lock.json
66
+ artifacts/
67
+
68
+ # ASP.NET Scaffolding
69
+ ScaffoldingReadMe.txt
70
+
71
+ # StyleCop
72
+ StyleCopReport.xml
73
+
74
+ # Files built by Visual Studio
75
+ *_i.c
76
+ *_p.c
77
+ *_h.h
78
+ *.ilk
79
+ *.meta
80
+ *.obj
81
+ *.iobj
82
+ *.pch
83
+ *.pdb
84
+ *.ipdb
85
+ *.pgc
86
+ *.pgd
87
+ *.rsp
88
+ *.sbr
89
+ *.tlb
90
+ *.tli
91
+ *.tlh
92
+ *.tmp
93
+ *.tmp_proj
94
+ *_wpftmp.csproj
95
+ *.log
96
+ *.vspscc
97
+ *.vssscc
98
+ .builds
99
+ *.pidb
100
+ *.svclog
101
+ *.scc
102
+
103
+ # Chutzpah Test files
104
+ _Chutzpah*
105
+
106
+ # Visual C++ cache files
107
+ ipch/
108
+ *.aps
109
+ *.ncb
110
+ *.opendb
111
+ *.opensdf
112
+ *.sdf
113
+ *.cachefile
114
+ *.VC.db
115
+ *.VC.VC.opendb
116
+
117
+ # Visual Studio profiler
118
+ *.psess
119
+ *.vsp
120
+ *.vspx
121
+ *.sap
122
+
123
+ # Visual Studio Trace Files
124
+ *.e2e
125
+
126
+ # TFS 2012 Local Workspace
127
+ $tf/
128
+
129
+ # Guidance Automation Toolkit
130
+ *.gpState
131
+
132
+ # ReSharper is a .NET coding add-in
133
+ _ReSharper*/
134
+ *.[Rr]e[Ss]harper
135
+ *.DotSettings.user
136
+
137
+ # TeamCity is a build add-in
138
+ _TeamCity*
139
+
140
+ # DotCover is a Code Coverage Tool
141
+ *.dotCover
142
+
143
+ # AxoCover is a Code Coverage Tool
144
+ .axoCover/*
145
+ !.axoCover/settings.json
146
+
147
+ # Coverlet is a free, cross platform Code Coverage Tool
148
+ coverage*.json
149
+ coverage*.xml
150
+ coverage*.info
151
+
152
+ # Visual Studio code coverage results
153
+ *.coverage
154
+ *.coveragexml
155
+
156
+ # NCrunch
157
+ _NCrunch_*
158
+ .*crunch*.local.xml
159
+ nCrunchTemp_*
160
+
161
+ # MightyMoose
162
+ *.mm.*
163
+ AutoTest.Net/
164
+
165
+ # Web workbench (sass)
166
+ .sass-cache/
167
+
168
+ # Installshield output folder
169
+ [Ee]xpress/
170
+
171
+ # DocProject is a documentation generator add-in
172
+ DocProject/buildhelp/
173
+ DocProject/Help/*.HxT
174
+ DocProject/Help/*.HxC
175
+ DocProject/Help/*.hhc
176
+ DocProject/Help/*.hhk
177
+ DocProject/Help/*.hhp
178
+ DocProject/Help/Html2
179
+ DocProject/Help/html
180
+
181
+ # Click-Once directory
182
+ publish/
183
+
184
+ # Publish Web Output
185
+ *.[Pp]ublish.xml
186
+ *.azurePubxml
187
+ # Note: Comment the next line if you want to checkin your web deploy settings,
188
+ # but database connection strings (with potential passwords) will be unencrypted
189
+ *.pubxml
190
+ *.publishproj
191
+
192
+ # Microsoft Azure Web App publish settings. Comment the next line if you want to
193
+ # checkin your Azure Web App publish settings, but sensitive information contained
194
+ # in these scripts will be unencrypted
195
+ PublishScripts/
196
+
197
+ # NuGet Packages
198
+ *.nupkg
199
+ # NuGet Symbol Packages
200
+ *.snupkg
201
+ # The packages folder can be ignored because of Package Restore
202
+ **/[Pp]ackages/*
203
+ # except build/, which is used as an MSBuild target.
204
+ !**/[Pp]ackages/build/
205
+ # Uncomment if necessary however generally it will be regenerated when needed
206
+ #!**/[Pp]ackages/repositories.config
207
+ # NuGet v3's project.json files produces more ignorable files
208
+ *.nuget.props
209
+ *.nuget.targets
210
+
211
+ # Microsoft Azure Build Output
212
+ csx/
213
+ *.build.csdef
214
+
215
+ # Microsoft Azure Emulator
216
+ ecf/
217
+ rcf/
218
+
219
+ # Windows Store app package directories and files
220
+ AppPackages/
221
+ BundleArtifacts/
222
+ Package.StoreAssociation.xml
223
+ _pkginfo.txt
224
+ *.appx
225
+ *.appxbundle
226
+ *.appxupload
227
+
228
+ # Visual Studio cache files
229
+ # files ending in .cache can be ignored
230
+ *.[Cc]ache
231
+ # but keep track of directories ending in .cache
232
+ !?*.[Cc]ache/
233
+
234
+ # Others
235
+ ClientBin/
236
+ ~$*
237
+ *~
238
+ *.dbmdl
239
+ *.dbproj.schemaview
240
+ *.jfm
241
+ *.pfx
242
+ *.publishsettings
243
+ orleans.codegen.cs
244
+
245
+ # Including strong name files can present a security risk
246
+ # (https://github.com/github/gitignore/pull/2483#issue-259490424)
247
+ #*.snk
248
+
249
+ # Since there are multiple workflows, uncomment next line to ignore bower_components
250
+ # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
251
+ #bower_components/
252
+
253
+ # RIA/Silverlight projects
254
+ Generated_Code/
255
+
256
+ # Backup & report files from converting an old project file
257
+ # to a newer Visual Studio version. Backup files are not needed,
258
+ # because we have git ;-)
259
+ _UpgradeReport_Files/
260
+ Backup*/
261
+ UpgradeLog*.XML
262
+ UpgradeLog*.htm
263
+ ServiceFabricBackup/
264
+ *.rptproj.bak
265
+
266
+ # SQL Server files
267
+ *.mdf
268
+ *.ldf
269
+ *.ndf
270
+
271
+ # Business Intelligence projects
272
+ *.rdl.data
273
+ *.bim.layout
274
+ *.bim_*.settings
275
+ *.rptproj.rsuser
276
+ *- [Bb]ackup.rdl
277
+ *- [Bb]ackup ([0-9]).rdl
278
+ *- [Bb]ackup ([0-9][0-9]).rdl
279
+
280
+ # Microsoft Fakes
281
+ FakesAssemblies/
282
+
283
+ # GhostDoc plugin setting file
284
+ *.GhostDoc.xml
285
+
286
+ # Node.js Tools for Visual Studio
287
+ .ntvs_analysis.dat
288
+ node_modules/
289
+
290
+ # Visual Studio 6 build log
291
+ *.plg
292
+
293
+ # Visual Studio 6 workspace options file
294
+ *.opt
295
+
296
+ # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
297
+ *.vbw
298
+
299
+ # Visual Studio LightSwitch build output
300
+ **/*.HTMLClient/GeneratedArtifacts
301
+ **/*.DesktopClient/GeneratedArtifacts
302
+ **/*.DesktopClient/ModelManifest.xml
303
+ **/*.Server/GeneratedArtifacts
304
+ **/*.Server/ModelManifest.xml
305
+ _Pvt_Extensions
306
+
307
+ # Paket dependency manager
308
+ .paket/paket.exe
309
+ paket-files/
310
+
311
+ # FAKE - F# Make
312
+ .fake/
313
+
314
+ # CodeRush personal settings
315
+ .cr/personal
316
+
317
+ # Python Tools for Visual Studio (PTVS)
318
+ __pycache__/
319
+ *.pyc
320
+
321
+ # Cake - Uncomment if you are using it
322
+ # tools/**
323
+ # !tools/packages.config
324
+
325
+ # Tabs Studio
326
+ *.tss
327
+
328
+ # Telerik's JustMock configuration file
329
+ *.jmconfig
330
+
331
+ # BizTalk build output
332
+ *.btp.cs
333
+ *.btm.cs
334
+ *.odx.cs
335
+ *.xsd.cs
336
+
337
+ # OpenCover UI analysis results
338
+ OpenCover/
339
+
340
+ # Azure Stream Analytics local run output
341
+ ASALocalRun/
342
+
343
+ # MSBuild Binary and Structured Log
344
+ *.binlog
345
+
346
+ # NVidia Nsight GPU debugger configuration file
347
+ *.nvuser
348
+
349
+ # MFractors (Xamarin productivity tool) working folder
350
+ .mfractor/
351
+
352
+ # Local History for Visual Studio
353
+ .localhistory/
354
+
355
+ # BeatPulse healthcheck temp database
356
+ healthchecksdb
357
+
358
+ # Backup folder for Package Reference Convert tool in Visual Studio 2017
359
+ MigrationBackup/
360
+
361
+ # Ionide (cross platform F# VS Code tools) working folder
362
+ .ionide/
363
+
364
+ # Fody - auto-generated XML schema
365
+ FodyWeavers.xsd
366
+
367
+ # StemCode local runtime data
368
+ .stemcode/cache/
369
+ .stemcode/logs/
370
+ .stemcode/sessions/
371
+ .stemcode/tmp/
372
+ .stemcode/temp/
373
+
374
+ # JetBrains plugin build output
375
+ StemCode.JetBrains/build/
376
+ StemCode.JetBrains/.gradle/
377
+ StemCode.JetBrains/.intellijPlatform/
378
+ StemCode.JetBrains/.kotlin/
379
+ .idea/
380
+
381
+ # Python package build output
382
+ python/dist/
383
+ python/stemcode/_dotnet/
384
+
385
+ # JavaScript/TypeScript SDK build output
386
+ js/dist/
387
+ js/dotnet/
@@ -0,0 +1,126 @@
1
+ Metadata-Version: 2.5
2
+ Name: stemcode-sdk
3
+ Version: 1.1.23
4
+ Summary: Python wrapper for the StemCode .NET SDK using pythonnet.
5
+ Project-URL: Repository, https://github.com/rizwan3d/StemCode
6
+ Project-URL: Documentation, https://github.com/rizwan3d/StemCode/blob/master/docs/documentation.md
7
+ Author: Rizwan3d
8
+ License: Apache-2.0
9
+ Keywords: agent,ai,dotnet,pythonnet,stemcode
10
+ Requires-Python: >=3.10
11
+ Requires-Dist: pythonnet>=3.0.5
12
+ Description-Content-Type: text/markdown
13
+
14
+ # StemCode Python Wrapper
15
+
16
+ This package is a thin Python facade over the `StemCode.Sdk` .NET API. It uses
17
+ [`pythonnet`](https://pythonnet.github.io/) to load a published `StemCode.dll`
18
+ and keeps the .NET SDK as the source of truth.
19
+
20
+ ## Requirements
21
+
22
+ - Python 3.10 or newer
23
+ - .NET runtime that can run the StemCode target framework
24
+
25
+ ## Setup From This Repository
26
+
27
+ From the repository root, enter the Python wrapper folder:
28
+
29
+ ```powershell
30
+ cd python
31
+ ```
32
+
33
+ Create a virtual environment and install the wrapper:
34
+
35
+ ```powershell
36
+ py -3.12 -m venv .venv
37
+ .\.venv\Scripts\Activate.ps1
38
+ pip install -e .
39
+ ```
40
+
41
+ The package loads the StemCode .NET SDK from `STEMCODE_DOTNET_PATH`, a bundled
42
+ payload if one was built, or a NuGet-backed cache. On first use, the wrapper can
43
+ download the NuGet package into that cache when no local payload is present.
44
+ Set your provider credentials:
45
+
46
+ ```powershell
47
+ $env:STEMCODE_PROVIDER = "openai"
48
+ $env:STEMCODE_API_KEY = "PASTE_NEW_ROTATED_KEY_HERE"
49
+ $env:STEMCODE_MODEL = "gpt-5"
50
+ ```
51
+
52
+ Run the example:
53
+
54
+ ```powershell
55
+ python .\examples\basic_chat.py "Explain this repository in one paragraph."
56
+ ```
57
+
58
+ ## Basic Usage
59
+
60
+ ```python
61
+ from stemcode import StemCodeClient
62
+
63
+ with (
64
+ StemCodeClient.builder()
65
+ .use_openai("PASTE_NEW_ROTATED_KEY_HERE", "gpt-5")
66
+ .use_build_tool()
67
+ .with_workspace(r"F:\Projects\GrowBitLabs\StemCode")
68
+ .auto_approve_tools()
69
+ .build()
70
+ ) as client:
71
+ client.on_assistant_message_chunk(print, end="")
72
+ session = client.initialize()
73
+ print(f"Using {session.provider_name} / {session.model_id}")
74
+
75
+ result = client.run_turn("Summarize the SDK entry points.")
76
+ print(result.response_text)
77
+ ```
78
+
79
+ The wrapper exposes synchronous convenience methods around the .NET async API.
80
+ Callbacks are kept alive for the lifetime of the Python client.
81
+
82
+ ## Runtime Path
83
+
84
+ The package resolves the StemCode .NET SDK in this order:
85
+
86
+ 1. `load_stemcode(runtime_path=...)`, `StemCodeClient.builder(runtime_path=...)`,
87
+ or `STEMCODE_DOTNET_PATH`
88
+ 2. a bundled `stemcode/_dotnet` payload, when the wheel was built with one
89
+ 3. a NuGet package downloaded into the StemCode Python cache
90
+
91
+ The runtime path can be:
92
+
93
+ - a folder containing `StemCode.dll`
94
+ - the full path to `StemCode.dll`
95
+
96
+ Publish output is preferred over copying a single assembly because pythonnet
97
+ must resolve StemCode's dependency assemblies too.
98
+
99
+ NuGet download settings:
100
+
101
+ - `STEMCODE_NUGET_PACKAGE`: package ID, default `StemCode`
102
+ - `STEMCODE_NUGET_VERSION`: package version, default matching `stemcode-sdk`
103
+ - `STEMCODE_NUGET_SOURCE`: flat-container source, default NuGet.org
104
+ - `STEMCODE_DOTNET_CACHE`: cache folder override
105
+
106
+ The NuGet package must contain `StemCode.dll` and its dependency DLLs in one of
107
+ these layouts:
108
+
109
+ - `tools/stemcode/<rid>/`
110
+ - `tools/stemcode/any/`
111
+ - `tools/<rid>/`
112
+ - `tools/`
113
+ - `lib/net10.0/`
114
+
115
+ To build a wheel with the .NET payload bundled instead of downloaded, set:
116
+
117
+ ```powershell
118
+ $env:STEMCODE_BUNDLE_DOTNET = "1"
119
+ python -m build
120
+ ```
121
+
122
+ To verify the NuGet download path end to end:
123
+
124
+ ```powershell
125
+ python .\scripts\test_nuget_runtime.py --version 1.1.22
126
+ ```
@@ -0,0 +1,113 @@
1
+ # StemCode Python Wrapper
2
+
3
+ This package is a thin Python facade over the `StemCode.Sdk` .NET API. It uses
4
+ [`pythonnet`](https://pythonnet.github.io/) to load a published `StemCode.dll`
5
+ and keeps the .NET SDK as the source of truth.
6
+
7
+ ## Requirements
8
+
9
+ - Python 3.10 or newer
10
+ - .NET runtime that can run the StemCode target framework
11
+
12
+ ## Setup From This Repository
13
+
14
+ From the repository root, enter the Python wrapper folder:
15
+
16
+ ```powershell
17
+ cd python
18
+ ```
19
+
20
+ Create a virtual environment and install the wrapper:
21
+
22
+ ```powershell
23
+ py -3.12 -m venv .venv
24
+ .\.venv\Scripts\Activate.ps1
25
+ pip install -e .
26
+ ```
27
+
28
+ The package loads the StemCode .NET SDK from `STEMCODE_DOTNET_PATH`, a bundled
29
+ payload if one was built, or a NuGet-backed cache. On first use, the wrapper can
30
+ download the NuGet package into that cache when no local payload is present.
31
+ Set your provider credentials:
32
+
33
+ ```powershell
34
+ $env:STEMCODE_PROVIDER = "openai"
35
+ $env:STEMCODE_API_KEY = "PASTE_NEW_ROTATED_KEY_HERE"
36
+ $env:STEMCODE_MODEL = "gpt-5"
37
+ ```
38
+
39
+ Run the example:
40
+
41
+ ```powershell
42
+ python .\examples\basic_chat.py "Explain this repository in one paragraph."
43
+ ```
44
+
45
+ ## Basic Usage
46
+
47
+ ```python
48
+ from stemcode import StemCodeClient
49
+
50
+ with (
51
+ StemCodeClient.builder()
52
+ .use_openai("PASTE_NEW_ROTATED_KEY_HERE", "gpt-5")
53
+ .use_build_tool()
54
+ .with_workspace(r"F:\Projects\GrowBitLabs\StemCode")
55
+ .auto_approve_tools()
56
+ .build()
57
+ ) as client:
58
+ client.on_assistant_message_chunk(print, end="")
59
+ session = client.initialize()
60
+ print(f"Using {session.provider_name} / {session.model_id}")
61
+
62
+ result = client.run_turn("Summarize the SDK entry points.")
63
+ print(result.response_text)
64
+ ```
65
+
66
+ The wrapper exposes synchronous convenience methods around the .NET async API.
67
+ Callbacks are kept alive for the lifetime of the Python client.
68
+
69
+ ## Runtime Path
70
+
71
+ The package resolves the StemCode .NET SDK in this order:
72
+
73
+ 1. `load_stemcode(runtime_path=...)`, `StemCodeClient.builder(runtime_path=...)`,
74
+ or `STEMCODE_DOTNET_PATH`
75
+ 2. a bundled `stemcode/_dotnet` payload, when the wheel was built with one
76
+ 3. a NuGet package downloaded into the StemCode Python cache
77
+
78
+ The runtime path can be:
79
+
80
+ - a folder containing `StemCode.dll`
81
+ - the full path to `StemCode.dll`
82
+
83
+ Publish output is preferred over copying a single assembly because pythonnet
84
+ must resolve StemCode's dependency assemblies too.
85
+
86
+ NuGet download settings:
87
+
88
+ - `STEMCODE_NUGET_PACKAGE`: package ID, default `StemCode`
89
+ - `STEMCODE_NUGET_VERSION`: package version, default matching `stemcode-sdk`
90
+ - `STEMCODE_NUGET_SOURCE`: flat-container source, default NuGet.org
91
+ - `STEMCODE_DOTNET_CACHE`: cache folder override
92
+
93
+ The NuGet package must contain `StemCode.dll` and its dependency DLLs in one of
94
+ these layouts:
95
+
96
+ - `tools/stemcode/<rid>/`
97
+ - `tools/stemcode/any/`
98
+ - `tools/<rid>/`
99
+ - `tools/`
100
+ - `lib/net10.0/`
101
+
102
+ To build a wheel with the .NET payload bundled instead of downloaded, set:
103
+
104
+ ```powershell
105
+ $env:STEMCODE_BUNDLE_DOTNET = "1"
106
+ python -m build
107
+ ```
108
+
109
+ To verify the NuGet download path end to end:
110
+
111
+ ```powershell
112
+ python .\scripts\test_nuget_runtime.py --version 1.1.22
113
+ ```
@@ -0,0 +1,65 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import sys
5
+ from pathlib import Path
6
+
7
+ from stemcode import StemCodeClient
8
+
9
+
10
+ def main() -> int:
11
+ prompt = " ".join(sys.argv[1:]).strip() or "Say hello from StemCode."
12
+ provider = os.getenv("STEMCODE_PROVIDER", "openai").lower()
13
+ api_key = os.getenv("STEMCODE_API_KEY")
14
+ model = os.getenv("STEMCODE_MODEL")
15
+ workspace = os.getenv("STEMCODE_WORKSPACE", str(Path.cwd()))
16
+
17
+ builder = StemCodeClient.builder().with_workspace(workspace).use_build_tool()
18
+
19
+ if provider == "openai":
20
+ require_key(api_key, provider)
21
+ builder.use_openai(api_key, model)
22
+ elif provider == "anthropic":
23
+ require_key(api_key, provider)
24
+ builder.use_anthropic(api_key, model)
25
+ elif provider == "openrouter":
26
+ require_key(api_key, provider)
27
+ builder.use_openrouter(api_key, model)
28
+ elif provider == "google-ai-studio":
29
+ require_key(api_key, provider)
30
+ builder.use_google_ai_studio(api_key, model)
31
+ elif provider == "ollama":
32
+ builder.use_ollama(os.getenv("STEMCODE_BASE_URL"), model)
33
+ elif provider == "lm-studio":
34
+ builder.use_lm_studio(os.getenv("STEMCODE_BASE_URL"), model)
35
+ elif provider == "openai-compatible":
36
+ require_key(api_key, provider)
37
+ base_url = os.getenv("STEMCODE_BASE_URL")
38
+ if not base_url:
39
+ raise SystemExit("STEMCODE_BASE_URL is required for openai-compatible.")
40
+ builder.use_openai_compatible(base_url, api_key, model)
41
+ else:
42
+ raise SystemExit(f"Unsupported STEMCODE_PROVIDER: {provider}")
43
+
44
+ with builder.build() as client:
45
+ client.on_assistant_message_chunk(print, end="", flush=True)
46
+ client.on_status(lambda severity, message: print(f"\n[{severity}] {message}"))
47
+
48
+ session = client.initialize()
49
+ print(f"StemCode session {session.session_id} using {session.provider_name}/{session.model_id}")
50
+ result = client.run_turn(prompt)
51
+
52
+ if result.response_text:
53
+ print("\n\nFinal response:")
54
+ print(result.response_text)
55
+
56
+ return 0
57
+
58
+
59
+ def require_key(api_key: str | None, provider: str) -> None:
60
+ if not api_key:
61
+ raise SystemExit(f"STEMCODE_API_KEY is required for {provider}.")
62
+
63
+
64
+ if __name__ == "__main__":
65
+ raise SystemExit(main())