@acosmi/sdk-ts 1.3.0 → 1.3.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/dist/index.mjs CHANGED
@@ -1439,6 +1439,7 @@ var ScopeComplianceSealApprovalRequest = "compliance:seal_approval:request";
1439
1439
  var ScopeComplianceSealApprovalApprove = "compliance:seal_approval:approve";
1440
1440
  var ScopeComplianceSealUseExecute = "compliance:seal_use:execute";
1441
1441
  var ScopeComplianceReportsRead = "compliance:reports:read";
1442
+ var ScopeComplianceReportsWrite = "compliance:reports:write";
1442
1443
  var ScopeComplianceReportsPublish = "compliance:reports:publish";
1443
1444
  function allScopes() {
1444
1445
  return [ScopeAI, ScopeSkills, ScopeAccount];
@@ -1456,6 +1457,7 @@ function complianceScopes() {
1456
1457
  ScopeComplianceSealApprovalApprove,
1457
1458
  ScopeComplianceSealUseExecute,
1458
1459
  ScopeComplianceReportsRead,
1460
+ ScopeComplianceReportsWrite,
1459
1461
  ScopeComplianceReportsPublish
1460
1462
  ];
1461
1463
  }
@@ -3326,17 +3328,20 @@ var ComplianceClient = class {
3326
3328
  }
3327
3329
  /**
3328
3330
  * 公开 verify。隐私边界:返回字段不含 PII / 合同原文 / storage / provider raw。
3329
- * 服务端不要求 compliance scope(公开端点);但 SDK 仍带上 token 以便审计。
3331
+ *
3332
+ * 匿名可调用:未 login 时走匿名请求,不会抛 `not authorized, call login() first`。
3333
+ * 已 login / 已持有 token 时附带 `Authorization` 以保留审计上下文。public 端点不
3334
+ * 应要求认证 — 收到 401 直接抛 HTTPError,不触发 `forceRefresh`,也不做 refresh
3335
+ * replay。
3330
3336
  */
