@siglume/api-sdk 1.1.0 → 1.2.1

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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  TypeScript runtime for building, testing, and registering Siglume developer apps.
4
4
 
5
- This package is prepared in the public SDK repo and ships with the current v0.10.x release line.
5
+ This package is prepared in the public SDK repo and ships with the current v1.2.x release line.
6
6
 
7
7
  It also includes `draft_tool_manual()` and `fill_tool_manual_gaps()` with
8
8
  bundled `AnthropicProvider` and `OpenAIProvider` classes. Provide
@@ -85,6 +85,9 @@ public-order / morals compliance.
85
85
 
86
86
  ## Usage-Based And Per-Action Billing
87
87
 
88
+ For the canonical pricing reference, see
89
+ [`../docs/pricing-and-billing.md`](../docs/pricing-and-billing.md).
90
+
88
91
  Use `price_model: PriceModel.USAGE_BASED` or `PriceModel.PER_ACTION` when the
89
92
  API must execute before the final operation is known. These listings are free to
90
93
  invoke up front. Your adapter returns the executed operation in
@@ -134,6 +137,14 @@ the fee.
134
137
  `units_consumed` is kept for receipts and analytics; it does not multiply a
135
138
  request-type plan price.
136
139
 
140
+ For irreversible side effects such as posting to X, set
141
+ `billing_timing: "prepay"`. The platform first calls your API as a quote
142
+ (`execution_kind="quote"` / `dry_run=true`), reads `billingPreview.operation`
143
+ and `draftToken`, collects the direct payment for that pricing-plan operation,
144
+ then calls the ACTION endpoint with the same token as `commit_token`. If payment
145
+ fails, the ACTION call is never made. Use the default `"post"` timing only for
146
+ read-only or reversible usage.
147
+
137
148
  Company-name publishing is founder-only in the Phase 2 MVP. Use
138
149
  `publisher_type: "company"` with `company_id` in `app_manifest.yaml`, or pass
139
150
  `--company <company_id>` to the CLI. Paid company listings require the
@@ -1494,6 +1494,7 @@ function parseListing(data) {
1494
1494
  price_model: stringOrNull(data.price_model),
1495
1495
  price_value_minor: Number(data.price_value_minor ?? 0),
1496
1496
  pricing_plan,
1497
+ billing_timing: String(data.billing_timing ?? metadata.billing_timing ?? "post"),
1497
1498
  currency: String(data.currency ?? "USD"),
1498
1499
  allow_free_trial: Boolean(data.allow_free_trial ?? false),
1499
1500
  free_trial_duration_days: Number(data.free_trial_duration_days ?? 30),
@@ -2712,6 +2713,7 @@ var init_client = __esm({
2712
2713
  "price_model",
2713
2714
  "price_value_minor",
2714
2715
  "pricing_plan",
2716
+ "billing_timing",
2715
2717
  "currency",
2716
2718
  "allow_free_trial",
2717
2719
  "free_trial_duration_days",
@@ -2731,6 +2733,13 @@ var init_client = __esm({
2731
2733
  if (payload.pricing_plan !== void 0 && (typeof payload.pricing_plan !== "object" || Array.isArray(payload.pricing_plan))) {
2732
2734
  throw new SiglumeClientError("AppManifest.pricing_plan must be an object when provided.");
2733
2735
  }
2736
+ if (payload.billing_timing !== void 0 && payload.billing_timing !== null) {
2737
+ const billingTiming = String(payload.billing_timing || "post").trim().toLowerCase();
2738
+ if (billingTiming !== "post" && billingTiming !== "prepay") {
2739
+ throw new SiglumeClientError("AppManifest.billing_timing must be 'post' or 'prepay'.");
2740
+ }
2741
+ payload.billing_timing = billingTiming;
2742
+ }
2734
2743
  if (payload.store_vertical === void 0 || payload.store_vertical === null) {
2735
2744
  throw new SiglumeClientError(
2736
2745
  "AppManifest.store_vertical is required. Choose 'api' for normal API Store listings or 'game' for API games."
@@ -6238,6 +6247,9 @@ var AppTestHarness = class {
6238
6247
  issues.push("at least one example_prompt is recommended");
6239
6248
  }
6240
6249
  issues.push(...pricingPlanFloorIssues(manifest.pricing_plan, String(manifest.currency ?? "USD")));
6250
+ if (manifest.billing_timing !== void 0 && manifest.billing_timing !== "post" && manifest.billing_timing !== "prepay") {
6251
+ issues.push("billing_timing must be 'post' or 'prepay'");
6252
+ }
6241
6253
  if ((manifest.price_model === PriceModel.USAGE_BASED || manifest.price_model === PriceModel.PER_ACTION) && (!manifest.pricing_plan || !Array.isArray(manifest.pricing_plan.items) || manifest.pricing_plan.items.length === 0)) {
6242
6254
  issues.push("pricing_plan.items is required for usage_based/per_action pricing");
6243
6255
  }