@aliyunrds/ctxdb 1.0.9-beta.0 → 1.0.9-beta.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.
@@ -64,6 +64,11 @@ function readTranscript(path) {
64
64
  if (!obj || typeof obj !== "object" || Array.isArray(obj)) continue;
65
65
  const o = obj;
66
66
  const rawType = typeof o.type === "string" ? o.type : "";
67
+ if (rawType === "message" && typeof o.role === "string" || rawType === "function_call") {
68
+ const row = normalizeWorkBuddyRow(o);
69
+ if (row) out.push(row);
70
+ continue;
71
+ }
67
72
  if (rawType === CODEX_RESPONSE_ITEM) {
68
73
  const payload = o.payload;
69
74
  if (payload && typeof payload === "object" && !Array.isArray(payload)) {
@@ -79,6 +84,55 @@ function readTranscript(path) {
79
84
  }
80
85
  return out;
81
86
  }
87
+ function normalizeWorkBuddyRow(row) {
88
+ if (row.isMeta || row.isSidechain || row.is_synthetic || row._pre_verify_synthetic || row._verify_on_stop_synthetic) {
89
+ return null;
90
+ }
91
+ if (row.type === "function_call") {
92
+ if (typeof row.name !== "string") return null;
93
+ const args = row.arguments && typeof row.arguments === "object" && !Array.isArray(row.arguments) ? row.arguments : parseArgs(row.arguments);
94
+ const command = typeof args.command === "string" ? args.command : typeof args.cmd === "string" ? args.cmd : void 0;
95
+ return {
96
+ ...row,
97
+ type: "assistant",
98
+ message: {
99
+ role: "assistant",
100
+ content: [{
101
+ type: "tool_use",
102
+ // WorkBuddy shell tools may use engine-specific names. Reuse
103
+ // the shared detector's shell shape when command args exist;
104
+ // preserve direct tool names such as kb_upload_text and Skill.
105
+ name: command === void 0 ? row.name : "bash",
106
+ input: command === void 0 ? args : { ...args, command }
107
+ }]
108
+ }
109
+ };
110
+ }
111
+ const role = row.role;
112
+ if (role !== "user" && role !== "assistant") return null;
113
+ const content = row.content;
114
+ let text = "";
115
+ if (typeof content === "string") text = content;
116
+ else if (Array.isArray(content)) {
117
+ text = content.flatMap((block) => {
118
+ if (!block || typeof block !== "object") return [];
119
+ const b = block;
120
+ if (b.synthetic || b.ignored) return [];
121
+ if (b.type !== "text" && b.type !== (role === "user" ? "input_text" : "output_text")) return [];
122
+ return typeof b.text === "string" ? [b.text] : [];
123
+ }).join("\n");
124
+ }
125
+ if (role === "user") {
126
+ if (text.trimStart().startsWith("Stop hook feedback:")) return null;
127
+ if (text.includes("<user_query>")) {
128
+ text = /<user_query>([\s\S]*)<\/user_query>/.exec(text)?.[1] ?? "";
129
+ }
130
+ if (text.trimStart().startsWith("Stop hook feedback:")) return null;
131
+ }
132
+ text = text.trim();
133
+ if (!text) return null;
134
+ return { ...row, type: role, message: { role, content: [{ type: "text", text }] } };
135
+ }
82
136
  function toKbDetectionMessages(rows) {
83
137
  const out = [];
84
138
  for (const row of rows) {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  captureParsedMessages
4
- } from "../chunk-N5JGS5EC.js";
4
+ } from "../chunk-2ROMQSPA.js";
5
5
  import "../chunk-7TPYIT63.js";
6
6
  import {
7
7
  HttpClient,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  captureTurn
4
- } from "../chunk-N5JGS5EC.js";
4
+ } from "../chunk-2ROMQSPA.js";
5
5
  import "../chunk-7TPYIT63.js";
6
6
  import {
7
7
  HttpClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliyunrds/ctxdb",
3
- "version": "1.0.9-beta.0",
3
+ "version": "1.0.9-beta.1",
4
4
  "type": "module",
5
5
  "description": "Unified access layer for RDS ContextDatabase: `ctxdb` CLI (memory + KB ops), one-shot multi-agent installer, per-agent config, hooks/plugins, and SKILL.md.",
6
6
  "license": "Apache-2.0",