@siftd/connect-agent 0.2.42 → 0.2.44
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/dist/core/hub.js +3 -2
- package/dist/orchestrator.d.ts +5 -0
- package/dist/orchestrator.js +51 -3
- package/dist/tools/calendar.js +21 -14
- package/dist/tools/worker.d.ts +1 -1
- package/package.json +1 -1
package/dist/core/hub.js
CHANGED
|
@@ -8,10 +8,11 @@ import { existsSync, readFileSync, writeFileSync, appendFileSync, mkdirSync, chm
|
|
|
8
8
|
import { execSync } from 'child_process';
|
|
9
9
|
import { join } from 'path';
|
|
10
10
|
import { homedir } from 'os';
|
|
11
|
-
const
|
|
11
|
+
const hubHome = process.env.LIA_WORKSPACE || homedir();
|
|
12
|
+
const HUB_DIR = join(hubHome, '.connect-hub');
|
|
12
13
|
const PROJECTS_DIR = join(HUB_DIR, 'projects');
|
|
13
14
|
// Lia-Hub: The orchestrator's working directory
|
|
14
|
-
const LIA_HUB_DIR = join(
|
|
15
|
+
const LIA_HUB_DIR = join(hubHome, 'Lia-Hub');
|
|
15
16
|
const NOTEBOOK_A_DIR = join(LIA_HUB_DIR, 'notebook-a');
|
|
16
17
|
const DRAFTS_DIR = join(NOTEBOOK_A_DIR, 'drafts');
|
|
17
18
|
const SHARED_DIR = join(LIA_HUB_DIR, 'shared');
|
package/dist/orchestrator.d.ts
CHANGED
|
@@ -188,6 +188,11 @@ export declare class MasterOrchestrator {
|
|
|
188
188
|
*/
|
|
189
189
|
private handleSlashCommand;
|
|
190
190
|
private extractAttachmentContext;
|
|
191
|
+
private stripTodoSnapshot;
|
|
192
|
+
private hasTodoMutation;
|
|
193
|
+
private hasCalendarMutation;
|
|
194
|
+
private hasExplicitDate;
|
|
195
|
+
private getToolChoice;
|
|
191
196
|
private withAttachments;
|
|
192
197
|
/**
|
|
193
198
|
* Check if verbose mode is enabled
|
package/dist/orchestrator.js
CHANGED
|
@@ -153,6 +153,10 @@ CALENDAR + TODO (Lia-managed data):
|
|
|
153
153
|
- When users add, edit, or delete events, use calendar_upsert_events
|
|
154
154
|
- When users add, edit, or delete tasks, use todo_upsert_items
|
|
155
155
|
- Keep these files hidden; refer users to /cal or /todo in responses
|
|
156
|
+
- If the user provides subtasks or a bullet list under one task, store them as subtasks (unless they explicitly ask to split into multiple items)
|
|
157
|
+
- Preserve explicit due dates, times, and priorities exactly as given (YYYY-MM-DD, HH:MM)
|
|
158
|
+
- If the user explicitly requests /todo or /cal changes, you MUST call the corresponding tool in the same response
|
|
159
|
+
- If the user says "Add to /todo:" followed by a list of deadlines/details, create ONE todo with notes unless they explicitly ask to split/break down
|
|
156
160
|
- Schemas:
|
|
157
161
|
- calendar.json: { "version": 1, "calendars": [...], "events": [...] }
|
|
158
162
|
- todos.json: { "version": 1, "items": [...] }
|
|
@@ -661,6 +665,42 @@ export class MasterOrchestrator {
|
|
|
661
665
|
return null;
|
|
662
666
|
return lines.join('\n');
|
|
663
667
|
}
|
|
668
|
+
stripTodoSnapshot(message) {
|
|
669
|
+
const marker = '\n\nTODO SNAPSHOT';
|
|
670
|
+
const index = message.indexOf(marker);
|
|
671
|
+
return index === -1 ? message : message.slice(0, index);
|
|
672
|
+
}
|
|
673
|
+
hasTodoMutation(message) {
|
|
674
|
+
const lower = this.stripTodoSnapshot(message).toLowerCase();
|
|
675
|
+
const target = /(^|\s)\/todo\b|\btodo\b|\btasks?\b/.test(lower);
|
|
676
|
+
const action = /\b(add|create|update|edit|remove|delete|mark|complete|finish|done|toggle|split|break(?:\s|-)?down|parse|subtasks?)\b/.test(lower);
|
|
677
|
+
const query = /\b(what|show|list|open|view|see)\b/.test(lower);
|
|
678
|
+
return target && action && !query;
|
|
679
|
+
}
|
|
680
|
+
hasCalendarMutation(message) {
|
|
681
|
+
const lower = this.stripTodoSnapshot(message).toLowerCase();
|
|
682
|
+
const target = /(^|\s)\/cal\b|\/calendar\b|\bcalendar\b/.test(lower);
|
|
683
|
+
const action = /\b(add|create|schedule|book|move|reschedule|update|change|cancel|delete|remove)\b/.test(lower);
|
|
684
|
+
const query = /\b(what|show|list|open|view|see)\b/.test(lower);
|
|
685
|
+
return target && action && !query;
|
|
686
|
+
}
|
|
687
|
+
hasExplicitDate(message) {
|
|
688
|
+
return /\b\d{4}-\d{2}-\d{2}\b/.test(this.stripTodoSnapshot(message));
|
|
689
|
+
}
|
|
690
|
+
getToolChoice(messages) {
|
|
691
|
+
const last = messages[messages.length - 1];
|
|
692
|
+
if (!last || last.role !== 'user' || typeof last.content !== 'string')
|
|
693
|
+
return undefined;
|
|
694
|
+
const wantsTodo = this.hasTodoMutation(last.content);
|
|
695
|
+
const wantsCal = this.hasCalendarMutation(last.content);
|
|
696
|
+
if (wantsTodo && !wantsCal) {
|
|
697
|
+
return { type: 'tool', name: 'todo_upsert_items' };
|
|
698
|
+
}
|
|
699
|
+
if (wantsCal && !wantsTodo && this.hasExplicitDate(last.content)) {
|
|
700
|
+
return { type: 'tool', name: 'calendar_upsert_events' };
|
|
701
|
+
}
|
|
702
|
+
return undefined;
|
|
703
|
+
}
|
|
664
704
|
withAttachments(task, context) {
|
|
665
705
|
if (!this.attachmentContext)
|
|
666
706
|
return { task, context };
|
|
@@ -1144,6 +1184,7 @@ ${hubContextStr}
|
|
|
1144
1184
|
const requestTimeoutMs = 60000;
|
|
1145
1185
|
while (iterations < maxIterations) {
|
|
1146
1186
|
iterations++;
|
|
1187
|
+
const toolChoice = this.getToolChoice(currentMessages);
|
|
1147
1188
|
const requestStart = Date.now();
|
|
1148
1189
|
console.log(`[ORCHESTRATOR] Anthropic request ${iterations}/${maxIterations} (model: ${this.model})`);
|
|
1149
1190
|
const response = await Promise.race([
|
|
@@ -1152,7 +1193,8 @@ ${hubContextStr}
|
|
|
1152
1193
|
max_tokens: this.maxTokens,
|
|
1153
1194
|
system,
|
|
1154
1195
|
tools,
|
|
1155
|
-
messages: currentMessages
|
|
1196
|
+
messages: currentMessages,
|
|
1197
|
+
...(toolChoice ? { tool_choice: toolChoice } : {})
|
|
1156
1198
|
}),
|
|
1157
1199
|
new Promise((_, reject) => {
|
|
1158
1200
|
setTimeout(() => {
|
|
@@ -1209,7 +1251,9 @@ For ANY file creation, editing, or system modification, use delegate_to_worker i
|
|
|
1209
1251
|
name: 'calendar_upsert_events',
|
|
1210
1252
|
description: `Create or update calendar events for /cal.
|
|
1211
1253
|
|
|
1212
|
-
Writes ONLY to ~/Lia-Hub/shared/outputs/.lia/calendar.json (creates the directory/file if missing)
|
|
1254
|
+
Writes ONLY to ~/Lia-Hub/shared/outputs/.lia/calendar.json (creates the directory/file if missing).
|
|
1255
|
+
|
|
1256
|
+
Preserve explicit dates/times exactly as the user provides them (YYYY-MM-DD, HH:MM).`,
|
|
1213
1257
|
input_schema: {
|
|
1214
1258
|
type: 'object',
|
|
1215
1259
|
properties: {
|
|
@@ -1261,7 +1305,11 @@ BREAKING DOWN A TODO:
|
|
|
1261
1305
|
When asked to split/parse a todo into multiple items:
|
|
1262
1306
|
1. Include the original item with done: true (marks it complete)
|
|
1263
1307
|
2. Add the new parsed items with unique ids
|
|
1264
|
-
3. Extract deadlines, priorities, and notes from the original content
|
|
1308
|
+
3. Extract deadlines, priorities, and notes from the original content
|
|
1309
|
+
|
|
1310
|
+
SUBTASKS:
|
|
1311
|
+
If the user provides a subtask list under one todo, put them in "subtasks" on that item
|
|
1312
|
+
and preserve explicit due dates and priority from the user.`,
|
|
1265
1313
|
input_schema: {
|
|
1266
1314
|
type: 'object',
|
|
1267
1315
|
properties: {
|
package/dist/tools/calendar.js
CHANGED
|
@@ -188,32 +188,39 @@ export class CalendarTools {
|
|
|
188
188
|
}
|
|
189
189
|
normalizeTodoItems(inputItems, existingItems) {
|
|
190
190
|
const existingById = new Map(existingItems.map((item) => [item.id, item]));
|
|
191
|
-
const
|
|
191
|
+
const titleToId = new Map(existingItems.map((item) => [item.title.trim().toLowerCase(), item.id]));
|
|
192
192
|
for (const rawItem of inputItems) {
|
|
193
193
|
if (!rawItem || typeof rawItem.title !== 'string' || !rawItem.title.trim())
|
|
194
194
|
continue;
|
|
195
195
|
const title = rawItem.title.trim();
|
|
196
|
-
const
|
|
196
|
+
const titleKey = title.toLowerCase();
|
|
197
|
+
const existingId = titleToId.get(titleKey);
|
|
198
|
+
const requestedId = typeof rawItem.id === 'string' && rawItem.id.trim()
|
|
197
199
|
? rawItem.id.trim()
|
|
198
|
-
:
|
|
199
|
-
const
|
|
200
|
-
const
|
|
201
|
-
const
|
|
200
|
+
: undefined;
|
|
201
|
+
const fallbackId = stableId('todo', [title, rawItem.due]);
|
|
202
|
+
const id = requestedId || existingId || fallbackId;
|
|
203
|
+
const previous = existingById.get(id) || (existingId ? existingById.get(existingId) : undefined);
|
|
204
|
+
const resolvedId = previous?.id || id;
|
|
205
|
+
const priority = rawItem.priority === 'low' || rawItem.priority === 'high'
|
|
206
|
+
? rawItem.priority
|
|
207
|
+
: previous?.priority || 'medium';
|
|
208
|
+
const due = typeof rawItem.due === 'string' && rawItem.due.trim() ? rawItem.due.trim() : previous?.due;
|
|
209
|
+
const notes = typeof rawItem.notes === 'string' && rawItem.notes.trim() ? rawItem.notes.trim() : previous?.notes;
|
|
202
210
|
const incomingSubtasks = Array.isArray(rawItem.subtasks)
|
|
203
211
|
? rawItem.subtasks
|
|
204
212
|
.filter((subtask) => subtask && typeof subtask.title === 'string' && subtask.title.trim())
|
|
205
213
|
.map((subtask, index) => ({
|
|
206
214
|
id: typeof subtask.id === 'string' && subtask.id.trim()
|
|
207
215
|
? subtask.id.trim()
|
|
208
|
-
: stableId('subtask', [
|
|
216
|
+
: stableId('subtask', [resolvedId, subtask.title.trim(), String(index)]),
|
|
209
217
|
title: subtask.title.trim(),
|
|
210
218
|
done: Boolean(subtask.done),
|
|
211
219
|
notes: typeof subtask.notes === 'string' && subtask.notes.trim() ? subtask.notes.trim() : undefined,
|
|
212
220
|
}))
|
|
213
221
|
: undefined;
|
|
214
|
-
const previous = existingById.get(id);
|
|
215
222
|
const subtasks = incomingSubtasks || previous?.subtasks;
|
|
216
|
-
let done =
|
|
223
|
+
let done = typeof rawItem.done === 'boolean' ? rawItem.done : (previous?.done ?? false);
|
|
217
224
|
if (incomingSubtasks && incomingSubtasks.length > 0) {
|
|
218
225
|
done = incomingSubtasks.every((subtask) => subtask.done);
|
|
219
226
|
}
|
|
@@ -222,11 +229,11 @@ export class CalendarTools {
|
|
|
222
229
|
for (const subtask of previous.subtasks)
|
|
223
230
|
subtask.done = true;
|
|
224
231
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
232
|
+
if (previous && previous.id !== resolvedId) {
|
|
233
|
+
existingById.delete(previous.id);
|
|
234
|
+
}
|
|
235
|
+
existingById.set(resolvedId, { id: resolvedId, title, done, due, priority, notes, subtasks });
|
|
236
|
+
titleToId.set(titleKey, resolvedId);
|
|
230
237
|
}
|
|
231
238
|
return Array.from(existingById.values());
|
|
232
239
|
}
|
package/dist/tools/worker.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Worker Tools
|
|
3
3
|
* Tools for spawning and managing Claude Code workers
|
|
4
4
|
*/
|
|
5
|
-
import { GalleryCallback, GalleryWorker, WorkerLogCallback } from '../workers/manager.js';
|
|
5
|
+
import type { GalleryCallback, GalleryWorker, WorkerLogCallback } from '../workers/manager.js';
|
|
6
6
|
import type { ToolResult } from './bash.js';
|
|
7
7
|
export { GalleryCallback, GalleryWorker };
|
|
8
8
|
export type { WorkerLogCallback };
|