@nt-ai-lab/deterministic-agent-workflow-opencode 0.1.5 → 0.2.1
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.
|
@@ -4,10 +4,9 @@ const textPartSchema = z.object({
|
|
|
4
4
|
type: z.literal('text'),
|
|
5
5
|
text: z.string()
|
|
6
6
|
});
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
data: z.string(),
|
|
7
|
+
const partRowSchema = z.object({
|
|
8
|
+
message_id: z.string(),
|
|
9
|
+
part_data: z.string(),
|
|
11
10
|
});
|
|
12
11
|
/** @riviere-role external-client-model */
|
|
13
12
|
export class OpenCodeTranscriptReader {
|
|
@@ -30,34 +29,42 @@ export class OpenCodeTranscriptReader {
|
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
queryMessages(db) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
const textByMessage = new Map();
|
|
33
|
+
const rows = db
|
|
34
|
+
.prepare(`SELECT m.id AS message_id, p.data AS part_data
|
|
35
|
+
FROM message m
|
|
36
|
+
JOIN part p ON p.message_id = m.id
|
|
37
|
+
WHERE m.session_id = ? AND json_extract(m.data, '$.role') = 'assistant'
|
|
38
|
+
ORDER BY m.time_created ASC, p.time_created ASC`)
|
|
39
|
+
.all(this.sessionId);
|
|
40
|
+
for (const row of rows) {
|
|
41
|
+
const parsedRow = partRowSchema.safeParse(row);
|
|
42
|
+
if (!parsedRow.success) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const textContent = this.parseTextPart(parsedRow.data.part_data);
|
|
46
|
+
if (textContent === undefined) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const existingParts = textByMessage.get(parsedRow.data.message_id) ?? [];
|
|
50
|
+
existingParts.push(textContent);
|
|
51
|
+
textByMessage.set(parsedRow.data.message_id, existingParts);
|
|
52
|
+
}
|
|
53
|
+
return [...textByMessage.entries()].map(([id, parts]) => ({
|
|
54
|
+
id,
|
|
55
|
+
textContent: parts.join('\n'),
|
|
56
|
+
}));
|
|
39
57
|
}
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
parseTextPart(partData) {
|
|
59
|
+
const parsedData = JSON.parse(partData);
|
|
60
|
+
const textPart = textPartSchema.safeParse(parsedData);
|
|
61
|
+
if (!textPart.success) {
|
|
62
|
+
return undefined;
|
|
44
63
|
}
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return [];
|
|
64
|
+
const textContent = textPart.data.text.trim();
|
|
65
|
+
if (textContent.length === 0) {
|
|
66
|
+
return undefined;
|
|
49
67
|
}
|
|
50
|
-
return
|
|
51
|
-
id: rowResult.data.id,
|
|
52
|
-
textContent: extractFirstText(dataResult.data.parts),
|
|
53
|
-
}];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function extractFirstText(parts) {
|
|
57
|
-
for (const part of parts) {
|
|
58
|
-
const result = textPartSchema.safeParse(part);
|
|
59
|
-
if (result.success)
|
|
60
|
-
return result.data.text;
|
|
68
|
+
return textContent;
|
|
61
69
|
}
|
|
62
|
-
return undefined;
|
|
63
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nt-ai-lab/deterministic-agent-workflow-opencode",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@opencode-ai/plugin": "^1.4.3",
|
|
15
15
|
"zod": "^3.25.76",
|
|
16
|
-
"@nt-ai-lab/deterministic-agent-workflow-cli": "0.1
|
|
17
|
-
"@nt-ai-lab/deterministic-agent-workflow-
|
|
18
|
-
"@nt-ai-lab/deterministic-agent-workflow-
|
|
16
|
+
"@nt-ai-lab/deterministic-agent-workflow-cli": "0.2.1",
|
|
17
|
+
"@nt-ai-lab/deterministic-agent-workflow-engine": "0.2.1",
|
|
18
|
+
"@nt-ai-lab/deterministic-agent-workflow-event-store": "0.2.1"
|
|
19
19
|
},
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public"
|