@siglume/api-sdk 0.10.6 → 0.10.8
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 +99 -91
- package/dist/bin/siglume.cjs +336 -10
- package/dist/bin/siglume.cjs.map +1 -1
- package/dist/bin/siglume.js +336 -10
- package/dist/bin/siglume.js.map +1 -1
- package/dist/cli/index.cjs +336 -10
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +82 -0
- package/dist/cli/index.d.ts +82 -0
- package/dist/cli/index.js +336 -10
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +243 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +103 -1
- package/dist/index.d.ts +103 -1
- package/dist/index.js +243 -1
- package/dist/index.js.map +1 -1
- package/package.json +58 -58
package/dist/index.cjs
CHANGED
|
@@ -1559,6 +1559,56 @@ var init_operations = __esm({
|
|
|
1559
1559
|
});
|
|
1560
1560
|
|
|
1561
1561
|
// src/client.ts
|
|
1562
|
+
function validateManifestPersistenceContract(payload) {
|
|
1563
|
+
const vertical = String(payload.store_vertical ?? "").trim().toLowerCase();
|
|
1564
|
+
const persistence = payload.persistence;
|
|
1565
|
+
if (persistence === void 0 || persistence === null) {
|
|
1566
|
+
return;
|
|
1567
|
+
}
|
|
1568
|
+
if (!isRecord2(persistence)) {
|
|
1569
|
+
throw new SiglumeClientError("AppManifest.persistence must be an object.");
|
|
1570
|
+
}
|
|
1571
|
+
const mode = String(persistence.mode ?? (vertical === "game" ? "platform" : "none")).trim().toLowerCase();
|
|
1572
|
+
if (!["none", "local", "platform", "developer_server"].includes(mode)) {
|
|
1573
|
+
throw new SiglumeClientError(
|
|
1574
|
+
"AppManifest.persistence.mode must be one of: none, local, platform, developer_server."
|
|
1575
|
+
);
|
|
1576
|
+
}
|
|
1577
|
+
const schema = persistence.save_data_schema;
|
|
1578
|
+
if (vertical === "game" && mode !== "none" && schema === void 0) {
|
|
1579
|
+
throw new SiglumeClientError(
|
|
1580
|
+
"AppManifest.persistence.save_data_schema is required when store_vertical='game' and persistence.mode is not 'none'."
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1583
|
+
if (schema !== void 0) {
|
|
1584
|
+
validateSaveDataSchema(schema, "AppManifest.persistence.save_data_schema");
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
function validateSaveDataSchema(schema, fieldName) {
|
|
1588
|
+
if (!isRecord2(schema)) {
|
|
1589
|
+
throw new SiglumeClientError(`${fieldName} must be a JSON Schema object.`);
|
|
1590
|
+
}
|
|
1591
|
+
const schemaSize = new TextEncoder().encode(JSON.stringify(schema)).length;
|
|
1592
|
+
if (schemaSize > 8192) {
|
|
1593
|
+
throw new SiglumeClientError(`${fieldName} must be at most 8192 bytes.`);
|
|
1594
|
+
}
|
|
1595
|
+
if (schema.type !== "object") {
|
|
1596
|
+
throw new SiglumeClientError(`${fieldName}.type must be 'object'.`);
|
|
1597
|
+
}
|
|
1598
|
+
const properties = schema.properties;
|
|
1599
|
+
if (!isRecord2(properties) || Object.keys(properties).length === 0) {
|
|
1600
|
+
throw new SiglumeClientError(`${fieldName}.properties must be a non-empty object.`);
|
|
1601
|
+
}
|
|
1602
|
+
if (schema.required !== void 0) {
|
|
1603
|
+
if (!Array.isArray(schema.required) || !schema.required.every((item) => typeof item === "string")) {
|
|
1604
|
+
throw new SiglumeClientError(`${fieldName}.required must be an array of strings when provided.`);
|
|
1605
|
+
}
|
|
1606
|
+
const missing = schema.required.filter((item) => !(item in properties));
|
|
1607
|
+
if (missing.length > 0) {
|
|
1608
|
+
throw new SiglumeClientError(`${fieldName}.required references undefined properties: ${missing.join(", ")}.`);
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1562
1612
|
function buildToolManualQualityReport(payload) {
|
|
1563
1613
|
const qualityBlock = isRecord2(payload.quality) ? payload.quality : payload;
|
|
1564
1614
|
const issues = [];
|
|
@@ -1633,6 +1683,8 @@ function buildUrl(baseUrl, path, params) {
|
|
|
1633
1683
|
return url.toString();
|
|
1634
1684
|
}
|
|
1635
1685
|
function parseListing(data) {
|
|
1686
|
+
const metadata = isRecord2(data.metadata) ? data.metadata : {};
|
|
1687
|
+
const persistence = isRecord2(data.persistence) ? data.persistence : isRecord2(metadata.persistence) ? metadata.persistence : {};
|
|
1636
1688
|
return {
|
|
1637
1689
|
listing_id: String(data.listing_id ?? data.id ?? ""),
|
|
1638
1690
|
capability_key: String(data.capability_key ?? ""),
|
|
@@ -1646,6 +1698,8 @@ function parseListing(data) {
|
|
|
1646
1698
|
price_model: stringOrNull2(data.price_model),
|
|
1647
1699
|
price_value_minor: Number(data.price_value_minor ?? 0),
|
|
1648
1700
|
currency: String(data.currency ?? "USD"),
|
|
1701
|
+
allow_free_trial: Boolean(data.allow_free_trial ?? false),
|
|
1702
|
+
free_trial_duration_days: Number(data.free_trial_duration_days ?? 30),
|
|
1649
1703
|
short_description: stringOrNull2(data.short_description),
|
|
1650
1704
|
description: stringOrNull2(data.description),
|
|
1651
1705
|
docs_url: stringOrNull2(data.docs_url),
|
|
@@ -1653,14 +1707,59 @@ function parseListing(data) {
|
|
|
1653
1707
|
seller_display_name: stringOrNull2(data.seller_display_name),
|
|
1654
1708
|
seller_homepage_url: stringOrNull2(data.seller_homepage_url),
|
|
1655
1709
|
seller_social_url: stringOrNull2(data.seller_social_url),
|
|
1710
|
+
publisher_type: stringOrNull2(data.publisher_type),
|
|
1711
|
+
publisher_company_id: stringOrNull2(data.publisher_company_id),
|
|
1712
|
+
company_id: stringOrNull2(data.company_id),
|
|
1713
|
+
company_name: stringOrNull2(data.company_name),
|
|
1714
|
+
company_publish_status: stringOrNull2(data.company_publish_status),
|
|
1715
|
+
company_terms_version: stringOrNull2(data.company_terms_version),
|
|
1656
1716
|
review_status: stringOrNull2(data.review_status),
|
|
1657
1717
|
review_note: stringOrNull2(data.review_note),
|
|
1658
1718
|
submission_blockers: Array.isArray(data.submission_blockers) ? data.submission_blockers.filter((item) => typeof item === "string") : [],
|
|
1719
|
+
persistence: { ...persistence },
|
|
1659
1720
|
created_at: stringOrNull2(data.created_at),
|
|
1660
1721
|
updated_at: stringOrNull2(data.updated_at),
|
|
1661
1722
|
raw: { ...data }
|
|
1662
1723
|
};
|
|
1663
1724
|
}
|
|
1725
|
+
function parseCompanyPublisher(data) {
|
|
1726
|
+
const wallets = Array.isArray(data.settlement_wallets) ? data.settlement_wallets.filter((item) => isRecord2(item)) : [];
|
|
1727
|
+
return {
|
|
1728
|
+
company_id: String(data.company_id ?? data.id ?? ""),
|
|
1729
|
+
name: String(data.name ?? ""),
|
|
1730
|
+
status: String(data.status ?? ""),
|
|
1731
|
+
description: stringOrNull2(data.description),
|
|
1732
|
+
is_founder: Boolean(data.is_founder ?? false),
|
|
1733
|
+
membership_role: stringOrNull2(data.membership_role),
|
|
1734
|
+
membership_status: stringOrNull2(data.membership_status),
|
|
1735
|
+
can_publish: Boolean(data.can_publish ?? true),
|
|
1736
|
+
can_approve: Boolean(data.can_approve ?? false),
|
|
1737
|
+
approval_required: Boolean(data.approval_required ?? false),
|
|
1738
|
+
paid_listing_allowed: Boolean(data.paid_listing_allowed ?? false),
|
|
1739
|
+
disabled_reasons: Array.isArray(data.disabled_reasons) ? data.disabled_reasons.filter((item) => typeof item === "string") : [],
|
|
1740
|
+
company_terms_version: stringOrNull2(data.company_terms_version),
|
|
1741
|
+
active_listing_count: Number(data.active_listing_count ?? 0),
|
|
1742
|
+
pending_approval_count: Number(data.pending_approval_count ?? 0),
|
|
1743
|
+
settlement_wallet_ready: Boolean(data.settlement_wallet_ready ?? false),
|
|
1744
|
+
settlement_wallets: wallets.map((item) => ({ ...item })),
|
|
1745
|
+
raw: { ...data }
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
function parseCapabilitySaveState(data) {
|
|
1749
|
+
return {
|
|
1750
|
+
capability_key: String(data.capability_key ?? ""),
|
|
1751
|
+
save_key: String(data.save_key ?? ""),
|
|
1752
|
+
schema_version: String(data.schema_version ?? "1"),
|
|
1753
|
+
revision: Number(data.revision ?? 0),
|
|
1754
|
+
payload: toRecord2(data.payload),
|
|
1755
|
+
metadata: toRecord2(data.metadata),
|
|
1756
|
+
checksum: stringOrNull2(data.checksum),
|
|
1757
|
+
updated_at: stringOrNull2(data.updated_at),
|
|
1758
|
+
created_at: stringOrNull2(data.created_at),
|
|
1759
|
+
exists: Boolean(data.exists ?? false),
|
|
1760
|
+
raw: { ...data }
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1664
1763
|
function parseBundleMember(data) {
|
|
1665
1764
|
return {
|
|
1666
1765
|
capability_listing_id: String(data.capability_listing_id ?? ""),
|
|
@@ -2840,17 +2939,23 @@ var init_client = __esm({
|
|
|
2840
2939
|
"support_contact",
|
|
2841
2940
|
"seller_homepage_url",
|
|
2842
2941
|
"seller_social_url",
|
|
2942
|
+
"publisher_type",
|
|
2943
|
+
"company_id",
|
|
2944
|
+
"publisher_company_id",
|
|
2843
2945
|
"store_vertical",
|
|
2844
2946
|
"jurisdiction",
|
|
2845
2947
|
"price_model",
|
|
2846
2948
|
"price_value_minor",
|
|
2847
2949
|
"currency",
|
|
2950
|
+
"allow_free_trial",
|
|
2951
|
+
"free_trial_duration_days",
|
|
2848
2952
|
"permission_class",
|
|
2849
2953
|
"approval_mode",
|
|
2850
2954
|
"dry_run_supported",
|
|
2851
2955
|
"required_connected_accounts",
|
|
2852
2956
|
"permission_scopes",
|
|
2853
|
-
"compatibility_tags"
|
|
2957
|
+
"compatibility_tags",
|
|
2958
|
+
"persistence"
|
|
2854
2959
|
]) {
|
|
2855
2960
|
const value = manifestPayload[fieldName];
|
|
2856
2961
|
if (value !== void 0 && value !== null) {
|
|
@@ -2872,6 +2977,44 @@ var init_client = __esm({
|
|
|
2872
2977
|
throw new SiglumeClientError(`AppManifest.currency must be 'USD' or 'JPY'. Got ${String(payload.currency)}.`);
|
|
2873
2978
|
}
|
|
2874
2979
|
payload.currency = currency;
|
|
2980
|
+
if (payload.allow_free_trial === void 0 || payload.allow_free_trial === null) {
|
|
2981
|
+
throw new SiglumeClientError(
|
|
2982
|
+
"AppManifest.allow_free_trial is required. Pass true to offer a Plus/Pro buyer free trial or false to disable trials."
|
|
2983
|
+
);
|
|
2984
|
+
}
|
|
2985
|
+
if (Boolean(payload.allow_free_trial)) {
|
|
2986
|
+
const duration = payload.free_trial_duration_days ?? 30;
|
|
2987
|
+
if (typeof duration !== "number" || !Number.isInteger(duration)) {
|
|
2988
|
+
throw new SiglumeClientError(
|
|
2989
|
+
"AppManifest.free_trial_duration_days must be an integer when allow_free_trial=true."
|
|
2990
|
+
);
|
|
2991
|
+
}
|
|
2992
|
+
if (duration < 1 || duration > 90) {
|
|
2993
|
+
throw new SiglumeClientError(
|
|
2994
|
+
`AppManifest.free_trial_duration_days must be between 1 and 90 when allow_free_trial=true, got: ${duration}.`
|
|
2995
|
+
);
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
const explicitPublisherType = payload.publisher_type !== void 0 && payload.publisher_type !== null;
|
|
2999
|
+
const companyId = String(payload.company_id ?? "").trim() || String(payload.publisher_company_id ?? "").trim();
|
|
3000
|
+
const publisherType = String(payload.publisher_type ?? "user").trim().toLowerCase();
|
|
3001
|
+
if (publisherType !== "user" && publisherType !== "company") {
|
|
3002
|
+
throw new SiglumeClientError("AppManifest.publisher_type must be 'user' or 'company'.");
|
|
3003
|
+
}
|
|
3004
|
+
if (publisherType === "company" && !companyId) {
|
|
3005
|
+
throw new SiglumeClientError("AppManifest.company_id is required when publisher_type='company'.");
|
|
3006
|
+
}
|
|
3007
|
+
if (publisherType === "user" && companyId) {
|
|
3008
|
+
throw new SiglumeClientError("AppManifest.company_id cannot be combined with publisher_type='user'.");
|
|
3009
|
+
}
|
|
3010
|
+
if (explicitPublisherType || companyId) {
|
|
3011
|
+
payload.publisher_type = publisherType;
|
|
3012
|
+
}
|
|
3013
|
+
if (companyId) {
|
|
3014
|
+
payload.company_id = companyId;
|
|
3015
|
+
payload.publisher_company_id = companyId;
|
|
3016
|
+
}
|
|
3017
|
+
validateManifestPersistenceContract(payload);
|
|
2875
3018
|
if (payload.manifest && typeof payload.manifest === "object") {
|
|
2876
3019
|
delete payload.manifest.version;
|
|
2877
3020
|
}
|
|
@@ -2979,6 +3122,45 @@ var init_client = __esm({
|
|
|
2979
3122
|
const [data] = await this.request("GET", `/market/capabilities/${listing_id}`);
|
|
2980
3123
|
return parseListing(data);
|
|
2981
3124
|
}
|
|
3125
|
+
async list_company_publishers() {
|
|
3126
|
+
const [data] = await this.request("GET", "/market/company-publishers");
|
|
3127
|
+
return Array.isArray(data.items) ? data.items.filter((item) => isRecord2(item)).map(parseCompanyPublisher) : [];
|
|
3128
|
+
}
|
|
3129
|
+
async request_company_publish_approval(listing_id, note) {
|
|
3130
|
+
const [data] = await this.request("POST", `/market/capabilities/${listing_id}/company-publish-approval`, {
|
|
3131
|
+
json_body: note ? { note } : {}
|
|
3132
|
+
});
|
|
3133
|
+
return parseListing(data);
|
|
3134
|
+
}
|
|
3135
|
+
async decide_company_publish_approval(listing_id, options) {
|
|
3136
|
+
const [data] = await this.request("POST", `/market/capabilities/${listing_id}/company-publish-approval/decision`, {
|
|
3137
|
+
json_body: {
|
|
3138
|
+
decision: options.decision,
|
|
3139
|
+
...options.reason ? { reason: options.reason } : {}
|
|
3140
|
+
}
|
|
3141
|
+
});
|
|
3142
|
+
return parseListing(data);
|
|
3143
|
+
}
|
|
3144
|
+
async get_capability_state(capability_key, save_key = "default") {
|
|
3145
|
+
const [data] = await this.request("GET", `/market/capability-state/${capability_key}/${save_key}`);
|
|
3146
|
+
return parseCapabilitySaveState(data);
|
|
3147
|
+
}
|
|
3148
|
+
async put_capability_state(capability_key, save_key = "default", payload = {}, options = {}) {
|
|
3149
|
+
const body = {
|
|
3150
|
+
payload: toRecord2(payload),
|
|
3151
|
+
schema_version: options.schema_version ?? "1",
|
|
3152
|
+
metadata: toRecord2(options.metadata)
|
|
3153
|
+
};
|
|
3154
|
+
if (options.expected_revision !== void 0 && options.expected_revision !== null) {
|
|
3155
|
+
body.expected_revision = Math.trunc(options.expected_revision);
|
|
3156
|
+
}
|
|
3157
|
+
const [data] = await this.request("PUT", `/market/capability-state/${capability_key}/${save_key}`, { json_body: body });
|
|
3158
|
+
return parseCapabilitySaveState(data);
|
|
3159
|
+
}
|
|
3160
|
+
async delete_capability_state(capability_key, save_key = "default") {
|
|
3161
|
+
const [data] = await this.request("DELETE", `/market/capability-state/${capability_key}/${save_key}`);
|
|
3162
|
+
return parseCapabilitySaveState(data);
|
|
3163
|
+
}
|
|
2982
3164
|
// ----- Capability bundles (v0.7 track 2) ---------------------------------
|
|
2983
3165
|
async list_bundles(options = {}) {
|
|
2984
3166
|
const params = {
|
|
@@ -5138,6 +5320,7 @@ __export(src_exports, {
|
|
|
5138
5320
|
MeterClient: () => MeterClient,
|
|
5139
5321
|
OpenAIProvider: () => OpenAIProvider,
|
|
5140
5322
|
PermissionClass: () => PermissionClass,
|
|
5323
|
+
PersistenceMode: () => PersistenceMode,
|
|
5141
5324
|
PriceModel: () => PriceModel,
|
|
5142
5325
|
RecordMode: () => RecordMode,
|
|
5143
5326
|
Recorder: () => Recorder,
|
|
@@ -5353,6 +5536,55 @@ var SiglumeBuyerClient = class {
|
|
|
5353
5536
|
}
|
|
5354
5537
|
};
|
|
5355
5538
|
}
|
|
5539
|
+
async start_trial(options) {
|
|
5540
|
+
const listing = await this.get_listing(options.capability_key);
|
|
5541
|
+
const [data, meta] = await this.request("POST", `/market/capabilities/${listing.listing_id}/start-trial`, {
|
|
5542
|
+
json_body: {}
|
|
5543
|
+
});
|
|
5544
|
+
const accessGrant = parseAccessGrant2(toRecord2(data.access_grant));
|
|
5545
|
+
if (!accessGrant.access_grant_id) {
|
|
5546
|
+
const purchaseStatus = String(data.purchase_status ?? "trial_started");
|
|
5547
|
+
throw new SiglumeExperimentalError(
|
|
5548
|
+
`Trial started with status '${purchaseStatus}' but did not return an access grant. Buyer-side trial flows are still experimental on the public API.`
|
|
5549
|
+
);
|
|
5550
|
+
}
|
|
5551
|
+
const targetAgentId = resolveAgentId(options.agent_id, this.default_agent_id);
|
|
5552
|
+
const shouldBind = options.bind_agent ?? Boolean(targetAgentId);
|
|
5553
|
+
let binding = null;
|
|
5554
|
+
let trace_id = meta.trace_id ?? void 0;
|
|
5555
|
+
let request_id = meta.request_id ?? void 0;
|
|
5556
|
+
if (shouldBind) {
|
|
5557
|
+
if (!targetAgentId) {
|
|
5558
|
+
throw new SiglumeClientError("agent_id is required to bind a trial access grant.");
|
|
5559
|
+
}
|
|
5560
|
+
const grantBinding = await this.client.bind_agent_to_grant(accessGrant.access_grant_id, {
|
|
5561
|
+
agent_id: targetAgentId,
|
|
5562
|
+
binding_status: options.binding_status ?? "active"
|
|
5563
|
+
});
|
|
5564
|
+
binding = grantBinding.binding;
|
|
5565
|
+
trace_id = grantBinding.trace_id ?? trace_id;
|
|
5566
|
+
request_id = grantBinding.request_id ?? request_id;
|
|
5567
|
+
}
|
|
5568
|
+
return {
|
|
5569
|
+
access_grant_id: accessGrant.access_grant_id,
|
|
5570
|
+
capability_listing_id: accessGrant.capability_listing_id ?? listing.listing_id,
|
|
5571
|
+
capability_key: listing.capability_key,
|
|
5572
|
+
purchase_status: String(data.purchase_status ?? "trial_started"),
|
|
5573
|
+
grant_status: accessGrant.grant_status,
|
|
5574
|
+
agent_id: binding?.agent_id ?? targetAgentId ?? null,
|
|
5575
|
+
binding_id: binding?.binding_id ?? null,
|
|
5576
|
+
binding_status: binding?.binding_status ?? null,
|
|
5577
|
+
access_grant: accessGrant,
|
|
5578
|
+
binding,
|
|
5579
|
+
trace_id,
|
|
5580
|
+
request_id,
|
|
5581
|
+
raw: { trial: { ...data }, binding }
|
|
5582
|
+
};
|
|
5583
|
+
}
|
|
5584
|
+
async get_trial_quota() {
|
|
5585
|
+
const [data] = await this.request("GET", "/market/me/trial-quota");
|
|
5586
|
+
return { ...data };
|
|
5587
|
+
}
|
|
5356
5588
|
async invoke(options) {
|
|
5357
5589
|
if (!this.allow_internal_execute) {
|
|
5358
5590
|
throw new SiglumeExperimentalError(
|
|
@@ -6080,10 +6312,14 @@ function appendValueChange(changes, emittedKeys, level, key, oldValue, newValue,
|
|
|
6080
6312
|
}
|
|
6081
6313
|
function normalizeManifest(value) {
|
|
6082
6314
|
const payload = coerceMapping(value, "manifest");
|
|
6315
|
+
const rawDuration = payload.free_trial_duration_days;
|
|
6316
|
+
const duration = rawDuration === void 0 || rawDuration === null ? 30 : Number(rawDuration);
|
|
6083
6317
|
return {
|
|
6084
6318
|
...payload,
|
|
6085
6319
|
price_model: payload.price_model ?? "free",
|
|
6086
6320
|
currency: payload.currency ?? "USD",
|
|
6321
|
+
allow_free_trial: Boolean(payload.allow_free_trial ?? false),
|
|
6322
|
+
free_trial_duration_days: Number.isFinite(duration) ? Math.trunc(duration) : 30,
|
|
6087
6323
|
// AppManifest defaults permission_class to "read-only" (hyphen form,
|
|
6088
6324
|
// PermissionClass.READ_ONLY). Without this default, a legacy / minimal
|
|
6089
6325
|
// manifest without permission_class compared against an upgraded one
|
|
@@ -6495,6 +6731,12 @@ var ListingCurrency = {
|
|
|
6495
6731
|
USD: "USD",
|
|
6496
6732
|
JPY: "JPY"
|
|
6497
6733
|
};
|
|
6734
|
+
var PersistenceMode = {
|
|
6735
|
+
NONE: "none",
|
|
6736
|
+
LOCAL: "local",
|
|
6737
|
+
PLATFORM: "platform",
|
|
6738
|
+
DEVELOPER_SERVER: "developer_server"
|
|
6739
|
+
};
|
|
6498
6740
|
var ToolManualPermissionClass = {
|
|
6499
6741
|
READ_ONLY: "read_only",
|
|
6500
6742
|
ACTION: "action",
|