handinger 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +1 -1
  4. data/lib/handinger/models/workers/update_webhook.rb +22 -0
  5. data/lib/handinger/models/workers/webhook.rb +32 -0
  6. data/lib/handinger/models/workers/webhook_delete_params.rb +22 -0
  7. data/lib/handinger/models/workers/webhook_execution.rb +102 -0
  8. data/lib/handinger/models/workers/webhook_execution_list.rb +42 -0
  9. data/lib/handinger/models/workers/webhook_list_executions_params.rb +31 -0
  10. data/lib/handinger/models/workers/webhook_regenerate_token_params.rb +22 -0
  11. data/lib/handinger/models/workers/webhook_retrieve_params.rb +22 -0
  12. data/lib/handinger/models/workers/webhook_update_params.rb +22 -0
  13. data/lib/handinger/resources/workers/webhooks.rb +138 -0
  14. data/lib/handinger/resources/workers.rb +5 -0
  15. data/lib/handinger/version.rb +1 -1
  16. data/lib/handinger.rb +10 -0
  17. data/rbi/handinger/models/workers/update_webhook.rbi +34 -0
  18. data/rbi/handinger/models/workers/webhook.rbi +45 -0
  19. data/rbi/handinger/models/workers/webhook_delete_params.rbi +40 -0
  20. data/rbi/handinger/models/workers/webhook_execution.rbi +146 -0
  21. data/rbi/handinger/models/workers/webhook_execution_list.rbi +64 -0
  22. data/rbi/handinger/models/workers/webhook_list_executions_params.rbi +57 -0
  23. data/rbi/handinger/models/workers/webhook_regenerate_token_params.rbi +40 -0
  24. data/rbi/handinger/models/workers/webhook_retrieve_params.rbi +40 -0
  25. data/rbi/handinger/models/workers/webhook_update_params.rbi +40 -0
  26. data/rbi/handinger/resources/workers/webhooks.rbi +101 -0
  27. data/rbi/handinger/resources/workers.rbi +4 -0
  28. data/sig/handinger/models/workers/update_webhook.rbs +15 -0
  29. data/sig/handinger/models/workers/webhook.rbs +17 -0
  30. data/sig/handinger/models/workers/webhook_delete_params.rbs +25 -0
  31. data/sig/handinger/models/workers/webhook_execution.rbs +78 -0
  32. data/sig/handinger/models/workers/webhook_execution_list.rbs +37 -0
  33. data/sig/handinger/models/workers/webhook_list_executions_params.rbs +32 -0
  34. data/sig/handinger/models/workers/webhook_regenerate_token_params.rbs +25 -0
  35. data/sig/handinger/models/workers/webhook_retrieve_params.rbs +25 -0
  36. data/sig/handinger/models/workers/webhook_update_params.rbs +27 -0
  37. data/sig/handinger/resources/workers/webhooks.rbs +36 -0
  38. data/sig/handinger/resources/workers.rbs +2 -0
  39. metadata +31 -1
