目录

插件

为使云A2A模式的Agent能够调用位置服务、账号绑定等手机端系统能力,平台支持绑定端插件(插件广场中的端插件目前仅对企业开发者开放),Agent可通过端插件与设备侧应用交互。

添加插件的操作步骤如下:

以位置服务插件为例,可以具备获取当前位置的能力。

处理流程和示例代码:

步骤

处理

1

用户询问当前位置天气,Agent返回GetCurrentLocation指令。

2

小艺获得用户授权后返回UploadExeResult事件。

3

Agent校验latitude和longitude,并优先读取定位结果中的城市和区县。

定位指令示意:

Agent Server向小艺发送报文,调用GetCurrentLocation端插件请求位置服务:

{
    "jsonrpc": "2.0",
    "id": "ac65354f-ade2-45c9-b7be-2d10d52c9ea4&3&6d69&0",
    "result": {
        "taskId": "ac65354f-ade2-45c9-b7be-2d10d52c9ea4&3&6d69&0",
        "kind": "artifact-update",
        "append": true,
        "final": false,
        "lastChunk": false,
        "artifact": {
            "artifactId": "875aa96d-43a7-4d05-8469-07673fca35cf",
            "parts": [
                {
                    "kind": "data",
                    "data": {
                        "commands": [
                            {
                                "header": {
                                    "namespace": "Common",
                                    "name": "Action"
                                },
                                "payload": {
                                    "cardParam": {},
                                    "needUploadResult": true,
                                    "pageControlRelated": false,
                                    "responses": [
                                        {
                                            "displayText": "",
                                            "ttsText": "",
                                            "resultCode": ""
                                        }
                                    ],
                                    "executeParam": {
                                        "permissionId": [],
                                        "executeMode": "background",
                                        "achieveType": "INTENT",
                                        "actionResponse": true,
                                        "intentName": "GetCurrentLocation",
                                        "intentParam": {
                                            "cacheValidityPeriod": 300
                                        },
                                        "bundleName": "com.huawei.******",
                                        "needUnlock": true,
                                        "dimension": "",
                                        "timeOut": 5
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}

小艺调用端插件获取到位置信息后,返回给Agent Server的报文示例:

{
    "conversationId": "66ab2b954ca241c89efe48882adf16db",
    "deviceId": "0181ec2d-cea6-793b-ab22-e974ab724c03",
    "id": "ac65354f-ade2-45c9-b7be-2d10d52c9ea4&3&6d69&0",
    "jsonrpc": "2.0",
    "method": "message/stream",
    "params": {
        "id": "ac65354f-ade2-45c9-b7be-2d10d52c9ea4&3&6d69&0",
        "message": {
            "kind": "message",
            "messageId": "ac65354f-ade2-45c9-b7be-2d10d52c9ea4&3&6d69&0",
            "parts": [
                {
                    "data": {
                        "events": [
                            {
                                "header": {
                                    "name": "UploadExeResult",
                                    "namespace": "Common"
                                },
                                "payload": {
                                    "intentName": "GetCurrentLocation",
                                    "isNeedAgentInfo": false,
                                    "outputs": {
                                        "accuracy": 8.5,
                                        "additionSize": 2,
                                        "additions": [
                                            "requestId:f04780f9-a323-4f9e-8808-0fd5c189e978",
                                            "locateType:Wifi"
                                        ],
                                        "additionsMap": {},
                                        "altitude": 0,
                                        "altitudeAccuracy": 0,
                                        "direction": 0,
                                        "directionAccuracy": 0,
                                        "isFromMock": false,
                                        "latitude": 40.0572459,
                                        "longitude": 116.1792998,
                                        "sourceType": 2,
                                        "speed": 0,
                                        "speedAccuracy": 0,
                                        "timeSinceBoot": 3428629036054486,
                                        "timeStamp": 1790592612662,
                                        "uncertaintyOfTimeSinceBoot": 0
                                    }
                                 }
                            }
                        ]
                    },
                    "kind": "data"
                }
            ],
            "role": "user"
        },
        "sessionId": "66ab2b954ca241c89efe48882adf16db"
    },
    "sessionId": "ac65354f-ade2-45c9-b7be-2d10d52c9ea4"
}

Agent中已添加的端插件若有版本更新,需在Agent编排界面手动移除旧版本并添加新版本端插件。

插件其他能力可查看插件。