@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.
@@ -1339,19 +1339,6 @@ function parseBundleMember(data) {
1339
1339
  link_id: stringOrNull(data.link_id)
1340
1340
  };
1341
1341
  }
1342
- function parseConnectedAccountProvider(data) {
1343
- return {
1344
- provider_key: String(data.provider_key ?? ""),
1345
- display_name: String(data.display_name ?? ""),
1346
- auth_type: String(data.auth_type ?? "oauth2"),
1347
- refresh_supported: Boolean(data.refresh_supported ?? false),
1348
- pkce_required: Boolean(data.pkce_required ?? false),
1349
- default_scopes: Array.isArray(data.default_scopes) ? data.default_scopes.filter((s) => typeof s === "string") : [],
1350
- available_scopes: Array.isArray(data.available_scopes) ? data.available_scopes.filter((s) => typeof s === "string") : [],
1351
- scope_separator: String(data.scope_separator ?? " "),
1352
- notes: stringOrNull(data.notes)
1353
- };
1354
- }
1355
1342
  function parseConnectedAccountLifecycle(data) {
1356
1343
  return {
1357
1344
  connected_account_id: String(data.connected_account_id ?? ""),
@@ -2477,9 +2464,13 @@ var init_client = __esm({
2477
2464
  async auto_register(manifest, tool_manual, options = {}) {
2478
2465
  const manifestPayload = coerceMapping(manifest, "manifest");
2479
2466
  const toolManualPayload = coerceMapping(tool_manual, "tool_manual");
2467
+ const toolManualForRequest = { ...toolManualPayload };
2468
+ const embeddedInputFormSpec = toolManualForRequest.input_form_spec;
2469
+ delete toolManualForRequest.input_form_spec;
2470
+ const inputFormSpec = options.input_form_spec ?? embeddedInputFormSpec;
2480
2471
  const payload = {
2481
2472
  manifest: { ...manifestPayload },
2482
- tool_manual: { ...toolManualPayload }
2473
+ tool_manual: toolManualForRequest
2483
2474
  };
2484
2475
  if (options.source_url) {
2485
2476
  payload.source_url = options.source_url;
@@ -2501,8 +2492,8 @@ var init_client = __esm({
2501
2492
  if (options.source_context) {
2502
2493
  payload.source_context = coerceMapping(options.source_context, "source_context");
2503
2494
  }
2504
- if (options.input_form_spec) {
2505
- payload.input_form_spec = coerceMapping(options.input_form_spec, "input_form_spec");
2495
+ if (inputFormSpec !== void 0 && inputFormSpec !== null) {
2496
+ payload.input_form_spec = coerceMapping(inputFormSpec, "input_form_spec");
2506
2497
  }
2507
2498
  for (const fieldName of [
2508
2499
  "capability_key",
@@ -2553,7 +2544,11 @@ var init_client = __esm({
2553
2544
  if (!listing_id) {
2554
2545
  throw new SiglumeClientError("Siglume auto-register response did not include listing_id.");
2555
2546
  }
2556
- this.pendingConfirmations.set(listing_id, { manifest: manifestPayload, tool_manual: toolManualPayload });
2547
+ this.pendingConfirmations.set(listing_id, {
2548
+ manifest: manifestPayload,
2549
+ tool_manual: toRecord(payload.tool_manual),
2550
+ input_form_spec: toRecord(payload.input_form_spec)
2551
+ });
2557
2552
  return {
2558
2553
  listing_id,
2559
2554
  status: String(data.status ?? "draft"),
@@ -2701,11 +2696,6 @@ var init_client = __esm({
2701
2696
  // ----- end bundles -------------------------------------------------------
2702
2697
  // ----- Connected accounts (v0.7 track 3) ---------------------------------
2703
2698
  // `resolve()` is intentionally NOT wrapped: runtime-only, never over the wire.
2704
- async list_connected_account_providers() {
2705
- const [data] = await this.request("GET", "/me/connected-accounts/providers");
2706
- const items = Array.isArray(data.items) ? data.items : [];
2707
- return items.filter((item) => isRecord(item)).map(parseConnectedAccountProvider);
2708
- }
2709
2699
  async start_connected_account_oauth(input) {
2710
2700
  const body = {
2711
2701
  listing_id: input.listing_id,
@@ -2742,8 +2732,17 @@ var init_client = __esm({
2742
2732
  const body = {
2743
2733
  provider_key: input.provider_key,
2744
2734
  client_id: input.client_id,
2745
- client_secret: input.client_secret
2735
+ client_secret: input.client_secret,
2736
+ authorize_url: input.authorize_url,
2737
+ token_url: input.token_url
2746
2738
  };
2739
+ if (input.revoke_url !== void 0) body.revoke_url = input.revoke_url;
2740
+ if (input.display_name !== void 0) body.display_name = input.display_name;
2741
+ if (input.scope_separator !== void 0) body.scope_separator = input.scope_separator;
2742
+ if (input.token_endpoint_auth !== void 0) body.token_endpoint_auth = input.token_endpoint_auth;
2743
+ if (input.pkce_required !== void 0) body.pkce_required = input.pkce_required;
2744
+ if (input.refresh_supported !== void 0) body.refresh_supported = input.refresh_supported;
2745
+ if (input.available_scopes !== void 0) body.available_scopes = input.available_scopes;
2747
2746
  if (input.required_scopes !== void 0) body.required_scopes = input.required_scopes;
2748
2747
  const [data] = await this.request("PUT", `/market/capabilities/${listing_id}/oauth-credentials`, {
2749
2748
  json_body: body
@@ -5656,16 +5655,24 @@ function coerceToolManual(manual) {
5656
5655
  }
5657
5656
  function checkSchemaForbiddenRecursive(schema, rootField, pushIssue, path = "") {
5658
5657
  for (const keyword of COMPOSITION_KEYWORDS) {
5659
- if (keyword in schema) {
5660
- const location = path ? `${rootField}.${path}.${keyword}` : `${rootField}.${keyword}`;
5661
- pushIssue(
5662
- issue(
5663
- "INPUT_SCHEMA",
5664
- `Composition keyword '${keyword}' is not allowed in beta${path ? ` at ${path}` : ""}`,
5665
- location
5666
- )
5667
- );
5658
+ if (!(keyword in schema)) {
5659
+ continue;
5660
+ }
5661
+ const branches = schema[keyword];
5662
+ const location = path ? `${rootField}.${path}.${keyword}` : `${rootField}.${keyword}`;
5663
+ if (!Array.isArray(branches) || branches.length === 0) {
5664
+ pushIssue(issue("INPUT_SCHEMA", `${keyword} must be a non-empty array`, location));
5665
+ continue;
5668
5666
  }
5667
+ branches.forEach((branch, index) => {
5668
+ const branchPath = path ? `${path}.${keyword}[${index}]` : `${keyword}[${index}]`;
5669
+ const branchLocation = `${rootField}.${branchPath}`;
5670
+ if (!isRecord(branch)) {
5671
+ pushIssue(issue("INPUT_SCHEMA", `${keyword}[${index}] must be an object`, branchLocation));
5672
+ return;
5673
+ }
5674
+ checkSchemaForbiddenRecursive(branch, rootField, pushIssue, branchPath);
5675
+ });
5669
5676
  }
5670
5677
  for (const forbidden of INPUT_SCHEMA_FORBIDDEN_KEYS) {
5671
5678
  if (forbidden in schema) {
@@ -7032,43 +7039,51 @@ async function loadProject(path = ".") {
7032
7039
  oauth_credentials
7033
7040
  };
7034
7041
  }
7035
- var OAUTH_PROVIDER_ALIASES = {
7036
- x: "twitter",
7037
- "x-twitter": "twitter",
7038
- twitter: "twitter",
7039
- slack: "slack",
7040
- google: "google",
7041
- gmail: "google",
7042
- "google-drive": "google",
7043
- "google-calendar": "google",
7044
- github: "github",
7045
- linear: "linear",
7046
- notion: "notion"
7047
- };
7042
+ function isPlatformManagedRequirement(value) {
7043
+ if (!isRecord(value)) return false;
7044
+ if (value.platform_managed === true) return true;
7045
+ const owner = String(
7046
+ value.managed_by ?? value.auth_managed_by ?? value.connection_owner ?? ""
7047
+ ).trim().toLowerCase().replaceAll("_", "-");
7048
+ return owner === "platform" || owner === "siglume" || owner === "siglume-platform";
7049
+ }
7048
7050
  function oauthProviderKeyFromRequirement(value) {
7049
- const raw = String(value ?? "").trim().toLowerCase().replaceAll("_", "-");
7050
- if (!raw) return null;
7051
- if (OAUTH_PROVIDER_ALIASES[raw]) {
7052
- return OAUTH_PROVIDER_ALIASES[raw];
7053
- }
7054
- for (const token of raw.replaceAll("/", "-").replaceAll(":", "-").split("-")) {
7055
- const next = token.trim();
7056
- if (OAUTH_PROVIDER_ALIASES[next]) {
7057
- return OAUTH_PROVIDER_ALIASES[next];
7051
+ if (isRecord(value)) {
7052
+ for (const key of ["provider_key", "provider", "account_type", "name"]) {
7053
+ const providerKey = oauthProviderKeyFromRequirement(value[key]);
7054
+ if (providerKey) return providerKey;
7058
7055
  }
7056
+ return null;
7059
7057
  }
7060
- return null;
7058
+ const raw = String(value ?? "").trim();
7059
+ return raw || null;
7061
7060
  }
7062
7061
  function requiredOauthProviders(requirements) {
7063
7062
  const providers = [];
7064
7063
  for (const item of requirements ?? []) {
7064
+ if (!isPlatformManagedRequirement(item)) continue;
7065
7065
  const providerKey = oauthProviderKeyFromRequirement(item);
7066
+ if (!providerKey) {
7067
+ throw new SiglumeProjectError(
7068
+ "required_connected_accounts platform-managed entries must include a provider_key"
7069
+ );
7070
+ }
7066
7071
  if (providerKey && !providers.includes(providerKey)) {
7067
7072
  providers.push(providerKey);
7068
7073
  }
7069
7074
  }
7070
7075
  return providers;
7071
7076
  }
7077
+ function connectedAccountRequirementLabel(value) {
7078
+ if (isRecord(value)) {
7079
+ for (const key of ["provider_key", "provider", "account_type", "name"]) {
7080
+ const label = String(value[key] ?? "").trim();
7081
+ if (label) return label;
7082
+ }
7083
+ return "";
7084
+ }
7085
+ return String(value ?? "").trim();
7086
+ }
7072
7087
  function oauthProviderRecordsMap(payload) {
7073
7088
  if (!payload) {
7074
7089
  return {};
@@ -7081,7 +7096,23 @@ function oauthProviderRecordsMap(payload) {
7081
7096
  }
7082
7097
  const providerKey = oauthProviderKeyFromRequirement(item.provider_key ?? item.provider);
7083
7098
  if (!providerKey) {
7084
- throw new SiglumeProjectError(`oauth_credentials[${index}].provider_key is unsupported.`);
7099
+ throw new SiglumeProjectError(`oauth_credentials[${index}].provider_key is required.`);
7100
+ }
7101
+ const authorizeUrl = String(item.authorize_url ?? item.authorization_url ?? item.auth_url ?? "").trim();
7102
+ const tokenUrl = String(item.token_url ?? "").trim();
7103
+ if (!authorizeUrl || !tokenUrl) {
7104
+ throw new SiglumeProjectError(
7105
+ `oauth_credentials[${index}] must include authorize_url and token_url.`
7106
+ );
7107
+ }
7108
+ for (const [urlKey, urlValue] of Object.entries({
7109
+ authorize_url: authorizeUrl,
7110
+ token_url: tokenUrl,
7111
+ revoke_url: String(item.revoke_url ?? "").trim()
7112
+ })) {
7113
+ if (urlValue && !urlValue.startsWith("https://")) {
7114
+ throw new SiglumeProjectError(`oauth_credentials[${index}].${urlKey} must be an https URL.`);
7115
+ }
7085
7116
  }
7086
7117
  const clientId = String(item.client_id ?? "").trim();
7087
7118
  const clientSecret = String(item.client_secret ?? "").trim();
@@ -7097,12 +7128,30 @@ function oauthProviderRecordsMap(payload) {
7097
7128
  } else {
7098
7129
  scopes = rawScopes.map((scope) => String(scope ?? "").trim()).filter(Boolean);
7099
7130
  }
7100
- resolved[providerKey] = {
7131
+ const record = {
7101
7132
  provider_key: providerKey,
7102
7133
  client_id: clientId,
7103
7134
  client_secret: clientSecret,
7104
7135
  required_scopes: scopes
7105
7136
  };
7137
+ for (const [key, value] of Object.entries({
7138
+ authorize_url: authorizeUrl,
7139
+ token_url: tokenUrl,
7140
+ revoke_url: String(item.revoke_url ?? "").trim(),
7141
+ display_name: String(item.display_name ?? "").trim(),
7142
+ scope_separator: String(item.scope_separator ?? "").trim(),
7143
+ token_endpoint_auth: String(item.token_endpoint_auth ?? "").trim()
7144
+ })) {
7145
+ if (value) record[key] = value;
7146
+ }
7147
+ for (const key of ["pkce_required", "refresh_supported"]) {
7148
+ if (typeof item[key] === "boolean") record[key] = item[key];
7149
+ }
7150
+ if (Array.isArray(item.available_scopes)) {
7151
+ const availableScopes = item.available_scopes.map((scope) => String(scope ?? "").trim()).filter(Boolean);
7152
+ if (availableScopes.length > 0) record.available_scopes = availableScopes;
7153
+ }
7154
+ resolved[providerKey] = record;
7106
7155
  }
7107
7156
  return resolved;
7108
7157
  }
@@ -7128,7 +7177,7 @@ function ensureRequiredOauthCredentials(project) {
7128
7177
  }
7129
7178
  const path = project.oauth_credentials_path ?? join(project.root_dir, "oauth_credentials.json");
7130
7179
  throw new SiglumeProjectError(
7131
- `${path} is required for OAuth-backed APIs. Missing provider seeds: ${missing.join(", ")}`
7180
+ `${path} is required for platform-managed OAuth APIs. Missing provider seeds: ${missing.join(", ")}`
7132
7181
  );
7133
7182
  }
7134
7183
  async function validateProject(path = ".", deps = {}) {
@@ -7296,7 +7345,7 @@ async function registrationPreflight(project, client) {
7296
7345
  errors.push(`remote Tool Manual quality is not publishable: ${remoteQuality.grade} (${remoteQuality.overall_score}/100)`);
7297
7346
  }
7298
7347
  if (missingOauthProviders.length > 0) {
7299
- errors.push(`oauth_credentials.json is required for OAuth-backed APIs: ${missingOauthProviders.join(", ")}`);
7348
+ errors.push(`oauth_credentials.json is required for platform-managed OAuth APIs: ${missingOauthProviders.join(", ")}`);
7300
7349
  }
7301
7350
  const preflight = {
7302
7351
  manifest_issues: manifestIssues,
@@ -7322,6 +7371,7 @@ async function runRegistration(path = ".", options = {}, deps = {}) {
7322
7371
  ensureManifestPublisherIdentity(project);
7323
7372
  ensureRuntimeValidationReady(project);
7324
7373
  ensureRequiredOauthCredentials(project);
7374
+ const canonicalOauthCredentials = canonicalOauthCredentialsPayload(project.oauth_credentials);
7325
7375
  const client = await createClient(deps);
7326
7376
  const preflight = await registrationPreflight(project, client);
7327
7377
  let developerPortalPreflight = null;
@@ -7337,7 +7387,7 @@ async function runRegistration(path = ".", options = {}, deps = {}) {
7337
7387
  }
7338
7388
  const receipt = await client.auto_register(project.manifest, project.tool_manual, {
7339
7389
  runtime_validation: project.runtime_validation,
7340
- oauth_credentials: canonicalOauthCredentialsPayload(project.oauth_credentials)
7390
+ oauth_credentials: canonicalOauthCredentials
7341
7391
  });
7342
7392
  const result = {
7343
7393
  receipt: toJsonable(receipt),
@@ -7348,7 +7398,8 @@ async function runRegistration(path = ".", options = {}, deps = {}) {
7348
7398
  if (developerPortalPreflight) {
7349
7399
  result.developer_portal_preflight = developerPortalPreflight;
7350
7400
  }
7351
- if (options.confirm) {
7401
+ const shouldConfirm = Boolean(options.confirm) || options.confirm === void 0 && !options.draft_only && !options.submit_review;
7402
+ if (shouldConfirm) {
7352
7403
  result.confirmation = toJsonable(await client.confirm_registration(receipt.listing_id));
7353
7404
  if (options.submit_review) {
7354
7405
  result.submit_review_skipped = true;
@@ -7879,8 +7930,8 @@ function operationReadmeTemplate(operation, manifest, warning) {
7879
7930
  "siglume score . --remote",
7880
7931
  "siglume preflight .",
7881
7932
  "siglume register .",
7882
- "# inspect the draft, then explicitly approve publish:",
7883
- "siglume register . --confirm",
7933
+ "# review-only staging path:",
7934
+ "siglume register . --draft-only",
7884
7935
  "```",
7885
7936
  ""
7886
7937
  ].join("\n");
@@ -7891,7 +7942,7 @@ function apiUsageDocsTemplate(manifest) {
7891
7942
  const jobToBeDone = String(manifest.job_to_be_done ?? "Describe what this API lets an agent do.");
7892
7943
  const permissionClass = String(manifest.permission_class ?? "read-only");
7893
7944
  const priceModel = String(manifest.price_model ?? "free");
7894
- const requiredAccounts = (manifest.required_connected_accounts ?? []).join(", ") || "none";
7945
+ const requiredAccounts = (manifest.required_connected_accounts ?? []).map((item) => connectedAccountRequirementLabel(item)).filter(Boolean).join(", ") || "none";
7895
7946
  const supportContact = String(manifest.support_contact ?? "replace-with-support-contact");
7896
7947
  return [
7897
7948
  `# ${name} API Usage Guide`,
@@ -8452,8 +8503,8 @@ function readmeTemplate(template) {
8452
8503
  "siglume score . --remote",
8453
8504
  "siglume preflight .",
8454
8505
  "siglume register .",
8455
- "# inspect the draft, then explicitly approve publish:",
8456
- "siglume register . --confirm",
8506
+ "# review-only staging path:",
8507
+ "siglume register . --draft-only",
8457
8508
  "```",
8458
8509
  ""
8459
8510
  ].join("\n");
@@ -8635,16 +8686,25 @@ async function runCli(argv, deps = {}) {
8635
8686
  if (report.runtime_validation_path) emit(stdout, `runtime_validation_path: ${String(report.runtime_validation_path)}`);
8636
8687
  if (report.oauth_credentials_path) emit(stdout, `oauth_credentials_path: ${String(report.oauth_credentials_path)}`);
8637
8688
  });
8638
- 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) => {
8639
- const report = await runRegistration(path, { confirm: options.confirm, submit_review: options.submitReview }, deps);
8689
+ 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) => {
8690
+ const draftOnly = Boolean(options.draftOnly);
8691
+ if (draftOnly && options.confirm) {
8692
+ throw new SiglumeProjectError("--draft-only cannot be combined with --confirm.");
8693
+ }
8694
+ if (draftOnly && options.submitReview) {
8695
+ throw new SiglumeProjectError("--draft-only cannot be combined with --submit-review.");
8696
+ }
8697
+ const shouldConfirm = Boolean(options.confirm) || !draftOnly && !options.submitReview;
8698
+ const report = await runRegistration(path, { confirm: shouldConfirm, draft_only: draftOnly, submit_review: options.submitReview }, deps);
8640
8699
  if (options.json) {
8641
8700
  emit(stdout, renderJson(report));
8642
8701
  } else {
8643
8702
  const receipt = report.receipt;
8644
- if (report.confirmation) {
8645
- emit(stdout, "Listing published.");
8646
- } else if (report.review) {
8647
- emit(stdout, "Listing published via legacy submit-review alias.");
8703
+ const published = Boolean(report.confirmation || report.review);
8704
+ if (published && receipt.registration_mode === "upgrade") {
8705
+ emit(stdout, "Upgrade registered.");
8706
+ } else if (published) {
8707
+ emit(stdout, "Registration accepted.");
8648
8708
  } else if (receipt.registration_mode === "upgrade") {
8649
8709
  emit(stdout, "Upgrade staged.");
8650
8710
  } else if (receipt.registration_mode === "refresh") {
@@ -8661,10 +8721,12 @@ async function runCli(argv, deps = {}) {
8661
8721
  if (receipt.request_id) emit(stdout, `request_id: ${receipt.request_id}`);
8662
8722
  if (report.confirmation) {
8663
8723
  const confirmation = report.confirmation;
8724
+ emit(stdout, "Listing published.");
8664
8725
  if (confirmation.status) emit(stdout, `confirmation_status: ${confirmation.status}`);
8665
8726
  if (confirmation.release?.release_status) emit(stdout, `release_status: ${confirmation.release.release_status}`);
8666
8727
  } else if (report.review) {
8667
8728
  const review = report.review;
8729
+ emit(stdout, "Listing published via legacy submit-review alias.");
8668
8730
  if (review.status) emit(stdout, `publish_status: ${review.status}`);
8669
8731
  }
8670
8732
  const preflight = report.registration_preflight;