feat(judgement): refuse privileged and undeclared actions in chat (#2071)
Connector actions and lookups now declare privilege change and secret access, and an MCP server declares both per installation. Chat withholds and refuses any tool that has either effect or declared nothing, in judgement and at execution, so an approval cannot convert the refusal. Workflows and the dashboard are unchanged.
This commit is contained in:
19 files changed
+660
-73
No files matched your search
@@ -853,10 +853,17 @@ export interface Extension {
|
||||
credentials?: Record<string, string>;
|
||||
/** An MCP server's declared tools, as it was accepted with them. */
|
||||
tools?: unknown;
|
||||
/** An MCP server's declared privileged effects; absent until declared. */
|
||||
effects?: ServerEffects;
|
||||
/** A connector's declarations; absent until it has loaded. */
|
||||
capabilities?: Capabilities;
|
||||
}
|
||||
|
||||
export interface ServerEffects {
|
||||
privilege_change: boolean;
|
||||
secret_access: boolean;
|
||||
}
|
||||
|
||||
export interface ExtensionInput {
|
||||
path?: string;
|
||||
sha256?: string;
|
||||
@@ -867,6 +874,7 @@ export interface ExtensionInput {
|
||||
settings?: Record<string, string>;
|
||||
credentials?: Record<string, string>;
|
||||
tools?: unknown;
|
||||
effects?: ServerEffects;
|
||||
}
|
||||
|
||||
export interface Credential {
|
||||
|
||||
@@ -50,10 +50,27 @@ function declared(ext: Extension) {
|
||||
}
|
||||
|
||||
const mcp = computed(() => props.kind === "mcp-servers");
|
||||
|
||||
/** What an operator declares about an MCP server's tools. Chat offers a server
|
||||
* only when its effects are declared and neither one applies. */
|
||||
const EFFECT_OPTIONS = [
|
||||
{ value: "unset", label: "Not declared", effects: undefined },
|
||||
{ value: "none", label: "No privileged effects", effects: { privilege_change: false, secret_access: false } },
|
||||
{ value: "privilege_change", label: "Changes privileges", effects: { privilege_change: true, secret_access: false } },
|
||||
{ value: "secret_access", label: "Accesses secrets", effects: { privilege_change: false, secret_access: true } },
|
||||
{ value: "both", label: "Changes privileges and accesses secrets", effects: { privilege_change: true, secret_access: true } },
|
||||
] as const;
|
||||
|
||||
function effectOf(ext?: Extension): string {
|
||||
const e = ext?.effects;
|
||||
if (!e) return "unset";
|
||||
if (e.privilege_change && e.secret_access) return "both";
|
||||
return e.privilege_change ? "privilege_change" : e.secret_access ? "secret_access" : "none";
|
||||
}
|
||||
const editing = ref(false);
|
||||
const isNew = ref(true);
|
||||
const schema = ref<Extension["settings_schema"]>([]);
|
||||
const form = ref({ name: "", path: "", sha256: "", url: "", args: "", egress: "", env: "", credentials: "", tools: "", settings: {} as Record<string, string>, other: "" });
|
||||
const form = ref({ name: "", path: "", sha256: "", url: "", args: "", egress: "", env: "", credentials: "", tools: "", effects: "unset", settings: {} as Record<string, string>, other: "" });
|
||||
function open(ext?: Extension): void {
|
||||
isNew.value = !ext;
|
||||
actionError.value = "";
|
||||
@@ -70,6 +87,7 @@ function open(ext?: Extension): void {
|
||||
env: (ext?.env ?? []).join("\n"),
|
||||
credentials: toLines(ext?.credentials ?? {}),
|
||||
tools: ext?.tools ? JSON.stringify(ext.tools, null, 2) : "[]",
|
||||
effects: effectOf(ext),
|
||||
settings: Object.fromEntries(Object.entries(settings).filter(([k]) => known.has(k))),
|
||||
other: toLines(Object.fromEntries(Object.entries(settings).filter(([k]) => !known.has(k)))),
|
||||
};
|
||||
@@ -97,6 +115,7 @@ async function submit(): Promise<void> {
|
||||
body.url = f.url.trim() || undefined;
|
||||
body.args = list(f.args);
|
||||
body.tools = JSON.parse(f.tools || "[]");
|
||||
body.effects = EFFECT_OPTIONS.find((o) => o.value === f.effects)?.effects;
|
||||
}
|
||||
await api.acceptExtension(props.kind, f.name.trim(), body);
|
||||
editing.value = false;
|
||||
@@ -171,6 +190,12 @@ async function remove(): Promise<void> {
|
||||
<SettingRow label="Arguments" for="ext-args" hint="One per line."><Textarea id="ext-args" v-model="form.args" class="font-mono" rows="2" /></SettingRow>
|
||||
<SettingRow label="Tools" for="ext-tools" hint="The tools it may offer, as JSON: name, kind, read_only, reversibility, summary."><Textarea id="ext-tools" v-model="form.tools" class="font-mono" rows="5" /></SettingRow>
|
||||
</template>
|
||||
<SettingRow v-if="mcp" label="Effects" for="ext-effects" hint="Chat offers a server only once this says its tools change no privileges and access no secrets.">
|
||||
<Select v-model="form.effects">
|
||||
<SelectTrigger id="ext-effects" class="w-full"><SelectValue /></SelectTrigger>
|
||||
<SelectContent><SelectItem v-for="o in EFFECT_OPTIONS" :key="o.value" :value="o.value">{{ o.label }}</SelectItem></SelectContent>
|
||||
</Select>
|
||||
</SettingRow>
|
||||
<SettingRow v-for="field in schema" :key="field.key" :label="field.label || field.key" :for="`ext-set-${field.key}`" :hint="field.description">
|
||||
<Select v-if="field.options?.length" v-model="form.settings[field.key]">
|
||||
<SelectTrigger :id="`ext-set-${field.key}`" class="w-full"><SelectValue /></SelectTrigger>
|
||||
|
||||
Reference in new issue
Block a user