Skip to main content

asystant_core 0.5.1 copy "asystant_core: ^0.5.1" to clipboard
asystant_core: ^0.5.1 copied to clipboard

Typed local tools, protocol models and the OpenRouter and Claude Code providers for embedded assistants.

example/asystant_core_example.dart

import 'package:asystant_core/asystant_core.dart';

/// Reads application state without a network call or provider credential.
class ReadWorkspaceTool extends AsystantTool {
  const ReadWorkspaceTool();

  @override
  ToolDefinition get definition => const ToolDefinition(
    name: 'read_workspace',
    description: 'Read the name of the current workspace.',
    fields: [],
  );

  @override
  bool get requiresConfirmation => false;

  @override
  Future<Result<AssistantCard, AssistantFailure>> preview(
    ToolArguments arguments,
  ) async => Ok(const AssistantCard(title: 'Current workspace'));

  @override
  Future<Result<ToolOutcome, AssistantFailure>> execute(
    ToolArguments arguments,
    ToolContext context,
  ) async {
    context.checkCanceled();
    return Ok(const ToolOutcome(modelContent: 'Example workspace'));
  }
}

Future<void> main() async {
  const tool = ReadWorkspaceTool();
  final outcome = await tool.execute(
    ToolArguments.fromJson({}),
    ToolContext(
      idempotencyKey: 'local-read-example',
      selectedOptions: const [],
      isCanceled: () => false,
    ),
  );
  outcome.when(
    ok: (completed) => print(completed.modelContent),
    err: (failure) => print('Tool failed: ${failure.code.name}'),
  );
}
1
likes
0
points
824
downloads

Documentation

Documentation

Publisher

verified publisherjhonacode.com

Weekly Downloads

Typed local tools, protocol models and the OpenRouter and Claude Code providers for embedded assistants.

Homepage
Repository (GitHub)
View/report issues

Topics

#ai #assistant #tools #openrouter

License

unknown (license)

Dependencies

collection, http, result_controller

More

Packages that depend on asystant_core