@grackle-ai/server 0.55.0 → 0.56.0

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.
@@ -1,7 +1,54 @@
1
1
  /**
2
2
  * Builds system prompts for agent sessions, assembling sections
3
3
  * dynamically based on the session type (task vs ad-hoc).
4
+ *
5
+ * Orchestrator tasks (canDecompose + depth <= 1) receive rich project
6
+ * context (task tree, persona roster, environments, findings).
7
+ * Leaf tasks receive the existing completion-contract template.
4
8
  */
9
+ /** Lightweight task node for rendering the task tree in orchestrator prompts. */
10
+ export interface TaskTreeNode {
11
+ /** Task ID. */
12
+ id: string;
13
+ /** Task title. */
14
+ title: string;
15
+ /** Current lifecycle status (not_started, working, paused, complete, failed). */
16
+ status: string;
17
+ /** Nesting depth in the hierarchy (0 = root). */
18
+ depth: number;
19
+ /** Parent task ID (empty string for root-level tasks). */
20
+ parentTaskId: string;
21
+ /** IDs of tasks this task depends on. */
22
+ dependsOn: string[];
23
+ /** Resolved persona display name (empty if none assigned). */
24
+ personaName: string;
25
+ /** Git branch name (empty if none). */
26
+ branch: string;
27
+ /** Whether this task can create subtasks. */
28
+ canDecompose: boolean;
29
+ }
30
+ /** Persona summary for the available-personas prompt section. */
31
+ export interface PersonaSummary {
32
+ /** Display name. */
33
+ name: string;
34
+ /** Short description. */
35
+ description: string;
36
+ /** Runtime backend (claude-code, copilot, codex, etc.). */
37
+ runtime: string;
38
+ /** Default model (e.g. "opus", "sonnet"). */
39
+ model: string;
40
+ }
41
+ /** Environment summary for the available-environments prompt section. */
42
+ export interface EnvironmentSummary {
43
+ /** Human-readable name. */
44
+ displayName: string;
45
+ /** Adapter backend (local, ssh, codespace, docker). */
46
+ adapterType: string;
47
+ /** Connection status (connected, disconnected, etc.). */
48
+ status: string;
49
+ /** Default runtime for this environment. */
50
+ defaultRuntime: string;
51
+ }
5
52
  /** Options for building a system prompt. */
6
53
  export interface SystemPromptOptions {
7
54
  /** Task metadata. When absent, this is an ad-hoc session. */
@@ -10,15 +57,36 @@ export interface SystemPromptOptions {
10
57
  description: string;
11
58
  notes: string;
12
59
  };
60
+ /** ID of the current task (used to mark it in the task tree). */
61
+ taskId?: string;
13
62
  /** Whether the agent is allowed to create subtasks. */
14
63
  canDecompose?: boolean;
15
64
  /** Persona behavioral instructions (prepended when non-empty). */
16
65
  personaPrompt?: string;
66
+ /** Task depth in the hierarchy (0 = root, 1 = first child, etc.). */
67
+ taskDepth?: number;
68
+ /** Workspace metadata for the orchestrator context section. */
69
+ workspace?: {
70
+ name: string;
71
+ description: string;
72
+ repoUrl: string;
73
+ };
74
+ /** All tasks in the workspace, for rendering the task tree. */
75
+ taskTree?: TaskTreeNode[];
76
+ /** Available personas for the orchestrator to assign. */
77
+ availablePersonas?: PersonaSummary[];
78
+ /** Available environments for the orchestrator to route work to. */
79
+ availableEnvironments?: EnvironmentSummary[];
80
+ /** Pre-built findings context string (from buildFindingsContext). */
81
+ findingsContext?: string;
82
+ /** Invocation mode: fresh (first time) or resume (re-invoked after child completion). */
83
+ triggerMode?: "fresh" | "resume";
17
84
  }
18
85
  /**
19
86
  * Assembles a system prompt from discrete sections based on session type.
20
87
  *
21
- * Task sessions get task context, completion contract, signal docs, and findings guidance.
88
+ * Orchestrator tasks get project state, task tree, persona roster, and
89
+ * decomposition guidelines. Leaf tasks get the existing completion contract.
22
90
  * Ad-hoc sessions get only the MCP note and persona prompt.
23
91
  */
