wip: first run of implementation

This commit is contained in:
2026-02-25 20:29:01 +01:00
parent 2e203fa3a9
commit 20ea499a6f
40 changed files with 2170 additions and 22 deletions

View File

@@ -0,0 +1,39 @@
import { describe, expect, it } from 'vitest';
import {
WorkflowCheckpointStore,
type WorkflowCheckpointSettingsAdapter,
} from '../../../../src/main/agentic/workflow/checkpointStore';
class InMemorySettingsAdapter implements WorkflowCheckpointSettingsAdapter {
private readonly store = new Map<string, string>();
async getSetting(key: string): Promise<string | null> {
return this.store.get(key) ?? null;
}
async setSetting(key: string, value: string): Promise<void> {
this.store.set(key, value);
}
}
describe('WorkflowCheckpointStore', () => {
it('persists and reloads workflow checkpoints by conversation id', async () => {
const adapter = new InMemorySettingsAdapter();
const store = new WorkflowCheckpointStore(adapter);
await store.save({
conversationId: 'conversation-1',
state: 'awaiting_input',
pendingFields: ['date'],
lastTraceId: 'trace-1',
updatedAt: new Date('2026-02-25T10:00:00.000Z').toISOString(),
});
const loaded = await store.load('conversation-1');
expect(loaded).not.toBeNull();
expect(loaded?.state).toBe('awaiting_input');
expect(loaded?.pendingFields).toEqual(['date']);
expect(loaded?.lastTraceId).toBe('trace-1');
});
});

View File

@@ -0,0 +1,38 @@
import { describe, expect, it } from 'vitest';
import { AgentTurnStateMachine } from '../../../../src/main/agentic/workflow/turnStateMachine';
describe('AgentTurnStateMachine', () => {
it('transitions to awaiting_input when envelope requests required input', () => {
const stateMachine = new AgentTurnStateMachine();
const next = stateMachine.transition({
previousState: 'planning',
envelope: {
intent: 'ask_input',
needsInput: {
required: true,
fields: [{ key: 'date', label: 'Date', inputType: 'date' }],
},
},
});
expect(next).toBe('awaiting_input');
});
it('transitions to completed when summarize intent has no required input', () => {
const stateMachine = new AgentTurnStateMachine();
const next = stateMachine.transition({
previousState: 'observing',
envelope: {
intent: 'summarize',
needsInput: {
required: false,
fields: [],
},
},
});
expect(next).toBe('completed');
});
});