feat(moments): the human door onto mounts, mappings and per-moment telemetry (milestone 458 step 6, #4924)
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 18s
CI & Build / TypeScript typecheck (push) Successful in 54s
CI & Build / Python tests (push) Failing after 1m34s
CI & Build / Build & push image (push) Skipped
CI & Build / integration (push) Successful in 2m7s
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 18s
CI & Build / TypeScript typecheck (push) Successful in 54s
CI & Build / Python tests (push) Failing after 1m34s
CI & Build / Build & push image (push) Skipped
CI & Build / integration (push) Successful in 2m7s
Everything an agent can do with moments, a person can now see and change in the app. - Rule editor: a moment picker beside the trigger. Catalog moments are ticked; a named procedure's `skill.<name>` is typed and checked as the server checks it. `moments` is always sent, so unticking the last moment unmounts the rule. - Settings, Moments section (General tab): for each moment, what it means, the actions that reach it on this install (shipped ones can be switched off, the install's own removed), how many rules are mounted on it, and deliveries and agent opens over the window. Below that: named procedures with mounts, switched-off defaults with Restore, and a form to add an action. - retrieval_telemetry.moment_usage: per moment, `delivered`, `rules`, `opened` (agent pulls after the first delivery there; an upper bound, as by_source is) and `last_delivered_at`. No ratio, because a mount is a person's statement, not a ranker's guess. Guarded on its own, and also reported in retrieval_summary as `moment_usage`. - rulebooks.mount_counts; mounted_moments now derives from it. - GET /api/retrieval/moments carries `mounted` and `usage` (?days=). DELETE /moments/mappings also reads the mapping from query parameters, since the browser's DELETE sends no body. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import { ref } from "vue";
|
||||
import { defineStore } from "pinia";
|
||||
import * as api from "@/api/moments";
|
||||
import type { MappingChange, MomentsPayload } from "@/api/moments";
|
||||
import { useToastStore } from "@/stores/toast";
|
||||
import { apiErrorMessage } from "@/api/client";
|
||||
|
||||
/**
|
||||
* The moment catalog and this install's mappings (milestone 458 step 6).
|
||||
*
|
||||
* Shared by the rule editor's picker and the Settings section, so the two
|
||||
* cannot offer different moments. The catalog is the product's and changes
|
||||
* only with a release; the mappings and counts change with every write here,
|
||||
* so a write re-reads the whole payload rather than patching it locally.
|
||||
*/
|
||||
export const useMomentsStore = defineStore("moments", () => {
|
||||
const data = ref<MomentsPayload | null>(null);
|
||||
const loading = ref(false);
|
||||
const failed = ref(false);
|
||||
|
||||
async function fetch(force = false) {
|
||||
if (data.value && !force) return data.value;
|
||||
loading.value = true;
|
||||
try {
|
||||
data.value = await api.getMoments();
|
||||
failed.value = false;
|
||||
} catch {
|
||||
// The picker rides on the rule editor: an unreachable catalog hides
|
||||
// the picker, it does not break the form it sits in.
|
||||
failed.value = true;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
return data.value;
|
||||
}
|
||||
|
||||
async function change(kind: "map" | "unmap", mapping: MappingChange) {
|
||||
try {
|
||||
if (kind === "map") await api.mapAction(mapping);
|
||||
else await api.unmapAction(mapping);
|
||||
} catch (e) {
|
||||
useToastStore().show(
|
||||
apiErrorMessage(e, kind === "map" ? "Could not add the mapping" : "Could not remove the mapping"),
|
||||
"error",
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
await fetch(true);
|
||||
}
|
||||
|
||||
return {
|
||||
data, loading, failed, fetch,
|
||||
map: (m: MappingChange) => change("map", m),
|
||||
unmap: (m: MappingChange) => change("unmap", m),
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user