Skip to content

add Nim SDK - #29

Open
jasagiri wants to merge 1 commit into
ag-ui-protocol:mainfrom
jasagiri:main
Open

jasagiri wants to merge 1 commit into
ag-ui-protocol:mainfrom
jasagiri:main

Conversation

@jasagiri

Copy link
Copy Markdown

add Nim SDK

@NathanTarbert

Copy link
Copy Markdown
Contributor

Hey @jasagiri, thanks for the contribution.
Someone from the team will review your PR soon.

@tylerslaton tylerslaton moved this to In review in Road Map Jul 10, 2025
@tylerslaton tylerslaton added the Roadmap This feature or functionality should be added to the roadmap. label Jul 11, 2025
@NathanTarbert

Copy link
Copy Markdown
Contributor

Hey @jasagiri, would you be up for maintaining this if it's merged?

@jasagiri

Copy link
Copy Markdown
Author

I've never collaborated with VSC before, so I'm still feeling my way around, but I can do it.

@tylerslaton tylerslaton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jasagiri! This looks great. Left a small comment about the documentation. Outside of that, a few asks.

  1. Since this is older, can you look through the existing protocol spec and make sure this is fully compatible?
  2. Can you run the tests in CI? We'd happily accept a contribution for that.
  3. How would we go about packaging this for Nim's consumption?

Comment thread nim-sdk/docs/CHANGELOG.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please add documentation to the docs folder and get rid of this? We don't necessarily want to keep these files.

Comment thread nim-sdk/.DS_Store Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please remove this? Also in the root would you mind adding a gitignore for this?

Comment thread nim-sdk/src/.DS_Store Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, can we remove this?

Comment thread nim-sdk/src/ag_ui_nim/.DS_Store Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make sure to remove all of these please!

Comment thread nim-sdk/docs/PR.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these AI generated files also go in. Can we remove them? CLAUDE.md is good to keep but let's remove the progress ones.

maxkorp pushed a commit that referenced this pull request Sep 16, 2025
@maxkorp maxkorp added the SDK label Oct 13, 2025
@jpr5 jpr5 self-assigned this Mar 4, 2026
@jpr5

jpr5 commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Hello @jasagiri, it's unclear to us where you stand on this incomplete work. Are you interested in taking it over the finish line? Especially with Agents now, maybe it's easier for you? Or is it superseded by something else?

Please let us know in the next 2 weeks, otherwise we will close this as stale.

Thanks for the time & effort this far! 🙏

@jasagiri
jasagiri requested a review from a team as a code owner March 5, 2026 00:58
@vercel

vercel Bot commented Mar 5, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the CopilotKit Team on Vercel.

A member of the Team first needs to authorize it.

@jasagiri

jasagiri commented Mar 5, 2026

Copy link
Copy Markdown
Author

I sincerely apologize for the delay in responding to the feedback. I am aware that I sometimes have difficulties with communication, so I would greatly appreciate your patience and understanding as we work through this.

I have addressed the requested changes and synchronized the Nim SDK with the latest protocol specification:

  • SDK Relocation: Moved the Nim SDK to sdks/nim to align with the repository's standard project structure.
  • Cleanup: Removed all .DS_Store files and added a proper .gitignore for the Nim SDK.
  • Documentation: Moved the CHANGELOG.md to docs/sdk/nim/ and removed AI-generated temporary progress files.
  • CI Integration: Added a GitHub Actions workflow (unit-nim-sdk.yml) to automate testing for the Nim SDK.
  • Protocol Compatibility: Updated the SDK (types, events, and validation logic) to match the latest protocol version, including support for Thinking, Reasoning, and Activity events.
  • Verification: Verified that the entire Nim test suite passes successfully.

Thank you for your review and support.

@jpr5

jpr5 commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

@jasagiri Thank you so much for coming back to this and for the continued effort — we really appreciate you taking the time to work on a Nim SDK for the project. 🙏

I took a close look at the current state of the PR and wanted to share some notes to help get this across the finish line. You've clearly put a lot of work in, and the core is solid — the event type enum covers all 34 protocol event types correctly, the test suite is substantive (not just stubs), and the overall architecture looks well thought out.

There are a few things that would need to be addressed before we can merge:

Build artifacts

It looks like sdks/build/tests/ contains compiled macOS binaries and .dSYM debug symbol directories (about 36 files). These appear to have been generated during local testing and accidentally included in the commit. Would you mind removing that entire sdks/build/ directory from the PR? The current sdks/nim/.gitignore wouldn't catch these since they live two levels above — it might be worth adding sdks/build/ to the root .gitignore as well.

