Compare commits
3 Commits
b90306ea4b
...
f7edc59abb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7edc59abb | ||
|
|
be01127098 | ||
|
|
33c1bd3866 |
@@ -158,10 +158,18 @@ pub async fn memory_search(
|
|||||||
// Build search query
|
// Build search query
|
||||||
let query = options.query.unwrap_or_default();
|
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 {
|
let find_options = zclaw_growth::FindOptions {
|
||||||
scope,
|
scope,
|
||||||
limit: options.limit.or(Some(50)),
|
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
|
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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export interface AutonomyConfig {
|
|||||||
selfModification: boolean;
|
selfModification: boolean;
|
||||||
autoCompaction: boolean;
|
autoCompaction: boolean;
|
||||||
autoReflection: boolean;
|
autoReflection: boolean;
|
||||||
|
handAutoTrigger: boolean;
|
||||||
};
|
};
|
||||||
approvalThreshold: {
|
approvalThreshold: {
|
||||||
importanceMax: number; // Auto-approve if importance <= this (default: 5)
|
importanceMax: number; // Auto-approve if importance <= this (default: 5)
|
||||||
@@ -112,6 +113,7 @@ export const DEFAULT_AUTONOMY_CONFIGS: Record<AutonomyLevel, AutonomyConfig> = {
|
|||||||
selfModification: false,
|
selfModification: false,
|
||||||
autoCompaction: false,
|
autoCompaction: false,
|
||||||
autoReflection: false,
|
autoReflection: false,
|
||||||
|
handAutoTrigger: false,
|
||||||
},
|
},
|
||||||
approvalThreshold: {
|
approvalThreshold: {
|
||||||
importanceMax: 0,
|
importanceMax: 0,
|
||||||
@@ -129,6 +131,7 @@ export const DEFAULT_AUTONOMY_CONFIGS: Record<AutonomyLevel, AutonomyConfig> = {
|
|||||||
selfModification: false,
|
selfModification: false,
|
||||||
autoCompaction: true,
|
autoCompaction: true,
|
||||||
autoReflection: true,
|
autoReflection: true,
|
||||||
|
handAutoTrigger: false,
|
||||||
},
|
},
|
||||||
approvalThreshold: {
|
approvalThreshold: {
|
||||||
importanceMax: 5,
|
importanceMax: 5,
|
||||||
@@ -146,6 +149,7 @@ export const DEFAULT_AUTONOMY_CONFIGS: Record<AutonomyLevel, AutonomyConfig> = {
|
|||||||
selfModification: false, // Always require approval for self-modification
|
selfModification: false, // Always require approval for self-modification
|
||||||
autoCompaction: true,
|
autoCompaction: true,
|
||||||
autoReflection: true,
|
autoReflection: true,
|
||||||
|
handAutoTrigger: true,
|
||||||
},
|
},
|
||||||
approvalThreshold: {
|
approvalThreshold: {
|
||||||
importanceMax: 7,
|
importanceMax: 7,
|
||||||
@@ -265,7 +269,7 @@ export class AutonomyManager {
|
|||||||
skill_uninstall: 'skillAutoInstall',
|
skill_uninstall: 'skillAutoInstall',
|
||||||
config_change: null,
|
config_change: null,
|
||||||
workflow_trigger: 'autoCompaction',
|
workflow_trigger: 'autoCompaction',
|
||||||
hand_trigger: null,
|
hand_trigger: 'handAutoTrigger',
|
||||||
llm_call: 'autoReflection',
|
llm_call: 'autoReflection',
|
||||||
reflection_run: 'autoReflection',
|
reflection_run: 'autoReflection',
|
||||||
compaction_run: 'autoCompaction',
|
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 {
|
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.
|
* Load the connection mode from localStorage.
|
||||||
|
* Handles both new JSON format and legacy plain string format.
|
||||||
* Returns null if not set.
|
* Returns null if not set.
|
||||||
*/
|
*/
|
||||||
export function loadConnectionMode(): string | null {
|
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,
|
account,
|
||||||
saasUrl: restored.saasUrl,
|
saasUrl: restored.saasUrl,
|
||||||
authToken: newToken,
|
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().fetchAvailableModels().catch(() => {});
|
||||||
get().fetchAvailableTemplates().catch(() => {});
|
get().fetchAvailableTemplates().catch(() => {});
|
||||||
get().fetchAssignedTemplate().catch(() => {});
|
get().fetchAssignedTemplate().catch(() => {});
|
||||||
|
|||||||
Reference in New Issue
Block a user