@siglume/api-sdk 0.10.7 → 1.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.js CHANGED
@@ -1537,6 +1537,56 @@ var init_operations = __esm({
1537
1537
  });
1538
1538
 
1539
1539
  // src/client.ts
1540
+ function validateManifestPersistenceContract(payload) {
1541
+ const vertical = String(payload.store_vertical ?? "").trim().toLowerCase();
1542
+ const persistence = payload.persistence;
1543
+ if (persistence === void 0 || persistence === null) {
1544
+ return;
1545
+ }
1546
+ if (!isRecord2(persistence)) {
1547
+ throw new SiglumeClientError("AppManifest.persistence must be an object.");
1548
+ }
1549
+ const mode = String(persistence.mode ?? (vertical === "game" ? "platform" : "none")).trim().toLowerCase();
1550
+ if (!["none", "local", "platform", "developer_server"].includes(mode)) {
1551
+ throw new SiglumeClientError(
1552
+ "AppManifest.persistence.mode must be one of: none, local, platform, developer_server."
1553
+ );
1554
+ }
1555
+ const schema = persistence.save_data_schema;
1556
+ if (vertical === "game" && mode !== "none" && schema === void 0) {
1557
+ throw new SiglumeClientError(
1558
+ "AppManifest.persistence.save_data_schema is required when store_vertical='game' and persistence.mode is not 'none'."
1559
+ );
1560
+ }
1561
+ if (schema !== void 0) {
1562
+ validateSaveDataSchema(schema, "AppManifest.persistence.save_data_schema");
1563
+ }
1564
+ }
1565
+ function validateSaveDataSchema(schema, fieldName) {
1566
+ if (!isRecord2(schema)) {
1567
+ throw new SiglumeClientError(`${fieldName} must be a JSON Schema object.`);
1568
+ }
1569
+ const schemaSize = new TextEncoder().encode(JSON.stringify(schema)).length;
1570
+ if (schemaSize > 8192) {
1571
+ throw new SiglumeClientError(`${fieldName} must be at most 8192 bytes.`);
1572
+ }
1573
+ if (schema.type !== "object") {
1574
+ throw new SiglumeClientError(`${fieldName}.type must be 'object'.`);
1575
+ }
1576
+ const properties = schema.properties;
1577
+ if (!isRecord2(properties) || Object.keys(properties).length === 0) {
1578
+ throw new SiglumeClientError(`${fieldName}.properties must be a non-empty object.`);
1579
+ }
1580
+ if (schema.required !== void 0) {
1581
+ if (!Array.isArray(schema.required) || !schema.required.every((item) => typeof item === "string")) {
1582
+ throw new SiglumeClientError(`${fieldName}.required must be an array of strings when provided.`);
1583
+ }
1584
+ const missing = schema.required.filter((item) => !(item in properties));
1585
+ if (missing.length > 0) {
1586
+ throw new SiglumeClientError(`${fieldName}.required references undefined properties: ${missing.join(", ")}.`);
1587
+ }
1588
+ }
1589
+ }
1540
1590
  function buildToolManualQualityReport(payload) {
1541
1591
  const qualityBlock = isRecord2(payload.quality) ? payload.quality : payload;
1542
1592
  const issues = [];
@@ -1611,6 +1661,8 @@ function buildUrl(baseUrl, path, params) {
1611
1661
  return url.toString();
1612
1662
  }
1613
1663
  function parseListing(data) {
1664
+ const metadata = isRecord2(data.metadata) ? data.metadata : {};
1665
+ const persistence = isRecord2(data.persistence) ? data.persistence : isRecord2(metadata.persistence) ? metadata.persistence : {};
1614
1666
  return {
1615
1667
  listing_id: String(data.listing_id ?? data.id ?? ""),
1616
1668
  capability_key: String(data.capability_key ?? ""),
@@ -1633,14 +1685,59 @@ function parseListing(data) {
1633
1685
  seller_display_name: stringOrNull2(data.seller_display_name),
1634
1686
  seller_homepage_url: stringOrNull2(data.seller_homepage_url),
1635
1687
  seller_social_url: stringOrNull2(data.seller_social_url),
1688
+ publisher_type: stringOrNull2(data.publisher_type),
1689
+ publisher_company_id: stringOrNull2(data.publisher_company_id),
1690
+ company_id: stringOrNull2(data.company_id),
1691
+ company_name: stringOrNull2(data.company_name),
1692
+ company_publish_status: stringOrNull2(data.company_publish_status),
1693
+ company_terms_version: stringOrNull2(data.company_terms_version),
1636
1694
  review_status: stringOrNull2(data.review_status),
1637
1695
  review_note: stringOrNull2(data.review_note),
1638
1696
  submission_blockers: Array.isArray(data.submission_blockers) ? data.submission_blockers.filter((item) => typeof item === "string") : [],
1697
+ persistence: { ...persistence },
1639
1698
  created_at: stringOrNull2(data.created_at),
1640
1699
  updated_at: stringOrNull2(data.updated_at),
1641
1700
  raw: { ...data }
1642
1701
  };
1643
1702
  }
1703
+ function parseCompanyPublisher(data) {
1704
+ const wallets = Array.isArray(data.settlement_wallets) ? data.settlement_wallets.filter((item) => isRecord2(item)) : [];
1705
+ return {
1706
+ company_id: String(data.company_id ?? data.id ?? ""),
1707
+ name: String(data.name ?? ""),
1708
+ status: String(data.status ?? ""),
1709
+ description: stringOrNull2(data.description),
1710
+ is_founder: Boolean(data.is_founder ?? false),
1711
+ membership_role: stringOrNull2(data.membership_role),
1712
+ membership_status: stringOrNull2(data.membership_status),
1713
+ can_publish: Boolean(data.can_publish ?? true),
1714
+ can_approve: Boolean(data.can_approve ?? false),
1715
+ approval_required: Boolean(data.approval_required ?? false),
1716
+ paid_listing_allowed: Boolean(data.paid_listing_allowed ?? false),
1717
+ disabled_reasons: Array.isArray(data.disabled_reasons) ? data.disabled_reasons.filter((item) => typeof item === "string") : [],
1718
+ company_terms_version: stringOrNull2(data.company_terms_version),
1719
+ active_listing_count: Number(data.active_listing_count ?? 0),
1720
+ pending_approval_count: Number(data.pending_approval_count ?? 0),
1721
+ settlement_wallet_ready: Boolean(data.settlement_wallet_ready ?? false),
1722
+ settlement_wallets: wallets.map((item) => ({ ...item })),
1723
+ raw: { ...data }
1724
+ };
1725
+ }
1726
+ function parseCapabilitySaveState(data) {
1727
+ return {
1728
+ capability_key: String(data.capability_key ?? ""),
1729
+ save_key: String(data.save_key ?? ""),
1730
+ schema_version: String(data.schema_version ?? "1"),
1731
+ revision: Number(data.revision ?? 0),
1732
+ payload: toRecord2(data.payload),
1733
+ metadata: toRecord2(data.metadata),
1734
+ checksum: stringOrNull2(data.checksum),
1735
+ updated_at: stringOrNull2(data.updated_at),
1736
+ created_at: stringOrNull2(data.created_at),
1737
+ exists: Boolean(data.exists ?? false),
1738
+ raw: { ...data }
1739
+ };
1740
+ }
1644
1741
  function parseBundleMember(data) {
1645
1742
  return {
1646
1743
  capability_listing_id: String(data.capability_listing_id ?? ""),
@@ -1652,18 +1749,6 @@ function parseBundleMember(data) {
1652
1749
  link_id: stringOrNull2(data.link_id)
1653
1750
  };
1654
1751
  }
1655
- function parseConnectedAccountLifecycle(data) {
1656
- return {
1657
- connected_account_id: String(data.connected_account_id ?? ""),
1658
- provider_key: String(data.provider_key ?? ""),
1659
- expires_at: stringOrNull2(data.expires_at),
1660
- scopes: Array.isArray(data.scopes) ? data.scopes.filter((s) => typeof s === "string") : [],
1661
- refreshed_at: stringOrNull2(data.refreshed_at),
1662
- connection_status: stringOrNull2(data.connection_status),
1663
- provider_revoked: typeof data.provider_revoked === "boolean" ? data.provider_revoked : null,
1664
- revoked_at: stringOrNull2(data.revoked_at)
1665
- };
1666
- }
1667
1752
  function parseBundle(data) {
1668
1753
  const membersRaw = Array.isArray(data.members) ? data.members : [];
1669
1754
  return {
@@ -1742,21 +1827,6 @@ function parseBinding(data) {
1742
1827
  raw: { ...data }
1743
1828
  };
1744
1829
  }
1745
- function parseConnectedAccount(data) {
1746
- return {
1747
- connected_account_id: String(data.connected_account_id ?? data.id ?? ""),
1748
- provider_key: String(data.provider_key ?? ""),
1749
- account_role: String(data.account_role ?? ""),
1750
- display_name: stringOrNull2(data.display_name),
1751
- environment: stringOrNull2(data.environment),
1752
- connection_status: stringOrNull2(data.connection_status),
1753
- scopes: Array.isArray(data.scopes) ? data.scopes.filter((item) => typeof item === "string") : [],
1754
- metadata: toRecord2(data.metadata),
1755
- created_at: stringOrNull2(data.created_at),
1756
- updated_at: stringOrNull2(data.updated_at),
1757
- raw: { ...data }
1758
- };
1759
- }
1760
1830
  function parseSupportCase(data) {
1761
1831
  return {
1762
1832
  support_case_id: String(data.support_case_id ?? data.id ?? ""),
@@ -2795,13 +2865,6 @@ var init_client = __esm({
2795
2865
  if (options.runtime_validation) {
2796
2866
  payload.runtime_validation = coerceMapping(options.runtime_validation, "runtime_validation");
2797
2867
  }
2798
- if (options.oauth_credentials) {
2799
- payload.oauth_credentials = Array.isArray(options.oauth_credentials) ? {
2800
- items: options.oauth_credentials.map(
2801
- (item, index) => coerceMapping(item, `oauth_credentials[${index}]`)
2802
- )
2803
- } : coerceMapping(options.oauth_credentials, "oauth_credentials");
2804
- }
2805
2868
  if (options.source_context) {
2806
2869
  payload.source_context = coerceMapping(options.source_context, "source_context");
2807
2870
  }
@@ -2820,6 +2883,9 @@ var init_client = __esm({
2820
2883
  "support_contact",
2821
2884
  "seller_homepage_url",
2822
2885
  "seller_social_url",
2886
+ "publisher_type",
2887
+ "company_id",
2888
+ "publisher_company_id",
2823
2889
  "store_vertical",
2824
2890
  "jurisdiction",
2825
2891
  "price_model",
@@ -2832,7 +2898,8 @@ var init_client = __esm({
2832
2898
  "dry_run_supported",
2833
2899
  "required_connected_accounts",
2834
2900
  "permission_scopes",
2835
- "compatibility_tags"
2901
+ "compatibility_tags",
2902
+ "persistence"
2836
2903
  ]) {
2837
2904
  const value = manifestPayload[fieldName];
2838
2905
  if (value !== void 0 && value !== null) {
@@ -2872,6 +2939,26 @@ var init_client = __esm({
2872
2939
  );
2873
2940
  }
2874
2941
  }
2942
+ const explicitPublisherType = payload.publisher_type !== void 0 && payload.publisher_type !== null;
2943
+ const companyId = String(payload.company_id ?? "").trim() || String(payload.publisher_company_id ?? "").trim();
2944
+ const publisherType = String(payload.publisher_type ?? "user").trim().toLowerCase();
2945
+ if (publisherType !== "user" && publisherType !== "company") {
2946
+ throw new SiglumeClientError("AppManifest.publisher_type must be 'user' or 'company'.");
2947
+ }
2948
+ if (publisherType === "company" && !companyId) {
2949
+ throw new SiglumeClientError("AppManifest.company_id is required when publisher_type='company'.");
2950
+ }
2951
+ if (publisherType === "user" && companyId) {
2952
+ throw new SiglumeClientError("AppManifest.company_id cannot be combined with publisher_type='user'.");
2953
+ }
2954
+ if (explicitPublisherType || companyId) {
2955
+ payload.publisher_type = publisherType;
2956
+ }
2957
+ if (companyId) {
2958
+ payload.company_id = companyId;
2959
+ payload.publisher_company_id = companyId;
2960
+ }
2961
+ validateManifestPersistenceContract(payload);
2875
2962
  if (payload.manifest && typeof payload.manifest === "object") {
2876
2963
  delete payload.manifest.version;
2877
2964
  }
@@ -2907,7 +2994,6 @@ var init_client = __esm({
2907
2994
  auto_manifest: toRecord2(data.auto_manifest),
2908
2995
  confidence: toRecord2(data.confidence),
2909
2996
  validation_report: toRecord2(data.validation_report),
2910
- oauth_status: toRecord2(data.oauth_status),
2911
2997
  review_url: stringOrNull2(data.review_url),
2912
2998
  trace_id: meta.trace_id,
2913
2999
  request_id: meta.request_id
@@ -2979,6 +3065,45 @@ var init_client = __esm({
2979
3065
  const [data] = await this.request("GET", `/market/capabilities/${listing_id}`);
2980
3066
  return parseListing(data);
2981
3067
  }
3068
+ async list_company_publishers() {
3069
+ const [data] = await this.request("GET", "/market/company-publishers");
3070
+ return Array.isArray(data.items) ? data.items.filter((item) => isRecord2(item)).map(parseCompanyPublisher) : [];
3071
+ }
3072
+ async request_company_publish_approval(listing_id, note) {
3073
+ const [data] = await this.request("POST", `/market/capabilities/${listing_id}/company-publish-approval`, {
3074
+ json_body: note ? { note } : {}
3075
+ });
3076
+ return parseListing(data);
3077
+ }
3078
+ async decide_company_publish_approval(listing_id, options) {
3079
+ const [data] = await this.request("POST", `/market/capabilities/${listing_id}/company-publish-approval/decision`, {
3080
+ json_body: {
3081
+ decision: options.decision,
3082
+ ...options.reason ? { reason: options.reason } : {}
3083
+ }
3084
+ });
3085
+ return parseListing(data);
3086
+ }
3087
+ async get_capability_state(capability_key, save_key = "default") {
3088
+ const [data] = await this.request("GET", `/market/capability-state/${capability_key}/${save_key}`);
3089
+ return parseCapabilitySaveState(data);
3090
+ }
3091
+ async put_capability_state(capability_key, save_key = "default", payload = {}, options = {}) {
3092
+ const body = {
3093
+ payload: toRecord2(payload),
3094
+ schema_version: options.schema_version ?? "1",
3095
+ metadata: toRecord2(options.metadata)
3096
+ };
3097
+ if (options.expected_revision !== void 0 && options.expected_revision !== null) {
3098
+ body.expected_revision = Math.trunc(options.expected_revision);
3099
+ }
3100
+ const [data] = await this.request("PUT", `/market/capability-state/${capability_key}/${save_key}`, { json_body: body });
3101
+ return parseCapabilitySaveState(data);
3102
+ }
3103
+ async delete_capability_state(capability_key, save_key = "default") {
3104
+ const [data] = await this.request("DELETE", `/market/capability-state/${capability_key}/${save_key}`);
3105
+ return parseCapabilitySaveState(data);
3106
+ }
2982
3107
  // ----- Capability bundles (v0.7 track 2) ---------------------------------
2983
3108
  async list_bundles(options = {}) {
2984
3109
  const params = {
@@ -3044,66 +3169,9 @@ var init_client = __esm({
3044
3169
  return parseBundle(data);
3045
3170
  }
3046
3171
  // ----- end bundles -------------------------------------------------------
3047
- // ----- Connected accounts (v0.7 track 3) ---------------------------------
3048
- // `resolve()` is intentionally NOT wrapped: runtime-only, never over the wire.
3049
- async start_connected_account_oauth(input) {
3050
- const body = {
3051
- listing_id: input.listing_id,
3052
- redirect_uri: input.redirect_uri
3053
- };
3054
- if (input.scopes !== void 0) body.scopes = input.scopes;
3055
- if (input.account_role !== void 0) body.account_role = input.account_role;
3056
- const [data] = await this.request("POST", "/me/connected-accounts/oauth/authorize", {
3057
- json_body: body
3058
- });
3059
- return {
3060
- authorize_url: String(data.authorize_url ?? ""),
3061
- state: String(data.state ?? ""),
3062
- provider_key: String(data.provider_key ?? ""),
3063
- scopes: Array.isArray(data.scopes) ? data.scopes.filter((s) => typeof s === "string") : [],
3064
- pkce_method: stringOrNull2(data.pkce_method)
3065
- };
3066
- }
3067
- async complete_connected_account_oauth(input) {
3068
- const [data] = await this.request("POST", "/me/connected-accounts/oauth/callback", {
3069
- json_body: { state: input.state, code: input.code }
3070
- });
3071
- return { ...data };
3072
- }
3073
- async refresh_connected_account(account_id) {
3074
- const [data] = await this.request("POST", `/me/connected-accounts/${account_id}/refresh`);
3075
- return parseConnectedAccountLifecycle(data);
3076
- }
3077
- async revoke_connected_account(account_id) {
3078
- const [data] = await this.request("POST", `/me/connected-accounts/${account_id}/revoke`);
3079
- return parseConnectedAccountLifecycle(data);
3080
- }
3081
- async set_listing_oauth_credentials(listing_id, input) {
3082
- const body = {
3083
- provider_key: input.provider_key,
3084
- client_id: input.client_id,
3085
- client_secret: input.client_secret,
3086
- authorize_url: input.authorize_url,
3087
- token_url: input.token_url
3088
- };
3089
- if (input.revoke_url !== void 0) body.revoke_url = input.revoke_url;
3090
- if (input.display_name !== void 0) body.display_name = input.display_name;
3091
- if (input.scope_separator !== void 0) body.scope_separator = input.scope_separator;
3092
- if (input.token_endpoint_auth !== void 0) body.token_endpoint_auth = input.token_endpoint_auth;
3093
- if (input.pkce_required !== void 0) body.pkce_required = input.pkce_required;
3094
- if (input.refresh_supported !== void 0) body.refresh_supported = input.refresh_supported;
3095
- if (input.available_scopes !== void 0) body.available_scopes = input.available_scopes;
3096
- if (input.required_scopes !== void 0) body.required_scopes = input.required_scopes;
3097
- const [data] = await this.request("PUT", `/market/capabilities/${listing_id}/oauth-credentials`, {
3098
- json_body: body
3099
- });
3100
- return { ...data };
3101
- }
3102
- async get_listing_oauth_credentials_status(listing_id) {
3103
- const [data] = await this.request("GET", `/market/capabilities/${listing_id}/oauth-credentials`);
3104
- return { ...data };
3105
- }
3106
- // ----- end connected accounts --------------------------------------------
3172
+ // ----- Connected accounts ------------------------------------------------
3173
+ // Architecture B: publisher APIs own external OAuth and token storage.
3174
+ // The SDK no longer exposes platform OAuth or listing credential APIs.
3107
3175
  async get_developer_portal() {
3108
3176
  const [data, meta] = await this.request("GET", "/market/developer/portal");
3109
3177
  return {
@@ -3136,7 +3204,6 @@ var init_client = __esm({
3136
3204
  dry_run_supported: Boolean(data.dry_run_supported ?? false),
3137
3205
  approval_mode: stringOrNull2(data.approval_mode),
3138
3206
  required_connected_accounts: Array.isArray(data.required_connected_accounts) ? data.required_connected_accounts : [],
3139
- connected_accounts: Array.isArray(data.connected_accounts) ? data.connected_accounts.filter((item) => isRecord2(item)).map((item) => ({ ...item })) : [],
3140
3207
  stub_providers_enabled: Boolean(data.stub_providers_enabled ?? false),
3141
3208
  simulated_receipts: Boolean(data.simulated_receipts ?? false),
3142
3209
  approval_simulator: Boolean(data.approval_simulator ?? false),
@@ -4434,25 +4501,6 @@ var init_client = __esm({
4434
4501
  raw: { ...data }
4435
4502
  };
4436
4503
  }
4437
- async list_connected_accounts(options = {}) {
4438
- const params = {
4439
- provider_key: options.provider_key,
4440
- environment: options.environment,
4441
- limit: Math.max(1, Math.min(Math.trunc(options.limit ?? 50), 100)),
4442
- cursor: options.cursor
4443
- };
4444
- const [data, meta] = await this.request("GET", "/market/connected-accounts", { params });
4445
- const items = Array.isArray(data.items) ? data.items.filter((item) => isRecord2(item)).map(parseConnectedAccount) : [];
4446
- const next_cursor = stringOrNull2(data.next_cursor);
4447
- return new CursorPageResult({
4448
- items,
4449
- next_cursor,
4450
- limit: typeof data.limit === "number" ? data.limit : params.limit,
4451
- offset: typeof data.offset === "number" ? data.offset : null,
4452
- meta,
4453
- fetchNext: next_cursor ? (cursor) => this.list_connected_accounts({ ...options, cursor }) : void 0
4454
- });
4455
- }
4456
4504
  async create_support_case(subject, body, options = {}) {
4457
4505
  const summary = subject.trim();
4458
4506
  const details = body.trim();
@@ -6465,6 +6513,12 @@ var ListingCurrency = {
6465
6513
  USD: "USD",
6466
6514
  JPY: "JPY"
6467
6515
  };
6516
+ var PersistenceMode = {
6517
+ NONE: "none",
6518
+ LOCAL: "local",
6519
+ PLATFORM: "platform",
6520
+ DEVELOPER_SERVER: "developer_server"
6521
+ };
6468
6522
  var ToolManualPermissionClass = {
6469
6523
  READ_ONLY: "read_only",
6470
6524
  ACTION: "action",
@@ -7201,24 +7255,12 @@ var AppTestHarness = class {
7201
7255
  this.stubs = stubs;
7202
7256
  }
7203
7257
  async executeWithKind(execution_kind, task_type = "default", options = {}) {
7204
- const connected_accounts = options.connected_accounts ?? Object.fromEntries(
7205
- Object.keys(this.stubs).map((key) => [
7206
- key,
7207
- {
7208
- provider_key: key,
7209
- session_token: `stub-token-${key}`,
7210
- environment: Environment.SANDBOX,
7211
- scopes: []
7212
- }
7213
- ])
7214
- );
7215
7258
  const ctx = {
7216
7259
  agent_id: "test-agent-001",
7217
7260
  owner_user_id: "test-owner-001",
7218
7261
  task_type,
7219
7262
  environment: Environment.SANDBOX,
7220
7263
  execution_kind,
7221
- connected_accounts,
7222
7264
  input_params: options.input_params ?? {},
7223
7265
  trace_id: options.trace_id,
7224
7266
  idempotency_key: options.idempotency_key,
@@ -7308,12 +7350,6 @@ var AppTestHarness = class {
7308
7350
  }
7309
7351
  return issues;
7310
7352
  }
7311
- async simulate_connected_account_missing(task_type = "default", options = {}) {
7312
- return this.executeWithKind("dry_run", task_type, {
7313
- ...options,
7314
- connected_accounts: {}
7315
- });
7316
- }
7317
7353
  async simulate_metering(record, options = {}) {
7318
7354
  const { normalizeUsageRecord: normalizeUsageRecord2 } = await Promise.resolve().then(() => (init_metering(), metering_exports));
7319
7355
  const manifest = await this.app.manifest();
@@ -8789,6 +8825,7 @@ export {
8789
8825
  MeterClient,
8790
8826
  OpenAIProvider,
8791
8827
  PermissionClass,
8828
+ PersistenceMode,
8792
8829
  PriceModel,
8793
8830
  RecordMode,
8794
8831
  Recorder,