@doubao-apps/ai 0.0.33 → 0.0.34

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.
Files changed (69) hide show
  1. package/README.md +1 -32
  2. package/dist/733.js +7 -15
  3. package/dist/cli.js +1 -1
  4. package/dist/manifest.json +3 -11
  5. package/dist/skills/doubao-apps-dev/SKILL.md +103 -227
  6. package/dist/skills/doubao-apps-dev/references/examples/common-patterns.md +80 -66
  7. package/dist/skills/doubao-apps-dev/references/examples/component-basics.md +24 -3
  8. package/dist/skills/doubao-apps-dev/references/examples/component-recipes.md +71 -0
  9. package/dist/skills/doubao-apps-dev/references/examples/open-api-recipes.md +203 -0
  10. package/dist/skills/doubao-apps-dev/references/guides/component-development.md +66 -42
  11. package/dist/skills/doubao-apps-dev/references/guides/expired-widget.md +113 -0
  12. package/dist/skills/doubao-apps-dev/references/guides/mcp-ui.md +275 -0
  13. package/dist/skills/doubao-apps-dev/references/guides/performance-optimization.md +24 -7
  14. package/dist/skills/doubao-apps-dev/references/reference/components-quick-ref.md +18 -7
  15. package/dist/skills/doubao-apps-dev/references/reference/framework-api-quick-ref.md +125 -107
  16. package/dist/skills/doubao-apps-dev/references/reference/open-api/01-/345/237/272/347/241/200.md +136 -0
  17. package/dist/skills/doubao-apps-dev/references/reference/open-api/02-/347/263/273/347/273/237.md +257 -0
  18. package/dist/skills/doubao-apps-dev/references/reference/open-api/03-/345/256/232/344/275/215.md +326 -0
  19. package/dist/skills/doubao-apps-dev/references/reference/open-api/04-/345/255/230/345/202/250.md +284 -0
  20. package/dist/skills/doubao-apps-dev/references/reference/open-api/05-/350/267/257/347/224/261.md +162 -0
  21. package/dist/skills/doubao-apps-dev/references/reference/open-api/06-/344/272/244/344/272/222.md +290 -0
  22. package/dist/skills/doubao-apps-dev/references/reference/open-api/07-/350/276/223/345/205/245.md +63 -0
  23. package/dist/skills/doubao-apps-dev/references/reference/open-api/08-/347/275/221/347/273/234.md +124 -0
  24. package/dist/skills/doubao-apps-dev/references/reference/open-api/09-/345/252/222/344/275/223.md +192 -0
  25. package/dist/skills/doubao-apps-dev/references/reference/open-api/10-/344/270/232/345/212/241/350/203/275/345/212/233.md +431 -0
  26. package/dist/skills/doubao-apps-dev/references/reference/open-api/11-/347/231/273/345/275/225.md +110 -0
  27. package/dist/skills/doubao-apps-dev/references/reference/open-api/12-/346/224/257/344/273/230.md +224 -0
  28. package/dist/skills/doubao-apps-dev/references/reference/open-api/13-/346/225/260/346/215/256/345/210/206/346/236/220.md +43 -0
  29. package/dist/skills/doubao-apps-dev/references/reference/open-api/14-/350/223/235/347/211/231.md +598 -0
  30. package/dist/skills/doubao-apps-dev/references/reference/open-api/15-wi-fi.md +210 -0
  31. package/dist/skills/doubao-apps-dev/references/reference/open-api/16-/345/212/240/351/200/237/345/272/246/350/256/241.md +87 -0
  32. package/dist/skills/doubao-apps-dev/references/reference/open-api/17-ibeacon.md +97 -0
  33. package/dist/skills/doubao-apps-dev/references/reference/open-api/18-/347/275/227/347/233/230.md +78 -0
  34. package/dist/skills/doubao-apps-dev/references/reference/open-api/19-/350/256/276/345/244/207/346/226/271/345/220/221.md +86 -0
  35. package/dist/skills/doubao-apps-dev/references/reference/open-api/20-/351/231/200/350/236/272/344/273/252.md +87 -0
  36. package/dist/skills/doubao-apps-dev/references/reference/open-api/21-/350/256/276/345/244/207-/347/275/221/347/273/234.md +102 -0
  37. package/dist/skills/doubao-apps-dev/references/reference/open-api/22-/347/237/255/344/277/241.md +40 -0
  38. package/dist/skills/doubao-apps-dev/references/reference/open-api/23-/346/227/240/351/232/234/347/242/215.md +40 -0
  39. package/dist/skills/doubao-apps-dev/references/reference/open-api/24-/345/237/272/347/241/200/344/277/241/346/201/257.md +86 -0
  40. package/dist/skills/doubao-apps-dev/references/reference/open-api/25-/347/224/265/346/261/240.md +63 -0
  41. package/dist/skills/doubao-apps-dev/references/reference/open-api/26-/346/227/245/345/216/206.md +95 -0
  42. package/dist/skills/doubao-apps-dev/references/reference/open-api/27-/345/211/252/350/264/264/346/235/277.md +64 -0
  43. package/dist/skills/doubao-apps-dev/references/reference/open-api/28-/350/201/224/347/263/273/344/272/272.md +101 -0
  44. package/dist/skills/doubao-apps-dev/references/reference/open-api/29-/345/212/240/345/257/206.md +43 -0
  45. package/dist/skills/doubao-apps-dev/references/reference/open-api/30-/347/224/265/350/257/235.md +36 -0
  46. package/dist/skills/doubao-apps-dev/references/reference/open-api/31-/346/211/253/347/240/201.md +58 -0
  47. package/dist/skills/doubao-apps-dev/references/reference/open-api/32-/345/261/217/345/271/225.md +136 -0
  48. package/dist/skills/doubao-apps-dev/references/reference/open-api/33-/351/234/207/345/212/250.md +62 -0
  49. package/dist/skills/doubao-apps-dev/references/reference/open-api/34-/346/226/207/344/273/266/347/263/273/347/273/237.md +73 -0
  50. package/dist/skills/doubao-apps-dev/references/reference/open-api/README.md +34 -0
  51. package/dist/skills/doubao-apps-dev/references/reference/open-api.md +384 -2
  52. package/dist/skills/doubao-apps-dev/references/rules/dos-and-donts.md +44 -27
  53. package/dist/skills/h5-to-doubao/SKILL.md +8 -4
  54. package/dist/skills/weixin-to-doubao/SKILL.md +8 -4
  55. package/dist/skills/weixin-to-doubao/assets/migration-checklist-template.md +1 -1
  56. package/package.json +2 -3
  57. package/dist/contexts/doubao-apps-dev/AGENTS.md +0 -300
  58. package/dist/contexts/doubao-apps-dev/CLAUDE.md +0 -31
  59. package/dist/contexts/doubao-apps-dev/references/examples/common-patterns.md +0 -589
  60. package/dist/contexts/doubao-apps-dev/references/examples/component-basics.md +0 -526
  61. package/dist/contexts/doubao-apps-dev/references/guides/best-practices.md +0 -571
  62. package/dist/contexts/doubao-apps-dev/references/guides/component-development.md +0 -891
  63. package/dist/contexts/doubao-apps-dev/references/guides/performance-optimization.md +0 -402
  64. package/dist/contexts/doubao-apps-dev/references/guides/troubleshooting.md +0 -287
  65. package/dist/contexts/doubao-apps-dev/references/reference/components-quick-ref.md +0 -103
  66. package/dist/contexts/doubao-apps-dev/references/reference/framework-api-quick-ref.md +0 -550
  67. package/dist/contexts/doubao-apps-dev/references/reference/open-api/README.md +0 -8
  68. package/dist/contexts/doubao-apps-dev/references/reference/open-api.md +0 -11
  69. package/dist/contexts/doubao-apps-dev/references/rules/dos-and-donts.md +0 -467
