目录

ToolEventCallback (CLI Tool Event Callback)

ToolEventCallback is used to receive session events generated during the running of a CLI tool process.

Since: 26.0.1

The APIs of this module can be used only in the stage model.

Modules to Import

import { common } from '@kit.AbilityKit';

OnEventFn

type OnEventFn = (event: CliToolEvent) => void

Type of the callback for the CLI tool session event.

Since: 26.0.1

System capability: SystemCapability.Ability.AgentRuntime.Core

Model restriction: This API can be used only in the stage model.

Name Type Mandatory Description
event CliToolEvent Yes Session event generated by the CLI tool process during runtime.

ToolEventCallback

Callback interface for session events generated during the running of a CLI tool process.

Since: 26.0.1

System capability: SystemCapability.Ability.AgentRuntime.Core

Model restriction: This API can be used only in the stage model.

Name Type Read-only Optional Description
onEvent OnEventFn No No Callback for the CLI tool session event.

Example

import { common } from '@kit.AbilityKit';

// Define the callback object for CLI tool session events.
let callback: common.ToolEventCallback = {
  onEvent: (event: common.CliToolEvent) => {
    console.info('tool event type: ' + event.toolEventType + ', data: ' + event.data);
  }
};