Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix(skills): count GitHub skill subtrees and polish catalog install UI

wizardchen2783d9cab8d0
diff --git a/.env.example b/.env.example
index 408d897a6..a152d4017 100644
--- a/.env.example
+++ b/.env.example
@@ -185,7 +185,7 @@ STORAGE_TYPE=local
LOCAL_STORAGE_BASE_DIR=/data/files
# 本地存储路径前缀(legacy 回填用,一般留空)。
# LOCAL_STORAGE_PATH_PREFIX=
-# 统一文件大小限制(MB,默认 50)。影响单文件上传、docreader gRPC 消息、frontend Nginx请求体、浏览器客户端校验。属部署期配置:Go/Nginx/docreader/浏览器四层启动时读一次,运行中改不生效,改后须同步重启四层。
+# 统一文件大小限制(MB,默认 50)。影响单文件上传、技能 zip / 来源下载、docreader gRPC 消息、frontend Nginx 请求体、浏览器客户端校验。属部署期配置:Go/Nginx/docreader/浏览器四层启动时读一次,运行中改不生效,改后须同步重启四层。
# MAX_FILE_SIZE_MB=50
# ========== B4. 对象存储 provider(按 STORAGE_TYPE 选其一)==========
diff --git a/frontend/src/components/SandboxSkillsPanel.test.mjs b/frontend/src/components/SandboxSkillsPanel.test.mjs
index 0453746a9..839e9f885 100644
--- a/frontend/src/components/SandboxSkillsPanel.test.mjs
+++ b/frontend/src/components/SandboxSkillsPanel.test.mjs
@@ -14,8 +14,13 @@ test('focused skill management expands env vars and transcript without a mid-pag
assert.match(source, /isBusy\(skill\) \|\| !hasEnvEdits\(skill\)/)
assert.match(manageBlock, /SkillInstallTimeline/)
assert.match(manageBlock, /settings\.skills\.manageUninstall/)
- assert.match(manageBlock, /skill-manage__progress/)
- assert.match(manageBlock, /v-if="!isBusy\(managedSkill\)"/)
+ assert.match(manageBlock, /skill-manage__section--danger/)
+ assert.match(manageBlock, /managedSkill\.status !== 'installing'/)
+ assert.match(manageBlock, /skill-manage__section--remove/)
+ assert.match(manageBlock, /askRemove/)
+ assert.match(manageBlock, /skillRemoveDone/)
+ assert.match(manageBlock, /progressStageText/)
+ assert.doesNotMatch(manageBlock, /t-icon name="delete"/)
assert.doesNotMatch(manageBlock, /skill-manage__footer/)
assert.doesNotMatch(manageBlock, /settings\.sandbox\.skillEnv\.save/)
})
diff --git a/frontend/src/components/SandboxSkillsPanel.vue b/frontend/src/components/SandboxSkillsPanel.vue
index ac2e95f58..2a5fb636e 100644
--- a/frontend/src/components/SandboxSkillsPanel.vue
+++ b/frontend/src/components/SandboxSkillsPanel.vue
@@ -17,7 +17,7 @@
<section v-if="mode === 'install'" class="setting-drawer__section">
<h4 class="setting-drawer__section-title">{{ $t('settings.sandbox.skillSourceSection') }}</h4>
- <p class="installer-model-hint">{{ $t('settings.sandbox.skillSourceSectionHint') }}</p>
+ <p class="installer-model-hint">{{ $t('settings.sandbox.skillSourceSectionHint', { size: MAX_FILE_SIZE_MB }) }}</p>
<t-input-adornment class="skill-source-row">
<t-input
v-model="sourceInput"
@@ -40,7 +40,7 @@
<section v-if="mode === 'install'" class="setting-drawer__section">
<h4 class="setting-drawer__section-title">{{ $t('settings.sandbox.skillUploadSection') }}</h4>
- <p class="installer-model-hint">{{ $t('settings.sandbox.skillUploadSectionHint') }}</p>
+ <p class="installer-model-hint">{{ $t('settings.sandbox.skillUploadSectionHint', { size: MAX_FILE_SIZE_MB }) }}</p>
<input
ref="fileInputRef"
type="file"
@@ -76,7 +76,21 @@
</section>
<section v-if="mode === 'list' && focusSkillId" class="skill-manage">
- <template v-if="managedSkill">
+ <div v-if="uninstallDone" class="skill-manage__done">
+ <t-icon name="check-circle-filled" size="22px" />
+ <p>{{ $t('settings.sandbox.skillRemoveDone', { name: uninstallingName }) }}</p>
+ </div>
+ <template v-else-if="managedSkill && isRemoving(managedSkill)">
+ <section class="skill-manage__section skill-manage__section--remove">
+ <div class="skill-manage__section-head">
+ <h4>{{ $t('settings.sandbox.skillRemoveInProgress') }}</h4>
+ <span class="skill-manage__progress-label">{{ progressOf(managedSkill) }}%</span>
+ </div>
+ <t-progress :percentage="progressOf(managedSkill)" :stroke-width="6" />
+ <p class="skill-manage__remove-stage">{{ progressStageText(managedSkill) }}</p>
+ </section>
+ </template>
+ <template v-else-if="managedSkill">
<div class="skill-manage__row">
<div class="skill-manage__info">
<label>{{ $t('settings.skills.manageEnable') }}</label>
@@ -105,25 +119,6 @@
<t-icon name="refresh" size="16px" />
</button>
</t-tooltip>
- <t-popconfirm
- v-if="!isBusy(managedSkill)"
- theme="warning"
- :content="deleteHint"
- :confirm-btn="{ content: $t('settings.skills.manageUninstall'), theme: 'danger' }"
- :cancel-btn="{ content: $t('common.cancel') }"
- placement="top-right"
- @confirm="removeSkill(managedSkill)"
- >
- <button
- type="button"
- class="skill-card__icon-btn skill-card__icon-btn--danger"
- :disabled="deletingId === managedSkill.id"
- :title="$t('settings.skills.manageUninstall')"
- :aria-label="$t('settings.skills.manageUninstall')"
- >
- <t-icon name="delete" size="16px" />
- </button>
- </t-popconfirm>
</div>
</div>
<ul v-if="failedErrorLines(managedSkill).length" class="skill-card__error">
@@ -192,10 +187,10 @@
</div>
</div>
</section>
- <section v-if="hasTranscript(managedSkill) || isBusy(managedSkill)" class="skill-manage__section">
+ <section v-if="hasTranscript(managedSkill)" class="skill-manage__section">
<div class="skill-manage__section-head">
<h4>{{ $t('settings.sandbox.skillTranscriptTitle') }}</h4>
- <div v-if="isBusy(managedSkill)" class="skill-manage__progress">
+ <div v-if="managedSkill.status === 'installing'" class="skill-manage__progress">
<t-progress
theme="circle"
:percentage="progressOf(managedSkill)"
@@ -216,6 +211,25 @@
:live="managedSkill.status === 'installing'"
/>
</section>
+ <section
+ v-if="managedSkill.status !== 'installing'"
+ class="skill-manage__section skill-manage__section--danger"
+ >
+ <h4>{{ $t('settings.skills.manageUninstall') }}</h4>
+ <p class="skill-envs__hint">{{ deleteHint }}</p>
+ <ul v-if="removalErrorLines(managedSkill).length" class="skill-card__error">
+ <li v-for="(line, i) in removalErrorLines(managedSkill)" :key="i">{{ line }}</li>
+ </ul>
+ <t-button
+ theme="danger"
+ variant="outline"
+ :disabled="isBusy(managedSkill)"
+ :loading="deletingId === managedSkill.id"
+ @click="askRemove(managedSkill)"
+ >
+ {{ $t('settings.skills.manageUninstall') }}
+ </t-button>
+ </section>
</template>
</section>
@@ -488,24 +502,16 @@
<t-icon name="refresh" size="14px" />
</button>
</t-tooltip>
- <t-popconfirm
+ <button
v-if="!isBusy(skill)"
- theme="warning"
- :content="deleteHint"
- :confirm-btn="{ content: $t('common.delete'), theme: 'danger' }"
- :cancel-btn="{ content: $t('common.cancel') }"
- placement="top-right"
- @confirm="removeSkill(skill)"
+ type="button"
+ class="skill-card__icon-btn skill-card__icon-btn--danger"
+ :disabled="deletingId === skill.id"
+ :aria-label="$t('settings.skills.manageUninstall')"
+ @click="askRemove(skill)"
>
- <button
- type="button"
- class="skill-card__icon-btn skill-card__icon-btn--danger"
- :disabled="deletingId === skill.id"
- :aria-label="$t('common.delete')"
- >
- <t-icon name="delete" size="14px" />
- </button>
- </t-popconfirm>
+ <t-icon name="delete" size="14px" />
+ </button>
</div>
</div>
<div v-if="skill.version && !focusSkillId" class="skill-card__type">{{ skill.version }}</div>
@@ -549,6 +555,7 @@ import { useI18n } from 'vue-i18n'
import { fetchEventSource } from '@microsoft/fetch-event-source'
import ModelSelector from '@/components/ModelSelector.vue'
import SkillInstallTimeline from '@/components/SkillInstallTimeline.vue'
+import { useConfirmDelete } from '@/components/settings/useConfirmDelete'
import { SKILL_ICON } from '@/types/mention'
import {
getAgentById,
@@ -569,7 +576,7 @@ import {
type SandboxConfigRecord,
} from '@/api/system'
import { getApiBaseUrl } from '@/utils/api-base'
-import { generateRandomString } from '@/utils/index'
+import { generateRandomString, MAX_FILE_SIZE_BYTES, MAX_FILE_SIZE_MB } from '@/utils/index'
import i18n from '@/i18n'
import {
MAX_ENV_VALUE_BYTES,
@@ -608,6 +615,7 @@ const emit = defineEmits<{
}>()
const { t } = useI18n()
+const confirmDelete = useConfirmDelete()
const loading = ref(false)
const uploading = ref(false)
@@ -618,6 +626,10 @@ const skills = ref<ConfigSkill[]>([])
const togglingId = ref('')
const deletingId = ref('')
const retryingId = ref('')
+const uninstallingId = ref('')
+const uninstallingName = ref('')
+const uninstallDone = ref(false)
+const sawRemoving = ref(false)
// Only one install timeline is open at a time: each one holds an SSE
// connection, and two runs' worth of agent steps in a drawer is unreadable.
const expandedSkillId = ref('')
@@ -690,6 +702,10 @@ function isBusy(skill: ConfigSkill): boolean {
return skill.status === 'installing' || skill.status === 'removing'
}
+function isRemoving(skill: ConfigSkill): boolean {
+ return skill.status === 'removing' || deletingId.value === skill.id
+}
+
function cardStatusClass(skill: ConfigSkill): string {
if (skill.status === 'failed') return 'skill-card__status--failed'
if (skill.status === 'installing' || skill.status === 'removing') return 'skill-card__status--busy'
@@ -720,6 +736,29 @@ watch(managedSkill, (skill) => {
if (skill && skillHasDeclaredEnvs(skill)) ensureEnvDrafts(skill.id)
}, { immediate: true })
+watch(
+ () => props.focusSkillId,
+ () => {
+ uninstallingId.value = ''
+ uninstallingName.value = ''
+ uninstallDone.value = false
+ sawRemoving.value = false
+ },
+)
+
+watch(skills, (list) => {
+ const id = uninstallingId.value
+ if (!id || uninstallDone.value) return
+ const row = list.find((skill) => skill.id === id)
+ if (row?.status === 'removing') {
+ sawRemoving.value = true
+ return
+ }
+ if (sawRemoving.value && (!row || row.status === 'removed')) {
+ uninstallDone.value = true
+ }
+})
+
watch(
() => skills.value.some(isBusy),
(busy) => emit('inFlightChange', busy),
@@ -906,11 +945,33 @@ function progressOf(skill: ConfigSkill): number {
if (typeof percent === 'number' && Number.isFinite(percent)) {
return Math.max(0, Math.min(100, percent))
}
+ if (skill.status === 'removing' || deletingId.value === skill.id) return 5
return skill.status === 'ready' || skill.status === 'failed' ? 100 : 0
}
+const REMOVE_STAGE_I18N: Record<string, string> = {
+ accepted: 'settings.sandbox.skillRemoveStage.accepted',
+ sandbox_ready: 'settings.sandbox.skillRemoveStage.sandbox_ready',
+ removed: 'settings.sandbox.skillRemoveStage.removed',
+ done: 'settings.sandbox.skillRemoveStage.done',
+ failed: 'settings.sandbox.skillRemoveStage.failed',
+}
+
+function progressStageText(skill: ConfigSkill): string {
+ const ev = progressById.value[skill.id]
+ const stageKey = ev?.stage ? REMOVE_STAGE_I18N[ev.stage] : ''
+ if (stageKey) return t(stageKey)
+ if (skill.status === 'removing' || deletingId.value === skill.id) {
+ return t('settings.sandbox.skillRemoveWaiting')
+ }
+ return ev?.log || ''
+}
+
function progressLog(skill: ConfigSkill): string {
- return progressById.value[skill.id]?.log || ''
+ const ev = progressById.value[skill.id]
+ if (ev?.log) return ev.log
+ if (skill.status === 'removing') return progressStageText(skill)
+ return ''
}
// A re-run reuses the skill id, so the previous run's last event is still the
@@ -940,6 +1001,17 @@ function failedErrorLines(skill: ConfigSkill): string[] {
.filter(Boolean)
}
+function removalErrorLines(skill: ConfigSkill): string[] {
+ const ev = progressById.value[skill.id]
+ const raw = ev?.stage === 'failed'
+ ? (ev.log || skill.error || '')
+ : (uninstallingId.value === skill.id && skill.status !== 'removing' ? (skill.error || '') : '')
+ return raw
+ .split('\n')
+ .map((line) => line.trim())
+ .filter(Boolean)
+}
+
function stopFollow(skillId: string) {
const controller = abortBySkill.get(skillId)
if (controller) {
@@ -1124,6 +1196,18 @@ function isZipFile(file: File): boolean {
return file.name.toLowerCase().endsWith('.zip') || file.type === 'application/zip'
}
+function skillBundleErrorMessage(err: any, fallbackKey: string): string {
+ const raw = String(err?.message || '')
+ if (/cannot exceed \d+\s*MB/i.test(raw)) {
+ return t('settings.sandbox.skillBundleTooLarge', { size: MAX_FILE_SIZE_MB })
+ }
+ const tooMany = raw.match(/archive holds more than (\d+) files/i)
+ if (tooMany) {
+ return t('settings.sandbox.skillBundleTooManyFiles', { count: tooMany[1] })
+ }
+ return raw || t(fallbackKey)
+}
+
async function uploadFile(file: File) {
if (!props.record || installBusy.value) return
if (!installerModelId.value) {
@@ -1134,6 +1218,10 @@ async function uploadFile(file: File) {
MessagePlugin.error(t('settings.sandbox.skillUploadFailed'))
return
}
+ if (file.size > MAX_FILE_SIZE_BYTES) {
+ MessagePlugin.error(t('settings.sandbox.skillBundleTooLarge', { size: MAX_FILE_SIZE_MB }))
+ return
+ }
uploading.value = true
uploadPercent.value = 0
try {
@@ -1145,7 +1233,7 @@ async function uploadFile(file: File) {
const skillId = res?.data?.skill_id || ''
emit('installed', skillId)
} catch (e: any) {
- MessagePlugin.error(e?.message || t('settings.sandbox.skillUploadFailed'))
+ MessagePlugin.error(skillBundleErrorMessage(e, 'settings.sandbox.skillUploadFailed'))
} finally {
uploading.value = false
uploadPercent.value = 0
@@ -1170,7 +1258,7 @@ async function installFromSource() {
const skillId = res?.data?.skill_id || ''
emit('installed', skillId)
} catch (e: any) {
- MessagePlugin.error(e?.message || t('settings.sandbox.skillSourceFailed'))
+ MessagePlugin.error(skillBundleErrorMessage(e, 'settings.sandbox.skillSourceFailed'))
} finally {
installingFromSource.value = false
}
@@ -1224,12 +1312,34 @@ async function retrySkill(skill: ConfigSkill) {
}
}
+function askRemove(skill: ConfigSkill) {
+ if (!props.record || isBusy(skill) || deletingId.value) return
+ confirmDelete({
+ title: t('settings.skills.manageUninstall'),
+ body: deleteHint.value,
+ confirmText: t('settings.skills.manageUninstall'),
+ onConfirm: () => removeSkill(skill),
+ })
+}
+
async function removeSkill(skill: ConfigSkill) {
- if (!props.record) return
+ if (!props.record || isBusy(skill) || deletingId.value) return
deletingId.value = skill.id
+ uninstallingId.value = skill.id
+ uninstallingName.value = skill.name
+ uninstallDone.value = false
+ forgetProgress(skill.id)
try {
await deleteConfigSkill(props.record.id, skill.id)
MessagePlugin.success(t('settings.sandbox.skillDeleteAccepted'))
+ skills.value = skills.value.map((item) => (
+ item.id === skill.id ? { ...item, status: 'removing' } : item
+ ))
+ sawRemoving.value = true
+ progressById.value = {
+ ...progressById.value,
+ [skill.id]: { percent: 5, stage: 'accepted', done: false },
+ }
await loadSkills()
await refreshImage()
followProgress(skill.id)
@@ -1289,7 +1399,7 @@ onUnmounted(() => {
}
.installer-model-hint {
- margin: 0 0 10px;
+ margin: 0;
font-size: 12px;
line-height: 1.5;
color: var(--td-text-color-secondary);
@@ -1527,69 +1637,107 @@ onUnmounted(() => {
}
}
- .skill-envs__hint {
- margin: 0;
- font-size: 12px;
- line-height: 1.5;
- color: var(--td-text-color-secondary);
+ &--danger h4 {
+ color: var(--td-error-color);
}
- .skill-envs__rows {
- display: flex;
- flex-direction: column;
- gap: 10px;
+ &--remove {
+ border-top: 0;
+ padding-top: 0;
}
+}
- .skill-envs__row {
- display: flex;
- flex-direction: column;
- gap: 4px;
- }
+.skill-manage__progress-label {
+ font-size: 12px;
+ font-weight: 600;
+ color: var(--td-brand-color);
+}
- .skill-envs__meta {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- gap: 6px;
- }
+.skill-manage__remove-stage {
+ margin: 0;
+ font-size: 13px;
+ line-height: 1.5;
+ color: var(--td-text-color-secondary);
+}
- .skill-envs__name {
- font-family: var(--td-font-family-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
- font-size: 12px;
+.skill-manage__done {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 10px;
+ padding: 8px 0 4px;
+ color: var(--td-success-color, var(--td-brand-color));
+
+ p {
+ margin: 0;
+ font-size: 14px;
+ line-height: 1.55;
color: var(--td-text-color-primary);
- overflow-wrap: anywhere;
}
+}
- .skill-envs__tag {
- font-size: 12px;
- line-height: 18px;
- padding: 0 8px;
- border-radius: 10px;
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-secondary);
- }
+.skill-envs__hint {
+ margin: 0;
+ font-size: 12px;
+ line-height: 1.5;
+ color: var(--td-text-color-secondary);
+}
- .skill-envs__tag--required {
- background: var(--td-warning-color-light);
- color: var(--td-warning-color);
- }
+.skill-envs__rows {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+}
- .skill-envs__tag--set {
- background: var(--td-success-color-light);
- color: var(--td-success-color);
- }
+.skill-envs__row {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+}
- .skill-envs__desc {
- font-size: 12px;
- line-height: 1.5;
- color: var(--td-text-color-secondary);
- }
+.skill-envs__meta {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 6px;
+}
- .skill-envs__editor {
- display: flex;
- align-items: center;
- gap: 8px;
- }
+.skill-envs__name {
+ font-family: var(--td-font-family-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
+ font-size: 12px;
+ color: var(--td-text-color-primary);
+ overflow-wrap: anywhere;
+}
+
+.skill-envs__tag {
+ font-size: 12px;
+ line-height: 18px;
+ padding: 0 8px;
+ border-radius: 10px;
+ background: var(--td-bg-color-secondarycontainer);
+ color: var(--td-text-color-secondary);
+}
+
+.skill-envs__tag--required {
+ background: var(--td-warning-color-light);
+ color: var(--td-warning-color);
+}
+
+.skill-envs__tag--set {
+ background: var(--td-success-color-light);
+ color: var(--td-success-color);
+}
+
+.skill-envs__desc {
+ font-size: 12px;
+ line-height: 1.5;
+ color: var(--td-text-color-secondary);
+}
+
+.skill-envs__editor {
+ display: flex;
+ align-items: center;
+ gap: 8px;
}
.skill-list {
diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts
index 0b73c1959..eb007e0c7 100755
--- a/frontend/src/i18n/locales/en-US.ts
+++ b/frontend/src/i18n/locales/en-US.ts
@@ -1324,14 +1324,16 @@ export default {
skillUploadHint: 'Install writes the skill onto the current image and takes a new snapshot. This can take several minutes. The current chat turn is not interrupted; open sessions rebuild their sandbox on the next turn, which clears the session workspace scratch.',
skillUploadHintNewSession: 'Install writes the skill onto the current image and takes a new snapshot. This can take several minutes. Already-open sessions keep their current sandbox until they end; only newly started sessions pick up this install.',
skillSourceSection: 'Install from a source',
- skillSourceSectionHint: 'Paste a ClawHub, GitHub or SkillHub link, or {\'@\'}owner/slug.',
+ skillSourceSectionHint: 'Paste a ClawHub, GitHub or SkillHub link, or {\'@\'}owner/slug. The bundle cannot exceed {size} MB.',
skillUploadSection: 'Upload a local bundle',
- skillUploadSectionHint: 'Drop a zip that contains SKILL.md below, or click to pick a file.',
+ skillUploadSectionHint: 'Drop a zip that contains SKILL.md below, or click to pick a file. The bundle cannot exceed {size} MB.',
skillSourcePlaceholder: 'ClawHub: {\'@\'}owner/slug. GitHub/SkillHub: paste the full URL',
skillSourceInstall: 'Install',
skillInstallOr: 'or',
skillSourceFailed: 'Failed to install the skill from the registry',
skillUploadFailed: 'Failed to upload the skill',
+ skillBundleTooLarge: 'The skill bundle cannot exceed {size} MB.',
+ skillBundleTooManyFiles: 'The skill directory cannot hold more than {count} files.',
skillUploading: 'Uploading {percent}%',
skillUploadAccepted: 'Skill install started',
skillStatusInstalling: 'Installing',
@@ -1342,6 +1344,16 @@ export default {
skillDisableHint: 'Disable = the skill is invisible to the agent, files stay in the image. Changes take effect on the session\'s next execution.',
skillDeleteHint: 'Delete removes the skill directory from the image and takes a new snapshot. The current chat turn is not interrupted; open sessions rebuild their sandbox on the next turn, which clears the session workspace scratch.',
skillDeleteHintNewSession: 'Delete removes the skill directory from the image and takes a new snapshot. Already-open sessions keep their current sandbox until they end; only newly started sessions lose this skill.',
+ skillRemoveInProgress: 'Uninstalling',
+ skillRemoveWaiting: 'Uninstall from the image has started. Waiting for progress…',
+ skillRemoveDone: 'Uninstalled “{name}” from this sandbox. It remains in the catalog, so you can install it again later.',
+ skillRemoveStage: {
+ accepted: 'Uninstall request accepted',
+ sandbox_ready: 'Opening a maintenance sandbox',
+ removed: 'Files removed, building a new image',
+ done: 'Uninstall complete',
+ failed: 'Uninstall failed',
+ },
imageInfoTitle: 'Current image',
imageInfoSnapshot: 'Snapshot ID',
imageInfoGeneration: 'Version',
diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts
index b91bca9ad..f999fb03d 100755
--- a/frontend/src/i18n/locales/ko-KR.ts
+++ b/frontend/src/i18n/locales/ko-KR.ts
@@ -5244,14 +5244,16 @@ export default {
skillUploadHint: '설치하면 현재 이미지에 스킬을 쓰고 새 스냅샷을 만듭니다. 몇 분이 걸릴 수 있습니다. 현재 대화 턴은 중단되지 않으며, 이미 열린 세션은 다음 턴에서 새 이미지로 샌드박스를 다시 만들고 그때 세션 작업 공간 초안이 지워집니다.',
skillUploadHintNewSession: '설치하면 현재 이미지에 스킬을 쓰고 새 스냅샷을 만듭니다. 몇 분이 걸릴 수 있습니다. 이미 열린 세션은 세션이 끝날 때까지 기존 샌드박스를 유지하며, 이번에 설치한 스킬은 새로 시작한 세션에만 적용됩니다.',
skillSourceSection: '소스에서 설치',
- skillSourceSectionHint: 'ClawHub, GitHub 또는 SkillHub 링크, 혹은 {\'@\'}owner/slug를 붙여넣으세요.',
+ skillSourceSectionHint: 'ClawHub, GitHub 또는 SkillHub 링크, 혹은 {\'@\'}owner/slug를 붙여넣으세요. 압축 파일은 {size} MB를 넘을 수 없습니다.',
skillUploadSection: '로컬 번들 업로드',
- skillUploadSectionHint: 'SKILL.md가 포함된 zip을 아래로 끌어다 놓거나 클릭해서 선택하세요.',
+ skillUploadSectionHint: 'SKILL.md가 포함된 zip을 아래로 끌어다 놓거나 클릭해서 선택하세요. 압축 파일은 {size} MB를 넘을 수 없습니다.',
skillSourcePlaceholder: 'ClawHub는 {\'@\'}owner/slug, GitHub/SkillHub는 전체 URL을 붙여넣으세요',
skillSourceInstall: '설치',
skillInstallOr: '또는',
skillSourceFailed: '레지스트리에서 스킬을 설치하지 못했습니다',
skillUploadFailed: 'Failed to upload the skill',
+ skillBundleTooLarge: '스킬 압축 파일은 {size} MB를 넘을 수 없습니다.',
+ skillBundleTooManyFiles: '스킬 디렉터리의 파일은 {count}개를 넘을 수 없습니다.',
skillUploading: 'Uploading {percent}%',
skillUploadAccepted: 'Skill install started',
skillStatusInstalling: 'Installing',
@@ -5262,6 +5264,16 @@ export default {
skillDisableHint: 'Disable = the skill is invisible to the agent, files stay in the image. Changes take effect on the session\'s next execution.',
skillDeleteHint: '삭제하면 이미지에서 스킬 디렉터리를 제거하고 새 스냅샷을 만듭니다. 현재 대화 턴은 중단되지 않으며, 이미 열린 세션은 다음 턴에서 새 이미지로 샌드박스를 다시 만들고 그때 세션 작업 공간 초안이 지워집니다.',
skillDeleteHintNewSession: '삭제하면 이미지에서 스킬 디렉터리를 제거하고 새 스냅샷을 만듭니다. 이미 열린 세션은 세션이 끝날 때까지 기존 샌드박스를 유지하며, 이 스킬은 새로 시작한 세션에서만 빠집니다.',
+ skillRemoveInProgress: '제거 중',
+ skillRemoveWaiting: '이미지에서 제거를 시작했습니다. 진행 상황을 기다리는 중…',
+ skillRemoveDone: '샌드박스에서 「{name}」을(를) 제거했습니다. 스킬은 카탈로그에 남아 있으니 나중에 다시 설치할 수 있습니다.',
+ skillRemoveStage: {
+ accepted: '제거 요청을 수락했습니다',
+ sandbox_ready: '유지보수 샌드박스를 여는 중',
+ removed: '파일을 삭제했고 새 이미지를 생성하는 중',
+ done: '제거 완료',
+ failed: '제거 실패',
+ },
imageInfoTitle: 'Current image',
imageInfoSnapshot: 'Snapshot ID',
imageInfoGeneration: 'Version',
diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts
index 74624fdbd..a4eee1f16 100755
--- a/frontend/src/i18n/locales/ru-RU.ts
+++ b/frontend/src/i18n/locales/ru-RU.ts
@@ -5244,14 +5244,16 @@ export default {
skillUploadHint: 'Установка записывает навык в текущий образ и создаёт новый снимок. Это может занять несколько минут. Текущий ход диалога не прерывается; открытые сессии пересоздадут песочницу при следующем сообщении, и тогда черновики рабочей области сессии будут очищены.',
skillUploadHintNewSession: 'Установка записывает навык в текущий образ и создаёт новый снимок. Это может занять несколько минут. Уже открытые сессии продолжают использовать текущую песочницу до своего завершения; этот навык появится только у новых сессий.',
skillSourceSection: 'Установить из источника',
- skillSourceSectionHint: 'Вставьте ссылку ClawHub, GitHub или SkillHub, либо {\'@\'}owner/slug.',
+ skillSourceSectionHint: 'Вставьте ссылку ClawHub, GitHub или SkillHub, либо {\'@\'}owner/slug. Архив не может превышать {size} МБ.',
skillUploadSection: 'Загрузить локальный пакет',
- skillUploadSectionHint: 'Перетащите zip с файлом SKILL.md ниже или нажмите, чтобы выбрать файл.',
+ skillUploadSectionHint: 'Перетащите zip с файлом SKILL.md ниже или нажмите, чтобы выбрать файл. Архив не может превышать {size} МБ.',
skillSourcePlaceholder: 'ClawHub: {\'@\'}owner/slug. GitHub/SkillHub: вставьте полный URL',
skillSourceInstall: 'Установить',
skillInstallOr: 'или',
skillSourceFailed: 'Не удалось установить навык из реестра',
skillUploadFailed: 'Failed to upload the skill',
+ skillBundleTooLarge: 'Архив навыка не может превышать {size} МБ.',
+ skillBundleTooManyFiles: 'В каталоге навыка не может быть больше {count} файлов.',
skillUploading: 'Uploading {percent}%',
skillUploadAccepted: 'Skill install started',
skillStatusInstalling: 'Installing',
@@ -5262,6 +5264,16 @@ export default {
skillDisableHint: 'Disable = the skill is invisible to the agent, files stay in the image. Changes take effect on the session\'s next execution.',
skillDeleteHint: 'Удаление убирает каталог навыка из образа и создаёт новый снимок. Текущий ход диалога не прерывается; открытые сессии пересоздадут песочницу при следующем сообщении, и тогда черновики рабочей области сессии будут очищены.',
skillDeleteHintNewSession: 'Удаление убирает каталог навыка из образа и создаёт новый снимок. Уже открытые сессии продолжают использовать текущую песочницу до своего завершения; этот навык исчезнет только у новых сессий.',
+ skillRemoveInProgress: 'Удаление',
+ skillRemoveWaiting: 'Удаление из образа началось. Ожидание хода выполнения…',
+ skillRemoveDone: '«{name}» удалён из этой песочницы. Навык остаётся в каталоге, его можно установить снова.',
+ skillRemoveStage: {
+ accepted: 'Запрос на удаление принят',
+ sandbox_ready: 'Открывается служебная песочница',
+ removed: 'Файлы удалены, создаётся новый образ',
+ done: 'Удаление завершено',
+ failed: 'Не удалось удалить',
+ },
imageInfoTitle: 'Current image',
imageInfoSnapshot: 'Snapshot ID',
imageInfoGeneration: 'Version',
diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts
index 15c4c298c..24eedc35d 100755
--- a/frontend/src/i18n/locales/zh-CN.ts
+++ b/frontend/src/i18n/locales/zh-CN.ts
@@ -5246,14 +5246,16 @@ export default {
skillUploadHint: '安装会在当前镜像上生成新快照,可能需要数分钟。当前这一轮对话不会中断;下一轮提问时才会按新镜像重建沙箱,会话工作区草稿会在那时清空。',
skillUploadHintNewSession: '安装会在当前镜像上生成新快照,可能需要数分钟。已打开的会话继续使用原沙箱,直到该会话结束;只有新打开的会话才会带上这次安装的技能。',
skillSourceSection: '从来源安装',
- skillSourceSectionHint: '粘贴 ClawHub、GitHub 或 SkillHub 链接,或 {\'@\'}owner/slug。',
+ skillSourceSectionHint: '粘贴 ClawHub、GitHub 或 SkillHub 链接,或 {\'@\'}owner/slug。压缩包不超过 {size} MB。',
skillUploadSection: '上传本地压缩包',
- skillUploadSectionHint: '把包含 SKILL.md 的 zip 拖到下方,或点击选择文件。',
+ skillUploadSectionHint: '把包含 SKILL.md 的 zip 拖到下方,或点击选择文件。压缩包不超过 {size} MB。',
skillSourcePlaceholder: 'ClawHub 用 {\'@\'}owner/slug,GitHub / SkillHub 请粘贴完整链接',
skillSourceInstall: '安装',
skillInstallOr: '或',
skillSourceFailed: '从托管平台安装技能失败',
skillUploadFailed: '技能上传失败',
+ skillBundleTooLarge: '技能压缩包不能超过 {size} MB。',
+ skillBundleTooManyFiles: '技能目录里的文件不能超过 {count} 个。',
skillUploading: '正在上传 {percent}%',
skillUploadAccepted: '已开始安装技能',
skillStatusInstalling: '安装中',
@@ -5264,6 +5266,16 @@ export default {
skillDisableHint: '禁用后该技能对智能体不可见,文件仍保留在镜像中。变更将在会话下一次执行时生效。',
skillDeleteHint: '删除会从镜像中移除该技能目录并生成新快照。当前这一轮对话不会中断;下一轮提问时才会按新镜像重建沙箱,会话工作区草稿会在那时清空。',
skillDeleteHintNewSession: '删除会从镜像中移除该技能目录并生成新快照。已打开的会话继续使用原沙箱,直到该会话结束;只有新打开的会话才会去掉该技能。',
+ skillRemoveInProgress: '正在卸载',
+ skillRemoveWaiting: '已开始从镜像卸载,正在等待进度…',
+ skillRemoveDone: '已从沙箱卸载「{name}」。技能仍在目录里,可以稍后再装回去。',
+ skillRemoveStage: {
+ accepted: '已接受卸载请求',
+ sandbox_ready: '正在打开维护沙箱',
+ removed: '文件已删除,正在生成新镜像',
+ done: '卸载完成',
+ failed: '卸载失败',
+ },
imageInfoTitle: '当前镜像',
imageInfoSnapshot: '快照 ID',
imageInfoGeneration: '版本',
diff --git a/frontend/src/views/settings/SkillSettings.test.mjs b/frontend/src/views/settings/SkillSettings.test.mjs
index 42ff9ba72..f9d985252 100644
--- a/frontend/src/views/settings/SkillSettings.test.mjs
+++ b/frontend/src/views/settings/SkillSettings.test.mjs
@@ -25,12 +25,26 @@ test('catalog cards can install onto sandboxes and manage one install', () => {
assert.match(source, /settings\.skills\.installedOnName/)
assert.match(source, /settings\.skills\.installedCount/)
assert.match(source, /skill-card__icon-btn/)
+ assert.match(source, /FolderIcon/)
+ assert.match(source, /DeleteIcon/)
+ assert.match(source, /skill-card--idle/)
+ assert.match(source, /skill-card--installed/)
+ assert.match(source, /skill-card__chip--idle/)
+ assert.match(source, /skill-card__chip--installed/)
+ assert.doesNotMatch(source, /t-icon name="folder"/)
+ assert.doesNotMatch(source, /t-icon name="delete"/)
assert.match(source, /openCatalogFiles/)
assert.match(source, /SkillFilesDrawer/)
assert.match(source, /installPartial/)
assert.match(source, /installOutdated/)
assert.match(source, /skill-card__entry--stale/)
assert.match(source, /check-circle-filled/)
+ assert.doesNotMatch(source, /installSummaryIcon/)
+ assert.match(source, /skillSourceSectionHint/)
+ assert.match(source, /skillUploadSectionHint/)
+ assert.match(source, /maxSkillBundleMB/)
+ assert.match(source, /align-items: stretch/)
+ assert.match(source, /margin-top: auto/)
assert.match(source, /installsView/)
assert.match(source, /needsPanel/)
assert.match(source, /catalogInstallFailedCount/)
diff --git a/frontend/src/views/settings/SkillSettings.vue b/frontend/src/views/settings/SkillSettings.vue
index a69e52e3b..8646cb813 100644
--- a/frontend/src/views/settings/SkillSettings.vue
+++ b/frontend/src/views/settings/SkillSettings.vue
@@ -48,7 +48,11 @@
v-for="item in catalog"
:key="item.id"
class="skill-card"
- :class="{ 'skill-card--focused': focusedCatalogId === item.id }"
+ :class="{
+ 'skill-card--focused': focusedCatalogId === item.id,
+ 'skill-card--installed': liveInstalls(item).length > 0,
+ 'skill-card--idle': liveInstalls(item).length === 0,
+ }"
>
<div class="skill-card__main">
<div class="skill-card__badge" aria-hidden="true">
@@ -68,7 +72,7 @@
:aria-label="$t('settings.sandbox.skillFiles')"
@click="openCatalogFiles(item)"
>
- <t-icon name="folder" size="16px" />
+ <folder-icon size="14px" />
</button>
<button
v-if="canDelete(item)"
@@ -79,7 +83,7 @@
:aria-label="$t('settings.skills.deleteCatalog')"
@click="askDelete(item)"
>
- <t-icon name="delete" size="16px" />
+ <delete-icon size="14px" />
</button>
</div>
</div>
@@ -101,7 +105,7 @@
v-else-if="!view.needsPanel"
type="button"
class="skill-card__chip"
- :class="view.installs[0] ? installEntryClass(item, view.installs[0]) : undefined"
+ :class="chipClass(item, view)"
:disabled="Boolean(view.installs[0] && !recordFor(view.installs[0].sandbox_config_id))"
:title="installSummaryTooltip(item, view)"
:aria-label="installSummary(item, view)"
@@ -113,12 +117,6 @@
aria-hidden="true"
/>
<span class="skill-card__chip-text">{{ installSummary(item, view) }}</span>
- <t-icon
- v-if="installSummaryIcon(item, view)"
- :name="installSummaryIcon(item, view)"
- size="14px"
- class="skill-card__entry-status"
- />
<t-icon name="chevron-right" size="14px" class="skill-card__chip-go" />
</button>
<t-popup
@@ -135,6 +133,7 @@
<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"
@@ -145,12 +144,6 @@
aria-hidden="true"
/>
<span class="skill-card__chip-text">{{ installSummary(item, view) }}</span>
- <t-icon
- v-if="installSummaryIcon(item, view)"
- :name="installSummaryIcon(item, view)"
- size="14px"
- class="skill-card__entry-status"
- />
<t-icon name="chevron-down" size="14px" class="skill-card__chip-go" />
</button>
<template #content>
@@ -275,7 +268,7 @@
<template v-if="addStep === 0">
<section class="setting-drawer__section">
<h4 class="setting-drawer__section-title">{{ $t('settings.sandbox.skillSourceSection') }}</h4>
- <p class="installer-model-hint">{{ $t('settings.sandbox.skillSourceSectionHint') }}</p>
+ <p class="installer-model-hint">{{ $t('settings.sandbox.skillSourceSectionHint', { size: maxSkillBundleMB }) }}</p>
<t-input
v-model="sourceInput"
:placeholder="$t('settings.sandbox.skillSourcePlaceholder')"
@@ -286,7 +279,7 @@
<section class="setting-drawer__section">
<h4 class="setting-drawer__section-title">{{ $t('settings.sandbox.skillUploadSection') }}</h4>
- <p class="installer-model-hint">{{ $t('settings.sandbox.skillUploadSectionHint') }}</p>
+ <p class="installer-model-hint">{{ $t('settings.sandbox.skillUploadSectionHint', { size: maxSkillBundleMB }) }}</p>
<input
ref="fileInputRef"
type="file"
@@ -435,7 +428,7 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next'
-import { AddIcon } from 'tdesign-icons-vue-next'
+import { AddIcon, DeleteIcon, FolderIcon } from 'tdesign-icons-vue-next'
import { useI18n } from 'vue-i18n'
import SandboxSkillsPanel from '@/components/SandboxSkillsPanel.vue'
import SkillFilesDrawer from '@/components/SkillFilesDrawer.vue'
@@ -445,6 +438,7 @@ import ModelSelector from '@/components/ModelSelector.vue'
import { useConfirmDelete } from '@/components/settings/useConfirmDelete'
import { SKILL_ICON } from '@/types/mention'
import { useUIStore } from '@/stores/ui'
+import { MAX_FILE_SIZE_BYTES, MAX_FILE_SIZE_MB } from '@/utils'
import {
deleteSkillCatalog,
installSkillCatalog,
@@ -516,6 +510,7 @@ const skillConfigs = computed(() =>
)
const addBusy = computed(() => uploading.value || addingFromSource.value)
+const maxSkillBundleMB = MAX_FILE_SIZE_MB
const addSteps = computed(() => [
{ key: 'register', title: t('settings.skills.addStepRegister') },
@@ -704,12 +699,11 @@ function installSummary(item: SkillCatalogItem, view: ReturnType<typeof installs
return t('settings.skills.installedCount', { count: view.installs.length })
}
-function installSummaryIcon(item: SkillCatalogItem, view: ReturnType<typeof installsView>): string {
- for (const inst of view.installs) {
- const icon = installChipStatusIcon(item, inst)
- if (icon && icon !== 'check-circle-filled') return icon
- }
- return ''
+function chipClass(item: SkillCatalogItem, view: ReturnType<typeof installsView>): (string | undefined)[] {
+ return [
+ view.installs.length === 0 ? 'skill-card__chip--idle' : 'skill-card__chip--installed',
+ view.installs[0] ? installEntryClass(item, view.installs[0]) : undefined,
+ ]
}
function installSummaryTooltip(item: SkillCatalogItem, view: ReturnType<typeof installsView>): string {
@@ -917,9 +911,28 @@ function acceptPendingFile(file: File) {
MessagePlugin.error(t('settings.sandbox.skillUploadFailed'))
return
}
+ if (file.size > MAX_FILE_SIZE_BYTES) {
+ MessagePlugin.error(t('settings.sandbox.skillBundleTooLarge', { size: maxSkillBundleMB }))
+ return
+ }
pendingFile.value = file
}
+function skillRegisterErrorMessage(err: any, fromFile: boolean): string {
+ const raw = String(err?.message || '')
+ if (/cannot exceed \d+\s*MB/i.test(raw)) {
+ return t('settings.sandbox.skillBundleTooLarge', { size: maxSkillBundleMB })
+ }
+ const tooMany = raw.match(/archive holds more than (\d+) files/i)
+ if (tooMany) {
+ return t('settings.sandbox.skillBundleTooManyFiles', { count: tooMany[1] })
+ }
+ if (raw) return raw
+ return fromFile
+ ? t('settings.sandbox.skillUploadFailed')
+ : t('settings.sandbox.skillSourceFailed')
+}
+
async function registerThenAdvance() {
if (registeredCatalog.value) {
addTargetIds.value = defaultAddTargets()
@@ -954,11 +967,7 @@ async function registerThenAdvance() {
await loadCatalog()
syncRegisteredFromCatalog()
} catch (e: any) {
- MessagePlugin.error(
- e?.message || (pendingFile.value
- ? t('settings.sandbox.skillUploadFailed')
- : t('settings.sandbox.skillSourceFailed')),
- )
+ MessagePlugin.error(skillRegisterErrorMessage(e, Boolean(pendingFile.value)))
} finally {
uploading.value = false
addingFromSource.value = false
@@ -1226,7 +1235,7 @@ onUnmounted(() => {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 10px;
- align-items: start;
+ align-items: stretch;
}
.skill-card {
@@ -1240,18 +1249,24 @@ onUnmounted(() => {
background: var(--td-bg-color-container);
transition: border-color 0.18s ease, box-shadow 0.18s ease;
min-width: 0;
+ height: 100%;
&--focused {
border-color: var(--td-brand-color);
box-shadow: 0 0 0 2px var(--td-brand-color-focus, rgba(0, 168, 112, 0.18));
}
+ &--installed .skill-card__badge {
+ background: color-mix(in srgb, var(--td-brand-color) 12%, transparent);
+ color: var(--td-brand-color);
+ }
+
&--add {
flex-direction: column;
align-items: center;
justify-content: center;
gap: 6px;
- min-height: 88px;
+ height: 100%;
padding: 16px 12px;
border-style: dashed;
background: transparent;
@@ -1295,14 +1310,16 @@ onUnmounted(() => {
.skill-card__main {
display: flex;
- align-items: flex-start;
+ align-items: stretch;
gap: 10px;
- padding: 10px 12px 10px 10px;
+ padding: 10px 12px;
min-width: 0;
+ flex: 1;
}
.skill-card__badge {
flex-shrink: 0;
+ align-self: flex-start;
width: 28px;
height: 28px;
border-radius: 7px;
@@ -1369,9 +1386,14 @@ onUnmounted(() => {
border: 0;
border-radius: 6px;
background: none;
- color: var(--td-text-color-placeholder);
+ color: var(--td-text-color-secondary);
cursor: pointer;
+ :deep(svg) {
+ display: block;
+ overflow: visible;
+ }
+
&:hover:not(:disabled) {
color: var(--td-text-color-primary);
background: var(--td-bg-color-container-hover);
@@ -1413,6 +1435,7 @@ onUnmounted(() => {
display: flex;
align-items: center;
min-width: 0;
+ margin-top: auto;
}
.skill-card__installs-label {
@@ -1449,16 +1472,42 @@ onUnmounted(() => {
opacity: 0.6;
}
- &--off {
+ &--idle {
+ color: var(--td-brand-color);
+ background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
+
+ &:hover:not(:disabled) {
+ color: var(--td-brand-color);
+ background: color-mix(in srgb, var(--td-brand-color) 16%, transparent);
+ }
+
+ .skill-card__chip-go {
+ color: var(--td-brand-color);
+ }
+ }
+
+ &.skill-card__entry--off {
color: var(--td-text-color-placeholder);
}
- &.skill-card__entry--stale .skill-card__entry-status {
- color: var(--td-warning-color);
+ &--installed .skill-card__entry-status {
+ color: var(--td-success-color, var(--td-brand-color));
}
- &.skill-card__entry--failed .skill-card__entry-status {
- color: var(--td-error-color);
+ &.skill-card__entry--stale {
+ background: color-mix(in srgb, var(--td-warning-color) 10%, transparent);
+
+ .skill-card__entry-status {
+ color: var(--td-warning-color);
+ }
+ }
+
+ &.skill-card__entry--failed {
+ background: color-mix(in srgb, var(--td-error-color) 10%, transparent);
+
+ .skill-card__entry-status {
+ color: var(--td-error-color);
+ }
}
&.skill-card__entry--busy .skill-card__entry-dot {
@@ -1575,9 +1624,9 @@ onUnmounted(() => {
}
.installer-model-hint {
- margin: 0 0 10px;
+ margin: 0;
font-size: 12px;
- line-height: 1.55;
+ line-height: 1.5;
color: var(--td-text-color-secondary);
}
@@ -1678,17 +1727,6 @@ onUnmounted(() => {
}
}
-.setting-drawer__section {
- margin-bottom: 20px;
-}
-
-.setting-drawer__section-title {
- margin: 0 0 8px;
- font-size: 13px;
- font-weight: 600;
- color: var(--td-text-color-primary);
-}
-
.sandbox-pick-list {
display: flex;
flex-direction: column;
diff --git a/internal/agent/skills/tenant_source.go b/internal/agent/skills/tenant_source.go
index bf0098160..2aa3c683d 100644
--- a/internal/agent/skills/tenant_source.go
+++ b/internal/agent/skills/tenant_source.go
@@ -19,9 +19,9 @@ import (
// archive read here is the same one that was accepted then, and a corrupted or
// hostile object in storage must not be able to exhaust this process.
const (
- maxBundleEntries = 2000
+ maxBundleEntries = 20_000
maxBundleEntryBytes = 32 << 20 // 32 MiB per entry
- maxBundleBytes = 256 << 20 // 256 MiB across the archive
+ maxBundleBytes = 512 << 20 // 512 MiB across the archive
)
// cachedBundleCount bounds the unpacked archives one source keeps. A source
diff --git a/internal/application/service/tenant_skill_bundle.go b/internal/application/service/tenant_skill_bundle.go
index 65911e807..3d1bf4ead 100644
--- a/internal/application/service/tenant_skill_bundle.go
+++ b/internal/application/service/tenant_skill_bundle.go
@@ -24,9 +24,17 @@ var ErrSkillBundleInvalid = errors.New("skill bundle is invalid")
// The skill bundle limits bound decompression so a zip bomb cannot exhaust
// memory before we ever reach the sandbox.
const (
- maxSkillBundleFiles = 2000
+ // maxSkillBundleFiles is the cap on files kept as the skill itself
+ // (after dropping GitHub zipball extras and directory entries).
+ // Real skills vendor assets: hugohe3/ppt-master's skills/ppt-master
+ // tree is ~13k files, almost all under templates/.
+ maxSkillBundleFiles = 20_000
+ // maxSkillBundleZipEntries bounds central-directory iteration on the
+ // raw archive. GitHub zipballs include the whole repository, so this
+ // is higher than maxSkillBundleFiles.
+ maxSkillBundleZipEntries = 100_000
maxSkillBundleFileBytes = 32 << 20 // 32 MiB per entry
- maxSkillBundleTotalBytes = 256 << 20 // 256 MiB across the archive
+ maxSkillBundleTotalBytes = 512 << 20 // 512 MiB across the kept skill files
)
// SkillBundle is a validated, in-memory skill archive.
@@ -72,7 +80,7 @@ func ParseSkillBundle(archive []byte) (*SkillBundle, error) {
// ParseSkillBundleWithOptions is ParseSkillBundle with the extra knobs remote
// installs need. SHA256 is still over the input bytes, not the re-rooted view.
func ParseSkillBundleWithOptions(archive []byte, opts SkillBundleParseOptions) (*SkillBundle, error) {
- raw, err := unzipSkillArchive(archive)
+ raw, err := unzipSkillArchive(archive, opts)
if err != nil {
return nil, err
}
@@ -83,8 +91,8 @@ func ParseSkillBundleWithOptions(archive []byte, opts SkillBundleParseOptions) (
return skillBundleFromFiles(archive, files)
}
-func unzipSkillArchive(archive []byte) (map[string][]byte, error) {
- entries, err := skillZipEntries(archive)
+func unzipSkillArchive(archive []byte, opts SkillBundleParseOptions) (map[string][]byte, error) {
+ entries, err := skillZipEntries(archive, opts)
if err != nil {
return nil, err
}
@@ -124,56 +132,89 @@ type skillZipEntry struct {
size int64
}
-func skillZipEntries(archive []byte) ([]skillZipEntry, error) {
+func skillZipEntries(archive []byte, opts SkillBundleParseOptions) ([]skillZipEntry, error) {
reader, err := zip.NewReader(bytes.NewReader(archive), int64(len(archive)))
if err != nil {
return nil, fmt.Errorf("%w: not a readable zip archive: %v", ErrSkillBundleInvalid, err)
}
- if len(reader.File) > maxSkillBundleFiles {
+ if len(reader.File) > maxSkillBundleZipEntries {
return nil, fmt.Errorf("%w: archive holds more than %d files",
- ErrSkillBundleInvalid, maxSkillBundleFiles)
+ ErrSkillBundleInvalid, maxSkillBundleZipEntries)
}
- out := make([]skillZipEntry, 0, len(reader.File))
- var totalBytes int64
+ pending := make([]skillZipEntry, 0, len(reader.File))
+ names := make(map[string][]byte, len(reader.File))
for _, entry := range reader.File {
- name, skip, err := inspectSkillZipEntry(entry)
+ name, skip, err := inspectSkillZipPath(entry)
if err != nil {
return nil, err
}
if skip {
continue
}
- size := entry.FileInfo().Size()
- if totalBytes+size > maxSkillBundleTotalBytes {
+ pending = append(pending, skillZipEntry{
+ file: entry,
+ name: name,
+ size: entry.FileInfo().Size(),
+ })
+ names[name] = nil
+ }
+
+ prefix, err := skillRootPrefix(names, opts)
+ if err != nil {
+ return nil, err
+ }
+
+ out := make([]skillZipEntry, 0, len(pending))
+ var totalBytes int64
+ for _, item := range pending {
+ if prefix != "" && !strings.HasPrefix(item.name, prefix+"/") {
+ if opts.AllowExtraFiles {
+ continue
+ }
+ return nil, fmt.Errorf("%w: archive holds files outside the skill directory %q",
+ ErrSkillBundleInvalid, prefix)
+ }
+ if err := inspectKeptSkillZipEntry(item); err != nil {
+ return nil, err
+ }
+ if totalBytes+item.size > maxSkillBundleTotalBytes {
return nil, fmt.Errorf("%w: archive is too large", ErrSkillBundleInvalid)
}
- totalBytes += size
- out = append(out, skillZipEntry{file: entry, name: name, size: size})
+ totalBytes += item.size
+ out = append(out, item)
+ if len(out) > maxSkillBundleFiles {
+ return nil, fmt.Errorf("%w: archive holds more than %d files",
+ ErrSkillBundleInvalid, maxSkillBundleFiles)
+ }
}
return out, nil
}
-func inspectSkillZipEntry(entry *zip.File) (name string, skip bool, err error) {
+func inspectSkillZipPath(entry *zip.File) (name string, skip bool, err error) {
if entry.FileInfo().IsDir() {
return "", true, nil
}
- if entry.FileInfo().Mode()&os.ModeSymlink != 0 {
- return "", false, fmt.Errorf("%w: entry %q is a symlink", ErrSkillBundleInvalid, entry.Name)
- }
name = path.Clean(entry.Name)
if name == "." || strings.HasPrefix(name, "..") ||
path.IsAbs(name) || strings.Contains(name, "../") {
return "", false, fmt.Errorf("%w: entry %q escapes the archive root",
ErrSkillBundleInvalid, entry.Name)
}
- if err := validateSkillEntryName(name); err != nil {
- return "", false, err
+ return name, false, nil
+}
+
+func inspectKeptSkillZipEntry(item skillZipEntry) error {
+ if item.file.FileInfo().Mode()&os.ModeSymlink != 0 {
+ return fmt.Errorf("%w: entry %q is a symlink", ErrSkillBundleInvalid, item.file.Name)
}
- if entry.FileInfo().Size() > maxSkillBundleFileBytes {
- return "", false, fmt.Errorf("%w: entry %q is too large", ErrSkillBundleInvalid, entry.Name)
+ if err := validateSkillEntryName(item.name); err != nil {
+ return err
}
- return name, false, nil
+ if item.size > maxSkillBundleFileBytes {
+ return fmt.Errorf("%w: entry %q is too large", ErrSkillBundleInvalid, item.file.Name)
+ }
+ return nil
}
func readLimitedZipEntry(entry *zip.File) ([]byte, error) {
@@ -226,7 +267,7 @@ func readSkillZipFile(archive []byte, rel string) ([]byte, error) {
}
func skillZipFileIndex(archive []byte) (map[string]skillZipEntry, error) {
- entries, err := skillZipEntries(archive)
+ entries, err := skillZipEntries(archive, SkillBundleParseOptions{})
if err != nil {
return nil, err
}
diff --git a/internal/application/service/tenant_skill_bundle_test.go b/internal/application/service/tenant_skill_bundle_test.go
index ed5aeefbe..b3a4f496b 100644
--- a/internal/application/service/tenant_skill_bundle_test.go
+++ b/internal/application/service/tenant_skill_bundle_test.go
@@ -48,6 +48,25 @@ func zipBundleWithSymlink(t *testing.T) []byte {
return buf.Bytes()
}
+func zipBundleWithDirEntries(t *testing.T, dirs int) []byte {
+ t.Helper()
+ var buf bytes.Buffer
+ w := zip.NewWriter(&buf)
+
+ f, err := w.Create("SKILL.md")
+ require.NoError(t, err)
+ _, err = f.Write([]byte(validSkillMD))
+ require.NoError(t, err)
+
+ for i := range dirs {
+ _, err := w.Create(fmt.Sprintf("empty-%04d/", i))
+ require.NoError(t, err)
+ }
+
+ require.NoError(t, w.Close())
+ return buf.Bytes()
+}
+
func zipBundleWithNFiles(t *testing.T, count int) []byte {
t.Helper()
var buf bytes.Buffer
@@ -302,6 +321,34 @@ Use the scripts in this skill.
require.ErrorIs(t, err, ErrSkillBundleInvalid)
})
+ t.Run("remote options count only the skill subtree", func(t *testing.T) {
+ files := map[string]string{
+ "repo-main/README.md": "noise",
+ "repo-main/skills/pdf/SKILL.md": validSkillMD,
+ "repo-main/skills/pdf/run.py": "print(1)\n",
+ }
+ for i := 0; i < 3000; i++ {
+ files[fmt.Sprintf("repo-main/vendor/%04d.txt", i)] = "x"
+ }
+
+ bundle, err := ParseSkillBundleWithOptions(zipBundle(t, files), SkillBundleParseOptions{
+ AllowExtraFiles: true,
+ AllowNestedSkill: true,
+ })
+ require.NoError(t, err)
+ require.Equal(t, "pdf-tools", bundle.Name)
+ require.Len(t, bundle.Files, 2)
+ require.Contains(t, bundle.Files, "run.py")
+ require.NotContains(t, bundle.Files, "README.md")
+ })
+
+ t.Run("directory entries do not count toward the file cap", func(t *testing.T) {
+ bundle, err := ParseSkillBundle(zipBundleWithDirEntries(t, 3000))
+ require.NoError(t, err)
+ require.Equal(t, "pdf-tools", bundle.Name)
+ require.Len(t, bundle.Files, 1)
+ })
+
t.Run("rejects too many entries", func(t *testing.T) {
_, err := ParseSkillBundle(zipBundleWithNFiles(t, maxSkillBundleFiles))
require.ErrorIs(t, err, ErrSkillBundleInvalid)