pinesandbox 0.3.21 → 0.3.22

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d156958acb2d1acd0f962691b98b7d9427d0483b043f0f94bc9a46d35b0a69e
4
- data.tar.gz: feee8dff7adffd1f7bd962fe94fe639bb2328045fc1cb6b17637693b7cffc200
3
+ metadata.gz: 55f1a5304b3816e9e36f1d087f979d082050f2ee19639d489272e35ca55d2a9a
4
+ data.tar.gz: d7e5f8f0f84a2cc876a4a54e2f47ff468c33483760a203cea636c75050891556
5
5
  SHA512:
6
- metadata.gz: 7670a560d04222fd9da967ec3ec44a5703a44c6e7395a2cd32f1f8a072408c0f934633abca1dca7b655f88ab14521d3dc5ebd0521bb86361a279c60314fe87a7
7
- data.tar.gz: d15cb731f74c548116aa788ff3f0698bf9b6409efe3650db9ae2d7b092b2c75f66397a0a7cc67b538f6d366b84868a9ec41c8c8ca5113025eb187e67bb8d01ef
6
+ metadata.gz: 94cd92b7ff365c67c795346987cd503475bfac9bbf696d26919df8c6d671babe6c891d42e26b7678ca18f81a5a8393e4a078f9bf11e6e3bdbdd75c328670f6f4
7
+ data.tar.gz: 6528144c681b71f9434dfa8dee8d7a1356e0d69cc7730ff763ee79580e4470a86c4fcc814c951984aab9770db09104db17aaa57fca46a79584433c0b831ef14b
data/README.md CHANGED
@@ -16,12 +16,12 @@ bundle add pinesandbox
16
16
 
17
17
  Bundler pins it to the latest release's compatibility line (`"~> 0.3.<patch>"`), so
18
18
  `bundle update` takes later patches but not a new minor version. Using it needs a project key (`pk_…`) from the
19
- [Console](https://console.pinecomputer.io). Pine Computer is in beta:
19
+ [Console](https://console.pinecomputer.io). Access is by approval:
20
20
  [request access](https://pinecomputer.io/#access) if you don't have one yet. Each
21
21
  release is also an archive on the [Ruby SDK page](https://console.pinecomputer.io/sdks/ruby),
22
22
  for vendoring.
23
23
 
24
- The current beta SDK is on the `0.3` compatibility line.
24
+ The current SDK is on the `0.3` compatibility line.
25
25
 
26
26
  ## Create a Computer
27
27
 
@@ -321,10 +321,12 @@ module PineSandbox
321
321
  def raise_generic(resp, label,
322
322
  forbidden: "project or key may not mint attach credentials (scope, project status, or computer status)")
323
323
  if resp.status == 403
324
- raise ProjectAccessDenied.new(
325
- error_message(resp, forbidden),
326
- **error_attributes(resp)
327
- )
324
+ attributes = error_attributes(resp)
325
+ if attributes[:problem_type] == SpendLimitReachedError::PROBLEM_TYPE
326
+ raise SpendLimitReachedError.new(error_message(resp, forbidden), **attributes.slice(:request_id, :op))
327
+ end
328
+
329
+ raise ProjectAccessDenied.new(error_message(resp, forbidden), **attributes)
328
330
  end
329
331
  default =
330
332
  case resp.status
@@ -284,6 +284,10 @@ module PineSandbox
284
284
  # the op path already carries the id for get/destroy/pause/resume.
285
285
  rid = resp.headers["x-request-id"] || resp.headers["X-Request-Id"]
286
286
  op = op_for(resp)
287
+ if resp.status == 403 && body.is_a?(Hash) && body["type"] == PineSandbox::SpendLimitReachedError::PROBLEM_TYPE
288
+ raise PineSandbox::SpendLimitReachedError.new(status_message(resp), request_id: rid, op: op)
289
+ end
290
+
287
291
  ext = {}
288
292
  ext["op"] = op if op && !op.to_s.empty?
289
293
  ext["request_id"] = rid unless rid.to_s.empty?
@@ -642,6 +642,28 @@ module PineSandbox
642
642
  end
643
643
  end
644
644
 
645
+ # 403 SPEND_LIMIT_REACHED: the project has reached its monthly spend limit, or
646
+ # its organization is out of credits, so a Computer wasn't started or resumed
647
+ # or its idle timeout wasn't changed. The same error whichever call was
648
+ # refused. Reads, stop, pause and delete still work. Not retried by the SDK:
649
+ # credits are added or the limit raised first; #message says which.
650
+ class SpendLimitReachedError < Error
651
+ CODE = "SPEND_LIMIT_REACHED".freeze
652
+ # The refusal's problem type, the same from every call.
653
+ PROBLEM_TYPE = "urn:pinesandbox:problem:spend-limit-reached".freeze
654
+
655
+ attr_reader :status, :request_id, :op
656
+
657
+ def initialize(message, status: 403, request_id: nil, op: nil)
658
+ @status = status
659
+ @request_id = request_id
660
+ @op = op
661
+ super(PineSandbox.with_context(message, op: op, request_id: request_id))
662
+ end
663
+
664
+ def code = CODE
665
+ end
666
+
645
667
  # 429 COMPUTER_CAPACITY_EXCEEDED on create/attach: the project is at its
646
668
  # concurrent Computer limit, so nothing was provisioned. Not retried by the
647
669
  # SDK — capacity frees only when another of the project's Computers stops.
@@ -1,5 +1,5 @@
1
1
  # Generated by specs/gen-signal-actions.py from sdks/pine-computer/contract/signal-actions.json. Do not edit; run `python3 specs/gen-signal-actions.py`.
2
- # signal-actions source-sha256=63709f95953341c1d1db139bd8ff3b46837f30ed1ec978f7bf8b885d4e09ca18 body-sha256=5ced47750cea6b0dec02ebfd88cc5c8b3ff17b912ab01054b1782c9162cdb6a0
2
+ # signal-actions source-sha256=6b1fd0c880882510913e27b38e9169567f64c4d7193e7acc158a4da906ff8c20 body-sha256=8b26db77552ce1578c3677792aab7c0519ef534aee4668e65e183e5951857fa2
3
3
 
4
4
  module PineSandbox
5
5
  # @api private — the terminal_reason values of a turn's result: how a turn or a
@@ -15,6 +15,7 @@ module PineSandbox
15
15
  EXECUTOR_PANIC = "executor_panic".freeze
16
16
  COORDINATOR_RESTARTED = "coordinator_restarted".freeze
17
17
  STORAGE_EXHAUSTED = "storage_exhausted".freeze
18
+ SPEND_LIMIT_REACHED = "spend_limit_reached".freeze
18
19
  OUTPUT_INVALID = "output_invalid".freeze
19
20
  DRAFT_REGISTERED = "draft_registered".freeze
20
21
  CLARIFICATION_REQUESTED = "clarification_requested".freeze
@@ -1,5 +1,5 @@
1
1
  module PineSandbox
2
- VERSION = "0.3.21"
2
+ VERSION = "0.3.22"
3
3
  # What the SDK's requests send as User-Agent.
4
4
  USER_AGENT = "pinesandbox-ruby/#{VERSION}".freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pinesandbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.21
4
+ version: 0.3.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pine AI