Skip to content

Commit f2edcea

Browse files
🔄 Sync from private repository - 2026-03-20 08:59:41
1 parent a940be7 commit f2edcea

6 files changed

Lines changed: 780 additions & 1 deletion

File tree

API.en.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The following icons indicate API compatibility when running in background trigge
4040
- [system](#system) ✅ - System settings control
4141
- [miniapp](#miniapp) ✅ - MiniApp - Full-screen interactive multi-page application
4242
- [widget](#widget) ✅ - Widget - Scriptable-compatible iOS Home Screen widgets
43+
- [ai](#ai) ✅ - AI Agent module - chat, run autonomous tasks, generate code
4344

4445
---
4546

@@ -4100,6 +4101,47 @@ Open system settings
41004101

41014102
---
41024103

4104+
### `system.alert`
4105+
4106+
**Signature:** `alert(title, message, okTitle?)`
4107+
4108+
Show a system-level alert dialog
4109+
4110+
**Parameters:**
4111+
4112+
| Name | Type | Description | Optional |
4113+
|------|------|-------------|----------|
4114+
| `title` | `string` | Title text | No |
4115+
| `message` | `string` | Message text | No |
4116+
| `okTitle` | `string` | OK button title | Yes |
4117+
4118+
**Returns:** `Promise<void>`
4119+
4120+
*Resolves when user dismisses the alert*
4121+
4122+
---
4123+
4124+
### `system.confirm`
4125+
4126+
**Signature:** `confirm(title, message, confirmTitle?, cancelTitle?)`
4127+
4128+
Show a system-level confirm dialog
4129+
4130+
**Parameters:**
4131+
4132+
| Name | Type | Description | Optional |
4133+
|------|------|-------------|----------|
4134+
| `title` | `string` | Title text | No |
4135+
| `message` | `string` | Message text | No |
4136+
| `confirmTitle` | `string` | Confirm button title | Yes |
4137+
| `cancelTitle` | `string` | Cancel button title | Yes |
4138+
4139+
**Returns:** `Promise<boolean>`
4140+
4141+
*Resolves true if confirmed, false otherwise*
4142+
4143+
---
4144+
41034145
## miniapp
41044146

41054147
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
@@ -4161,3 +4203,66 @@ Preview a Widget in MiniApp interface without saving to App Group. Shows a previ
41614203

41624204
---
41634205

4206+
## ai
4207+
4208+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
4209+
4210+
AI Agent module - chat, run autonomous tasks, generate code
4211+
4212+
### `ai.chat`
4213+
4214+
**Signature:** `chat(prompt, options?)`
4215+
4216+
Send a chat message to AI and get a text response
4217+
4218+
**Parameters:**
4219+
4220+
| Name | Type | Description | Optional |
4221+
|------|------|-------------|----------|
4222+
| `prompt` | `string` | The message to send | No |
4223+
| `options` | `object` | { messages?: array } - conversation history | Yes |
4224+
4225+
**Returns:** `Promise<string>`
4226+
4227+
*AI's text response*
4228+
4229+
---
4230+
4231+
### `ai.run`
4232+
4233+
**Signature:** `run(prompt, options?)`
4234+
4235+
Run AI agent to autonomously complete a task using device APIs
4236+
4237+
**Parameters:**
4238+
4239+
| Name | Type | Description | Optional |
4240+
|------|------|-------------|----------|
4241+
| `prompt` | `string` | Task description | No |
4242+
| `options` | `object` | { input?, maxSteps?, confirmEach?, timeout?, modules? } | Yes |
4243+
4244+
**Returns:** `Promise<object>`
4245+
4246+
*{ success: boolean, result: string, steps: array, summary: string }*
4247+
4248+
---
4249+
4250+
### `ai.generate`
4251+
4252+
**Signature:** `generate(prompt, options?)`
4253+
4254+
Generate TrollScript code from natural language description
4255+
4256+
**Parameters:**
4257+
4258+
| Name | Type | Description | Optional |
4259+
|------|------|-------------|----------|
4260+
| `prompt` | `string` | What the code should do | No |
4261+
| `options` | `object` | { modules?: string[] } - limit to specific API modules | Yes |
4262+
4263+
**Returns:** `Promise<string>`
4264+
4265+
*Generated TrollScript code*
4266+
4267+
---
4268+

API.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ The following icons indicate API compatibility when running in background trigge
3939
- [system](#system) ✅ - 系统设置控制
4040
- [miniapp](#miniapp) ✅ - 迷你应用 - 全屏交互式多页面应用
4141
- [widget](#widget) ✅ - 小组件 - Scriptable 兼容的 iOS 主屏幕小组件
42+
- [ai](#ai) ✅ - AI 智能助手模块 - 对话、自主执行任务、生成代码
4243

4344
---
4445

@@ -3929,6 +3930,47 @@ execute() 的别名
39293930

39303931
---
39313932

3933+
### `system.alert`
3934+
3935+
**Signature:** `alert(title, message, okTitle?)`
3936+
3937+
显示系统级提示弹窗
3938+
3939+
**Parameters:**
3940+
3941+
| Name | Type | Description | Optional |
3942+
|------|------|-------------|----------|
3943+
| `title` | `string` | 标题 | No |
3944+
| `message` | `string` | 内容 | No |
3945+
| `okTitle` | `string` | 确定按钮标题 | Yes |
3946+
3947+
**Returns:** `Promise<void>`
3948+
3949+
*用户关闭弹窗后完成*
3950+
3951+
---
3952+
3953+
### `system.confirm`
3954+
3955+
**Signature:** `confirm(title, message, confirmTitle?, cancelTitle?)`
3956+
3957+
显示系统级确认弹窗
3958+
3959+
**Parameters:**
3960+
3961+
| Name | Type | Description | Optional |
3962+
|------|------|-------------|----------|
3963+
| `title` | `string` | 标题 | No |
3964+
| `message` | `string` | 内容 | No |
3965+
| `confirmTitle` | `string` | 确认按钮标题 | Yes |
3966+
| `cancelTitle` | `string` | 取消按钮标题 | Yes |
3967+
3968+
**Returns:** `Promise<boolean>`
3969+
3970+
*确认返回 true,取消返回 false*
3971+
3972+
---
3973+
39323974
## miniapp
39333975

39343976
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
@@ -3990,3 +4032,66 @@ execute() 的别名
39904032

39914033
---
39924034

4035+
## ai
4036+
4037+
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)
4038+
4039+
AI 智能助手模块 - 对话、自主执行任务、生成代码
4040+
4041+
### `ai.chat`
4042+
4043+
**Signature:** `chat(prompt, options?)`
4044+
4045+
向 AI 发送对话消息并获取文本回复
4046+
4047+
**Parameters:**
4048+
4049+
| Name | Type | Description | Optional |
4050+
|------|------|-------------|----------|
4051+
| `prompt` | `string` | 要发送的消息 | No |
4052+
| `options` | `object` | { messages?: array } - 对话历史记录 | Yes |
4053+
4054+
**Returns:** `Promise<string>`
4055+
4056+
*AI 的文本回复*
4057+
4058+
---
4059+
4060+
### `ai.run`
4061+
4062+
**Signature:** `run(prompt, options?)`
4063+
4064+
运行 AI 智能体,自主调用设备 API 完成任务
4065+
4066+
**Parameters:**
4067+
4068+
| Name | Type | Description | Optional |
4069+
|------|------|-------------|----------|
4070+
| `prompt` | `string` | 任务描述 | No |
4071+
| `options` | `object` | { input?, maxSteps?, confirmEach?, timeout?, modules? } | Yes |
4072+
4073+
**Returns:** `Promise<object>`
4074+
4075+
*{ success: boolean, result: string, steps: array, summary: string }*
4076+
4077+
---
4078+
4079+
### `ai.generate`
4080+
4081+
**Signature:** `generate(prompt, options?)`
4082+
4083+
根据自然语言描述生成 TrollScript 代码
4084+
4085+
**Parameters:**
4086+
4087+
| Name | Type | Description | Optional |
4088+
|------|------|-------------|----------|
4089+
| `prompt` | `string` | 代码应该实现的功能 | No |
4090+
| `options` | `object` | { modules?: string[] } - 限制使用特定的 API 模块 | Yes |
4091+
4092+
**Returns:** `Promise<string>`
4093+
4094+
*生成的 TrollScript 代码*
4095+
4096+
---
4097+

TrollScript-Private

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit f87fdac1808e9066ba03ac98c6eeed42a95f4ac5
1+
Subproject commit e5acc23b869b21462ba19d9fd1dfa6b9aefba0e8

npm/index.d.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,25 @@ interface System {
16951695
*/
16961696
openSettings(section?: string): boolean;
16971697

1698+
/**
1699+
* 显示系统级提示弹窗
1700+
* @param title 标题
1701+
* @param message 内容
1702+
* @param okTitle 确定按钮标题
1703+
* @returns 用户关闭弹窗后完成
1704+
*/
1705+
alert(title: string, message: string, okTitle?: string): any;
1706+
1707+
/**
1708+
* 显示系统级确认弹窗
1709+
* @param title 标题
1710+
* @param message 内容
1711+
* @param confirmTitle 确认按钮标题
1712+
* @param cancelTitle 取消按钮标题
1713+
* @returns 确认返回 true,取消返回 false
1714+
*/
1715+
confirm(title: string, message: string, confirmTitle?: string, cancelTitle?: string): any;
1716+
16981717
}
16991718

17001719
declare const system: System;
@@ -1726,3 +1745,32 @@ interface Widget {
17261745
}
17271746

17281747
declare const widget: Widget;
1748+
1749+
interface Ai {
1750+
/**
1751+
* 向 AI 发送对话消息并获取文本回复
1752+
* @param prompt 要发送的消息
1753+
* @param options { messages?: array } - 对话历史记录
1754+
* @returns AI 的文本回复
1755+
*/
1756+
chat(prompt: string, options?: Record<string, any>): any;
1757+
1758+
/**
1759+
* 运行 AI 智能体,自主调用设备 API 完成任务
1760+
* @param prompt 任务描述
1761+
* @param options { input?, maxSteps?, confirmEach?, timeout?, modules? }
1762+
* @returns { success: boolean, result: string, steps: array, summary: string }
1763+
*/
1764+
run(prompt: string, options?: Record<string, any>): any;
1765+
1766+
/**
1767+
* 根据自然语言描述生成 TrollScript 代码
1768+
* @param prompt 代码应该实现的功能
1769+
* @param options { modules?: string[] } - 限制使用特定的 API 模块
1770+
* @returns 生成的 TrollScript 代码
1771+
*/
1772+
generate(prompt: string, options?: Record<string, any>): any;
1773+
1774+
}
1775+
1776+
declare const ai: Ai;

0 commit comments

Comments
 (0)