Replace OpenCode with SmartAgent runtime
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
import * as fs from 'node:fs/promises';
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
import { GitZoneAgentRuntime, type IAgentEventEnvelope, type IAgentProjectContext } from '../applications/electron-shell/ts/agent-runtime.js';
|
||||
|
||||
const createProjectContext = (instanceId: string): IAgentProjectContext => ({
|
||||
instanceId,
|
||||
title: 'Persisted Project',
|
||||
path: '/srv/work/persisted-project',
|
||||
runtimeRoot: '/tmp/gitzone-ide-runtime-test',
|
||||
target: {
|
||||
id: 'dev-box',
|
||||
hostAlias: 'dev-box',
|
||||
hostName: 'dev.example.com',
|
||||
user: 'deploy',
|
||||
port: 2222,
|
||||
},
|
||||
batchMode: true,
|
||||
});
|
||||
|
||||
tap.test('should persist agent sessions by remote project context', async () => {
|
||||
const persistenceRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'gitzone-agent-runtime-'));
|
||||
try {
|
||||
const events: IAgentEventEnvelope[] = [];
|
||||
const firstRuntime = new GitZoneAgentRuntime(
|
||||
(payload) => events.push(payload),
|
||||
(instanceId) => createProjectContext(instanceId),
|
||||
persistenceRoot,
|
||||
);
|
||||
const createdSession = await firstRuntime.createSession({
|
||||
instanceId: 'first-instance',
|
||||
title: 'Persisted Chat',
|
||||
});
|
||||
firstRuntime.dispose();
|
||||
|
||||
const secondRuntime = new GitZoneAgentRuntime(
|
||||
() => undefined,
|
||||
(instanceId) => createProjectContext(instanceId),
|
||||
persistenceRoot,
|
||||
);
|
||||
const sessions = await secondRuntime.listSessions({ instanceId: 'second-instance' });
|
||||
secondRuntime.dispose();
|
||||
|
||||
expect(createdSession.title).toEqual('Persisted Chat');
|
||||
expect(events.some((payload) => payload.event.type === 'session.created')).toEqual(true);
|
||||
expect(sessions).toHaveLength(1);
|
||||
expect(sessions[0]!.id).toEqual(createdSession.id);
|
||||
expect(sessions[0]!.title).toEqual('Persisted Chat');
|
||||
} finally {
|
||||
await fs.rm(persistenceRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user