fix(skill): do not fail installs on non-blocking observations (#4246)

* fix(skill): do not fail installs on non-blocking observations

A working skill was rejected when the installer recorded a docs mismatch
as a blocker. Keep real setup failures in blockers and surface harmless
observations as notes.

* style(skill): wrap the install-report validation error

* feat(frontend): compact skill cards and install progress

Show each sandbox install on the card and collapse installer prompts, so
the skills page stays readable when a skill is installed in more than one place.

* fix(chat): include shared KBs in starter questions and stop composer jitter

Agents using all knowledge bases now draw starters from KBs shared into
the tenant, matching chat retrieval. The new-chat page skips refetches
whose scope did not change and only shows the skeleton on first load.
main
lyingbug 2026-10-13 19:47:14 +08:00 committed by GitHub
parent 94fae6de43
commit 4356f8c16d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 572 additions and 176 deletions

View File

@ -102,7 +102,7 @@
<t-button
class="skill-header-uninstall"
theme="danger"
variant="outline"
variant="text"
size="small"
:disabled="!managedSkill || isBusy(managedSkill)"
:loading="!!managedSkill && deletingId === managedSkill.id"
@ -1687,9 +1687,13 @@ onUnmounted(() => {
min-width: 0;
}
:deep(.skill-timeline--compact) {
padding: 0;
}
:deep(.skill-timeline__guidance) {
// Include the drawer's 18px side padding and 16px bottom padding.
--skill-guidance-gutter: 30px;
--skill-guidance-gutter: 18px;
--skill-guidance-bottom-gap: 16px;
margin-bottom: -12px;
padding-bottom: 12px;
@ -1708,9 +1712,13 @@ onUnmounted(() => {
.skill-manage__row {
display: flex;
align-items: flex-start;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 12px 14px;
border: 1px solid var(--td-component-stroke);
border-radius: var(--app-radius-md);
background: var(--td-bg-color-container);
}
.skill-manage__served {
@ -1724,10 +1732,8 @@ onUnmounted(() => {
}
.skill-manage__row--upgrade {
align-items: center;
padding: var(--app-space-2) var(--app-space-3);
border-radius: var(--app-radius-sm);
background: color-mix(in srgb, var(--td-warning-color) 8%, transparent);
border-color: color-mix(in srgb, var(--td-warning-color) 30%, transparent);
background: color-mix(in srgb, var(--td-warning-color) 6%, transparent);
}
.skill-manage__controls {
@ -1761,13 +1767,13 @@ onUnmounted(() => {
flex-direction: column;
align-items: stretch;
gap: 10px;
padding-top: 12px;
border-top: 1px solid var(--td-component-stroke);
padding-top: 4px;
h4 {
margin: 0;
font-size: var(--app-text-md);
font-size: var(--app-text-base);
font-weight: 600;
line-height: 22px;
color: var(--td-text-color-primary);
}

View File

@ -10,7 +10,14 @@
<template v-else>
<div v-for="(msg, index) in messages" :key="msg.id || index" class="skill-timeline__turn"
:class="{ 'skill-timeline__turn--command': index === messages.length - 1 && live && commandOutput && !commandOutput.done }">
<pre v-if="msg.role === 'user'" class="skill-timeline__prompt">{{ msg.content }}</pre>
<details v-if="msg.role === 'user'" class="skill-timeline__prompt">
<summary>
<t-icon name="chevron-right" size="14px" class="skill-timeline__prompt-arrow" />
<span class="skill-timeline__prompt-label">{{ $t('settings.sandbox.skillTranscriptPrompt') }}</span>
<span class="skill-timeline__prompt-preview">{{ promptPreview(msg.content) }}</span>
</summary>
<pre>{{ String(msg.content || '').trim() }}</pre>
</details>
<AgentStreamDisplay
v-else
:session="msg"
@ -31,23 +38,33 @@
</div>
</div>
<div v-if="live || canRetry" class="skill-timeline__guidance">
<t-textarea
v-model="guidanceText"
:placeholder="$t('settings.sandbox.skillGuidance.placeholder')"
:maxlength="10000"
:autosize="{ minRows: 2, maxRows: 6 }"
:disabled="sendingGuidance"
/>
<p v-if="guidanceError" role="alert" class="skill-timeline__guidance-error">{{ guidanceError }}</p>
<div class="skill-timeline__guidance-actions">
<span v-if="live && !guidance.accepting">{{ $t('settings.sandbox.skillGuidance.unavailable') }}</span>
<t-button
size="small"
:loading="sendingGuidance"
:disabled="!guidanceText.trim() || (live && !guidance.accepting)"
@click="sendGuidance"
>{{ $t(live ? 'settings.sandbox.skillGuidance.send' : 'settings.sandbox.skillGuidance.retry') }}</t-button>
<div class="skill-timeline__guidance-box">
<t-textarea
v-model="guidanceText"
:placeholder="$t('settings.sandbox.skillGuidance.placeholder')"
:maxlength="10000"
:autosize="{ minRows: 2, maxRows: 6 }"
:disabled="sendingGuidance"
/>
<div class="skill-timeline__guidance-actions">
<span v-if="live && !guidance.accepting">{{ $t('settings.sandbox.skillGuidance.unavailable') }}</span>
<span v-else-if="guidanceText.length > 9000" class="skill-timeline__guidance-count">
{{ guidanceText.length }}/10000
</span>
<t-button
size="small"
:variant="guidanceText.trim() ? 'base' : 'outline'"
:theme="guidanceText.trim() ? 'primary' : 'default'"
:loading="sendingGuidance"
:disabled="!guidanceText.trim() || (live && !guidance.accepting)"
@click="sendGuidance"
>
<template #icon><t-icon :name="live ? 'send' : 'refresh'" /></template>
{{ $t(live ? 'settings.sandbox.skillGuidance.send' : 'settings.sandbox.skillGuidance.retry') }}
</t-button>
</div>
</div>
<p v-if="guidanceError" role="alert" class="skill-timeline__guidance-error">{{ guidanceError }}</p>
</div>
</section>
</template>
@ -181,6 +198,11 @@ const { handleMsgList, processStreamChunk } = useChatStreamHandler({
// install_prompt is the installer's opening line. It is not an assistant
// event, so it becomes the user turn here rather than going through the chat
// stream handler.
function promptPreview(content: unknown): string {
const line = String(content || '').trim().split('\n')[0] || ''
return line.length > 80 ? `${line.slice(0, 80)}…` : line
}
function applyPrompt(content: string) {
if (!content) return
if (messages.some((msg) => msg.role === 'user')) return
@ -357,7 +379,6 @@ onUnmounted(stop)
margin-top: 12px;
padding-top: 12px;
background: var(--td-bg-color-container);
border-top: 1px solid var(--td-component-stroke);
// Cover the timeline's padding too, so scrolling text cannot peek around
// the sticky composer. Its z-index keeps this backdrop above the transcript.
@ -372,21 +393,46 @@ onUnmounted(stop)
}
.skill-timeline__guidance-message {
margin: 8px 0;
padding: 8px;
background: var(--td-bg-color-container);
padding: 8px 10px;
background: var(--td-bg-color-secondarycontainer);
border-radius: var(--app-radius-sm);
span { font-size: var(--app-text-sm); color: var(--td-text-color-secondary); }
p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
span { font-size: var(--app-text-xs); color: var(--td-text-color-placeholder); }
p { margin: 4px 0 0; font-size: var(--app-text-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
}
.skill-timeline__guidance-box {
border: 1px solid var(--td-component-stroke);
border-radius: var(--app-radius-md);
background: var(--td-bg-color-container);
transition: border-color var(--app-motion-fast) ease, box-shadow var(--app-motion-fast) ease;
&:focus-within {
border-color: var(--td-brand-color);
box-shadow: 0 0 0 2px var(--td-brand-color-focus);
}
:deep(.t-textarea__inner) {
padding: 10px 12px 4px;
border: 0;
box-shadow: none;
background: transparent;
resize: none;
}
:deep(.t-textarea__info_wrapper),
:deep(.t-textarea__limit) {
display: none;
}
}
.skill-timeline__guidance-actions {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 12px;
margin-top: 8px;
span { flex: 1; font-size: var(--app-text-sm); color: var(--td-text-color-secondary); }
padding: 4px 8px 8px 12px;
span { flex: 1; font-size: var(--app-text-xs); color: var(--td-text-color-placeholder); }
}
.skill-timeline__guidance-error { color: var(--td-error-color); font-size: var(--app-text-sm); }
.skill-timeline__guidance-count { font-variant-numeric: tabular-nums; }
.skill-timeline__guidance-error { margin: 6px 0 0; color: var(--td-error-color); font-size: var(--app-text-sm); }
.skill-timeline {
display: flex;
@ -402,17 +448,63 @@ onUnmounted(stop)
}
.skill-timeline__prompt {
max-height: 140px;
margin: 0;
padding: 8px 10px;
overflow-y: auto;
color: var(--td-text-color-secondary);
font-size: var(--app-text-sm);
line-height: 1.6;
background: var(--td-bg-color-container);
border: 1px solid var(--td-component-stroke);
border-radius: var(--app-radius-sm);
white-space: pre-wrap;
word-break: break-word;
background: var(--td-bg-color-container);
summary {
display: flex;
align-items: center;
gap: 6px;
min-width: 0;
padding: 6px 10px;
cursor: pointer;
list-style: none;
font-size: var(--app-text-sm);
line-height: 20px;
color: var(--td-text-color-secondary);
user-select: none;
&::-webkit-details-marker { display: none; }
&:hover { color: var(--td-text-color-primary); }
}
pre {
max-height: 240px;
margin: 0;
padding: 8px 12px 10px;
overflow-y: auto;
border-top: 1px solid var(--td-component-stroke);
color: var(--td-text-color-secondary);
font-size: var(--app-text-xs);
line-height: 1.6;
white-space: pre-wrap;
word-break: break-word;
}
&[open] .skill-timeline__prompt-arrow { transform: rotate(90deg); }
&[open] .skill-timeline__prompt-preview { display: none; }
}
.skill-timeline__prompt-arrow {
flex-shrink: 0;
color: var(--td-text-color-placeholder);
transition: transform var(--app-motion-fast) ease;
}
.skill-timeline__prompt-label {
flex-shrink: 0;
font-weight: 500;
}
.skill-timeline__prompt-preview {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: var(--td-text-color-placeholder);
}
.skill-timeline__empty {
@ -428,11 +520,8 @@ onUnmounted(stop)
border-radius: 0;
}
.skill-timeline--compact .skill-timeline__prompt {
max-height: 72px;
padding: 6px 8px;
font-size: var(--app-text-xs);
line-height: 1.5;
.skill-timeline--compact .skill-timeline__prompt pre {
max-height: 160px;
}
.skill-timeline--compact .skill-timeline__empty {

View File

@ -1828,6 +1828,7 @@ export default {
skillTranscriptLive: 'Install log',
skillTranscriptLiveHint: 'Installing — click to watch',
skillTranscriptTitle: 'Install run',
skillTranscriptPrompt: 'Install instructions',
skillTranscriptHide: 'Hide install run',
skillGuidance: {
placeholder: 'Add installation guidance, such as required CLIs, setup documentation, or environment constraints',
@ -1946,6 +1947,7 @@ export default {
installedCount: 'Installed on {count} sandboxes',
installPanelGroup: 'Installed',
installPanelAvailable: 'Not installed',
installAction: 'Install',
viewInstallProgress: 'View progress',
manageOnSandbox: 'Manage this skill on “{name}”',
manageDrawerDesc: 'Manage enablement, variables, and uninstall on sandbox “{name}”.',

View File

@ -1828,6 +1828,7 @@ export default {
skillTranscriptLive: 'インストールログ',
skillTranscriptLiveHint: 'インストール中 — クリックで表示',
skillTranscriptTitle: 'インストールの実行内容',
skillTranscriptPrompt: 'インストール指示',
skillTranscriptHide: 'インストールの実行内容を非表示',
skillGuidance: {
placeholder: '必要な CLI、インストール手順、環境の制約などを入力',
@ -1946,6 +1947,7 @@ export default {
installedCount: '{count}個のサンドボックスにインストール済み',
installPanelGroup: 'インストール済み',
installPanelAvailable: '未インストール',
installAction: 'インストール',
viewInstallProgress: '進捗を表示',
manageOnSandbox: 'サンドボックス「{name}」でこのスキルを管理',
manageDrawerDesc: 'サンドボックス「{name}」での有効化、変数、アンインストールを管理します。',

View File

@ -6259,6 +6259,7 @@ export default {
skillTranscriptLive: '설치 과정',
skillTranscriptLiveHint: '설치 중입니다. 클릭해서 과정을 보세요',
skillTranscriptTitle: '설치 과정',
skillTranscriptPrompt: '설치 지시',
skillTranscriptHide: 'Hide install run',
skillGuidance: {
placeholder: '필요한 CLI, 설치 문서, 환경 제약 등 설치 안내를 추가하세요',
@ -6377,6 +6378,7 @@ export default {
installedCount: '{count}개 샌드박스에 설치됨',
installPanelGroup: '설치됨',
installPanelAvailable: '미설치',
installAction: '설치',
viewInstallProgress: '진행 상황',
manageOnSandbox: '「{name}」 샌드박스에서 관리',
manageDrawerDesc: '샌드박스 「{name}」에서 사용 여부, 변수, 제거를 관리합니다.',

View File

@ -6259,6 +6259,7 @@ export default {
skillTranscriptLive: 'Ход установки',
skillTranscriptLiveHint: 'Идёт установка — нажмите, чтобы смотреть',
skillTranscriptTitle: 'Ход установки',
skillTranscriptPrompt: 'Инструкции по установке',
skillTranscriptHide: 'Hide install run',
skillGuidance: {
placeholder: 'Добавьте указания по установке: нужные CLI, документацию или ограничения среды',
@ -6377,6 +6378,7 @@ export default {
installedCount: 'Установлен в {count} песочницах',
installPanelGroup: 'Установлено',
installPanelAvailable: 'Не установлено',
installAction: 'Установить',
viewInstallProgress: 'Смотреть ход',
manageOnSandbox: 'Управление в песочнице «{name}»',
manageDrawerDesc: 'В песочнице «{name}» можно включать навык, править переменные и удалять установку.',

View File

@ -6261,6 +6261,7 @@ export default {
skillTranscriptLive: '安装过程',
skillTranscriptLiveHint: '正在安装,点击查看过程',
skillTranscriptTitle: '安装过程',
skillTranscriptPrompt: '安装指令',
skillTranscriptHide: '收起安装过程',
skillGuidance: {
placeholder: '补充安装说明,例如需要安装的 CLI、安装文档或环境限制',
@ -6379,6 +6380,7 @@ export default {
installedCount: '已安装到 {count} 个沙箱',
installPanelGroup: '已安装',
installPanelAvailable: '未安装',
installAction: '安装',
viewInstallProgress: '查看进度',
manageOnSandbox: '管理沙箱「{name}」上的安装',
manageDrawerDesc: '在沙箱「{name}」上管理启用、变量和卸载。',

View File

@ -6261,6 +6261,7 @@ export default {
skillTranscriptLive: '安裝過程',
skillTranscriptLiveHint: '正在安裝,點擊查看過程',
skillTranscriptTitle: '安裝過程',
skillTranscriptPrompt: '安裝指令',
skillTranscriptHide: '收起安裝過程',
skillGuidance: {
placeholder: '補充安裝說明,例如需要安裝的 CLI、安裝文件或環境限制',
@ -6379,6 +6380,7 @@ export default {
installedCount: '已安裝到 {count} 個沙箱',
installPanelGroup: '已安裝',
installPanelAvailable: '未安裝',
installAction: '安裝',
viewInstallProgress: '查看進度',
manageOnSandbox: '管理沙箱「{name}」上的安裝',
manageDrawerDesc: '在沙箱「{name}」上管理啟用、變數和解除安裝。',

View File

@ -7,7 +7,7 @@
<!-- 推荐问题 -->
<div ref="sqContainerRef" class="suggested-questions-container">
<!-- 骨架屏占位 -->
<div v-if="sqLoading && suggestedQuestions.length === 0" class="suggested-questions-inner">
<div v-if="sqInitialLoad && suggestedQuestions.length === 0" class="suggested-questions-inner">
<div class="suggested-questions-title"><t-skeleton animation="gradient"
:row-col="[{ width: '120px', height: '14px' }]" /></div>
<div class="suggested-questions-grid">
@ -25,7 +25,7 @@
<span class="suggested-questions-title">{{ $t('chat.suggestedQuestions') }}</span>
<button type="button" class="suggested-questions-refresh" :disabled="sqLoading"
:title="$t('chat.refreshSuggestedQuestions')"
:aria-label="$t('chat.refreshSuggestedQuestions')" @click="fetchSuggestedQuestions">
:aria-label="$t('chat.refreshSuggestedQuestions')" @click="fetchSuggestedQuestions(true)">
<t-icon :name="sqLoading ? 'loading' : 'refresh'"
:class="{ 'sq-refresh-spin': sqLoading }" />
</button>
@ -118,12 +118,20 @@ const showChatContextualGuide = computed(() => {
// ===== 推荐问题 =====
const suggestedQuestions = ref<SuggestedQuestion[]>([]);
const sqLoading = ref(true);
// The skeleton reserves space only until the first answer arrives. Later
// refetches keep the current content in place, so the composer below does not
// jump each time the agent or @mention selection changes.
const sqInitialLoad = ref(true);
const sqCardsRevealed = ref(false);
const sqRenderKey = ref(0);
const sqContainerRef = ref<HTMLElement | null>(null);
let suggestedQuestionsFetchId = 0;
let lastSuggestedQuestionsKey = '';
let debounceTimer: ReturnType<typeof setTimeout> | null = null;
const sameSuggestedQuestions = (a: SuggestedQuestion[], b: SuggestedQuestion[]) =>
a.length === b.length && a.every((item, i) => item.question === b[i].question && item.source === b[i].source);
// --- 高度平滑过渡钩子 ---
const onBeforeLeave = () => {
const c = sqContainerRef.value;
@ -166,26 +174,39 @@ const onQuestionsEntered = () => {
nextTick(() => { sqCardsRevealed.value = true; });
};
const fetchSuggestedQuestions = async () => {
const fetchSuggestedQuestions = async (force = false) => {
const agentId = settingsStore.selectedAgentId;
const params = settingsStore.getSuggestedQuestionsParams();
const requestKey = JSON.stringify([agentId, params]);
if (!force && requestKey === lastSuggestedQuestionsKey) return;
lastSuggestedQuestionsKey = requestKey;
const fetchId = ++suggestedQuestionsFetchId;
sqLoading.value = true;
try {
const agentId = settingsStore.selectedAgentId;
if (!agentId) return;
const res = await getSuggestedQuestions(agentId, settingsStore.getSuggestedQuestionsParams());
if (!agentId) {
suggestedQuestions.value = [];
return;
}
const res = await getSuggestedQuestions(agentId, params);
if (fetchId === suggestedQuestionsFetchId) {
sqCardsRevealed.value = false;
sqRenderKey.value++;
suggestedQuestions.value = res?.data?.questions || [];
const next = res?.data?.questions || [];
if (!sameSuggestedQuestions(suggestedQuestions.value, next)) {
sqCardsRevealed.value = false;
sqRenderKey.value++;
suggestedQuestions.value = next;
}
}
} catch (err) {
console.warn('[SuggestedQuestions] Failed to fetch:', err);
if (fetchId === suggestedQuestionsFetchId) {
lastSuggestedQuestionsKey = '';
suggestedQuestions.value = [];
}
} finally {
if (fetchId === suggestedQuestionsFetchId) {
sqLoading.value = false;
sqInitialLoad.value = false;
}
}
};
@ -196,15 +217,13 @@ const debouncedFetch = () => {
debounceTimer = setTimeout(() => { fetchSuggestedQuestions(); }, 300);
};
// 监听 Agent / 知识库 / 文件 / 标签 / MCP / Skill @mention
// 监听 Agent / 知识库 / 文件 / 标签 @mention;MCP 与 Skill 不影响推荐范围
watch(
() => ({
agentId: settingsStore.selectedAgentId,
kbs: settingsStore.settings.selectedKnowledgeBases,
files: settingsStore.settings.selectedFiles,
tags: settingsStore.settings.selectedTags,
mcps: settingsStore.settings.selectedMCPServices,
skills: settingsStore.settings.selectedSkills,
}),
debouncedFetch,
{ deep: true },

View File

@ -62,8 +62,8 @@
<div class="skill-card__main">
<div class="skill-card__body">
<div class="skill-card__header">
<div class="skill-card__badge" aria-hidden="true">
<t-icon :name="SKILL_ICON" size="14px" />
<div class="skill-card__badge" :style="skillBadgeStyle(item.name)" aria-hidden="true">
{{ skillInitial(item.name) }}
</div>
<div class="skill-card__heading">
<h3 class="skill-card__title" :title="item.name">{{ item.name }}</h3>
@ -93,9 +93,10 @@
:disabled="Boolean(view.installs[0] && !recordFor(view.installs[0].sandbox_config_id))"
:title="installSummaryTooltip(item, view)" :aria-label="installSummary(item, view)"
@click="onInstallChipClick(item, view)">
<span v-if="view.installs.some(isInstallBusy)" class="skill-card__entry-dot" aria-hidden="true" />
<span class="skill-card__chip-text">{{ installSummary(item, view) }}</span>
<t-icon name="chevron-right" size="14px" class="skill-card__chip-go" />
<t-icon v-if="view.installs.length === 0" name="add" size="14px" class="skill-card__chip-lead" />
<span v-else class="skill-card__chip-dot" aria-hidden="true" />
<span class="skill-card__chip-text">{{ installChipText(view) }}</span>
<t-icon v-if="view.installs.length > 0" name="chevron-right" size="14px" class="skill-card__chip-go" />
</button>
<t-popup v-else :visible="openPanelId === item.id" trigger="click" placement="bottom-left" attach="body"
destroy-on-close overlay-class-name="skill-install-panel-overlay"
@ -104,34 +105,52 @@
<button type="button" class="skill-card__chip" :class="chipClass(item, view)"
:title="installSummaryTooltip(item, view)" :aria-label="installSummary(item, view)"
:aria-expanded="openPanelId === item.id">
<span v-if="view.installs.some(isInstallBusy)" class="skill-card__entry-dot" aria-hidden="true" />
<span class="skill-card__chip-text">{{ installSummary(item, view) }}</span>
<t-icon name="chevron-down" size="14px" class="skill-card__chip-go" />
<t-icon v-if="view.installs.length === 0" name="add" size="14px" class="skill-card__chip-lead" />
<span v-else class="skill-card__chip-dot" aria-hidden="true" />
<span class="skill-card__chip-text">{{ installChipText(view) }}</span>
<span v-if="view.installs.length > CHIP_NAME_LIMIT" class="skill-card__chip-more">
+{{ view.installs.length - CHIP_NAME_LIMIT }}
</span>
<t-icon name="chevron-down" size="14px" class="skill-card__chip-go"
:class="{ 'is-open': openPanelId === item.id }" />
</button>
<template #content>
<div class="skill-install-panel">
<template v-if="view.installs.length > 0">
<p class="skill-install-panel__group">{{ $t('settings.skills.installPanelGroup') }}</p>
<p class="skill-install-panel__group">
{{ $t('settings.skills.installPanelGroup') }}
<span class="skill-install-panel__group-count">{{ view.installs.length }}</span>
</p>
<button v-for="inst in view.installs" :key="inst.skill_id" type="button"
class="skill-install-panel__item" :class="installEntryClass(item, inst)"
:disabled="!recordFor(inst.sandbox_config_id)" :title="installTooltip(item, inst)"
@click="openManageFromPanel(item, inst)">
<SandboxBackendBadge v-if="inst.sandbox_type" :type="inst.sandbox_type" size="xs" />
<span class="skill-install-panel__name">{{ installName(inst) }}</span>
<span v-if="isInstallBusy(inst)" class="skill-card__entry-dot" aria-hidden="true" />
<t-icon v-else-if="installChipStatusIcon(item, inst)"
:name="installChipStatusIcon(item, inst)" size="14px" class="skill-card__entry-status" />
<span v-if="installChipStatus(item, inst)" class="skill-install-panel__status">
<span v-if="isInstallBusy(inst)" class="skill-card__entry-dot" aria-hidden="true" />
<t-icon v-else-if="installChipStatusIcon(item, inst)"
:name="installChipStatusIcon(item, inst)" size="12px" class="skill-card__entry-status" />
{{ installChipStatus(item, inst) }}
</span>
<t-icon name="chevron-right" size="14px" class="skill-install-panel__go" />
</button>
</template>
<template v-if="view.available.length > 0">
<div v-if="view.installs.length > 0" class="skill-install-panel__split" role="separator" />
<p class="skill-install-panel__group">{{ $t('settings.skills.installPanelAvailable') }}</p>
<p class="skill-install-panel__group">
{{ $t('settings.skills.installPanelAvailable') }}
<span class="skill-install-panel__group-count">{{ view.available.length }}</span>
</p>
<button v-for="cfg in view.available" :key="cfg.id" type="button"
class="skill-install-panel__item skill-install-panel__item--available"
:title="sandboxMetaLine(cfg)" @click="openInstallTo(item, cfg)">
<SandboxBackendBadge :type="cfg.sandbox_type" size="xs" />
<span class="skill-install-panel__name">{{ cfg.name }}</span>
<t-icon name="add" size="14px" class="skill-install-panel__add" />
<span class="skill-install-panel__add">
<t-icon name="add" size="12px" />
{{ $t('settings.skills.installAction') }}
</span>
</button>
</template>
</div>
@ -187,8 +206,8 @@
<div class="skill-card__main">
<div class="skill-card__body">
<div class="skill-card__header">
<div class="skill-card__badge" aria-hidden="true">
<t-icon :name="SKILL_ICON" size="14px" />
<div class="skill-card__badge" :style="skillBadgeStyle(registeredCatalog.name)" aria-hidden="true">
{{ skillInitial(registeredCatalog.name) }}
</div>
<h3 class="skill-card__title" :title="registeredCatalog.name">{{ registeredCatalog.name }}</h3>
<span v-if="registeredCatalog.version" class="skill-card__type">{{ registeredCatalog.version }}</span>
@ -295,6 +314,11 @@
:description="installDrawerDesc" :icon="SKILL_ICON" width="560px" :min-width="480" :max-width="760"
storage-key="setting-drawer:width:skill-catalog-install" :confirm-loading="installing"
:confirm-disabled="installConfirmDisabled" :confirm-text="installConfirmText" @confirm="onInstallDrawerConfirm">
<template v-if="installCatalog" #headerIcon>
<span class="skill-drawer-avatar" :style="skillBadgeStyle(installCatalog.name)">
{{ skillInitial(installCatalog.name) }}
</span>
</template>
<p v-if="installMode === 'install'" class="installer-model-hint">{{ skillText('installToSandboxDesc') }}</p>
<section v-if="!hostOnly && installPickRows.length > 0" class="setting-drawer__section">
<div class="sandbox-pick-list">
@ -345,6 +369,9 @@
<SettingDrawer v-model:visible="showManage" :title="manageTitle" :description="manageDesc" :icon="SKILL_ICON"
width="680px" :min-width="560" :max-width="920" storage-key="setting-drawer:width:skill-catalog-manage"
:hide-footer="true" :z-index="2600">
<template v-if="manageTitle" #headerIcon>
<span class="skill-drawer-avatar" :style="skillBadgeStyle(manageTitle)">{{ skillInitial(manageTitle) }}</span>
</template>
<SandboxSkillsPanel v-if="showManage && manageRecord && manageSkillId" :record="manageRecord" mode="list" hide-add
:focus-skill-id="manageSkillId" :catalog-item="catalogItemById(manageCatalogId)" @updated="onPanelUpdated"
@skills-changed="loadCatalog" />
@ -402,7 +429,7 @@ const props = defineProps<{
}>()
const emit = defineEmits<{ count: [value: number] }>()
const { t, te } = useI18n()
const { t, te, locale } = useI18n()
const uiStore = useUIStore()
const deploymentCapabilities = useDeploymentCapabilitiesStore()
const confirmDelete = useConfirmDelete()
@ -733,6 +760,19 @@ function compactText(value: string): string {
return value.replace(/\s+/g, ' ').trim()
}
const SKILL_BADGE_HUES = ['#366ef4', '#0594fa', '#00a870', '#8e56dd', '#e37318', '#d6418f', '#5b5bd6', '#b07b3b']
function skillInitial(name: string): string {
const ch = Array.from((name || '').replace(/^[^\p{L}\p{N}]+/u, ''))[0] || '?'
return ch.toUpperCase()
}
function skillBadgeStyle(name: string): Record<string, string> {
let hash = 0
for (const ch of name || '') hash = (hash * 31 + ch.codePointAt(0)!) >>> 0
return { '--skill-hue': SKILL_BADGE_HUES[hash % SKILL_BADGE_HUES.length] }
}
function upgradeVersionText(item: SkillCatalogItem, inst: SkillCatalogInstall): string {
const versions = upgradeVersions(item, inst)
return versions
@ -820,6 +860,14 @@ function installSummary(item: SkillCatalogItem, view: ReturnType<typeof installs
return t('settings.skills.installedCount', { count: view.installs.length })
}
const CHIP_NAME_LIMIT = 2
function installChipText(view: ReturnType<typeof installsView>): string {
if (view.installs.length === 0) return skillText('installToSandbox')
const sep = /^(zh|ja)/.test(String(locale.value)) ? '、' : ', '
return view.installs.slice(0, CHIP_NAME_LIMIT).map(installName).join(sep)
}
function chipClass(item: SkillCatalogItem, view: ReturnType<typeof installsView>): (string | undefined)[] {
return [
view.installs.length === 0 ? 'skill-card__chip--idle' : 'skill-card__chip--installed',
@ -1419,7 +1467,7 @@ onUnmounted(() => {
.skill-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
gap: 10px;
gap: 12px;
align-items: stretch;
}
@ -1446,9 +1494,15 @@ onUnmounted(() => {
box-shadow: 0 0 0 2px var(--td-brand-color-focus);
}
&--installed .skill-card__badge {
background: color-mix(in srgb, var(--td-brand-color) 12%, transparent);
color: var(--td-brand-color);
&--idle .skill-card__badge {
background: var(--td-bg-color-secondarycontainer);
color: var(--td-text-color-placeholder);
}
&:hover .skill-card__actions,
&:focus-within .skill-card__actions,
&--focused .skill-card__actions {
opacity: 1;
}
&--add {
@ -1502,19 +1556,38 @@ onUnmounted(() => {
.skill-card__main {
display: flex;
align-items: stretch;
padding: 12px;
padding: 12px 14px 8px;
min-width: 0;
flex: 1;
}
.skill-card__badge {
.provider-card-badge(28px, 8px);
font-size: var(--app-text-md);
.provider-card-badge(28px, 7px);
--skill-hue: var(--td-brand-color);
margin-top: 0;
font-size: var(--app-text-base);
font-weight: 600;
line-height: 1;
letter-spacing: 0;
background: color-mix(in srgb, var(--skill-hue) 12%, transparent);
color: var(--skill-hue);
user-select: none;
}
:deep(.t-icon) {
display: block;
line-height: 1;
}
.skill-drawer-avatar {
--skill-hue: var(--td-brand-color);
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
border-radius: inherit;
background: color-mix(in srgb, var(--skill-hue) 12%, var(--td-bg-color-container));
color: var(--skill-hue);
font-size: var(--app-text-md);
font-weight: 600;
line-height: 1;
user-select: none;
}
.skill-card__body {
@ -1522,13 +1595,13 @@ onUnmounted(() => {
min-width: 0;
display: flex;
flex-direction: column;
gap: 8px;
gap: 6px;
}
.skill-card__header {
display: flex;
align-items: center;
gap: 10px;
gap: 8px;
min-width: 0;
min-height: 28px;
}
@ -1559,6 +1632,12 @@ onUnmounted(() => {
display: flex;
align-items: center;
gap: 2px;
opacity: 0;
transition: opacity var(--app-motion-fast) ease;
@media (hover: none) {
opacity: 1;
}
}
.skill-card__icon-btn {
@ -1599,10 +1678,14 @@ onUnmounted(() => {
.skill-card__type {
flex-shrink: 0;
padding: 0 6px;
border-radius: var(--app-radius-sm);
background: var(--td-bg-color-secondarycontainer);
font-size: var(--app-text-xs);
font-weight: 500;
line-height: 18px;
color: var(--td-text-color-placeholder);
font-variant-numeric: tabular-nums;
}
.skill-card__desc {
@ -1611,6 +1694,7 @@ onUnmounted(() => {
-webkit-line-clamp: 2;
line-clamp: 2;
margin: 0;
min-height: calc(2 * 1.5em);
overflow: hidden;
font-size: var(--app-text-sm);
line-height: 1.5;
@ -1624,6 +1708,8 @@ onUnmounted(() => {
gap: 6px;
min-width: 0;
margin-top: auto;
padding-top: 6px;
border-top: 1px solid var(--td-component-stroke);
}
.skill-card__installs-label {
@ -1635,22 +1721,25 @@ onUnmounted(() => {
.skill-card__chip {
display: inline-flex;
align-items: center;
gap: 4px;
gap: 6px;
min-width: 0;
max-width: 100%;
margin: 0;
padding: 2px 6px;
height: 26px;
margin: 0 0 0 -6px;
padding: 0 6px;
border: 0;
border-radius: var(--app-radius-sm);
background: var(--td-bg-color-secondarycontainer);
background: transparent;
color: var(--td-text-color-secondary);
cursor: pointer;
font: inherit;
font-size: var(--app-text-sm);
line-height: 18px;
text-align: left;
transition: background-color var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
&:hover:not(:disabled) {
&:hover:not(:disabled),
&[aria-expanded='true'] {
color: var(--td-text-color-primary);
background: var(--td-bg-color-container-hover);
}
@ -1660,14 +1749,31 @@ onUnmounted(() => {
opacity: 0.6;
}
&--upgrade {
flex-shrink: 0;
&--idle {
color: var(--td-brand-color);
&:hover:not(:disabled),
&[aria-expanded='true'] {
color: var(--td-brand-color);
background: color-mix(in srgb, var(--td-brand-color) 8%, transparent);
}
.skill-card__chip-go {
color: var(--td-brand-color);
}
}
&--idle,
&--upgrade {
flex-shrink: 0;
gap: 2px;
margin: 0 0 0 auto;
height: 22px;
padding: 0 8px 0 6px;
border-radius: 999px;
color: var(--td-brand-color);
background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
font-size: var(--app-text-xs);
font-weight: 500;
&:hover:not(:disabled) {
color: var(--td-brand-color);
@ -1679,43 +1785,22 @@ onUnmounted(() => {
}
}
&.skill-card__entry--off {
color: var(--td-text-color-placeholder);
&.skill-card__entry--off .skill-card__chip-dot {
background: var(--td-text-color-disabled);
}
&--installed .skill-card__entry-status {
color: var(--td-success-color);
}
// 异常状态只用前置圆点着色,避免整排卡片铺满红黄底色
&.skill-card__entry--stale::before,
&.skill-card__entry--failed::before {
content: '';
flex-shrink: 0;
width: 6px;
height: 6px;
border-radius: 50%;
}
&.skill-card__entry--stale {
&::before { background: var(--td-warning-color); }
.skill-card__entry-status {
color: var(--td-warning-color);
}
}
&.skill-card__entry--failed {
&::before { background: var(--td-error-color); }
.skill-card__entry-status {
color: var(--td-error-color);
}
}
&.skill-card__entry--busy .skill-card__entry-dot {
&.skill-card__entry--stale .skill-card__chip-dot {
background: var(--td-warning-color);
}
&.skill-card__entry--failed .skill-card__chip-dot {
background: var(--td-error-color);
}
&.skill-card__entry--busy .skill-card__chip-dot {
background: var(--td-warning-color);
animation: skill-chip-dot 1.2s ease-in-out infinite;
}
}
.skill-card__chip-text {
@ -1748,6 +1833,32 @@ onUnmounted(() => {
color: currentColor;
}
.skill-card__chip-go {
transition: transform var(--app-motion-fast) ease;
&.is-open {
transform: rotate(180deg);
}
}
.skill-card__chip-lead {
flex-shrink: 0;
}
.skill-card__chip-dot {
flex-shrink: 0;
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--td-success-color);
}
.skill-card__chip-more {
flex-shrink: 0;
color: var(--td-text-color-placeholder);
font-variant-numeric: tabular-nums;
}
.skill-card__entry-dot {
width: 6px;
height: 6px;
@ -1759,29 +1870,38 @@ onUnmounted(() => {
.skill-install-panel {
display: flex;
flex-direction: column;
width: 240px;
width: 280px;
max-width: calc(100vw - 32px);
max-height: min(360px, 70vh);
max-height: min(380px, 70vh);
overflow-y: auto;
padding: 4px;
padding: 6px;
box-sizing: border-box;
}
.skill-install-panel__group {
display: flex;
align-items: center;
gap: 6px;
margin: 0;
padding: 6px 8px 2px;
padding: 4px 8px 4px;
font-size: var(--app-text-xs);
font-weight: 500;
line-height: 18px;
color: var(--td-text-color-placeholder);
}
.skill-install-panel__group-count {
font-variant-numeric: tabular-nums;
opacity: 0.8;
}
.skill-install-panel__item {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
height: 32px;
margin: 0 0 2px;
min-height: 34px;
margin: 0 0 1px;
padding: 0 8px;
border: 0;
border-radius: var(--app-radius-sm);
@ -1792,8 +1912,10 @@ onUnmounted(() => {
font-size: var(--app-text-md);
line-height: 22px;
text-align: left;
transition: background-color var(--app-motion-fast) ease;
&:hover:not(:disabled) {
&:hover:not(:disabled),
&:focus-visible {
background: var(--td-bg-color-container-hover);
}
@ -1802,12 +1924,22 @@ onUnmounted(() => {
opacity: 0.5;
}
&.skill-card__entry--stale .skill-card__entry-status {
color: var(--td-warning-color);
&.skill-card__entry--off .skill-install-panel__name {
color: var(--td-text-color-placeholder);
}
&.skill-card__entry--failed .skill-card__entry-status {
&.skill-card__entry--stale .skill-install-panel__status {
color: var(--td-warning-color);
background: color-mix(in srgb, var(--td-warning-color) 10%, transparent);
}
&.skill-card__entry--failed .skill-install-panel__status {
color: var(--td-error-color);
background: color-mix(in srgb, var(--td-error-color) 10%, transparent);
}
&.skill-card__entry--busy .skill-install-panel__status {
color: var(--td-warning-color);
}
&.skill-card__entry--busy .skill-card__entry-dot {
@ -1815,10 +1947,6 @@ onUnmounted(() => {
}
}
.skill-install-panel__item--available {
color: var(--td-text-color-secondary);
}
.skill-install-panel__name {
flex: 1;
min-width: 0;
@ -1827,8 +1955,64 @@ onUnmounted(() => {
white-space: nowrap;
}
.skill-install-panel__status {
flex-shrink: 0;
display: inline-flex;
align-items: center;
gap: 3px;
max-width: 120px;
padding: 0 6px;
border-radius: 999px;
background: var(--td-bg-color-secondarycontainer);
color: var(--td-text-color-secondary);
font-size: var(--app-text-xs);
line-height: 18px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.skill-install-panel__go {
flex-shrink: 0;
margin-right: -2px;
color: var(--td-text-color-placeholder);
opacity: 0;
transition: opacity var(--app-motion-fast) ease;
}
.skill-install-panel__item:hover:not(:disabled) .skill-install-panel__go,
.skill-install-panel__item:focus-visible .skill-install-panel__go {
opacity: 1;
}
.skill-install-panel__item--available {
color: var(--td-text-color-secondary);
:deep(.sandbox-badge) {
filter: grayscale(1);
opacity: 0.7;
transition: filter var(--app-motion-fast) ease, opacity var(--app-motion-fast) ease;
}
&:hover,
&:focus-visible {
color: var(--td-text-color-primary);
:deep(.sandbox-badge) {
filter: none;
opacity: 1;
}
}
}
.skill-install-panel__add {
flex-shrink: 0;
display: inline-flex;
align-items: center;
gap: 2px;
font-size: var(--app-text-xs);
font-weight: 500;
line-height: 18px;
color: var(--td-brand-color);
opacity: 0;
transition: opacity var(--app-motion-fast) ease;
@ -1839,13 +2023,9 @@ onUnmounted(() => {
opacity: 1;
}
.skill-install-panel__item--available:hover {
color: var(--td-text-color-primary);
}
.skill-install-panel__split {
height: 1px;
margin: 4px -4px;
margin: 5px 2px;
background: var(--td-component-stroke);
}

View File

@ -664,13 +664,23 @@ func (s *customAgentService) getSuggestedQuestions(
// e.g. a quick-answer (RAG-only) agent doesn't surface wiki-only
// KBs whose wiki pages it could never answer from. Same filter
// the @ mention dropdown applies on the frontend.
capFilter := tools.DeriveKBFilterForAgent(agent.Config.AgentMode, agent.Config.AllowedTools)
mode, allowed := agent.Config.AgentMode, agent.Config.AllowedTools
capFilter := tools.DeriveKBFilterForAgent(mode, allowed)
accept := func(kb *types.KnowledgeBase) bool {
return capFilter.IsEmpty() || tools.KBSatisfiesAgentRequirements(kb.Capabilities(), mode, allowed)
}
for _, kb := range kbs {
if !capFilter.IsEmpty() &&
!tools.KBSatisfiesAgentRequirements(kb.Capabilities(), agent.Config.AgentMode, agent.Config.AllowedTools) {
continue
if accept(kb) {
effectiveKBIDs = append(effectiveKBIDs, kb.ID)
}
}
// Match the chat runtime's "all" scope, which also reaches KBs shared
// into the caller's tenant; otherwise a tenant whose only KB is shared
// sees no starters until it @mentions that KB explicitly.
for _, kb := range s.sharedSuggestionKnowledgeBases(ctx, tenantID, agent) {
if accept(kb) {
effectiveKBIDs = mergeUniqueStrings(effectiveKBIDs, []string{kb.ID})
}
effectiveKBIDs = append(effectiveKBIDs, kb.ID)
}
case "selected":
effectiveKBIDs = agent.Config.KnowledgeBases
@ -1156,6 +1166,31 @@ func (s *customAgentService) readableSuggestionKnowledgeIDs(ctx context.Context,
return readable
}
// sharedSuggestionKnowledgeBases lists the KBs shared into the caller's tenant.
// A shared agent keeps its owner's scope, so it never picks up the borrower's
// shares.
func (s *customAgentService) sharedSuggestionKnowledgeBases(
ctx context.Context,
tenantID uint64,
agent *types.CustomAgent,
) []*types.KnowledgeBase {
if s.kbShareService == nil || agent.TenantID != tenantID {
return nil
}
shared, err := s.kbShareService.ListSharedKnowledgeBases(ctx, tenantID, types.TenantRoleFromContext(ctx))
if err != nil {
logger.Warnf(ctx, "Failed to list shared knowledge bases for suggestions: %v", err)
return nil
}
kbs := make([]*types.KnowledgeBase, 0, len(shared))
for _, info := range shared {
if info != nil && info.KnowledgeBase != nil {
kbs = append(kbs, info.KnowledgeBase)
}
}
return kbs
}
// groupKBIDsByEffectiveTenant resolves each kbID to the tenant whose chunk
// rows back that KB, so cross-tenant shares can be queried correctly:
// - In-tenant KBs map to the caller's tenant id.

View File

@ -77,6 +77,30 @@ func (s *suggestionKBShareService) CheckTenantKBPermission(
return types.OrgRoleViewer, s.allowed[kbID], nil
}
func (s *suggestionKBShareService) ListSharedKnowledgeBases(
_ context.Context,
_ uint64,
_ types.TenantRole,
) ([]*types.SharedKnowledgeBaseInfo, error) {
var out []*types.SharedKnowledgeBaseInfo
for id := range s.allowed {
out = append(out, &types.SharedKnowledgeBaseInfo{KnowledgeBase: &types.KnowledgeBase{ID: id, TenantID: 2}})
}
return out, nil
}
func TestSharedSuggestionKnowledgeBases_OnlyForCallerOwnedAgents(t *testing.T) {
svc := &customAgentService{kbShareService: &suggestionKBShareService{allowed: map[string]bool{"shared-kb": true}}}
ctx := context.WithValue(context.Background(), types.TenantIDContextKey, uint64(1))
own := svc.sharedSuggestionKnowledgeBases(ctx, 1, &types.CustomAgent{ID: "agent", TenantID: 1})
require.Len(t, own, 1)
assert.Equal(t, "shared-kb", own[0].ID)
borrowed := svc.sharedSuggestionKnowledgeBases(ctx, 1, &types.CustomAgent{ID: "agent", TenantID: 2})
assert.Empty(t, borrowed, "a shared agent keeps its owner's scope")
}
func TestResolveSuggestionTagScopes_UsesSourceTenantForSharedKB(t *testing.T) {
const (
callerTenant = uint64(1)

View File

@ -22,12 +22,17 @@ Runtime prerequisites and completion report (required for every skill):
- Verify required commands with documented, non-destructive checks. Assess whether required capabilities
are available in this execution environment and whether dependencies outside it are reachable. Report
unresolved setup or compatibility requirements precisely; do not silently substitute a different tool.
- With write_skill_file, create .weknora/install-report.json as a JSON object with two required fields:
- With write_skill_file, create .weknora/install-report.json as a JSON object with two required fields
and one optional field:
- commands: an array of strings listing every runtime CLI required by this skill, including those
already installed. Each entry must be a bare executable name without paths or arguments.
- blockers: an array of strings describing unresolved setup or compatibility requirements found
during verification.
Populate both arrays from this skill's actual requirements and verification results, without
during verification. A blocker means the skill cannot do its job in this environment: a required
dependency, capability, or external service is missing or unreachable.
- notes (optional): an array of strings for observations that do not stop the skill from working,
such as documentation that disagrees with the code while a verified working usage exists, upstream
quirks, or usage hints for later sessions. Notes never fail the install; do not put them in blockers.
Populate the arrays from this skill's actual requirements and verification results, without
placeholder entries. Use an empty array when there are no entries for that field. Never include
credentials; declare ordinary per-user API keys in .weknora/requirements.json instead of blockers.
- The server refuses missing/invalid reports, missing commands, and unresolved blockers. Do not remove a
@ -41,15 +46,18 @@ var skillRuntimeCommandName = regexp.MustCompile(`^[A-Za-z0-9_][A-Za-z0-9_.+-]*$
type skillRuntimeReport struct {
Commands []string `json:"commands"`
Blockers []string `json:"blockers"`
Notes []string `json:"notes"`
}
// The agent discovers prerequisites; this gate independently checks executable
// availability and refuses explicitly unresolved setup before snapshotting.
// The report's notes are returned even when the gate refuses, so whoever reads
// the failure also sees what the installer observed.
func (s *TenantSkillService) verifyRuntimePrerequisites(
ctx context.Context,
mgr sandbox.Manager,
sessionID, skillDir string,
) error {
) ([]string, error) {
fail := func(problem string, repairable bool) error {
return &skillVerificationError{
Language: "runtime prerequisites",
@ -59,40 +67,49 @@ func (s *TenantSkillService) verifyRuntimePrerequisites(
}
reader, ok := mgr.(sandbox.SessionFileReader)
if !ok {
return fmt.Errorf("sandbox backend cannot read the install report")
return nil, fmt.Errorf("sandbox backend cannot read the install report")
}
raw, err := reader.ReadSessionFile(ctx, sessionID, path.Join(skillDir, ".weknora", "install-report.json"))
if err != nil {
return fail(
return nil, fail(
"Write .weknora/install-report.json after assessing CLI and external runtime prerequisites: "+err.Error(),
true,
)
}
var report skillRuntimeReport
if len(raw) > 64*1024 {
return fail("install-report.json exceeds 64 KiB", true)
return nil, fail("install-report.json exceeds 64 KiB", true)
}
if err := json.Unmarshal(raw, &report); err != nil || report.Commands == nil || report.Blockers == nil {
return fail(`Write a valid .weknora/install-report.json with commands and blockers arrays of strings`, true)
return nil, fail(
`Write a valid .weknora/install-report.json with commands and blockers arrays of strings`,
true,
)
}
if len(report.Commands) > 100 || len(report.Blockers) > 100 {
return fail("install report has too many entries", true)
if len(report.Commands) > 100 || len(report.Blockers) > 100 || len(report.Notes) > 100 {
return nil, fail("install report has too many entries", true)
}
var notes []string
for _, note := range report.Notes {
if note = strings.TrimSpace(note); note != "" {
notes = append(notes, note)
}
}
for _, name := range report.Commands {
if !skillRuntimeCommandName.MatchString(name) || len(name) > 128 {
return fail("commands must contain bare executable names, without paths or arguments", true)
return notes, fail("commands must contain bare executable names, without paths or arguments", true)
}
}
for _, blocker := range report.Blockers {
if strings.TrimSpace(blocker) == "" {
return fail("blockers must contain non-empty explanations", true)
return notes, fail("blockers must contain non-empty explanations", true)
}
}
if len(report.Blockers) > 0 {
return fail("Unresolved runtime prerequisites: "+strings.Join(report.Blockers, "; "), false)
return notes, fail("Unresolved runtime prerequisites: "+strings.Join(report.Blockers, "; "), false)
}
if len(report.Commands) == 0 {
return nil
return notes, nil
}
var command strings.Builder
command.WriteString(
@ -109,5 +126,5 @@ func (s *TenantSkillService) verifyRuntimePrerequisites(
}
command.WriteString("; exit $status")
_, err = s.execVerify(ctx, mgr, sessionID, skillDir, "runtime commands", command.String())
return err
return notes, err
}

View File

@ -59,7 +59,7 @@ func TestRuntimePrerequisiteReportValidation(t *testing.T) {
fx.sandboxMgr.files = map[string][]byte{
path.Join(installSkillDir, ".weknora/install-report.json"): []byte(raw),
}
err := fx.svc.verifyRuntimePrerequisites(context.Background(), fx.sandboxMgr, "session", installSkillDir)
_, err := fx.svc.verifyRuntimePrerequisites(context.Background(), fx.sandboxMgr, "session", installSkillDir)
var gate *skillVerificationError
require.ErrorAs(t, err, &gate)
require.True(t, gate.Repairable)
@ -76,13 +76,26 @@ func TestRuntimePrerequisitesResolveSkillLocalCLI(t *testing.T) {
path.Join(dir, ".weknora/install-report.json"): []byte(`{"commands":["weknora-test-cli"],"blockers":[]}`),
}
mgr := runtimeProbeManager{fx.sandboxMgr}
err := fx.svc.verifyRuntimePrerequisites(context.Background(), mgr, "session", dir)
_, err := fx.svc.verifyRuntimePrerequisites(context.Background(), mgr, "session", dir)
var gate *skillVerificationError
require.ErrorAs(t, err, &gate)
require.True(t, gate.Repairable)
require.Contains(t, err.Error(), "weknora-test-cli")
require.NoError(t, os.WriteFile(path.Join(binDir, "weknora-test-cli"), []byte("#!/bin/sh\nexit 0\n"), 0o755))
require.NoError(t, fx.svc.verifyRuntimePrerequisites(context.Background(), mgr, "session", dir))
_, err = fx.svc.verifyRuntimePrerequisites(context.Background(), mgr, "session", dir)
require.NoError(t, err)
}
func TestRuntimePrerequisiteNotesDoNotFailInstall(t *testing.T) {
fx := newInstallFixture(t)
fx.sandboxMgr.files = map[string][]byte{
path.Join(installSkillDir, ".weknora/install-report.json"): []byte(
`{"commands":[],"blockers":[],"notes":["SKILL.md CLI usage is a no-op; use the module API", " "]}`,
),
}
notes, err := fx.svc.verifyRuntimePrerequisites(context.Background(), fx.sandboxMgr, "session", installSkillDir)
require.NoError(t, err)
require.Equal(t, []string{"SKILL.md CLI usage is a no-op; use the module API"}, notes)
}
func TestRunInstallDoesNotSnapshotUnresolvedExternalPrerequisites(t *testing.T) {

View File

@ -94,7 +94,8 @@ func (s *TenantSkillService) verifySkill(
if err != nil {
return notes, err
}
return notes, s.verifyRuntimePrerequisites(ctx, mgr, sessionID, skillDir)
runtimeNotes, err := s.verifyRuntimePrerequisites(ctx, mgr, sessionID, skillDir)
return append(notes, runtimeNotes...), err
}
// verifySkillTree confirms the files the agent was given are still the files