@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.d.cts
CHANGED
|
@@ -210,6 +210,8 @@ interface AppManifest {
|
|
|
210
210
|
price_model?: PriceModel;
|
|
211
211
|
price_value_minor?: number;
|
|
212
212
|
currency: ListingCurrency;
|
|
213
|
+
allow_free_trial: boolean;
|
|
214
|
+
free_trial_duration_days?: number;
|
|
213
215
|
jurisdiction: string;
|
|
214
216
|
applicable_regulations?: string[];
|
|
215
217
|
data_residency?: string;
|
|
@@ -377,6 +379,8 @@ interface AppListingRecord {
|
|
|
377
379
|
price_model?: string | null;
|
|
378
380
|
price_value_minor: number;
|
|
379
381
|
currency: string;
|
|
382
|
+
allow_free_trial: boolean;
|
|
383
|
+
free_trial_duration_days: number;
|
|
380
384
|
short_description?: string | null;
|
|
381
385
|
description?: string | null;
|
|
382
386
|
docs_url?: string | null;
|
|
@@ -2702,6 +2706,13 @@ declare class SiglumeBuyerClient {
|
|
|
2702
2706
|
buyer_currency?: string;
|
|
2703
2707
|
buyer_token?: string;
|
|
2704
2708
|
}): Promise<Subscription>;
|
|
2709
|
+
start_trial(options: {
|
|
2710
|
+
capability_key: string;
|
|
2711
|
+
agent_id?: string;
|
|
2712
|
+
bind_agent?: boolean;
|
|
2713
|
+
binding_status?: string;
|
|
2714
|
+
}): Promise<Subscription>;
|
|
2715
|
+
get_trial_quota(): Promise<Record<string, unknown>>;
|
|
2705
2716
|
invoke(options: {
|
|
2706
2717
|
capability_key: string;
|
|
2707
2718
|
input: Record<string, unknown>;
|
package/dist/index.d.ts
CHANGED
|
@@ -210,6 +210,8 @@ interface AppManifest {
|
|
|
210
210
|
price_model?: PriceModel;
|
|
211
211
|
price_value_minor?: number;
|
|
212
212
|
currency: ListingCurrency;
|
|
213
|
+
allow_free_trial: boolean;
|
|
214
|
+
free_trial_duration_days?: number;
|
|
213
215
|
jurisdiction: string;
|
|
214
216
|
applicable_regulations?: string[];
|
|
215
217
|
data_residency?: string;
|
|
@@ -377,6 +379,8 @@ interface AppListingRecord {
|
|
|
377
379
|
price_model?: string | null;
|
|
378
380
|
price_value_minor: number;
|
|
379
381
|
currency: string;
|
|
382
|
+
allow_free_trial: boolean;
|
|
383
|
+
free_trial_duration_days: number;
|
|
380
384
|
short_description?: string | null;
|
|
381
385
|
description?: string | null;
|
|
382
386
|
docs_url?: string | null;
|
|
@@ -2702,6 +2706,13 @@ declare class SiglumeBuyerClient {
|
|
|
2702
2706
|
buyer_currency?: string;
|
|
2703
2707
|
buyer_token?: string;
|
|
2704
2708
|
}): Promise<Subscription>;
|
|
2709
|
+
start_trial(options: {
|
|
2710
|
+
capability_key: string;
|
|
2711
|
+
agent_id?: string;
|
|
2712
|
+
bind_agent?: boolean;
|
|
2713
|
+
binding_status?: string;
|
|
2714
|
+
}): Promise<Subscription>;
|
|
2715
|
+
get_trial_quota(): Promise<Record<string, unknown>>;
|
|
2705
2716
|
invoke(options: {
|
|
2706
2717
|
capability_key: string;
|
|
2707
2718
|
input: Record<string, unknown>;
|
package/dist/index.js
CHANGED
|
@@ -1624,6 +1624,8 @@ function parseListing(data) {
|
|
|
1624
1624
|
price_model: stringOrNull2(data.price_model),
|
|
1625
1625
|
price_value_minor: Number(data.price_value_minor ?? 0),
|
|
1626
1626
|
currency: String(data.currency ?? "USD"),
|
|
1627
|
+
allow_free_trial: Boolean(data.allow_free_trial ?? false),
|
|
1628
|
+
free_trial_duration_days: Number(data.free_trial_duration_days ?? 30),
|
|
1627
1629
|
short_description: stringOrNull2(data.short_description),
|
|
1628
1630
|
description: stringOrNull2(data.description),
|
|
1629
1631
|
docs_url: stringOrNull2(data.docs_url),
|
|
@@ -2823,6 +2825,8 @@ var init_client = __esm({
|
|
|
2823
2825
|
"price_model",
|
|
2824
2826
|
"price_value_minor",
|
|
2825
2827
|
"currency",
|
|
2828
|
+
"allow_free_trial",
|
|
2829
|
+
"free_trial_duration_days",
|
|
2826
2830
|
"permission_class",
|
|
2827
2831
|
"approval_mode",
|
|
2828
2832
|
"dry_run_supported",
|
|
@@ -2850,6 +2854,24 @@ var init_client = __esm({
|
|
|
2850
2854
|
throw new SiglumeClientError(`AppManifest.currency must be 'USD' or 'JPY'. Got ${String(payload.currency)}.`);
|
|
2851
2855
|
}
|
|
2852
2856
|
payload.currency = currency;
|
|
2857
|
+
if (payload.allow_free_trial === void 0 || payload.allow_free_trial === null) {
|
|
2858
|
+
throw new SiglumeClientError(
|
|
2859
|
+
"AppManifest.allow_free_trial is required. Pass true to offer a Plus/Pro buyer free trial or false to disable trials."
|
|
2860
|
+
);
|
|
2861
|
+
}
|
|
2862
|
+
if (Boolean(payload.allow_free_trial)) {
|
|
2863
|
+
const duration = payload.free_trial_duration_days ?? 30;
|
|
2864
|
+
if (typeof duration !== "number" || !Number.isInteger(duration)) {
|
|
2865
|
+
throw new SiglumeClientError(
|
|
2866
|
+
"AppManifest.free_trial_duration_days must be an integer when allow_free_trial=true."
|
|
2867
|
+
);
|
|
2868
|
+
}
|
|
2869
|
+
if (duration < 1 || duration > 90) {
|
|
2870
|
+
throw new SiglumeClientError(
|
|
2871
|
+
`AppManifest.free_trial_duration_days must be between 1 and 90 when allow_free_trial=true, got: ${duration}.`
|
|
2872
|
+
);
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2853
2875
|
if (payload.manifest && typeof payload.manifest === "object") {
|
|
2854
2876
|
delete payload.manifest.version;
|
|
2855
2877
|
}
|
|
@@ -5248,6 +5270,55 @@ var SiglumeBuyerClient = class {
|
|
|
5248
5270
|
}
|
|
5249
5271
|
};
|
|
5250
5272
|
}
|
|
5273
|
+
async start_trial(options) {
|
|
5274
|
+
const listing = await this.get_listing(options.capability_key);
|
|
5275
|
+
const [data, meta] = await this.request("POST", `/market/capabilities/${listing.listing_id}/start-trial`, {
|
|
5276
|
+
json_body: {}
|
|
5277
|
+
});
|
|
5278
|
+
const accessGrant = parseAccessGrant2(toRecord2(data.access_grant));
|
|
5279
|
+
if (!accessGrant.access_grant_id) {
|
|
5280
|
+
const purchaseStatus = String(data.purchase_status ?? "trial_started");
|
|
5281
|
+
throw new SiglumeExperimentalError(
|
|
5282
|
+
`Trial started with status '${purchaseStatus}' but did not return an access grant. Buyer-side trial flows are still experimental on the public API.`
|
|
5283
|
+
);
|
|
5284
|
+
}
|
|
5285
|
+
const targetAgentId = resolveAgentId(options.agent_id, this.default_agent_id);
|
|
5286
|
+
const shouldBind = options.bind_agent ?? Boolean(targetAgentId);
|
|
5287
|
+
let binding = null;
|
|
5288
|
+
let trace_id = meta.trace_id ?? void 0;
|
|
5289
|
+
let request_id = meta.request_id ?? void 0;
|
|
5290
|
+
if (shouldBind) {
|
|
5291
|
+
if (!targetAgentId) {
|
|
5292
|
+
throw new SiglumeClientError("agent_id is required to bind a trial access grant.");
|
|
5293
|
+
}
|
|
5294
|
+
const grantBinding = await this.client.bind_agent_to_grant(accessGrant.access_grant_id, {
|
|
5295
|
+
agent_id: targetAgentId,
|
|
5296
|
+
binding_status: options.binding_status ?? "active"
|
|
5297
|
+
});
|
|
5298
|
+
binding = grantBinding.binding;
|
|
5299
|
+
trace_id = grantBinding.trace_id ?? trace_id;
|
|
5300
|
+
request_id = grantBinding.request_id ?? request_id;
|
|
5301
|
+
}
|
|
5302
|
+
return {
|
|
5303
|
+
access_grant_id: accessGrant.access_grant_id,
|
|
5304
|
+
capability_listing_id: accessGrant.capability_listing_id ?? listing.listing_id,
|
|
5305
|
+
capability_key: listing.capability_key,
|
|
5306
|
+
purchase_status: String(data.purchase_status ?? "trial_started"),
|
|
5307
|
+
grant_status: accessGrant.grant_status,
|
|
5308
|
+
agent_id: binding?.agent_id ?? targetAgentId ?? null,
|
|
5309
|
+
binding_id: binding?.binding_id ?? null,
|
|
5310
|
+
binding_status: binding?.binding_status ?? null,
|
|
5311
|
+
access_grant: accessGrant,
|
|
5312
|
+
binding,
|
|
5313
|
+
trace_id,
|
|
5314
|
+
request_id,
|
|
5315
|
+
raw: { trial: { ...data }, binding }
|
|
5316
|
+
};
|
|
5317
|
+
}
|
|
5318
|
+
async get_trial_quota() {
|
|
5319
|
+
const [data] = await this.request("GET", "/market/me/trial-quota");
|
|
5320
|
+
return { ...data };
|
|
5321
|
+
}
|
|
5251
5322
|
async invoke(options) {
|
|
5252
5323
|
if (!this.allow_internal_execute) {
|
|
5253
5324
|
throw new SiglumeExperimentalError(
|
|
@@ -5975,10 +6046,14 @@ function appendValueChange(changes, emittedKeys, level, key, oldValue, newValue,
|
|
|
5975
6046
|
}
|
|
5976
6047
|
function normalizeManifest(value) {
|
|
5977
6048
|
const payload = coerceMapping(value, "manifest");
|
|
6049
|
+
const rawDuration = payload.free_trial_duration_days;
|
|
6050
|
+
const duration = rawDuration === void 0 || rawDuration === null ? 30 : Number(rawDuration);
|
|
5978
6051
|
return {
|
|
5979
6052
|
...payload,
|
|
5980
6053
|
price_model: payload.price_model ?? "free",
|
|
5981
6054
|
currency: payload.currency ?? "USD",
|
|
6055
|
+
allow_free_trial: Boolean(payload.allow_free_trial ?? false),
|
|
6056
|
+
free_trial_duration_days: Number.isFinite(duration) ? Math.trunc(duration) : 30,
|
|
5982
6057
|
// AppManifest defaults permission_class to "read-only" (hyphen form,
|
|
5983
6058
|
// PermissionClass.READ_ONLY). Without this default, a legacy / minimal
|
|
5984
6059
|
// manifest without permission_class compared against an upgraded one
|