@siglume/api-sdk 1.2.1 → 2.0.0

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/index.js CHANGED
@@ -420,7 +420,12 @@ var init_webhooks = __esm({
420
420
  "capability.published",
421
421
  "capability.delisted",
422
422
  "execution.completed",
423
- "execution.failed"
423
+ "execution.failed",
424
+ "reward_payout.created",
425
+ "reward_payout.provider_pending",
426
+ "reward_paid",
427
+ "reward_payout.failed",
428
+ "reward_payout.cancelled"
424
429
  ];
425
430
  WEBHOOK_EVENT_SET = new Set(WEBHOOK_EVENT_TYPES);
426
431
  InMemoryWebhookDedupe = class {
@@ -1714,6 +1719,23 @@ function validatePricingPlanFloor(plan, defaultCurrency) {
1714
1719
  function pricingPlanHasItems(plan) {
1715
1720
  return isRecord2(plan) && Array.isArray(plan.items) && plan.items.length > 0;
1716
1721
  }
1722
+ function validateListingTextLengths(payload) {
1723
+ const limits = {
1724
+ short_description: LISTING_SHORT_DESCRIPTION_MAX_LENGTH,
1725
+ job_to_be_done: LISTING_JOB_TO_BE_DONE_MAX_LENGTH,
1726
+ description: LISTING_DESCRIPTION_MAX_LENGTH
1727
+ };
1728
+ for (const [fieldName, maxLength] of Object.entries(limits)) {
1729
+ const value = payload[fieldName];
1730
+ if (value === void 0 || value === null) continue;
1731
+ if (typeof value !== "string") {
1732
+ throw new SiglumeClientError(`AppManifest.${fieldName} must be a string when provided.`);
1733
+ }
1734
+ if (Array.from(value).length > maxLength) {
1735
+ throw new SiglumeClientError(`AppManifest.${fieldName} must be at most ${maxLength} characters.`);
1736
+ }
1737
+ }
1738
+ }
1717
1739
  function buildToolManualQualityReport(payload) {
1718
1740
  const qualityBlock = isRecord2(payload.quality) ? payload.quality : payload;
1719
1741
  const issues = [];
@@ -2271,139 +2293,6 @@ function parseInstalledToolReceiptStep(data) {
2271
2293
  raw: { ...data }
2272
2294
  };
2273
2295
  }
2274
- function toRecordList(value) {
2275
- return Array.isArray(value) ? value.filter((item) => isRecord2(item)).map((item) => ({ ...item })) : [];
2276
- }
2277
- function parsePartnerDashboard(data) {
2278
- return {
2279
- partner_id: String(data.partner_id ?? data.user_id ?? ""),
2280
- company_name: stringOrNull2(data.company_name) ?? void 0,
2281
- plan: stringOrNull2(data.plan) ?? void 0,
2282
- plan_label: stringOrNull2(data.plan_label) ?? void 0,
2283
- month_bytes_used: Math.trunc(Number(data.month_bytes_used ?? 0)),
2284
- month_bytes_limit: Math.trunc(Number(data.month_bytes_limit ?? 0)),
2285
- month_usage_pct: Number(data.month_usage_pct ?? 0),
2286
- total_source_items: Math.trunc(Number(data.total_source_items ?? 0)),
2287
- has_billing: Boolean(data.has_billing ?? false),
2288
- has_subscription: Boolean(data.has_subscription ?? false),
2289
- raw: { ...data }
2290
- };
2291
- }
2292
- function parsePartnerUsage(data) {
2293
- return {
2294
- plan: stringOrNull2(data.plan) ?? void 0,
2295
- month_bytes_used: Math.trunc(Number(data.month_bytes_used ?? 0)),
2296
- month_bytes_limit: Math.trunc(Number(data.month_bytes_limit ?? 0)),
2297
- month_bytes_remaining: Math.trunc(Number(data.month_bytes_remaining ?? 0)),
2298
- month_usage_pct: Number(data.month_usage_pct ?? 0),
2299
- raw: { ...data }
2300
- };
2301
- }
2302
- function parsePartnerApiKey(data) {
2303
- return {
2304
- credential_id: String(data.credential_id ?? data.id ?? ""),
2305
- name: stringOrNull2(data.name) ?? void 0,
2306
- key_id: stringOrNull2(data.key_id) ?? void 0,
2307
- allowed_source_types: Array.isArray(data.allowed_source_types) ? data.allowed_source_types.filter((item) => typeof item === "string") : [],
2308
- last_used_at: stringOrNull2(data.last_used_at) ?? void 0,
2309
- created_at: stringOrNull2(data.created_at) ?? void 0,
2310
- revoked: Boolean(data.revoked ?? false),
2311
- raw: { ...data }
2312
- };
2313
- }
2314
- function parsePartnerApiKeyHandle(data) {
2315
- const raw = Object.fromEntries(
2316
- Object.entries(data).filter(([key]) => key !== "ingest_key" && key !== "full_key")
2317
- );
2318
- return {
2319
- credential_id: String(raw.credential_id ?? raw.id ?? ""),
2320
- name: stringOrNull2(raw.name) ?? void 0,
2321
- key_id: stringOrNull2(raw.key_id) ?? void 0,
2322
- allowed_source_types: Array.isArray(raw.allowed_source_types) ? raw.allowed_source_types.filter((item) => typeof item === "string") : [],
2323
- masked_key_hint: stringOrNull2(raw.masked_key_hint) ?? void 0,
2324
- raw
2325
- };
2326
- }
2327
- function parseAdsBilling(data) {
2328
- return {
2329
- currency: stringOrNull2(data.currency) ?? void 0,
2330
- billing_mode: stringOrNull2(data.billing_mode) ?? void 0,
2331
- month_spend_jpy: Math.trunc(Number(data.month_spend_jpy ?? 0)),
2332
- month_spend_usd: Math.trunc(Number(data.month_spend_usd ?? 0)),
2333
- all_time_spend_jpy: Math.trunc(Number(data.all_time_spend_jpy ?? 0)),
2334
- all_time_spend_usd: Math.trunc(Number(data.all_time_spend_usd ?? 0)),
2335
- total_impressions: Math.trunc(Number(data.total_impressions ?? 0)),
2336
- total_replies: Math.trunc(Number(data.total_replies ?? 0)),
2337
- has_billing: Boolean(data.has_billing ?? false),
2338
- has_subscription: Boolean(data.has_subscription ?? false),
2339
- invoices: toRecordList(data.invoices),
2340
- wallet: isRecord2(data.wallet) ? { ...data.wallet } : null,
2341
- balances: toRecordList(data.balances),
2342
- supported_tokens: toRecordList(data.supported_tokens),
2343
- funding_instructions: isRecord2(data.funding_instructions) ? { ...data.funding_instructions } : null,
2344
- mandate: isRecord2(data.mandate) ? parsePlanWeb3Mandate(data.mandate) : null,
2345
- raw: { ...data }
2346
- };
2347
- }
2348
- function parseAdsBillingSettlement(data) {
2349
- return {
2350
- status: stringOrNull2(data.status) ?? void 0,
2351
- message: stringOrNull2(data.message ?? data.detail) ?? void 0,
2352
- settles_automatically: typeof data.settles_automatically === "boolean" ? data.settles_automatically : typeof data.auto_settles === "boolean" ? data.auto_settles : void 0,
2353
- cycle_key: stringOrNull2(data.cycle_key) ?? void 0,
2354
- settled_at: stringOrNull2(data.settled_at) ?? void 0,
2355
- raw: { ...data }
2356
- };
2357
- }
2358
- function parseAdsProfile(data) {
2359
- return {
2360
- has_profile: Boolean(data.has_profile ?? false),
2361
- company_name: stringOrNull2(data.company_name) ?? void 0,
2362
- ad_currency: stringOrNull2(data.ad_currency) ?? void 0,
2363
- has_billing: Boolean(data.has_billing ?? false),
2364
- raw: { ...data }
2365
- };
2366
- }
2367
- function parseAdsCampaign(data) {
2368
- return {
2369
- campaign_id: String(data.campaign_id ?? data.id ?? ""),
2370
- name: stringOrNull2(data.name) ?? void 0,
2371
- target_url: stringOrNull2(data.target_url) ?? void 0,
2372
- content_brief: stringOrNull2(data.content_brief) ?? void 0,
2373
- target_topics: Array.isArray(data.target_topics) ? data.target_topics.filter((item) => typeof item === "string") : [],
2374
- posting_interval_minutes: Math.trunc(Number(data.posting_interval_minutes ?? 360)),
2375
- max_posts_per_day: Math.trunc(Number(data.max_posts_per_day ?? 4)),
2376
- currency: stringOrNull2(data.currency) ?? void 0,
2377
- monthly_budget_jpy: Math.trunc(Number(data.monthly_budget_jpy ?? 0)),
2378
- cpm_jpy: Math.trunc(Number(data.cpm_jpy ?? 0)),
2379
- cpr_jpy: Math.trunc(Number(data.cpr_jpy ?? 0)),
2380
- monthly_budget_usd: Math.trunc(Number(data.monthly_budget_usd ?? 0)),
2381
- cpm_usd: Math.trunc(Number(data.cpm_usd ?? 0)),
2382
- cpr_usd: Math.trunc(Number(data.cpr_usd ?? 0)),
2383
- status: String(data.status ?? "active").trim().toLowerCase() || "active",
2384
- month_spend_jpy: Math.trunc(Number(data.month_spend_jpy ?? 0)),
2385
- month_spend_usd: Math.trunc(Number(data.month_spend_usd ?? 0)),
2386
- total_posts: Math.trunc(Number(data.total_posts ?? 0)),
2387
- total_impressions: Math.trunc(Number(data.total_impressions ?? 0)),
2388
- total_replies: Math.trunc(Number(data.total_replies ?? 0)),
2389
- next_post_at: stringOrNull2(data.next_post_at) ?? void 0,
2390
- created_at: stringOrNull2(data.created_at) ?? void 0,
2391
- raw: { ...data }
2392
- };
2393
- }
2394
- function parseAdsCampaignPost(data) {
2395
- return {
2396
- post_id: String(data.post_id ?? data.id ?? ""),
2397
- content_id: stringOrNull2(data.content_id) ?? void 0,
2398
- cost_jpy: Math.trunc(Number(data.cost_jpy ?? 0)),
2399
- cost_usd: Math.trunc(Number(data.cost_usd ?? 0)),
2400
- impressions: Math.trunc(Number(data.impressions ?? 0)),
2401
- replies: Math.trunc(Number(data.replies ?? 0)),
2402
- status: stringOrNull2(data.status) ?? void 0,
2403
- created_at: stringOrNull2(data.created_at) ?? void 0,
2404
- raw: { ...data }
2405
- };
2406
- }
2407
2296
  function parseWorksCategory(data) {
2408
2297
  return {
2409
2298
  key: String(data.key ?? ""),
@@ -2902,7 +2791,7 @@ function cloneJsonLike(value) {
2902
2791
  }
2903
2792
  return value;
2904
2793
  }
2905
- var DEFAULT_SIGLUME_API_BASE, RETRYABLE_STATUS_CODES, MINIMUM_JPY_OPERATION_PRICE_CURRENCIES, CursorPageResult, SiglumeClient;
2794
+ var DEFAULT_SIGLUME_API_BASE, RETRYABLE_STATUS_CODES, MINIMUM_JPY_OPERATION_PRICE_CURRENCIES, LISTING_SHORT_DESCRIPTION_MAX_LENGTH, LISTING_JOB_TO_BE_DONE_MAX_LENGTH, LISTING_DESCRIPTION_MAX_LENGTH, CursorPageResult, SiglumeClient;
2906
2795
  var init_client = __esm({
2907
2796
  "src/client.ts"() {
2908
2797
  "use strict";
@@ -2915,6 +2804,9 @@ var init_client = __esm({
2915
2804
  DEFAULT_SIGLUME_API_BASE = "https://siglume.com/v1";
2916
2805
  RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
2917
2806
  MINIMUM_JPY_OPERATION_PRICE_CURRENCIES = /* @__PURE__ */ new Set(["JPY", "JPYC"]);
2807
+ LISTING_SHORT_DESCRIPTION_MAX_LENGTH = 60;
2808
+ LISTING_JOB_TO_BE_DONE_MAX_LENGTH = 240;
2809
+ LISTING_DESCRIPTION_MAX_LENGTH = 1e3;
2918
2810
  CursorPageResult = class {
2919
2811
  items;
2920
2812
  next_cursor;
@@ -3068,6 +2960,7 @@ var init_client = __esm({
3068
2960
  if (payload.pricing_plan !== void 0) {
3069
2961
  validatePricingPlanFloor(payload.pricing_plan, currency);
3070
2962
  }
2963
+ validateListingTextLengths(payload);
3071
2964
  const priceModel = String(payload.price_model ?? "free").trim().toLowerCase();
3072
2965
  if ((priceModel === "usage_based" || priceModel === "per_action") && !pricingPlanHasItems(payload.pricing_plan)) {
3073
2966
  throw new SiglumeClientError("AppManifest.pricing_plan.items is required for usage_based/per_action pricing.");
@@ -4210,115 +4103,6 @@ var init_client = __esm({
4210
4103
  );
4211
4104
  return Array.isArray(data.result) ? data.result.filter((item) => isRecord2(item)).map((item) => parseInstalledToolReceiptStep(item)) : [];
4212
4105
  }
4213
- async get_partner_dashboard(options = {}) {
4214
- const execution = await this.execute_owner_operation(
4215
- await this.resolveOwnerOperationAgentId(options.agent_id),
4216
- "partner.dashboard.get",
4217
- {},
4218
- { lang: options.lang }
4219
- );
4220
- return parsePartnerDashboard(execution.result);
4221
- }
4222
- async get_partner_usage(options = {}) {
4223
- const execution = await this.execute_owner_operation(
4224
- await this.resolveOwnerOperationAgentId(options.agent_id),
4225
- "partner.usage.get",
4226
- {},
4227
- { lang: options.lang }
4228
- );
4229
- return parsePartnerUsage(execution.result);
4230
- }
4231
- async list_partner_api_keys(options = {}) {
4232
- const execution = await this.execute_owner_operation(
4233
- await this.resolveOwnerOperationAgentId(options.agent_id),
4234
- "partner.keys.list",
4235
- {},
4236
- { lang: options.lang }
4237
- );
4238
- return Array.isArray(execution.result.keys) ? execution.result.keys.filter((item) => isRecord2(item)).map((item) => parsePartnerApiKey(item)) : [];
4239
- }
4240
- async create_partner_api_key(options = {}) {
4241
- const payload = {};
4242
- if (options.name !== void 0) {
4243
- const normalizedName = String(options.name).trim();
4244
- if (!normalizedName) {
4245
- throw new SiglumeClientError("name cannot be empty.");
4246
- }
4247
- payload.name = normalizedName;
4248
- }
4249
- if (options.allowed_source_types !== void 0) {
4250
- if (!Array.isArray(options.allowed_source_types)) {
4251
- throw new SiglumeClientError("allowed_source_types must be a list of strings.");
4252
- }
4253
- payload.allowed_source_types = options.allowed_source_types.flatMap((item) => {
4254
- if (typeof item !== "string") {
4255
- throw new SiglumeClientError("allowed_source_types must contain only strings.");
4256
- }
4257
- const normalizedItem = item.trim();
4258
- return normalizedItem ? [normalizedItem] : [];
4259
- });
4260
- }
4261
- const execution = await this.execute_owner_operation(
4262
- await this.resolveOwnerOperationAgentId(options.agent_id),
4263
- "partner.keys.create",
4264
- payload,
4265
- { lang: options.lang }
4266
- );
4267
- return parsePartnerApiKeyHandle(execution.result);
4268
- }
4269
- async get_ads_billing(options = {}) {
4270
- const payload = {};
4271
- if (options.rail !== void 0 && String(options.rail).trim()) {
4272
- payload.rail = String(options.rail).trim().toLowerCase();
4273
- }
4274
- const execution = await this.execute_owner_operation(
4275
- await this.resolveOwnerOperationAgentId(options.agent_id),
4276
- "ads.billing.get",
4277
- payload,
4278
- { lang: options.lang }
4279
- );
4280
- return parseAdsBilling(execution.result);
4281
- }
4282
- async settle_ads_billing(options = {}) {
4283
- const execution = await this.execute_owner_operation(
4284
- await this.resolveOwnerOperationAgentId(options.agent_id),
4285
- "ads.billing.settle",
4286
- {},
4287
- { lang: options.lang }
4288
- );
4289
- return parseAdsBillingSettlement(execution.result);
4290
- }
4291
- async get_ads_profile(options = {}) {
4292
- const execution = await this.execute_owner_operation(
4293
- await this.resolveOwnerOperationAgentId(options.agent_id),
4294
- "ads.profile.get",
4295
- {},
4296
- { lang: options.lang }
4297
- );
4298
- return parseAdsProfile(execution.result);
4299
- }
4300
- async list_ads_campaigns(options = {}) {
4301
- const execution = await this.execute_owner_operation(
4302
- await this.resolveOwnerOperationAgentId(options.agent_id),
4303
- "ads.campaigns.list",
4304
- {},
4305
- { lang: options.lang }
4306
- );
4307
- return Array.isArray(execution.result.campaigns) ? execution.result.campaigns.filter((item) => isRecord2(item)).map((item) => parseAdsCampaign(item)) : [];
4308
- }
4309
- async list_ads_campaign_posts(campaign_id, options = {}) {
4310
- const normalizedCampaignId = String(campaign_id ?? "").trim();
4311
- if (!normalizedCampaignId) {
4312
- throw new SiglumeClientError("campaign_id is required.");
4313
- }
4314
- const execution = await this.execute_owner_operation(
4315
- await this.resolveOwnerOperationAgentId(options.agent_id),
4316
- "ads.campaign_posts.list",
4317
- { campaign_id: normalizedCampaignId },
4318
- { lang: options.lang }
4319
- );
4320
- return Array.isArray(execution.result.posts) ? execution.result.posts.filter((item) => isRecord2(item)).map((item) => parseAdsCampaignPost(item)) : [];
4321
- }
4322
4106
  // `market.proposals.*` currently rides on the public owner-operation execute
4323
4107
  // route. Read helpers return typed proposal records; guarded mutations return
4324
4108
  // the approval envelope without treating it as an error.
@@ -7125,12 +6909,15 @@ function validate_tool_manual(manualInput) {
7125
6909
  pushError("INVALID_TOOL_NAME", "tool_name must be alphanumeric + underscore, 3-64 chars", "tool_name");
7126
6910
  }
7127
6911
  for (const [fieldName, minLength, maxLength] of [
7128
- ["job_to_be_done", 10, 500],
6912
+ ["job_to_be_done", 10, 240],
7129
6913
  ["summary_for_model", 10, 300]
7130
6914
  ]) {
7131
6915
  const value = manual[fieldName];
7132
- if (typeof value === "string" && (value.length < minLength || value.length > maxLength)) {
7133
- pushError("INVALID_TYPE", `${fieldName} must be ${minLength}-${maxLength} characters`, fieldName);
6916
+ if (typeof value === "string") {
6917
+ const length = Array.from(value).length;
6918
+ if (length < minLength || length > maxLength) {
6919
+ pushError("INVALID_TYPE", `${fieldName} must be ${minLength}-${maxLength} characters`, fieldName);
6920
+ }
7134
6921
  }
7135
6922
  }
7136
6923
  const triggerConditions = manual.trigger_conditions;
@@ -8806,7 +8593,7 @@ function normalizeSchema(value) {
8806
8593
  function buildToolManualSchema(permissionClass, fields) {
8807
8594
  const properties = {
8808
8595
  tool_name: { type: "string", minLength: 3, maxLength: 64 },
8809
- job_to_be_done: { type: "string", minLength: 10, maxLength: 500 },
8596
+ job_to_be_done: { type: "string", minLength: 10, maxLength: 240 },
8810
8597
  summary_for_model: { type: "string", minLength: 10, maxLength: 300 },
8811
8598
  trigger_conditions: {
8812
8599
  type: "array",