Class: Handinger::Resources::Workers

Inherits:
Object
  • Object
show all
Defined in:
lib/handinger/resources/workers.rb,
lib/handinger/resources/workers/schedules.rb

Overview

Create, retrieve, and manage agent worker templates.

Defined Under Namespace

Classes: Schedules

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Workers

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Workers.

Parameters:



100
101
102
103
# File 'lib/handinger/resources/workers.rb', line 100

def initialize(client:)
  @client = client
  @schedules = Handinger::Resources::Workers::Schedules.new(client: client)
end

Instance Attribute Details

#schedulesHandinger::Resources::Workers::Schedules (readonly)

Manage future and recurring worker tasks.



9
10
11
# File 'lib/handinger/resources/workers.rb', line 9

def schedules
  @schedules
end

Instance Method Details

#create(instructions: nil, output_schema: nil, prompt: nil, summary: nil, title: nil, visibility: nil, request_options: {}) ⇒ Handinger::Models::WorkerCreateResponse

Some parameter documentations has been truncated, see Models::WorkerCreateParams for more details.

Create a new worker. The worker is a reusable agent template; tasks are runs against this template. Use ‘POST /tasks` to actually run the agent.

Parameters:

  • instructions (String)

    Persistent system prompt the worker uses for every task it runs.

  • output_schema (Hash{Symbol=>Object})

    Optional JSON Schema (Draft-07) describing the structured object the worker must

  • prompt (String)

    Natural-language description of the worker to use for AI-generated instructions

  • summary (String)

    Short one-line description of the worker’s purpose. Auto-generated when omitted

  • title (String)

    Optional display name. When omitted, Handinger assigns a random dog-themed name.

  • visibility (Symbol, Handinger::Models::CreateWorker::Visibility)

    ‘public` (default) is visible to all org members. `private` is only visible to i

  • request_options (Handinger::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



36
37
38
39
40
41
42
43
44
45
# File 'lib/handinger/resources/workers.rb', line 36

def create(params = {})
  parsed, options = Handinger::WorkerCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/workers",
    body: parsed,
    model: Handinger::Models::WorkerCreateResponse,
    options: options
  )
end

#retrieve(worker_id, stream: nil, request_options: {}) ⇒ Handinger::Models::Worker

Some parameter documentations has been truncated, see Models::WorkerRetrieveParams for more details.

Retrieve the current worker state and messages from its most recent task. Returns a JSON worker object by default, or a server-sent event stream when ‘stream=true`.

Parameters:

Returns:

See Also:



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/handinger/resources/workers.rb', line 65

def retrieve(worker_id, params = {})
  parsed, options = Handinger::WorkerRetrieveParams.dump_request(params)
  query = Handinger::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/workers/%1$s", worker_id],
    query: query,
    model: Handinger::Worker,
    options: options
  )
end

#retrieve_email(worker_id, request_options: {}) ⇒ Handinger::Models::WorkerRetrieveEmailResponse

Retrieve the inbound email address for a worker.

Parameters:

  • worker_id (String)

    Worker id returned by the create worker endpoint.

  • request_options (Handinger::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



88
89
90
91
92
93
94
95
# File 'lib/handinger/resources/workers.rb', line 88

def retrieve_email(worker_id, params = {})
  @client.request(
    method: :get,
    path: ["api/workers/%1$s/email", worker_id],
    model: Handinger::Models::WorkerRetrieveEmailResponse,
    options: params[:request_options]
  )
end