Class: RailsAgents::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_agents/client.rb

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Constructor Details

#initialize(config: RailsAgents.config) ⇒ Client

Returns a new instance of Client.



19
20
21
# File 'lib/rails_agents/client.rb', line 19

def initialize(config: RailsAgents.config)
  @config = config
end

Instance Method Details

#claim_connect(code) ⇒ Object



78
79
80
# File 'lib/rails_agents/client.rb', line 78

def claim_connect(code)
  post("/auth/connect/claim", { code: code }, auth: false)
end

#create_run(agent:, message:, session_id: nil, metadata: {}) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/rails_agents/client.rb', line 23

def create_run(agent:, message:, session_id: nil, metadata: {})
  post("/runs", {
    agent: agent,
    message: message,
    session_id: session_id,
    project_id: @config.project_id,
    metadata: 
  }.compact)
end

#deploy(agent:, bundle_path: nil) ⇒ Object



37
38
39
40
41
# File 'lib/rails_agents/client.rb', line 37

def deploy(agent:, bundle_path: nil)
  payload = { agent: agent, project_id: @config.project_id }
  payload[:bundle_path] = bundle_path if bundle_path
  post("/deploys", payload)
end

#email_start(email:, purpose:, name: nil, company: nil) ⇒ Object



82
83
84
85
86
87
88
89
# File 'lib/rails_agents/client.rb', line 82

def email_start(email:, purpose:, name: nil, company: nil)
  post("/auth/email/start", {
    email: email,
    purpose: purpose,
    name: name,
    company: company
  }.compact, auth: false)
end

#email_verify(email:, code:, name: nil, company: nil) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/rails_agents/client.rb', line 91

def email_verify(email:, code:, name: nil, company: nil)
  post("/auth/email/verify", {
    email: email,
    code: code,
    name: name,
    company: company
  }.compact, auth: false)
end

#evals(agent: nil) ⇒ Object



108
109
110
# File 'lib/rails_agents/client.rb', line 108

def evals(agent: nil)
  get("/evals", query: { agent: agent, project_id: @config.project_id }.compact)
end

#get_agent(agent:) ⇒ Object



58
59
60
# File 'lib/rails_agents/client.rb', line 58

def get_agent(agent:)
  get("/agents/#{agent}")
end

#handshake(email:, password:, workspace: nil) ⇒ Object



70
71
72
73
74
75
76
# File 'lib/rails_agents/client.rb', line 70

def handshake(email:, password:, workspace: nil)
  post("/auth/handshake", {
    email: email,
    password: password,
    workspace: workspace
  }.compact, auth: false)
end

#install_channel(kind:, redirect_url: nil) ⇒ Object



43
44
45
46
47
48
# File 'lib/rails_agents/client.rb', line 43

def install_channel(kind:, redirect_url: nil)
  post("/channels/#{kind}/install", {
    project_id: @config.project_id,
    redirect_url: redirect_url
  }.compact)
end

#install_package(payload) ⇒ Object



116
117
118
# File 'lib/rails_agents/client.rb', line 116

def install_package(payload)
  post("/packages", payload)
end

#list_files(agent:) ⇒ Object



66
67
68
# File 'lib/rails_agents/client.rb', line 66

def list_files(agent:)
  get("/agents/#{agent}/files")
end

#logs(agent: nil, limit: 50) ⇒ Object



100
101
102
# File 'lib/rails_agents/client.rb', line 100

def logs(agent: nil, limit: 50)
  get("/logs", query: { agent: agent, limit: limit, project_id: @config.project_id }.compact)
end

#search_packages(query:, registry: "all", limit: 18) ⇒ Object



112
113
114
# File 'lib/rails_agents/client.rb', line 112

def search_packages(query:, registry: "all", limit: 18)
  get("/packages", query: { q: query, registry: registry, limit: limit }.compact)
end

#stream_run(run_id, &block) ⇒ Object



33
34
35
# File 'lib/rails_agents/client.rb', line 33

def stream_run(run_id, &block)
  get_stream("/runs/#{run_id}/stream", &block)
end

#sync_files(agent:, files:) ⇒ Object



62
63
64
# File 'lib/rails_agents/client.rb', line 62

def sync_files(agent:, files:)
  put("/agents/#{agent}/files", { files: files })
end

#sync_knowledge(agent:, paths: []) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/rails_agents/client.rb', line 50

def sync_knowledge(agent:, paths: [])
  post("/knowledge/sync", {
    agent: agent,
    project_id: @config.project_id,
    paths: paths
  })
end

#traces(agent: nil, limit: 50) ⇒ Object



104
105
106
# File 'lib/rails_agents/client.rb', line 104

def traces(agent: nil, limit: 50)
  get("/traces", query: { agent: agent, limit: limit, project_id: @config.project_id }.compact)
end