Skip to content

Packages  ›  trotsky  ›  StepSave

StepSave class

A step that saves the current output to a JSON file at the specified path.

Signature:

typescript
export declare class StepSave<P = StepBuilder, C = null, O = string> extends Step<P, C, O>

Extends: Step<P, C, O>

Example 1

Save search results to a file:

ts
await Trotsky.init(agent)
  .searchPosts({ q: "typescript tips" })
  .take(20)
  .each()
  .when((step) => step?.context?.likeCount > 10)
  .save("typescript-tips.json")
  .run()

Example 2

Save actor profiles:

ts
await Trotsky.init(agent)
  .actors(["alice.bsky.social", "bob.bsky.social", "carol.bsky.social"])
  .each()
  .save("profiles.json")
  .run()

Constructors

Constructor

Modifiers

Description

(constructor)(agent, parent, path)

Initializes the StepSave instance with the given path.

Properties

Property

Modifiers

Type

Description

_path

protected

StepSavePath

Path of the JSON file to save the current output.

Methods

Method

Modifiers

Description

apply()

Applies the step logic to save the output to a JSON file.

clone(rest)

Clones the current step and returns a new instance with the same parameters.