@siglume/api-sdk 0.10.1 → 0.10.2

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 CHANGED
@@ -65,8 +65,8 @@ siglume score . --offline
65
65
  siglume validate .
66
66
  siglume score . --remote
67
67
  siglume preflight . # checks blockers without creating a draft
68
- siglume register . # preflight + draft only
69
- siglume register . --confirm # confirm + publish
68
+ siglume register . # preflight + auto-register + confirm/publish
69
+ siglume register . --draft-only # review-only draft staging
70
70
  ```
71
71
 
72
72
  `siglume register` reads `tool_manual.json`, the local Git-ignored
@@ -76,8 +76,9 @@ credential files Git-ignored because they can contain review keys and client
76
76
  secrets. SDK / HTTP automation can pass
77
77
  `source_url`, `source_context`, and `input_form_spec` directly to
78
78
  `auto-register`. The CLI runs preflight by default, then calls the same
79
- `auto-register` route used by SDK / automation clients. Re-run the
80
- same `capability_key` to stage an upgrade. The server-side publish gate
79
+ `auto-register` route used by SDK / automation clients and confirms publication
80
+ unless `--draft-only` is set. Re-run the same `capability_key` to publish a
81
+ non-material upgrade when checks pass. The server-side publish gate
81
82
  includes runtime checks, contract checks, seller OAuth checks, pricing / payout
82
83
  rules, and a mandatory fail-closed LLM legal review for law compliance plus
83
84
  public-order / morals compliance.
@@ -1360,19 +1360,6 @@ function parseBundleMember(data) {
1360
1360
  link_id: stringOrNull(data.link_id)
1361
1361
  };
1362
1362
  }
1363
- function parseConnectedAccountProvider(data) {
1364
- return {
1365
- provider_key: String(data.provider_key ?? ""),
1366
- display_name: String(data.display_name ?? ""),
1367
- auth_type: String(data.auth_type ?? "oauth2"),
1368
- refresh_supported: Boolean(data.refresh_supported ?? false),
1369
- pkce_required: Boolean(data.pkce_required ?? false),
1370
- default_scopes: Array.isArray(data.default_scopes) ? data.default_scopes.filter((s) => typeof s === "string") : [],
1371
- available_scopes: Array.isArray(data.available_scopes) ? data.available_scopes.filter((s) => typeof s === "string") : [],
1372
- scope_separator: String(data.scope_separator ?? " "),
1373
- notes: stringOrNull(data.notes)
1374
- };
1375
- }
1376
1363
  function parseConnectedAccountLifecycle(data) {
1377
1364
  return {
1378
1365
  connected_account_id: String(data.connected_account_id ?? ""),
@@ -2498,9 +2485,13 @@ var init_client = __esm({
2498
2485
  async auto_register(manifest, tool_manual, options = {}) {
2499
2486
  const manifestPayload = coerceMapping(manifest, "manifest");
2500
2487
  const toolManualPayload = coerceMapping(tool_manual, "tool_manual");
2488
+ const toolManualForRequest = { ...toolManualPayload };
2489
+ const embeddedInputFormSpec = toolManualForRequest.input_form_spec;
2490
+ delete toolManualForRequest.input_form_spec;
2491
+ const inputFormSpec = options.input_form_spec ?? embeddedInputFormSpec;
2501
2492
  const payload = {
2502
2493
  manifest: { ...manifestPayload },
2503
- tool_manual: { ...toolManualPayload }
2494
+ tool_manual: toolManualForRequest
2504
2495
  };
2505
2496
  if (options.source_url) {
2506
2497
  payload.source_url = options.source_url;
@@ -2522,8 +2513,8 @@ var init_client = __esm({
2522
2513
  if (options.source_context) {
2523
2514
  payload.source_context = coerceMapping(options.source_context, "source_context");
2524
2515
  }
2525
- if (options.input_form_spec) {
2526
- payload.input_form_spec = coerceMapping(options.input_form_spec, "input_form_spec");
2516
+ if (inputFormSpec !== void 0 && inputFormSpec !== null) {
2517
+ payload.input_form_spec = coerceMapping(inputFormSpec, "input_form_spec");
2527
2518
  }
2528
2519
  for (const fieldName of [
2529
2520
  "capability_key",
@@ -2574,7 +2565,11 @@ var init_client = __esm({
2574
2565
  if (!listing_id) {
2575
2566
  throw new SiglumeClientError("Siglume auto-register response did not include listing_id.");
2576
2567
  }
2577
- this.pendingConfirmations.set(listing_id, { manifest: manifestPayload, tool_manual: toolManualPayload });
2568
+ this.pendingConfirmations.set(listing_id, {
2569
+ manifest: manifestPayload,
2570
+ tool_manual: toRecord(payload.tool_manual),
2571
+ input_form_spec: toRecord(payload.input_form_spec)
2572
+ });
2578
2573
  return {
2579
2574
  listing_id,
2580
2575
  status: String(data.status ?? "draft"),
@@ -2722,11 +2717,6 @@ var init_client = __esm({
2722
2717
  // ----- end bundles -------------------------------------------------------
2723
2718
  // ----- Connected accounts (v0.7 track 3) ---------------------------------
2724
2719
  // `resolve()` is intentionally NOT wrapped: runtime-only, never over the wire.
2725
- async list_connected_account_providers() {
2726
- const [data] = await this.request("GET", "/me/connected-accounts/providers");
2727
- const items = Array.isArray(data.items) ? data.items : [];
2728
- return items.filter((item) => isRecord(item)).map(parseConnectedAccountProvider);
2729
- }
2730
2720
  async start_connected_account_oauth(input) {
2731
2721
  const body = {
2732
2722
  listing_id: input.listing_id,
@@ -2763,8 +2753,17 @@ var init_client = __esm({
2763
2753
  const body = {
2764
2754
  provider_key: input.provider_key,
2765
2755
  client_id: input.client_id,
2766
- client_secret: input.client_secret
2756
+ client_secret: input.client_secret,
2757
+ authorize_url: input.authorize_url,
2758
+ token_url: input.token_url
2767
2759
  };
2760
+ if (input.revoke_url !== void 0) body.revoke_url = input.revoke_url;
2761
+ if (input.display_name !== void 0) body.display_name = input.display_name;
2762
+ if (input.scope_separator !== void 0) body.scope_separator = input.scope_separator;
2763
+ if (input.token_endpoint_auth !== void 0) body.token_endpoint_auth = input.token_endpoint_auth;
2764
+ if (input.pkce_required !== void 0) body.pkce_required = input.pkce_required;
2765
+ if (input.refresh_supported !== void 0) body.refresh_supported = input.refresh_supported;
2766
+ if (input.available_scopes !== void 0) body.available_scopes = input.available_scopes;
2768
2767
  if (input.required_scopes !== void 0) body.required_scopes = input.required_scopes;
2769
2768
  const [data] = await this.request("PUT", `/market/capabilities/${listing_id}/oauth-credentials`, {
2770
2769
  json_body: body
@@ -5677,16 +5676,24 @@ function coerceToolManual(manual) {
5677
5676
  }
5678
5677
  function checkSchemaForbiddenRecursive(schema, rootField, pushIssue, path = "") {
5679
5678
  for (const keyword of COMPOSITION_KEYWORDS) {
5680
- if (keyword in schema) {
5681
- const location = path ? `${rootField}.${path}.${keyword}` : `${rootField}.${keyword}`;
5682
- pushIssue(
5683
- issue(
5684
- "INPUT_SCHEMA",
5685
- `Composition keyword '${keyword}' is not allowed in beta${path ? ` at ${path}` : ""}`,
5686
- location
5687
- )
5688
- );
5679
+ if (!(keyword in schema)) {
5680
+ continue;
5681
+ }
5682
+ const branches = schema[keyword];
5683
+ const location = path ? `${rootField}.${path}.${keyword}` : `${rootField}.${keyword}`;
5684
+ if (!Array.isArray(branches) || branches.length === 0) {
5685
+ pushIssue(issue("INPUT_SCHEMA", `${keyword} must be a non-empty array`, location));
5686
+ continue;
5689
5687
  }
5688
+ branches.forEach((branch, index) => {
5689
+ const branchPath = path ? `${path}.${keyword}[${index}]` : `${keyword}[${index}]`;
5690
+ const branchLocation = `${rootField}.${branchPath}`;
5691
+ if (!isRecord(branch)) {
5692
+ pushIssue(issue("INPUT_SCHEMA", `${keyword}[${index}] must be an object`, branchLocation));
5693
+ return;
5694
+ }
5695
+ checkSchemaForbiddenRecursive(branch, rootField, pushIssue, branchPath);
5696
+ });
5690
5697
  }
5691
5698
  for (const forbidden of INPUT_SCHEMA_FORBIDDEN_KEYS) {
5692
5699
  if (forbidden in schema) {
@@ -7053,43 +7060,51 @@ async function loadProject(path = ".") {
7053
7060
  oauth_credentials
7054
7061
  };
7055
7062
  }
7056
- var OAUTH_PROVIDER_ALIASES = {
7057
- x: "twitter",
7058
- "x-twitter": "twitter",
7059
- twitter: "twitter",
7060
- slack: "slack",
7061
- google: "google",
7062
- gmail: "google",
7063
- "google-drive": "google",
7064
- "google-calendar": "google",
7065
- github: "github",
7066
- linear: "linear",
7067
- notion: "notion"
7068
- };
7063
+ function isPlatformManagedRequirement(value) {
7064
+ if (!isRecord(value)) return false;
7065
+ if (value.platform_managed === true) return true;
7066
+ const owner = String(
7067
+ value.managed_by ?? value.auth_managed_by ?? value.connection_owner ?? ""
7068
+ ).trim().toLowerCase().replaceAll("_", "-");
7069
+ return owner === "platform" || owner === "siglume" || owner === "siglume-platform";
7070
+ }
7069
7071
  function oauthProviderKeyFromRequirement(value) {
7070
- const raw = String(value ?? "").trim().toLowerCase().replaceAll("_", "-");
7071
- if (!raw) return null;
7072
- if (OAUTH_PROVIDER_ALIASES[raw]) {
7073
- return OAUTH_PROVIDER_ALIASES[raw];
7074
- }
7075
- for (const token of raw.replaceAll("/", "-").replaceAll(":", "-").split("-")) {
7076
- const next = token.trim();
7077
- if (OAUTH_PROVIDER_ALIASES[next]) {
7078
- return OAUTH_PROVIDER_ALIASES[next];
7072
+ if (isRecord(value)) {
7073
+ for (const key of ["provider_key", "provider", "account_type", "name"]) {
7074
+ const providerKey = oauthProviderKeyFromRequirement(value[key]);
7075
+ if (providerKey) return providerKey;
7079
7076
  }
7077
+ return null;
7080
7078
  }
7081
- return null;
7079
+ const raw = String(value ?? "").trim();
7080
+ return raw || null;
7082
7081
  }
7083
7082
  function requiredOauthProviders(requirements) {
7084
7083
  const providers = [];
7085
7084
  for (const item of requirements ?? []) {
7085
+ if (!isPlatformManagedRequirement(item)) continue;
7086
7086
  const providerKey = oauthProviderKeyFromRequirement(item);
7087
+ if (!providerKey) {
7088
+ throw new SiglumeProjectError(
7089
+ "required_connected_accounts platform-managed entries must include a provider_key"
7090
+ );
7091
+ }
7087
7092
  if (providerKey && !providers.includes(providerKey)) {
7088
7093
  providers.push(providerKey);
7089
7094
  }
7090
7095
  }
7091
7096
  return providers;
7092
7097
  }
7098
+ function connectedAccountRequirementLabel(value) {
7099
+ if (isRecord(value)) {
7100
+ for (const key of ["provider_key", "provider", "account_type", "name"]) {
7101
+ const label = String(value[key] ?? "").trim();
7102
+ if (label) return label;
7103
+ }
7104
+ return "";
7105
+ }
7106
+ return String(value ?? "").trim();
7107
+ }
7093
7108
  function oauthProviderRecordsMap(payload) {
7094
7109
  if (!payload) {
7095
7110
  return {};
@@ -7102,7 +7117,23 @@ function oauthProviderRecordsMap(payload) {
7102
7117
  }
7103
7118
  const providerKey = oauthProviderKeyFromRequirement(item.provider_key ?? item.provider);
7104
7119
  if (!providerKey) {
7105
- throw new SiglumeProjectError(`oauth_credentials[${index}].provider_key is unsupported.`);
7120
+ throw new SiglumeProjectError(`oauth_credentials[${index}].provider_key is required.`);
7121
+ }
7122
+ const authorizeUrl = String(item.authorize_url ?? item.authorization_url ?? item.auth_url ?? "").trim();
7123
+ const tokenUrl = String(item.token_url ?? "").trim();
7124
+ if (!authorizeUrl || !tokenUrl) {
7125
+ throw new SiglumeProjectError(
7126
+ `oauth_credentials[${index}] must include authorize_url and token_url.`
7127
+ );
7128
+ }
7129
+ for (const [urlKey, urlValue] of Object.entries({
7130
+ authorize_url: authorizeUrl,
7131
+ token_url: tokenUrl,
7132
+ revoke_url: String(item.revoke_url ?? "").trim()
7133
+ })) {
7134
+ if (urlValue && !urlValue.startsWith("https://")) {
7135
+ throw new SiglumeProjectError(`oauth_credentials[${index}].${urlKey} must be an https URL.`);
7136
+ }
7106
7137
  }
7107
7138
  const clientId = String(item.client_id ?? "").trim();
7108
7139
  const clientSecret = String(item.client_secret ?? "").trim();
@@ -7118,12 +7149,30 @@ function oauthProviderRecordsMap(payload) {
7118
7149
  } else {
7119
7150
  scopes = rawScopes.map((scope) => String(scope ?? "").trim()).filter(Boolean);
7120
7151
  }
7121
- resolved[providerKey] = {
7152
+ const record = {
7122
7153
  provider_key: providerKey,
7123
7154
  client_id: clientId,
7124
7155
  client_secret: clientSecret,
7125
7156
  required_scopes: scopes
7126
7157
  };
7158
+ for (const [key, value] of Object.entries({
7159
+ authorize_url: authorizeUrl,
7160
+ token_url: tokenUrl,
7161
+ revoke_url: String(item.revoke_url ?? "").trim(),
7162
+ display_name: String(item.display_name ?? "").trim(),
7163
+ scope_separator: String(item.scope_separator ?? "").trim(),
7164
+ token_endpoint_auth: String(item.token_endpoint_auth ?? "").trim()
7165
+ })) {
7166
+ if (value) record[key] = value;
7167
+ }
7168
+ for (const key of ["pkce_required", "refresh_supported"]) {
7169
+ if (typeof item[key] === "boolean") record[key] = item[key];
7170
+ }
7171
+ if (Array.isArray(item.available_scopes)) {
7172
+ const availableScopes = item.available_scopes.map((scope) => String(scope ?? "").trim()).filter(Boolean);
7173
+ if (availableScopes.length > 0) record.available_scopes = availableScopes;
7174
+ }
7175
+ resolved[providerKey] = record;
7127
7176
  }
7128
7177
  return resolved;
7129
7178
  }
@@ -7149,7 +7198,7 @@ function ensureRequiredOauthCredentials(project) {
7149
7198
  }
7150
7199
  const path = project.oauth_credentials_path ?? (0, import_node_path.join)(project.root_dir, "oauth_credentials.json");
7151
7200
  throw new SiglumeProjectError(
7152
- `${path} is required for OAuth-backed APIs. Missing provider seeds: ${missing.join(", ")}`
7201
+ `${path} is required for platform-managed OAuth APIs. Missing provider seeds: ${missing.join(", ")}`
7153
7202
  );
7154
7203
  }
7155
7204
  async function validateProject(path = ".", deps = {}) {
@@ -7317,7 +7366,7 @@ async function registrationPreflight(project, client) {
7317
7366
  errors.push(`remote Tool Manual quality is not publishable: ${remoteQuality.grade} (${remoteQuality.overall_score}/100)`);
7318
7367
  }
7319
7368
  if (missingOauthProviders.length > 0) {
7320
- errors.push(`oauth_credentials.json is required for OAuth-backed APIs: ${missingOauthProviders.join(", ")}`);
7369
+ errors.push(`oauth_credentials.json is required for platform-managed OAuth APIs: ${missingOauthProviders.join(", ")}`);
7321
7370
  }
7322
7371
  const preflight = {
7323
7372
  manifest_issues: manifestIssues,
@@ -7343,6 +7392,7 @@ async function runRegistration(path = ".", options = {}, deps = {}) {
7343
7392
  ensureManifestPublisherIdentity(project);
7344
7393
  ensureRuntimeValidationReady(project);
7345
7394
  ensureRequiredOauthCredentials(project);
7395
+ const canonicalOauthCredentials = canonicalOauthCredentialsPayload(project.oauth_credentials);
7346
7396
  const client = await createClient(deps);
7347
7397
  const preflight = await registrationPreflight(project, client);
7348
7398
  let developerPortalPreflight = null;
@@ -7358,7 +7408,7 @@ async function runRegistration(path = ".", options = {}, deps = {}) {
7358
7408
  }
7359
7409
  const receipt = await client.auto_register(project.manifest, project.tool_manual, {
7360
7410
  runtime_validation: project.runtime_validation,
7361
- oauth_credentials: canonicalOauthCredentialsPayload(project.oauth_credentials)
7411
+ oauth_credentials: canonicalOauthCredentials
7362
7412
  });
7363
7413
  const result = {
7364
7414
  receipt: toJsonable(receipt),
@@ -7369,7 +7419,8 @@ async function runRegistration(path = ".", options = {}, deps = {}) {
7369
7419
  if (developerPortalPreflight) {
7370
7420
  result.developer_portal_preflight = developerPortalPreflight;
7371
7421
  }
7372
- if (options.confirm) {
7422
+ const shouldConfirm = Boolean(options.confirm) || options.confirm === void 0 && !options.draft_only && !options.submit_review;
7423
+ if (shouldConfirm) {
7373
7424
  result.confirmation = toJsonable(await client.confirm_registration(receipt.listing_id));
7374
7425
  if (options.submit_review) {
7375
7426
  result.submit_review_skipped = true;
@@ -7900,8 +7951,8 @@ function operationReadmeTemplate(operation, manifest, warning) {
7900
7951
  "siglume score . --remote",
7901
7952
  "siglume preflight .",
7902
7953
  "siglume register .",
7903
- "# inspect the draft, then explicitly approve publish:",
7904
- "siglume register . --confirm",
7954
+ "# review-only staging path:",
7955
+ "siglume register . --draft-only",
7905
7956
  "```",
