DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
const PERMISSION_SETTINGS_NS = "permission";
function permissionDefaultOf(view, catalog) {
const currentValue = view.value.defaultPreset ?? catalog.defaultPreset;
const options = catalog.defaultOptions.map((option) => ({
id: option.value,
label: displayPermissionPreset(option.value, option.name)
}));
if (!options.some((option) => option.id === currentValue)) throw new Error("permission catalog does not advertise its current default");
return {
currentValue,
options
};
}
var PermissionPresetSettingsController = class {
describeFace;
ctx;
catalog;
store = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)({
status: "idle",
error: null,
writable: false,
currentValue: "",
options: [],
revision: 0
});
following;
followingCatalog;
saving = false;
disposed = false;
constructor(describeFace, ctx, catalog) {
this.describeFace = describeFace;
this.ctx = ctx;
this.catalog = catalog;
}
async load() {
if (this.disposed) return;
this.following ??= this.describeFace.subscribe(() => {
this.derive();
});
this.followingCatalog ??= this.catalog.store.subscribe(() => {
this.derive();
});
this.store.update((state) => {
state.status = "loading";
state.error = null;
});
await this.describeFace.ensure();
if (this.describeFace.getSnapshot().status !== "unavailable") try {
await this.catalog.load();
} catch (error) {
this.fail(error);
return;
}
this.derive();
}
async select(preset) {
const state = this.store.getSnapshot();
const view = this.describeFace.getSnapshot().view?.namespaces.find((entry) => entry.ns === PERMISSION_SETTINGS_NS);
if (view === void 0 || !state.writable || this.saving) return;
this.saving = true;
this.store.update((draft) => {
draft.status = "saving";
draft.error = null;
});
let response;
try {
response = await this.ctx.remote.settings.mutate(PERMISSION_SETTINGS_NS, [{
op: "set",
path: ["defaultPreset"],
value: preset
}], view.revision);
} finally {
this.saving = false;
}
if (this.disposed) return;
if (!response.ok) {
this.fail(response.error);
return;
}
this.describeFace.acceptView(response.value);
}
dispose() {
this.disposed = true;
this.following?.();
this.following = void 0;
this.followingCatalog?.();
this.followingCatalog = void 0;
}
derive() {
if (this.disposed || this.saving) return;
const mirrored = this.describeFace.getSnapshot();
if (mirrored.status === "unavailable") {
this.store.update((state) => {
state.status = "unavailable";
state.writable = false;
state.currentValue = "";
state.options = [];
});
return;
}
if (mirrored.view === void 0) {
if (mirrored.error !== null) this.fail(new Error(mirrored.error));
return;
}
const view = mirrored.view.namespaces.find((entry) => entry.ns === PERMISSION_SETTINGS_NS);
if (view === void 0) {
this.store.update((state) => {
state.status = "unavailable";
state.writable = false;
state.currentValue = "";
state.options = [];
});
return;
}
try {
const catalog = this.catalog.store.getSnapshot().value;
if (catalog === null) return;
const resolved = permissionDefaultOf(view, catalog);
const { writable } = mirrored.view;
this.store.update((state) => {
state.status = "ready";
state.error = null;
state.writable = writable;
state.currentValue = resolved.currentValue;
state.options = resolved.options;
state.revision = view.revision;
});
} catch (error) {
this.fail(error);
}
}
fail(error) {
this.store.update((state) => {
state.status = "error";
state.error = error instanceof Error ? error.message : String(error);
});
}
};