Quick Start
Quick Start
Environment Requirements
| Dependency | Version |
|---|---|
| JDK | 17+ |
| Maven | 3.6+ |
| Netty | 4.1.116.Final (bundled with SDK) |
Build Dependencies
Maven (recommended)
xml
<dependency>
<groupId>com.agibot.aiem</groupId>
<artifactId>linksoul-agentsdk</artifactId>
<version>1.4.0-SNAPSHOT</version>
</dependency>
Gradle (Groovy build.gradle)
groovy
implementation 'com.agibot.aiem:linksoul-agentsdk:1.4.0-SNAPSHOT'
Third-party dependencies when integrating the bare jar
If you cannot resolve transitive dependencies via Maven / Gradle, add the libraries below by hand:
| Dependency | Version | Purpose |
|---|---|---|
org.slf4j:slf4j-api | 2.0.16 | Logging facade |
ch.qos.logback:logback-classic | 1.5.13 | Logging implementation |
org.projectlombok:lombok | 1.18.36 | Annotation processor |
com.alibaba.fastjson2:fastjson2 | 2.0.53 | JSON encode/decode |
org.apache.commons:commons-lang3 | 3.14.0 | Utility classes |
io.jsonwebtoken:jjwt-api | 0.11.5 | JWT API |
io.jsonwebtoken:jjwt-impl | 0.11.5 | JWT runtime |
io.jsonwebtoken:jjwt-jackson | 0.11.5 | JWT JSON serialization |
io.netty:netty-all | 4.1.116.Final | WebSocket client |
Equivalent pom.xml / build.gradle snippets:
xml
<dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>2.0.16</version></dependency>
<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.36</version></dependency>
<dependency><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><version>1.5.13</version></dependency>
<dependency><groupId>com.alibaba.fastjson2</groupId><artifactId>fastjson2</artifactId><version>2.0.53</version></dependency>
<dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.14.0</version></dependency>
<dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt-api</artifactId><version>0.11.5</version></dependency>
<dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt-impl</artifactId><version>0.11.5</version></dependency>
<dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt-jackson</artifactId><version>0.11.5</version></dependency>
<dependency><groupId>io.netty</groupId><artifactId>netty-all</artifactId><version>4.1.116.Final</version></dependency>
groovy
implementation 'org.slf4j:slf4j-api:2.0.16'
implementation 'org.projectlombok:lombok:1.18.36'
implementation 'ch.qos.logback:logback-classic:1.5.13'
implementation 'com.alibaba.fastjson2:fastjson2:2.0.53'
implementation 'org.apache.commons:commons-lang3:3.14.0'
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'
implementation 'io.netty:netty-all:4.1.116.Final'
Note: keep
appKeyandappSecretprivate — they are used for the HMAC-SHA256 gateway signature. Never check them into source code or logs.
Complete Integration Example
The walkthrough below uses the classic Asr2Llm mode (text in → LLM text out). Other passive
callbacks integrate the same way — only the register* call and the onRequest signature change
(see Passive Examples).
java
import com.agibot.aiem.sdk.*;
import com.agibot.aiem.sdk.passive.*;
public class QuickStart {
public static void main(String[] args) {
String url = "wss://open.agibot.com/api/V1/open-portal/app/wss/agent-sdk";
String appId = "your_appId";
String appKey = "your_appKey";
String appSecret = "your_appSecret";
// Step 1: Create SDK instance (singleton - same appId always returns the same instance)
AgentSdk agentSdk = AgentSdk.create(url, appId, appKey, appSecret);
// Step 2: Register auth callback (monitor connection state)
agentSdk.registerAuth((appId1, code, msg) -> {
if (code == 0) {
System.out.println("Connection authenticated successfully");
} else {
System.err.println("Authentication failed: code=" + code + ", msg=" + msg);
}
});
// Step 3: Register the Asr2Llm callback (robot already did ASR; SDK only runs 语义理解/LLM)
agentSdk.registerAsr2Llm(new Asr2LlmCallback(agentSdk) {
@Override
public void onRobotOnline(String agentId, AgentMeta agentMeta) {
// Robot comes online, retrieve metadata (wakeup word, city, etc.)
System.out.println("Robot online: " + agentId);
System.out.println("Wakeup word: " + agentMeta.getWakeupWord());
}
@Override
public void onRobotOffline(String agentId) {
// Robot goes offline, clean up related resources
System.out.println("Robot offline: " + agentId);
}
/**
* @param text ASR-recognised text from upstream (usually the final ASR)
* @param param extension parameters
* @param response reply object — feed back LLM / skill / interrupt results
*/
@Override
public void onRequest(String agentId, String eventId, String text,
AgentParam param, Asr2LlmResponse response) {
// Run 语义理解 + knowledge lookup + LLM summarisation on `text`
String itemId = "itemId_000001";
// Barge-in for valid commands (skip on rejected utterances)
response.onInterrupt(eventId, "chat", null);
// Optional skill dispatch
AgentParam skillParam = AgentParam.create().setInteger("step", 3);
response.onSkill(eventId, itemId, "movement", "move_forward", skillParam);
// LLM streaming output
response.onLlmItemDelta(eventId, itemId, "The weather is nice today, ");
response.onLlmItemDelta(eventId, itemId, "a great day to go outside.");
response.onLlmItemDone(eventId, itemId);
response.onLlmDone(eventId);
// Error handling (uncomment when needed)
// response.onError(eventId, 1010, "LLM call failed");
}
});
// Step 4: Initialize (establish WebSocket connection with auto-reconnect)
agentSdk.initialize();
}
}
Core Concepts Quick Reference
| Concept | Description |
|---|---|
appId / appKey / appSecret | Obtained from the LinkSoul open platform after creating an application; appKey + appSecret are used for HMAC-SHA256 gateway signing |
| Passive Interaction | Robot initiates request -> SDK processes -> Returns result via Response |
| Active Interaction | SDK initiates a task flow toward the robot (registerTaskFlow) |
agentId | The agent ID configured on the LinkSoul platform (e.g., AGENT_0000001). The robot binds to that agent on-device; once it comes online the SDK delivers it via onRobotOnline(agentId, ...). It is not a hardware/instance identifier |
eventId | Unique identifier for one conversation round |
itemId | Identifier for multiple intents/response segments within the same conversation |
flag | Lifecycle flag used by Audio2* / AudioVideo2* / AsrVideo2* callbacks |
AgentParam | Extension parameters (key-value structure, supports chained calls) |
AgentMeta | Robot metadata (wakeup word, city, robot name, etc.) |
Integration Flow Diagram
text
create() -> registerAuth() -> register*Callback() -> initialize()
|
v
WebSocket Connection
|
+---------+---------+
v v
onAuthState() onRobotOnline()
(auth result) (robot online)
|
v
onRequest()
(process audio/text)
|
v
response.on*()
(return results)
Next Steps
- Architecture Overview - Understand the threading model and internal workings
- Passive Callbacks Guide - 8 callback types explained in detail
- Active Operations Guide - Task flow (v1.3.0 first opened the active surface but only task flow was ever functional; v1.4.0 removes the never-enabled entries — skill / state query, pull / push stream — and narrows the public API to task flow)
- Task-flow payload protocol - Skill orchestration /
action_group/action_typereference - Semantic Skills - Full catalogue dispatched via
response.onSkillor task flow - Complete Examples - More scenario-based example code