feat(app,learn,todo): the assistants in Settings and on the operator's screen

ADR 0021, step 2's app half. halkyon_app asks the module's assistant
endpoints (ServerpodAssistantGateway, ServerpodAssistantOperatorGateway)
and a person's own provider directly (halkyon_llm), behind
AssistantRepository: an AssistantChoice is a GrantedAssistant, asked
through the instance, which counts it, or a PersonalAssistant with the
person's own key, which the instance never sees. assistant_messages.dart
turns a conversation into the endpoint's models and back.

AssistantsCard, for an app's settings: what is granted and left of its
limits, agreed to once on a sheet saying what goes where, the person's
use by UTC month, the instance's privacy page, and their own assistants
where the operator allows own keys (kept ones stay listed, unasked,
where it doesn't). AssistantGrantsCard on InstanceOperatorScreen: grants
by handle with their limits in the pricing's unit, changed and taken
back after asking, everyone's use by month; a found account's menu
grants too. Nothing shows where nothing is offered or can be read.
package:halkyon_app/assistant_models.dart holds the models in pure Dart.

Learn keeps own assistants in the person's settings (ownAssistants,
schema 12, SettingsOwnAssistants); SettingsRepository.update refuses
(OwnAssistantRefused) to write a key where the settings would not be
sealed (SettingsGateway.seals). Learn depends on halkyon_llm directly.
Todo wires the gateways; a member offers no assistant. No feature asks
an assistant yet (step 3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-25 18:59:41 +01:00
commit 36899cdc3b
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
2 changed files with 7505 additions and 46 deletions

View file

@ -17,6 +17,10 @@ class FakeSettingsGateway() implements SettingsGateway {
/// The ids of the deleted rows, in order.
final deleted = <String>[];
/// Whether what it writes is sealed with the person's key, as on a device
/// holding the account's keys.
bool sealing = true;
/// Stores the row [id] as if another device had written it and a sync had
/// brought it here.
void receiveRemoteRow(String id, ByteData payload) {
@ -52,6 +56,9 @@ class FakeSettingsGateway() implements SettingsGateway {
deleted.add(id);
}
@override
Future<bool> seals() async => sealing;
@override
Stream<void> get remoteChanges => _remoteChanges.stream;
}

View file

@ -178,7 +178,13 @@ Dependencies testDependencies({
FakeSimpleLoginGateway? simpleLoginGateway,
// Nobody operates the instance unless a test says so.
InstanceOperatorGateway? operatorGateway,
// Nothing offered unless a test offers it.
AssistantGateway? assistantGateway,
AssistantOperatorGateway? assistantOperatorGateway,
// A person's own key's provider; none answers unless scripted.
FakeLlmClient? llm,
}) {
final operators = operatorGateway ?? FakeInstanceOperatorGateway();
final device = deviceDictionaries ?? noDeviceDictionaries();
final auth = authGateway ?? FakeAuthGateway();
final addresses = signInAddresses ?? MemorySignInAddresses();
@ -205,8 +211,14 @@ Dependencies testDependencies({
callbackScheme: 'app.halkyon.learn',
loopbackPort: 43823,
),
instanceOperators: InstanceOperatorRepository(
operatorGateway ?? FakeInstanceOperatorGateway(),
instanceOperators: InstanceOperatorRepository(operators),
assistants: AssistantRepository(
assistantGateway ?? FakeAssistantGateway(),
llm: llm ?? FakeLlmClient(),
),
assistantOperators: AssistantOperatorRepository(
assistantOperatorGateway ?? FakeAssistantOperatorGateway(),
operators,
),
sourceCodeUrl:
sourceCodeUrl ?? () async => 'https://example.org/halkyon-learn',