Class: SolidAgent::AgentManifest::Registry::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_agent/agent_manifest/registry/client.rb

Overview

Client provides HTTP API access to the ActiveAgents registry.

Examples:

Search for agents

client = Registry::Client.new
results = client.search(q: "research", tags: ["assistant"])

Download an agent

client.download("@anthropic/research-assistant", path: "./agents/")

Publish an agent

client = Registry::Client.new(token: "aa_live_xxx")
client.publish("./research-assistant.agent.md")

Constant Summary collapse

BASE_URL =
"https://api.activeagents.ai/v1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token: nil, base_url: BASE_URL) ⇒ Client

Initialize a new client

Parameters:

  • token (String, nil) (defaults to: nil)

    Auth token (uses Auth.token if nil)

  • base_url (String) (defaults to: BASE_URL)

    API base URL



33
34
35
36
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 33

def initialize(token: nil, base_url: BASE_URL)
  @token = token || Auth.token
  @base_url = base_url
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



27
28
29
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 27

def base_url
  @base_url
end

#tokenObject (readonly)

Returns the value of attribute token.



27
28
29
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 27

def token
  @token
end

Instance Method Details

#deprecate(name, version, message:) ⇒ Hash

Deprecate a version

Parameters:

  • name (String)

    Agent name

  • version (String)

    Version to deprecate

  • message (String)

    Deprecation message

Returns:

  • (Hash)

    Updated version info



178
179
180
181
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 178

def deprecate(name, version, message:)
  require_auth!
  patch("/agents/#{encode_name(name)}/versions/#{version}", { deprecated: true, deprecation_message: message })
end

#download(name, version: nil, path: nil, format: :agent_md) ⇒ String

Download an agent manifest

Parameters:

  • name (String)

    Agent name

  • version (String, nil) (defaults to: nil)

    Specific version

  • path (String, nil) (defaults to: nil)

    Download directory (current dir if nil)

  • format (Symbol) (defaults to: :agent_md)

    Output format (:agent_md, :dotprompt, etc.)

Returns:

  • (String)

    Path to downloaded file



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 91

def download(name, version: nil, path: nil, format: :agent_md)
  # Get agent metadata
  agent = get(name, version: version)

  # Determine output path
  output_dir = path || Dir.pwd
  FileUtils.mkdir_p(output_dir)

  filename = agent_filename(agent, format)
  output_path = File.join(output_dir, filename)

  # Download content
  content_url = agent["download_url"] || agent.dig("links", "download")
  if content_url
    content = fetch_content(content_url)
  else
    # Fetch from content endpoint
    content = get_request("/agents/#{encode_name(name)}/content", accept: "text/markdown")
  end

  # Convert format if needed
  source_format = agent["format"]&.to_sym || :agent_md
  if format != source_format
    manifest = ParserRegistry.parse_string(content, format: source_format)
    content = ExporterRegistry.export(manifest, format)
  end

  File.write(output_path, content, encoding: "UTF-8")
  output_path
end

#download_file(name, file_path, version: nil) ⇒ String

Download a specific file from an agent package

Parameters:

  • name (String)

    Agent name

  • file_path (String)

    Path within the package

  • version (String, nil) (defaults to: nil)

    Specific version

Returns:

  • (String)

    File content



128
129
130
131
132
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 128

def download_file(name, file_path, version: nil)
  path = "/agents/#{encode_name(name)}/files/#{file_path}"
  path += "?version=#{version}" if version
  get_request(path, accept: "*/*")
end

#fork(name, new_name:, scope: nil) ⇒ Hash

Fork an agent

Parameters:

  • name (String)

    Source agent name

  • new_name (String)

    Name for the fork

  • scope (String, nil) (defaults to: nil)

    Organization scope

Returns:

  • (Hash)

    Forked agent info



222
223
224
225
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 222

def fork(name, new_name:, scope: nil)
  require_auth!
  post("/agents/#{encode_name(name)}/fork", { new_name: new_name, scope: scope })
end

#get(name, version: nil) ⇒ Hash

Get an agent by name

Parameters:

  • name (String)

    Agent name (e.g., "@anthropic/research-assistant")

  • version (String, nil) (defaults to: nil)

    Specific version (latest if nil)

Returns:

  • (Hash)

    Agent metadata



69
70
71
72
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 69

def get(name, version: nil)
  path = version ? "/agents/#{encode_name(name)}/versions/#{version}" : "/agents/#{encode_name(name)}"
  get_request(path)
end

#meHash

Get current user info

Returns:

  • (Hash)

    User info



256
257
258
259
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 256

def me
  require_auth!
  get_request("/me")
end

#my_agentsArray<Hash>

Get user's published agents

Returns:

  • (Array<Hash>)

    Published agents