@@ -0,0 +1,146 @@
1
+ # typed: strong
2
+
3
+ module Handinger
4
+ module Models
5
+ module Workers
6
+ class WebhookExecution < Handinger::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ Handinger::Workers::WebhookExecution,
11
+ Handinger::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ sig { returns(String) }
16
+ attr_accessor :id
17
+
18
+ sig { returns(Time) }
19
+ attr_accessor :created_at
20
+
21
+ # Wall-clock time spent on the delivery attempt.
22
+ sig { returns(Integer) }
23
+ attr_accessor :duration_ms
24
+
25
+ # Failure reason when `requestStatus` is `error`.
26
+ sig { returns(T.nilable(String)) }
27
+ attr_accessor :error_message
28
+
29
+ # `success` when the endpoint returned a 2xx response, `error` otherwise.
30
+ sig do
31
+ returns(
32
+ Handinger::Workers::WebhookExecution::RequestStatus::TaggedSymbol
33
+ )
34
+ end
35
+ attr_accessor :request_status
36
+
37
+ # HTTP status returned by the endpoint, when reachable.
38
+ sig { returns(T.nilable(Integer)) }
39
+ attr_accessor :response_status
40
+
41
+ # Task that triggered the delivery, when available.
42
+ sig { returns(T.nilable(String)) }
43
+ attr_accessor :task_id
44
+
45
+ # Title of the originating task, when available.
46
+ sig { returns(T.nilable(String)) }
47
+ attr_accessor :task_title
48
+
49
+ # Endpoint Handinger attempted to deliver to.
50
+ sig { returns(String) }
51
+ attr_accessor :url
52
+
53
+ sig { returns(String) }
54
+ attr_accessor :worker_id
55
+
56
+ sig do
57
+ params(
58
+ id: String,
59
+ created_at: Time,
60
+ duration_ms: Integer,
61
+ error_message: T.nilable(String),
62
+ request_status:
63
+ Handinger::Workers::WebhookExecution::RequestStatus::OrSymbol,
64
+ response_status: T.nilable(Integer),
65
+ task_id: T.nilable(String),
66
+ task_title: T.nilable(String),
67
+ url: String,
68
+ worker_id: String
69
+ ).returns(T.attached_class)
70
+ end
71
+ def self.new(
72
+ id:,
73
+ created_at:,
74
+ # Wall-clock time spent on the delivery attempt.
75
+ duration_ms:,
76
+ # Failure reason when `requestStatus` is `error`.
77
+ error_message:,
78
+ # `success` when the endpoint returned a 2xx response, `error` otherwise.
79
+ request_status:,
80
+ # HTTP status returned by the endpoint, when reachable.
81
+ response_status:,
82
+ # Task that triggered the delivery, when available.
83
+ task_id:,
84
+ # Title of the originating task, when available.
85
+ task_title:,
86
+ # Endpoint Handinger attempted to deliver to.
87
+ url:,
88
+ worker_id:
89
+ )
90
+ end
91
+
92
+ sig do
93
+ override.returns(
94
+ {
95
+ id: String,
96
+ created_at: Time,
97
+ duration_ms: Integer,
98
+ error_message: T.nilable(String),
99
+ request_status:
100
+ Handinger::Workers::WebhookExecution::RequestStatus::TaggedSymbol,
101
+ response_status: T.nilable(Integer),
102
+ task_id: T.nilable(String),
103
+ task_title: T.nilable(String),
104
+ url: String,
105
+ worker_id: String
106
+ }
107
+ )
108
+ end
109
+ def to_hash
110
+ end
111
+
112
+ # `success` when the endpoint returned a 2xx response, `error` otherwise.
113
+ module RequestStatus
114
+ extend Handinger::Internal::Type::Enum
115
+
116
+ TaggedSymbol =
117
+ T.type_alias do
118
+ T.all(Symbol, Handinger::Workers::WebhookExecution::RequestStatus)
119
+ end
120
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
121
+
122
+ SUCCESS =
123
+ T.let(
124
+ :success,
125
+ Handinger::Workers::WebhookExecution::RequestStatus::TaggedSymbol
126
+ )
127
+ ERROR =
128
+ T.let(
129
+ :error,
130
+ Handinger::Workers::WebhookExecution::RequestStatus::TaggedSymbol
131
+ )
132
+
133
+ sig do
134
+ override.returns(
135
+ T::Array[
136
+ Handinger::Workers::WebhookExecution::RequestStatus::TaggedSymbol
137
+ ]
138
+ )
139
+ end
140
+ def self.values
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,64 @@
1
+ # typed: strong
2
+
3
+ module Handinger
4
+ module Models
5
+ module Workers
6
+ class WebhookExecutionList < Handinger::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ Handinger::Workers::WebhookExecutionList,
11
+ Handinger::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ sig { returns(T::Array[Handinger::Workers::WebhookExecution]) }
16
+ attr_accessor :logs
17
+
18
+ # Current page number.
19
+ sig { returns(Integer) }
20
+ attr_accessor :page
21
+
22
+ # Total number of pages available.
23
+ sig { returns(Integer) }
24
+ attr_accessor :page_count
25
+
26
+ # Total number of executions recorded.
27
+ sig { returns(Integer) }
28
+ attr_accessor :total_count
29
+
30
+ sig do
31
+ params(
32
+ logs: T::Array[Handinger::Workers::WebhookExecution::OrHash],
33
+ page: Integer,
34
+ page_count: Integer,
35
+ total_count: Integer
36
+ ).returns(T.attached_class)
37
+ end
38
+ def self.new(
39
+ logs:,
40
+ # Current page number.
41
+ page:,
42
+ # Total number of pages available.
43
+ page_count:,
44
+ # Total number of executions recorded.
45
+ total_count:
46
+ )
47
+ end
48
+
49
+ sig do
50
+ override.returns(
51
+ {
52
+ logs: T::Array[Handinger::Workers::WebhookExecution],
53
+ page: Integer,
54
+ page_count: Integer,
55
+ total_count: Integer
56
+ }
57
+ )
58
+ end
59
+ def to_hash
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,57 @@
1
+ # typed: strong
2
+
3
+ module Handinger
4
+ module Models
5
+ module Workers
6
+ class WebhookListExecutionsParams < Handinger::Internal::Type::BaseModel
7
+ extend Handinger::Internal::Type::RequestParameters::Converter
8
+ include Handinger::Internal::Type::RequestParameters
9
+
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Handinger::Workers::WebhookListExecutionsParams,
14
+ Handinger::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ sig { returns(String) }
19
+ attr_accessor :worker_id
20
+
21
+ # Page number (1-indexed). Defaults to 1.
22
+ sig { returns(T.nilable(Integer)) }
23
+ attr_reader :page
24
+
25
+ sig { params(page: Integer).void }
26
+ attr_writer :page
27
+
28
+ sig do
29
+ params(
30
+ worker_id: String,
31
+ page: Integer,
32
+ request_options: Handinger::RequestOptions::OrHash
33
+ ).returns(T.attached_class)
34
+ end
35
+ def self.new(
36
+ worker_id:,
37
+ # Page number (1-indexed). Defaults to 1.
38
+ page: nil,
39
+ request_options: {}
40
+ )
41
+ end
42
+
43
+ sig do
44
+ override.returns(
45
+ {
46
+ worker_id: String,
47
+ page: Integer,
48
+ request_options: Handinger::RequestOptions
49
+ }
50
+ )
51
+ end
52
+ def to_hash
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,40 @@
1
+ # typed: strong
2
+
3
+ module Handinger
4
+ module Models
5
+ module Workers
6
+ class WebhookRegenerateTokenParams < Handinger::Internal::Type::BaseModel
7
+ extend Handinger::Internal::Type::RequestParameters::Converter
8
+ include Handinger::Internal::Type::RequestParameters
9
+
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Handinger::Workers::WebhookRegenerateTokenParams,
14
+ Handinger::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ sig { returns(String) }
19
+ attr_accessor :worker_id
20
+
21
+ sig do
22
+ params(
23
+ worker_id: String,
24
+ request_options: Handinger::RequestOptions::OrHash
25
+ ).returns(T.attached_class)
26
+ end
27
+ def self.new(worker_id:, request_options: {})
28
+ end
29
+
30
+ sig do
31
+ override.returns(
32
+ { worker_id: String, request_options: Handinger::RequestOptions }
33
+ )
34
+ end
35
+ def to_hash
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ # typed: strong
2
+
3
+ module Handinger
4
+ module Models
5
+ module Workers
6
+ class WebhookRetrieveParams < Handinger::Internal::Type::BaseModel
7
+ extend Handinger::Internal::Type::RequestParameters::Converter
8
+ include Handinger::Internal::Type::RequestParameters
9
+
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Handinger::Workers::WebhookRetrieveParams,
14
+ Handinger::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ sig { returns(String) }
19
+ attr_accessor :worker_id
20
+
21
+ sig do
22
+ params(
23
+ worker_id: String,
24
+ request_options: Handinger::RequestOptions::OrHash
25
+ ).returns(T.attached_class)
26
+ end
27
+ def self.new(worker_id:, request_options: {})
28
+ end
29
+
30
+ sig do
31
+ override.returns(
32
+ { worker_id: String, request_options: Handinger::RequestOptions }
33
+ )
34
+ end
35
+ def to_hash
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ # typed: strong
2
+
3
+ module Handinger
4
+ module Models
5
+ module Workers
6
+ class WebhookUpdateParams < Handinger::Models::Workers::UpdateWebhook
7
+ extend Handinger::Internal::Type::RequestParameters::Converter
8
+ include Handinger::Internal::Type::RequestParameters
9
+
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Handinger::Workers::WebhookUpdateParams,
14
+ Handinger::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ sig { returns(String) }
19
+ attr_accessor :worker_id
20
+
21
+ sig do
22
+ params(
23
+ worker_id: String,
24
+ request_options: Handinger::RequestOptions::OrHash
25
+ ).returns(T.attached_class)
26
+ end
27
+ def self.new(worker_id:, request_options: {})
28
+ end
29
+
30
+ sig do
31
+ override.returns(
32
+ { worker_id: String, request_options: Handinger::RequestOptions }
33
+ )
34
+ end
35
+ def to_hash
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,101 @@
1
+ # typed: strong
2
+
3
+ module Handinger
4
+ module Resources
5
+ class Workers
6
+ # Configure outbound webhooks delivered when a worker's tasks complete.
7
+ class Webhooks
8
+ # Retrieve the webhook URL and shared token configured for a worker. Both fields
9
+ # are `null` when no webhook is configured. Only the worker creator can read the
10
+ # webhook configuration.
11
+ sig do
12
+ params(
13
+ worker_id: String,
14
+ request_options: Handinger::RequestOptions::OrHash
15
+ ).returns(Handinger::Workers::Webhook)
16
+ end
17
+ def retrieve(
18
+ # Worker id returned by the create worker endpoint.
19
+ worker_id,
20
+ request_options: {}
21
+ )
22
+ end
23
+
24
+ # Set or replace the webhook URL for a worker. A fresh token is generated the
25
+ # first time a URL is set; subsequent updates keep the existing token. Pass
26
+ # `url: null` to clear the webhook (use the dedicated DELETE for the same effect).
27
+ # Only the worker creator can update the webhook.
28
+ sig do
29
+ params(
30
+ worker_id: String,
31
+ url: T.nilable(String),
32
+ request_options: Handinger::RequestOptions::OrHash
33
+ ).returns(Handinger::Workers::Webhook)
34
+ end
35
+ def update(
36
+ # Worker id returned by the create worker endpoint.
37
+ worker_id,
38
+ # HTTPS endpoint Handinger should POST to when a task finishes. Pass `null` to
39
+ # remove the webhook and clear its token.
40
+ url:,
41
+ request_options: {}
42
+ )
43
+ end
44
+
45
+ # Remove the webhook from a worker. Both `url` and `token` are cleared and no
46
+ # further deliveries are attempted. Only the worker creator can delete the
47
+ # webhook.
48
+ sig do
49
+ params(
50
+ worker_id: String,
51
+ request_options: Handinger::RequestOptions::OrHash
52
+ ).returns(Handinger::Workers::Webhook)
53
+ end
54
+ def delete(
55
+ # Worker id returned by the create worker endpoint.
56
+ worker_id,
57
+ request_options: {}
58
+ )
59
+ end
60
+
61
+ # List recent webhook delivery attempts for a worker, newest first, paginated 50
62
+ # per page. Only the worker creator can read execution history.
63
+ sig do
64
+ params(
65
+ worker_id: String,
66
+ page: Integer,
67
+ request_options: Handinger::RequestOptions::OrHash
68
+ ).returns(Handinger::Workers::WebhookExecutionList)
69
+ end
70
+ def list_executions(
71
+ # Worker id returned by the create worker endpoint.
72
+ worker_id,
73
+ # Page number (1-indexed). Defaults to 1.
74
+ page: nil,
75
+ request_options: {}
76
+ )
77
+ end
78
+
79
+ # Issue a new shared token for the webhook, invalidating the previous one. The
80
+ # webhook URL is preserved. Only the worker creator can regenerate the token.
81
+ sig do
82
+ params(
83
+ worker_id: String,
84
+ request_options: Handinger::RequestOptions::OrHash
85
+ ).returns(Handinger::Workers::Webhook)
86
+ end
87
+ def regenerate_token(
88
+ # Worker id returned by the create worker endpoint.
89
+ worker_id,
90
+ request_options: {}
91
+ )
92
+ end
93
+
94
+ # @api private
95
+ sig { params(client: Handinger::Client).returns(T.attached_class) }
96
+ def self.new(client:)
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
@@ -8,6 +8,10 @@ module Handinger
8
8
  sig { returns(Handinger::Resources::Workers::Schedules) }
