fix(daemon): execute dashboard identities with scoped authority
This commit is contained in:
1 parent
6a6db5737a
commit
2181dd8a48
22 files changed
+508
-75
No files matched your search
@@ -177,6 +177,7 @@ export const api = {
|
||||
method: "POST",
|
||||
body: workspace,
|
||||
}),
|
||||
orgAgents: <T = unknown>(id: string) => request<T>(`/api/orgs/${encodeURIComponent(id)}/agents`),
|
||||
orgMembers: <T = unknown>(id: string) =>
|
||||
request<T>(`/api/orgs/${encodeURIComponent(id)}/members`),
|
||||
addOrgMember: <T = unknown>(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { storeToRefs } from "pinia";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { onMounted, ref, watch } from "vue";
|
||||
import { Bot, KeyRound, Plus, ShieldCheck, User } from "@lucide/vue";
|
||||
|
||||
import IdentityGrantsCard from "@/settings/IdentityGrantsCard.vue";
|
||||
@@ -28,17 +28,8 @@ import {
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { api } from "@/lib/api";
|
||||
import { useOrgStore, type Identity } from "@/stores/org";
|
||||
import type { Member } from "./org";
|
||||
|
||||
/**
|
||||
* The org's agents and service accounts: their lifecycle, and the org each
|
||||
* serves. Credential grants are the control-plane draft below, so the settings
|
||||
* save bar rides along with it.
|
||||
*
|
||||
* An agent's assignment is not readable over the API; the org's member list is,
|
||||
* and a bot or service account is a member of the org it serves. The badge
|
||||
* reads that, and Assign writes the assignment directly.
|
||||
*/
|
||||
// Agent assignment is independent of membership roles.
|
||||
const store = useOrgStore();
|
||||
const { org } = storeToRefs(store);
|
||||
store.watchIdentities();
|
||||
@@ -48,16 +39,16 @@ const error = ref("");
|
||||
const busy = ref("");
|
||||
|
||||
async function load(): Promise<void> {
|
||||
if (!org.value) return;
|
||||
const id = org.value?.id;
|
||||
serves.value = new Set();
|
||||
if (!id) return;
|
||||
try {
|
||||
const response = await api.orgMembers<{ members: Member[] }>(org.value.id);
|
||||
serves.value = new Set(
|
||||
response.members
|
||||
.filter((m) => !m.workspace_id)
|
||||
.map((m) => m.identity_id),
|
||||
);
|
||||
const response = await api.orgAgents<{ agents: Identity[] }>(id);
|
||||
if (org.value?.id !== id) return;
|
||||
serves.value = new Set(response.agents.map((agent) => agent.id));
|
||||
error.value = "";
|
||||
} catch (cause) {
|
||||
error.value = String((cause as Error).message || cause);
|
||||
if (org.value?.id === id) error.value = String((cause as Error).message || cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +62,8 @@ onMounted(async () => {
|
||||
await load();
|
||||
});
|
||||
|
||||
watch(() => org.value?.id, () => void load());
|
||||
|
||||
const name = ref("");
|
||||
const kind = ref<Identity["kind"]>("bot");
|
||||
async function create(): Promise<void> {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { NativeSelect, NativeSelectOption } from "@/components/ui/native-select";
|
||||
import { computed, ref } from "vue";
|
||||
import { computed, ref, onMounted } from "vue";
|
||||
import { Plus, Trash2, X } from "@lucide/vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -10,6 +10,8 @@ import { Badge } from "@/components/ui/badge";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { statusKind, statusLabel, type Binding } from "@/bindings/binding-draft";
|
||||
import { api } from "@/lib/api";
|
||||
import type { Identity } from "@/stores/org";
|
||||
import { useOrgStore } from "@/stores/org";
|
||||
import BindEvent from "./BindEvent.vue";
|
||||
import { setWorkflowField, workflowField } from "./workflow-edit";
|
||||
@@ -61,8 +63,22 @@ function addSpec(key: "inputs" | "outputs", list: [string, Spec][]): void {
|
||||
// The identity a run acts as must be an agent, never a person; a workflow
|
||||
// naming none is refused when it runs.
|
||||
const identities = useOrgStore();
|
||||
identities.watchIdentities();
|
||||
const agents = computed(() => identities.identities.filter((i) => i.kind !== "user" && i.lifecycle === "active"));
|
||||
const agents = ref<Identity[]>([]);
|
||||
const identitiesLoading = ref(true);
|
||||
const identitiesError = ref("");
|
||||
async function loadAgents(): Promise<void> {
|
||||
identitiesLoading.value = true;
|
||||
identitiesError.value = "";
|
||||
agents.value = [];
|
||||
try {
|
||||
await identities.loadOrg();
|
||||
const response = await api.orgAgents<{ agents: Identity[] }>(identities.homeOrg);
|
||||
agents.value = response.agents.filter((agent) => agent.lifecycle === "active");
|
||||
} catch (cause) {
|
||||
identitiesError.value = String((cause as Error).message || cause);
|
||||
} finally { identitiesLoading.value = false; }
|
||||
}
|
||||
onMounted(loadAgents);
|
||||
|
||||
const MODES = [
|
||||
{ value: "required", label: "Repository", hint: "Clones the task's repository" },
|
||||
@@ -150,18 +166,20 @@ function setNeeds(next: { captures?: boolean; gate_retries?: number }): void {
|
||||
<div class="divide-y divide-border rounded-md border border-border">
|
||||
<label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
|
||||
<span class="flex-1 text-[13px]">Identity</span>
|
||||
<Input
|
||||
<NativeSelect
|
||||
:model-value="text('identity')"
|
||||
list="workflow-identities"
|
||||
placeholder="required"
|
||||
title="Every run acts as this identity; a workflow naming none is refused."
|
||||
:class="cn('h-7 w-44 text-[13px]', !text('identity') && 'border-danger/60')"
|
||||
@change="set('identity', ($event.target as HTMLInputElement).value.trim())"
|
||||
/>
|
||||
<datalist id="workflow-identities">
|
||||
<option v-for="agent in agents" :key="agent.id" :value="agent.id">{{ agent.display_name }}</option>
|
||||
</datalist>
|
||||
aria-label="Execution identity"
|
||||
:disabled="identitiesLoading || !!identitiesError"
|
||||
:class="cn('w-44 text-[13px]', !text('identity') && 'border-danger/60')"
|
||||
@update:model-value="(value) => set('identity', String(value))"
|
||||
>
|
||||
<NativeSelectOption value="" disabled>{{ identitiesLoading ? 'Loading agents…' : 'Choose an agent' }}</NativeSelectOption>
|
||||
<NativeSelectOption v-if="text('identity') && !agents.some((agent) => agent.id === text('identity'))" :value="text('identity')" disabled>{{ text('identity') === 'root' ? 'Existing instance agent' : 'Unavailable agent' }}</NativeSelectOption>
|
||||
<NativeSelectOption v-for="agent in agents" :key="agent.id" :value="agent.id">{{ agent.display_name }}</NativeSelectOption>
|
||||
</NativeSelect>
|
||||
</label>
|
||||
<p v-if="identitiesError" role="alert" class="px-3 py-2 text-xs text-danger">{{ identitiesError }} <Button variant="link" size="xs" @click="loadAgents">Retry</Button></p>
|
||||
<p v-else-if="!identitiesLoading && !agents.length" class="px-3 py-2 text-xs text-fg-subtle">No active agents are assigned to your organisation.</p>
|
||||
<label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
|
||||
<span class="flex-1 text-[13px]">Container profile</span>
|
||||
<Input
|
||||
|
||||
Reference in new issue
Block a user