@siglume/api-sdk 2.0.5 → 3.1.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.
@@ -1528,12 +1528,6 @@ function parseListing(data) {
1528
1528
  seller_display_name: stringOrNull(data.seller_display_name),
1529
1529
  seller_homepage_url: stringOrNull(data.seller_homepage_url),
1530
1530
  seller_social_url: stringOrNull(data.seller_social_url),
1531
- publisher_type: stringOrNull(data.publisher_type),
1532
- publisher_company_id: stringOrNull(data.publisher_company_id),
1533
- company_id: stringOrNull(data.company_id),
1534
- company_name: stringOrNull(data.company_name),
1535
- company_publish_status: stringOrNull(data.company_publish_status),
1536
- company_terms_version: stringOrNull(data.company_terms_version),
1537
1531
  review_status: stringOrNull(data.review_status),
1538
1532
  review_note: stringOrNull(data.review_note),
1539
1533
  submission_blockers: Array.isArray(data.submission_blockers) ? data.submission_blockers.filter((item) => typeof item === "string") : [],
@@ -1543,29 +1537,6 @@ function parseListing(data) {
1543
1537
  raw: { ...data }
1544
1538
  };
1545
1539
  }
1546
- function parseCompanyPublisher(data) {
1547
- const wallets = Array.isArray(data.settlement_wallets) ? data.settlement_wallets.filter((item) => isRecord(item)) : [];
1548
- return {
1549
- company_id: String(data.company_id ?? data.id ?? ""),
1550
- name: String(data.name ?? ""),
1551
- status: String(data.status ?? ""),
1552
- description: stringOrNull(data.description),
1553
- is_founder: Boolean(data.is_founder ?? false),
1554
- membership_role: stringOrNull(data.membership_role),
1555
- membership_status: stringOrNull(data.membership_status),
1556
- can_publish: Boolean(data.can_publish ?? true),
1557
- can_approve: Boolean(data.can_approve ?? false),
1558
- approval_required: Boolean(data.approval_required ?? false),
1559
- paid_listing_allowed: Boolean(data.paid_listing_allowed ?? false),
1560
- disabled_reasons: Array.isArray(data.disabled_reasons) ? data.disabled_reasons.filter((item) => typeof item === "string") : [],
1561
- company_terms_version: stringOrNull(data.company_terms_version),
1562
- active_listing_count: Number(data.active_listing_count ?? 0),
1563
- pending_approval_count: Number(data.pending_approval_count ?? 0),
1564
- settlement_wallet_ready: Boolean(data.settlement_wallet_ready ?? false),
1565
- settlement_wallets: wallets.map((item) => ({ ...item })),
1566
- raw: { ...data }
1567
- };
1568
- }
1569
1540
  function parseCapabilitySaveState(data) {
1570
1541
  return {
1571
1542
  capability_key: String(data.capability_key ?? ""),
@@ -2480,9 +2451,6 @@ var init_client = __esm({
2480
2451
  "support_contact",
2481
2452
  "seller_homepage_url",
2482
2453
  "seller_social_url",
2483
- "publisher_type",
2484
- "company_id",
2485
- "publisher_company_id",
2486
2454
  "store_vertical",
2487
2455
  "jurisdiction",
2488
2456
  "price_model",
@@ -2556,25 +2524,6 @@ var init_client = __esm({
2556
2524
  );
2557
2525
  }
2558
2526
  }
2559
- const explicitPublisherType = payload.publisher_type !== void 0 && payload.publisher_type !== null;
2560
- const companyId = String(payload.company_id ?? "").trim() || String(payload.publisher_company_id ?? "").trim();
2561
- const publisherType = String(payload.publisher_type ?? "user").trim().toLowerCase();
2562
- if (publisherType !== "user" && publisherType !== "company") {
2563
- throw new SiglumeClientError("AppManifest.publisher_type must be 'user' or 'company'.");
2564
- }
2565
- if (publisherType === "company" && !companyId) {
2566
- throw new SiglumeClientError("AppManifest.company_id is required when publisher_type='company'.");
2567
- }
2568
- if (publisherType === "user" && companyId) {
2569
- throw new SiglumeClientError("AppManifest.company_id cannot be combined with publisher_type='user'.");
2570
- }
2571
- if (explicitPublisherType || companyId) {
2572
- payload.publisher_type = publisherType;
2573
- }
2574
- if (companyId) {
2575
- payload.company_id = companyId;
2576
- payload.publisher_company_id = companyId;
2577
- }
2578
2527
  validateManifestPersistenceContract(payload);
2579
2528
  if (payload.manifest && typeof payload.manifest === "object") {
2580
2529
  delete payload.manifest.version;
@@ -2617,8 +2566,12 @@ var init_client = __esm({
2617
2566
  };
2618
2567
  }
2619
2568
  async confirm_registration(listing_id, options = {}) {
2620
- const { version_bump: versionBump } = options;
2569
+ const { version_bump: versionBump, visibility = "public" } = options;
2621
2570
  const payload = { approved: true };
2571
+ if (visibility !== "public" && visibility !== "private") {
2572
+ throw new Error(`visibility must be one of ["public","private"], got ${JSON.stringify(visibility)}`);
2573
+ }
2574
+ payload.visibility = visibility;
2622
2575
  if (versionBump !== void 0) {
2623
2576
  const allowed = ["patch", "minor", "major"];
2624
2577
  if (!allowed.includes(versionBump)) {
@@ -2636,6 +2589,7 @@ var init_client = __esm({
2636
2589
  return {
2637
2590
  listing_id: String(data.listing_id ?? listing_id),
2638
2591
  status: String(data.status ?? ""),
2592
+ visibility: stringOrNull(data.visibility),
2639
2593
  message: stringOrNull(data.message),
2640
2594
  checklist,
2641
2595
  release: toRecord(data.release),
@@ -2682,25 +2636,6 @@ var init_client = __esm({
2682
2636
  const [data] = await this.request("GET", `/market/capabilities/${listing_id}`);
2683
2637
  return parseListing(data);
2684
2638
  }
2685
- async list_company_publishers() {
2686
- const [data] = await this.request("GET", "/market/company-publishers");
2687
- return Array.isArray(data.items) ? data.items.filter((item) => isRecord(item)).map(parseCompanyPublisher) : [];
2688
- }
2689
- async request_company_publish_approval(listing_id, note) {
2690
- const [data] = await this.request("POST", `/market/capabilities/${listing_id}/company-publish-approval`, {
2691
- json_body: note ? { note } : {}
2692
- });
2693
- return parseListing(data);
2694
- }
2695
- async decide_company_publish_approval(listing_id, options) {
2696
- const [data] = await this.request("POST", `/market/capabilities/${listing_id}/company-publish-approval/decision`, {
2697
- json_body: {
2698
- decision: options.decision,
2699
- ...options.reason ? { reason: options.reason } : {}
2700
- }
2701
- });
2702
- return parseListing(data);
2703
- }
2704
2639
  async get_capability_state(capability_key, save_key = "default") {
2705
2640
  const [data] = await this.request("GET", `/market/capability-state/${capability_key}/${save_key}`);
2706
2641
  return parseCapabilitySaveState(data);
@@ -6964,12 +6899,7 @@ function ensureManifestPublisherIdentity(project) {
6964
6899
  const sellerHomepageUrl = String(manifestPayload.seller_homepage_url ?? "").trim();
6965
6900
  const sellerSocialUrl = String(manifestPayload.seller_social_url ?? "").trim();
6966
6901
  const jurisdiction = String(manifestPayload.jurisdiction ?? "").trim();
6967
- const companyId = String(manifestPayload.company_id ?? "").trim() || String(manifestPayload.publisher_company_id ?? "").trim();
6968
- const publisherType = String(manifestPayload.publisher_type ?? "user").trim().toLowerCase();
6969
6902
  const issues = [];
6970
- if (companyId && publisherType !== "company") {
6971
- issues.push('manifest.company_id requires manifest.publisher_type to be "company"');
6972
- }
6973
6903
  if (!docsUrl) {
6974
6904
  issues.push("manifest.docs_url is required");
6975
6905
  } else if (looksLikePlaceholder(docsUrl)) {
@@ -7129,108 +7059,23 @@ ${errors.map((error) => `- ${error}`).join("\n")}`
7129
7059
  }
7130
7060
  return preflight;
7131
7061
  }
7132
- function companyNameSlug(value) {
7133
- return value.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
7134
- }
7135
7062
  async function runRegistration(path = ".", options = {}, deps = {}) {
7136
7063
  const project = await loadProject(path);
7137
- let requestedCompanyId = String(options.company_id ?? "").trim();
7138
- const requestedCompanySlug = String(options.company_slug ?? "").trim();
7139
- let companyPublisherCandidates = null;
7140
- if (requestedCompanySlug) {
7141
- if (requestedCompanyId) {
7142
- throw new SiglumeProjectError("--company and --company-slug cannot be combined.");
7143
- }
7144
- const slug = companyNameSlug(requestedCompanySlug);
7145
- if (!slug && requestedCompanySlug !== requestedCompanyId) {
7146
- throw new SiglumeProjectError(`Company slug ${requestedCompanySlug} is not slug-compatible; use --company <company_id> instead.`);
7147
- }
7148
- }
7149
- if (requestedCompanyId) {
7150
- project.manifest = {
7151
- ...project.manifest,
7152
- publisher_type: "company",
7153
- company_id: requestedCompanyId,
7154
- publisher_company_id: requestedCompanyId
7155
- };
7156
- }
7157
7064
  ensureExplicitToolManual(project);
7158
7065
  ensureManifestPublisherIdentity(project);
7159
7066
  ensureRuntimeValidationReady(project);
7160
7067
  const client = await createClient(deps);
7161
- if (requestedCompanySlug) {
7162
- const slug = companyNameSlug(requestedCompanySlug);
7163
- companyPublisherCandidates = await client.list_company_publishers();
7164
- const matches = companyPublisherCandidates.filter(
7165
- (item) => companyNameSlug(item.name || item.company_id) === slug || item.company_id === requestedCompanySlug
7166
- );
7167
- if (matches.length === 0) {
7168
- throw new SiglumeProjectError(`Company slug ${requestedCompanySlug} is not available to this API key.`);
7169
- }
7170
- if (matches.length > 1) {
7171
- throw new SiglumeProjectError(`Company slug ${requestedCompanySlug} is ambiguous; use --company <company_id> instead.`);
7172
- }
7173
- const match = matches[0];
7174
- if (!match) {
7175
- throw new SiglumeProjectError(`Company slug ${requestedCompanySlug} is not available to this API key.`);
7176
- }
7177
- if (match.can_publish === false) {
7178
- const disabledReasons = match.disabled_reasons ?? [];
7179
- const reasons = disabledReasons.length > 0 ? disabledReasons.join(", ") : "company publisher is disabled";
7180
- throw new SiglumeProjectError(`Company ${match.company_id} cannot publish: ${reasons}.`);
7181
- }
7182
- requestedCompanyId = match.company_id;
7183
- project.manifest = {
7184
- ...project.manifest,
7185
- publisher_type: "company",
7186
- company_id: requestedCompanyId,
7187
- publisher_company_id: requestedCompanyId
7188
- };
7189
- }
7190
7068
  const preflight = await registrationPreflight(project, client);
7191
- let companyPublisherPreflight = null;
7192
- const companyId = String(project.manifest.company_id ?? "").trim() || String(project.manifest.publisher_company_id ?? "").trim();
7193
- const publisherType = String(project.manifest.publisher_type ?? "user").toLowerCase();
7194
- if (publisherType === "company") {
7195
- if (!companyId) {
7196
- throw new SiglumeProjectError("Company registration requires --company <company_id> or manifest.company_id.");
7197
- }
7198
- const companies = companyPublisherCandidates ?? await client.list_company_publishers();
7199
- companyPublisherCandidates = companies;
7200
- const company = companies.find((item) => item.company_id === companyId);
7201
- if (!company) {
7202
- throw new SiglumeProjectError(`Company ${companyId} is not available to this API key.`);
7203
- }
7204
- if (company.can_publish === false) {
7205
- const disabledReasons = company.disabled_reasons ?? [];
7206
- const reasons = disabledReasons.length > 0 ? disabledReasons.join(", ") : "company publisher is disabled";
7207
- throw new SiglumeProjectError(`Company ${companyId} cannot publish: ${reasons}.`);
7208
- }
7209
- companyPublisherPreflight = company;
7210
- }
7211
7069
  let developerPortalPreflight = null;
7212
7070
  if (String(project.manifest.price_model ?? "free").toLowerCase() !== "free") {
7213
- if (publisherType === "company") {
7214
- const company = companyPublisherPreflight;
7215
- if (!company) {
7216
- throw new SiglumeProjectError(`Company ${companyId} is not available to this API key.`);
7217
- }
7218
- if (company.settlement_wallet_ready !== true) {
7219
- throw new SiglumeProjectError(
7220
- `Paid company registration requires a verified company settlement wallet for ${company.name}. Open the company settings and complete settlement readiness before registering.`
7221
- );
7222
- }
7223
- developerPortalPreflight = { company_publisher: toJsonable(company) };
7224
- } else {
7225
- const portal = await client.get_developer_portal();
7226
- const verifiedDestination = portal.payout_readiness?.verified_destination;
7227
- if (verifiedDestination !== true) {
7228
- throw new SiglumeProjectError(
7229
- "Paid API registration requires a verified Polygon payout destination. Open https://siglume.com/owner/credits/payout and confirm the embedded-wallet payout token, or call GET /v1/market/developer/portal until payout_readiness.verified_destination is true."
7230
- );
7231
- }
7232
- developerPortalPreflight = toJsonable(portal);
7071
+ const portal = await client.get_developer_portal();
7072
+ const verifiedDestination = portal.payout_readiness?.verified_destination;
7073
+ if (verifiedDestination !== true) {
7074
+ throw new SiglumeProjectError(
7075
+ "Paid API registration requires a verified Polygon payout destination. Open https://siglume.com/owner/credits/payout and confirm the embedded-wallet payout token, or call GET /v1/market/developer/portal until payout_readiness.verified_destination is true."
7076
+ );
7233
7077
  }
7078
+ developerPortalPreflight = toJsonable(portal);
7234
7079
  }
7235
7080
  const receipt = await client.auto_register(project.manifest, project.tool_manual, {
7236
7081
  runtime_validation: project.runtime_validation
@@ -7245,7 +7090,9 @@ async function runRegistration(path = ".", options = {}, deps = {}) {
7245
7090
  }
7246
7091
  const shouldConfirm = Boolean(options.confirm) || options.confirm === void 0 && !options.draft_only && !options.submit_review;
7247
7092
  if (shouldConfirm) {
7248
- result.confirmation = toJsonable(await client.confirm_registration(receipt.listing_id));
7093
+ result.confirmation = toJsonable(await client.confirm_registration(receipt.listing_id, {
7094
+ visibility: options.confirm_visibility ?? "public"
7095
+ }));
7249
7096
  if (options.submit_review) {
7250
7097
  result.submit_review_skipped = true;
7251
7098
  }
@@ -7299,14 +7146,6 @@ async function getUsageReport(options, deps = {}) {
7299
7146
  count: items.length
7300
7147
  };
7301
7148
  }
7302
- async function listCompanyPublishersReport(deps = {}) {
7303
- const client = await createClient(deps);
7304
- const companies = await client.list_company_publishers();
7305
- return {
7306
- companies: companies.map((item) => toJsonable(item)),
7307
- count: companies.length
7308
- };
7309
- }
7310
7149
  async function diffJsonFiles(oldPath, newPath) {
7311
7150
  const oldPayload = await loadJsonDocument(oldPath);
7312
7151
  const newPayload = await loadJsonDocument(newPath);
@@ -8375,24 +8214,6 @@ function renderOperationTable(operations) {
8375
8214
  ...rows.map((row) => row.map((cell, index) => cell.padEnd(widths[index] ?? cell.length)).join(" "))
8376
8215
  ];
8377
8216
  }
8378
- function renderCompanyTable(companies) {
8379
- const rows = companies.map((item) => [
8380
- String(item.company_id ?? item.id ?? ""),
8381
- String(item.name ?? ""),
8382
- String(item.membership_role ?? (item.is_founder ? "founder" : "")),
8383
- String(item.settlement_wallet_ready === true ? "ready" : "not_ready"),
8384
- String(item.pending_approval_count ?? 0)
8385
- ]);
8386
- const headers = ["company_id", "name", "role", "settlement", "pending"];
8387
- const widths = headers.map(
8388
- (header, index) => Math.max(header.length, ...rows.map((row) => row[index]?.length ?? 0))
8389
- );
8390
- return [
8391
- headers.map((header, index) => header.padEnd(widths[index] ?? header.length)).join(" "),
8392
- widths.map((width) => "-".repeat(width)).join(" "),
8393
- ...rows.map((row) => row.map((cell, index) => cell.padEnd(widths[index] ?? cell.length)).join(" "))
8394
- ];
8395
- }
8396
8217
  async function runCli(argv, deps = {}) {
8397
8218
  const stdout = deps.stdout;
8398
8219
  const stderr = deps.stderr ?? console.error;
@@ -8548,42 +8369,44 @@ async function runCli(argv, deps = {}) {
8548
8369
  }
8549
8370
  if (report.runtime_validation_path) emit(stdout, `runtime_validation_path: ${String(report.runtime_validation_path)}`);
8550
8371
  });
8551
- program.command("companies").description("List Siglume companies available for company-name publishing.").option("--json", "emit machine-readable JSON", false).action(async (options) => {
8552
- const report = await listCompanyPublishersReport(deps);
8553
- if (options.json) {
8554
- emit(stdout, renderJson(report));
8555
- return;
8556
- }
8557
- const companies = Array.isArray(report.companies) ? report.companies.filter((item) => Boolean(item && typeof item === "object")) : [];
8558
- if (companies.length === 0) {
8559
- emit(stdout, "No company publishers available for this API key.");
8560
- return;
8561
- }
8562
- emit(stdout, "Company publishers");
8563
- renderCompanyTable(companies).forEach((line) => emit(stdout, line));
8564
- });
8565
- program.command("register").option("--confirm", "explicitly confirm the registration; this is the default unless --draft-only is set", false).option("--draft-only", "create or refresh the draft without confirming publication", false).option("--submit-review", "legacy alias: publish immediately if your environment still routes through submit-review", false).option("--company <companyId>", "publish under a Siglume company name; revenue is split equally among active members", "").option("--company-slug <slug>", "publish under a Siglume company by matching the slugified company name", "").option("--json", "emit machine-readable JSON", false).argument("[path]", ".", "project path").action(async (path, options) => {
8372
+ program.command("register").option("--confirm", "explicitly confirm the registration; this is the default unless --draft-only is set", false).option("--private-confirm", "confirm the registration for private production testing without publishing it", false).option("--draft-only", "create or refresh the draft without confirming publication", false).option("--submit-review", "legacy alias: publish immediately if your environment still routes through submit-review", false).option("--json", "emit machine-readable JSON", false).argument("[path]", ".", "project path").action(async (path, options) => {
8566
8373
  const draftOnly = Boolean(options.draftOnly);
8374
+ const privateConfirm = Boolean(options.privateConfirm);
8567
8375
  if (draftOnly && options.confirm) {
8568
8376
  throw new SiglumeProjectError("--draft-only cannot be combined with --confirm.");
8569
8377
  }
8378
+ if (draftOnly && privateConfirm) {
8379
+ throw new SiglumeProjectError("--draft-only cannot be combined with --private-confirm.");
8380
+ }
8381
+ if (options.confirm && privateConfirm) {
8382
+ throw new SiglumeProjectError("--confirm cannot be combined with --private-confirm.");
8383
+ }
8570
8384
  if (draftOnly && options.submitReview) {
8571
8385
  throw new SiglumeProjectError("--draft-only cannot be combined with --submit-review.");
8572
8386
  }
8573
- const shouldConfirm = Boolean(options.confirm) || !draftOnly && !options.submitReview;
8387
+ if (privateConfirm && options.submitReview) {
8388
+ throw new SiglumeProjectError("--private-confirm cannot be combined with --submit-review.");
8389
+ }
8390
+ const shouldConfirm = Boolean(options.confirm) || privateConfirm || !draftOnly && !options.submitReview;
8574
8391
  const report = await runRegistration(path, {
8575
8392
  confirm: shouldConfirm,
8393
+ confirm_visibility: privateConfirm ? "private" : "public",
8576
8394
  draft_only: draftOnly,
8577
- submit_review: options.submitReview,
8578
- company_id: options.company,
8579
- company_slug: options.companySlug
8395
+ submit_review: options.submitReview
8580
8396
  }, deps);
8397
+ if (privateConfirm && report.confirmation && !report.confirmation.visibility) {
8398
+ report.confirmation.visibility = "private";
8399
+ }
8581
8400
  if (options.json) {
8582
8401
  emit(stdout, renderJson(report));
8583
8402
  } else {
8584
8403
  const receipt = report.receipt;
8585
- const published = Boolean(report.confirmation || report.review);
8586
- if (published && receipt.registration_mode === "upgrade") {
8404
+ const confirmationSummary = report.confirmation;
8405
+ const privatelyConfirmed = confirmationSummary?.visibility === "private";
8406
+ const published = !privatelyConfirmed && Boolean(report.confirmation || report.review);
8407
+ if (privatelyConfirmed) {
8408
+ emit(stdout, "Registration privately confirmed.");
8409
+ } else if (published && receipt.registration_mode === "upgrade") {
8587
8410
  emit(stdout, "Upgrade registered.");
8588
8411
  } else if (published) {
8589
8412
  emit(stdout, "Registration accepted.");
@@ -8602,8 +8425,9 @@ async function runCli(argv, deps = {}) {
8602
8425
  if (receipt.request_id) emit(stdout, `request_id: ${receipt.request_id}`);
8603
8426
  if (report.confirmation) {
8604
8427
  const confirmation = report.confirmation;
8605
- emit(stdout, "Listing published.");
8428
+ emit(stdout, confirmation.visibility === "private" ? "Listing confirmed privately for production testing." : "Listing published.");
8606
8429
  if (confirmation.status) emit(stdout, `confirmation_status: ${confirmation.status}`);
8430
+ if (confirmation.visibility) emit(stdout, `confirmation_visibility: ${confirmation.visibility}`);
8607
8431
  if (confirmation.release?.release_status) emit(stdout, `release_status: ${confirmation.release.release_status}`);
8608
8432
  } else if (report.review) {
8609
8433
  const review = report.review;