@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.cjs CHANGED
@@ -442,7 +442,12 @@ var init_webhooks = __esm({
442
442
  "capability.published",
443
443
  "capability.delisted",
444
444
  "execution.completed",
445
- "execution.failed"
445
+ "execution.failed",
446
+ "reward_payout.created",
447
+ "reward_payout.provider_pending",
448
+ "reward_paid",
449
+ "reward_payout.failed",
450
+ "reward_payout.cancelled"
446
451
  ];
447
452
  WEBHOOK_EVENT_SET = new Set(WEBHOOK_EVENT_TYPES);
448
453
  InMemoryWebhookDedupe = class {
@@ -1736,6 +1741,23 @@ function validatePricingPlanFloor(plan, defaultCurrency) {
1736
1741
  function pricingPlanHasItems(plan) {
1737
1742
  return isRecord2(plan) && Array.isArray(plan.items) && plan.items.length > 0;
1738
1743
  }
1744
+ function validateListingTextLengths(payload) {
1745
+ const limits = {
1746
+ short_description: LISTING_SHORT_DESCRIPTION_MAX_LENGTH,
1747
+ job_to_be_done: LISTING_JOB_TO_BE_DONE_MAX_LENGTH,
1748
+ description: LISTING_DESCRIPTION_MAX_LENGTH
1749
+ };
1750
+ for (const [fieldName, maxLength] of Object.entries(limits)) {
1751
+ const value = payload[fieldName];
1752
+ if (value === void 0 || value === null) continue;
1753
+ if (typeof value !== "string") {
1754
+ throw new SiglumeClientError(`AppManifest.${fieldName} must be a string when provided.`);
1755
+ }
1756
+ if (Array.from(value).length > maxLength) {
1757
+ throw new SiglumeClientError(`AppManifest.${fieldName} must be at most ${maxLength} characters.`);
1758
+ }
1759
+ }
1760
+ }
1739
1761
  function buildToolManualQualityReport(payload) {
1740
1762
  const qualityBlock = isRecord2(payload.quality) ? payload.quality : payload;
1741
1763
  const issues = [];
@@ -2293,139 +2315,6 @@ function parseInstalledToolReceiptStep(data) {
2293
2315
  raw: { ...data }
2294
2316
  };
2295
2317
  }
2296
- function toRecordList(value) {
2297
- return Array.isArray(value) ? value.filter((item) => isRecord2(item)).map((item) => ({ ...item })) : [];
2298
- }
2299
- function parsePartnerDashboard(data) {
2300
- return {
2301
- partner_id: String(data.partner_id ?? data.user_id ?? ""),
2302
- company_name: stringOrNull2(data.company_name) ?? void 0,
2303
- plan: stringOrNull2(data.plan) ?? void 0,
2304
- plan_label: stringOrNull2(data.plan_label) ?? void 0,
2305
- month_bytes_used: Math.trunc(Number(data.month_bytes_used ?? 0)),
2306
- month_bytes_limit: Math.trunc(Number(data.month_bytes_limit ?? 0)),
2307
- month_usage_pct: Number(data.month_usage_pct ?? 0),
2308
- total_source_items: Math.trunc(Number(data.total_source_items ?? 0)),
2309
- has_billing: Boolean(data.has_billing ?? false),
2310
- has_subscription: Boolean(data.has_subscription ?? false),
2311
- raw: { ...data }
2312
- };
2313
- }
2314
- function parsePartnerUsage(data) {
2315
- return {
2316
- plan: stringOrNull2(data.plan) ?? void 0,
2317
- month_bytes_used: Math.trunc(Number(data.month_bytes_used ?? 0)),
2318
- month_bytes_limit: Math.trunc(Number(data.month_bytes_limit ?? 0)),
2319
- month_bytes_remaining: Math.trunc(Number(data.month_bytes_remaining ?? 0)),
2320
- month_usage_pct: Number(data.month_usage_pct ?? 0),
2321
- raw: { ...data }
2322
- };
2323
- }
2324
- function parsePartnerApiKey(data) {
2325
- return {
2326
- credential_id: String(data.credential_id ?? data.id ?? ""),
2327
- name: stringOrNull2(data.name) ?? void 0,
2328
- key_id: stringOrNull2(data.key_id) ?? void 0,
2329
- allowed_source_types: Array.isArray(data.allowed_source_types) ? data.allowed_source_types.filter((item) => typeof item === "string") : [],
2330
- last_used_at: stringOrNull2(data.last_used_at) ?? void 0,
2331
- created_at: stringOrNull2(data.created_at) ?? void 0,
2332
- revoked: Boolean(data.revoked ?? false),
2333
- raw: { ...data }
2334
- };
2335
- }
2336
- function parsePartnerApiKeyHandle(data) {
2337
- const raw = Object.fromEntries(
2338
- Object.entries(data).filter(([key]) => key !== "ingest_key" && key !== "full_key")
2339
- );
2340
- return {
2341
- credential_id: String(raw.credential_id ?? raw.id ?? ""),
2342
- name: stringOrNull2(raw.name) ?? void 0,
2343
- key_id: stringOrNull2(raw.key_id) ?? void 0,
2344
- allowed_source_types: Array.isArray(raw.allowed_source_types) ? raw.allowed_source_types.filter((item) => typeof item === "string") : [],
2345
- masked_key_hint: stringOrNull2(raw.masked_key_hint) ?? void 0,
2346
- raw
2347
- };
2348
- }
2349
- function parseAdsBilling(data) {
2350
- return {
2351
- currency: stringOrNull2(data.currency) ?? void 0,
2352
- billing_mode: stringOrNull2(data.billing_mode) ?? void 0,
2353
- month_spend_jpy: Math.trunc(Number(data.month_spend_jpy ?? 0)),
2354
- month_spend_usd: Math.trunc(Number(data.month_spend_usd ?? 0)),
2355
- all_time_spend_jpy: Math.trunc(Number(data.all_time_spend_jpy ?? 0)),
2356
- all_time_spend_usd: Math.trunc(Number(data.all_time_spend_usd ?? 0)),
2357
- total_impressions: Math.trunc(Number(data.total_impressions ?? 0)),
2358
- total_replies: Math.trunc(Number(data.total_replies ?? 0)),
2359
- has_billing: Boolean(data.has_billing ?? false),
2360
- has_subscription: Boolean(data.has_subscription ?? false),
2361
- invoices: toRecordList(data.invoices),
2362
- wallet: isRecord2(data.wallet) ? { ...data.wallet } : null,
2363
- balances: toRecordList(data.balances),
2364
- supported_tokens: toRecordList(data.supported_tokens),
2365
- funding_instructions: isRecord2(data.funding_instructions) ? { ...data.funding_instructions } : null,
2366
- mandate: isRecord2(data.mandate) ? parsePlanWeb3Mandate(data.mandate) : null,
2367
- raw: { ...data }
2368
- };
2369
- }
2370
- function parseAdsBillingSettlement(data) {
2371
- return {
2372
- status: stringOrNull2(data.status) ?? void 0,
2373
- message: stringOrNull2(data.message ?? data.detail) ?? void 0,
2374
- settles_automatically: typeof data.settles_automatically === "boolean" ? data.settles_automatically : typeof data.auto_settles === "boolean" ? data.auto_settles : void 0,
2375
- cycle_key: stringOrNull2(data.cycle_key) ?? void 0,
2376
- settled_at: stringOrNull2(data.settled_at) ?? void 0,
2377
- raw: { ...data }
2378
- };
2379
- }
2380
- function parseAdsProfile(data) {
2381
- return {
2382
- has_profile: Boolean(data.has_profile ?? false),
2383
- company_name: stringOrNull2(data.company_name) ?? void 0,
2384
- ad_currency: stringOrNull2(data.ad_currency) ?? void 0,
2385
- has_billing: Boolean(data.has_billing ?? false),
2386
- raw: { ...data }
2387
- };
2388
- }
2389
- function parseAdsCampaign(data) {
2390
- return {
2391
- campaign_id: String(data.campaign_id ?? data.id ?? ""),
2392
- name: stringOrNull2(data.name) ?? void 0,
2393
- target_url: stringOrNull2(data.target_url) ?? void 0,
2394
- content_brief: stringOrNull2(data.content_brief) ?? void 0,
2395
- target_topics: Array.isArray(data.target_topics) ? data.target_topics.filter((item) => typeof item === "string") : [],
2396
- posting_interval_minutes: Math.trunc(Number(data.posting_interval_minutes ?? 360)),
2397
- max_posts_per_day: Math.trunc(Number(data.max_posts_per_day ?? 4)),
2398
- currency: stringOrNull2(data.currency) ?? void 0,
2399
- monthly_budget_jpy: Math.trunc(Number(data.monthly_budget_jpy ?? 0)),
2400
- cpm_jpy: Math.trunc(Number(data.cpm_jpy ?? 0)),
2401
- cpr_jpy: Math.trunc(Number(data.cpr_jpy ?? 0)),
2402
- monthly_budget_usd: Math.trunc(Number(data.monthly_budget_usd ?? 0)),
2403
- cpm_usd: Math.trunc(Number(data.cpm_usd ?? 0)),
2404
- cpr_usd: Math.trunc(Number(data.cpr_usd ?? 0)),
2405
- status: String(data.status ?? "active").trim().toLowerCase() || "active",
2406
- month_spend_jpy: Math.trunc(Number(data.month_spend_jpy ?? 0)),
2407
- month_spend_usd: Math.trunc(Number(data.month_spend_usd ?? 0)),
2408
- total_posts: Math.trunc(Number(data.total_posts ?? 0)),
2409
- total_impressions: Math.trunc(Number(data.total_impressions ?? 0)),
2410
- total_replies: Math.trunc(Number(data.total_replies ?? 0)),
2411
- next_post_at: stringOrNull2(data.next_post_at) ?? void 0,
2412
- created_at: stringOrNull2(data.created_at) ?? void 0,
2413
- raw: { ...data }
2414
- };
2415
- }
2416
- function parseAdsCampaignPost(data) {
2417
- return {
2418
- post_id: String(data.post_id ?? data.id ?? ""),
2419
- content_id: stringOrNull2(data.content_id) ?? void 0,
2420
- cost_jpy: Math.trunc(Number(data.cost_jpy ?? 0)),
2421
- cost_usd: Math.trunc(Number(data.cost_usd ?? 0)),
2422
- impressions: Math.trunc(Number(data.impressions ?? 0)),
2423
- replies: Math.trunc(Number(data.replies ?? 0)),
2424
- status: stringOrNull2(data.status) ?? void 0,
2425
- created_at: stringOrNull2(data.created_at) ?? void 0,
2426
- raw: { ...data }
2427
- };
2428
- }
2429
2318
  function parseWorksCategory(data) {
2430
2319
  return {
2431
2320
  key: String(data.key ?? ""),
@@ -2924,7 +2813,7 @@ function cloneJsonLike(value) {
2924
2813
  }
2925
2814
  return value;
2926
2815
  }
2927
- var DEFAULT_SIGLUME_API_BASE, RETRYABLE_STATUS_CODES, MINIMUM_JPY_OPERATION_PRICE_CURRENCIES, CursorPageResult, SiglumeClient;
2816
+ 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;
2928
2817
  var init_client = __esm({
2929
2818
  "src/client.ts"() {
2930
2819
  "use strict";
@@ -2937,6 +2826,9 @@ var init_client = __esm({
2937
2826
  DEFAULT_SIGLUME_API_BASE = "https://siglume.com/v1";
2938
2827
  RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
2939
2828
  MINIMUM_JPY_OPERATION_PRICE_CURRENCIES = /* @__PURE__ */ new Set(["JPY", "JPYC"]);
2829
+ LISTING_SHORT_DESCRIPTION_MAX_LENGTH = 60;
2830
+ LISTING_JOB_TO_BE_DONE_MAX_LENGTH = 240;
2831
+ LISTING_DESCRIPTION_MAX_LENGTH = 1e3;
2940
2832
  CursorPageResult = class {
2941
2833
  items;
2942
2834
  next_cursor;
@@ -3090,6 +2982,7 @@ var init_client = __esm({
3090
2982
  if (payload.pricing_plan !== void 0) {
3091
2983
  validatePricingPlanFloor(payload.pricing_plan, currency);
3092
2984
  }
2985
+ validateListingTextLengths(payload);
3093
2986
  const priceModel = String(payload.price_model ?? "free").trim().toLowerCase();
3094
2987
  if ((priceModel === "usage_based" || priceModel === "per_action") && !pricingPlanHasItems(payload.pricing_plan)) {
3095
2988
  throw new SiglumeClientError("AppManifest.pricing_plan.items is required for usage_based/per_action pricing.");
@@ -4232,115 +4125,6 @@ var init_client = __esm({
4232
4125
  );
4233
4126
  return Array.isArray(data.result) ? data.result.filter((item) => isRecord2(item)).map((item) => parseInstalledToolReceiptStep(item)) : [];
4234
4127
  }
4235
- async get_partner_dashboard(options = {}) {
4236
- const execution = await this.execute_owner_operation(
4237
- await this.resolveOwnerOperationAgentId(options.agent_id),
4238
- "partner.dashboard.get",
4239
- {},
4240
- { lang: options.lang }
4241
- );
4242
- return parsePartnerDashboard(execution.result);
4243
- }
4244
- async get_partner_usage(options = {}) {
4245
- const execution = await this.execute_owner_operation(
4246
- await this.resolveOwnerOperationAgentId(options.agent_id),
4247
- "partner.usage.get",
4248
- {},
4249
- { lang: options.lang }
4250
- );
4251
- return parsePartnerUsage(execution.result);
4252
- }
4253
- async list_partner_api_keys(options = {}) {
4254
- const execution = await this.execute_owner_operation(
4255
- await this.resolveOwnerOperationAgentId(options.agent_id),
4256
- "partner.keys.list",
4257
- {},
4258
- { lang: options.lang }
4259
- );
4260
- return Array.isArray(execution.result.keys) ? execution.result.keys.filter((item) => isRecord2(item)).map((item) => parsePartnerApiKey(item)) : [];
4261
- }
4262
- async create_partner_api_key(options = {}) {
4263
- const payload = {};
4264
- if (options.name !== void 0) {
4265
- const normalizedName = String(options.name).trim();
4266
- if (!normalizedName) {
4267
- throw new SiglumeClientError("name cannot be empty.");
4268
- }
4269
- payload.name = normalizedName;
4270
- }
4271
- if (options.allowed_source_types !== void 0) {
4272
- if (!Array.isArray(options.allowed_source_types)) {
4273
- throw new SiglumeClientError("allowed_source_types must be a list of strings.");
4274
- }
4275
- payload.allowed_source_types = options.allowed_source_types.flatMap((item) => {
4276
- if (typeof item !== "string") {
4277
- throw new SiglumeClientError("allowed_source_types must contain only strings.");
4278
- }
4279
- const normalizedItem = item.trim();
4280
- return normalizedItem ? [normalizedItem] : [];
4281
- });
4282
- }
4283
- const execution = await this.execute_owner_operation(
4284
- await this.resolveOwnerOperationAgentId(options.agent_id),
4285
- "partner.keys.create",
4286
- payload,
4287
- { lang: options.lang }
4288
- );
4289
- return parsePartnerApiKeyHandle(execution.result);
4290
- }
4291
- async get_ads_billing(options = {}) {
4292
- const payload = {};
4293
- if (options.rail !== void 0 && String(options.rail).trim()) {
4294
- payload.rail = String(options.rail).trim().toLowerCase();
4295
- }
4296
- const execution = await this.execute_owner_operation(
4297
- await this.resolveOwnerOperationAgentId(options.agent_id),
4298
- "ads.billing.get",
4299
- payload,
4300
- { lang: options.lang }
4301
- );
4302
- return parseAdsBilling(execution.result);
4303
- }
4304
- async settle_ads_billing(options = {}) {
4305
- const execution = await this.execute_owner_operation(
4306
- await this.resolveOwnerOperationAgentId(options.agent_id),
4307
- "ads.billing.settle",
4308
- {},
4309
- { lang: options.lang }
4310
- );
4311
- return parseAdsBillingSettlement(execution.result);
4312
- }
4313
- async get_ads_profile(options = {}) {
4314
- const execution = await this.execute_owner_operation(
4315
- await this.resolveOwnerOperationAgentId(options.agent_id),
4316
- "ads.profile.get",
4317
- {},
4318
- { lang: options.lang }
4319
- );
4320
- return parseAdsProfile(execution.result);
4321
- }
4322
- async list_ads_campaigns(options = {}) {
4323
- const execution = await this.execute_owner_operation(
4324
- await this.resolveOwnerOperationAgentId(options.agent_id),
4325
- "ads.campaigns.list",
4326
- {},
4327
- { lang: options.lang }
4328
- );
4329
- return Array.isArray(execution.result.campaigns) ? execution.result.campaigns.filter((item) => isRecord2(item)).map((item) => parseAdsCampaign(item)) : [];
4330
- }
4331
- async list_ads_campaign_posts(campaign_id, options = {}) {
4332
- const normalizedCampaignId = String(campaign_id ?? "").trim();
4333
- if (!normalizedCampaignId) {
4334
- throw new SiglumeClientError("campaign_id is required.");
4335
- }
4336
- const execution = await this.execute_owner_operation(
4337
- await this.resolveOwnerOperationAgentId(options.agent_id),
4338
- "ads.campaign_posts.list",
4339
- { campaign_id: normalizedCampaignId },
4340
- { lang: options.lang }
4341
- );
4342
- return Array.isArray(execution.result.posts) ? execution.result.posts.filter((item) => isRecord2(item)).map((item) => parseAdsCampaignPost(item)) : [];
4343
- }
4344
4128
  // `market.proposals.*` currently rides on the public owner-operation execute
4345
4129
  // route. Read helpers return typed proposal records; guarded mutations return
4346
4130
  // the approval envelope without treating it as an error.
@@ -7232,12 +7016,15 @@ function validate_tool_manual(manualInput) {
7232
7016
  pushError("INVALID_TOOL_NAME", "tool_name must be alphanumeric + underscore, 3-64 chars", "tool_name");
7233
7017
  }
7234
7018
  for (const [fieldName, minLength, maxLength] of [
7235
- ["job_to_be_done", 10, 500],
7019
+ ["job_to_be_done", 10, 240],
7236
7020
  ["summary_for_model", 10, 300]
7237
7021
  ]) {
7238
7022
  const value = manual[fieldName];
7239
- if (typeof value === "string" && (value.length < minLength || value.length > maxLength)) {
7240
- pushError("INVALID_TYPE", `${fieldName} must be ${minLength}-${maxLength} characters`, fieldName);
7023
+ if (typeof value === "string") {
7024
+ const length = Array.from(value).length;
7025
+ if (length < minLength || length > maxLength) {
7026
+ pushError("INVALID_TYPE", `${fieldName} must be ${minLength}-${maxLength} characters`, fieldName);
7027
+ }
7241
7028
  }
7242
7029
  }
7243
7030
  const triggerConditions = manual.trigger_conditions;
@@ -8913,7 +8700,7 @@ function normalizeSchema(value) {
8913
8700
  function buildToolManualSchema(permissionClass, fields) {
8914
8701
  const properties = {
8915
8702
  tool_name: { type: "string", minLength: 3, maxLength: 64 },
8916
- job_to_be_done: { type: "string", minLength: 10, maxLength: 500 },
8703
+ job_to_be_done: { type: "string", minLength: 10, maxLength: 240 },
8917
8704
  summary_for_model: { type: "string", minLength: 10, maxLength: 300 },
8918
8705
  trigger_conditions: {
8919
8706
  type: "array",