24
92
  export declare class SystemPromptBuilder {
@@ -26,6 +94,33 @@ export declare class SystemPromptBuilder {
26
94
  constructor(options: SystemPromptOptions);
27
95
  /** Build the complete system prompt string. */
28
96
  build(): string;
97
+ /**
98
+ * Determine whether this is an orchestrator task.
99
+ * Requires canDecompose, shallow depth, AND orchestrator data fields to be
100
+ * present. This ensures existing callers that pass canDecompose without
101
+ * the new fields still get the leaf template.
102
+ */
103
+ private isOrchestrator;
104
+ /** Orchestrator task context with role framing. */
105
+ private buildOrchestratorTaskContext;
106
+ /** Workspace metadata section. */
107
+ private buildWorkspaceContext;
108
+ /** Hierarchical task tree with statuses, personas, and dependencies. */
109
+ private buildTaskTree;
110
+ /** Available personas table. */
111
+ private buildAvailablePersonas;
112
+ /** Available environments table. */
113
+ private buildAvailableEnvironments;
114
+ /** Orchestrator findings section with actual findings data. */
115
+ private buildOrchestratorFindingsSection;
116
+ /** Trigger context describing why this invocation happened. */
117
+ private buildTriggerContext;
118
+ /** Decomposition heuristics and guardrails. */
119
+ private buildDecompositionGuidelines;
120
+ /** Orchestrator-specific MCP tool documentation. */
121
+ private buildOrchestratorTools;
122
+ /** Orchestrator-specific completion contract. */
123
+ private buildOrchestratorCompletionContract;
29
124
  /** Task title, description, and notes. */
30
125
  private buildTaskContext;
31
126
  /** Contract for signaling task completion. */
@@ -34,7 +129,7 @@ export declare class SystemPromptBuilder {
34
129
  private buildSubtaskSection;
35
130
  /** SIGCHLD signal documentation. */
36
131
  private buildSignalSection;
37
- /** Guidance on using findings. */
132
+ /** Guidance on using findings (leaf agents). */
38
133
  private buildFindingsSection;
39
134
  /** MCP note (always included). */
40
135
  private buildMcpNote;
@@ -1 +1 @@
1
- {"version":3,"file":"system-prompt-builder.d.ts","sourceRoot":"","sources":["../src/system-prompt-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC,6DAA6D;IAC7D,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,uDAAuD;IACvD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;gBAE3B,OAAO,EAAE,mBAAmB;IAI/C,+CAA+C;IACxC,KAAK,IAAI,MAAM;IAsBtB,0CAA0C;IAC1C,OAAO,CAAC,gBAAgB;IAYxB,8CAA8C;IAC9C,OAAO,CAAC,uBAAuB;IAO/B,8CAA8C;IAC9C,OAAO,CAAC,mBAAmB;IAa3B,oCAAoC;IACpC,OAAO,CAAC,kBAAkB;IAU1B,kCAAkC;IAClC,OAAO,CAAC,oBAAoB;IAO5B,kCAAkC;IAClC,OAAO,CAAC,YAAY;CAGrB"}
1
+ {"version":3,"file":"system-prompt-builder.d.ts","sourceRoot":"","sources":["../src/system-prompt-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,iFAAiF;AACjF,MAAM,WAAW,YAAY;IAC3B,eAAe;IACf,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,yEAAyE;AACzE,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,cAAc,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IACpC,OAAO,CAAC,0BAA0B;IAiBlC,+DAA+D;IAC/D,OAAO,CAAC,gCAAgC;IAOxC,+DAA+D;IAC/D,OAAO,CAAC,mBAAmB;IAa3B,+CAA+C;IAC/C,OAAO,CAAC,4BAA4B;IAcpC,oDAAoD;IACpD,OAAO,CAAC,sBAAsB;IAe9B,iDAAiD;IACjD,OAAO,CAAC,mCAAmC;IAS3C,0CAA0C;IAC1C,OAAO,CAAC,gBAAgB;IAYxB,8CAA8C;IAC9C,OAAO,CAAC,uBAAuB;IAO/B,8CAA8C;IAC9C,OAAO,CAAC,mBAAmB;IAa3B,oCAAoC;IACpC,OAAO,CAAC,kBAAkB;IAU1B,gDAAgD;IAChD,OAAO,CAAC,oBAAoB;IAO5B,kCAAkC;IAClC,OAAO,CAAC,YAAY;CAGrB"}
@@ -1,11 +1,17 @@
1
1
  /**
2
2
  * Builds system prompts for agent sessions, assembling sections
3
3
  * dynamically based on the session type (task vs ad-hoc).
4
+ *
5
+ * Orchestrator tasks (canDecompose + depth <= 1) receive rich project
6
+ * context (task tree, persona roster, environments, findings).
7
+ * Leaf tasks receive the existing completion-contract template.
4
8
  */
9
+ // ─── Builder ─────────────────────────────────────────────────
5
10
  /**
6
11
  * Assembles a system prompt from discrete sections based on session type.
7
12
  *
8
- * Task sessions get task context, completion contract, signal docs, and findings guidance.
13
+ * Orchestrator tasks get project state, task tree, persona roster, and
14
+ * decomposition guidelines. Leaf tasks get the existing completion contract.
9
15
  * Ad-hoc sessions get only the MCP note and persona prompt.
10
16
  */
11
17
  export class SystemPromptBuilder {
@@ -21,16 +27,215 @@ export class SystemPromptBuilder {
21
27
  sections.push(this.options.personaPrompt);
22
28
  }
23
29
  if (this.options.task) {
24
- sections.push(this.buildTaskContext());
25
- sections.push(this.buildCompletionContract());
26
- sections.push(this.buildSubtaskSection());
27
- sections.push(this.buildSignalSection());
28
- sections.push(this.buildFindingsSection());
30
+ if (this.isOrchestrator()) {
31
+ sections.push(this.buildOrchestratorTaskContext());
32
+ sections.push(this.buildWorkspaceContext());
33
+ sections.push(this.buildTaskTree());
34
+ sections.push(this.buildAvailablePersonas());
35
+ sections.push(this.buildAvailableEnvironments());
36
+ sections.push(this.buildOrchestratorFindingsSection());
37
+ sections.push(this.buildTriggerContext());
38
+ sections.push(this.buildDecompositionGuidelines());
39
+ sections.push(this.buildOrchestratorTools());
40
+ sections.push(this.buildOrchestratorCompletionContract());
41
+ sections.push(this.buildSignalSection());
42
+ }
43
+ else {
44
+ // Existing leaf behavior — unchanged
45
+ sections.push(this.buildTaskContext());
46
+ sections.push(this.buildCompletionContract());
47
+ sections.push(this.buildSubtaskSection());
48
+ sections.push(this.buildSignalSection());
49
+ sections.push(this.buildFindingsSection());
50
+ }
29
51
  }
30
52
  // MCP note (always included)
31
53
  sections.push(this.buildMcpNote());
32
54
  return sections.filter(Boolean).join("\n\n");
33
55
  }
56
+ // ─── Orchestrator Detection ──────────────────────────────
57
+ /**
58
+ * Determine whether this is an orchestrator task.
59
+ * Requires canDecompose, shallow depth, AND orchestrator data fields to be
60
+ * present. This ensures existing callers that pass canDecompose without
61
+ * the new fields still get the leaf template.
62
+ */
63
+ isOrchestrator() {
64
+ return this.options.canDecompose === true
65
+ && this.options.taskDepth !== undefined
66
+ && this.options.taskDepth <= 1
67
+ && this.options.taskTree !== undefined;
68
+ }
69
+ // ─── Orchestrator Sections ───────────────────────────────
70
+ /** Orchestrator task context with role framing. */
71
+ buildOrchestratorTaskContext() {
72
+ const { title, description, notes } = this.options.task;
73
+ const parts = [
74
+ `## Your Task: ${title}`,
75
+ `You are an **orchestrator agent** responsible for decomposing and coordinating work. You do not write code directly — you break work into subtasks, assign personas, manage dependencies, and monitor progress.`,
76
+ ];
77
+ if (description) {
78
+ parts.push(description);
79
+ }
80
+ if (notes) {
81
+ parts.push(`### Notes (from previous attempt or user feedback)\n${notes}`);
82
+ }
83
+ return parts.join("\n\n");
84
+ }
85
+ /** Workspace metadata section. */
86
+ buildWorkspaceContext() {
87
+ const ws = this.options.workspace;
88
+ if (!ws) {
89
+ return "";
90
+ }
91
+ const lines = [`## Workspace Context`];
92
+ lines.push(`- **Name**: ${ws.name}`);
93
+ if (ws.description) {
94
+ lines.push(`- **Description**: ${ws.description}`);
95
+ }
96
+ if (ws.repoUrl) {
97
+ lines.push(`- **Repository**: ${ws.repoUrl}`);
98
+ }
99
+ return lines.join("\n");
100
+ }
101
+ /** Hierarchical task tree with statuses, personas, and dependencies. */
102
+ buildTaskTree() {
103
+ const nodes = this.options.taskTree;
104
+ if (!nodes || nodes.length === 0) {
105
+ return "";
106
+ }
107
+ // Build parent → children map
108
+ const childMap = new Map();
109
+ for (const node of nodes) {
110
+ const key = node.parentTaskId || "";
111
+ const children = childMap.get(key);
112
+ if (children) {
113
+ children.push(node);
114
+ }
115
+ else {
116
+ childMap.set(key, [node]);
117
+ }
118
+ }
119
+ // Status summary
120
+ const counts = new Map();
121
+ for (const node of nodes) {
122
+ counts.set(node.status, (counts.get(node.status) || 0) + 1);
123
+ }
124
+ const summary = [...counts.entries()]
125
+ .map(([status, count]) => `${count} ${status}`)
126
+ .join(", ");
127
+ // Recursive render
128
+ const lines = [];
129
+ const renderNode = (node, indent) => {
130
+ const pad = " ".repeat(indent);
131
+ const persona = node.personaName ? ` (persona: ${node.personaName})` : "";
132
+ const deps = node.dependsOn.length > 0
133
+ ? ` [depends on: ${node.dependsOn.join(", ")}]`
134
+ : "";
135
+ const branch = node.branch ? ` [branch: ${node.branch}]` : "";
136
+ const marker = node.id === this.options.taskId ? " <-- YOU" : "";
137
+ lines.push(`${pad}- [${node.status}] ${node.title}${persona}${deps}${branch}${marker}`);
138
+ const children = childMap.get(node.id);
139
+ if (children) {
140
+ for (const child of children) {
141
+ renderNode(child, indent + 1);
142
+ }
143
+ }
144
+ };
145
+ // Start from root nodes
146
+ const roots = childMap.get("") || [];
147
+ for (const root of roots) {
148
+ renderNode(root, 0);
149
+ }
150
+ return `## Task Tree\n\nStatus: ${summary}\n\n${lines.join("\n")}`;
151
+ }
152
+ /** Available personas table. */
153
+ buildAvailablePersonas() {
154
+ const personas = this.options.availablePersonas;
155
+ if (!personas || personas.length === 0) {
156
+ return "";
157
+ }
158
+ const rows = personas.map((p) => `| ${p.name} | ${p.description || "—"} | ${p.runtime || "—"} | ${p.model || "—"} |`);
159
+ return [
160
+ `## Available Personas`,
161
+ ``,
162
+ `| Name | Description | Runtime | Model |`,
163
+ `|------|-------------|---------|-------|`,
164
+ ...rows,
165
+ ].join("\n");
166
+ }
167
+ /** Available environments table. */
168
+ buildAvailableEnvironments() {
169
+ const envs = this.options.availableEnvironments;
170
+ if (!envs || envs.length === 0) {
171
+ return "";
172
+ }
173
+ const rows = envs.map((e) => `| ${e.displayName} | ${e.adapterType} | ${e.status} | ${e.defaultRuntime || "—"} |`);
174
+ return [
175
+ `## Available Environments`,
176
+ ``,
177
+ `| Name | Adapter | Status | Runtime |`,
178
+ `|------|---------|--------|---------|`,
179
+ ...rows,
180
+ ].join("\n");
181
+ }
182
+ /** Orchestrator findings section with actual findings data. */
183
+ buildOrchestratorFindingsSection() {
184
+ if (!this.options.findingsContext) {
185
+ return "";
186
+ }
187
+ return this.options.findingsContext;
188
+ }
189
+ /** Trigger context describing why this invocation happened. */
190
+ buildTriggerContext() {
191
+ if (this.options.triggerMode === "resume") {
192
+ return [
193
+ `## Trigger Context`,
194
+ `You are being re-invoked after one or more child tasks completed. Review the task tree above for current statuses and decide what to do next.`,
195
+ ].join("\n");
196
+ }
197
+ return [
198
+ `## Trigger Context`,
199
+ `You are being invoked for the first time to orchestrate this workspace. Assess the current state, then decompose your task into subtasks.`,
200
+ ].join("\n");
201
+ }
202
+ /** Decomposition heuristics and guardrails. */
203
+ buildDecompositionGuidelines() {
204
+ return [
205
+ `## Decomposition Guidelines`,
206
+ ``,
207
+ `- Estimate task complexity before decomposing. Do not decompose simple tasks (under ~100 lines of code or touching fewer than 3 files).`,
208
+ `- Favor context-boundary decomposition over role-boundary decomposition: the agent implementing a feature should also write its tests.`,
209
+ `- Consider coordination cost vs. parallel benefit. Decomposition multiplies token usage by 3-10x.`,
210
+ `- Keep the number of direct subtasks reasonable (aim for 3-7 per parent).`,
211
+ `- Each subtask description must be self-contained — the child agent has no context beyond what you provide in the description.`,
212
+ `- Set dependencies between subtasks when ordering matters. Independent subtasks can run in parallel.`,
213
+ `- Grant decomposition rights (\`canDecompose: true\`) only to subtasks that genuinely need to coordinate further work.`,
214
+ ].join("\n");
215
+ }
216
+ /** Orchestrator-specific MCP tool documentation. */
217
+ buildOrchestratorTools() {
218
+ return [
219
+ `## Orchestrator Tools`,
220
+ ``,
221
+ `Use these tools on your \`grackle\` MCP server to coordinate work:`,
222
+ `- \`task_create\` — Create a subtask with title, description, dependencies, persona, and decomposition rights.`,
223
+ `- \`task_list\` — List all tasks in the workspace with their current statuses.`,
224
+ `- \`task_show\` — Show details of a specific task including its sessions and output.`,
225
+ `- \`task_start\` — Start a task (begins agent execution on the assigned environment).`,
226
+ `- \`task_complete\` — Signal that your task is complete.`,
227
+ `- \`finding_post\` — Share a discovery (architecture decisions, patterns, bugs) with other agents.`,
228
+ `- \`finding_list\` — List recent findings from all agents in this workspace.`,
229
+ ].join("\n");
230
+ }
231
+ /** Orchestrator-specific completion contract. */
232
+ buildOrchestratorCompletionContract() {
233
+ return [
234
+ `## Completion`,
235
+ `When all subtasks are complete and you have verified the results, use \`task_complete\` to signal your own completion. If any subtasks failed, decide whether to retry, reassign, or handle the failure before completing.`,
236
+ ].join("\n");
237
+ }
238
+ // ─── Leaf Sections (unchanged) ───────────────────────────
34
239
  /** Task title, description, and notes. */
35
240
  buildTaskContext() {
36
241
  const { title, description, notes } = this.options.task;
@@ -73,7 +278,7 @@ export class SystemPromptBuilder {
73
278
  `3. If the child failed or was interrupted, decide whether to retry, reassign, or handle the failure yourself.`,
74
279
  ].join("\n");
75
280
  }
76
- /** Guidance on using findings. */
281
+ /** Guidance on using findings (leaf agents). */
77
282
  buildFindingsSection() {
78
283
  return [
79
284
  `## Findings`,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AE;YACnB,WAAW;SACZ,CAAC;QACF,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,CAAC,IAAI,CAAC,sDAAsD,KAAK,EAAE,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,8CAA8C;IACtC,uBAAuB;QAC7B,OAAO;YACL,eAAe;YACf,sMAAsM;SACvM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IAED,8CAA8C;IACtC,mBAAmB;QACzB,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;YAC9B,OAAO;gBACL,aAAa;gBACb,4OAA4O;aAC7O,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;QACD,OAAO;YACL,aAAa;YACb,yEAAyE;SAC1E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IAED,oCAAoC;IAC5B,kBAAkB;QACxB,OAAO;YACL,YAAY;YACZ,oHAAoH;YACpH,wEAAwE;YACxE,mGAAmG;YACnG,+GAA+G;SAChH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IAED,kCAAkC;IAC1B,oBAAoB;QAC1B,OAAO;YACL,aAAa;YACb,kKAAkK;SACnK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IAED,kCAAkC;IAC1B,YAAY;QAClB,OAAO,gDAAgD,CAAC;IAC1D,CAAC;CACF"}
1
+ {"version":3,"file":"system-prompt-builder.js","sourceRoot":"","sources":["../src/system-prompt-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiFH,gEAAgE;AAEhE;;;;;;GAMG;AACH,MAAM,OAAO,mBAAmB;IACb,OAAO,CAAsB;IAE9C,YAAmB,OAA4B;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,+CAA+C;I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AoH;YACpH,wEAAwE;YACxE,mGAAmG;YACnG,+GAA+G;SAChH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IAED,gDAAgD;IACxC,oBAAoB;QAC1B,OAAO;YACL,aAAa;YACb,kKAAkK;SACnK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IAED,kCAAkC;IAC1B,YAAY;QAClB,OAAO,gDAAgD,CAAC;IAC1D,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ws-bridge.d.ts","sourceRoot":"","sources":["../src/ws-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAa,MAAM,IAAI,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AAiEtD,wGAAwG;AACxG,wBAAgB,cAAc,CAC5B,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,EACxC,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,GACjD,eAAe,CA6CjB"}
1
+ {"version":3,"file":"ws-bridge.d.ts","sourceRoot":"","sources":["../src/ws-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAa,MAAM,IAAI,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AAkEtD,wGAAwG;AACxG,wBAAgB,cAAc,CAC5B,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,EACxC,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,GACjD,eAAe,CA6CjB"}
package/dist/ws-bridge.js CHANGED
@@ -16,6 +16,7 @@ import { v4 as uuid } from "uuid";
16
16
  import { join } from "node:path";
17
17
  import { LOGS_DIR, SESSION_STATUS, TERMINAL_SESSION_STATUSES, TASK_STATUS, DEFAULT_MCP_PORT, ROOT_TASK_ID, eventTypeToString, } from "@grackle-ai/common";
18
18
  import { resolvePersona } from "./resolve-persona.js";
19
+ import { fetchOrchestratorContext } from "./orchestrator-context.js";
19
20
  import * as settingsStore from "./settings-store.js";
20
21
  import { isAllowedSettingKey } from "./settings-store.js";
21
22
  import { grackleHome } from "./paths.js";
@@ -119,6 +120,7 @@ async function autoProvisionEnvironment(ws, environmentId, env, logContext) {
119
120
  emit("environment.changed", {});
120
121
  try {
121
122
  const config = safeParseAdapterConfig(env.adapterConfig, environmentId);
123
+ config.defaultRuntime = env.defaultRuntime;
122
124
  const powerlineToken = env.powerlineToken || "";
123
125
  for await (const provEvent of reconnectOrProvision(environmentId, adapter, config, powerlineToken, !!env.bootstrapped)) {
124
126
  logger.info({ environmentId, stage: provEvent.stage, ...logContext }, "Auto-provision progress");
@@ -209,10 +211,13 @@ async function startTaskSession(ws, task, options) {
209
211
  const initialPrompt = freshTask.id === ROOT_TASK_ID
210
212
  ? (options?.notes || "")
211
213
  : freshTask.title;
214
+ const orchestratorCtx = freshTask.canDecompose && freshTask.depth <= 1
215
+ ? fetchOrchestratorContext(freshTask.workspaceId || "") : undefined;
212
216
  const systemContext = new SystemPromptBuilder({
213
217
  task: { title: freshTask.title, description: freshTask.description, notes: options?.notes || "" },
214
- canDecompose: freshTask.canDecompose,
215
- personaPrompt: systemPrompt,
218
+ taskId: freshTask.id, canDecompose: freshTask.canDecompose, personaPrompt: systemPrompt,
219
+ taskDepth: freshTask.depth, ...orchestratorCtx,
220
+ ...(orchestratorCtx && { triggerMode: "fresh" }),
216
221
  }).build();
217
222
  sessionStore.createSession(sessionId, environmentId, runtime, initialPrompt || freshTask.title, model, logPath, freshTask.id, resolved.personaId);
218
223
  emit("task.started", {
@@ -1285,6 +1290,7 @@ async function handleMessage(ws, msg, subscriptions) {
1285
1290
  (async () => {
1286
1291
  try {
1287
1292
  const config = safeParseAdapterConfig(env.adapterConfig, environmentId);
1293
+ config.defaultRuntime = env.defaultRuntime;
1288
1294
  const powerlineToken = env.powerlineToken || "";
1289
1295
  for await (const event of reconnectOrProvision(environmentId, adapter, config, powerlineToken, !!env.bootstrapped)) {
1290
1296
  logger.info({ environmentId, stage: event.stage, message: event.message }, "Provision progress");