paseo-dsh 0.2.16 → 0.2.18

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.
@@ -47,6 +47,11 @@ function stringField(source: Record<string, unknown>, key: string): string | und
47
47
  return typeof value === "string" && value !== "" ? value : undefined;
48
48
  }
49
49
 
50
+ /** DSH returns `started subagent <childId>` when a subagent starts. */
51
+ function childSessionIdOf(output: string | undefined): string | undefined {
52
+ return output?.match(/^\s*started subagent ([A-Za-z0-9][A-Za-z0-9_-]*)\s*$/)?.[1];
53
+ }
54
+
50
55
  /** Map one DSH tool call onto the richest Paseo tool detail available. */
51
56
  function toolDetail(name: string, input: Record<string, unknown>, output?: string): ProviderToolCallDetail {
52
57
  const filePath = stringField(input, "file_path") ?? stringField(input, "filePath");
@@ -112,14 +117,18 @@ function toolDetail(name: string, input: Record<string, unknown>, output?: strin
112
117
  // emits the same item next to the approval buttons. The plan has to be
113
118
  // visible *before* the choice, so this is the copy that carries it.
114
119
  return { type: "plan", text: stringField(input, "plan") ?? "" };
115
- case "subagent":
120
+ case "subagent": {
121
+ const childSessionId = childSessionIdOf(output);
116
122
  return {
117
123
  type: "sub_agent",
124
+ subAgentType: "Sub-agent",
118
125
  ...(stringField(input, "description") === undefined
119
126
  ? {}
120
127
  : { description: stringField(input, "description") as string }),
128
+ ...(childSessionId === undefined ? {} : { childSessionId }),
121
129
  log: output ?? "",
122
130
  };
131
+ }
123
132
  default:
124
133
  return {
125
134
  type: "unknown",
@@ -129,17 +138,37 @@ function toolDetail(name: string, input: Record<string, unknown>, output?: strin
129
138
  }
130
139
  }
131
140
 
132
- /** Extract `todo_write` items into Paseo's native todo row. */
133
- function todoItems(input: Record<string, unknown>): Array<{ text: string; completed: boolean }> | null {
141
+ type TodoStatus = "pending" | "in_progress" | "completed";
142
+
143
+ /**
144
+ * Extract `todo_write` items into Paseo's native todo row.
145
+ *
146
+ * Paseo decides between pending, in progress and completed from `status`; the
147
+ * older `completed` boolean alone makes every unfinished task look pending.
148
+ */
149
+ function todoItems(
150
+ input: Record<string, unknown>,
151
+ ): Array<{ text: string; completed: boolean; status: TodoStatus; activeForm?: string }> | null {
134
152
  const raw = input.todos;
135
153
  if (!Array.isArray(raw)) return null;
136
154
  const items = raw
137
155
  .filter(isRecord)
138
- .map((todo) => ({
139
- text:
140
- stringField(todo, "content") ?? stringField(todo, "text") ?? stringField(todo, "activeForm") ?? "",
141
- completed: todo.status === "completed",
142
- }))
156
+ .map((todo) => {
157
+ const status: TodoStatus =
158
+ todo.status === "completed"
159
+ ? "completed"
160
+ : todo.status === "in_progress"
161
+ ? "in_progress"
162
+ : "pending";
163
+ const activeForm = stringField(todo, "activeForm");
164
+ return {
165
+ text:
166
+ stringField(todo, "content") ?? stringField(todo, "text") ?? activeForm ?? "",
167
+ completed: status === "completed",
168
+ status,
169
+ ...(activeForm === undefined ? {} : { activeForm }),
170
+ };
171
+ })
143
172
  .filter((todo) => todo.text !== "");
144
173
  return items.length === 0 ? null : items;
145
174
  }