9
9
  attr_reader :schedules
10
10
 
11
+ # Configure outbound webhooks delivered when a worker's tasks complete.
12
+ sig { returns(Handinger::Resources::Workers::Webhooks) }
13
+ attr_reader :webhooks
14
+
11
15
  # Create a new worker. The worker is a reusable agent template; tasks are runs
12
16
  # against this template. Use `POST /tasks` to actually run the agent.
13
17
  sig do
@@ -0,0 +1,15 @@
1
+ module Handinger
2
+ module Models
3
+ module Workers
4
+ type update_webhook = { url: String? }
5
+
6
+ class UpdateWebhook < Handinger::Internal::Type::BaseModel
7
+ attr_accessor url: String?
8
+
9
+ def initialize: (url: String?) -> void
10
+
11
+ def to_hash: -> { url: String? }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ module Handinger
2
+ module Models
3
+ module Workers
4
+ type webhook = { token: String?, url: String? }
5
+
6
+ class Webhook < Handinger::Internal::Type::BaseModel
7
+ attr_accessor token: String?
8
+
9
+ attr_accessor url: String?
10
+
11
+ def initialize: (token: String?, url: String?) -> void
12
+
13
+ def to_hash: -> { token: String?, url: String? }
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ module Handinger
2
+ module Models
3
+ module Workers
4
+ type webhook_delete_params =
5
+ { worker_id: String } & Handinger::Internal::Type::request_parameters
6
+
7
+ class WebhookDeleteParams < Handinger::Internal::Type::BaseModel
8
+ extend Handinger::Internal::Type::RequestParameters::Converter
9
+ include Handinger::Internal::Type::RequestParameters
10
+
11
+ attr_accessor worker_id: String
12
+
13
+ def initialize: (
14
+ worker_id: String,
15
+ ?request_options: Handinger::request_opts
16
+ ) -> void
17
+
18
+ def to_hash: -> {
19
+ worker_id: String,
20
+ request_options: Handinger::RequestOptions
21
+ }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,78 @@
1
+ module Handinger
2
+ module Models
3
+ module Workers
4
+ type webhook_execution =
5
+ {
6
+ id: String,
7
+ created_at: Time,
8
+ duration_ms: Integer,
9
+ error_message: String?,
10
+ request_status: Handinger::Models::Workers::WebhookExecution::request_status,
11
+ response_status: Integer?,
12
+ task_id: String?,
13
+ task_title: String?,
14
+ url: String,
15
+ worker_id: String
16
+ }
17
+
18
+ class WebhookExecution < Handinger::Internal::Type::BaseModel
19
+ attr_accessor id: String
20
+
21
+ attr_accessor created_at: Time
22
+
23
+ attr_accessor duration_ms: Integer
24
+
25
+ attr_accessor error_message: String?
26
+
27
+ attr_accessor request_status: Handinger::Models::Workers::WebhookExecution::request_status
28
+
29
+ attr_accessor response_status: Integer?
30
+
31
+ attr_accessor task_id: String?
32
+
33
+ attr_accessor task_title: String?
34
+
35
+ attr_accessor url: String
36
+
37
+ attr_accessor worker_id: String
38
+
39
+ def initialize: (
40
+ id: String,
41
+ created_at: Time,
42
+ duration_ms: Integer,
43
+ error_message: String?,
44
+ request_status: Handinger::Models::Workers::WebhookExecution::request_status,
45
+ response_status: Integer?,
46
+ task_id: String?,
47
+ task_title: String?,
48
+ url: String,
49
+ worker_id: String
50
+ ) -> void
51
+
52
+ def to_hash: -> {
53
+ id: String,
54
+ created_at: Time,
55
+ duration_ms: Integer,
56
+ error_message: String?,
57
+ request_status: Handinger::Models::Workers::WebhookExecution::request_status,
58
+ response_status: Integer?,
59
+ task_id: String?,
60
+ task_title: String?,
61
+ url: String,
62
+ worker_id: String
63
+ }
64
+
65
+ type request_status = :success | :error
66
+
67
+ module RequestStatus
68
+ extend Handinger::Internal::Type::Enum
69
+
70
+ SUCCESS: :success
71
+ ERROR: :error
72
+
73
+ def self?.values: -> ::Array[Handinger::Models::Workers::WebhookExecution::request_status]
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,37 @@
1
+ module Handinger
2
+ module Models
3
+ module Workers
4
+ type webhook_execution_list =
5
+ {
6
+ logs: ::Array[Handinger::Workers::WebhookExecution],
7
+ page: Integer,
8
+ page_count: Integer,
9
+ total_count: Integer
10
+ }
11
+
12
+ class WebhookExecutionList < Handinger::Internal::Type::BaseModel
13
+ attr_accessor logs: ::Array[Handinger::Workers::WebhookExecution]
14
+
15
+ attr_accessor page: Integer
16
+
17
+ attr_accessor page_count: Integer
18
+
19
+ attr_accessor total_count: Integer
20
+
21
+ def initialize: (
22
+ logs: ::Array[Handinger::Workers::WebhookExecution],
23
+ page: Integer,
24
+ page_count: Integer,
25
+ total_count: Integer
26
+ ) -> void
27
+
28
+ def to_hash: -> {
29
+ logs: ::Array[Handinger::Workers::WebhookExecution],
30
+ page: Integer,
31
+ page_count: Integer,
32
+ total_count: Integer
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end