@siglume/api-sdk 0.10.6 → 0.10.7
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/dist/bin/siglume.cjs +30 -0
- package/dist/bin/siglume.cjs.map +1 -1
- package/dist/bin/siglume.js +30 -0
- package/dist/bin/siglume.js.map +1 -1
- package/dist/cli/index.cjs +30 -0
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +4 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.js +30 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +75 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1646,6 +1646,8 @@ function parseListing(data) {
|
|
|
1646
1646
|
price_model: stringOrNull2(data.price_model),
|
|
1647
1647
|
price_value_minor: Number(data.price_value_minor ?? 0),
|
|
1648
1648
|
currency: String(data.currency ?? "USD"),
|
|
1649
|
+
allow_free_trial: Boolean(data.allow_free_trial ?? false),
|
|
1650
|
+
free_trial_duration_days: Number(data.free_trial_duration_days ?? 30),
|
|
1649
1651
|
short_description: stringOrNull2(data.short_description),
|
|
1650
1652
|
description: stringOrNull2(data.description),
|
|
1651
1653
|
docs_url: stringOrNull2(data.docs_url),
|
|
@@ -2845,6 +2847,8 @@ var init_client = __esm({
|
|
|
2845
2847
|
"price_model",
|
|
2846
2848
|
"price_value_minor",
|
|
2847
2849
|
"currency",
|
|
2850
|
+
"allow_free_trial",
|
|
2851
|
+
"free_trial_duration_days",
|
|
2848
2852
|
"permission_class",
|
|
2849
2853
|
"approval_mode",
|
|
2850
2854
|
"dry_run_supported",
|
|
@@ -2872,6 +2876,24 @@ var init_client = __esm({
|
|
|
2872
2876
|
throw new SiglumeClientError(`AppManifest.currency must be 'USD' or 'JPY'. Got ${String(payload.currency)}.`);
|
|
2873
2877
|
}
|
|
2874
2878
|
payload.currency = currency;
|
|
2879
|
+
if (payload.allow_free_trial === void 0 || payload.allow_free_trial === null) {
|
|
2880
|
+
throw new SiglumeClientError(
|
|
2881
|
+
"AppManifest.allow_free_trial is required. Pass true to offer a Plus/Pro buyer free trial or false to disable trials."
|
|
2882
|
+
);
|
|
2883
|
+
}
|
|
2884
|
+
if (Boolean(payload.allow_free_trial)) {
|
|
2885
|
+
const duration = payload.free_trial_duration_days ?? 30;
|
|
2886
|
+
if (typeof duration !== "number" || !Number.isInteger(duration)) {
|
|
2887
|
+
throw new SiglumeClientError(
|
|
2888
|
+
"AppManifest.free_trial_duration_days must be an integer when allow_free_trial=true."
|
|
2889
|
+
);
|
|
2890
|
+
}
|
|
2891
|
+
if (duration < 1 || duration > 90) {
|
|
2892
|
+
throw new SiglumeClientError(
|
|
2893
|
+
`AppManifest.free_trial_duration_days must be between 1 and 90 when allow_free_trial=true, got: ${duration}.`
|
|
2894
|
+
);
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2875
2897
|
if (payload.manifest && typeof payload.manifest === "object") {
|
|
2876
2898
|
delete payload.manifest.version;
|
|
2877
2899
|
}
|
|
@@ -5353,6 +5375,55 @@ var SiglumeBuyerClient = class {
|
|
|
5353
5375
|
}
|
|
5354
5376
|
};
|
|
5355
5377
|
}
|
|
5378
|
+
async start_trial(options) {
|
|
5379
|
+
const listing = await this.get_listing(options.capability_key);
|
|
5380
|
+
const [data, meta] = await this.request("POST", `/market/capabilities/${listing.listing_id}/start-trial`, {
|
|
5381
|
+
json_body: {}
|
|
5382
|
+
});
|
|
5383
|
+
const accessGrant = parseAccessGrant2(toRecord2(data.access_grant));
|
|
5384
|
+
if (!accessGrant.access_grant_id) {
|
|
5385
|
+
const purchaseStatus = String(data.purchase_status ?? "trial_started");
|
|
5386
|
+
throw new SiglumeExperimentalError(
|
|
5387
|
+
`Trial started with status '${purchaseStatus}' but did not return an access grant. Buyer-side trial flows are still experimental on the public API.`
|
|
5388
|
+
);
|
|
5389
|
+
}
|
|
5390
|
+
const targetAgentId = resolveAgentId(options.agent_id, this.default_agent_id);
|
|
5391
|
+
const shouldBind = options.bind_agent ?? Boolean(targetAgentId);
|
|
5392
|
+
let binding = null;
|
|
5393
|
+
let trace_id = meta.trace_id ?? void 0;
|
|
5394
|
+
let request_id = meta.request_id ?? void 0;
|
|
5395
|
+
if (shouldBind) {
|
|
5396
|
+
if (!targetAgentId) {
|
|
5397
|
+
throw new SiglumeClientError("agent_id is required to bind a trial access grant.");
|
|
5398
|
+
}
|
|
5399
|
+
const grantBinding = await this.client.bind_agent_to_grant(accessGrant.access_grant_id, {
|
|
5400
|
+
agent_id: targetAgentId,
|
|
5401
|
+
binding_status: options.binding_status ?? "active"
|
|
5402
|
+
});
|
|
5403
|
+
binding = grantBinding.binding;
|
|
5404
|
+
trace_id = grantBinding.trace_id ?? trace_id;
|
|
5405
|
+
request_id = grantBinding.request_id ?? request_id;
|
|
5406
|
+
}
|
|
5407
|
+
return {
|
|
5408
|
+
access_grant_id: accessGrant.access_grant_id,
|
|
5409
|
+
capability_listing_id: accessGrant.capability_listing_id ?? listing.listing_id,
|
|
5410
|
+
capability_key: listing.capability_key,
|
|
5411
|
+
purchase_status: String(data.purchase_status ?? "trial_started"),
|
|
5412
|
+
grant_status: accessGrant.grant_status,
|
|
5413
|
+
agent_id: binding?.agent_id ?? targetAgentId ?? null,
|
|
5414
|
+
binding_id: binding?.binding_id ?? null,
|
|
5415
|
+
binding_status: binding?.binding_status ?? null,
|
|
5416
|
+
access_grant: accessGrant,
|
|
5417
|
+
binding,
|
|
5418
|
+
trace_id,
|
|
5419
|
+
request_id,
|
|
5420
|
+
raw: { trial: { ...data }, binding }
|
|
5421
|
+
};
|
|
5422
|
+
}
|
|
5423
|
+
async get_trial_quota() {
|
|
5424
|
+
const [data] = await this.request("GET", "/market/me/trial-quota");
|
|
5425
|
+
return { ...data };
|
|
5426
|
+
}
|
|
5356
5427
|
async invoke(options) {
|
|
5357
5428
|
if (!this.allow_internal_execute) {
|
|
5358
5429
|
throw new SiglumeExperimentalError(
|
|
@@ -6080,10 +6151,14 @@ function appendValueChange(changes, emittedKeys, level, key, oldValue, newValue,
|
|
|
6080
6151
|
}
|
|
6081
6152
|
function normalizeManifest(value) {
|
|
6082
6153
|
const payload = coerceMapping(value, "manifest");
|
|
6154
|
+
const rawDuration = payload.free_trial_duration_days;
|
|
6155
|
+
const duration = rawDuration === void 0 || rawDuration === null ? 30 : Number(rawDuration);
|
|
6083
6156
|
return {
|
|
6084
6157
|
...payload,
|
|
6085
6158
|
price_model: payload.price_model ?? "free",
|
|
6086
6159
|
currency: payload.currency ?? "USD",
|
|
6160
|
+
allow_free_trial: Boolean(payload.allow_free_trial ?? false),
|
|
6161
|
+
free_trial_duration_days: Number.isFinite(duration) ? Math.trunc(duration) : 30,
|
|
6087
6162
|
// AppManifest defaults permission_class to "read-only" (hyphen form,
|
|
6088
6163
|
// PermissionClass.READ_ONLY). Without this default, a legacy / minimal
|
|
6089
6164
|
// manifest without permission_class compared against an upgraded one
|