@siftd/connect-agent 0.2.41 → 0.2.43

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 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 HUB_DIR = join(homedir(), '.connect-hub');
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(homedir(), 'Lia-Hub');
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');
@@ -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
@@ -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": [...] }
@@ -221,7 +225,7 @@ export class MasterOrchestrator {
221
225
  todoUpdateCallback;
222
226
  constructor(options) {
223
227
  this.client = new Anthropic({ apiKey: options.apiKey });
224
- this.model = options.model || process.env.ANTHROPIC_MODEL || 'claude-sonnet-4-20250514';
228
+ this.model = options.model || process.env.ANTHROPIC_MODEL || 'claude-opus-4-5-20251101';
225
229
  this.maxTokens = options.maxTokens || 4096;
226
230
  this.userId = options.userId;
227
231
  this.orgId = options.orgId;
@@ -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: {
@@ -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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siftd/connect-agent",
3
- "version": "0.2.41",
3
+ "version": "0.2.43",
4
4
  "description": "Master orchestrator agent - control Claude Code remotely via web",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",