3331
3337
  verifyEvidencePublic(params, signal) {
3332
3338
  const q = new URLSearchParams();
3333
3339
  if (params.evidenceNo) q.set("evidenceNo", params.evidenceNo);
3334
3340
  if (params.publicVerifyCode) q.set("publicVerifyCode", params.publicVerifyCode);
3335
3341
  const qs = q.toString();
3336
- return this.read(
3342
+ return this.publicRead(
3337
3343
  "GET",
3338
3344
  `/compliance/evidence/verify${qs ? "?" + qs : ""}`,
3339
- null,
3340
3345
  signal
3341
3346
  );
3342
3347
  }
@@ -3420,9 +3425,10 @@ var ComplianceClient = class {
3420
3425
  /**
3421
3426
  * 发布报告(写,step-up 必须)。
3422
3427
  *
3423
- * 缺少 step-up 时服务端会返回 `COMPLIANCE_STEP_UP_REQUIRED`(数值码
3424
- * 1031000013)。SDK 不会自动重试;调用方需要引导用户重新做 OAuth introspection 或
3425
- * 重新登录后再次调用本方法(使用同一 idempotency-key)。
3428
+ * `@status gated` — step-up 闸门未闭合前服务端会一致返回
3429
+ * `COMPLIANCE_STEP_UP_REQUIRED`(数值码 1031000013)。SDK 不会自动重试、不伪成功;
3430
+ * 调用方需要引导用户重新做 OAuth introspection 或重新登录后再次调用本方法
3431
+ *(使用同一 idempotency-key)。方法状态分级见 `docs/compliance.md` Method Status。
3426
3432
  */
3427
3433
  publishReport(id, opts = {}) {
3428
3434
  return this.write(
@@ -3469,7 +3475,7 @@ var ComplianceClient = class {
3469
3475
  /**
3470
3476
  * 正式签署(写,step-up 必须)。
3471
3477
  *
3472
- * 服务端闸门关闭时会一致返回 `ENVELOPE_GATE_CLOSED` (1031004004)。
3478
+ * `@status gated` — 服务端闸门关闭时会一致返回 `ENVELOPE_GATE_CLOSED` (1031004004)。
3473
3479
  * SDK 不重试、不伪成功;调用方应该将该错误展示为"功能未开放"。
3474
3480
  */
3475
3481
  signEnvelope(envelopeId, req, opts = {}) {
@@ -3483,7 +3489,7 @@ var ComplianceClient = class {
3483
3489
  /**
3484
3490
  * 创建 H5 签署短链(写,step-up 必须)。
3485
3491
  *
3486
- * 同上:服务端闸门关闭时 SDK 不重试。
3492
+ * `@status gated` — 同 {@link signEnvelope}:服务端闸门关闭时 SDK 不重试、不伪成功。
3487
3493
  */
3488
3494
  createH5SigningUrl(envelopeId, req, opts = {}) {
3489
3495
  return this.write(
@@ -3505,6 +3511,13 @@ var ComplianceClient = class {
3505
3511
  // =========================================================================
3506
3512
  // Seal Approval
3507
3513
  // =========================================================================
3514
+ /**
3515
+ * 提交用印审批申请(写)。
3516
+ *
3517
+ * `@status production-ready` — 服务端以 `Idempotency-Key` + 业务请求指纹做重放保护:
3518
+ * 同 key + 同请求 → 返回原审批 id;同 key + 不同请求 → 拒绝复用幂等键。强烈建议调用方
3519
+ * 持久化 `idempotencyKey`,网络重试 / 任务恢复时复用,避免重复创建审批单。
3520
+ */
3508
3521
  submitSealApproval(req, opts = {}) {
3509
3522
  return this.write(
3510
3523
  "POST",
@@ -3513,6 +3526,12 @@ var ComplianceClient = class {
3513
3526
  writeCtx(opts)
3514
3527
  );
3515
3528
  }
3529
+ /**
3530
+ * 审批通过用印申请(写,step-up 必须)。
3531
+ *
3532
+ * `@status gated` — step-up 未闭合前服务端会返回 `COMPLIANCE_STEP_UP_REQUIRED`。
3533
+ * SDK 不重试、不伪成功。方法状态分级见 `docs/compliance.md` Method Status。
3534
+ */
3516
3535
  approveSealApproval(id, query, opts = {}) {
3517
3536
  const q = new URLSearchParams();
3518
3537
  if (query.expiresAt) q.set("expiresAt", query.expiresAt);
@@ -3610,6 +3629,38 @@ var ComplianceClient = class {
3610
3629
  extraHeaders
3611
3630
  });
3612
3631
  }
3632
+ /**
3633
+ * 公开读路径:public verify。
3634
+ *
3635
+ * 与 {@link read} 的区别 — public 端点不应要求认证:
3636
+ * - 无 token 时匿名请求:ensureToken 抛 `not authorized` 会被吞掉,继续匿名发送。
3637
+ * - 有 token 时附带 `Authorization`,保留后端审计上下文。
3638
+ * - 不做 401 refresh replay:401 直接抛 HTTPError,不触发 `forceRefresh`。
3639
+ *
3640
+ * URL 仍走 `client.complianceURL(path)`,不复用 `/api/v4`;底层复用
3641
+ * `client.doRequest`,不新增 fetch/axios 直连。
3642
+ */
3643
+ async publicRead(method, path, signal) {
3644
+ let token = "";
3645
+ try {
3646
+ token = await this.client.ensureToken(signal);
3647
+ } catch {
3648
+ }
3649
+ const url = this.client.complianceURL(path);
3650
+ const headers = { Accept: "application/json" };
3651
+ if (token) headers.Authorization = `Bearer ${token}`;
3652
+ const resp = await this.client.doRequest({ method, url, headers }, signal);
3653
+ if (resp.status < 200 || resp.status >= 300) {
3654
+ const bodyBytes = resp.body ? await readLimited(resp.body, maxErrorBodySize) : new Uint8Array();
3655
+ throw parseHTTPErrorWithHeader(resp.status, bodyBytes, resp.headers);
3656
+ }
3657
+ const text = await resp.text();
3658
+ if (!text) return void 0;
3659
+ const parsed = JSON.parse(text);
3660
+ const bizErr = apiResponseBusinessError(parsed);
3661
+ if (bizErr) throw bizErr;
3662
+ return parsed.data;
3663
+ }
3613
3664
  /**
3614
3665
  * 写路径:POST。
3615
3666
  * - 发送前 ensureToken 一次确保 token fresh。
@@ -5318,6 +5369,6 @@ Client.prototype.getBugReport = async function(bugID, signal) {
5318
5369
  return resp.data;
5319
5370
  };
5320
5371
 
5321
- export { AgentRunStreamError, AgentRunsClient, AnthropicAdapter, BucketClassCommercial, BucketClassGeneric, BusinessError, Client, ComplianceClient, CompliancePollError, DefaultRetryPolicy, ErrAuthDenied, ErrBillingCallbackCannotCommit, ErrBillingCommitRequiresLocalVerify, ErrBillingS2sForbidden, ErrBrowserOpen, ErrComplianceStepUpRequired, ErrDiscovery, ErrEnvelopeGateClosed, ErrProviderNotConfigured, ErrProviderUnknownNoRetry, ErrRegistration, ErrSSLProxy, ErrSealApprovalContractHashMismatch, ErrSealApprovalExpired, ErrSealApprovalLocationMismatch, ErrSealApprovalNonceUsed, ErrSealApprovalNotApproved, ErrSealApprovalSealMismatch, ErrSealApprovalTransactorMismatch, ErrSealUseAlreadyConsumed, ErrTimeout, ErrTokenExchange, EventAuthURL, EventComplete, EventError, FileTokenStore, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, HTTPError, InMemoryTokenStore, LocalStorageTokenStore, ModelNotFoundError, NetworkError, OpenAIAdapter, OrderTerminalError, ProviderFormat, RateLimitError, ScopeAI, ScopeAccount, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, ServerToolTypeWebSearch, StreamError, ThinkingHigh, ThinkingHighMinMaxTokens, ThinkingMax, ThinkingMaxFallbackMaxTokens, ThinkingOff, allScopes, anthropicResponseTextContent, anthropicResponseThinkingContent, anthropicResponseToolUseBlocks, apiResponseBusinessError, apiResponseGetMessage, authorize, bucketInfoIsCommercial, bucketRowIsCommercial, buildBetas, classifyComplianceError, commerceScopes, complianceScopes, computeBackoff, defaultRetryable, defaultSafeToRetry, discover, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, getAdapter, getAdapterForModel, isBillingConfirmable, isComplianceBusinessError, isComplianceTerminalError, isSSLError, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newThinkingConfig, newTokenSet, newWebSearchTool, parseNotificationEvent, parseSettlement, parseSourcesEvent, refreshToken, register, revokeToken, sanitize_exports as sanitize, skillScopes, tokenSetIsExpired, uniqueMerge };
5372
+ export { AgentRunStreamError, AgentRunsClient, AnthropicAdapter, BucketClassCommercial, BucketClassGeneric, BusinessError, Client, ComplianceClient, CompliancePollError, DefaultRetryPolicy, ErrAuthDenied, ErrBillingCallbackCannotCommit, ErrBillingCommitRequiresLocalVerify, ErrBillingS2sForbidden, ErrBrowserOpen, ErrComplianceStepUpRequired, ErrDiscovery, ErrEnvelopeGateClosed, ErrProviderNotConfigured, ErrProviderUnknownNoRetry, ErrRegistration, ErrSSLProxy, ErrSealApprovalContractHashMismatch, ErrSealApprovalExpired, ErrSealApprovalLocationMismatch, ErrSealApprovalNonceUsed, ErrSealApprovalNotApproved, ErrSealApprovalSealMismatch, ErrSealApprovalTransactorMismatch, ErrSealUseAlreadyConsumed, ErrTimeout, ErrTokenExchange, EventAuthURL, EventComplete, EventError, FileTokenStore, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, HTTPError, InMemoryTokenStore, LocalStorageTokenStore, ModelNotFoundError, NetworkError, OpenAIAdapter, OrderTerminalError, ProviderFormat, RateLimitError, ScopeAI, ScopeAccount, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, ServerToolTypeWebSearch, StreamError, ThinkingHigh, ThinkingHighMinMaxTokens, ThinkingMax, ThinkingMaxFallbackMaxTokens, ThinkingOff, allScopes, anthropicResponseTextContent, anthropicResponseThinkingContent, anthropicResponseToolUseBlocks, apiResponseBusinessError, apiResponseGetMessage, authorize, bucketInfoIsCommercial, bucketRowIsCommercial, buildBetas, classifyComplianceError, commerceScopes, complianceScopes, computeBackoff, defaultRetryable, defaultSafeToRetry, discover, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, getAdapter, getAdapterForModel, isBillingConfirmable, isComplianceBusinessError, isComplianceTerminalError, isSSLError, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newThinkingConfig, newTokenSet, newWebSearchTool, parseNotificationEvent, parseSettlement, parseSourcesEvent, refreshToken, register, revokeToken, sanitize_exports as sanitize, skillScopes, tokenSetIsExpired, uniqueMerge };
5322
5373
  //# sourceMappingURL=index.mjs.map
5323
5374
  //# sourceMappingURL=index.mjs.map