migrate-ts-decorator-sdk

Migrates TypeScript Golem agents from the removed decorator API to the schema-driven defineAgent API.

1.5k|212|Updated Nov 24, 2023
One-click install
npx skills add https://github.com/golemcloud/golem --skill migrate-ts-decorator-sdk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-ts-decorator-sdk
Source: https://github.com/golemcloud/golem/tree/main/.agents/skills/migrate-ts-decorator-sdk
Command: npx skills add https://github.com/golemcloud/golem --skill migrate-ts-decorator-sdk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The decorator-based surface of @golemcloud/golem-ts-sdk (@agent classes extending BaseAgent, @endpoint, @prompt, and the golem-ts-typegen package) has been removed, so existing TypeScript Golem agents no longer compile. This Skill maps every removed construct to its current schema-driven replacement so agents can be ported without inventing compatibility shims.

Core Features & Use Cases

  • Construct-by-construct mapping: Converts @agent classes to defineAgent + .implement, constructor params to id records, class fields to init() state, and method signatures to method({ input, returns }) with Standard Schema.
  • Annotation and config migration: Translates @description/@prompt/@readonly/@endpoint into method options and http.mount, Config/Secret constructor params into a config record with s.secret markers, and save/loadSnapshot overrides into snapshotting policies or custom snapshot blocks.
  • Use Case: You have a CounterAgent written with @agent({ mount }) and @endpoint decorators that fails to build after an SDK upgrade; this Skill walks you through rewriting it as defineAgent({...}).implement({...}), updating tsconfig, and rebuilding against the local SDK packages.

Quick Start

Migrate my decorator-based TypeScript Golem agent in src/counter-agent.ts to the current defineAgent API and update my tsconfig accordingly.

Frequently Asked Questions about migrate-ts-decorator-sdk

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

FAQPage Schema
How do I migrate a Golem TypeScript agent away from @agent and BaseAgent?

Replace the @agent class with defineAgent({ name, id, methods }) for the contract and .implement({ init, methods }) for behavior. Constructor parameters become the id record, private class fields become state returned by init(), and handlers access that state through this.

What replaces @endpoint, @prompt, and @description decorators in golem-ts-sdk?

@endpoint({ post: '/x' }) becomes method({ http: http.post('/x') }) with a mount declared via defineAgent({ http: http.mount(...) }). @prompt maps to promptHint and @description maps to description, either on method options or on defineAgent for agent-level metadata.

Does the current golem-ts-sdk still support Config and Secret constructor parameters?

No, Config and Secret constructor parameter types are removed. Configuration is now a config record on defineAgent, with secret fields wrapped in s.secret(...) and exposed as lazy Secret<T> handles on this.config that you reveal with .get().

How do I convert saveSnapshot and loadSnapshot overrides to the new API?

Use the declarative snapshotting option on defineAgent with a typed state schema and a policy such as everyNInvocations or periodicSeconds. For fully custom bytes, supply a snapshot block with save and load methods on .implement, where save returns a Uint8Array.

Why does my decorator-based Golem agent no longer compile after upgrading the SDK?

The decorator surface including BaseAgent, @agent, and the golem-ts-typegen package was removed entirely from golem-ts-sdk. You must remove experimentalDecorators and emitDecoratorMetadata from tsconfig and rewrite agents using defineAgent and Standard Schema method definitions.

Can I keep compatibility wrappers for the old decorator API during migration?

No, the migration guidance explicitly forbids decorator facades, compatibility wrappers, aliases, or adapters that preserve the removed surface. Migrate directly to the current API and verify each API name against the SDK source in sdks/ts/packages/golem-ts-sdk/src.