@siglume/api-sdk 0.10.1 → 0.10.3

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.
@@ -1361,19 +1361,6 @@ function parseBundleMember(data) {
1361
1361
  link_id: stringOrNull(data.link_id)
1362
1362
  };
1363
1363
  }
1364
- function parseConnectedAccountProvider(data) {
1365
- return {
1366
- provider_key: String(data.provider_key ?? ""),
1367
- display_name: String(data.display_name ?? ""),
1368
- auth_type: String(data.auth_type ?? "oauth2"),
1369
- refresh_supported: Boolean(data.refresh_supported ?? false),
1370
- pkce_required: Boolean(data.pkce_required ?? false),
1371
- default_scopes: Array.isArray(data.default_scopes) ? data.default_scopes.filter((s) => typeof s === "string") : [],
1372
- available_scopes: Array.isArray(data.available_scopes) ? data.available_scopes.filter((s) => typeof s === "string") : [],
1373
- scope_separator: String(data.scope_separator ?? " "),
1374
- notes: stringOrNull(data.notes)
1375
- };
1376
- }
1377
1364
  function parseConnectedAccountLifecycle(data) {
1378
1365
  return {
1379
1366
  connected_account_id: String(data.connected_account_id ?? ""),
@@ -2499,9 +2486,13 @@ var init_client = __esm({
2499
2486
  async auto_register(manifest, tool_manual, options = {}) {
2500
2487
  const manifestPayload = coerceMapping(manifest, "manifest");
2501
2488
  const toolManualPayload = coerceMapping(tool_manual, "tool_manual");
2489
+ const toolManualForRequest = { ...toolManualPayload };
2490
+ const embeddedInputFormSpec = toolManualForRequest.input_form_spec;
2491
+ delete toolManualForRequest.input_form_spec;
2492
+ const inputFormSpec = options.input_form_spec ?? embeddedInputFormSpec;
2502
2493
  const payload = {
2503
2494
  manifest: { ...manifestPayload },
2504
- tool_manual: { ...toolManualPayload }
2495
+ tool_manual: toolManualForRequest
2505
2496
  };
2506
2497
  if (options.source_url) {
2507
2498
  payload.source_url = options.source_url;
@@ -2523,8 +2514,8 @@ var init_client = __esm({
2523
2514
  if (options.source_context) {
2524
2515
  payload.source_context = coerceMapping(options.source_context, "source_context");
2525
2516
  }
2526
- if (options.input_form_spec) {
2527
- payload.input_form_spec = coerceMapping(options.input_form_spec, "input_form_spec");
2517
+ if (inputFormSpec !== void 0 && inputFormSpec !== null) {
2518
+ payload.input_form_spec = coerceMapping(inputFormSpec, "input_form_spec");
2528
2519
  }
2529
2520
  for (const fieldName of [
2530
2521
  "capability_key",
@@ -2575,7 +2566,11 @@ var init_client = __esm({
2575
2566
  if (!listing_id) {
2576
2567
  throw new SiglumeClientError("Siglume auto-register response did not include listing_id.");
2577
2568
  }
2578
- this.pendingConfirmations.set(listing_id, { manifest: manifestPayload, tool_manual: toolManualPayload });
2569
+ this.pendingConfirmations.set(listing_id, {
2570
+ manifest: manifestPayload,
2571
+ tool_manual: toRecord(payload.tool_manual),
2572
+ input_form_spec: toRecord(payload.input_form_spec)
2573
+ });
2579
2574
  return {
2580
2575
  listing_id,
2581
2576
  status: String(data.status ?? "draft"),
@@ -2723,11 +2718,6 @@ var init_client = __esm({
2723
2718
  // ----- end bundles -------------------------------------------------------
2724
2719
  // ----- Connected accounts (v0.7 track 3) ---------------------------------
2725
2720
  // `resolve()` is intentionally NOT wrapped: runtime-only, never over the wire.
2726
- async list_connected_account_providers() {
2727
- const [data] = await this.request("GET", "/me/connected-accounts/providers");
2728
- const items = Array.isArray(data.items) ? data.items : [];
2729
- return items.filter((item) => isRecord(item)).map(parseConnectedAccountProvider);
2730
- }
2731
2721
  async start_connected_account_oauth(input) {
2732
2722
  const body = {
2733
2723
  listing_id: input.listing_id,
@@ -2764,8 +2754,17 @@ var init_client = __esm({
2764
2754
  const body = {
2765
2755
  provider_key: input.provider_key,
2766
2756
  client_id: input.client_id,
2767
- client_secret: input.client_secret
2757
+ client_secret: input.client_secret,
2758
+ authorize_url: input.authorize_url,
2759
+ token_url: input.token_url
2768
2760
  };
2761
+ if (input.revoke_url !== void 0) body.revoke_url = input.revoke_url;
2762
+ if (input.display_name !== void 0) body.display_name = input.display_name;
2763
+ if (input.scope_separator !== void 0) body.scope_separator = input.scope_separator;
2764
+ if (input.token_endpoint_auth !== void 0) body.token_endpoint_auth = input.token_endpoint_auth;
2765
+ if (input.pkce_required !== void 0) body.pkce_required = input.pkce_required;
2766
+ if (input.refresh_supported !== void 0) body.refresh_supported = input.refresh_supported;
2767
+ if (input.available_scopes !== void 0) body.available_scopes = input.available_scopes;
2769
2768
  if (input.required_scopes !== void 0) body.required_scopes = input.required_scopes;
2770
2769
  const [data] = await this.request("PUT", `/market/capabilities/${listing_id}/oauth-credentials`, {
2771
2770
  json_body: body
@@ -5683,16 +5682,24 @@ function coerceToolManual(manual) {
5683
5682
  }
5684
5683
  function checkSchemaForbiddenRecursive(schema, rootField, pushIssue, path = "") {
5685
5684
  for (const keyword of COMPOSITION_KEYWORDS) {
5686
- if (keyword in schema) {
5687
- const location = path ? `${rootField}.${path}.${keyword}` : `${rootField}.${keyword}`;
5688
- pushIssue(
5689
- issue(
5690
- "INPUT_SCHEMA",
5691
- `Composition keyword '${keyword}' is not allowed in beta${path ? ` at ${path}` : ""}`,
5692
- location
5693
- )
5694
- );
5685
+ if (!(keyword in schema)) {
5686
+ continue;
5687
+ }
5688
+ const branches = schema[keyword];
5689
+ const location = path ? `${rootField}.${path}.${keyword}` : `${rootField}.${keyword}`;
5690
+ if (!Array.isArray(branches) || branches.length === 0) {
5691
+ pushIssue(issue("INPUT_SCHEMA", `${keyword} must be a non-empty array`, location));
5692
+ continue;
5695
5693
  }
5694
+ branches.forEach((branch, index) => {
5695
+ const branchPath = path ? `${path}.${keyword}[${index}]` : `${keyword}[${index}]`;
5696
+ const branchLocation = `${rootField}.${branchPath}`;
5697
+ if (!isRecord(branch)) {
5698
+ pushIssue(issue("INPUT_SCHEMA", `${keyword}[${index}] must be an object`, branchLocation));
5699
+ return;
5700
+ }
5701
+ checkSchemaForbiddenRecursive(branch, rootField, pushIssue, branchPath);
5702
+ });
5696
5703
  }
5697
5704
  for (const forbidden of INPUT_SCHEMA_FORBIDDEN_KEYS) {
5698
5705
  if (forbidden in schema) {
@@ -7059,43 +7066,51 @@ async function loadProject(path = ".") {
7059
7066
  oauth_credentials
7060
7067
  };
7061
7068
  }
7062
- var OAUTH_PROVIDER_ALIASES = {
7063
- x: "twitter",
7064
- "x-twitter": "twitter",
7065
- twitter: "twitter",
7066
- slack: "slack",
7067
- google: "google",
7068
- gmail: "google",
7069
- "google-drive": "google",
7070
- "google-calendar": "google",
7071
- github: "github",
7072
- linear: "linear",
7073
- notion: "notion"
7074
- };
7069
+ function isPlatformManagedRequirement(value) {
7070
+ if (!isRecord(value)) return false;
7071
+ if (value.platform_managed === true) return true;
7072
+ const owner = String(
7073
+ value.managed_by ?? value.auth_managed_by ?? value.connection_owner ?? ""
7074
+ ).trim().toLowerCase().replaceAll("_", "-");
7075
+ return owner === "platform" || owner === "siglume" || owner === "siglume-platform";
7076
+ }
7075
7077
  function oauthProviderKeyFromRequirement(value) {
7076
- const raw = String(value ?? "").trim().toLowerCase().replaceAll("_", "-");
7077
- if (!raw) return null;
7078
- if (OAUTH_PROVIDER_ALIASES[raw]) {
7079
- return OAUTH_PROVIDER_ALIASES[raw];
7080
- }
7081
- for (const token of raw.replaceAll("/", "-").replaceAll(":", "-").split("-")) {
7082
- const next = token.trim();
7083
- if (OAUTH_PROVIDER_ALIASES[next]) {
7084
- return OAUTH_PROVIDER_ALIASES[next];
7078
+ if (isRecord(value)) {
7079
+ for (const key of ["provider_key", "provider", "account_type", "name"]) {
7080
+ const providerKey = oauthProviderKeyFromRequirement(value[key]);
7081
+ if (providerKey) return providerKey;
7085
7082
  }
7083
+ return null;
7086
7084
  }
7087
- return null;
7085
+ const raw = String(value ?? "").trim();
7086
+ return raw || null;
7088
7087
  }
7089
7088
  function requiredOauthProviders(requirements) {
7090
7089
  const providers = [];
7091
7090
  for (const item of requirements ?? []) {
7091
+ if (!isPlatformManagedRequirement(item)) continue;
7092
7092
  const providerKey = oauthProviderKeyFromRequirement(item);
7093
+ if (!providerKey) {
7094
+ throw new SiglumeProjectError(
7095
+ "required_connected_accounts platform-managed entries must include a provider_key"
7096
+ );
7097
+ }
7093
7098
  if (providerKey && !providers.includes(providerKey)) {
7094
7099
  providers.push(providerKey);
7095
7100
  }
7096
7101
  }
7097
7102
  return providers;
7098
7103
  }
7104
+ function connectedAccountRequirementLabel(value) {
7105
+ if (isRecord(value)) {
7106
+ for (const key of ["provider_key", "provider", "account_type", "name"]) {
7107
+ const label = String(value[key] ?? "").trim();
7108
+ if (label) return label;
7109
+ }
7110
+ return "";
7111
+ }
7112
+ return String(value ?? "").trim();
7113
+ }
7099
7114
  function oauthProviderRecordsMap(payload) {
7100
7115
  if (!payload) {
7101
7116
  return {};
@@ -7108,7 +7123,23 @@ function oauthProviderRecordsMap(payload) {
7108
7123
  }
7109
7124
  const providerKey = oauthProviderKeyFromRequirement(item.provider_key ?? item.provider);
7110
7125
  if (!providerKey) {
7111
- throw new SiglumeProjectError(`oauth_credentials[${index}].provider_key is unsupported.`);
7126
+ throw new SiglumeProjectError(`oauth_credentials[${index}].provider_key is required.`);
7127
+ }
7128
+ const authorizeUrl = String(item.authorize_url ?? item.authorization_url ?? item.auth_url ?? "").trim();
7129
+ const tokenUrl = String(item.token_url ?? "").trim();
7130
+ if (!authorizeUrl || !tokenUrl) {
7131
+ throw new SiglumeProjectError(
7132
+ `oauth_credentials[${index}] must include authorize_url and token_url.`
7133
+ );
7134
+ }
7135
+ for (const [urlKey, urlValue] of Object.entries({
7136
+ authorize_url: authorizeUrl,
7137
+ token_url: tokenUrl,
7138
+ revoke_url: String(item.revoke_url ?? "").trim()
7139
+ })) {
7140
+ if (urlValue && !urlValue.startsWith("https://")) {
7141
+ throw new SiglumeProjectError(`oauth_credentials[${index}].${urlKey} must be an https URL.`);
7142
+ }
7112
7143
  }
7113
7144
  const clientId = String(item.client_id ?? "").trim();
7114
7145
  const clientSecret = String(item.client_secret ?? "").trim();
@@ -7124,12 +7155,30 @@ function oauthProviderRecordsMap(payload) {
7124
7155
  } else {
7125
7156
  scopes = rawScopes.map((scope) => String(scope ?? "").trim()).filter(Boolean);
7126
7157
  }
7127
- resolved[providerKey] = {
7158
+ const record = {
7128
7159
  provider_key: providerKey,
7129
7160
  client_id: clientId,
7130
7161
  client_secret: clientSecret,
7131
7162
  required_scopes: scopes
7132
7163
  };
7164
+ for (const [key, value] of Object.entries({
7165
+ authorize_url: authorizeUrl,
7166
+ token_url: tokenUrl,
7167
+ revoke_url: String(item.revoke_url ?? "").trim(),
7168
+ display_name: String(item.display_name ?? "").trim(),
7169
+ scope_separator: String(item.scope_separator ?? "").trim(),
7170
+ token_endpoint_auth: String(item.token_endpoint_auth ?? "").trim()
7171
+ })) {
7172
+ if (value) record[key] = value;
7173
+ }
7174
+ for (const key of ["pkce_required", "refresh_supported"]) {
7175
+ if (typeof item[key] === "boolean") record[key] = item[key];
7176
+ }
7177
+ if (Array.isArray(item.available_scopes)) {
7178
+ const availableScopes = item.available_scopes.map((scope) => String(scope ?? "").trim()).filter(Boolean);
7179
+ if (availableScopes.length > 0) record.available_scopes = availableScopes;
7180
+ }
7181
+ resolved[providerKey] = record;
7133
7182
  }
7134
7183
  return resolved;
7135
7184
  }
@@ -7155,7 +7204,7 @@ function ensureRequiredOauthCredentials(project) {
7155
7204
  }
7156
7205
  const path = project.oauth_credentials_path ?? (0, import_node_path.join)(project.root_dir, "oauth_credentials.json");
7157
7206
  throw new SiglumeProjectError(
7158
- `${path} is required for OAuth-backed APIs. Missing provider seeds: ${missing.join(", ")}`
7207
+ `${path} is required for platform-managed OAuth APIs. Missing provider seeds: ${missing.join(", ")}`
7159
7208
  );
7160
7209
  }
7161
7210
  async function validateProject(path = ".", deps = {}) {
@@ -7323,7 +7372,7 @@ async function registrationPreflight(project, client) {
7323
7372
  errors.push(`remote Tool Manual quality is not publishable: ${remoteQuality.grade} (${remoteQuality.overall_score}/100)`);
7324
7373
  }
7325
7374
  if (missingOauthProviders.length > 0) {
7326
- errors.push(`oauth_credentials.json is required for OAuth-backed APIs: ${missingOauthProviders.join(", ")}`);
7375
+ errors.push(`oauth_credentials.json is required for platform-managed OAuth APIs: ${missingOauthProviders.join(", ")}`);
7327
7376
  }
7328
7377
  const preflight = {
7329
7378
  manifest_issues: manifestIssues,
@@ -7349,6 +7398,7 @@ async function runRegistration(path = ".", options = {}, deps = {}) {
7349
7398
  ensureManifestPublisherIdentity(project);
7350
7399
  ensureRuntimeValidationReady(project);
7351
7400
  ensureRequiredOauthCredentials(project);
7401
+ const canonicalOauthCredentials = canonicalOauthCredentialsPayload(project.oauth_credentials);
7352
7402
  const client = await createClient(deps);
7353
7403
  const preflight = await registrationPreflight(project, client);
7354
7404
  let developerPortalPreflight = null;
@@ -7364,7 +7414,7 @@ async function runRegistration(path = ".", options = {}, deps = {}) {
7364
7414
  }
7365
7415
  const receipt = await client.auto_register(project.manifest, project.tool_manual, {
7366
7416
  runtime_validation: project.runtime_validation,
7367
- oauth_credentials: canonicalOauthCredentialsPayload(project.oauth_credentials)
7417
+ oauth_credentials: canonicalOauthCredentials
7368
7418
  });
7369
7419
  const result = {
7370
7420
  receipt: toJsonable(receipt),
@@ -7375,7 +7425,8 @@ async function runRegistration(path = ".", options = {}, deps = {}) {
7375
7425
  if (developerPortalPreflight) {
7376
7426
  result.developer_portal_preflight = developerPortalPreflight;
7377
7427
  }
7378
- if (options.confirm) {
7428
+ const shouldConfirm = Boolean(options.confirm) || options.confirm === void 0 && !options.draft_only && !options.submit_review;
7429
+ if (shouldConfirm) {
7379
7430
  result.confirmation = toJsonable(await client.confirm_registration(receipt.listing_id));
7380
7431
  if (options.submit_review) {
7381
7432
  result.submit_review_skipped = true;
@@ -7906,8 +7957,8 @@ function operationReadmeTemplate(operation, manifest, warning) {
7906
7957
  "siglume score . --remote",
7907
7958
  "siglume preflight .",
7908
7959
  "siglume register .",
7909
- "# inspect the draft, then explicitly approve publish:",
7910
- "siglume register . --confirm",
7960
+ "# review-only staging path:",
7961
+ "siglume register . --draft-only",
7911
7962
  "```",
7912
7963
  ""
7913
7964
  ].join("\n");
@@ -7918,7 +7969,7 @@ function apiUsageDocsTemplate(manifest) {
7918
7969
  const jobToBeDone = String(manifest.job_to_be_done ?? "Describe what this API lets an agent do.");
7919
7970
  const permissionClass = String(manifest.permission_class ?? "read-only");
7920
7971
  const priceModel = String(manifest.price_model ?? "free");
7921
- const requiredAccounts = (manifest.required_connected_accounts ?? []).join(", ") || "none";
7972
+ const requiredAccounts = (manifest.required_connected_accounts ?? []).map((item) => connectedAccountRequirementLabel(item)).filter(Boolean).join(", ") || "none";
7922
7973
  const supportContact = String(manifest.support_contact ?? "replace-with-support-contact");
7923
7974
  return [
7924
7975
  `# ${name} API Usage Guide`,
@@ -8479,8 +8530,8 @@ function readmeTemplate(template) {
8479
8530
  "siglume score . --remote",
8480
8531
  "siglume preflight .",
8481
8532
  "siglume register .",
8482
- "# inspect the draft, then explicitly approve publish:",
8483
- "siglume register . --confirm",
8533
+ "# review-only staging path:",
8534
+ "siglume register . --draft-only",
8484
8535
  "```",
8485
8536
  ""
8486
8537
  ].join("\n");
@@ -8662,16 +8713,25 @@ async function runCli(argv, deps = {}) {
8662
8713
  if (report.runtime_validation_path) emit(stdout, `runtime_validation_path: ${String(report.runtime_validation_path)}`);
8663
8714
  if (report.oauth_credentials_path) emit(stdout, `oauth_credentials_path: ${String(report.oauth_credentials_path)}`);
8664
8715
  });
8665
- 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) => {
8666
- const report = await runRegistration(path, { confirm: options.confirm, submit_review: options.submitReview }, deps);
8716
+ 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) => {
8717
+ const draftOnly = Boolean(options.draftOnly);
8718
+ if (draftOnly && options.confirm) {
8719
+ throw new SiglumeProjectError("--draft-only cannot be combined with --confirm.");
8720
+ }
8721
+ if (draftOnly && options.submitReview) {
8722
+ throw new SiglumeProjectError("--draft-only cannot be combined with --submit-review.");
8723
+ }
8724
+ const shouldConfirm = Boolean(options.confirm) || !draftOnly && !options.submitReview;
8725
+ const report = await runRegistration(path, { confirm: shouldConfirm, draft_only: draftOnly, submit_review: options.submitReview }, deps);
8667
8726
  if (options.json) {
8668
8727
  emit(stdout, renderJson(report));
8669
8728
  } else {
8670
8729
  const receipt = report.receipt;
8671
- if (report.confirmation) {
8672
- emit(stdout, "Listing published.");
8673
- } else if (report.review) {
8674
- emit(stdout, "Listing published via legacy submit-review alias.");
8730
+ const published = Boolean(report.confirmation || report.review);
8731
+ if (published && receipt.registration_mode === "upgrade") {
8732
+ emit(stdout, "Upgrade registered.");
8733
+ } else if (published) {
8734
+ emit(stdout, "Registration accepted.");
8675
8735
  } else if (receipt.registration_mode === "upgrade") {
8676
8736
  emit(stdout, "Upgrade staged.");
8677
8737
  } else if (receipt.registration_mode === "refresh") {
@@ -8688,10 +8748,12 @@ async function runCli(argv, deps = {}) {
8688
8748
  if (receipt.request_id) emit(stdout, `request_id: ${receipt.request_id}`);
8689
8749
  if (report.confirmation) {
8690
8750
  const confirmation = report.confirmation;
8751
+ emit(stdout, "Listing published.");
8691
8752
  if (confirmation.status) emit(stdout, `confirmation_status: ${confirmation.status}`);
8692
8753
  if (confirmation.release?.release_status) emit(stdout, `release_status: ${confirmation.release.release_status}`);
8693
8754
  } else if (report.review) {
8694
8755
  const review = report.review;
8756
+ emit(stdout, "Listing published via legacy submit-review alias.");
8695
8757
  if (review.status) emit(stdout, `publish_status: ${review.status}`);
8696
8758
  }
8697
8759
  const preflight = report.registration_preflight;