oz-agent-sdk 0.1.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.
- checksums.yaml +7 -0
- data/AGENTS.md +23 -0
- data/CHANGELOG.md +30 -0
- data/CONTRIBUTING.md +60 -0
- data/Gemfile +6 -0
- data/LICENSE +201 -0
- data/Makefile +64 -0
- data/README.md +266 -0
- data/Rakefile +32 -0
- data/docs/api_reference.md +156 -0
- data/docs/configuration.md +84 -0
- data/docs/error_handling.md +87 -0
- data/docs/getting_started.md +92 -0
- data/docs/index.md +56 -0
- data/examples/identities.rb +35 -0
- data/examples/list_runs.rb +31 -0
- data/examples/run_agent.rb +38 -0
- data/examples/schedules.rb +31 -0
- data/lib/oz/client.rb +299 -0
- data/lib/oz/configuration.rb +46 -0
- data/lib/oz/cursor_page.rb +89 -0
- data/lib/oz/errors.rb +72 -0
- data/lib/oz/model.rb +116 -0
- data/lib/oz/resources/agent.rb +95 -0
- data/lib/oz/resources/base.rb +33 -0
- data/lib/oz/resources/conversations.rb +16 -0
- data/lib/oz/resources/identities.rb +46 -0
- data/lib/oz/resources/runs.rb +55 -0
- data/lib/oz/resources/schedules.rb +64 -0
- data/lib/oz/resources/sessions.rb +16 -0
- data/lib/oz/version.rb +5 -0
- data/lib/oz.rb +72 -0
- data/mise.toml +2 -0
- data/oz-agent-sdk.gemspec +55 -0
- metadata +184 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 4588539e5a81dcbb25086df63b65d44f8ba647f93dab969f281d430daf10b47a
|
|
4
|
+
data.tar.gz: cd64be47a467a2289ade7563681fed0b24d640d52b7cb478c660b19c26452ac1
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 51e8f3acf7aee995b415468c18aa1a531ce2361b473a2ccb126d5c5ae4eb1c3acc30b6c843be352c61f61680566afebf133b7e3d0a63acd3a30b11573e92f228
|
|
7
|
+
data.tar.gz: b459cd4e0b98b188a7ff1f8cb40b19185f3da66b7d408772e5e7b11ad1d7eb6ba67591ac6226e5abbac46b1f9114f45954179ecacb9c88336cc6a2692afc61a1
|
data/AGENTS.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# AGENTS.md — oz-agent-sdk (Ruby SDK for the Oz/Warp cloud agent platform)
|
|
2
|
+
|
|
3
|
+
## Build & Test
|
|
4
|
+
- Install: `bundle install`
|
|
5
|
+
- Run all tests: `bundle exec rspec`
|
|
6
|
+
- Run single test file: `bundle exec rspec spec/oz/resources/runs_spec.rb`
|
|
7
|
+
- Run single example: `bundle exec rspec spec/oz/resources/runs_spec.rb:42`
|
|
8
|
+
- Lint: `bundle exec rubocop` | Auto-fix: `bundle exec rubocop -A`
|
|
9
|
+
- Full CI suite (lint + tests): `bundle exec rake ci`
|
|
10
|
+
|
|
11
|
+
## Architecture
|
|
12
|
+
- Gem entry: `lib/oz.rb` → top-level `Oz` module with global config & shared client
|
|
13
|
+
- `Oz::Client` (`lib/oz/client.rb`) — Faraday-based HTTP client, configured via `Oz::Configuration`
|
|
14
|
+
- Resources (`lib/oz/resources/`) — API resource classes (Runs, Schedules, Identities, Sessions, Conversations, Agent) inheriting from `Base`
|
|
15
|
+
- `Oz::Model` — base model; `Oz::CursorPage` — paginated list wrapper; `Oz::Errors` — error hierarchy
|
|
16
|
+
- Tests in `spec/` mirror `lib/` structure; use WebMock (no real HTTP), `build_client` helper, expect-only syntax
|
|
17
|
+
|
|
18
|
+
## Code Style
|
|
19
|
+
- Ruby >= 3.1; every file starts with `# frozen_string_literal: true`
|
|
20
|
+
- RuboCop enforced: 120-char line limit, `Style/Documentation` disabled, no `Style/DoubleNegation`
|
|
21
|
+
- Use `require_relative` for internal imports; `Oz::` namespace for all classes
|
|
22
|
+
- RSpec: `expect` syntax only, `disable_monkey_patching!`, no real network calls (WebMock)
|
|
23
|
+
- Env vars isolated per test via `around` hook (see `spec/spec_helper.rb`)
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-06-18
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Initial release of the Ruby SDK for the Oz API.
|
|
15
|
+
- `Oz::Client` with Bearer authentication (`WARP_API_KEY`), configurable base URL
|
|
16
|
+
(`OZ_API_BASE_URL`), custom headers (`OZ_API_CUSTOM_HEADERS`), timeouts, and
|
|
17
|
+
automatic retries with exponential backoff for transient failures.
|
|
18
|
+
- `client.agent` resource: `run`, `list`, `get_artifact`, `list_environments`.
|
|
19
|
+
- `client.agent.runs`: `retrieve`, `list` (cursor pagination), `cancel`,
|
|
20
|
+
`list_handoff_attachments`, `submit_followup`.
|
|
21
|
+
- `client.agent.schedules`: `create`, `retrieve`, `update`, `list`, `delete`,
|
|
22
|
+
`pause`, `resume`.
|
|
23
|
+
- `client.agent.identities`: `create`, `update`, `list`, `retrieve`, `delete`.
|
|
24
|
+
- `client.agent.sessions` and `client.agent.conversations`: `check_redirect`.
|
|
25
|
+
- `Oz::CursorPage` with `auto_paging_each` for transparent multi-page iteration.
|
|
26
|
+
- `Oz::Model` response wrapper with method/`[]` access and recursive nesting.
|
|
27
|
+
- Typed error hierarchy mapping HTTP status codes to exception classes.
|
|
28
|
+
|
|
29
|
+
[Unreleased]: https://github.com/warpdotdev/oz-sdk-ruby/compare/v0.1.0...HEAD
|
|
30
|
+
[0.1.0]: https://github.com/warpdotdev/oz-sdk-ruby/releases/tag/v0.1.0
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in improving the Oz Ruby SDK!
|
|
4
|
+
|
|
5
|
+
## Development setup
|
|
6
|
+
|
|
7
|
+
The Ruby toolchain is managed with [mise](https://mise.jdx.dev). The pinned default is
|
|
8
|
+
**Ruby 4.0** (see [`mise.toml`](mise.toml)).
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
git clone https://github.com/warpdotdev/oz-sdk-ruby.git
|
|
12
|
+
cd oz-sdk-ruby
|
|
13
|
+
mise install # install the pinned Ruby (4.0.x)
|
|
14
|
+
make install # bundle install
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The gem supports Ruby 3.1+ (verified in CI across 3.1–4.0) and uses
|
|
18
|
+
[Faraday](https://lostisland.github.io/faraday/) for HTTP.
|
|
19
|
+
|
|
20
|
+
> **Bundler on Ruby 4:** use Bundler ≥ 2.7 (or 4.x). Bundler < 2.7 calls the removed
|
|
21
|
+
> `CGI.parse` and aborts. If `bundle` fails, run `gem install bundler` to get a current one.
|
|
22
|
+
|
|
23
|
+
## Common tasks
|
|
24
|
+
|
|
25
|
+
All tasks are available through the `Makefile` (run `make help` to list them):
|
|
26
|
+
|
|
27
|
+
| Command | Description |
|
|
28
|
+
| ---------------- | -------------------------------------------- |
|
|
29
|
+
| `make spec` | Run the RSpec test suite |
|
|
30
|
+
| `make lint` | Run RuboCop |
|
|
31
|
+
| `make lint-fix` | Run RuboCop with safe auto-correct |
|
|
32
|
+
| `make ci` | Run lint + tests (what CI runs) |
|
|
33
|
+
| `make coverage` | Run tests and open the coverage report |
|
|
34
|
+
| `make build` | Build the gem into `pkg/` |
|
|
35
|
+
| `make console` | Open an IRB console with the gem loaded |
|
|
36
|
+
| `make docs` | Generate YARD documentation |
|
|
37
|
+
|
|
38
|
+
## Tests
|
|
39
|
+
|
|
40
|
+
- Tests live in `spec/` and use RSpec + WebMock (no live network calls).
|
|
41
|
+
- Please add coverage for any new behaviour; SimpleCov enforces a minimum.
|
|
42
|
+
- Keep examples in `examples/` runnable.
|
|
43
|
+
|
|
44
|
+
## Pull requests
|
|
45
|
+
|
|
46
|
+
1. Create a feature branch off `main`.
|
|
47
|
+
2. Make your change with tests and documentation.
|
|
48
|
+
3. Ensure `make ci` passes locally.
|
|
49
|
+
4. Open a PR describing the change and its motivation.
|
|
50
|
+
|
|
51
|
+
## Releasing
|
|
52
|
+
|
|
53
|
+
Maintainers publish releases by bumping the version and pushing a tag:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
make tag VERSION=x.y.z # bumps lib/oz/version.rb, commits, tags, pushes
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Pushing a `v*` tag triggers the `Release Gem` GitHub Actions workflow, which runs
|
|
60
|
+
the test suite and publishes to RubyGems (requires the `RUBYGEMS_API_KEY` secret).
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Oz API
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
data/Makefile
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
.PHONY: setup install test spec lint lint-fix build release clean console docs coverage help tag ci
|
|
2
|
+
|
|
3
|
+
help: ## Show this help
|
|
4
|
+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
|
5
|
+
|
|
6
|
+
setup: ## First-run setup: install the pinned Ruby (mise) + a current Bundler + deps
|
|
7
|
+
mise install
|
|
8
|
+
gem install bundler --no-document
|
|
9
|
+
bundle install
|
|
10
|
+
|
|
11
|
+
install: ## Install dependencies
|
|
12
|
+
bundle install
|
|
13
|
+
|
|
14
|
+
spec: ## Run RSpec tests
|
|
15
|
+
bundle exec rspec
|
|
16
|
+
|
|
17
|
+
test: spec ## Alias for spec
|
|
18
|
+
|
|
19
|
+
coverage: ## Run tests and open the coverage report
|
|
20
|
+
bundle exec rspec
|
|
21
|
+
open coverage/index.html
|
|
22
|
+
|
|
23
|
+
lint: ## Run RuboCop linter
|
|
24
|
+
bundle exec rubocop
|
|
25
|
+
|
|
26
|
+
lint-fix: ## Run RuboCop with safe auto-correct
|
|
27
|
+
bundle exec rubocop -A
|
|
28
|
+
|
|
29
|
+
ci: ## Run the full CI suite locally (lint + tests)
|
|
30
|
+
bundle exec rake ci
|
|
31
|
+
|
|
32
|
+
build: ## Build the gem into pkg/
|
|
33
|
+
bundle exec rake build
|
|
34
|
+
|
|
35
|
+
docs: ## Generate YARD documentation into doc/
|
|
36
|
+
bundle exec yard doc
|
|
37
|
+
|
|
38
|
+
console: ## Start an IRB console with the gem loaded
|
|
39
|
+
bundle exec irb -r oz
|
|
40
|
+
|
|
41
|
+
clean: ## Remove build artifacts
|
|
42
|
+
rm -f *.gem
|
|
43
|
+
rm -rf pkg/ coverage/ doc/ .yardoc/
|
|
44
|
+
|
|
45
|
+
release: tag ## Tag the current version and let CI publish to RubyGems
|
|
46
|
+
@echo "Pushed tag. The release workflow will publish to RubyGems."
|
|
47
|
+
|
|
48
|
+
tag: ## Create and push a git tag for the current VERSION. Usage: make tag [VERSION=x.y.z]
|
|
49
|
+
@git fetch --tags; \
|
|
50
|
+
if [ -z "$(VERSION)" ]; then \
|
|
51
|
+
NEW_VERSION=$$(ruby -r ./lib/oz/version -e 'print Oz::VERSION'); \
|
|
52
|
+
else \
|
|
53
|
+
NEW_VERSION="$(VERSION)"; \
|
|
54
|
+
sed -i '' "s/VERSION = '.*'/VERSION = '$$NEW_VERSION'/" lib/oz/version.rb 2>/dev/null \
|
|
55
|
+
|| sed -i "s/VERSION = '.*'/VERSION = '$$NEW_VERSION'/" lib/oz/version.rb; \
|
|
56
|
+
git add lib/oz/version.rb; \
|
|
57
|
+
git commit -m "Release v$$NEW_VERSION" --allow-empty; \
|
|
58
|
+
fi; \
|
|
59
|
+
NEW_TAG="v$$NEW_VERSION"; \
|
|
60
|
+
echo "Tagging $$NEW_TAG ..."; \
|
|
61
|
+
git tag "$$NEW_TAG"; \
|
|
62
|
+
git push origin HEAD; \
|
|
63
|
+
git push origin "$$NEW_TAG"; \
|
|
64
|
+
echo "Done! Pushed $$NEW_TAG"
|
data/README.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# Oz Ruby SDK
|
|
2
|
+
|
|
3
|
+
[](https://github.com/warpdotdev/oz-sdk-ruby/actions/workflows/ci.yml)
|
|
4
|
+
[](https://rubygems.org/gems/oz-agent-sdk)
|
|
5
|
+
[](https://www.ruby-lang.org)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
The Oz Ruby SDK provides convenient access to the [Oz API](https://docs.warp.dev) — Warp's
|
|
9
|
+
cloud agent platform — from any Ruby 3.1+ application. Run and manage cloud agents,
|
|
10
|
+
schedules, agent identities, environments, and artifacts with an idiomatic, resource-oriented
|
|
11
|
+
client.
|
|
12
|
+
|
|
13
|
+
This is the Ruby counterpart to the official
|
|
14
|
+
[Python](https://github.com/warpdotdev/oz-sdk-python) and
|
|
15
|
+
[TypeScript](https://github.com/warpdotdev/oz-sdk-typescript) SDKs.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Add it to your Gemfile:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
gem 'oz-agent-sdk'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Then run `bundle install`. Or install it directly:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
gem install oz-agent-sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick start
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
require 'oz'
|
|
35
|
+
|
|
36
|
+
client = Oz::Client.new(
|
|
37
|
+
api_key: ENV['WARP_API_KEY'] # the default; can be omitted if the env var is set
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
response = client.agent.run(prompt: 'Fix the bug in auth.rb')
|
|
41
|
+
puts response.run_id
|
|
42
|
+
puts response.state # => "QUEUED"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The API key is read from the `WARP_API_KEY` environment variable by default, so in most
|
|
46
|
+
cases you can simply write `Oz::Client.new`.
|
|
47
|
+
|
|
48
|
+
## Configuration
|
|
49
|
+
|
|
50
|
+
Configure a single client instance, or set global defaults once at boot.
|
|
51
|
+
|
|
52
|
+
```ruby
|
|
53
|
+
# Per-client
|
|
54
|
+
client = Oz::Client.new(
|
|
55
|
+
api_key: 'sk-...',
|
|
56
|
+
base_url: 'https://app.warp.dev/api/v1', # default; override with OZ_API_BASE_URL
|
|
57
|
+
timeout: 60, # seconds
|
|
58
|
+
max_retries: 2, # retries for transient failures
|
|
59
|
+
default_headers: { 'X-My-Header' => 'value' },
|
|
60
|
+
logger: Logger.new($stdout) # optional Faraday request logging
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# Global defaults + shared client
|
|
64
|
+
Oz.configure do |config|
|
|
65
|
+
config.api_key = ENV.fetch('WARP_API_KEY')
|
|
66
|
+
config.max_retries = 3
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
Oz.client.agent.runs.list(limit: 20).each { |run| puts run.title }
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Environment variables
|
|
73
|
+
|
|
74
|
+
| Variable | Description |
|
|
75
|
+
| ------------------------ | ------------------------------------------------------------------ |
|
|
76
|
+
| `WARP_API_KEY` | Bearer token used to authenticate requests. |
|
|
77
|
+
| `OZ_API_BASE_URL` | Override the API base URL. |
|
|
78
|
+
| `OZ_API_CUSTOM_HEADERS` | Extra headers, one `Key: Value` per line, added to every request. |
|
|
79
|
+
|
|
80
|
+
## Usage with a custom configuration
|
|
81
|
+
|
|
82
|
+
Pass a `config` hash to customise the run's environment, model, MCP servers, and more:
|
|
83
|
+
|
|
84
|
+
```ruby
|
|
85
|
+
response = client.agent.run(
|
|
86
|
+
prompt: 'Fix the bug in auth.rb',
|
|
87
|
+
config: {
|
|
88
|
+
environment_id: 'your-environment-id', # UID of a cloud environment
|
|
89
|
+
model_id: 'claude-sonnet-4', # optional: specify the LLM model
|
|
90
|
+
name: 'bug-fix-config', # optional: label for traceability
|
|
91
|
+
base_prompt: 'You are a helpful coding assistant.'
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
puts response.run_id
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### MCP servers
|
|
98
|
+
|
|
99
|
+
```ruby
|
|
100
|
+
client.agent.run(
|
|
101
|
+
prompt: 'Check my GitHub issues',
|
|
102
|
+
config: {
|
|
103
|
+
environment_id: 'your-environment-id',
|
|
104
|
+
mcp_servers: {
|
|
105
|
+
github: { warp_id: 'your-shared-mcp-server-id' },
|
|
106
|
+
'custom-server' => {
|
|
107
|
+
command: 'npx',
|
|
108
|
+
args: ['-y', '@modelcontextprotocol/server-filesystem'],
|
|
109
|
+
env: { 'PATH' => '/usr/local/bin' }
|
|
110
|
+
},
|
|
111
|
+
'remote-server' => {
|
|
112
|
+
url: 'https://mcp.example.com/sse',
|
|
113
|
+
headers: { 'Authorization' => 'Bearer token' }
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Resources
|
|
121
|
+
|
|
122
|
+
The client mirrors the API's resource hierarchy under `client.agent`.
|
|
123
|
+
|
|
124
|
+
### Runs
|
|
125
|
+
|
|
126
|
+
```ruby
|
|
127
|
+
client.agent.run(prompt: 'Refactor the parser') # start a run
|
|
128
|
+
run = client.agent.runs.retrieve('run-id') # fetch one run
|
|
129
|
+
client.agent.runs.cancel('run-id') # cancel a run
|
|
130
|
+
client.agent.runs.submit_followup('run-id', message: 'continue', mode: 'plan')
|
|
131
|
+
client.agent.runs.list_handoff_attachments('run-id')
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### Pagination
|
|
135
|
+
|
|
136
|
+
`runs.list` returns an `Oz::CursorPage`. Iterate one page, or transparently walk all pages
|
|
137
|
+
with `auto_paging_each`:
|
|
138
|
+
|
|
139
|
+
```ruby
|
|
140
|
+
page = client.agent.runs.list(limit: 50, state: %w[INPROGRESS QUEUED])
|
|
141
|
+
page.each { |run| puts run.run_id } # this page only
|
|
142
|
+
|
|
143
|
+
client.agent.runs.list(limit: 50).auto_paging_each do |run|
|
|
144
|
+
puts run.title # every run across all pages
|
|
145
|
+
end
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Schedules
|
|
149
|
+
|
|
150
|
+
```ruby
|
|
151
|
+
schedule = client.agent.schedules.create(
|
|
152
|
+
cron_schedule: '0 9 * * *',
|
|
153
|
+
name: 'nightly-dependency-check',
|
|
154
|
+
prompt: 'Check for outdated dependencies and open a PR'
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
client.agent.schedules.list
|
|
158
|
+
client.agent.schedules.retrieve(schedule.schedule_id)
|
|
159
|
+
client.agent.schedules.update(schedule.schedule_id, enabled: false)
|
|
160
|
+
client.agent.schedules.pause(schedule.schedule_id)
|
|
161
|
+
client.agent.schedules.resume(schedule.schedule_id)
|
|
162
|
+
client.agent.schedules.delete(schedule.schedule_id)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Agent identities
|
|
166
|
+
|
|
167
|
+
```ruby
|
|
168
|
+
identity = client.agent.identities.create(name: 'ci-bot', description: 'CI agent')
|
|
169
|
+
client.agent.identities.list
|
|
170
|
+
client.agent.identities.retrieve(identity.uid)
|
|
171
|
+
client.agent.identities.update(identity.uid, description: 'Updated')
|
|
172
|
+
client.agent.identities.delete(identity.uid)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Agents, environments, and artifacts
|
|
176
|
+
|
|
177
|
+
```ruby
|
|
178
|
+
client.agent.list(sort_by: 'last_run') # available agents (skills)
|
|
179
|
+
client.agent.list_environments # cloud environments
|
|
180
|
+
client.agent.get_artifact('artifact-uid') # a plan / screenshot / file artifact
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Sessions and conversations
|
|
184
|
+
|
|
185
|
+
```ruby
|
|
186
|
+
client.agent.sessions.check_redirect('session-uuid')
|
|
187
|
+
client.agent.conversations.check_redirect('conversation-id')
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Responses
|
|
191
|
+
|
|
192
|
+
Responses are wrapped in `Oz::Model`, which exposes fields as methods and via `[]`, and
|
|
193
|
+
wraps nested objects/arrays recursively. Unknown/optional fields return `nil`.
|
|
194
|
+
|
|
195
|
+
```ruby
|
|
196
|
+
run = client.agent.runs.retrieve('run-id')
|
|
197
|
+
run.state # => "SUCCEEDED"
|
|
198
|
+
run['run_id'] # => "run-id"
|
|
199
|
+
run.is_sandbox_running? # predicate form for booleans
|
|
200
|
+
run.agent_config.model_id # nested access
|
|
201
|
+
run.to_h # plain Hash with string keys
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Error handling
|
|
205
|
+
|
|
206
|
+
Every API failure raises a subclass of `Oz::APIError`, carrying the HTTP status, the parsed
|
|
207
|
+
response body, a machine-readable `code`, and the `request_id`.
|
|
208
|
+
|
|
209
|
+
```ruby
|
|
210
|
+
begin
|
|
211
|
+
client.agent.run(prompt: 'do the thing')
|
|
212
|
+
rescue Oz::RateLimitError => e
|
|
213
|
+
retry_after(e)
|
|
214
|
+
rescue Oz::AuthenticationError
|
|
215
|
+
warn 'Check your WARP_API_KEY'
|
|
216
|
+
rescue Oz::APIStatusError => e
|
|
217
|
+
warn "API error #{e.status_code} (#{e.code}): #{e.message}"
|
|
218
|
+
rescue Oz::APIConnectionError => e
|
|
219
|
+
warn "Network problem: #{e.message}"
|
|
220
|
+
end
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
| Exception | When |
|
|
224
|
+
| ----------------------------- | ----------------------------------- |
|
|
225
|
+
| `Oz::BadRequestError` | HTTP 400 |
|
|
226
|
+
| `Oz::AuthenticationError` | HTTP 401 / missing API key |
|
|
227
|
+
| `Oz::PermissionDeniedError` | HTTP 403 |
|
|
228
|
+
| `Oz::NotFoundError` | HTTP 404 |
|
|
229
|
+
| `Oz::ConflictError` | HTTP 409 |
|
|
230
|
+
| `Oz::UnprocessableEntityError`| HTTP 422 |
|
|
231
|
+
| `Oz::RateLimitError` | HTTP 429 |
|
|
232
|
+
| `Oz::InternalServerError` | HTTP 5xx |
|
|
233
|
+
| `Oz::APIConnectionError` | Connection failure |
|
|
234
|
+
| `Oz::APITimeoutError` | Request timeout |
|
|
235
|
+
|
|
236
|
+
All inherit from `Oz::APIError < Oz::Error < StandardError`.
|
|
237
|
+
|
|
238
|
+
### Retries
|
|
239
|
+
|
|
240
|
+
Connection errors, timeouts, and HTTP `408`, `409`, `429`, and `5xx` responses are retried
|
|
241
|
+
automatically (default: 2 retries) with exponential backoff and jitter. A numeric
|
|
242
|
+
`Retry-After` header is honoured. Tune it with `max_retries:` (set to `0` to disable).
|
|
243
|
+
|
|
244
|
+
## Development
|
|
245
|
+
|
|
246
|
+
This project uses [mise](https://mise.jdx.dev) to manage the Ruby toolchain. The default
|
|
247
|
+
version is **Ruby 4.0** (pinned in [`mise.toml`](mise.toml)); the gem itself supports Ruby
|
|
248
|
+
3.1+.
|
|
249
|
+
|
|
250
|
+
```sh
|
|
251
|
+
make setup # mise install + current Bundler + bundle install (run once)
|
|
252
|
+
make spec # run tests
|
|
253
|
+
make lint # run RuboCop
|
|
254
|
+
make ci # lint + tests (what CI runs)
|
|
255
|
+
make build # build the gem
|
|
256
|
+
make help # list all tasks
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
> On Ruby 4, use Bundler ≥ 2.7 (or 4.x). Bundler < 2.7 calls the removed `CGI.parse` and
|
|
260
|
+
> will fail — `make setup` installs a compatible one for you.
|
|
261
|
+
|
|
262
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for more, and [`docs/`](docs/) for deeper guides.
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
Released under the [Apache-2.0](LICENSE) license.
|