# 豆包智能服务的端能力 API: 基础

账号、授权、豆包客户端信息、窗口信息和能力可用性。

[返回目录](./groups.md) | [返回速查](./quick-reference.md)

## 速查

| API | 说明 |
| --- | --- |
| [getAccountInfo](#getaccountinfo) | 异步获取账号信息。 |
| [getAccountInfoSync](#getaccountinfosync) | 同步获取账号信息。<br><br>同步 API。 |
| [authorize](#authorize) | 提前向用户发起指定 scope 的应用授权。 |
| [getPerformance](#getperformance) | 获取当前智能服务应用的性能数据。 Entry 由客户端保存；getEntries*() 同步查询当前快照，observer 只接收新完成的 Entry。 |
| [getSetting](#getsetting) | 获取用户当前的应用授权设置。 |
| [openSetting](#opensetting) | 打开智能服务授权设置页面。 |

## API 详情

<a id="getaccountinfo"></a>
### getAccountInfo()

# getAccountInfo

异步获取账号信息。

## 扫码预览
![扫码预览 getAccountInfo](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fget-account-info%252Findex)

## 使用限制

> [!WARNING]
> **Android、iOS**：仅返回 develop 或 release，永远不会返回 trial；依赖 trial 判断体验版环境的逻辑不会生效。

## 支持版本

前端库版本不低于 `0.0.18`。

## 支持平台

<table>
<thead>
<tr><th>平台</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>Android</td><td>支持</td></tr>
<tr><td>iOS</td><td>支持</td></tr>
<tr><td>PC</td><td>不支持</td></tr>
<tr><td>HarmonyOS</td><td>不支持</td></tr>
</tbody>
</table>

## 调用方式

### 异步 API

```typescript
getAccountInfo(params?: object): Promise<GetAccountInfoResult>
```

## 入参

无。

## 调用示例

```typescript
import { getAccountInfo } from '@doubao-dev/framework/api';

const result = await getAccountInfo();
console.log(result.miniProgram.appId, result.miniProgram.envVersion, result.miniProgram.version);
```

## 成功返回

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必返</th><th>约束</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>miniProgram</code></td><td><code>DoubaoAppAccountInfo</code></td><td>是</td><td>-</td><td>豆包 App 账号信息</td></tr>
<tr><td><code>miniProgram.appId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>豆包 App appId</td></tr>
<tr><td><code>miniProgram.envVersion</code></td><td><code>&quot;develop&quot; | &quot;trial&quot; | &quot;release&quot;</code></td><td>是</td><td>豆包 Android、iOS 当前只返回 develop 或 release，不会返回 trial</td><td>豆包 App 运行环境。<br><br>- develop：开发版<br>- trial：体验版<br>- release：正式版。Android、iOS：仅返回 develop 或 release，永远不会返回 trial。</td></tr>
<tr><td><code>miniProgram.version</code></td><td><code>string</code></td><td>是</td><td>-</td><td>线上豆包 App 版本号。</td></tr>
<tr><td><code>plugin</code></td><td><code>PluginAccountInfo</code></td><td>否</td><td>-</td><td>插件账号信息（仅在插件中调用时包含）</td></tr>
<tr><td><code>plugin.appId</code></td><td><code>string</code></td><td>否</td><td>-</td><td>插件 appId</td></tr>
<tr><td><code>plugin.version</code></td><td><code>string</code></td><td>否</td><td>-</td><td>插件版本号，'a.b.c' 形式</td></tr>
</tbody>
</table>

### 返回示例

```json
{
  "miniProgram": {
    "appId": "7000000000000000000",
    "envVersion": "release",
    "version": "1.0.0"
  }
}
```

## 错误处理

错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。

### 错误码

#### 通用错误码

<table>
<thead>
<tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
</thead>
<tbody>
<tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android</td></tr>
</tbody>
</table>

<a id="getaccountinfosync"></a>
### getAccountInfoSync()

# getAccountInfoSync

同步获取账号信息。

## 扫码预览
![扫码预览 getAccountInfoSync](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fget-account-info%252Findex)

## 使用限制

> [!WARNING]
> **Android、iOS**：仅返回 develop 或 release，永远不会返回 trial；依赖 trial 判断体验版环境的逻辑不会生效。

## 支持版本

前端库版本不低于 `0.0.18`。

## 支持平台

<table>
<thead>
<tr><th>平台</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>Android</td><td>支持</td></tr>
<tr><td>iOS</td><td>支持</td></tr>
<tr><td>PC</td><td>不支持</td></tr>
<tr><td>HarmonyOS</td><td>不支持</td></tr>
</tbody>
</table>

## 调用方式

### 同步 API

```typescript
getAccountInfoSync(params?: object): GetAccountInfoResult
```

## 入参

无。

## 调用示例

```typescript
import { getAccountInfoSync } from '@doubao-dev/framework/api';

const result = getAccountInfoSync();
console.log(result.miniProgram.appId, result.miniProgram.envVersion, result.miniProgram.version);
```

## 返回值

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必返</th><th>约束</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>miniProgram</code></td><td><code>DoubaoAppAccountInfo</code></td><td>是</td><td>-</td><td>豆包 App 账号信息</td></tr>
<tr><td><code>miniProgram.appId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>豆包 App appId</td></tr>
<tr><td><code>miniProgram.envVersion</code></td><td><code>&quot;develop&quot; | &quot;trial&quot; | &quot;release&quot;</code></td><td>是</td><td>豆包 Android、iOS 当前只返回 develop 或 release，不会返回 trial</td><td>豆包 App 运行环境。<br><br>- develop：开发版<br>- trial：体验版<br>- release：正式版。Android、iOS：仅返回 develop 或 release，永远不会返回 trial。</td></tr>
<tr><td><code>miniProgram.version</code></td><td><code>string</code></td><td>是</td><td>-</td><td>线上豆包 App 版本号。</td></tr>
<tr><td><code>plugin</code></td><td><code>PluginAccountInfo</code></td><td>否</td><td>-</td><td>插件账号信息（仅在插件中调用时包含）</td></tr>
<tr><td><code>plugin.appId</code></td><td><code>string</code></td><td>否</td><td>-</td><td>插件 appId</td></tr>
<tr><td><code>plugin.version</code></td><td><code>string</code></td><td>否</td><td>-</td><td>插件版本号，'a.b.c' 形式</td></tr>
</tbody>
</table>

### 返回示例

```json
{
  "miniProgram": {
    "appId": "7000000000000000000",
    "envVersion": "release",
    "version": "1.0.0"
  }
}
```

## 错误处理

同步调用失败时抛出错误。错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。

### 错误码

#### 通用错误码

<table>
<thead>
<tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
</thead>
<tbody>
<tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android</td></tr>
</tbody>
</table>

<a id="authorize"></a>
### authorize()

# authorize

提前向用户发起指定 scope 的应用授权。

## 扫码预览
![扫码预览 authorize](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fauthorize%252Findex)

## 使用限制

> [!WARNING]
> **Android、iOS**：传入 scope.payment 时被判为非法 scope 并直接失败；依赖 scope.payment 发起授权的调用无法成功。

## 支持版本

前端库版本不低于 `0.0.18`。

## 支持平台

<table>
<thead>
<tr><th>平台</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>Android</td><td>支持</td></tr>
<tr><td>iOS</td><td>支持</td></tr>
<tr><td>PC</td><td>不支持</td></tr>
<tr><td>HarmonyOS</td><td>不支持</td></tr>
</tbody>
</table>

## 接入准备

### 权限要求

<table>
<thead>
<tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td>应用权限</td><td><code>传入的 scope</code></td><td>必须</td><td>Android、iOS</td><td>按传入 scope 发起对应的应用授权。</td></tr>
</tbody>
</table>

### 授权行为

- 调用会主动向用户发起指定 scope 的授权弹窗。用户拒绝、取消或此前已撤销授权时调用直接失败，可再次调用 `authorize` 重新发起；scope 未在应用权限声明中配置或不受支持时也会失败。

### 前置条件

- 在应用权限声明中配置需要申请的 scope

## 使用说明

- 授权状态可通过 `getSetting` 查询；建议在真正需要能力前再发起授权。

## 调用方式

### 异步 API

```typescript
authorize(params: AuthorizeRequest): Promise<object>
```

## 入参

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>scope</code></td><td><code>Scope</code></td><td>是</td><td>-</td><td>豆包 Android、iOS 当前不支持 scope.payment，传入后授权会失败</td><td>授权范围。Android、iOS：传入 scope.payment 时被判为非法 scope 并直接失败。</td></tr>
</tbody>
</table>

## 调用示例

```typescript
import { authorize } from '@doubao-dev/framework/api';

await authorize({ scope: 'scope.userLocation' });
```

## 成功返回

无返回字段。

## 错误处理

错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。

### 失败示例

```json
{
  "errNo": 107,
  "errMsg": "user permission denied"
}
```

### 错误码

<table>
<thead>
<tr><th>errNo</th><th>errMsg</th><th>平台</th><th>触发条件</th><th>处理建议</th></tr>
</thead>
<tbody>
<tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>Android、iOS</td><td>传入的 scope 为空或不受支持（如 scope.payment）</td><td>检查并传入受支持的 scope 后重试。</td></tr>
<tr><td><code>106</code></td><td><code>system permission denied</code></td><td>Android、iOS</td><td>对应能力的系统权限被拒绝</td><td>引导用户在系统设置中开启对应权限后重试。</td></tr>
<tr><td><code>107</code></td><td><code>user permission denied</code></td><td>Android、iOS</td><td>用户拒绝了本次应用授权</td><td>说明能力用途后再次调用 `authorize` 重新发起授权。</td></tr>
<tr><td><code>114</code></td><td><code>operation cancelled</code></td><td>Android、iOS</td><td>用户取消了授权弹窗</td><td>用户需要时可再次调用 `authorize` 重新发起授权。</td></tr>
<tr><td><code>301</code></td><td><code>network request cancelled</code></td><td>iOS</td><td>授权过程中的网络请求被取消</td><td>确认应用和网络状态后重试。</td></tr>
<tr><td><code>302</code></td><td><code>connection timed out</code></td><td>iOS</td><td>授权过程中的网络连接超时</td><td>检查网络连接后重试。</td></tr>
<tr><td><code>303</code></td><td><code>no network connection</code></td><td>iOS</td><td>当前无可用网络连接</td><td>恢复网络连接后重试。</td></tr>
<tr><td><code>305</code></td><td><code>network failure</code></td><td>Android、iOS</td><td>授权过程中发生其他网络错误</td><td>检查网络连接，稍后重试。</td></tr>
<tr><td><code>112</code></td><td><code>invalid result</code></td><td>iOS</td><td>授权服务返回的数据无法解析</td><td>稍后重试；持续失败时反馈服务端响应异常。</td></tr>
</tbody>
</table>

#### 通用错误码

<table>
<thead>
<tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
</thead>
<tbody>
<tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
</tbody>
</table>

## 平台差异

- **iOS**：网络类失败会细分为 301/302/303/305，并可能返回 112；Android 的网络类失败统一返回 305。

<a id="getperformance"></a>
### getPerformance()

# getPerformance

获取当前智能服务应用的性能数据。

Entry 由客户端保存；`getEntries*()` 同步查询当前快照，observer 只接收新完成的 Entry。

## 支持版本

前端库版本不低于 `0.0.42`。

## 支持平台

<table>
<thead>
<tr><th>平台</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>Android</td><td>支持</td></tr>
<tr><td>iOS</td><td>不支持</td></tr>
<tr><td>PC</td><td>不支持</td></tr>
<tr><td>HarmonyOS</td><td>不支持</td></tr>
</tbody>
</table>

## 使用说明

- 仅在需要接收后续新完成的 Entry 时创建 observer；不再需要时调用 disconnect。

## 调用方式

### 同步 API

```typescript
getPerformance(): Performance
```

## 入参

无。

## 调用示例

```typescript
import { getPerformance } from '@doubao-dev/framework/api';

const performance = getPerformance();
const observer = performance.createObserver((entryList) => {
  console.log(entryList.getEntries());
});

performance.setBufferSize(100);
observer.observe({ entryTypes: ['render'] });
console.log(performance.getEntriesByType('render'));
observer.disconnect();
```

## 返回值

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>createObserver</code></td><td><code>(callback: PerformanceObserverCallback) =&gt; PerformanceObserver</code></td><td>是</td><td>创建性能观察者。调用返回对象的 `observe` 后，回调会接收之后新完成且匹配的 Entry。</td></tr>
<tr><td><code>getEntries</code></td><td><code>() =&gt; PerformanceEntry[]</code></td><td>是</td><td>返回当前智能服务已记录的全部性能 Entry。</td></tr>
<tr><td><code>getEntriesByName</code></td><td><code>(name: string, entryType?: string) =&gt; PerformanceEntry[]</code></td><td>是</td><td>返回指定名称的性能 Entry；传入 entryType 时同时按类型筛选。</td></tr>
<tr><td><code>getEntriesByType</code></td><td><code>(entryType: string) =&gt; PerformanceEntry[]</code></td><td>是</td><td>返回指定 entryType 的性能 Entry。</td></tr>
<tr><td><code>setBufferSize</code></td><td><code>(size: number) =&gt; void</code></td><td>是</td><td>设置客户端最多保留的性能 Entry 数量。</td></tr>
</tbody>
</table>

### 返回示例

```json
[
  {
    "entryType": "render",
    "name": "firstRender",
    "startTime": 1730000000000,
    "duration": 42,
    "path": "pages/index/index",
    "pageId": 1
  }
]
```

<a id="getsetting"></a>
### getSetting()

# getSetting

获取用户当前的应用授权设置。

## 扫码预览
![扫码预览 getSetting](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fget-setting%252Findex)

## 支持版本

前端库版本不低于 `0.0.36`。

## 支持平台

<table>
<thead>
<tr><th>平台</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>Android</td><td>支持</td></tr>
<tr><td>iOS</td><td>支持</td></tr>
<tr><td>PC</td><td>不支持</td></tr>
<tr><td>HarmonyOS</td><td>不支持</td></tr>
</tbody>
</table>

## 使用说明

- authSetting 只包含已向用户请求过且状态明确的权限；豆包当前不支持订阅模板，不要传入 withSubscriptions: true。

## 调用方式

### 异步 API

```typescript
getSetting(params?: GetSettingParams): Promise<GetSettingResult>
```

## 入参

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>withSubscriptions</code></td><td><code>false</code></td><td>否</td><td><code>false</code></td><td>豆包 Android、iOS 当前不支持订阅模板，仅支持 false</td><td>是否同时获取用户订阅消息的订阅状态；当前仅支持 false。</td></tr>
</tbody>
</table>

## 调用示例

```typescript
import { getSetting } from '@doubao-dev/framework/api';

const result = await getSetting();
console.log(result.authSetting['scope.userLocation']);
```

## 成功返回

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>authSetting</code></td><td><code>AuthSetting</code></td><td>是</td><td>用户授权结果，key 为权限 scope，value 表示是否已授权</td></tr>
<tr><td><code>subscriptionsSetting</code></td><td><code>SubscriptionsSetting</code></td><td>否</td><td>预留的订阅消息设置字段。豆包当前仅支持 `withSubscriptions: false`，因此不会返回该字段。</td></tr>
<tr><td><code>subscriptionsSetting.itemSettings</code></td><td><code>Record&lt;string, SubscriptionSettingStatus&gt;</code></td><td>否</td><td>一次性订阅消息模板的订阅状态</td></tr>
<tr><td><code>subscriptionsSetting.mainSwitch</code></td><td><code>boolean</code></td><td>否</td><td>设置页订阅消息总开关</td></tr>
<tr><td><code>subscriptionsSetting.templateSettings</code></td><td><code>Record&lt;string, SubscriptionTemplateSetting&gt;</code></td><td>否</td><td>模板订阅状态</td></tr>
</tbody>
</table>

### 返回示例

```json
{
  "authSetting": {
    "scope.userLocation": true,
    "scope.record": false
  }
}
```

## 错误处理

错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。

### 失败示例

```json
{
  "errNo": 103,
  "errMsg": "feature not support"
}
```

### 错误码

<table>
<thead>
<tr><th>errNo</th><th>errMsg</th><th>平台</th><th>触发条件</th><th>处理建议</th></tr>
</thead>
<tbody>
<tr><td><code>103</code></td><td><code>feature not support</code></td><td>Android、iOS</td><td>传入 withSubscriptions: true，豆包当前不支持订阅消息模板</td><td>不要传入 withSubscriptions: true，仅使用默认的 false</td></tr>
<tr><td><code>116</code></td><td><code>resource not found</code></td><td>Android</td><td>未找到当前应用对应的运行环境记录</td><td>确认应用已正确安装并在有效运行环境中调用后重试</td></tr>
</tbody>
</table>

#### 通用错误码

<table>
<thead>
<tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
</thead>
<tbody>
<tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
</tbody>
</table>

## 平台差异

- **iOS**：iOS 不返回 errNo 116（resource not found），相应失败场景统一以 errNo 102（internal error）返回。

<a id="opensetting"></a>
### openSetting()

# openSetting

打开智能服务授权设置页面

## 扫码预览
![扫码预览 openSetting](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fopen-setting%252Findex)

## 支持版本

前端库版本不低于 `0.0.39`。

## 支持平台

<table>
<thead>
<tr><th>平台</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>Android</td><td>支持</td></tr>
<tr><td>iOS</td><td>支持</td></tr>
<tr><td>PC</td><td>不支持</td></tr>
<tr><td>HarmonyOS</td><td>不支持</td></tr>
</tbody>
</table>

## 接入准备

### 前置条件

- 无额外前置条件，不要求在用户点击事件中调用

## 使用说明

该接口不要求在用户点击事件中调用。
JavaScript 调用方也不要传入 `withSubscriptions: true`，否则豆包会返回 `subscription templates are not supported yet`。

- 豆包当前不支持订阅模板，不要传入 withSubscriptions: true。

## 调用方式

### 异步 API

```typescript
openSetting(params?: OpenSettingOptions): Promise<OpenSettingResult>
```

## 入参

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>withSubscriptions</code></td><td><code>false</code></td><td>否</td><td><code>false</code></td><td>豆包 Android、iOS 当前不支持订阅模板，仅支持 false</td><td>是否同时获取用户订阅消息的订阅状态；当前仅支持 false。</td></tr>
</tbody>
</table>

## 调用示例

```typescript
import { openSetting } from '@doubao-dev/framework/api';

try {
  const result = await openSetting();
  console.log(result.authSetting['scope.userLocation']);
} catch (error) {
  console.error(error);
}
```

## 成功返回

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>authSetting</code></td><td><code>AuthSetting</code></td><td>是</td><td>用户授权结果，key 为权限 scope，value 表示是否已授权</td></tr>
<tr><td><code>subscriptionsSetting</code></td><td><code>SubscriptionsSetting</code></td><td>否</td><td>预留的订阅消息设置字段。豆包当前仅支持 `withSubscriptions: false`，因此不会返回该字段。</td></tr>
<tr><td><code>subscriptionsSetting.itemSettings</code></td><td><code>Record&lt;string, SubscriptionSettingStatus&gt;</code></td><td>否</td><td>一次性订阅消息模板的订阅状态</td></tr>
<tr><td><code>subscriptionsSetting.mainSwitch</code></td><td><code>boolean</code></td><td>否</td><td>设置页订阅消息总开关</td></tr>
<tr><td><code>subscriptionsSetting.templateSettings</code></td><td><code>Record&lt;string, SubscriptionTemplateSetting&gt;</code></td><td>否</td><td>模板订阅状态</td></tr>
</tbody>
</table>

### 返回示例

```json
{
  "authSetting": {
    "scope.userLocation": true,
    "scope.record": false
  }
}
```

## 相关类型

<a id="doubaoappaccountinfo"></a>
### DoubaoAppAccountInfo

豆包 App 账号信息。

#### Properties

• **appId**: `string` - 豆包 App appId
• **envVersion**: `'develop' | 'trial' | 'release'` - 豆包 App 运行环境。 - develop：开发版 - trial：体验版 - release：正式版
• **version**: `string` - 线上豆包 App 版本号

<a id="pluginaccountinfo"></a>
### PluginAccountInfo

插件账号信息（仅在插件中调用时包含）。

#### Properties

• **appId**: `string` - 插件 appId
• **version**: `string` - 插件版本号，'a.b.c' 形式

<a id="getaccountinforesult"></a>
### GetAccountInfoResult

获取当前账号信息。

#### Properties

• **miniProgram**: `DoubaoAppAccountInfo` - 豆包 App 账号信息
• **plugin?**: `PluginAccountInfo` - 插件账号信息（仅在插件中调用时包含）

<a id="scope"></a>
### Scope

#### Type

`| 'scope.userLocation'
  | 'scope.userFuzzyLocation'
  | 'scope.userLocationBackground'
  | 'scope.payment'
  | 'scope.record'
  | 'scope.bluetooth'
  | 'scope.camera'
  | 'scope.addPhoneContact'
  | 'scope.addPhoneCalendar'`

<a id="authorizerequest"></a>
### AuthorizeRequest

#### Properties

• **scope**: `Scope` - 授权范围

<a id="performanceentry"></a>
### PerformanceEntry

#### Properties

• **entryType**: `PerformanceEntryType` - 性能指标所属类别
• **name**: `string` - 性能指标名称，例如 appLaunch、route、evaluateScript 或 firstRender
• **startTime**: `number` - 指标开始或发生时刻的 Unix 时间戳，单位为毫秒
• **duration?**: `number` - 指标持续时间，单位为毫秒；仅耗时类指标提供
• **path?**: `string` - 页面路径；仅页面的 navigation 和 render 类型指标提供
• **pageId?**: `number` - path 对应的页面实例 Id（随机生成，不保证递增）；仅页面相关指标提供
• **referrerPath?**: `string` - 路由来源页面的路径；仅 navigation / route 指标提供
• **referrerPageId?**: `number` - 路由来源页面的实例 ID；仅 navigation / route 指标提供
• **navigationStart?**: `number` - 路由开始被渲染层处理的 Unix 时间戳，单位为毫秒；仅 navigation 类型指标提供
• **navigationType?**: `string` - 路由类型。仅 navigation 类型的 Entry 有效
• **moduleName?**: `string` - 被执行脚本的模块名称；仅 script / evaluateScript 指标提供
• **viewLayerReadyTime?**: `number` - 视图层准备完成的 Unix 时间戳，单位为毫秒；仅 render / firstRender 指标提供
• **viewLayerRenderStartTime?**: `number` - 视图层首次渲染开始的 Unix 时间戳，单位为毫秒；仅 render / firstRender 指标提供
• **viewLayerRenderEndTime?**: `number` - 视图层首次渲染结束的 Unix 时间戳，单位为毫秒；仅 render / firstRender 指标提供
• **widgetId?**: `string` - Widget 标识；仅 Widget 的 render 类型指标提供
• **widgetInstanceId?**: `string` - Widget 实例 Id（随机生成，不保证递增）；仅 Widget 的 render 类型指标提供
• **isAppColdLaunch?**: `boolean` - Widget 关联的应用是否冷启动；仅 Widget 的 render 类型指标提供

<a id="performanceobservercallback"></a>
### PerformanceObserverCallback

#### Type

`(entryList: PerformanceObserverEntryList) => void`

<a id="performanceobserver"></a>
### PerformanceObserver

#### Properties

• **observe**: `(options: PerformanceObserverOptions) => void`
• **disconnect**: `() => void`

<a id="performance"></a>
### Performance

#### Properties

• **createObserver**: `(callback: PerformanceObserverCallback) => PerformanceObserver` - 创建性能观察者。调用返回对象的 observe 后，回调会接收之后新完成且匹配的 Entry
• **setBufferSize**: `(size: number) => void` - 设置客户端最多保留的性能 Entry 数量
• **getEntries**: `() => PerformanceEntry[]` - 返回当前智能服务已记录的全部性能 Entry
• **getEntriesByType**: `(entryType: string) => PerformanceEntry[]` - 返回指定 entryType 的性能 Entry
• **getEntriesByName**: `(name: string, entryType?: string) => PerformanceEntry[]` - 返回指定名称的性能 Entry；传入 entryType 时同时按类型筛选

<a id="performanceentrytype"></a>
### PerformanceEntryType

#### Type

`'navigation' | 'script' | 'render'`

<a id="performanceobserverentrylist"></a>
### PerformanceObserverEntryList

#### Properties

• **getEntries**: `() => PerformanceEntry[]`
• **getEntriesByType**: `(entryType: string) => PerformanceEntry[]`
• **getEntriesByName**: `(name: string, entryType?: string) => PerformanceEntry[]`

<a id="performanceobserveroptions"></a>
### PerformanceObserverOptions

#### Properties

• **entryTypes**: `string[]`

<a id="getsettingparams"></a>
### GetSettingParams

#### Properties

• **withSubscriptions?**: `false` - 是否同时获取用户订阅消息的订阅状态；当前仅支持 false

<a id="authsetting"></a>
### AuthSetting

#### Type

`Record<string, boolean>`

<a id="subscriptionsettingstatus"></a>
### SubscriptionSettingStatus

#### Type

`'accept' | 'reject' | 'ban' | 'filter'`

<a id="subscriptiontemplatesetting"></a>
### SubscriptionTemplateSetting

#### Properties

• **status**: `SubscriptionSettingStatus` - 订阅结果
• **alwaysSubscribe?**: `boolean` - 是否为长期订阅状态
• **allowReminderWay?**: `SubscriptionReminderWay[]` - 模板支持的提醒方式对应的用户授权结果

<a id="subscriptionssetting"></a>
### SubscriptionsSetting

#### Properties

• **mainSwitch**: `boolean` - 设置页订阅消息总开关
• **itemSettings?**: `Record<string, SubscriptionSettingStatus>` - 一次性订阅消息模板的订阅状态
• **templateSettings?**: `Record<string, SubscriptionTemplateSetting>` - 模板订阅状态

<a id="getsettingresult"></a>
### GetSettingResult

#### Properties

• **authSetting**: `AuthSetting` - 用户授权结果，key 为权限 scope，value 表示是否已授权
• **subscriptionsSetting?**: `SubscriptionsSetting` - 预留的订阅消息设置字段。豆包当前仅支持 withSubscriptions: false，因此不会返回该字段

<a id="subscriptionreminderway"></a>
### SubscriptionReminderWay

#### Properties

• **reminderType**: `SubscriptionReminderType` - 提醒方式
• **reminderStatus**: `SubscriptionReminderStatus` - 提醒授权结果

<a id="subscriptionremindertype"></a>
### SubscriptionReminderType

#### Type

`'message_notice' | 'feed' | 'push'`

<a id="subscriptionreminderstatus"></a>
### SubscriptionReminderStatus

#### Type

`'accept' | 'reject'`

<a id="opensettingoptions"></a>
### OpenSettingOptions

#### Properties

• **withSubscriptions?**: `false` - 是否同时获取用户订阅消息的订阅状态；当前仅支持 false

<a id="opensettingresult"></a>
### OpenSettingResult

#### Properties

• **authSetting**: `AuthSetting` - 用户授权结果，key 为权限 scope，value 表示是否已授权
• **subscriptionsSetting?**: `SubscriptionsSetting` - 预留的订阅消息设置字段。豆包当前仅支持 withSubscriptions: false，因此不会返回该字段
