Skip to content

feat: update tsdown version, add zod dependency, and enhance type def…#1343

Merged
sergiofilhowz merged 2 commits intomainfrom
feat/node-sdk-format-examples
Mar 24, 2026
Merged

feat: update tsdown version, add zod dependency, and enhance type def…#1343
sergiofilhowz merged 2 commits intomainfrom
feat/node-sdk-format-examples

Conversation

@sergiofilhowz
Copy link
Copy Markdown
Contributor

@sergiofilhowz sergiofilhowz commented Mar 23, 2026

…initions in SDK (#1341)

Summary by CodeRabbit

  • New Features

    • Added a Zod-based request/response validation example and added Zod as a runtime dependency.
  • Changes

    • Made function schema name optional.
    • Replaced array-shaped body with keyed properties.
    • Changed required from a boolean to a list of required field names.
  • Chores

    • Upgraded build tool dependency version.

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
iii-website Ready Ready Preview, Comment Mar 24, 2026 10:43am
motia-docs Ready Ready Preview, Comment Mar 24, 2026 10:43am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 23, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 87366640-4c6b-462f-8765-5c7f2be0aa8e

📥 Commits

Reviewing files that changed from the base of the PR and between 285c11e and 5319fdc.

📒 Files selected for processing (3)
  • sdk/packages/node/iii-example/src/iii-zod-example.ts
  • sdk/packages/node/iii-example/src/index.ts
  • sdk/packages/node/iii/src/iii-types.ts

📝 Walkthrough

Walkthrough

Adds a Zod-based example and zod dependency to the Node example package, updates SDK types for function registration, tweaks a build config and dev dependency, and applies small formatting/type-check suppressions in example sources.

Changes

Cohort / File(s) Summary
Example package manifest
sdk/packages/node/iii-example/package.json
Added zod (^4.3.6) to example runtime dependencies.
New Zod example
sdk/packages/node/iii-example/src/iii-zod-example.ts
Added a module defining Zod input/output schemas and registering a typed function (example::hello-world) with iii.
Example runtime & formatting
sdk/packages/node/iii-example/src/index.ts, sdk/packages/node/iii-example/src/state.ts, sdk/packages/node/iii-example/src/iii.ts
Imported the new zod example; reformatted some useApi handlers to one-line; renamed POST handler arg from data to value; added // @ts-expect-error`` above engineWsUrl; reordered imports.
SDK types
sdk/packages/node/iii/src/iii-types.ts
Modified RegisterFunctionFormat: name is now optional, bodyproperties (object map), and required changed from boolean to string[] (optional).
Build tooling / config
sdk/packages/node/iii/package.json, sdk/packages/node/iii/tsdown.config.ts
Upgraded dev dependency tsdown from ^0.17.0 to ^0.21.4; replaced external: [] with deps: { neverBundle: [] } in tsdown config.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • ytallo

Poem

🐇 Hopped in with Zod, a schema to show,

scope and key in a neat little flow,
Types trimmed and configs polished anew,
Example registered — a tiny debut,
I nibble on changes and cheer for the crew. 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: updating tsdown version, adding zod dependency, and enhancing type definitions in the SDK.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/node-sdk-format-examples

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

ytallo
ytallo previously approved these changes Mar 23, 2026
guibeira
guibeira previously approved these changes Mar 23, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
sdk/packages/node/iii/src/iii-types.ts (1)

86-111: ⚠️ Potential issue | 🟠 Major

Type mismatch: properties should be a Record, not an array, and required should support string arrays for object-level requirements.

The properties field is typed as RegisterFunctionFormat[] (array), but standard JSON Schema (and Zod's toJSONSchema() output) defines properties as a Record<string, Schema> (object map). Additionally, required is typed as boolean, but JSON Schema uses string[] for object-level property requirements.

This causes incompatibility with the Zod example in iii-zod-example.ts, which passes toJSONSchema(inputSchema) directly to request_format. The engine also expects JSON Schema format, as confirmed by its use of .as_object() on the properties field.

Align with JSON Schema conventions:

 export type RegisterFunctionFormat = {
   name?: string
   description?: string
   type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null' | 'map'
-  properties?: RegisterFunctionFormat[]
+  properties?: Record<string, RegisterFunctionFormat>
   items?: RegisterFunctionFormat
-  required?: boolean
+  required?: boolean | string[]
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/packages/node/iii/src/iii-types.ts` around lines 86 - 111, The
RegisterFunctionFormat type's properties and required fields are incorrect for
JSON Schema: change properties from an array to a map (properties:
Record<string, RegisterFunctionFormat> | undefined) and make required accept
JSON Schema-style string arrays (required?: string[]), or to preserve backwards
compatibility allow required?: boolean | string[]; update any consumers
expecting the old array/boolean shapes (references to
RegisterFunctionFormat.properties and RegisterFunctionFormat.required) to handle
the new types accordingly.
🧹 Nitpick comments (1)
sdk/packages/node/iii-example/src/iii.ts (1)

4-6: Consider using standard // @ts-expect-error`` format.

The JSDoc-style /** @ts-expect-error */ works but is unconventional. The standard format is a single-line comment directly above the offending line:

// `@ts-expect-error` process.env is not typed
const engineWsUrl = process.env.III_URL ?? 'ws://localhost:49134'

Alternatively, for better type safety in the example code, consider declaring the environment variable type or using a type assertion.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/packages/node/iii-example/src/iii.ts` around lines 4 - 6, Replace the
JSDoc-style suppression before the engineWsUrl declaration with the standard
single-line TypeScript suppression or add a proper type assertion: change the
comment above the const engineWsUrl declaration to use "// `@ts-expect-error`
process.env is not typed" or alternatively declare/augment the environment
variable types (or cast process.env.III_URL as string | undefined) so the const
engineWsUrl = process.env.III_URL ?? 'ws://localhost:49134' no longer relies on
the unconventional /** `@ts-expect-error` */ form.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@sdk/packages/node/iii-example/src/iii-zod-example.ts`:
- Line 1: The import currently pulls toJSONSchema as a named import (import {
toJSONSchema, z } from 'zod') which is invalid for Zod v4; update the import to
only import z (import { z } from 'zod') and then replace any direct uses of
toJSONSchema (e.g., toJSONSchema(schema) or standalone toJSONSchema calls) to
call the method on the z object (z.toJSONSchema(schema) or
schemaInstance?.toJSONSchema()) as appropriate so all references use
z.toJSONSchema.
- Around line 17-25: The call to iii.registerFunction is passing Zod's
toJSONSchema(inputSchema)/toJSONSchema(outputSchema) which produce standard JSON
Schema shapes that don't match the project's RegisterFunctionFormat (differences
in properties, required, type structure); add a conversion step before
registering: implement a utility (e.g., jsonSchemaToFormat) that takes the
return of toJSONSchema and maps fields into RegisterFunctionFormat (map
schema.type -> type, convert schema.properties object into
RegisterFunctionFormat[] with name and recursively converted children, convert
schema.required array into per-property boolean required) and use
jsonSchemaToFormat(toJSONSchema(inputSchema)) and
jsonSchemaToFormat(toJSONSchema(outputSchema)) as request_format/response_format
when calling iii.registerFunction (or alternatively align the
RegisterFunctionFormat type to accept JSON Schema if you control that type).

---

Outside diff comments:
In `@sdk/packages/node/iii/src/iii-types.ts`:
- Around line 86-111: The RegisterFunctionFormat type's properties and required
fields are incorrect for JSON Schema: change properties from an array to a map
(properties: Record<string, RegisterFunctionFormat> | undefined) and make
required accept JSON Schema-style string arrays (required?: string[]), or to
preserve backwards compatibility allow required?: boolean | string[]; update any
consumers expecting the old array/boolean shapes (references to
RegisterFunctionFormat.properties and RegisterFunctionFormat.required) to handle
the new types accordingly.

---

Nitpick comments:
In `@sdk/packages/node/iii-example/src/iii.ts`:
- Around line 4-6: Replace the JSDoc-style suppression before the engineWsUrl
declaration with the standard single-line TypeScript suppression or add a proper
type assertion: change the comment above the const engineWsUrl declaration to
use "// `@ts-expect-error` process.env is not typed" or alternatively
declare/augment the environment variable types (or cast process.env.III_URL as
string | undefined) so the const engineWsUrl = process.env.III_URL ??
'ws://localhost:49134' no longer relies on the unconventional /**
`@ts-expect-error` */ form.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7c9b776d-1cf7-47b4-aff2-80cda464f245

📥 Commits

Reviewing files that changed from the base of the PR and between 36af497 and 285c11e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • sdk/packages/node/iii-example/package.json
  • sdk/packages/node/iii-example/src/iii-zod-example.ts
  • sdk/packages/node/iii-example/src/iii.ts
  • sdk/packages/node/iii-example/src/index.ts
  • sdk/packages/node/iii-example/src/state.ts
  • sdk/packages/node/iii/package.json
  • sdk/packages/node/iii/src/iii-types.ts
  • sdk/packages/node/iii/tsdown.config.ts

@sergiofilhowz sergiofilhowz dismissed stale reviews from guibeira and ytallo via 5319fdc March 24, 2026 10:42
@sergiofilhowz sergiofilhowz merged commit 9edc900 into main Mar 24, 2026
10 of 13 checks passed
@sergiofilhowz sergiofilhowz deleted the feat/node-sdk-format-examples branch March 24, 2026 10:42
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.

3 participants