mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-18 03:27:08 +00:00
merge: hapi upstream main 2026-10-19 (34 commits past v0.30.7)
Bring in the post-0.30.7 upstream work while keeping local team, macaron, requirement, DSH and deployment features: - runner/hub: cross-platform orphan reap on archive and tracking loss, machine-spawn preallocated stubs, keepalive-only sessions reconcile to idle - hub: prepared-statement cache, stale/canceled permission request handling - cli: Codex compaction announcements, dynamic Kimi models, MCP bridge reap - web: session toolbar icon shedding, mark-all-read, unread/active sections, Russian locale, external-link preference, 48px search chrome - ios/android: locale and font-size updates Conflict resolution keeps local-only behavior (agent team spawns, macaron skins, collapsible sidebar, workspace markdown images) layered on the new upstream toolbar and session lifecycle plumbing. Test infrastructure: skip the Docker-only pwsh integration test quickly when Docker is unavailable, and exclude the Bun-only usageScan test from vitest. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run> Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ const listOpencodeModelsForCwdMock = vi.hoisted(() => vi.fn())
|
||||
const listOpencodeModelVariantsMock = vi.hoisted(() => vi.fn())
|
||||
const listGrokModelsForCwdMock = vi.hoisted(() => vi.fn())
|
||||
const listCopilotModelsForCwdMock = vi.hoisted(() => vi.fn())
|
||||
const listKimiModelsForCwdMock = vi.hoisted(() => vi.fn())
|
||||
const inspectCursorChatStoreMock = vi.hoisted(() => vi.fn())
|
||||
|
||||
vi.mock('socket.io-client', () => ({
|
||||
@@ -34,6 +35,10 @@ vi.mock('../modules/common/copilotModels', () => ({
|
||||
listCopilotModelsForCwd: listCopilotModelsForCwdMock
|
||||
}))
|
||||
|
||||
vi.mock('../modules/common/kimiModels', () => ({
|
||||
listKimiModelsForCwd: listKimiModelsForCwdMock
|
||||
}))
|
||||
|
||||
vi.mock('@/cursor/cursorChatStoreStatus', () => ({
|
||||
inspectCursorChatStore: inspectCursorChatStoreMock
|
||||
}))
|
||||
@@ -107,6 +112,15 @@ async function callListCopilotModels(client: ApiMachineClient, machineId: string
|
||||
return JSON.parse(raw) as unknown
|
||||
}
|
||||
|
||||
async function callListKimiModels(client: ApiMachineClient, machineId: string, cwd: string): Promise<unknown> {
|
||||
const manager = (client as unknown as { rpcHandlerManager: { handleRequest: (req: { method: string; params: string }) => Promise<string> } }).rpcHandlerManager
|
||||
const raw = await manager.handleRequest({
|
||||
method: `${machineId}:listKimiModelsForCwd`,
|
||||
params: JSON.stringify({ cwd })
|
||||
})
|
||||
return JSON.parse(raw) as unknown
|
||||
}
|
||||
|
||||
async function callCursorChatStoreStatus(
|
||||
client: ApiMachineClient,
|
||||
machineId: string,
|
||||
@@ -479,6 +493,64 @@ describe('ApiMachineClient listGrokModelsForCwd handler', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('ApiMachineClient listKimiModelsForCwd handler', () => {
|
||||
let workspaceRoot: string
|
||||
|
||||
beforeEach(() => {
|
||||
ioMock.mockReset()
|
||||
listKimiModelsForCwdMock.mockReset()
|
||||
workspaceRoot = mkdtempSync(join(tmpdir(), 'hapi-kimi-machine-ws-'))
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
rmSync(workspaceRoot, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('rejects cwd outside workspace roots before running the Kimi model probe', async () => {
|
||||
const machine = makeMachine('kimi-machine-1')
|
||||
const client = new ApiMachineClient('cli-token', machine, [workspaceRoot])
|
||||
const outsideCwd = mkdtempSync(join(tmpdir(), 'hapi-kimi-outside-'))
|
||||
|
||||
try {
|
||||
expect(await callListKimiModels(client, machine.id, outsideCwd)).toEqual({
|
||||
success: false,
|
||||
error: 'Path is outside workspace roots'
|
||||
})
|
||||
expect(listKimiModelsForCwdMock).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
rmSync(outsideCwd, { recursive: true, force: true })
|
||||
client.shutdown()
|
||||
}
|
||||
})
|
||||
|
||||
it('forwards a resolved workspace cwd to the Kimi model probe', async () => {
|
||||
const machine = makeMachine('kimi-machine-2')
|
||||
const client = new ApiMachineClient('cli-token', machine, [workspaceRoot])
|
||||
listKimiModelsForCwdMock.mockResolvedValueOnce({
|
||||
success: true,
|
||||
availableModels: [
|
||||
{ modelId: 'GLM-5.3-flash', name: 'thehive / GLM-5.3-flash', provider: 'thehive' },
|
||||
{ modelId: 'hyper-glm-5.3-flash', name: 'charm-hyper / Hyper · GLM-5.3-Flash', provider: 'charm-hyper' }
|
||||
],
|
||||
currentModelId: 'GLM-5.3-flash'
|
||||
})
|
||||
|
||||
try {
|
||||
expect(await callListKimiModels(client, machine.id, workspaceRoot)).toEqual({
|
||||
success: true,
|
||||
availableModels: [
|
||||
{ modelId: 'GLM-5.3-flash', name: 'thehive / GLM-5.3-flash', provider: 'thehive' },
|
||||
{ modelId: 'hyper-glm-5.3-flash', name: 'charm-hyper / Hyper · GLM-5.3-Flash', provider: 'charm-hyper' }
|
||||
],
|
||||
currentModelId: 'GLM-5.3-flash'
|
||||
})
|
||||
expect(listKimiModelsForCwdMock).toHaveBeenCalledWith(realpathSync.native(workspaceRoot))
|
||||
} finally {
|
||||
client.shutdown()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('ApiMachineClient Codex transcript handlers', () => {
|
||||
const originalCodexHome = process.env.CODEX_HOME
|
||||
let workspaceRoot: string
|
||||
@@ -674,6 +746,35 @@ describe('ApiMachineClient SpawnHappySession handler', () => {
|
||||
client.shutdown()
|
||||
}
|
||||
})
|
||||
|
||||
it('returns childStarted:false on outside_workspace_roots so hub deletes the stub', async () => {
|
||||
const machine = makeMachine('machine-spawn-outside')
|
||||
const client = new ApiMachineClient('cli-token', machine, [workspaceRoot])
|
||||
const spawnSession = vi.fn()
|
||||
|
||||
client.setRPCHandlers({
|
||||
spawnSession,
|
||||
stopSession: vi.fn(async () => 'stopped' as const),
|
||||
requestShutdown: vi.fn()
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await callSpawnHappySession(client, machine.id, {
|
||||
directory: '/tmp/definitely-outside-roots',
|
||||
agent: 'claude',
|
||||
})
|
||||
|
||||
expect(result).toEqual({
|
||||
type: 'error',
|
||||
errorMessage: "Directory is outside this machine's workspace roots",
|
||||
code: 'outside_workspace_roots',
|
||||
childStarted: false,
|
||||
})
|
||||
expect(spawnSession).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
client.shutdown()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('ApiMachineClient keepAlive lifecycle', () => {
|
||||
|
||||
Reference in New Issue
Block a user