sai-sdk 0.1.0 → 0.2.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 +4 -4
- data/README.md +8 -5
- data/lib/sai/control.rb +3 -3
- data/lib/sai/tenants.rb +6 -2
- data/lib/sai/types.rb +10 -4
- data/lib/sai/version.rb +1 -1
- data/lib/sai.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cf8b91f34d28bcf34e57a3a49a3b8a1e996c11ba27dbed5e75cf5f27cda1cd46
|
|
4
|
+
data.tar.gz: b67f3951139fc55948b58145cbdd62eaf34f82250a107671b35ef87a27330a94
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c785b77c57c7f2f423f460bdd1238afd6cc45ace84d4cb0d082a9bd7fb7332bece7879b716eaaa4783f08a3579105667f47a24c8d560dd8ca59927d7cd83b18c
|
|
7
|
+
data.tar.gz: b1eac86011e4a0e87b24e3ca09b8c186f8ce74dfd10e0eb59e486f2d3614b16e75fcb088f7e1572dc8597c20eef4a8d1e569720a9d2fc3a12a0528530f319ad1
|
data/README.md
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Ruby SDK for the [Sai API](https://platform.simular.ai/documentation). Hand desktop work to Sai on a
|
|
4
4
|
computer (a Sai cloud computer, or your own PC with the Sai app) and get the answer back, or drive a
|
|
5
|
-
|
|
5
|
+
computer yourself.
|
|
6
6
|
|
|
7
|
-
Status: **alpha (0.1)
|
|
7
|
+
Status: **alpha (0.1)**. The surface may still change before 1.0. It matches the
|
|
8
8
|
[Python SDK](../python/README.md) and the [TypeScript SDK](../typescript/README.md) method for method.
|
|
9
9
|
|
|
10
10
|
| Layer | What it is | Status |
|
|
11
11
|
| -------------- | --------------------------------------------- | ---------------- |
|
|
12
12
|
| `sai.sessions` | A conversation with Sai on one computer | available |
|
|
13
|
-
| `sai.control` | Drive a cloud
|
|
13
|
+
| `sai.control` | Drive a computer (cloud or own) with Simulang | research preview |
|
|
14
14
|
| `sai.turns` | A turn's record: typed output, evidence | available |
|
|
15
15
|
|
|
16
16
|
## Install
|
|
@@ -142,8 +142,8 @@ end
|
|
|
142
142
|
## Drive a computer yourself
|
|
143
143
|
|
|
144
144
|
Direct control runs [Simulang](https://platform.simular.ai/documentation/concepts/direct-control)
|
|
145
|
-
blocks on
|
|
146
|
-
open, Sai's own tasks on that computer wait.
|
|
145
|
+
blocks on one of your computers, cloud or your own. With a block, `open` closes the lease when the
|
|
146
|
+
block ends; while it is open, Sai's own tasks on that computer wait.
|
|
147
147
|
|
|
148
148
|
```ruby
|
|
149
149
|
sai.control.open(machine: pc) do |lease|
|
|
@@ -180,6 +180,8 @@ done = sai.learn.wait(job) # timeout: to stop waiting
|
|
|
180
180
|
run = sai.learn.rollout(job, 1, 1)
|
|
181
181
|
```
|
|
182
182
|
|
|
183
|
+
`done.agent_run_end` says how the job's agent run ended when it gave no answer: `time_limit` (still converted), or `needs_input` or the turn's `reason_code` such as `agent_error`, which stop the job (`agent_failed`) before it writes code.
|
|
184
|
+
|
|
183
185
|
## Run Sai for your customers
|
|
184
186
|
|
|
185
187
|
```ruby
|
|
@@ -193,6 +195,7 @@ clinic = org.tenants.client(tenant) # acts as the Tenant; renews its token
|
|
|
193
195
|
clinic.sessions.create(machine: machine.id).run("Open the calendar and read today's appointments")
|
|
194
196
|
|
|
195
197
|
org.tenants.update(tenant, cloud_machine_limit: nil) # nil removes the cap; leaving it out changes nothing
|
|
198
|
+
org.tenants.update(tenant, own_computer_access: true) # learn and control on its enrolled machines
|
|
196
199
|
usage = org.usage.get(granularity: "month", from: "2026-10", to: "2026-10")
|
|
197
200
|
page = org.usage.sessions(tenant, from: "2026-10-01", to: "2026-10-31")
|
|
198
201
|
```
|
data/lib/sai/control.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require "json"
|
|
4
4
|
|
|
5
5
|
module Sai
|
|
6
|
-
# Direct control: drive a
|
|
6
|
+
# Direct control: drive a computer with Simulang. No agent. A lease on the machine: at
|
|
7
7
|
# most one per machine. Research preview; model calls the code makes are billed as usual.
|
|
8
8
|
class Control
|
|
9
9
|
OPEN_TIMEOUT = 240
|
|
@@ -13,7 +13,7 @@ module Sai
|
|
|
13
13
|
@http = http
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
# Take a
|
|
16
|
+
# Take a computer (a Machine or its id). Returns once the lease holds it, up to about
|
|
17
17
|
# three minutes when a Sai task holds it or it has to start. Sai's tasks on that computer wait
|
|
18
18
|
# until the lease is closed. With a block, yields the lease, closes it after, and returns the
|
|
19
19
|
# block's value.
|
|
@@ -36,7 +36,7 @@ module Sai
|
|
|
36
36
|
# The result of ControlLease#shell.
|
|
37
37
|
ShellResult = Struct.new(:stdout, :stderr, :exit_code, :timed_out, keyword_init: true)
|
|
38
38
|
|
|
39
|
-
# A lease on a
|
|
39
|
+
# A lease on a computer. Close it when done: Sai's tasks on that computer wait until then.
|
|
40
40
|
class ControlLease
|
|
41
41
|
attr_reader :machine_id, :idle_timeout_sec
|
|
42
42
|
|
data/lib/sai/tenants.rb
CHANGED
|
@@ -45,15 +45,19 @@ module Sai
|
|
|
45
45
|
# Sends only what is given. +metadata+ replaces the whole map. +status: "disabled"+ stops the
|
|
46
46
|
# Tenant's tokens and machines; +"active"+ brings it back. +cloud_machine_limit+ (0 to 1000)
|
|
47
47
|
# caps the Tenant's cloud machines, and +cloud_machine_limit: nil+ removes the cap.
|
|
48
|
-
# +residential_proxy+ has no effect yet.
|
|
48
|
+
# +residential_proxy+ has no effect yet. +own_computer_access+ lets the Tenant's learn jobs and
|
|
49
|
+
# direct control run code on its enrolled machines (default off). Only the Organisation Key or
|
|
50
|
+
# an owner may set these three.
|
|
49
51
|
# @return [Tenant]
|
|
50
|
-
def update(tenant, name: nil, metadata: nil, status: nil, cloud_machine_limit: UNSET, residential_proxy: nil
|
|
52
|
+
def update(tenant, name: nil, metadata: nil, status: nil, cloud_machine_limit: UNSET, residential_proxy: nil,
|
|
53
|
+
own_computer_access: nil)
|
|
51
54
|
body = {}
|
|
52
55
|
body["name"] = name unless name.nil?
|
|
53
56
|
body["metadata"] = metadata unless metadata.nil?
|
|
54
57
|
body["status"] = status unless status.nil?
|
|
55
58
|
body["cloudMachineLimit"] = cloud_machine_limit unless cloud_machine_limit.equal?(UNSET)
|
|
56
59
|
body["residentialProxy"] = residential_proxy unless residential_proxy.nil?
|
|
60
|
+
body["ownComputerAccess"] = own_computer_access unless own_computer_access.nil?
|
|
57
61
|
Tenant.parse(Parse.obj(@http.json("PATCH", self.class.path(tenant), json: body)))
|
|
58
62
|
end
|
|
59
63
|
|
data/lib/sai/types.rb
CHANGED
|
@@ -417,9 +417,12 @@ module Sai
|
|
|
417
417
|
|
|
418
418
|
# The result of +sai.learn.create+: Simulang code made from recorded turns or an agent run, a
|
|
419
419
|
# repair of code you sent, or a learn job. Run the code with +lease.run(learned, inputs)+.
|
|
420
|
-
# +status+ is +succeeded+, +failed+, +running+ or +stopped+.
|
|
420
|
+
# +status+ is +succeeded+, +failed+, +running+ or +stopped+. +agent_run_end+ is how a job's agent
|
|
421
|
+
# run ended when it gave no answer (nil when it answered): +time_limit+ (still converted),
|
|
422
|
+
# +needs_input+ or the turn's +reason_code+, e.g. +agent_error+; every end but +time_limit+ stops
|
|
423
|
+
# the job (+agent_failed+) before conversion. Research preview.
|
|
421
424
|
LearnResult = Struct.new(:id, :mode, :status, :stop_reason, :message, :test_result, :progress,
|
|
422
|
-
:agent_turn_id, :agent_run_reset, :agent_judgement, :version, :iterations,
|
|
425
|
+
:agent_turn_id, :agent_run_end, :agent_run_reset, :agent_judgement, :version, :iterations,
|
|
423
426
|
:title, :template, :parameters, :code, :output_schema, :validation,
|
|
424
427
|
:changes, :source_turns, :usage, :error, :replayed, :raw,
|
|
425
428
|
keyword_init: true) do
|
|
@@ -447,6 +450,7 @@ module Sai
|
|
|
447
450
|
rollout: Parse.num_or_nil(p["rollout"])
|
|
448
451
|
),
|
|
449
452
|
agent_turn_id: Parse.str(d["agentTurnId"]),
|
|
453
|
+
agent_run_end: Parse.str(d["agentRunEnd"]),
|
|
450
454
|
agent_run_reset: LearnReset.parse(d["agentRunReset"]),
|
|
451
455
|
agent_judgement: aj && AgentJudgement.new(
|
|
452
456
|
judgement_id: Parse.str(aj["judgementId"]) || "",
|
|
@@ -545,10 +549,11 @@ module Sai
|
|
|
545
549
|
end
|
|
546
550
|
|
|
547
551
|
# One of your customers under an Organisation. Times are Unix milliseconds;
|
|
548
|
-
# +cloud_machine_limit+ nil means no limit.
|
|
552
|
+
# +cloud_machine_limit+ nil means no limit. +own_computer_access+: whether learn jobs and direct
|
|
553
|
+
# control may run code on its enrolled machines; nil from +list+ and from older servers.
|
|
549
554
|
Tenant = Struct.new(:id, :name, :external_id, :metadata, :status, :created_at, :disabled_at,
|
|
550
555
|
:machine_count, :cloud_machine_limit, :residential_proxy, :cloud_machine_count,
|
|
551
|
-
:raw, keyword_init: true) do
|
|
556
|
+
:own_computer_access, :raw, keyword_init: true) do
|
|
552
557
|
def self.parse(d)
|
|
553
558
|
new(
|
|
554
559
|
id: Parse.str(d["tenantId"]) || "",
|
|
@@ -562,6 +567,7 @@ module Sai
|
|
|
562
567
|
cloud_machine_limit: Parse.num_or_nil(d["cloudMachineLimit"]),
|
|
563
568
|
residential_proxy: [true, false].include?(d["residentialProxy"]) ? d["residentialProxy"] : nil,
|
|
564
569
|
cloud_machine_count: Parse.num_or_nil(d["cloudMachineCount"]),
|
|
570
|
+
own_computer_access: [true, false].include?(d["ownComputerAccess"]) ? d["ownComputerAccess"] : nil,
|
|
565
571
|
raw: d
|
|
566
572
|
)
|
|
567
573
|
end
|
data/lib/sai/version.rb
CHANGED
data/lib/sai.rb
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# - +sai.sessions+: give Sai a task on a computer and get the answer back.
|
|
6
6
|
# - +sai.learn+, +sai.judge+: turn recorded turns or a task into Simulang code, repair it, run,
|
|
7
7
|
# judge and repair it on a machine, judge turns.
|
|
8
|
-
# - +sai.control+: drive a
|
|
8
|
+
# - +sai.control+: drive a computer yourself with Simulang.
|
|
9
9
|
# - +sai.machines+, +sai.models+, +sai.files+, +sai.account+, +sai.auth+.
|
|
10
10
|
# - +sai.tenants+, +sai.tenant_machines+, +sai.usage+: your customers under an Organisation.
|
|
11
11
|
module Sai
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sai-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Simular, Inc.
|
|
@@ -10,7 +10,7 @@ cert_chain: []
|
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
12
|
description: Hand desktop work to Sai on a computer and get the answer back, or drive
|
|
13
|
-
a
|
|
13
|
+
a computer yourself.
|
|
14
14
|
executables: []
|
|
15
15
|
extensions: []
|
|
16
16
|
extra_rdoc_files: []
|