mirror of
https://github.com/hanzo-dart/hanzoai.git
synced 2026-09-11 18:41:33 +00:00
First-class services for agents, agent sessions, and machines with Hanzo IAM-native Bearer auth; raw send() escape hatch for the full /v1/cloud/* surface. Mirrors the @hanzo/cloud JavaScript client. dart format + analyze --fatal-infos clean, 22 tests green, pub publish dry-run: 0 warnings.
26 lines
833 B
Dart
26 lines
833 B
Dart
import 'package:hanzoai/hanzoai.dart';
|
|
|
|
/// Minimal end-to-end shape: create an agent, run it, watch its sessions.
|
|
///
|
|
/// Run against a real deployment with a Hanzo IAM token:
|
|
/// HANZO_TOKEN=... dart run example/hanzoai_example.dart
|
|
Future<void> main() async {
|
|
final cloud = HanzoCloud(token: const String.fromEnvironment('HANZO_TOKEN'));
|
|
|
|
final agent = await cloud.agents.create(
|
|
name: 'researcher',
|
|
model: 'zen-coder',
|
|
instructions: 'You research and summarize.',
|
|
tools: ['search', 'fetch'],
|
|
);
|
|
print('created ${agent.name} (${agent.id})');
|
|
|
|
final run = await cloud.agents.run(agent.name, input: 'Summarize RFC 8628.');
|
|
print('run ${run.status}: ${run.output}');
|
|
|
|
final sessions = await cloud.sessions.list(status: 'running');
|
|
print('${sessions.length} running session(s)');
|
|
|
|
cloud.close();
|
|
}
|