7906
7957
  ""
7907
7958
  ].join("\n");
@@ -7912,7 +7963,7 @@ function apiUsageDocsTemplate(manifest) {
7912
7963
  const jobToBeDone = String(manifest.job_to_be_done ?? "Describe what this API lets an agent do.");
7913
7964
  const permissionClass = String(manifest.permission_class ?? "read-only");
7914
7965
  const priceModel = String(manifest.price_model ?? "free");
7915
- const requiredAccounts = (manifest.required_connected_accounts ?? []).join(", ") || "none";
7966
+ const requiredAccounts = (manifest.required_connected_accounts ?? []).map((item) => connectedAccountRequirementLabel(item)).filter(Boolean).join(", ") || "none";
7916
7967
  const supportContact = String(manifest.support_contact ?? "replace-with-support-contact");
7917
7968
  return [
7918
7969
  `# ${name} API Usage Guide`,
@@ -8473,8 +8524,8 @@ function readmeTemplate(template) {
8473
8524
  "siglume score . --remote",
8474
8525
  "siglume preflight .",
8475
8526
  "siglume register .",
8476
- "# inspect the draft, then explicitly approve publish:",
8477
- "siglume register . --confirm",
8527
+ "# review-only staging path:",
8528
+ "siglume register . --draft-only",
8478
8529
  "```",
8479
8530
  ""
8480
8531
  ].join("\n");
@@ -8656,16 +8707,25 @@ async function runCli(argv, deps = {}) {
8656
8707
  if (report.runtime_validation_path) emit(stdout, `runtime_validation_path: ${String(report.runtime_validation_path)}`);
8657
8708
  if (report.oauth_credentials_path) emit(stdout, `oauth_credentials_path: ${String(report.oauth_credentials_path)}`);
8658
8709
  });
8659
- program.command("register").option("--confirm", "confirm the draft registration immediately and publish it when the self-serve checks pass", 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) => {
8660
- const report = await runRegistration(path, { confirm: options.confirm, submit_review: options.submitReview }, deps);
8710
+ 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("--json", "emit machine-readable JSON", false).argument("[path]", ".", "project path").action(async (path, options) => {
8711
+ const draftOnly = Boolean(options.draftOnly);
8712
+ if (draftOnly && options.confirm) {
8713
+ throw new SiglumeProjectError("--draft-only cannot be combined with --confirm.");
8714
+ }
8715
+ if (draftOnly && options.submitReview) {
8716
+ throw new SiglumeProjectError("--draft-only cannot be combined with --submit-review.");
8717
+ }
8718
+ const shouldConfirm = Boolean(options.confirm) || !draftOnly && !options.submitReview;
8719
+ const report = await runRegistration(path, { confirm: shouldConfirm, draft_only: draftOnly, submit_review: options.submitReview }, deps);
8661
8720
  if (options.json) {
8662
8721
  emit(stdout, renderJson(report));
8663
8722
  } else {
8664
8723
  const receipt = report.receipt;
8665
- if (report.confirmation) {
8666
- emit(stdout, "Listing published.");
8667
- } else if (report.review) {
8668
- emit(stdout, "Listing published via legacy submit-review alias.");
8724
+ const published = Boolean(report.confirmation || report.review);
8725
+ if (published && receipt.registration_mode === "upgrade") {
8726
+ emit(stdout, "Upgrade registered.");
8727
+ } else if (published) {
8728
+ emit(stdout, "Registration accepted.");
8669
8729
  } else if (receipt.registration_mode === "upgrade") {
8670
8730
  emit(stdout, "Upgrade staged.");
8671
8731
  } else if (receipt.registration_mode === "refresh") {
@@ -8682,10 +8742,12 @@ async function runCli(argv, deps = {}) {
8682
8742
  if (receipt.request_id) emit(stdout, `request_id: ${receipt.request_id}`);
8683
8743
  if (report.confirmation) {
8684
8744
  const confirmation = report.confirmation;
8745
+ emit(stdout, "Listing published.");
8685
8746
  if (confirmation.status) emit(stdout, `confirmation_status: ${confirmation.status}`);
8686
8747
  if (confirmation.release?.release_status) emit(stdout, `release_status: ${confirmation.release.release_status}`);
8687
8748
  } else if (report.review) {
8688
8749
  const review = report.review;
8750
+ emit(stdout, "Listing published via legacy submit-review alias.");
8689
8751
  if (review.status) emit(stdout, `publish_status: ${review.status}`);
8690
8752
  }
8691
8753
  const preflight = report.registration_preflight;