@siftd/connect-agent 0.2.47 → 0.2.49
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/orchestrator.d.ts +2 -0
- package/dist/orchestrator.js +32 -4
- package/package.json +1 -1
package/dist/orchestrator.d.ts
CHANGED
|
@@ -194,6 +194,7 @@ export declare class MasterOrchestrator {
|
|
|
194
194
|
private stripTodoSnapshot;
|
|
195
195
|
private hasTodoMutation;
|
|
196
196
|
private hasCalendarMutation;
|
|
197
|
+
private hasFileMutation;
|
|
197
198
|
private getUserTagHint;
|
|
198
199
|
private getBreakdownTarget;
|
|
199
200
|
private ensureBreakdownOriginalDone;
|
|
@@ -205,6 +206,7 @@ export declare class MasterOrchestrator {
|
|
|
205
206
|
private updateFileScope;
|
|
206
207
|
private getTeamFilesDir;
|
|
207
208
|
private getFileScopeOverrides;
|
|
209
|
+
private rewriteFilesAlias;
|
|
208
210
|
private getFileScopeSystemNote;
|
|
209
211
|
/**
|
|
210
212
|
* Check if verbose mode is enabled
|
package/dist/orchestrator.js
CHANGED
|
@@ -19,7 +19,7 @@ import { WorkerTools } from './tools/worker.js';
|
|
|
19
19
|
import { CalendarTools } from './tools/calendar.js';
|
|
20
20
|
import { SharedState } from './workers/shared-state.js';
|
|
21
21
|
import { getKnowledgeForPrompt } from './genesis/index.js';
|
|
22
|
-
import { loadHubContext, formatHubContext, logAction, logWorker } from './core/hub.js';
|
|
22
|
+
import { loadHubContext, formatHubContext, logAction, logWorker, getSharedOutputPath } from './core/hub.js';
|
|
23
23
|
import { buildWorkerPrompt } from './prompts/worker-system.js';
|
|
24
24
|
import { LiaTaskQueue } from './core/task-queue.js';
|
|
25
25
|
/**
|
|
@@ -701,6 +701,13 @@ export class MasterOrchestrator {
|
|
|
701
701
|
const query = /\b(what|show|list|open|view|see)\b/.test(lower);
|
|
702
702
|
return target && action && !query;
|
|
703
703
|
}
|
|
704
|
+
hasFileMutation(message) {
|
|
705
|
+
const lower = this.stripTodoSnapshot(message).toLowerCase();
|
|
706
|
+
const target = /(^|\s)\/files\b|\bfiles?\b/.test(lower);
|
|
707
|
+
const action = /\b(create|make|write|save|generate|export|upload|attach|produce|edit|update|modify|delete|remove)\b/.test(lower);
|
|
708
|
+
const query = /\b(what|show|list|open|view|see|browse|find)\b/.test(lower);
|
|
709
|
+
return target && action && !query;
|
|
710
|
+
}
|
|
704
711
|
getUserTagHint(message) {
|
|
705
712
|
if (!message)
|
|
706
713
|
return null;
|
|
@@ -768,12 +775,16 @@ export class MasterOrchestrator {
|
|
|
768
775
|
return undefined;
|
|
769
776
|
const wantsTodo = this.hasTodoMutation(last.content);
|
|
770
777
|
const wantsCal = this.hasCalendarMutation(last.content);
|
|
778
|
+
const wantsFiles = this.hasFileMutation(last.content);
|
|
771
779
|
if (wantsTodo && !wantsCal) {
|
|
772
780
|
return { type: 'tool', name: 'todo_upsert_items' };
|
|
773
781
|
}
|
|
774
782
|
if (wantsCal && !wantsTodo) {
|
|
775
783
|
return { type: 'tool', name: 'calendar_upsert_events' };
|
|
776
784
|
}
|
|
785
|
+
if (wantsFiles) {
|
|
786
|
+
return { type: 'tool', name: 'delegate_to_worker' };
|
|
787
|
+
}
|
|
777
788
|
return undefined;
|
|
778
789
|
}
|
|
779
790
|
withAttachments(task, context) {
|
|
@@ -828,6 +839,16 @@ export class MasterOrchestrator {
|
|
|
828
839
|
instructions: `TEAM FILES DIRECTORY: ${teamDir}\nSave any requested files under this directory so they appear in /files (Team Files). Create the directory if needed.`,
|
|
829
840
|
};
|
|
830
841
|
}
|
|
842
|
+
rewriteFilesAlias(task) {
|
|
843
|
+
if (!task.includes('/files'))
|
|
844
|
+
return task;
|
|
845
|
+
const teamDir = this.currentFileScope === 'team' ? this.getTeamFilesDir() : null;
|
|
846
|
+
const targetDir = teamDir || getSharedOutputPath();
|
|
847
|
+
return task.replace(/\/files(\/[^\s"'`)]*)?/gi, (match) => {
|
|
848
|
+
const suffix = match.slice('/files'.length);
|
|
849
|
+
return `${targetDir}${suffix}`;
|
|
850
|
+
});
|
|
851
|
+
}
|
|
831
852
|
getFileScopeSystemNote() {
|
|
832
853
|
if (this.currentFileScope !== 'team')
|
|
833
854
|
return null;
|
|
@@ -1368,12 +1389,17 @@ ${hubContextStr}
|
|
|
1368
1389
|
if (response.stop_reason === 'end_turn' || !this.hasToolUse(response.content)) {
|
|
1369
1390
|
if (forcedToolChoice && !retriedForcedTool) {
|
|
1370
1391
|
retriedForcedTool = true;
|
|
1392
|
+
const toolName = forcedToolChoice.name;
|
|
1393
|
+
const needsNoWorkers = toolName === 'todo_upsert_items' || toolName === 'calendar_upsert_events';
|
|
1394
|
+
const followup = needsNoWorkers
|
|
1395
|
+
? `You must call the ${toolName} tool now. Use the exact task/event titles and any bracketed tags exactly as provided. Do not spawn workers.`
|
|
1396
|
+
: `You must call the ${toolName} tool now. Use the user's request as the task details.`;
|
|
1371
1397
|
currentMessages = [
|
|
1372
1398
|
...currentMessages,
|
|
1373
1399
|
{ role: 'assistant', content: response.content },
|
|
1374
1400
|
{
|
|
1375
1401
|
role: 'user',
|
|
1376
|
-
content:
|
|
1402
|
+
content: followup
|
|
1377
1403
|
}
|
|
1378
1404
|
];
|
|
1379
1405
|
continue;
|
|
@@ -2083,7 +2109,8 @@ Unlike lia_plan (internal only), this creates a VISIBLE todo list that appears i
|
|
|
2083
2109
|
case 'spawn_worker': {
|
|
2084
2110
|
const { task } = this.withAttachments(input.task);
|
|
2085
2111
|
const fileScope = this.getFileScopeOverrides();
|
|
2086
|
-
const
|
|
2112
|
+
const normalizedTask = this.rewriteFilesAlias(task);
|
|
2113
|
+
const scopedTask = fileScope.instructions ? `${fileScope.instructions}\n\n${normalizedTask}` : normalizedTask;
|
|
2087
2114
|
result = await this.workerTools.spawnWorker(scopedTask, {
|
|
2088
2115
|
timeout: input.timeout,
|
|
2089
2116
|
priority: input.priority,
|
|
@@ -2107,7 +2134,8 @@ Unlike lia_plan (internal only), this creates a VISIBLE todo list that appears i
|
|
|
2107
2134
|
case 'delegate_to_worker': {
|
|
2108
2135
|
const { task, context } = this.withAttachments(input.task, input.context);
|
|
2109
2136
|
const fileScope = this.getFileScopeOverrides();
|
|
2110
|
-
|
|
2137
|
+
const normalizedTask = this.rewriteFilesAlias(task);
|
|
2138
|
+
result = await this.delegateToWorker(normalizedTask, context, input.working_directory || fileScope.workingDir, fileScope.instructions);
|
|
2111
2139
|
break;
|
|
2112
2140
|
}
|
|
2113
2141
|
case 'remember':
|