Sources: add Gitea; fix Windows shims for shell tool, repo paths and stateDir

This commit is contained in:
dev
2026-11-01 19:32:40 +08:00
committed by Wanderingss
parent 6337fc823c
commit 4379973775
22 changed files with 1182 additions and 28 deletions
+6 -5
View File
@@ -6,6 +6,7 @@ import { DatabaseSync } from 'node:sqlite'
import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, expectTypeOf, it, vi } from 'vitest'
import type { UserMessage } from '@deepseek-ai/dsh-llm'
import { SHELL_TOOL } from '../src/app/sessions.ts'
import { renderPrompt } from '@deepseek-ai/dsh-system-prompt'
import { Runtime } from '../src/app/runtime.ts'
import { jobRegistry } from './fixtures/host.ts'
@@ -164,7 +165,7 @@ beforeEach(async () => {
if (agents.has(sessionId)) return
const agentCtx = new Context()
const preset = {}
const inherited = ['bash', 'read', 'read_image', 'skill', 'job_output', 'job_list', 'job_kill', 'grep', 'web_search',
const inherited = ['bash', 'pwsh', 'read', 'read_image', 'skill', 'job_output', 'job_list', 'job_kill', 'grep', 'web_search',
'ask_user_question', 'plugin_manager', 'schedule_create', 'create_goal', 'session_create', 'session_send_message', 'feishu_doc_edit']
const sessionTools = new Map<string, RegisteredTool>()
tools.set(sessionId, sessionTools)
@@ -1560,10 +1561,10 @@ it('refuses an ended ticket\'s worker its tools, and restricts the main Session
expect(guards.get(sessionId)!()).toBeUndefined()
runtime.engine.stopTicket(ticket.id)
expect(guards.get(sessionId)!()).toBe('Ticket ended; new work needs a new authorized ticket')
expect(restricts.get(runtime.masterId)).toEqual([{ allow: ['skill', 'bash', 'read', 'read_image', 'job_output', 'job_list', 'job_kill'] }])
expect(restricts.get(runtime.masterId)).toEqual([{ allow: ['skill', SHELL_TOOL, 'read', 'read_image', 'job_output', 'job_list', 'job_kill'] }])
// A worker keeps only the profile's work tools: none that ask a person, change the profile, schedule or start work outside
// the worker slots, reach other Sessions or edit documents, whenever they were registered.
expect(restricts.get(sessionId)).toEqual([{ allow: ['read', 'read_image', 'grep', 'bash', 'job_output', 'job_list', 'job_kill', 'web_search', 'skill'] }])
expect(restricts.get(sessionId)).toEqual([{ allow: ['read', 'read_image', 'grep', SHELL_TOOL, 'job_output', 'job_list', 'job_kill', 'web_search', 'skill'] }])
})
it('gives an explicit ticket\'s worker a prompt without the limits of an inferred Mandate', async () => {
@@ -1717,7 +1718,7 @@ it('gives a subagent of a worker only the worker\'s work tools, and none once th
const child = agents.get('child-1')! as unknown as { session: { header: { parentSession?: string } } }
child.session.header = { parentSession: sessionId }
await (runtime as unknown as { ctx: Context }).ctx.parallel('agent/created', { agent: child } as never)
expect(restricts.get('child-1')).toEqual([{ allow: ['read', 'read_image', 'grep', 'bash', 'job_output', 'job_list', 'job_kill', 'web_search', 'skill'] }])
expect(restricts.get('child-1')).toEqual([{ allow: ['read', 'read_image', 'grep', SHELL_TOOL, 'job_output', 'job_list', 'job_kill', 'web_search', 'skill'] }])
expect(guards.get('child-1')!()).toBeUndefined()
runtime.engine.stopTicket(ticket.id)
expect(guards.get('child-1')!()).toBe('Ticket ended; new work needs a new authorized ticket')
@@ -1739,7 +1740,7 @@ it('gives a subagent of a worker\'s subagent the same work tools and guard', asy
agent.session.header = { parentSession: parent }
await created.parallel('agent/created', { agent } as never)
}
expect(restricts.get('grandchild-1')).toEqual([{ allow: ['read', 'read_image', 'grep', 'bash', 'job_output', 'job_list', 'job_kill', 'web_search', 'skill'] }])
expect(restricts.get('grandchild-1')).toEqual([{ allow: ['read', 'read_image', 'grep', SHELL_TOOL, 'job_output', 'job_list', 'job_kill', 'web_search', 'skill'] }])
runtime.engine.stopTicket(ticket.id)
expect(guards.get('grandchild-1')!()).toBe('Ticket ended; new work needs a new authorized ticket')
})