@@ -0,0 +1,431 @@
1
+ # Open API: 业务能力
2
+
3
+ 开放业务能力、隐私设置、上下文和外部应用打开。
4
+
5
+ [返回目录](./README.md) | [返回速查](../open-api.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [dispatchActionDirective](#dispatchactiondirective) | 描述用户行为,约束模型行为并指定后续执行路径。 |
12
+ | [expiredWidget](#expiredwidget) | 更新过期的 widget 为固定卡片。 |
13
+ | [openApp](#openapp) | 通过 deep link 等方式打开外部应用。 |
14
+ | [getPrivacySetting](#getprivacysetting) | 获取隐私设置状态。 |
15
+ | [sendQueryMessage](#sendquerymessage) | 以用户身份发送一条消息。<br><br>返回 void,不是 Promise。 |
16
+ | [setAdditionalContext](#setadditionalcontext) | 设置全局上下文供大模型理解。 |
17
+ | [createTask](#createtask) | 创建任务。 |
18
+ | [updateTask](#updatetask) | 更新任务状态或任务详情。 |
19
+ | [getTask](#gettask) | 查询任务。 |
20
+ | [updateModelContext](#updatemodelcontext) | 向 Agent 捐赠上下文。 |
21
+ | [updateWidget](#updatewidget) | 更新指定卡片。 |
22
+
23
+ ## API 详情
24
+
25
+ <a id="dispatchactiondirective"></a>
26
+ ### dispatchActionDirective()
27
+
28
+ 描述用户行为,约束模型行为并指定后续执行路径。
29
+
30
+ ## 代码示例
31
+
32
+ ```typescript
33
+ import { ActionDirectiveType, dispatchActionDirective } from '@doubao-apps/framework/api';
34
+
35
+ await dispatchActionDirective({
36
+ widgetInstanceId: 'widget-instance-id',
37
+ actionType: ActionDirectiveType.BUTTON_CLICK,
38
+ actionDescribe: '用户点击了支付按钮',
39
+ expectedAction: '继续完成支付流程'
40
+ });
41
+ ```
42
+
43
+ ## 入参
44
+
45
+ |参数名|类型|必填|说明|
46
+ |---|---|---|---|
47
+ |actionDescribe|`string`|是|自然语言描述,例如:用户点击支付按钮并完成话费支付|
48
+ |actionType|`ActionDirectiveType`|是|动作类型,参见 ActionDirectiveType|
49
+ |actionType.BUTTON_CLICK|`"button_click"`|是|按钮点击|
50
+ |actionType.FORM_SUBMIT|`"form_submit"`|是|表单提交(复杂的信息提交场景)|
51
+ |actionType.OPTION_SELECT|`"option_select"`|是|选择(下拉列表场景)|
52
+ |expectedAction|`string`|是|自然语言描述,例如:调用话费账单查询工具,基于工具返回回复用户。如果有卡片需要引用卡片|
53
+ |responseHint|`string`|否|自然语言描述,例如:严格参照提供的工具入参来调用工具,不要调用除bill_check以外的其他工具,只能严格基于bill_check工具返回结果进行回复|
54
+ |toolName|`string`|否|mcp名称,如果expectedAction里预期要调用工具,需要在这里写明调用工具的mcp name|
55
+ |toolParams|`Record<string, string>`|否|mcp入参,如果expectedAction里预期要调用工具,需要在这里写明调用工具的入参|
56
+ |widgetInstanceId|`string`|是|会话消息关联的卡片ID|
57
+
58
+ ## 返回值
59
+
60
+ 返回一个 Promise,在动作指令成功下发时解析。
61
+
62
+ <a id="expiredwidget"></a>
63
+ ### expiredWidget()
64
+
65
+ 更新过期的 widget 为固定卡片
66
+
67
+ ## 代码示例
68
+
69
+ ```ts
70
+ expiredWidget({
71
+ widgetInstanceId: 'instance_123',
72
+ url: '${pageId}?key=value'
73
+ });
74
+ ```
75
+
76
+ ## 入参
77
+
78
+ |参数名|类型|必填|说明|
79
+ |---|---|---|---|
80
+ |detailText|`string`|否|点击失效卡要跳转的页面 detailText|
81
+ |schema|`string`|否|点击失效卡要跳转的页面 schema,格式与 navigateTo 的 url 相同|
82
+ |title|`string`|否|点击失效卡要跳转的页面 title|
83
+ |url|`string`|否|点击失效卡要跳转的页面 url 或 sslocal schema|
84
+ |widgetInstanceId|`string`|是|卡片实例 ID,在卡片环境通过getWidgetInstanceId来获取,其他环境(比如页面)需要通过传参或通信的方式传递过去|
85
+
86
+ ## 返回值
87
+
88
+ 返回 `Promise<object>`。
89
+
90
+ <a id="openapp"></a>
91
+ ### openApp()
92
+
93
+ 通过 deep link 等方式打开外部应用。
94
+
95
+ ## 代码示例
96
+
97
+ ```typescript
98
+ import { openApp } from '@doubao-apps/framework/api';
99
+
100
+ const { status } = await openApp({
101
+ uri: 'demo://detail?id=1',
102
+ fallbackUrl: 'https://example.com/download'
103
+ });
104
+
105
+ console.log(status);
106
+ ```
107
+
108
+ ## 入参
109
+
110
+ |参数名|类型|必填|说明|
111
+ |---|---|---|---|
112
+ |fallbackUrl|`string`|否|Optional fallback URL when deep link fails|
113
+ |targetPackage|`string`|否|Optional target package name for Android|
114
+ |uri|`string`|是|Target URI to open, e.g. scheme://path?query|
115
+
116
+ ## 返回值
117
+
118
+ 返回外部应用打开结果。
119
+
120
+ |字段名|类型|说明|
121
+ |---|---|---|
122
+ |status|`OpenAppStatus`|Execution status from client|
123
+
124
+ **类型说明**
125
+
126
+ - `OpenAppStatus`: `"deep_link" | "market" | "browser"`
127
+
128
+ <a id="getprivacysetting"></a>
129
+ ### getPrivacySetting()
130
+
131
+ 获取隐私设置状态。
132
+
133
+ ## 代码示例
134
+
135
+ ```typescript
136
+ import { getPrivacySetting } from '@doubao-apps/framework/api';
137
+
138
+ const { needAuthorization } = await getPrivacySetting();
139
+
140
+ console.log(needAuthorization);
141
+ ```
142
+
143
+ ## 入参
144
+
145
+ 无入参。
146
+
147
+ ## 返回值
148
+
149
+ 返回隐私设置状态。
150
+
151
+ |字段名|类型|说明|
152
+ |---|---|---|
153
+ |needAuthorization|`boolean`|Whether user authorization for privacy agreement is required|
154
+
155
+ <a id="sendquerymessage"></a>
156
+ ### sendQueryMessage()
157
+
158
+ 以用户身份发送一条消息
159
+
160
+ 由于会自动获取页面上下文来确定向哪个 bot 发送消息,因此只能在卡片或页面中调用
161
+
162
+ ## 代码示例
163
+
164
+ ```ts
165
+ await sendQueryMessage({ content: '订阅消息', type: 'text' })
166
+
167
+ @public
168
+ ```
169
+
170
+ ## 入参
171
+
172
+ |参数名|类型|必填|说明|
173
+ |---|---|---|---|
174
+ |content|`string`|是|要发送的消息。根据类型不同,序列化方式可能不同|
175
+ |type|`"text"`|是|消息类型,目前仅支持 text|
176
+
177
+ ## 返回值
178
+
179
+ 返回 `void`。
180
+
181
+ <a id="setadditionalcontext"></a>
182
+ ### setAdditionalContext()
183
+
184
+ 设置全局上下文供大模型理解
185
+
186
+ ## 代码示例
187
+
188
+ ```typescript
189
+ import { setAdditionalContext } from '@doubao-apps/framework/api';
190
+
191
+ await setAdditionalContext({
192
+ additionalContext: '用户正在查看订单详情页',
193
+ botId: 'bot-id'
194
+ });
195
+ ```
196
+
197
+ ## 入参
198
+
199
+ |参数名|类型|必填|说明|
200
+ |---|---|---|---|
201
+ |additionalContext|`string`|是|上下文内容|
202
+ |botId|`string`|否|指定 bot id|
203
+
204
+ ## 返回值
205
+
206
+ 返回 `Promise<object>`。
207
+
208
+ <a id="createtask"></a>
209
+ ### createTask()
210
+
211
+ 创建任务。
212
+
213
+ ## 代码示例
214
+
215
+ ```typescript
216
+ import { createTask } from '@doubao-apps/framework/api';
217
+
218
+ const result = await createTask({
219
+ outTaskId: 'order-20260529-001',
220
+ taskTemplate: 'remote_normal_v1',
221
+ taskType: 'remote',
222
+ taskDetail: {
223
+ expire_in_sec: 3600,
224
+ display_data: {
225
+ title: '订单处理中',
226
+ sub_title: '正在为你处理订单,请稍候'
227
+ }
228
+ }
229
+ });
230
+
231
+ console.log(result.taskId, result.token, result.expiresIn);
232
+ ```
233
+
234
+ ## 入参
235
+
236
+ |参数名|类型|必填|说明|
237
+ |---|---|---|---|
238
+ |outTaskId|`string`|是|开发者侧任务唯一标识,用于幂等和关联|
239
+ |taskDetail|`TaskDetail`|是|模板对应的数据,传入对象时会在调用 native 前自动 JSON.stringify|
240
+ |taskDetail.display_data|`TaskDisplayData`|是|任务展示数据|
241
+ |taskDetail.display_data.sub_title|`string`|否|任务副标题|
242
+ |taskDetail.display_data.title|`string`|是|任务标题|
243
+ |taskDetail.expire_in_sec|`number`|是|任务过期时间,单位:秒。任务创建后经过该时间将自动过期|
244
+ |taskDetail.jump_page_data|`JumpSchemaData`|否|点击任务跳转的页面参数|
245
+ |taskDetail.jump_page_data.path|`string`|否|跳转页面|
246
+ |taskDetail.jump_page_data.query|`string`|否|页面参数,小程序内消费时会自动 base64 url encode,需要 decode|
247
+ |taskDetail.progress_data|`TaskProgressData`|否|任务进度数据|
248
+ |taskDetail.progress_data.progress|`number`|否|任务进度值,如百分比 0-100|
249
+ |taskDetail.progress_data.progress_text|`string`|否|进度描述文本,如"正在处理中"|
250
+ |taskDetail.progress_data.remaining_seconds|`number`|否|预估剩余时间,单位:秒|
251
+ |taskDetail.remove_data|`TaskActionParams`|否|移除任务时的操作参数|
252
+ |taskDetail.remove_data.action_key|`string`|否|操作标识|
253
+ |taskDetail.remove_data.page_param|`string`|否|页面参数|
254
+ |taskTemplate|`"remote_normal_v1"`|是|任务样式模板,当前仅支持 remote_normal_v1|
255
+ |taskType|`TaskType`|是|任务类型,当前支持 local 和 remote|
256
+
257
+ **类型说明**
258
+
259
+ - `TaskDetail`: `string | RemoteNormalV1Detail`
260
+ - `TaskType`: `"local" | "remote"`
261
+
262
+ ## 返回值
263
+
264
+ 返回创建后的任务 ID、远端任务 token 和过期时间。
265
+
266
+ |字段名|类型|说明|
267
+ |---|---|---|
268
+ |expiresIn|`number`|任务超时过期时间|
269
+ |taskId|`string`|任务 ID,后续可以使用这个 ID 更新任务|
270
+ |token|`string`|远端任务 token,后续使用 token 通过 OpenAPI 更新远端任务|
271
+
272
+ <a id="updatetask"></a>
273
+ ### updateTask()
274
+
275
+ 更新任务状态或任务详情。
276
+
277
+ ## 代码示例
278
+
279
+ ```typescript
280
+ import { updateTask } from '@doubao-apps/framework/api';
281
+
282
+ const result = await updateTask({
283
+ taskId: 'task_123',
284
+ taskStatus: 'completed',
285
+ taskDetail: {
286
+ expire_in_sec: 3600,
287
+ display_data: {
288
+ title: '订单已完成',
289
+ sub_title: '订单处理完成'
290
+ }
291
+ }
292
+ });
293
+
294
+ console.log(result.taskId, result.nextToken, result.expiresIn);
295
+ ```
296
+
297
+ ## 入参
298
+
299
+ |参数名|类型|必填|说明|
300
+ |---|---|---|---|
301
+ |taskDetail|`TaskDetail`|否|模板对应的数据,传入对象时会在调用 native 前自动 JSON.stringify,与 taskStatus 二选一|
302
+ |taskDetail.display_data|`TaskDisplayData`|否|任务展示数据|
303
+ |taskDetail.display_data.sub_title|`string`|否|任务副标题|
304
+ |taskDetail.display_data.title|`string`|否|任务标题|
305
+ |taskDetail.expire_in_sec|`number`|否|任务过期时间,单位:秒。任务创建后经过该时间将自动过期|
306
+ |taskDetail.jump_page_data|`JumpSchemaData`|否|点击任务跳转的页面参数|
307
+ |taskDetail.jump_page_data.path|`string`|否|跳转页面|
308
+ |taskDetail.jump_page_data.query|`string`|否|页面参数,小程序内消费时会自动 base64 url encode,需要 decode|
309
+ |taskDetail.progress_data|`TaskProgressData`|否|任务进度数据|
310
+ |taskDetail.progress_data.progress|`number`|否|任务进度值,如百分比 0-100|
311
+ |taskDetail.progress_data.progress_text|`string`|否|进度描述文本,如"正在处理中"|
312
+ |taskDetail.progress_data.remaining_seconds|`number`|否|预估剩余时间,单位:秒|
313
+ |taskDetail.remove_data|`TaskActionParams`|否|移除任务时的操作参数|
314
+ |taskDetail.remove_data.action_key|`string`|否|操作标识|
315
+ |taskDetail.remove_data.page_param|`string`|否|页面参数|
316
+ |taskId|`string`|是|任务 ID|
317
+ |taskStatus|`TaskStatus`|否|任务状态,与 taskDetail 二选一|
318
+
319
+ **类型说明**
320
+
321
+ - `TaskDetail`: `string | RemoteNormalV1Detail`
322
+ - `TaskStatus`: `"running" | "completed"`
323
+
324
+ ## 返回值
325
+
326
+ 返回任务 ID、新 token 和过期时间。
327
+
328
+ |字段名|类型|说明|
329
+ |---|---|---|
330
+ |expiresIn|`number`|任务超时过期时间|
331
+ |nextToken|`string`|每次更新后旧的 token 失效,必须使用新返回的 token|
332
+ |taskId|`string`|任务 ID,更新后任务 ID 不变|
333
+
334
+ <a id="gettask"></a>
335
+ ### getTask()
336
+
337
+ 查询任务。
338
+
339
+ ## 代码示例
340
+
341
+ ```typescript
342
+ import { getTask } from '@doubao-apps/framework/api';
343
+
344
+ const task = await getTask({ taskId: 'task_123' });
345
+
346
+ if (task.taskStatus === 'running') {
347
+ console.log('任务仍在运行', task.taskDetail);
348
+ }
349
+ ```
350
+
351
+ ## 入参
352
+
353
+ |参数名|类型|必填|说明|
354
+ |---|---|---|---|
355
+ |taskId|`string`|是|任务 ID|
356
+
357
+ ## 返回值
358
+
359
+ 返回任务详情、状态、类型和 token 信息。
360
+
361
+ |字段名|类型|说明|
362
+ |---|---|---|
363
+ |expiresIn|`number`|任务超时过期时间|
364
+ |taskDetail|`string`|模板对应的数据的 JSON 字符串|
365
+ |taskId|`string`|任务 ID|
366
+ |taskStatus|`TaskStatus`|任务状态,运行中或已完成|
367
+ |taskTemplate|`"remote_normal_v1"`|任务样式模板,当前仅支持 remote_normal_v1|
368
+ |taskType|`TaskType`|任务类型,local 或 remote|
369
+ |token|`string`|每次更新后旧的 token 失效,必须使用新返回的 token|
370
+
371
+ **类型说明**
372
+
373
+ - `TaskStatus`: `"running" | "completed"`
374
+ - `TaskType`: `"local" | "remote"`
375
+
376
+ <a id="updatemodelcontext"></a>
377
+ ### updateModelContext()
378
+
379
+ 向 Agent 捐赠上下文
380
+
381
+ ## 代码示例
382
+
383
+ ```typescript
384
+ import { updateModelContext } from '@doubao-apps/framework/api';
385
+
386
+ await updateModelContext({
387
+ taskId: 'task-id',
388
+ entityId: 'entity-id',
389
+ content: '用户选择了标准配送'
390
+ });
391
+ ```
392
+
393
+ ## 入参
394
+
395
+ |参数名|类型|必填|说明|
396
+ |---|---|---|---|
397
+ |content|`string`|是|上下文内容,格式无约束,可以与 MCP 服务下发的上下文格式保持一致|
398
+ |entityId|`string`|否|上下文所属的 entityID,业务侧管理|
399
+ |taskId|`string`|否|上下文所属任务 ID,业务侧定义|
400
+
401
+ ## 返回值
402
+
403
+ 返回 `Promise<object>`。
404
+
405
+ <a id="updatewidget"></a>
406
+ ### updateWidget()
407
+
408
+ 更新指定卡片
409
+
410
+ ## 代码示例
411
+
412
+ ```typescript
413
+ import { updateWidget } from '@doubao-apps/framework/api';
414
+
415
+ await updateWidget({
416
+ widgetInstanceId: 'widget-instance-id',
417
+ widgetData: JSON.stringify({ title: '更新后的标题' })
418
+ });
419
+ ```
420
+
421
+ ## 入参
422
+
423
+ |参数名|类型|必填|说明|
424
+ |---|---|---|---|
425
+ |widgetData|`string`|是|卡片渲染的数据|
426
+ |widgetId|`string`|否|卡片更新的为新的widgetId|
427
+ |widgetInstanceId|`string`|是|需要更新的widget 实例 ID|
428
+
429
+ ## 返回值
430
+
431
+ 返回 `Promise<object>`。
@@ -0,0 +1,110 @@
1
+ # Open API: 登录
2
+
3
+ 豆包登录和登录结果回传能力。
4
+
5
+ [返回目录](./README.md) | [返回速查](../open-api.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [loginWithDoubaoWidget](#loginwithdoubaowidget) | 发起豆包 Widget 登录。 |
12
+ | [login](#login) | 发起登录并获取登录凭证。 |
13
+ | [postLoginResult](#postloginresult) | 回传 MCP 授权登录凭证。 |
14
+
15
+ ## API 详情
16
+
17
+ <a id="loginwithdoubaowidget"></a>
18
+ ### loginWithDoubaoWidget()
19
+
20
+ 发起豆包 Widget 登录。
21
+
22
+ ## 代码示例
23
+
24
+ ```typescript
25
+ import { LoginType, loginWithDoubaoWidget } from '@doubao-apps/framework/api';
26
+
27
+ const { result } = await loginWithDoubaoWidget({
28
+ loginType: LoginType.LoginWithPrivacy
29
+ });
30
+
31
+ console.log(result);
32
+ ```
33
+
34
+ ## 入参
35
+
36
+ |参数名|类型|必填|说明|
37
+ |---|---|---|---|
38
+ |loginType|`LoginType`|是|Login type identifier|
39
+ |loginType.Login|`number`|是|仅登录|
40
+ |loginType.LoginThenPrivacy|`number`|是|先登录再隐私协议,两次弹窗|
41
+ |loginType.LoginWithPrivacy|`number`|是|登录和隐私协议合并,一次弹窗|
42
+ |loginType.Privacy|`number`|是|隐私协议登录|
43
+
44
+ **类型说明**
45
+
46
+ - `LoginType`: `object`
47
+
48
+ ## 返回值
49
+
50
+ 返回登录结果。
51
+
52
+ |字段名|类型|说明|
53
+ |---|---|---|
54
+ |result|`boolean`|Whether the login is successful|
55
+
56
+ <a id="login"></a>
57
+ ### login()
58
+
59
+ 发起登录并获取登录凭证。
60
+
61
+ ## 代码示例
62
+
63
+ ```typescript
64
+ import { login } from '@doubao-apps/framework/api';
65
+
66
+ const { code } = await login({ timeout: 30000 });
67
+
68
+ console.log(code);
69
+ ```
70
+
71
+ ## 入参
72
+
73
+ |参数名|类型|必填|说明|
74
+ |---|---|---|---|
75
+ |timeout|`number`|否|Timeout in milliseconds|
76
+
77
+ ## 返回值
78
+
79
+ 返回包含登录凭证 code 的 Promise。
80
+
81
+ |字段名|类型|说明|
82
+ |---|---|---|
83
+ |code|`string`|Login credential code|
84
+
85
+ <a id="postloginresult"></a>
86
+ ### postLoginResult()
87
+
88
+ 回传 MCP 授权登录凭证。
89
+
90
+ ## 代码示例
91
+
92
+ ```typescript
93
+ import { postLoginResult } from '@doubao-apps/framework/api';
94
+
95
+ await postLoginResult({
96
+ result: true,
97
+ code: 'login-code'
98
+ });
99
+ ```
100
+
101
+ ## 入参
102
+
103
+ |参数名|类型|必填|说明|
104
+ |---|---|---|---|
105
+ |code|`string`|否|Authorization login credential, valid when login result is true|
106
+ |result|`boolean`|是|Login result, true means success, false means failure|
107
+
108
+ ## 返回值
109
+
110
+ 返回回传完成的 Promise。