Compare commits
3 Commits
b90306ea4b
...
f7edc59abb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7edc59abb | ||
|
|
be01127098 | ||
|
|
33c1bd3866 |
@@ -158,10 +158,18 @@ pub async fn memory_search(
|
||||
// Build search query
|
||||
let query = options.query.unwrap_or_default();
|
||||
|
||||
// When query is empty, use min_similarity=0.0 to trigger table scan
|
||||
// (FTS5 requires non-empty query; without this, empty query returns 0 results)
|
||||
let min_similarity = if query.trim().is_empty() {
|
||||
Some(0.0)
|
||||
} else {
|
||||
options.min_importance.map(|i| (i as f32) / 10.0)
|
||||
};
|
||||
|
||||
let find_options = zclaw_growth::FindOptions {
|
||||
scope,
|
||||
limit: options.limit.or(Some(50)),
|
||||
min_similarity: options.min_importance.map(|i| (i as f32) / 10.0),
|
||||
min_similarity,
|
||||
};
|
||||
|
||||
let entries = zclaw_growth::VikingStorage::find(storage.as_ref(), &query, find_options).await
|
||||
|
||||
@@ -381,6 +381,15 @@ export function AutonomyConfig({ className = '', onConfigChange }: AutonomyConfi
|
||||
})
|
||||
}
|
||||
/>
|
||||
<ActionToggle
|
||||
label="自动触发 Hand 能力"
|
||||
enabled={config.allowedActions.handAutoTrigger}
|
||||
onChange={(enabled) =>
|
||||
updateConfig({
|
||||
allowedActions: { ...config.allowedActions, handAutoTrigger: enabled },
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ export interface AutonomyConfig {
|
||||
selfModification: boolean;
|
||||
autoCompaction: boolean;
|
||||
autoReflection: boolean;
|
||||
handAutoTrigger: boolean;
|
||||
};
|
||||
approvalThreshold: {
|
||||
importanceMax: number; // Auto-approve if importance <= this (default: 5)
|
||||
@@ -112,6 +113,7 @@ export const DEFAULT_AUTONOMY_CONFIGS: Record<AutonomyLevel, AutonomyConfig> = {
|
||||
selfModification: false,
|
||||
autoCompaction: false,
|
||||
autoReflection: false,
|
||||
handAutoTrigger: false,
|
||||
},
|
||||
approvalThreshold: {
|
||||
importanceMax: 0,
|
||||
@@ -129,6 +131,7 @@ export const DEFAULT_AUTONOMY_CONFIGS: Record<AutonomyLevel, AutonomyConfig> = {
|
||||
selfModification: false,
|
||||
autoCompaction: true,
|
||||
autoReflection: true,
|
||||
handAutoTrigger: false,
|
||||
},
|
||||
approvalThreshold: {
|
||||
importanceMax: 5,
|
||||
@@ -146,6 +149,7 @@ export const DEFAULT_AUTONOMY_CONFIGS: Record<AutonomyLevel, AutonomyConfig> = {
|
||||
selfModification: false, // Always require approval for self-modification
|
||||
autoCompaction: true,
|
||||
autoReflection: true,
|
||||
handAutoTrigger: true,
|
||||
},
|
||||
approvalThreshold: {
|
||||
importanceMax: 7,
|
||||
@@ -265,7 +269,7 @@ export class AutonomyManager {
|
||||
skill_uninstall: 'skillAutoInstall',
|
||||
config_change: null,
|
||||
workflow_trigger: 'autoCompaction',
|
||||
hand_trigger: null,
|
||||
hand_trigger: 'handAutoTrigger',
|
||||
llm_call: 'autoReflection',
|
||||
reflection_run: 'autoReflection',
|
||||
compaction_run: 'autoCompaction',
|
||||
|
||||
@@ -157,16 +157,41 @@ export async function clearSaaSSession(): Promise<void> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist the connection mode to localStorage.
|
||||
* Persist the connection mode to localStorage with timestamp.
|
||||
*/
|
||||
export function saveConnectionMode(mode: string): void {
|
||||
localStorage.setItem(SAASMODE_KEY, mode);
|
||||
const data = JSON.stringify({ mode, timestamp: Date.now() });
|
||||
localStorage.setItem(SAASMODE_KEY, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the connection mode from localStorage.
|
||||
* Handles both new JSON format and legacy plain string format.
|
||||
* Returns null if not set.
|
||||
*/
|
||||
export function loadConnectionMode(): string | null {
|
||||
return localStorage.getItem(SAASMODE_KEY);
|
||||
const raw = localStorage.getItem(SAASMODE_KEY);
|
||||
if (!raw) return null;
|
||||
try {
|
||||
const parsed = JSON.parse(raw);
|
||||
if (typeof parsed === 'string') return parsed; // legacy format
|
||||
return parsed.mode ?? null;
|
||||
} catch {
|
||||
return raw; // legacy format (plain string)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the timestamp of the persisted connection mode.
|
||||
* Returns null if not set or format is legacy.
|
||||
*/
|
||||
export function loadConnectionModeTimestamp(): number | null {
|
||||
const raw = localStorage.getItem(SAASMODE_KEY);
|
||||
if (!raw) return null;
|
||||
try {
|
||||
const parsed = JSON.parse(raw);
|
||||
return parsed.timestamp ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,8 +818,11 @@ export const useSaaSStore = create<SaaSStore>((set, get) => {
|
||||
account,
|
||||
saasUrl: restored.saasUrl,
|
||||
authToken: newToken,
|
||||
connectionMode: loadConnectionMode() === 'saas' ? 'saas' : 'tauri',
|
||||
// If token refresh succeeded, always restore to 'saas' mode
|
||||
// regardless of what was persisted (heartbeat may have degraded to 'tauri')
|
||||
connectionMode: 'saas',
|
||||
});
|
||||
saveConnectionMode('saas');
|
||||
get().fetchAvailableModels().catch(() => {});
|
||||
get().fetchAvailableTemplates().catch(() => {});
|
||||
get().fetchAssignedTemplate().catch(() => {});
|
||||
|
||||
Reference in New Issue
Block a user