@acosmi/sdk-ts 2.6.0 → 2.7.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.
@@ -2251,6 +2251,53 @@ declare function parseRemoteControlEvent(raw: unknown): RemoteControlEvent | nul
2251
2251
  * 因此 `error` 本身不算 terminal, `done` 才是。
2252
2252
  */
2253
2253
  declare function isTerminalRemoteEvent(ev: RemoteControlEvent): boolean;
2254
+ /**
2255
+ * C 端/平台可下达的 permission 决策 (契约 §14)。
2256
+ *
2257
+ * 仅 `approved` | `rejected` — `timeout` / `cancelled` 由服务端 reaper/cancel
2258
+ * 路径产生, 客户端不可下达。
2259
+ */
2260
+ type RemotePermissionDecision = 'approved' | 'rejected';
2261
+ /** `agentRuns.submitPermissionResult()` 请求 — 回写 permission_request 的决策。 */
2262
+ interface RemotePermissionResultRequest {
2263
+ /** 对应 permission_request 事件的 requestId。 */
2264
+ requestId: string;
2265
+ decision: RemotePermissionDecision;
2266
+ /** 可选决策理由 (透传给 CrabCode control_response)。 */
2267
+ reason?: string;
2268
+ }
2269
+ /** `agentRuns.submitUserMessage()` 请求 — 会话中途追加用户消息 (Phase 5C 输入框)。 */
2270
+ interface RemoteUserMessageRequest {
2271
+ /** 消息正文; 服务端上限 64KB。Role 由服务端硬编码 'user' (契约 §6 #5 防注入)。 */
2272
+ content: string;
2273
+ /** 幂等键; 缺省由服务端生成并在 ack 中返回。 */
2274
+ requestId?: string;
2275
+ }
2276
+ /** `agentRuns.submitUserMessage()` 确认。 */
2277
+ interface RemoteUserMessageAck {
2278
+ ok: boolean;
2279
+ /** 服务端最终采用的幂等键 (请求未带时为服务端生成值)。 */
2280
+ requestId: string;
2281
+ }
2282
+ /**
2283
+ * `agentRuns.revealRemoteToken()` 响应 — desktop launcher 一次性 session token
2284
+ * (Phase 5B; 仅 runner='desktop')。
2285
+ *
2286
+ * 安全红线 (契约 §6): token 一次性消费 (重复调用 409), TTL ≤ 1h; 永不落
2287
+ * 浏览器存储 (localStorage/cookie), 应由 native 层接收后只注入 CrabCode
2288
+ * 子进程 env。
2289
+ */
2290
+ interface RemoteSessionTokenGrant {
2291
+ accessToken: string;
2292
+ /** CrabCode 回连的 RemoteIO WS 完整地址 (公网 wss 基址 + run 路径 + tenant_id)。 */
2293
+ sessionUrl: string;
2294
+ tenantId: string;
2295
+ /**
2296
+ * 用户在 metadata.workspace 声明的期望项目目录 (契约 §18.3 r4); 缺省 undefined。
2297
+ * 桌面端决定是否 chdir 采纳 (路径不存在/越权时回退并提示)。
2298
+ */
2299
+ workspace?: string;
2300
+ }
2254
2301
 
2255
2302
  type AgentRunStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
