Skip to content

feat: JavaScript SDK via napi-rs#29

Merged
lostmygithubaccount merged 2 commits intomainfrom
cody/ws-toolsv1js
Mar 17, 2026
Merged

feat: JavaScript SDK via napi-rs#29
lostmygithubaccount merged 2 commits intomainfrom
cody/ws-toolsv1js

Conversation

@lostmygithubaccount
Copy link
Copy Markdown
Contributor

Closes #24
Stacks on: #25

Summary

  • ascend-tools-js: napi-rs cdylib crate with AsyncTask/TypedTask for async Node.js bridging
  • Auto-generated TypeScript types from core model structs
  • Workspace/deployment/flow methods via spawn_blocking
  • Demo app: Express + htmx exercising the SDK
  • Build tooling: bin/build-js, bin/check-js, bin/preview
  • CI: actions/setup-node@v4, npm install in bin/setup

PR 5 of 6 for v1.0.

🤖 Generated with Claude Code

Base automatically changed from cody/ws-toolsv1split to main March 17, 2026 15:24
Add ascend-tools-js crate with napi-rs bindings for workspace,
deployment, and flow operations. Includes demo Express app with
htmx UI, build scripts (bin/build-js, bin/check-js, bin/preview),
and CI setup for Node.js 22.

The JS crate is a standalone cdylib (not in the Cargo workspace)
with its own Cargo.lock. Core crate gains a `jsts` feature for
conditional napi derive annotations on model structs.

Otto bindings are excluded (separate PR).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread bin/setup
fi

# Install JS dependencies (napi-rs, ava, typescript)
if command -v npm &>/dev/null; then
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

use fnm (follow up)

Comment thread bin/preview

# wait for server to be ready
for i in {1..20}; do
curl -sf http://localhost:3000 >/dev/null 2>&1 && break
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

3000 conflicts w/ other things we use (follow up)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a JavaScript/TypeScript SDK for Ascend Tools using napi-rs, including generated TS typings backed by the Rust core models, plus build/check tooling and a small demo app to exercise the bindings.

Changes:

  • Introduce ascend-tools-js N-API crate exporting an async Client wrapper over ascend-tools-core.
  • Add jsts feature + N-API type annotations to core model types for TS generation.
  • Add JS build/check scripts, CI setup for Node, and a demo Express+htmx app.

Reviewed changes

Copilot reviewed 15 out of 24 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/app/server.js Express demo server that uses the JS SDK to list/work with workspaces/deployments/flows.
tests/app/public/index.html Demo UI (tabs + htmx) for browsing SDK data.
tests/app/package.json Demo app dependencies (local file install of the JS SDK + express).
tests/app/.gitignore Ignore node_modules/ for the demo app.
src/ascend_tools/ascend-tools-js/src/lib.rs N-API Client implementation + async task wrapper for Node.js.
src/ascend_tools/ascend-tools-js/package.json JS package metadata + build/test scripts for the native module.
src/ascend_tools/ascend-tools-js/build.rs napi_build::setup() integration for building the native module.
src/ascend_tools/ascend-tools-js/tests/index.spec.mjs Minimal AVA tests ensuring exports/methods exist.
src/ascend_tools/ascend-tools-js/Cargo.toml Rust crate config for the N-API cdylib and dependencies/features.
src/ascend_tools/ascend-tools-js/Cargo.lock Separate lockfile for the JS native module crate/workspace.
src/ascend_tools/ascend-tools-js/.gitignore Ignore build outputs (including generated JS/types/native binaries).
src/ascend_tools/ascend-tools-core/src/models.rs Add conditional N-API annotations for TS type generation.
src/ascend_tools/ascend-tools-core/src/lib.rs Adjust unsafe-code linting depending on jsts feature.
src/ascend_tools/ascend-tools-core/Cargo.toml Add jsts feature and optional napi/napi-derive deps.
bin/setup Install JS dependencies for the JS SDK package when npm is present.
bin/preview Script to run the demo app locally.
bin/check-js Build + test the JS SDK package.
bin/check Run JS checks as part of the overall repo check script.
bin/build-js Build the JS SDK package.
bin/build Run JS build as part of the overall repo build script.
Cargo.toml Add workspace-level release profile settings.
Cargo.lock Add napi-related crates due to new optional feature usage.
.github/actions/setup/action.yml Install Node.js in CI setup action.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/app/public/index.html
Comment thread tests/app/server.js Outdated
Comment thread src/ascend_tools/ascend-tools-js/src/lib.rs Outdated
Comment thread src/ascend_tools/ascend-tools-js/package.json
Comment thread src/ascend_tools/ascend-tools-core/src/lib.rs
Critical fixes:
- Replace TypedTask panic with proper error handling to prevent Node process crashes
- Add npm package files list to ensure built artifacts are published

Bug fixes:
- Validate limit parameter in flow-runs endpoint (return 400 on invalid input)
- Add missing detail container to deployments page for click navigation

Documentation:
- Add comment explaining unsafe code policy relaxation with jsts feature

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lostmygithubaccount lostmygithubaccount merged commit d175525 into main Mar 17, 2026
1 check passed
@lostmygithubaccount lostmygithubaccount deleted the cody/ws-toolsv1js branch March 17, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JavaScript SDK bindings

2 participants