AI-generated working files

A few files that look like internal working notes are still present in the tree:

  • sdks/nim/TODO.md
  • sdks/nim/docs/PROGRESS.md
  • sdks/nim/docs/PR.md
  • sdks/nim/CLAUDE.md

I believe these were part of Tyler's earlier feedback as well. No worries if they slipped through — easy to miss when there are a lot of files. docs/proto_implementation.md could potentially stay if it's rewritten as user-facing documentation, but in its current form it reads more like internal notes, so it might be best to remove it too.

Protocol completeness

The event types themselves are all accounted for, which is great. I did notice a few gaps in the event struct fields and message types when comparing against the current Python SDK:

Missing optional fields:

  • RunStartedEvent — parent_run_id, input
  • RunFinishedEvent — result
  • RunAgentInput — parent_run_id, forwarded_props
  • ToolCall and several message types — encrypted_value

Missing message types:

  • ActivityMessage and ReasoningMessage are not yet in types.nim (the Python SDK's Message union includes 7 types; the Nim SDK currently has 5)

Since these are all optional fields, the SDK would still function for basic use cases without them — but it would be wonderful to have them included for full protocol coverage. If adding them all at once is too much, it might be worth adding the fields with a TODO comment so future contributors know what's left.

CI workflow

The workflow looks good structurally! Two small suggestions:

  • The current Nim version is set to 1.6.0, which is from 2021. Would it be possible to update to a more recent version (2.x)? This would help ensure long-term compatibility.
  • For security best practices, it's generally recommended to pin GitHub Actions to a full commit SHA rather than a tag like @v1.

Test suite

The tests themselves are well-written and cover real behavior. I did notice that PROGRESS.md mentions a few test suites that may still need attention (proto, observable, legacy). It would be reassuring to confirm that nimble test passes cleanly in the CI workflow before merge.


Again, thank you for your dedication to this contribution — a Nim SDK would be a fantastic addition to the ecosystem. Please don't hesitate to reach out if any of the above is unclear or if there's anything we can help with. We're happy to work through any of these items together.

@jpr5

jpr5 commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

One more small note on the build artifacts — since those binaries (~15 MB) are already in the commit history, simply deleting them in a new commit would still leave them in the git objects. To keep the repo history clean, it would be best to do an interactive rebase or squash so that the sdks/build/ files never appear in any commit.

If you're not sure how to approach that, here's one way:

# From your branch, interactive rebase against main
git rebase -i main

# In the editor, mark the commits for 'edit' or squash them together,
# then remove the sdks/build/ directory before re-committing:
git rm -r sdks/build/
git commit --amend
git rebase --continue

Alternatively, squashing everything into a single clean commit works great too — whatever feels most comfortable for you. Happy to help walk through it if needed!

jpr5 pushed a commit that referenced this pull request Mar 5, 2026
PR #29 (Nim SDK) accidentally committed ~15 MB of compiled binaries
and .dSYM debug symbols. This adds three layers of defense:

- .gitignore: block common binary extensions and build directories
- CI workflow: check all PRs for binary files, build dirs, and files >500KB
- lefthook pre-push: catch binary artifacts before push (opt-in)
@jpr5 jpr5 mentioned this pull request Mar 5, 2026
3 tasks
@jasagiri

jasagiri commented Mar 5, 2026

Copy link
Copy Markdown
Author

Thank you for the review. I have addressed all the feedback and updated the Nim SDK to version 2.2.8.

Changes:

  • Cleanup: Removed sdks/build/ binaries and internal/AI working files (TODO.md, CLAUDE.md, etc.).
  • Git Hygiene: Updated the root .gitignore to exclude sdks/build/ and cleared existing binaries from the history.
  • Nim Upgrade: Upgraded to Nim 2.2.8 via mise and updated the CI workflow accordingly.
  • Protocol Completeness: Enhanced types and events to achieve full parity with the latest protocol spec (added missing optional fields like parent_run_id, and new message types Activity and Reasoning).
  • Documentation: Updated docs/sdk/nim/CHANGELOG.md with these changes.

Verified that all tests pass successfully in the Nim 2.2.8 environment. Thank you for your patience!

Add a Nim SDK under sdks/community/nim, built against
spec/1.0/schema.json:

- Types and a JSON codec for every schema definition: the 31 events
  (THINKING_* removed), the seven message roles, content parts and
  sources, RunAgentInput, run and subagent outcomes, interrupts, resume
  entries, token usage, AgentCapabilities and JSON Patch operations.
- Strict decoding (the schema exactly) and receiver decoding (unknown
  fields stripped and the deprecated whole-field nulls of
  DEPRECATIONS.md read as absent, with warnings). Errors name the
  schema keyword and the JSON Pointer. Encoding omits absent fields.
- RFC 6902 JSON Patch application and a reducer that folds events into
  messages and state, following the TypeScript client.
- SSE framing, an incremental SSE parser and an HTTP agent.

The tests run every document in spec/1.0/fixtures and the shared
sdks/fixtures cases, RFC 6902 Appendix A, and the HTTP agent against a
local server. `nimble test` runs every test file and fails on a
compiler warning. The unit-nim-sdk workflow installs the pinned Nim
2.2.12 release tarball, verified by SHA-256, and runs the suite when
the SDK, the 1.0 schema or the shared fixtures change.

Not implemented, as the README states: the protobuf transport, chunk
event expansion, event-sequence verification, parts of the TypeScript
reducer and the spec/1.0/conformance lanes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jasagiri

Copy link
Copy Markdown
Author

@jpr5 @tylerslaton — I am sorry for the long silence. After your notes in March I went quiet for more than seven months, well past the two weeks you asked for, and thank you for leaving the PR open. I also owe you a correction: my March reply said the binaries had been cleared from the history, but they had only been deleted in a later commit and were still in the branch. That is fixed now.

I would like to take it over the finish line, and I have reworked the PR rather than patching it further:

Layout. The SDK now lives in sdks/community/nim, next to the other community SDKs, with its CI in .github/workflows/unit-nim-sdk.yml.

History. The branch is now a single commit on top of current main. No commit contains build output, binaries, .DS_Store files or AI working notes (CLAUDE.md, TODO.md, PROGRESS.md, PR.md, ...); the old docs/CHANGELOG.md is gone too. I have not touched the root .gitignore.

Protocol 1.0. The types and the JSON codec were rewritten against spec/1.0/schema.json:

  • all 31 events, including REASONING_*, ACTIVITY_*, TOOL_CALL_RESULT and SUBAGENT_*; the THINKING_* events are gone;
  • all seven message roles, multimodal content parts with data/URL/file sources, RunAgentInput (parentRunId, state, forwardedProps, resume, ...), run and subagent outcomes, interrupts, token usage, AgentCapabilities, and the optional fields you listed (parentRunId, input, result, forwardedProps, encryptedValue, ...);
  • strict decoding (the schema exactly) and receiver decoding (unknown fields stripped and the deprecated whole-field nulls from DEPRECATIONS.md read as absent, each with a warning); the encoder omits absent fields instead of writing null.

Tests in CI. nimble test runs every test file and fails on a test failure or a compiler warning. Besides unit tests, it runs every document in spec/1.0/fixtures (valid ones must round-trip, invalid ones must be rejected for the rule their .expect.json names) and the shared sdks/fixtures/null-omission.json and agent-capabilities.json. The workflow installs the official Nim 2.2.12 release tarball, checked against its SHA-256, with no third-party action; actions/checkout is pinned to a commit SHA, credentials are not persisted, and permissions are contents: read. It also triggers on changes to spec/1.0/** and sdks/fixtures/**. Locally, nimble test passes (389 test cases in 7 files) on macOS arm64 and on Linux x86_64 with that tarball; zizmor reports no findings for the workflow.

Packaging. It is a Nimble package (ag_ui_nim, MIT, Nim >= 2.2, no dependencies outside the standard library). Nimble can install a package from a repository subdirectory:

nimble install "https://github.com/ag-ui-protocol/ag-ui?subdir=sdks/community/nim"

(or requires the same URL). Listing it in the Nimble package index can follow once it is merged.

Out of scope, stated in the README: the protobuf transport, expansion of chunk events, event-sequence verification (verifyEvents), parts of the TypeScript reducer (metadata merging, MESSAGES_SNAPSHOT merge rules), the pre-1.0 compatibility shims beyond the deprecated nulls, and the spec/1.0/conformance lanes, which are a regression corpus for the first-party clients.

On the documentation comment: the SDK's documentation is its README for now. If you would like reference pages under docs/sdk/nim/, like the Ruby and Dart ones, I can add them in this PR.

And yes, I am happy to maintain it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Roadmap This feature or functionality should be added to the roadmap. SDK

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

5 participants