2256
2303
  /**
@@ -2269,6 +2316,17 @@ interface AgentRunArtifactPolicy {
2269
2316
  enabled?: boolean;
2270
2317
  maxFiles?: number;
2271
2318
  }
2319
+ /**
2320
+ * Run metadata 约定键 (契约 §18.3 r4, additive)。
2321
+ *
2322
+ * 服务端防滥用上限: ≤32 条 / 键 ≤64B / 值 ≤2KB (`validateAgentRunMetadata`)。
2323
+ * - `title` 列表显示标题; 缺省由服务端从 input 首行派生 (60 rune 截断)。
2324
+ * - `workspace` 用户声明的期望项目目录; desktop runner 经
2325
+ * `revealRemoteToken()` 响应的 `workspace` 字段回传, 由桌面 launcher
2326
+ * 决定是否 chdir 采纳 (路径不存在/越权时回退本机当前目录并提示)。
2327
+ */
2328
+ declare const AGENT_RUN_META_TITLE = "title";
2329
+ declare const AGENT_RUN_META_WORKSPACE = "workspace";
2272
2330
  interface AgentRunCreateRequest {
2273
2331
  appId: string;
2274
2332
  mode?: string;
@@ -2278,6 +2336,10 @@ interface AgentRunCreateRequest {
2278
2336
  model?: string;
2279
2337
  activeSkillIds?: string[];
2280
2338
  knowledgeBaseIds?: string[];
2339
+ /**
2340
+ * 自由 KV 元数据。远控 run 的约定键见 {@link AGENT_RUN_META_TITLE} /
2341
+ * {@link AGENT_RUN_META_WORKSPACE} (契约 §18.3 r4)。
2342
+ */
2281
2343
  metadata?: Record<string, string>;
2282
2344
  localContextPolicy?: AgentRunLocalContextPolicy;
2283
2345
  artifactPolicy?: AgentRunArtifactPolicy;
@@ -2286,6 +2348,12 @@ interface AgentRunCreateRequest {
2286
2348
  adapter?: AdapterKind;
2287
2349
  permissionPolicy?: PermissionPolicy;
2288
2350
  workspacePolicy?: WorkspacePolicy;
2351
+ /**
2352
+ * BYO 模型密钥公开引用 (契约 §18.2; 仅远控 runtime + runner='cloud')。
2353
+ * 只传 `crabcodeByok.create()` 返回的 credentialRef; 明文/密文绝不过此请求 —
2354
+ * 解密只发生在网关 launchCloudRunner 的子进程 env 注入点。
2355
+ */
2356
+ byokCredentialRef?: string;
2289
2357
  }
2290
2358
  /**
2291
2359
  * Narrow type for `agentRuns.createRemoteRun(req)`:
@@ -2309,6 +2377,27 @@ interface AgentRun {
2309
2377
  completedAt?: string;
2310
2378
  error?: AgentRunErrorPayload;
2311
2379
  metadata?: Record<string, string>;
2380
+ runtime?: AgentRunRuntime | string;
2381
+ runner?: RunnerKind | string;
2382
+ adapter?: AdapterKind | string;
2383
+ }
2384
+ /** `agentRuns.list()` 过滤/分页参数 (GET /agent-runs, Phase 5C 控制台)。 */
2385
+ interface AgentRunListOptions {
2386
+ /** 按 runtime 过滤, 例 'crabcode_remote' (远控控制台列表)。 */
2387
+ runtime?: AgentRunRuntime | string;
2388
+ /** 按状态过滤, 例 'running'。 */
2389
+ status?: AgentRunStatus | string;
2390
+ /** 页码, 1 起; 缺省 1。 */
2391
+ page?: number;
2392
+ /** 每页条数; 缺省 20, 服务端上限 100。 */
2393
+ pageSize?: number;
2394
+ }
2395
+ /** `agentRuns.list()` 结果 — 分页形状对齐 listConsumeRecords ({records,total,page,pageSize})。 */
2396
+ interface AgentRunListResult {
2397
+ records: AgentRun[];
2398
+ total: number;
2399
+ page: number;
2400
+ pageSize: number;
2312
2401
  }
2313
2402
  interface AgentRunCreateResponse {
2314
2403
  runId: string;
@@ -2461,6 +2550,13 @@ declare class AgentRunsClient {
2461
2550
  private readonly client;
2462
2551
  constructor(client: Client);
2463
2552
  create(req: AgentRunCreateRequest, signal?: AbortSignal): Promise<AgentRunCreateResponse>;
2553
+ /**
2554
+ * List the caller's own agent runs, newest first (GET /agent-runs, Phase 5C
2555
+ * console). Returns view metadata only — never session tokens, policies or
2556
+ * messages (contract §6). Filter remote-control runs with
2557
+ * `{ runtime: 'crabcode_remote' }`.
2558
+ */
2559
+ list(opts?: AgentRunListOptions, signal?: AbortSignal): Promise<AgentRunListResult>;
2464
2560
  get(runId: string, signal?: AbortSignal): Promise<AgentRun>;
2465
2561
  stream(runId: string, opts?: AgentRunStreamOptions, signal?: AbortSignal): AsyncIterable<AgentRunStreamEvent>;
2466
2562
  cancel(runId: string, signal?: AbortSignal): Promise<AgentRun>;
@@ -2491,6 +2587,35 @@ declare class AgentRunsClient {
2491
2587
  * matching `parseRemoteControlEvent`'s null-return contract.
2492
2588
  */
2493
2589
  streamRemoteControl(runId: string, signal?: AbortSignal): AsyncIterable<RemoteControlEvent>;
2590
+ /**
2591
+ * Submit a permission decision for a pending `permission_request` event
2592
+ * (POST /agent-runs/:runId/permission-results, contract §4/§9/§14).
2593
+ *
2594
+ * Only `approved` | `rejected` may be submitted by clients — `timeout` /
2595
+ * `cancelled` are produced server-side. Requires an OAuth token with the
2596
+ * explicit `remote_control` scope (or a web JWT). 409 means the remote
2597
+ * session is gone (e.g. already terminated).
2598
+ */
2599
+ submitPermissionResult(runId: string, result: RemotePermissionResultRequest, signal?: AbortSignal): Promise<void>;
2600
+ /**
2601
+ * Append a mid-session user message to a remote run
2602
+ * (POST /agent-runs/:runId/messages, Phase 5C). The message role is
2603
+ * hard-coded to 'user' server-side (contract §6 #5 prompt-injection
2604
+ * defence); content is limited to 64KB. Requires the explicit
2605
+ * `remote_control` scope (or a web JWT).
2606
+ */
2607
+ submitUserMessage(runId: string, message: RemoteUserMessageRequest, signal?: AbortSignal): Promise<RemoteUserMessageAck>;
2608
+ /**
2609
+ * Reveal the one-shot remote session token for a desktop-runner run
2610
+ * (POST /agent-runs/:runId/remote-token, Phase 5B; contract §18.1).
2611
+ *
2612
+ * Desktop launcher only: the token is single-consumption (a second call
2613
+ * returns 409) and must never touch browser storage — receive it in the
2614
+ * native layer and inject it into the CrabCode child-process env only
2615
+ * (contract §6). Cloud / local_embedded runners never expose tokens over
2616
+ * HTTP (403). Requires the explicit `remote_control` scope.
2617
+ */
2618
+ revealRemoteToken(runId: string, signal?: AbortSignal): Promise<RemoteSessionTokenGrant>;
2494
2619
  private streamRemoteControlGen;
2495
2620
  listArtifacts(runId: string, signal?: AbortSignal): Promise<AgentRunArtifact[]>;
2496
2621
  downloadArtifact(runId: string, artifactId: string, signal?: AbortSignal): Promise<AgentRunDownload>;
@@ -2506,6 +2631,54 @@ declare class AgentRunsClient {
2506
2631
  private requestRawInner;
2507
2632
  }
2508
2633
 
2634
+ /** 允许的第三方提供商 (与网关 byokAllowedProviders / managed_model Provider 谱系对齐)。 */
2635
+ type ByokProvider = 'anthropic' | 'openai' | 'deepseek' | 'dashscope' | 'zhipu' | 'volcengine' | 'custom';
2636
+ type ByokCredentialStatus = 'active' | 'revoked';
2637
+ /** BYOK 密钥 masked 视图 — 永不含明文/密文。 */
2638
+ interface ByokCredential {
2639
+ credentialRef: string;
2640
+ provider: ByokProvider | string;
2641
+ name?: string;
2642
+ /** 仅 provider='custom' 时存在 (https:// 起始)。 */
2643
+ baseUrl?: string;
2644
+ /** 明文指纹 (轮换后变化; 用于"是否同一把钥匙"的人工核对)。 */
2645
+ fingerprint?: string;
2646
+ status: ByokCredentialStatus | string;
2647
+ createdAt?: string;
2648
+ lastUsedAt?: string;
2649
+ }
2650
+ /** `crabcodeByok.create()` 请求。明文一次性提交, 服务端加密落库后即弃。 */
2651
+ interface ByokCreateRequest {
2652
+ provider: ByokProvider;
2653
+ /** API key 明文; ≤4KB, 不得含换行。 */
2654
+ plaintext: string;
2655
+ /** 显示名; ≤100 字符。 */
2656
+ name?: string;
2657
+ /** 仅 provider='custom' 必填 (必须 https://); 其他 provider 不可设。 */
2658
+ baseUrl?: string;
2659
+ }
2660
+ declare module '@acosmi/sdk-ts' {
2661
+ interface Client {
2662
+ /** CrabCode 远控 BYO 模型密钥管理面 (契约 §18.2)。 */
2663
+ readonly crabcodeByok: CrabCodeByokClient;
2664
+ }
2665
+ }
2666
+ declare class CrabCodeByokClient {
2667
+ private readonly client;
2668
+ constructor(client: Client);
2669
+ /** 列出调用者自己的密钥 (masked; 新→旧, 服务端上限 100 条)。 */
2670
+ list(signal?: AbortSignal): Promise<ByokCredential[]>;
2671
+ /**
2672
+ * 创建密钥 — 明文一次性提交, 返回 masked 视图。
2673
+ * 单用户上限 20 把; provider='custom' 必须带 https:// baseUrl。
2674
+ */
2675
+ create(req: ByokCreateRequest, signal?: AbortSignal): Promise<ByokCredential>;
2676
+ /** 轮换密钥明文 — credentialRef 不变, fingerprint 更新。已吊销的密钥不可轮换 (400)。 */
2677
+ rotate(credentialRef: string, newPlaintext: string, signal?: AbortSignal): Promise<ByokCredential>;
2678
+ /** 吊销密钥 (软状态 + 服务端抹密文, 不可恢复; 幂等 — 重复吊销返回当前视图)。 */
2679
+ revoke(credentialRef: string, signal?: AbortSignal): Promise<ByokCredential>;
2680
+ }
2681
+
2509
2682
  declare const ScopeComplianceEvidenceRead = "compliance:evidence:read";
2510
2683
  declare const ScopeComplianceEvidenceWrite = "compliance:evidence:write";
2511
2684
  declare const ScopeComplianceTimestampIssue = "compliance:timestamp:issue";
@@ -4696,8 +4869,7 @@ interface BridgeThreadRef {
4696
4869
  /**
4697
4870
  * ChatIntegration — 平台安装记录的 SDK 只读视图.
4698
4871
  *
4699
- * 注意: `configJson` 仅含非敏感配置 (rate limit / feature toggles); 严禁含 secret
4700
- * Phase 7B handler 落地后, SDK admin 子客户端会按此型号 GET。
4872
+ * Phase 7B 起由 `client.chatBridge` 按此型号 GET (响应 camelCase, 契约 §12)。
4701
4873
  */
4702
4874
  interface ChatIntegration {
4703
4875
  id: string;
@@ -4708,6 +4880,10 @@ interface ChatIntegration {
4708
4880
  workspaceIdHash?: string;
4709
4881
  botIdHash?: string;
4710
4882
  status: IntegrationStatus;
4883
+ /**
4884
+ * @deprecated 服务端从不返回此字段 (model ConfigJSON json:"-", 防 secret 误入
4885
+ * 后整体不外发) — 读取恒为 undefined。写入走 createIntegration({ configJson })。
4886
+ */
4711
4887
  configJson?: string;
4712
4888
  installedByUserId?: string;
4713
4889
  lastUsedAt?: string;
@@ -4803,4 +4979,53 @@ declare function isChannelInboundEvent(v: unknown): v is ChannelInboundEvent;
4803
4979
  */
4804
4980
  declare function asCredentialRef(s: string): CredentialRef;
4805
4981
 
4806
- export { ALL_INTEGRATION_STATUS, ALL_PLATFORMS, ALL_REGIONS, type APIResponse, type AdapterKind, type AgentRun, type AgentRunArtifact, type AgentRunArtifactList, type AgentRunArtifactPolicy, type AgentRunCreateRequest, type AgentRunCreateResponse, type AgentRunDownload, type AgentRunErrorPayload, type AgentRunLocalContextPolicy, type AgentRunLocalToolHandler, type AgentRunLocalToolHandlerContext, type AgentRunLocalToolResult, type AgentRunRemoteCreateRequest, type AgentRunRunOptions, type AgentRunRuntime, type AgentRunSettlement, type AgentRunStatus, AgentRunStreamError, type AgentRunStreamEvent, type AgentRunStreamOptions, type AgentRunUsage, type AgentRunWithLocalToolsOptions, AgentRunsClient, AnthropicResponse, type ApiClientRef, type ApproveSealApprovalQuery, type AssignSeatRequest, type Audience, AudienceEnum, type AuthorizeResult, type BalanceDetail, type BalanceDetailEntitlement, type BillingMode, BillingModeEnum, type BillingPreflightResult, type BlockMeta, type BookConsultationRequest, type BridgeThreadRef, type BrowserRefreshMode, type BugReportResult, type BugView, BusinessError, type BuyResponse, type CancelSealApprovalQuery, type CaseLead, type CaseMatter, type CertificationStatus, type ChannelAttachment, type ChannelCard, type ChannelCardAction, type ChannelInboundEvent, type ChannelOutboundEvent, type ChatBridgeSession, type ChatCredentialPublic, type ChatIntegration, ChatRequest, ChatResponse, type ChatThread, Client, type ClientRegistration, type ComplianceAssetType, type ComplianceBenefitType, type ComplianceBillingDisplayStatus, type ComplianceCapability, ComplianceClient, type ComplianceClientErrorCode, type ComplianceDigestSource, type ComplianceEnvelopeStatus, type ComplianceErrorInfo, type ComplianceErrorKey, type ComplianceHashAlgorithm, CompliancePollError, type CompliancePollOptions, type CompliancePrivacyLevel, type ComplianceProviderRequestStatus, type ComplianceProviderStatus, type ComplianceQuoteResponse, type ComplianceReport, type ComplianceScope, type ComplianceSealApprovalStatus, type ComplianceSku, type ComplianceTimestampVerificationStatus, type ComplianceWriteOptions, type Config, type ConsumeRecord, type ConsumeRecordPage, type ContractTemplateField, type ContractTemplateFieldType, type ContractTemplatePageItem, type ContractTemplateResp, type ContractTemplateStatus, type ContractTemplateVersion, type CorporateTransfer, type CreateContractTemplateRequest, type CreateEvidenceAssetRequest, type CreateH5SigningUrlRequest, type CreateReportRequest, type CreateSigningEnvelopeRequest, type CreateWebAuthorizationRequestOptions, type CredentialRef, DEFAULT_API_TIMEOUT_MS, DEFAULT_GATEWAY_BASE_URL, DefaultRetryPolicy, type DeviceRegistration, type EnterpriseKycMyStatusView, type EnterpriseMember, type EnterpriseSummary, type EntitlementBalance, type EntitlementItem, type EnvelopeContractItem, ErrAuthDenied, ErrBillingCallbackCannotCommit, ErrBillingCommitRequiresLocalVerify, ErrBillingS2sForbidden, ErrBrowserOpen, ErrComplianceStepUpRequired, ErrDiscovery, ErrEnvelopeGateClosed, ErrOAuthCORSBlocked, ErrProviderNotConfigured, ErrProviderUnknownNoRetry, ErrRefreshProxyFailed, ErrRegistration, ErrSSLProxy, ErrSealApprovalContractHashMismatch, ErrSealApprovalExpired, ErrSealApprovalLocationMismatch, ErrSealApprovalNonceUsed, ErrSealApprovalNotApproved, ErrSealApprovalSealMismatch, ErrSealApprovalTransactorMismatch, ErrSealUseAlreadyConsumed, ErrStateMismatch, ErrTimeout, ErrTokenExchange, ErrTokenExpired, EventAuthURL, EventComplete, EventError, type EvidenceAsset, type EvidenceAssetPageItem, type EvidencePackage, type EvidencePackagePageItem, type FeatureGateState, type FeatureGateStatus, FileTokenStore, type FilterStatus, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, type GateQuota, type GenerateSkillRequest, type GenerateSkillResult, HTTPError, type IdempotencyKey, IdempotencyKeyHeader, ImageGenerationRequest, ImageGenerationResponse, InMemoryTokenStore, type InitiateCorporateTransferInput, type InitiateCorporateTransferResult, InputModality, type IntegrationStatus, type InviteMemberRequest, type Invoice, type IssueTimestampRequest, type LawyerCredentialMyView, type LawyerSummary, type LegalConsultation, type LegalServiceOrder, type LegalServiceSku, type LegalSkuCode, type ListContractTemplatesRequest, type ListEvidenceAssetsRequest, type ListEvidencePackagesRequest, type ListOperationsRequest, type ListReportsRequest, type ListSealApprovalsRequest, type ListSealUsesRequest, type ListSigningEnvelopesRequest, type ListTimestampsRequest, LocalStorageTokenStore, type LoginErrCode, type LoginEvent, type LoginEventType, type LoginOptions, ManagedModel, type Membership, type ModelBucket, type ModelByQuotaResponse, ModelCapabilities, type ModelCoefficient, ModelNotFoundError, NetworkError, type Notification, type NotificationList, type NotificationPreference, type NotificationUnreadCount, type OAuthMetadataProfile, OAuthTokenEndpointError, type OpenAIChatChoice, type OpenAIChatMessage, type OpenAIChatResponse, type OpenAIFunctionCall, type OpenAIStreamChoice, type OpenAIStreamChunk, type OpenAIStreamDelta, type OpenAIStreamToolCall, type OpenAIToolCall, type OpenAIUsage, type OperationDetail, type OperationId, type OperationPageItem, type OperationSource, type OperationStatus, type OptimizeSkillRequest, type OptimizeSkillResult, type Order, type OrderListItem, type OrderStatus, OrderTerminalError, type OrgConsumeReport, type OrgSeat, type OrgSubscription, type PageRequest, type PageResult, type PayPayload, type PaymentMethod, type PermissionPolicy, type Platform, type PricingConfig, type PrincipalRef, type Product, type ProductFamily, ProductFamilyEnum, ProviderAdapter, type ProviderRequestStatus, type ProviderRequestStatusView, type PublicEvidenceVerifyResult, type PublicModelSummary, QuotaSummary, RETRY_ADVICE_REASONS, RateLimitError, type RefundPolicy, type RefundRecord, type Region, type RegionScope, RegionScopeEnum, type RegisterWebOAuthClientOptions, type RejectSealApprovalQuery, type RemoteControlDone, type RemoteControlError, type RemoteControlEvent, type RemoteControlEventType, type RemoteControlPermissionRequest, type RemoteControlPermissionResult, type RemoteControlReasoningDelta, type RemoteControlSettle, type RemoteControlStatus, type RemoteControlTextDelta, type RemoteControlToolCall, type RemoteControlToolResult, type RemoteControlUsage, type RemoteSessionPlacement, type RemoteSessionRef, type ReportDownload, type ReportPageItem, type ReqTimeoutCtl, type RequestInvoiceInput, type RequestRefundInput, type RetryAdvice, type RetryAdviceReason, type RetryPolicy, type RetryRequestInfo, type RolloverPolicy, type RunnerKind, ScopeAI, ScopeAccount, ScopeChatBridge, ScopeChatBridgeRead, ScopeChatBridgeRotate, ScopeChatBridgeWrite, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceContractTemplateRead, ScopeComplianceContractTemplateWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeRemoteControl, ScopeRemoteControlAgentRun, ScopeRemoteControlPermissionResponse, ScopeRemoteControlSessionControl, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, type SealApproval, type SealApprovalPageItem, type SealUsePageItem, type ServerMetadata, type SignEnvelopeRequest, type SigningEnvelope, type SigningEnvelopePageItem, type SkillBrowseListResponse, type SkillBrowseResponse, type SkillStoreItem, type SkillStoreListItem, type SkillStoreQuery, type SkillSummary, type SortDirection, SourcesEvent, type StepUpStatus, StreamError, StreamEvent, StreamSettlement, type SubmitCaseLeadRequest, type SubmitSealApprovalRequest, type SubscriptionAudience, type SubscriptionPlan, type SubscriptionTier, type TenantRef, type TimestampPageItem, type TimestampToken, type TimestampVerifyResult, type TokenPackage, type TokenResponse, type TokenSet, type TokenStore, type ToolListResponse, type ToolProvider, type ToolView, type Transaction, type TsaProvider, type TsaStats, type UpdateContractTemplateRequest, type UploadContractTemplatePdfRequest, type UserSubscription, type VerifyStatus, type VerifyTimestampRequest, VideoGenerationRequest, VideoTaskResponse, type VoidEnvelopeRequest, type WSConfig, type WSEvent, type WalletStats, type WebAuthorizationCallbackParams, type WebAuthorizationPending, type WebAuthorizationRequest, type WorkspacePolicy, type YudaoPageResult, allScopes, apiResponseBusinessError, apiResponseGetMessage, asCredentialRef, authorize, buildBetas, chatBridgeScopes, classifyComplianceError, commerceScopes, completeWebAuthorizationRequest, complianceErrorToRetryAdvice, complianceScopes, computeBackoff, createWebAuthorizationRequest, defaultRetryable, defaultSafeToRetry, discover, discoverWebOAuthMetadata, discoverWithProfile, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, generateState, isBillingConfirmable, isChannelInboundEvent, isComplianceBusinessError, isComplianceTerminalError, isIntegrationStatus, isInvalidGrantError, isPlatform, isRegion, isSSECommentLine, isSSLError, isTerminalRemoteEvent, isValidTokenSet, maxEndUserIdLength, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newTokenSet, normalizeGatewayBaseURL, normalizeOverrideBaseURL, parseNotificationEvent, parseRemoteControlEvent, refreshToken, register, registerWebOAuthClient, remoteControlScopes, retryReasonForComplianceKey, retryReasonForOAuthError, revokeToken, skillScopes, tokenSetIsExpired, uniqueMerge, validateEndUserId };
4982
+ /** `chatBridge.createIntegration()` 请求 (wire snake_case 由 SDK 转换)。 */
4983
+ interface CreateIntegrationRequest {
4984
+ /** 绑定的 Acosmi app。 */
4985
+ appId: string;
4986
+ platform: Platform;
4987
+ region: Region;
4988
+ /** 平台 workspace/企业 原始 ID; 服务端只存 SHA256 hash。 */
4989
+ workspaceId?: string;
4990
+ /** 平台 bot 原始 ID; 服务端只存 SHA256 hash。 */
4991
+ botId?: string;
4992
+ /** 仅非敏感配置 (rate limit / feature toggles); 严禁含 secret。 */
4993
+ configJson?: string;
4994
+ }
4995
+ /** `chatBridge.storeCredential()` 请求 — 明文一次性提交。 */
4996
+ interface StoreCredentialRequest {
4997
+ /** 凭证种类 (平台相关, 例: app_secret / signing_secret / bot_token)。 */
4998
+ secretKind: string;
4999
+ /** 凭证明文; 加密落库后即弃, 响应只回 masked 视图。 */
5000
+ plaintext: string;
5001
+ region?: Region;
5002
+ platform?: Platform;
5003
+ }
5004
+ declare module '@acosmi/sdk-ts' {
5005
+ interface Client {
5006
+ /** 第三方聊天 bridge 控制面 (Phase 7B; 契约 §6/§12/ADR-8)。 */
5007
+ readonly chatBridge: ChatBridgeClient;
5008
+ }
5009
+ }
5010
+ declare class ChatBridgeClient {
5011
+ private readonly client;
5012
+ constructor(client: Client);
5013
+ /** 创建平台集成 (chat_bridge:write)。云端控制台与下游 (CrabCode) 调的是同一端点/同一份数据。 */
5014
+ createIntegration(req: CreateIntegrationRequest, signal?: AbortSignal): Promise<ChatIntegration>;
5015
+ /** 列出本租户集成 (chat_bridge:read; masked 视图)。可按 appId 过滤。 */
5016
+ listIntegrations(appId?: string, signal?: AbortSignal): Promise<ChatIntegration[]>;
5017
+ /** 取单个集成 (chat_bridge:read)。不存在/跨租户一律 404。 */
5018
+ getIntegration(id: string, signal?: AbortSignal): Promise<ChatIntegration>;
5019
+ /** 更新集成状态 (chat_bridge:write): pending | active | suspended | revoked。 */
5020
+ updateIntegrationStatus(id: string, status: IntegrationStatus, signal?: AbortSignal): Promise<void>;
5021
+ /** 存凭证 (chat_bridge:write) — 明文一次性提交, 返回 masked 记录 (ref+fingerprint)。 */
5022
+ storeCredential(integrationId: string, req: StoreCredentialRequest, signal?: AbortSignal): Promise<ChatCredentialPublic>;
5023
+ /** 列出集成的凭证 (chat_bridge:read; masked, 永不含明文/密文)。 */
5024
+ listCredentials(integrationId: string, signal?: AbortSignal): Promise<ChatCredentialPublic[]>;
5025
+ /** 轮换凭证 (chat_bridge:rotate, 高风险) — ref 不变, fingerprint 更新。 */
5026
+ rotateCredential(integrationId: string, secretKind: string, newPlaintext: string, signal?: AbortSignal): Promise<ChatCredentialPublic>;
5027
+ /** 吊销凭证 (chat_bridge:rotate) — 软吊销 + 服务端抹密文。 */
5028
+ revokeCredential(credentialRef: string, signal?: AbortSignal): Promise<void>;
5029
+ }
5030
+
5031
+ export { AGENT_RUN_META_TITLE, AGENT_RUN_META_WORKSPACE, ALL_INTEGRATION_STATUS, ALL_PLATFORMS, ALL_REGIONS, type APIResponse, type AdapterKind, type AgentRun, type AgentRunArtifact, type AgentRunArtifactList, type AgentRunArtifactPolicy, type AgentRunCreateRequest, type AgentRunCreateResponse, type AgentRunDownload, type AgentRunErrorPayload, type AgentRunListOptions, type AgentRunListResult, type AgentRunLocalContextPolicy, type AgentRunLocalToolHandler, type AgentRunLocalToolHandlerContext, type AgentRunLocalToolResult, type AgentRunRemoteCreateRequest, type AgentRunRunOptions, type AgentRunRuntime, type AgentRunSettlement, type AgentRunStatus, AgentRunStreamError, type AgentRunStreamEvent, type AgentRunStreamOptions, type AgentRunUsage, type AgentRunWithLocalToolsOptions, AgentRunsClient, AnthropicResponse, type ApiClientRef, type ApproveSealApprovalQuery, type AssignSeatRequest, type Audience, AudienceEnum, type AuthorizeResult, type BalanceDetail, type BalanceDetailEntitlement, type BillingMode, BillingModeEnum, type BillingPreflightResult, type BlockMeta, type BookConsultationRequest, type BridgeThreadRef, type BrowserRefreshMode, type BugReportResult, type BugView, BusinessError, type BuyResponse, type ByokCreateRequest, type ByokCredential, type ByokCredentialStatus, type ByokProvider, type CancelSealApprovalQuery, type CaseLead, type CaseMatter, type CertificationStatus, type ChannelAttachment, type ChannelCard, type ChannelCardAction, type ChannelInboundEvent, type ChannelOutboundEvent, ChatBridgeClient, type ChatBridgeSession, type ChatCredentialPublic, type ChatIntegration, ChatRequest, ChatResponse, type ChatThread, Client, type ClientRegistration, type ComplianceAssetType, type ComplianceBenefitType, type ComplianceBillingDisplayStatus, type ComplianceCapability, ComplianceClient, type ComplianceClientErrorCode, type ComplianceDigestSource, type ComplianceEnvelopeStatus, type ComplianceErrorInfo, type ComplianceErrorKey, type ComplianceHashAlgorithm, CompliancePollError, type CompliancePollOptions, type CompliancePrivacyLevel, type ComplianceProviderRequestStatus, type ComplianceProviderStatus, type ComplianceQuoteResponse, type ComplianceReport, type ComplianceScope, type ComplianceSealApprovalStatus, type ComplianceSku, type ComplianceTimestampVerificationStatus, type ComplianceWriteOptions, type Config, type ConsumeRecord, type ConsumeRecordPage, type ContractTemplateField, type ContractTemplateFieldType, type ContractTemplatePageItem, type ContractTemplateResp, type ContractTemplateStatus, type ContractTemplateVersion, type CorporateTransfer, CrabCodeByokClient, type CreateContractTemplateRequest, type CreateEvidenceAssetRequest, type CreateH5SigningUrlRequest, type CreateIntegrationRequest, type CreateReportRequest, type CreateSigningEnvelopeRequest, type CreateWebAuthorizationRequestOptions, type CredentialRef, DEFAULT_API_TIMEOUT_MS, DEFAULT_GATEWAY_BASE_URL, DefaultRetryPolicy, type DeviceRegistration, type EnterpriseKycMyStatusView, type EnterpriseMember, type EnterpriseSummary, type EntitlementBalance, type EntitlementItem, type EnvelopeContractItem, ErrAuthDenied, ErrBillingCallbackCannotCommit, ErrBillingCommitRequiresLocalVerify, ErrBillingS2sForbidden, ErrBrowserOpen, ErrComplianceStepUpRequired, ErrDiscovery, ErrEnvelopeGateClosed, ErrOAuthCORSBlocked, ErrProviderNotConfigured, ErrProviderUnknownNoRetry, ErrRefreshProxyFailed, ErrRegistration, ErrSSLProxy, ErrSealApprovalContractHashMismatch, ErrSealApprovalExpired, ErrSealApprovalLocationMismatch, ErrSealApprovalNonceUsed, ErrSealApprovalNotApproved, ErrSealApprovalSealMismatch, ErrSealApprovalTransactorMismatch, ErrSealUseAlreadyConsumed, ErrStateMismatch, ErrTimeout, ErrTokenExchange, ErrTokenExpired, EventAuthURL, EventComplete, EventError, type EvidenceAsset, type EvidenceAssetPageItem, type EvidencePackage, type EvidencePackagePageItem, type FeatureGateState, type FeatureGateStatus, FileTokenStore, type FilterStatus, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, type GateQuota, type GenerateSkillRequest, type GenerateSkillResult, HTTPError, type IdempotencyKey, IdempotencyKeyHeader, ImageGenerationRequest, ImageGenerationResponse, InMemoryTokenStore, type InitiateCorporateTransferInput, type InitiateCorporateTransferResult, InputModality, type IntegrationStatus, type InviteMemberRequest, type Invoice, type IssueTimestampRequest, type LawyerCredentialMyView, type LawyerSummary, type LegalConsultation, type LegalServiceOrder, type LegalServiceSku, type LegalSkuCode, type ListContractTemplatesRequest, type ListEvidenceAssetsRequest, type ListEvidencePackagesRequest, type ListOperationsRequest, type ListReportsRequest, type ListSealApprovalsRequest, type ListSealUsesRequest, type ListSigningEnvelopesRequest, type ListTimestampsRequest, LocalStorageTokenStore, type LoginErrCode, type LoginEvent, type LoginEventType, type LoginOptions, ManagedModel, type Membership, type ModelBucket, type ModelByQuotaResponse, ModelCapabilities, type ModelCoefficient, ModelNotFoundError, NetworkError, type Notification, type NotificationList, type NotificationPreference, type NotificationUnreadCount, type OAuthMetadataProfile, OAuthTokenEndpointError, type OpenAIChatChoice, type OpenAIChatMessage, type OpenAIChatResponse, type OpenAIFunctionCall, type OpenAIStreamChoice, type OpenAIStreamChunk, type OpenAIStreamDelta, type OpenAIStreamToolCall, type OpenAIToolCall, type OpenAIUsage, type OperationDetail, type OperationId, type OperationPageItem, type OperationSource, type OperationStatus, type OptimizeSkillRequest, type OptimizeSkillResult, type Order, type OrderListItem, type OrderStatus, OrderTerminalError, type OrgConsumeReport, type OrgSeat, type OrgSubscription, type PageRequest, type PageResult, type PayPayload, type PaymentMethod, type PermissionPolicy, type Platform, type PricingConfig, type PrincipalRef, type Product, type ProductFamily, ProductFamilyEnum, ProviderAdapter, type ProviderRequestStatus, type ProviderRequestStatusView, type PublicEvidenceVerifyResult, type PublicModelSummary, QuotaSummary, RETRY_ADVICE_REASONS, RateLimitError, type RefundPolicy, type RefundRecord, type Region, type RegionScope, RegionScopeEnum, type RegisterWebOAuthClientOptions, type RejectSealApprovalQuery, type RemoteControlDone, type RemoteControlError, type RemoteControlEvent, type RemoteControlEventType, type RemoteControlPermissionRequest, type RemoteControlPermissionResult, type RemoteControlReasoningDelta, type RemoteControlSettle, type RemoteControlStatus, type RemoteControlTextDelta, type RemoteControlToolCall, type RemoteControlToolResult, type RemoteControlUsage, type RemotePermissionDecision, type RemotePermissionResultRequest, type RemoteSessionPlacement, type RemoteSessionRef, type RemoteSessionTokenGrant, type RemoteUserMessageAck, type RemoteUserMessageRequest, type ReportDownload, type ReportPageItem, type ReqTimeoutCtl, type RequestInvoiceInput, type RequestRefundInput, type RetryAdvice, type RetryAdviceReason, type RetryPolicy, type RetryRequestInfo, type RolloverPolicy, type RunnerKind, ScopeAI, ScopeAccount, ScopeChatBridge, ScopeChatBridgeRead, ScopeChatBridgeRotate, ScopeChatBridgeWrite, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceContractTemplateRead, ScopeComplianceContractTemplateWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeRemoteControl, ScopeRemoteControlAgentRun, ScopeRemoteControlPermissionResponse, ScopeRemoteControlSessionControl, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, type SealApproval, type SealApprovalPageItem, type SealUsePageItem, type ServerMetadata, type SignEnvelopeRequest, type SigningEnvelope, type SigningEnvelopePageItem, type SkillBrowseListResponse, type SkillBrowseResponse, type SkillStoreItem, type SkillStoreListItem, type SkillStoreQuery, type SkillSummary, type SortDirection, SourcesEvent, type StepUpStatus, type StoreCredentialRequest, StreamError, StreamEvent, StreamSettlement, type SubmitCaseLeadRequest, type SubmitSealApprovalRequest, type SubscriptionAudience, type SubscriptionPlan, type SubscriptionTier, type TenantRef, type TimestampPageItem, type TimestampToken, type TimestampVerifyResult, type TokenPackage, type TokenResponse, type TokenSet, type TokenStore, type ToolListResponse, type ToolProvider, type ToolView, type Transaction, type TsaProvider, type TsaStats, type UpdateContractTemplateRequest, type UploadContractTemplatePdfRequest, type UserSubscription, type VerifyStatus, type VerifyTimestampRequest, VideoGenerationRequest, VideoTaskResponse, type VoidEnvelopeRequest, type WSConfig, type WSEvent, type WalletStats, type WebAuthorizationCallbackParams, type WebAuthorizationPending, type WebAuthorizationRequest, type WorkspacePolicy, type YudaoPageResult, allScopes, apiResponseBusinessError, apiResponseGetMessage, asCredentialRef, authorize, buildBetas, chatBridgeScopes, classifyComplianceError, commerceScopes, completeWebAuthorizationRequest, complianceErrorToRetryAdvice, complianceScopes, computeBackoff, createWebAuthorizationRequest, defaultRetryable, defaultSafeToRetry, discover, discoverWebOAuthMetadata, discoverWithProfile, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, generateState, isBillingConfirmable, isChannelInboundEvent, isComplianceBusinessError, isComplianceTerminalError, isIntegrationStatus, isInvalidGrantError, isPlatform, isRegion, isSSECommentLine, isSSLError, isTerminalRemoteEvent, isValidTokenSet, maxEndUserIdLength, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newTokenSet, normalizeGatewayBaseURL, normalizeOverrideBaseURL, parseNotificationEvent, parseRemoteControlEvent, refreshToken, register, registerWebOAuthClient, remoteControlScopes, retryReasonForComplianceKey, retryReasonForOAuthError, revokeToken, skillScopes, tokenSetIsExpired, uniqueMerge, validateEndUserId };