272
273
274
275
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 272

def my_agents
  require_auth!
  get_request("/me/agents")
end

#my_starsArray<Hash>

Get user's starred agents

Returns:

  • (Array<Hash>)

    Starred agents



264
265
266
267
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 264

def my_stars
  require_auth!
  get_request("/me/stars")
end

#publish(path, tag: "latest", scope: nil, access: "public") ⇒ Hash

Publish an agent manifest

Parameters:

  • path (String)

    Path to manifest file

  • tag (String) (defaults to: "latest")

    Version tag ("latest", "beta", etc.)

  • scope (String, nil) (defaults to: nil)

    Organization scope

  • access (String) (defaults to: "public")

    Access level ("public", "private")

Returns:

  • (Hash)

    Published agent info



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 143

def publish(path, tag: "latest", scope: nil, access: "public")
  require_auth!

  manifest = AgentManifest.parse(path)
  AgentManifest.validate!(manifest, strict: true)

  content = File.read(path, encoding: "UTF-8")
  format = ParserRegistry.detect_format(path)

  body = {
    name: scope ? "#{scope}/#{manifest.name}" : manifest.name,
    version: manifest.version,
    tag: tag,
    access: access,
    format: format,
    content: content,
    metadata: {
      description: manifest.description,
      tags: manifest.tags,
      model: manifest.model,
      author: manifest.author,
      license: manifest.license,
      repository: manifest.repository
    }
  }

  post("/agents", body)
end

#run(name, input:, model: nil, stream: false) ⇒ Hash

Run an agent in the sandbox

Parameters:

  • name (String)

    Agent name

  • input (Hash)

    Input parameters

  • model (String, nil) (defaults to: nil)

    Override model

  • stream (Boolean) (defaults to: false)

    Enable streaming

Returns:

  • (Hash)

    Run result or job info



236
237
238
239
240
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 236

def run(name, input:, model: nil, stream: false)
  require_auth!
  body = { input: input, model: model, stream: stream }.compact
  post("/agents/#{encode_name(name)}/run", body)
end

#run_status(run_id) ⇒ Hash

Get status of a sandbox run

Parameters:

  • run_id (String)

    Run ID

Returns:

  • (Hash)

    Run status



246
247
248
249
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 246

def run_status(run_id)
  require_auth!
  get_request("/runs/#{run_id}")
end

#search(q: nil, tags: nil, framework: nil, author: nil, sort: "popular", page: 1, per_page: 20) ⇒ Hash

Search for agents

Parameters:

  • q (String, nil) (defaults to: nil)

    Search query

  • tags (Array<String>, nil) (defaults to: nil)

    Filter by tags

  • framework (String, nil) (defaults to: nil)

    Filter by framework (e.g., "activeagent", "crewai")

  • author (String, nil) (defaults to: nil)

    Filter by author

  • sort (String) (defaults to: "popular")

    Sort order ("popular", "recent", "name")

  • page (Integer) (defaults to: 1)

    Page number

  • per_page (Integer) (defaults to: 20)

    Results per page

Returns:

  • (Hash)

    Search results with :agents, :total, :page keys



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 50

def search(q: nil, tags: nil, framework: nil, author: nil, sort: "popular", page: 1, per_page: 20)
  params = {
    q: q,
    tags: tags&.join(","),
    framework: framework,
    author: author,
    sort: sort,
    page: page,
    per_page: per_page
  }.compact

  get("/agents", params)
end

#star(name) ⇒ Boolean

Star an agent

Parameters:

  • name (String)

    Agent name

Returns:

  • (Boolean)


200
201
202
203
204
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 200

def star(name)
  require_auth!
  post("/agents/#{encode_name(name)}/star", {})
  true
end

#unpublish(name, version) ⇒ Boolean

Unpublish a version

Parameters:

  • name (String)

    Agent name

  • version (String)

    Version to remove

Returns:

  • (Boolean)


188
189
190
191
192
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 188

def unpublish(name, version)
  require_auth!
  delete("/agents/#{encode_name(name)}/versions/#{version}")
  true
end

#unstar(name) ⇒ Boolean

Unstar an agent

Parameters:

  • name (String)

    Agent name

Returns:

  • (Boolean)


210
211
212
213
214
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 210

def unstar(name)
  require_auth!
  delete("/agents/#{encode_name(name)}/star")
  true
end

#versions(name) ⇒ Array<Hash>

List all versions of an agent

Parameters:

  • name (String)

    Agent name

Returns:

  • (Array<Hash>)

    Version list



78
79
80
# File 'lib/solid_agent/agent_manifest/registry/client.rb', line 78

def versions(name)
  get_request("/agents/#{encode_name(name)}/versions")
end