ei-tui 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/handlers/human-matching.ts +13 -9
- package/src/core/orchestrators/human-extraction.ts +1 -0
- package/src/prompts/human/topic-update.ts +1 -1
- package/tui/src/commands/me.tsx +12 -6
- package/tui/src/util/yaml-context.ts +66 -0
- package/tui/src/util/yaml-human.ts +274 -0
- package/tui/src/util/yaml-persona.ts +479 -0
- package/tui/src/util/yaml-provider.ts +215 -0
- package/tui/src/util/yaml-queue.ts +81 -0
- package/tui/src/util/yaml-quotes.ts +46 -0
- package/tui/src/util/yaml-serializers.ts +9 -1510
- package/tui/src/util/yaml-settings.ts +223 -0
- package/tui/src/util/yaml-shared.ts +32 -0
- package/tui/src/util/yaml-toolkit.ts +55 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import YAML from "yaml";
|
|
2
|
+
import type { LLMRequest, LLMRequestState, LLMPriority, ProviderAccount } from "../../../src/core/types.js";
|
|
3
|
+
import { modelGuidToDisplay, displayToModelGuid } from "./yaml-shared.js";
|
|
4
|
+
|
|
5
|
+
interface EditableQueueItem {
|
|
6
|
+
id: string;
|
|
7
|
+
state: LLMRequestState;
|
|
8
|
+
created_at: string;
|
|
9
|
+
attempts: number;
|
|
10
|
+
last_attempt?: string;
|
|
11
|
+
retry_after?: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
priority?: LLMPriority;
|
|
14
|
+
next_step?: string;
|
|
15
|
+
model?: string;
|
|
16
|
+
data?: Record<string, unknown>;
|
|
17
|
+
_delete?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function queueItemsToYAML(items: LLMRequest[], accounts: ProviderAccount[]): string {
|
|
21
|
+
const data: EditableQueueItem[] = items.map(item => ({
|
|
22
|
+
id: item.id,
|
|
23
|
+
_delete: false,
|
|
24
|
+
state: item.state,
|
|
25
|
+
created_at: item.created_at,
|
|
26
|
+
attempts: item.attempts,
|
|
27
|
+
last_attempt: item.last_attempt,
|
|
28
|
+
retry_after: item.retry_after,
|
|
29
|
+
type: item.type,
|
|
30
|
+
priority: item.priority,
|
|
31
|
+
next_step: item.next_step,
|
|
32
|
+
model: item.model ? modelGuidToDisplay(item.model, accounts) : undefined,
|
|
33
|
+
data: item.data,
|
|
34
|
+
}));
|
|
35
|
+
return YAML.stringify(data, { lineWidth: 0 });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface QueueItemUpdate {
|
|
39
|
+
id: string;
|
|
40
|
+
state: LLMRequestState;
|
|
41
|
+
attempts: number;
|
|
42
|
+
model?: string;
|
|
43
|
+
priority?: LLMPriority;
|
|
44
|
+
data?: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface QueueItemsYAMLResult {
|
|
48
|
+
updates: QueueItemUpdate[];
|
|
49
|
+
deletedIds: string[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function queueItemsFromYAML(yamlContent: string, accounts: ProviderAccount[]): QueueItemsYAMLResult {
|
|
53
|
+
const data = YAML.parse(yamlContent) as EditableQueueItem[];
|
|
54
|
+
if (!Array.isArray(data)) throw new Error("Expected a YAML array of queue items");
|
|
55
|
+
|
|
56
|
+
const deletedIds: string[] = [];
|
|
57
|
+
const updates: QueueItemUpdate[] = [];
|
|
58
|
+
|
|
59
|
+
for (const item of data) {
|
|
60
|
+
if (!item.id) throw new Error(`Queue item missing 'id' field`);
|
|
61
|
+
if (item._delete) {
|
|
62
|
+
deletedIds.push(item.id);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (!item.state) throw new Error(`Queue item ${item.id} missing 'state' field`);
|
|
66
|
+
const validStates: LLMRequestState[] = ["pending", "processing", "dlq"];
|
|
67
|
+
if (!validStates.includes(item.state)) {
|
|
68
|
+
throw new Error(`Queue item ${item.id} has invalid state '${item.state}'. Valid: ${validStates.join(", ")}`);
|
|
69
|
+
}
|
|
70
|
+
updates.push({
|
|
71
|
+
id: item.id,
|
|
72
|
+
state: item.state,
|
|
73
|
+
attempts: typeof item.attempts === "number" ? item.attempts : 0,
|
|
74
|
+
model: item.model ? displayToModelGuid(item.model, accounts) ?? item.model : undefined,
|
|
75
|
+
priority: item.priority,
|
|
76
|
+
data: item.data,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return { updates, deletedIds };
|
|
81
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import YAML from "yaml";
|
|
2
|
+
import type { Quote } from "../../../src/core/types.js";
|
|
3
|
+
|
|
4
|
+
interface EditableQuote extends Quote {
|
|
5
|
+
_delete?: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface EditableQuoteData {
|
|
9
|
+
quotes: EditableQuote[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function quotesToYAML(quotes: Quote[]): string {
|
|
13
|
+
const data: EditableQuoteData = {
|
|
14
|
+
quotes: quotes.map(q => ({
|
|
15
|
+
...q,
|
|
16
|
+
_delete: false,
|
|
17
|
+
})),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return YAML.stringify(data, {
|
|
21
|
+
lineWidth: 0,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface QuotesYAMLResult {
|
|
26
|
+
quotes: Quote[];
|
|
27
|
+
deletedQuoteIds: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function quotesFromYAML(yamlContent: string): QuotesYAMLResult {
|
|
31
|
+
const data = YAML.parse(yamlContent) as EditableQuoteData;
|
|
32
|
+
|
|
33
|
+
const deletedQuoteIds: string[] = [];
|
|
34
|
+
const quotes: Quote[] = [];
|
|
35
|
+
|
|
36
|
+
for (const q of data.quotes ?? []) {
|
|
37
|
+
if (q._delete) {
|
|
38
|
+
deletedQuoteIds.push(q.id);
|
|
39
|
+
} else {
|
|
40
|
+
const { _delete, ...quote } = q;
|
|
41
|
+
quotes.push(quote);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return { quotes, deletedQuoteIds };
|
|
46
|
+
}
|