ADR 0044's step 6a (D42, D43, D45): accounts for programs, such as AI assistants, that an identified person makes from the Profile. halkyon_base keeps them on the instance's register, which its members ask: an agent is an account (agent_account: its owner, its name, its public keys, set by itself once) with one token (agent_token: 32 random bytes, kept as their SHA-256 alone, shown once). agents.create, mine, newToken, revoke, delete and setKeys serve its owner; agentSignIn.signIn exchanges the token for an ordinary server-side session of a day, with the scopes identified and agent, at most 60 sign-ins an hour from a network. Revoking a token or making a new one ends the agent's sessions; a token unused for 90 days lapses in every service's pruning. Up to 5 agents a person, where the operator didn't switch them off (AGENTS=off; said on the privacy page and in instance.basics). An agent makes no agents, creates or owns no shared space, is invited and raised as a Viewer alone, is never handed a space on, is named no operator and granted no assistants; each refusal has its test. Deleting a person deletes their agents first; an agent's public profile names whose agent it is. In the apps, every Profile has an Agents card (halkyon_app's AgentsSection): made with a name and a handle, its token shown once to copy, a new token, the token taken back, deleted. Learn's Share sheet marks an agent among the members and offers it no role above Viewer. The migrations, the module's and each host's (Learn, Meditate, Todo, Train), are additive alone: CREATE TABLE "agent_account" with a unique index on "agentId" (one row an agent account) and one on "ownerId" (a person's agents, and deleting them with the person), and CREATE TABLE "agent_token" with unique indexes on "agentId" (one token an agent) and "tokenHash" (the sign-in finds the token by its hash). No existing table is touched, so the server before the deploy keeps working on the migrated database. Whats-New: Make agents in your Profile: accounts for programs such as AI assistants, which sign in with a token and see only what you share with them. Whats-New-De: Leg in deinem Profil Agenten an: Konten für Programme wie KI-Assistenten, die sich mit einem Token anmelden und nur sehen, was du mit ihnen teilst. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
117 lines
3.8 KiB
Dart
117 lines
3.8 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:halkyon_app/halkyon_app.dart';
|
|
import 'package:halkyon_app/testing.dart';
|
|
import 'package:material_ui/material_ui.dart';
|
|
|
|
/// Keeps what was copied, without the system's clipboard and its timer.
|
|
class _Clipboard() implements SecretClipboard {
|
|
final copied = <String>[];
|
|
|
|
@override
|
|
Future<void> copy(String text) async => copied.add(text);
|
|
}
|
|
|
|
void main() {
|
|
late TestAppDependencies dependencies;
|
|
late _Clipboard clipboard;
|
|
|
|
setUp(() {
|
|
dependencies = TestAppDependencies();
|
|
clipboard = _Clipboard();
|
|
});
|
|
|
|
Future<void> show(WidgetTester tester) async {
|
|
tester.view.physicalSize = const Size(1000, 1800);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
await tester.pumpWidget(
|
|
testApp(
|
|
Scaffold(
|
|
body: SingleChildScrollView(
|
|
child: AgentsSection(clipboard: clipboard),
|
|
),
|
|
),
|
|
dependencies: dependencies,
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
Future<void> make(WidgetTester tester, String handle) async {
|
|
await tester.tap(find.text('Make an agent'));
|
|
await tester.pumpAndSettle();
|
|
await tester.enterText(find.byType(TextField).first, 'Claude');
|
|
await tester.enterText(find.byType(TextField).last, handle);
|
|
await tester.pump();
|
|
await tester.tap(find.widgetWithText(FilledButton, 'Make'));
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
testWidgets('nothing where the instance offers no agents', (tester) async {
|
|
dependencies.agentGateway.isOffered = false;
|
|
|
|
await show(tester);
|
|
|
|
expect(find.text('Agents'), findsNothing);
|
|
});
|
|
|
|
testWidgets('makes an agent and shows its token once, to copy', (
|
|
tester,
|
|
) async {
|
|
await show(tester);
|
|
expect(find.text('No agents yet.'), findsOneWidget);
|
|
|
|
await make(tester, 'claude_bot');
|
|
|
|
expect(find.text('Token for @claude_bot'), findsOneWidget);
|
|
expect(find.text('TOKEN-1'), findsOneWidget);
|
|
await tester.tap(find.text('Copy token'));
|
|
await tester.pump();
|
|
expect(clipboard.copied, ['TOKEN-1']);
|
|
|
|
await tester.tap(find.text('Done'));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('TOKEN-1'), findsNothing);
|
|
expect(find.text('Claude'), findsOneWidget);
|
|
expect(find.text('@claude_bot · never signed in'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('a handle someone has is said so in the dialog', (tester) async {
|
|
dependencies.agentGateway.taken.add('claude_bot');
|
|
await show(tester);
|
|
|
|
await make(tester, 'claude_bot');
|
|
|
|
expect(find.text('Someone else has this handle.'), findsOneWidget);
|
|
expect(find.byType(AlertDialog), findsOneWidget);
|
|
expect(dependencies.agentGateway.agents, isEmpty);
|
|
});
|
|
|
|
testWidgets('takes a token back and deletes, each once confirmed', (
|
|
tester,
|
|
) async {
|
|
await show(tester);
|
|
await make(tester, 'claude_bot');
|
|
await tester.tap(find.text('Done'));
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.byTooltip('Options for @claude_bot'));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('Take back token'));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text("Take back @claude_bot's token?"), findsOneWidget);
|
|
await tester.tap(find.widgetWithText(FilledButton, 'Take back token'));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('@claude_bot · no token'), findsOneWidget);
|
|
|
|
await tester.tap(find.byTooltip('Options for @claude_bot'));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('Delete'));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Delete @claude_bot?'), findsOneWidget);
|
|
await tester.tap(find.widgetWithText(FilledButton, 'Delete'));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('No agents yet.'), findsOneWidget);
|
|
expect(dependencies.agentGateway.agents, isEmpty);
|
|
});
|
|
}
|