ts-services

Author TypeScript services behind the Native SDK effect boundary using generated typed clients.

7.6k|312|Updated May 8, 2026
One-click install
npx skills add https://github.com/vercel-labs/zero-native --skill ts-services
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ts-services
Source: https://github.com/vercel-labs/zero-native/tree/main/skill-data/ts-services
Command: npx skills add https://github.com/vercel-labs/zero-native --skill ts-services

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Native SDK cores are restricted to a deterministic TypeScript subset, so work needing Node built-ins, regexes, JSON, Map/Set, Date, or classes cannot live in src/core.ts. This Skill guides authoring src/services modules that run ordinary static-tier TypeScript behind a typed effect boundary without breaking determinism or compiler rules.

Core Features & Use Cases

  • Typed operation surface: Exported service functions become named operations with contract-encodable request/result types, called from the core through generated clients from @native-sdk/services.
  • Hermetic npm vendoring: Use native vendor to install exact-version packages into src/services/vendor with hash verification and no network access at build time.
  • Streaming, cancellation, and deadlines: Declare streaming operations with emit capabilities, @deadlineMs timeouts, and cooperative cancellation via ServiceCancellation tokens.
  • Carrier selection and authority: Choose between the in-process thread pool and the isolated child subprocess carrier, with documented platform matrices and replay behavior.
  • Use Case: Move feed-parsing logic that needs regex and JSON out of a deterministic core into src/services/feeds.ts, then call it from update via the generated feedsParse command with typed ok/err message routing.

Quick Start

Ask the assistant to add a new TypeScript service under src/services that parses data with Node built-ins and wire it into the core through the generated typed client.

Frequently Asked Questions about ts-services

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a TypeScript service in a Native SDK app?

Create a module under src/services with exported named functions taking zero or one annotated request and returning a contract-encodable result. Call it from the core through the generated client imported from @native-sdk/services, never by importing the service file directly.

How do I use npm packages in Native SDK services?

Run native vendor with an exact package version, which installs with lifecycle scripts disabled, copies the flattened graph into src/services/vendor, and records names, versions, and hashes in app.zon. Builds verify every vendored byte and never run npm or use the network.

Can Native SDK services use async functions or await?

No. Services are limited to synchronous static-tier operations; async/await is refused by the pinned scriptc compiler with SC1070. Asynchronous service support is planned for a later compiler and runtime phase.

What is the difference between the in-process and child service carriers?

The child carrier runs services in a separate subprocess with an allowlisted environment, giving full isolation. The in-process carrier runs a thread pool inside the app process, sharing its environment, so faults like stack overflow or process.exit take the app down.

Why does my core fail with NS1065 when importing a service?

NS1065 fires because the deterministic core may never import a service file, even type-only. Import the generated command constructors from @native-sdk/services instead, and place shared record types in a core-class file both sides may import.

How do streaming and cancellation work in Native SDK services?

Add a final emit capability parameter to declare a stream, plus a ServiceCancellation token for cooperative cancellation. @deadlineMs sets an operation deadline, @streamBuffer caps in-flight chunks, and Cmd.cancel flips the token and closes the channel.