@deepagents/orchestrator 7.30.0 → 7.30.2

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.
Files changed (61) hide show
  1. package/dist/lib/deepplan/demo.js +8 -166
  2. package/dist/lib/deepplan/demo.js.map +4 -4
  3. package/dist/lib/deepplan/executors/generic-executor.d.ts +0 -12
  4. package/dist/lib/deepplan/executors/generic-executor.d.ts.map +1 -1
  5. package/dist/lib/deepplan/executors/generic-executor.js +0 -157
  6. package/dist/lib/deepplan/executors/generic-executor.js.map +2 -2
  7. package/dist/lib/deepplan/plan-and-solve.js +10 -166
  8. package/dist/lib/deepplan/plan-and-solve.js.map +3 -3
  9. package/dist/lib/deepplan/planner-agent.js +3 -159
  10. package/dist/lib/deepplan/planner-agent.js.map +3 -3
  11. package/dist/lib/deepplan/replanner-agent.js +3 -163
  12. package/dist/lib/deepplan/replanner-agent.js.map +4 -4
  13. package/package.json +4 -6
  14. package/dist/lib/arxiv/arxiv.d.ts +0 -14
  15. package/dist/lib/arxiv/arxiv.d.ts.map +0 -1
  16. package/dist/lib/arxiv/arxiv.js +0 -145
  17. package/dist/lib/arxiv/arxiv.js.map +0 -7
  18. package/dist/lib/citation.d.ts +0 -2
  19. package/dist/lib/citation.d.ts.map +0 -1
  20. package/dist/lib/citation.js +0 -117
  21. package/dist/lib/citation.js.map +0 -7
  22. package/dist/lib/deepplan/executors/product-manager-executor.d.ts +0 -13
  23. package/dist/lib/deepplan/executors/product-manager-executor.d.ts.map +0 -1
  24. package/dist/lib/deepplan/executors/product-manager-executor.js +0 -226
  25. package/dist/lib/deepplan/executors/product-manager-executor.js.map +0 -7
  26. package/dist/lib/deepplan/executors/repo-search-executor.d.ts +0 -11
  27. package/dist/lib/deepplan/executors/repo-search-executor.d.ts.map +0 -1
  28. package/dist/lib/deepplan/executors/repo-search-executor.js +0 -76
  29. package/dist/lib/deepplan/executors/repo-search-executor.js.map +0 -7
  30. package/dist/lib/deepresearch.v0.d.ts +0 -3
  31. package/dist/lib/deepresearch.v0.d.ts.map +0 -1
  32. package/dist/lib/deepresearch.v0.js +0 -300
  33. package/dist/lib/deepresearch.v0.js.map +0 -7
  34. package/dist/lib/deepwiki/complete-wiki.d.ts +0 -20
  35. package/dist/lib/deepwiki/complete-wiki.d.ts.map +0 -1
  36. package/dist/lib/deepwiki/complete-wiki.js +0 -321
  37. package/dist/lib/deepwiki/complete-wiki.js.map +0 -7
  38. package/dist/lib/deepwiki/deepwiki.d.ts +0 -2
  39. package/dist/lib/deepwiki/deepwiki.d.ts.map +0 -1
  40. package/dist/lib/deepwiki/deepwiki.js +0 -372
  41. package/dist/lib/deepwiki/deepwiki.js.map +0 -7
  42. package/dist/lib/deepwiki/gitignore-agent.d.ts +0 -6
  43. package/dist/lib/deepwiki/gitignore-agent.d.ts.map +0 -1
  44. package/dist/lib/deepwiki/gitignore-agent.js +0 -39
  45. package/dist/lib/deepwiki/gitignore-agent.js.map +0 -7
  46. package/dist/lib/deepwiki/outline-agent.d.ts +0 -22
  47. package/dist/lib/deepwiki/outline-agent.d.ts.map +0 -1
  48. package/dist/lib/deepwiki/outline-agent.js +0 -188
  49. package/dist/lib/deepwiki/outline-agent.js.map +0 -7
  50. package/dist/lib/deepwiki/wiki-writer.d.ts +0 -9
  51. package/dist/lib/deepwiki/wiki-writer.d.ts.map +0 -1
  52. package/dist/lib/deepwiki/wiki-writer.js +0 -244
  53. package/dist/lib/deepwiki/wiki-writer.js.map +0 -7
  54. package/dist/lib/deepwiki/writer.d.ts +0 -12
  55. package/dist/lib/deepwiki/writer.d.ts.map +0 -1
  56. package/dist/lib/deepwiki/writer.js +0 -407
  57. package/dist/lib/deepwiki/writer.js.map +0 -7
  58. package/dist/lib/graph.d.ts +0 -5
  59. package/dist/lib/graph.d.ts.map +0 -1
  60. package/dist/lib/graph.js +0 -12
  61. package/dist/lib/graph.js.map +0 -7
@@ -1,5 +1,5 @@
1
1
  // packages/orchestrator/src/lib/deepplan/replanner-agent.ts
2
- import { defaultSettingsMiddleware as defaultSettingsMiddleware2, wrapLanguageModel as wrapLanguageModel2 } from "ai";
2
+ import { defaultSettingsMiddleware, wrapLanguageModel } from "ai";
3
3
  import z from "zod";
4
4
  import { lmstudio } from "@deepagents/agent";
5
5
  import {
@@ -10,166 +10,6 @@ import {
10
10
  structuredOutput,
11
11
  user
12
12
  } from "@deepagents/context";
13
-
14
- // packages/orchestrator/src/lib/deepplan/executors/generic-executor.ts
15
- import { groq } from "@ai-sdk/groq";
16
- import { defaultSettingsMiddleware, wrapLanguageModel } from "ai";
17
- import { agent } from "@deepagents/agent";
18
- import { scratchpad_tool, search_content_tool } from "@deepagents/toolbox";
19
- var executorAgent = agent({
20
- name: "executor_agent",
21
- model: wrapLanguageModel({
22
- model: groq("openai/gpt-oss-20b"),
23
- middleware: defaultSettingsMiddleware({
24
- settings: { temperature: 0 }
25
- })
26
- }),
27
- prompt: `
28
- <SystemContext>
29
- You are a precise execution agent that follows plans and gathers information systematically.
30
- You pay close attention to details and track what you find.
31
- </SystemContext>
32
-
33
- <Identity>
34
- Your task is to execute a single step from a plan and report back with structured results.
35
- You are part of an adaptive planning system where your findings will influence future steps.
36
- </Identity>
37
-
38
- <ExecutionPrinciples>
39
- 1. **Focus on the Objective**
40
- - Understand exactly what this step is asking for
41
- - Review the expected outcome
42
- - Stay focused on gathering that specific information
43
-
44
- 2. **Extract Variables and Numerals**
45
- - As you find information, extract key data points
46
- - **CRITICAL: Extract numerical values separately from units**
47
- - Store them as structured variables (e.g., {product_name: "iPhone 15", release_date: "Sep 2024", release_month: 9, release_year: 2024})
48
- - Track counts, amounts, dates, and measurements explicitly
49
- - These variables help track progress across steps
50
-
51
- 3. **Calculate Intermediate Results**
52
- - Pay attention to correct numerical calculation and commonsense
53
- - Perform any required calculations step-by-step
54
- - Verify numerical accuracy (e.g., date ranges, counts, sums)
55
- - Check results against common sense (e.g., dates in valid range, reasonable quantities)
56
- - Show your calculation work when computing values
57
-
58
- 4. **Verify Results**
59
- - Carefully review what you find for accuracy
60
- - Ensure numerical values are consistent
61
- - Check for logical coherence
62
- - Note anything unexpected or inconsistent
63
-
64
- 5. **Make Observations**
65
- - What patterns did you notice?
66
- - What numerical trends are apparent?
67
- - What might affect subsequent steps?
68
-
69
- 6. **Note Issues**
70
- - Were there any calculation difficulties?
71
- - Was the information hard to find?
72
- - Were there any errors or ambiguities?
73
- </ExecutionPrinciples>
74
-
75
-
76
- <ContextAwareness>
77
- You will be given:
78
- - The current step to execute
79
- - The original user request (for context)
80
- - Variables gathered from previous steps
81
- - Data collected so far
82
-
83
- Use this context to:
84
- - Avoid re-gathering information you already have
85
- - Build on previous findings
86
- - Connect new information to what's already known
87
- </ContextAwareness>
88
-
89
- <ReportingGuidelines>
90
- Your report should include:
91
-
92
- 1. **Status**
93
- - success: Step completed as expected
94
- - partial: Got some but not all information
95
- - failed: Could not complete the step
96
-
97
- 2. **Data Gathered**
98
- - Summarize what you found
99
- - Be specific and factual
100
- - Include enough detail to be useful
101
-
102
- 3. **Extracted Variables and Numerals**
103
- - Key data points you discovered
104
- - Format as key-value pairs with numerical values separated
105
- - Examples: {count: 5, average_price: 299, latest_date: "2024-01-15", date_month: 1, date_year: 2024}
106
- - Include any intermediate calculations performed
107
-
108
- 4. **Observations**
109
- - Notable patterns or insights
110
- - Anything that might affect the plan
111
- - Connections to the overall goal
112
-
113
- 5. **Issues**
114
- - Any problems encountered
115
- - Missing or unclear information
116
- - Limitations of what you found
117
- </ReportingGuidelines>
118
-
119
- <Examples>
120
- Step: "Find Apple's official announcements from the past 3 months"
121
- Context: {company: "Apple", timeframe: "3 months"}
122
-
123
- Good Execution:
124
- - Use browser_search to find Apple newsroom/press releases
125
- - Filter results to last 3 months
126
- - List the announcements found
127
- - Extract count, dates, types
128
- - Note any gaps or issues
129
-
130
- Report (with numerical extraction):
131
- - Status: success
132
- - Data: "Found 15 press releases from Apple newsroom (Oct-Dec 2024)"
133
- - Variables: {
134
- press_release_count: 15,
135
- date_range: "Oct-Dec 2024",
136
- start_month: 10,
137
- end_month: 12,
138
- year: 2024,
139
- months_covered: 3
140
- }
141
- - Observations: ["Mix of product, service, and corporate announcements", "Exactly covers the requested 3-month timeframe"]
142
- - Issues: []
143
- </Examples>
144
-
145
- <CriticalInstructions>
146
- - Execute the step precisely as described
147
- - **Extract numerical variables and their values separately**
148
- - **Pay attention to correct numerical calculation and commonsense**
149
- - Calculate and verify intermediate results step-by-step
150
- - Report accurately with verified numbers - your results influence future steps
151
- - Use the context from previous steps to work smarter
152
- - If you can't find something, say so clearly
153
- - Double-check all numerical values for accuracy
154
- </CriticalInstructions>
155
-
156
- <OutputFormat>
157
- Provide a structured step result with:
158
- - status (success/partial/failed)
159
- - data_gathered (summary of findings)
160
- - extracted_variables (key-value pairs)
161
- - observations (notable insights)
162
- - issues (any problems)
163
- </OutputFormat>
164
- `,
165
- tools: {
166
- scratchpad: scratchpad_tool,
167
- search: search_content_tool
168
- // browser_search: groq.tools.browserSearch({}),
169
- }
170
- });
171
-
172
- // packages/orchestrator/src/lib/deepplan/replanner-agent.ts
173
13
  var PlanStepSchema = z.object({
174
14
  description: z.string().describe("What information to find or action to take"),
175
15
  expected_outcome: z.string().describe("What should be accomplished by this step")
@@ -180,10 +20,10 @@ var ReplanDecisionSchema = z.object({
180
20
  remaining_steps: z.array(PlanStepSchema).max(4).describe("Updated list of remaining steps"),
181
21
  new_insights: z.string().describe("New insights learned that affected the plan")
182
22
  });
183
- var replannerModel = wrapLanguageModel2({
23
+ var replannerModel = wrapLanguageModel({
184
24
  // model: groq('moonshotai/kimi-k2-instruct-0905'),
185
25
  model: lmstudio("google/gemma-3-12b"),
186
- middleware: defaultSettingsMiddleware2({
26
+ middleware: defaultSettingsMiddleware({
187
27
  settings: { temperature: 0.1 }
188
28
  })
189
29
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/lib/deepplan/replanner-agent.ts", "../../../src/lib/deepplan/executors/generic-executor.ts"],
4
- "sourcesContent": ["import { defaultSettingsMiddleware, wrapLanguageModel } from 'ai';\nimport z from 'zod';\n\nimport { lmstudio } from '@deepagents/agent';\nimport {\n ContextEngine,\n InMemoryContextStore,\n createBashTool,\n fragment,\n persona,\n structuredOutput,\n user,\n} from '@deepagents/context';\n\nimport { type ExecutionContext } from './executors/generic-executor.ts';\nimport type { PlanStep } from './planner-agent.ts';\n\nconst PlanStepSchema = z.object({\n description: z\n .string()\n .describe('What information to find or action to take'),\n expected_outcome: z\n .string()\n .describe('What should be accomplished by this step'),\n});\nexport const ReplanDecisionSchema = z.object({\n reasoning: z.string().describe('Why this replanning decision was made'),\n should_continue: z.boolean().describe('Should we continue executing?'),\n remaining_steps: z\n .array(PlanStepSchema)\n .max(4)\n .describe('Updated list of remaining steps'),\n new_insights: z\n .string()\n .describe('New insights learned that affected the plan'),\n});\n\nexport type ReplanDecision = z.infer<typeof ReplanDecisionSchema>;\n\n/**\n * Replanner Agent\n *\n * After each step execution, the replanner:\n * 1. Reviews what was accomplished vs what was expected\n * 2. Analyzes how this affects the remaining plan\n * 3. Decides if the plan needs adjustment\n * 4. Updates remaining steps based on new information\n *\n * This creates an adaptive planning system that learns as it executes.\n */\nconst replannerModel = wrapLanguageModel({\n // model: groq('moonshotai/kimi-k2-instruct-0905'),\n model: lmstudio('google/gemma-3-12b'),\n middleware: defaultSettingsMiddleware({\n settings: { temperature: 0.1 },\n }),\n});\n\nfunction createReplannerPrompt(): string {\n return `\n <SystemContext>\n You are an adaptive replanning agent.\n After each step execution, you review progress and adjust the plan as needed.\n </SystemContext>\n\n <Identity>\n Your role is to ensure the execution stays on track and adapts to new information.\n You analyze results, learn from findings, and modify the plan to achieve the goal efficiently.\n </Identity>\n\n <ReplanningPrinciples>\n 1. **Review Results**\n - What was the step supposed to accomplish?\n - What was actually accomplished?\n - Was it successful, partial, or failed?\n\n 2. **Analyze Impact**\n - How do these results affect the overall goal?\n - What did we learn that we didn't know before?\n - Does this change what we need to do next?\n\n 3. **Assess Remaining Plan**\n - Are the remaining steps still appropriate?\n - Do we need additional steps?\n - Can we skip any steps?\n - Should we change the order?\n\n 4. **Make Decisions**\n - Should we continue with the plan?\n - What adjustments are needed?\n - How significant are the changes?\n\n 5. **Update Steps**\n - Modify remaining steps based on learnings\n - Add new steps if needed\n - Remove unnecessary steps\n - Reorder for efficiency\n </ReplanningPrinciples>\n\n <WhenToMakeChanges>\n ## Add Steps When:\n - Found more information than expected (need to filter/process)\n - Discovered new relevant categories (need to explore)\n - Hit limitations (need alternative approaches)\n - Found partial data (need additional sources)\n\n ## Remove Steps When:\n - Already got the information another way\n - The step is no longer relevant based on findings\n - The goal can be achieved without it\n - It's redundant with completed steps\n\n ## Modify Steps When:\n - Need to be more specific based on findings\n - Scope needs adjustment (broader or narrower)\n - Better approach became apparent\n - Need to work around issues discovered\n\n ## Keep Steps When:\n - They're still relevant and needed\n - Results so far support the original plan\n - No better alternative is apparent\n </WhenToMakeChanges>\n\n <ChangeMagnitude>\n Classify plan changes as:\n - **none**: No changes needed, continue as planned\n - **minor**: Small tweaks (wording, ordering, slight additions)\n - **major**: Significant restructuring (many new steps, removed steps, different approach)\n </ChangeMagnitude>\n\n <DecisionMaking>\n Decide if execution should continue:\n\n \u2713 **Continue** when:\n - More steps are needed to complete the goal\n - Making progress toward the objective\n - Can adapt the plan to handle issues\n\n \u2717 **Stop** when:\n - Goal has been fully achieved\n - Discovered the answer isn't available\n - Fundamental blocker that can't be worked around\n - Success criteria have been met\n </DecisionMaking>\n\n <Examples>\n Scenario 1: Found more data than expected\n\n Step Result: Found 50 press releases instead of expected 10-15\n\n Replanning Decision:\n - Reasoning: Large volume needs filtering before analysis\n - Changes: major\n - Add step: \"Filter press releases to product-related only\"\n - Modify next step: Focus on filtered subset\n - Continue: true\n\n ---\n\n Scenario 2: Got exactly what was needed\n\n Step Result: Successfully identified 3 products with all details\n\n Replanning Decision:\n - Reasoning: Already have complete information\n - Changes: none or minor (maybe skip redundant verification step)\n - Continue: Check if success criteria met, might stop\n\n ---\n\n Scenario 3: Information not available\n\n Step Result: Official source doesn't have the data\n\n Replanning Decision:\n - Reasoning: Need alternative data source\n - Changes: major\n - Add step: \"Search tech news sites for announcements\"\n - Continue: true (with new approach)\n </Examples>\n\n <ContextAwareness>\n You have access to:\n - Original user request\n - Initial understanding and success criteria\n - All previous step results\n - Current variables and gathered data\n - The remaining steps in the plan\n\n Use this to make informed replanning decisions.\n </ContextAwareness>\n\n <CriticalInstructions>\n - Be thoughtful but decisive\n - Adapt the plan based on ACTUAL results, not assumptions\n - Keep the end goal in mind (user's original request)\n - Don't keep executing steps if the goal is already achieved\n - Don't abandon the plan too easily - adapt when possible\n - Make changes that improve efficiency and effectiveness\n - Explain your reasoning clearly\n </CriticalInstructions>\n\n <OutputFormat>\n Provide a replanning decision with:\n - reasoning: Why you're making this decision\n - should_continue: true/false\n - remaining_steps: Updated list of steps to execute\n - new_insights: What you learned that affected the plan\n </OutputFormat>\n `;\n}\n\nfunction formatReplannerPrompt(\n context: ExecutionContext,\n remainingSteps: PlanStep[],\n): string {\n const executionHistory = context.step_results\n .map((r, i) => `Step ${i}: ${r}`)\n .join('\\n');\n\n return `\n<OriginalRequest>${context.original_request}</OriginalRequest>\n\n<Understanding>${context.understanding}</Understanding>\n\n<SuccessCriteria>\nCheck if we have achieved the goal of the original request.\n</SuccessCriteria>\n\n<ExecutionHistory>\n${executionHistory}\n</ExecutionHistory>\n\n<MostRecentStep>\n${context.step_results.at(-1) ?? 'No steps executed yet'}\n</MostRecentStep>\n\n<CurrentVariables>\n${JSON.stringify(context.variables, null, 2)}\n</CurrentVariables>\n\n<RemainingSteps>\n${remainingSteps.length > 0 ? remainingSteps.map((s, i) => `${i}. ${s.description} (Expected: ${s.expected_outcome})`).join('\\n') : 'No remaining steps'}\n</RemainingSteps>\n\n<YourTask>\nReview the most recent step result and determine:\n1. Should we continue execution?\n2. Does the plan need adjustment based on what we found?\n3. What should the remaining steps be?\n\nConsider:\n- Did we find what we were looking for?\n- Is the goal achievable with the current approach?\n- Do results suggest a better path forward?\n- Have we already met the success criteria?\n</YourTask>\n `.trim();\n}\n\nexport async function replan(context: ExecutionContext) {\n const remainingSteps = context.current_plan.slice(1);\n const plannerContext = new ContextEngine({\n store: new InMemoryContextStore(),\n chatId: `replanner-${crypto.randomUUID()}`,\n userId: 'system',\n });\n\n plannerContext.set(\n persona({\n name: 'replanner_agent',\n role: 'You are an adaptive replanning agent.',\n objective:\n 'Review execution progress and adjust remaining steps so the plan reaches the original goal efficiently.',\n }),\n fragment('replanner_instructions', createReplannerPrompt()),\n user(formatReplannerPrompt(context, remainingSteps)),\n );\n\n const replannerOutput = structuredOutput({\n model: replannerModel,\n context: plannerContext,\n schema: ReplanDecisionSchema,\n });\n\n const decision = await replannerOutput.generate();\n return {\n ...context,\n current_plan: decision.remaining_steps,\n is_complete: !decision.should_continue,\n };\n}\n", "import { groq } from '@ai-sdk/groq';\nimport { defaultSettingsMiddleware, wrapLanguageModel } from 'ai';\n\nimport { agent } from '@deepagents/agent';\nimport { scratchpad_tool, search_content_tool } from '@deepagents/toolbox';\n\nimport type { PlanStep, PlannerOutput } from '../planner-agent.ts';\n\n/**\n * Executor Agent\n *\n * Executes individual plan steps while:\n * 1. Tracking what information is gathered\n * 2. Extracting numerical variables from results\n * 3. Calculating intermediate results with attention to accuracy\n * 4. Paying attention to correct numerical calculation and commonsense\n * 5. Making observations about findings\n * 6. Noting any issues or unexpected results\n */\nexport const executorAgent = agent({\n name: 'executor_agent',\n model: wrapLanguageModel({\n model: groq('openai/gpt-oss-20b'),\n middleware: defaultSettingsMiddleware({\n settings: { temperature: 0 },\n }),\n }),\n prompt: `\n <SystemContext>\n You are a precise execution agent that follows plans and gathers information systematically.\n You pay close attention to details and track what you find.\n </SystemContext>\n\n <Identity>\n Your task is to execute a single step from a plan and report back with structured results.\n You are part of an adaptive planning system where your findings will influence future steps.\n </Identity>\n\n <ExecutionPrinciples>\n 1. **Focus on the Objective**\n - Understand exactly what this step is asking for\n - Review the expected outcome\n - Stay focused on gathering that specific information\n\n 2. **Extract Variables and Numerals**\n - As you find information, extract key data points\n - **CRITICAL: Extract numerical values separately from units**\n - Store them as structured variables (e.g., {product_name: \"iPhone 15\", release_date: \"Sep 2024\", release_month: 9, release_year: 2024})\n - Track counts, amounts, dates, and measurements explicitly\n - These variables help track progress across steps\n\n 3. **Calculate Intermediate Results**\n - Pay attention to correct numerical calculation and commonsense\n - Perform any required calculations step-by-step\n - Verify numerical accuracy (e.g., date ranges, counts, sums)\n - Check results against common sense (e.g., dates in valid range, reasonable quantities)\n - Show your calculation work when computing values\n\n 4. **Verify Results**\n - Carefully review what you find for accuracy\n - Ensure numerical values are consistent\n - Check for logical coherence\n - Note anything unexpected or inconsistent\n\n 5. **Make Observations**\n - What patterns did you notice?\n - What numerical trends are apparent?\n - What might affect subsequent steps?\n\n 6. **Note Issues**\n - Were there any calculation difficulties?\n - Was the information hard to find?\n - Were there any errors or ambiguities?\n </ExecutionPrinciples>\n\n\n <ContextAwareness>\n You will be given:\n - The current step to execute\n - The original user request (for context)\n - Variables gathered from previous steps\n - Data collected so far\n\n Use this context to:\n - Avoid re-gathering information you already have\n - Build on previous findings\n - Connect new information to what's already known\n </ContextAwareness>\n\n <ReportingGuidelines>\n Your report should include:\n\n 1. **Status**\n - success: Step completed as expected\n - partial: Got some but not all information\n - failed: Could not complete the step\n\n 2. **Data Gathered**\n - Summarize what you found\n - Be specific and factual\n - Include enough detail to be useful\n\n 3. **Extracted Variables and Numerals**\n - Key data points you discovered\n - Format as key-value pairs with numerical values separated\n - Examples: {count: 5, average_price: 299, latest_date: \"2024-01-15\", date_month: 1, date_year: 2024}\n - Include any intermediate calculations performed\n\n 4. **Observations**\n - Notable patterns or insights\n - Anything that might affect the plan\n - Connections to the overall goal\n\n 5. **Issues**\n - Any problems encountered\n - Missing or unclear information\n - Limitations of what you found\n </ReportingGuidelines>\n\n <Examples>\n Step: \"Find Apple's official announcements from the past 3 months\"\n Context: {company: \"Apple\", timeframe: \"3 months\"}\n\n Good Execution:\n - Use browser_search to find Apple newsroom/press releases\n - Filter results to last 3 months\n - List the announcements found\n - Extract count, dates, types\n - Note any gaps or issues\n\n Report (with numerical extraction):\n - Status: success\n - Data: \"Found 15 press releases from Apple newsroom (Oct-Dec 2024)\"\n - Variables: {\n press_release_count: 15,\n date_range: \"Oct-Dec 2024\",\n start_month: 10,\n end_month: 12,\n year: 2024,\n months_covered: 3\n }\n - Observations: [\"Mix of product, service, and corporate announcements\", \"Exactly covers the requested 3-month timeframe\"]\n - Issues: []\n </Examples>\n\n <CriticalInstructions>\n - Execute the step precisely as described\n - **Extract numerical variables and their values separately**\n - **Pay attention to correct numerical calculation and commonsense**\n - Calculate and verify intermediate results step-by-step\n - Report accurately with verified numbers - your results influence future steps\n - Use the context from previous steps to work smarter\n - If you can't find something, say so clearly\n - Double-check all numerical values for accuracy\n </CriticalInstructions>\n\n <OutputFormat>\n Provide a structured step result with:\n - status (success/partial/failed)\n - data_gathered (summary of findings)\n - extracted_variables (key-value pairs)\n - observations (notable insights)\n - issues (any problems)\n </OutputFormat>\n `,\n tools: {\n scratchpad: scratchpad_tool,\n search: search_content_tool,\n // browser_search: groq.tools.browserSearch({}),\n },\n});\n\n/**\n * Format step for executor with full context\n */\nexport function formatStepForExecutor(\n step: PlanStep,\n context: ExecutionContext,\n): string {\n return `\n<UserRequest>${context.original_request}</UserRequest>\n\n<Understanding>${context.understanding}</Understanding>\n\n<CurrentVariables>\n${JSON.stringify(context.variables, null, 2)}\n</CurrentVariables>\n\n<PreviousSteps>\n${context.step_results.length ? context.step_results.map((result, i) => `Step ${i + 1}: ${result}`).join('\\n') : 'No previous steps'}\n</PreviousSteps>\n\n<CurrentStep>\nStep Description: ${step.description}\nExpected Outcome: ${step.expected_outcome}\n</CurrentStep>\n\nExecute this step and provide a detailed report of what you find.\n `.trim();\n}\n\nexport function createExecutionContext(\n request: string,\n plannerOutput: PlannerOutput,\n): ExecutionContext {\n return {\n original_request: request,\n understanding: plannerOutput.understanding,\n initial_plan: plannerOutput.steps,\n current_plan: [...plannerOutput.steps],\n variables: { ...plannerOutput.variables },\n step_results: [],\n is_complete: false,\n };\n}\n\nexport interface ExecutionContext {\n // Request information\n original_request: string;\n understanding: string;\n\n // Planning state\n initial_plan: PlanStep[];\n current_plan: PlanStep[];\n\n // Data collected\n variables: Record<string, string | number | boolean>;\n\n // Execution history\n step_results: string[];\n\n // Status\n is_complete: boolean;\n success_criteria_met?: boolean;\n}\n"],
5
- "mappings": ";AAAA,SAAS,6BAAAA,4BAA2B,qBAAAC,0BAAyB;AAC7D,OAAO,OAAO;AAEd,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACZP,SAAS,YAAY;AACrB,SAAS,2BAA2B,yBAAyB;AAE7D,SAAS,aAAa;AACtB,SAAS,iBAAiB,2BAA2B;AAe9C,IAAM,gBAAgB,MAAM;AAAA,EACjC,MAAM;AAAA,EACN,OAAO,kBAAkB;AAAA,IACvB,OAAO,KAAK,oBAAoB;AAAA,IAChC,YAAY,0BAA0B;AAAA,MACpC,UAAU,EAAE,aAAa,EAAE;AAAA,IAC7B,CAAC;AAAA,EACH,CAAC;AAAA,EACD,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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SAAS,IAAI,eAAe,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,KAAK,EAAE,WAAW,eAAe,EAAE,gBAAgB,GAAG,EAAE,KAAK,IAAI,IAAI,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAepJ,KAAK;AACT;AAEA,eAAsB,OAAO,SAA2B;AACtD,QAAM,iBAAiB,QAAQ,aAAa,MAAM,CAAC;AACnD,QAAM,iBAAiB,IAAI,cAAc;AAAA,IACvC,OAAO,IAAI,qBAAqB;AAAA,IAChC,QAAQ,aAAa,OAAO,WAAW,CAAC;AAAA,IACxC,QAAQ;AAAA,EACV,CAAC;AAED,iBAAe;AAAA,IACb,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WACE;AAAA,IACJ,CAAC;AAAA,IACD,SAAS,0BAA0B,sBAAsB,CAAC;AAAA,IAC1D,KAAK,sBAAsB,SAAS,cAAc,CAAC;AAAA,EACrD;AAEA,QAAM,kBAAkB,iBAAiB;AAAA,IACvC,OAAO;AAAA,IACP,SAAS;AAAA,IACT,QAAQ;AAAA,EACV,CAAC;AAED,QAAM,WAAW,MAAM,gBAAgB,SAAS;AAChD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,cAAc,SAAS;AAAA,IACvB,aAAa,CAAC,SAAS;AAAA,EACzB;AACF;",
6
- "names": ["defaultSettingsMiddleware", "wrapLanguageModel", "wrapLanguageModel", "defaultSettingsMiddleware"]
3
+ "sources": ["../../../src/lib/deepplan/replanner-agent.ts"],
4
+ "sourcesContent": ["import { defaultSettingsMiddleware, wrapLanguageModel } from 'ai';\nimport z from 'zod';\n\nimport { lmstudio } from '@deepagents/agent';\nimport {\n ContextEngine,\n InMemoryContextStore,\n createBashTool,\n fragment,\n persona,\n structuredOutput,\n user,\n} from '@deepagents/context';\n\nimport { type ExecutionContext } from './executors/generic-executor.ts';\nimport type { PlanStep } from './planner-agent.ts';\n\nconst PlanStepSchema = z.object({\n description: z\n .string()\n .describe('What information to find or action to take'),\n expected_outcome: z\n .string()\n .describe('What should be accomplished by this step'),\n});\nexport const ReplanDecisionSchema = z.object({\n reasoning: z.string().describe('Why this replanning decision was made'),\n should_continue: z.boolean().describe('Should we continue executing?'),\n remaining_steps: z\n .array(PlanStepSchema)\n .max(4)\n .describe('Updated list of remaining steps'),\n new_insights: z\n .string()\n .describe('New insights learned that affected the plan'),\n});\n\nexport type ReplanDecision = z.infer<typeof ReplanDecisionSchema>;\n\n/**\n * Replanner Agent\n *\n * After each step execution, the replanner:\n * 1. Reviews what was accomplished vs what was expected\n * 2. Analyzes how this affects the remaining plan\n * 3. Decides if the plan needs adjustment\n * 4. Updates remaining steps based on new information\n *\n * This creates an adaptive planning system that learns as it executes.\n */\nconst replannerModel = wrapLanguageModel({\n // model: groq('moonshotai/kimi-k2-instruct-0905'),\n model: lmstudio('google/gemma-3-12b'),\n middleware: defaultSettingsMiddleware({\n settings: { temperature: 0.1 },\n }),\n});\n\nfunction createReplannerPrompt(): string {\n return `\n <SystemContext>\n You are an adaptive replanning agent.\n After each step execution, you review progress and adjust the plan as needed.\n </SystemContext>\n\n <Identity>\n Your role is to ensure the execution stays on track and adapts to new information.\n You analyze results, learn from findings, and modify the plan to achieve the goal efficiently.\n </Identity>\n\n <ReplanningPrinciples>\n 1. **Review Results**\n - What was the step supposed to accomplish?\n - What was actually accomplished?\n - Was it successful, partial, or failed?\n\n 2. **Analyze Impact**\n - How do these results affect the overall goal?\n - What did we learn that we didn't know before?\n - Does this change what we need to do next?\n\n 3. **Assess Remaining Plan**\n - Are the remaining steps still appropriate?\n - Do we need additional steps?\n - Can we skip any steps?\n - Should we change the order?\n\n 4. **Make Decisions**\n - Should we continue with the plan?\n - What adjustments are needed?\n - How significant are the changes?\n\n 5. **Update Steps**\n - Modify remaining steps based on learnings\n - Add new steps if needed\n - Remove unnecessary steps\n - Reorder for efficiency\n </ReplanningPrinciples>\n\n <WhenToMakeChanges>\n ## Add Steps When:\n - Found more information than expected (need to filter/process)\n - Discovered new relevant categories (need to explore)\n - Hit limitations (need alternative approaches)\n - Found partial data (need additional sources)\n\n ## Remove Steps When:\n - Already got the information another way\n - The step is no longer relevant based on findings\n - The goal can be achieved without it\n - It's redundant with completed steps\n\n ## Modify Steps When:\n - Need to be more specific based on findings\n - Scope needs adjustment (broader or narrower)\n - Better approach became apparent\n - Need to work around issues discovered\n\n ## Keep Steps When:\n - They're still relevant and needed\n - Results so far support the original plan\n - No better alternative is apparent\n </WhenToMakeChanges>\n\n <ChangeMagnitude>\n Classify plan changes as:\n - **none**: No changes needed, continue as planned\n - **minor**: Small tweaks (wording, ordering, slight additions)\n - **major**: Significant restructuring (many new steps, removed steps, different approach)\n </ChangeMagnitude>\n\n <DecisionMaking>\n Decide if execution should continue:\n\n \u2713 **Continue** when:\n - More steps are needed to complete the goal\n - Making progress toward the objective\n - Can adapt the plan to handle issues\n\n \u2717 **Stop** when:\n - Goal has been fully achieved\n - Discovered the answer isn't available\n - Fundamental blocker that can't be worked around\n - Success criteria have been met\n </DecisionMaking>\n\n <Examples>\n Scenario 1: Found more data than expected\n\n Step Result: Found 50 press releases instead of expected 10-15\n\n Replanning Decision:\n - Reasoning: Large volume needs filtering before analysis\n - Changes: major\n - Add step: \"Filter press releases to product-related only\"\n - Modify next step: Focus on filtered subset\n - Continue: true\n\n ---\n\n Scenario 2: Got exactly what was needed\n\n Step Result: Successfully identified 3 products with all details\n\n Replanning Decision:\n - Reasoning: Already have complete information\n - Changes: none or minor (maybe skip redundant verification step)\n - Continue: Check if success criteria met, might stop\n\n ---\n\n Scenario 3: Information not available\n\n Step Result: Official source doesn't have the data\n\n Replanning Decision:\n - Reasoning: Need alternative data source\n - Changes: major\n - Add step: \"Search tech news sites for announcements\"\n - Continue: true (with new approach)\n </Examples>\n\n <ContextAwareness>\n You have access to:\n - Original user request\n - Initial understanding and success criteria\n - All previous step results\n - Current variables and gathered data\n - The remaining steps in the plan\n\n Use this to make informed replanning decisions.\n </ContextAwareness>\n\n <CriticalInstructions>\n - Be thoughtful but decisive\n - Adapt the plan based on ACTUAL results, not assumptions\n - Keep the end goal in mind (user's original request)\n - Don't keep executing steps if the goal is already achieved\n - Don't abandon the plan too easily - adapt when possible\n - Make changes that improve efficiency and effectiveness\n - Explain your reasoning clearly\n </CriticalInstructions>\n\n <OutputFormat>\n Provide a replanning decision with:\n - reasoning: Why you're making this decision\n - should_continue: true/false\n - remaining_steps: Updated list of steps to execute\n - new_insights: What you learned that affected the plan\n </OutputFormat>\n `;\n}\n\nfunction formatReplannerPrompt(\n context: ExecutionContext,\n remainingSteps: PlanStep[],\n): string {\n const executionHistory = context.step_results\n .map((r, i) => `Step ${i}: ${r}`)\n .join('\\n');\n\n return `\n<OriginalRequest>${context.original_request}</OriginalRequest>\n\n<Understanding>${context.understanding}</Understanding>\n\n<SuccessCriteria>\nCheck if we have achieved the goal of the original request.\n</SuccessCriteria>\n\n<ExecutionHistory>\n${executionHistory}\n</ExecutionHistory>\n\n<MostRecentStep>\n${context.step_results.at(-1) ?? 'No steps executed yet'}\n</MostRecentStep>\n\n<CurrentVariables>\n${JSON.stringify(context.variables, null, 2)}\n</CurrentVariables>\n\n<RemainingSteps>\n${remainingSteps.length > 0 ? remainingSteps.map((s, i) => `${i}. ${s.description} (Expected: ${s.expected_outcome})`).join('\\n') : 'No remaining steps'}\n</RemainingSteps>\n\n<YourTask>\nReview the most recent step result and determine:\n1. Should we continue execution?\n2. Does the plan need adjustment based on what we found?\n3. What should the remaining steps be?\n\nConsider:\n- Did we find what we were looking for?\n- Is the goal achievable with the current approach?\n- Do results suggest a better path forward?\n- Have we already met the success criteria?\n</YourTask>\n `.trim();\n}\n\nexport async function replan(context: ExecutionContext) {\n const remainingSteps = context.current_plan.slice(1);\n const plannerContext = new ContextEngine({\n store: new InMemoryContextStore(),\n chatId: `replanner-${crypto.randomUUID()}`,\n userId: 'system',\n });\n\n plannerContext.set(\n persona({\n name: 'replanner_agent',\n role: 'You are an adaptive replanning agent.',\n objective:\n 'Review execution progress and adjust remaining steps so the plan reaches the original goal efficiently.',\n }),\n fragment('replanner_instructions', createReplannerPrompt()),\n user(formatReplannerPrompt(context, remainingSteps)),\n );\n\n const replannerOutput = structuredOutput({\n model: replannerModel,\n context: plannerContext,\n schema: ReplanDecisionSchema,\n });\n\n const decision = await replannerOutput.generate();\n return {\n ...context,\n current_plan: decision.remaining_steps,\n is_complete: !decision.should_continue,\n };\n}\n"],
5
+ "mappings": ";AAAA,SAAS,2BAA2B,yBAAyB;AAC7D,OAAO,OAAO;AAEd,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKP,IAAM,iBAAiB,EAAE,OAAO;AAAA,EAC9B,aAAa,EACV,OAAO,EACP,SAAS,4CAA4C;AAAA,EACxD,kBAAkB,EACf,OAAO,EACP,SAAS,0CAA0C;AACxD,CAAC;AACM,IAAM,uBAAuB,EAAE,OAAO;AAAA,EAC3C,WAAW,EAAE,OAAO,EAAE,SAAS,uCAAuC;AAAA,EACtE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,+BAA+B;AAAA,EACrE,iBAAiB,EACd,MAAM,cAAc,EACpB,IAAI,CAAC,EACL,SAAS,iCAAiC;AAAA,EAC7C,cAAc,EACX,OAAO,EACP,SAAS,6CAA6C;AAC3D,CAAC;AAeD,IAAM,iBAAiB,kBAAkB;AAAA;AAAA,EAEvC,OAAO,SAAS,oBAAoB;AAAA,EACpC,YAAY,0BAA0B;AAAA,IACpC,UAAU,EAAE,aAAa,IAAI;AAAA,EAC/B,CAAC;AACH,CAAC;AAED,SAAS,wBAAgC;AACvC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAS,IAAI,eAAe,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,KAAK,EAAE,WAAW,eAAe,EAAE,gBAAgB,GAAG,EAAE,KAAK,IAAI,IAAI,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAepJ,KAAK;AACT;AAEA,eAAsB,OAAO,SAA2B;AACtD,QAAM,iBAAiB,QAAQ,aAAa,MAAM,CAAC;AACnD,QAAM,iBAAiB,IAAI,cAAc;AAAA,IACvC,OAAO,IAAI,qBAAqB;AAAA,IAChC,QAAQ,aAAa,OAAO,WAAW,CAAC;AAAA,IACxC,QAAQ;AAAA,EACV,CAAC;AAED,iBAAe;AAAA,IACb,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WACE;AAAA,IACJ,CAAC;AAAA,IACD,SAAS,0BAA0B,sBAAsB,CAAC;AAAA,IAC1D,KAAK,sBAAsB,SAAS,cAAc,CAAC;AAAA,EACrD;AAEA,QAAM,kBAAkB,iBAAiB;AAAA,IACvC,OAAO;AAAA,IACP,SAAS;AAAA,IACT,QAAQ;AAAA,EACV,CAAC;AAED,QAAM,WAAW,MAAM,gBAAgB,SAAS;AAChD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,cAAc,SAAS;AAAA,IACvB,aAAa,CAAC,SAAS;AAAA,EACzB;AACF;",
6
+ "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepagents/orchestrator",
3
- "version": "7.30.0",
3
+ "version": "7.30.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,15 +38,13 @@
38
38
  "access": "public"
39
39
  },
40
40
  "dependencies": {
41
- "@deepagents/agent": "7.30.0",
42
- "@deepagents/context": "7.30.0",
41
+ "@deepagents/agent": "7.30.2",
42
+ "@deepagents/context": "7.30.2",
43
43
  "@ai-sdk/groq": "^4.0.78",
44
44
  "@ai-sdk/openai": "^4.0.111",
45
45
  "ai": "^7.0.166",
46
46
  "zod": "^4.6.7",
47
- "lodash-es": "^4.18.1",
48
- "@deepagents/retrieval": "7.30.0",
49
- "@deepagents/toolbox": "7.30.0",
47
+ "@deepagents/toolbox": "7.30.2",
50
48
  "p-limit": "^7.3.0",
51
49
  "@tavily/core": "^0.7.6",
52
50
  "dedent": "^1.7.2"
@@ -1,14 +0,0 @@
1
- type ArxivAgentContext = {
2
- pdf_url: string;
3
- store_path: string;
4
- };
5
- export declare function queryArxivPaper(query: string, pdfUrl: string, storePath: string): Promise<{
6
- content: string;
7
- document_id: string;
8
- metadata: Record<string, unknown> | null;
9
- similarity: number;
10
- distance: number;
11
- }[]>;
12
- export declare const arxivAgent: import("@deepagents/agent").Agent<unknown, ArxivAgentContext, ArxivAgentContext>;
13
- export {};
14
- //# sourceMappingURL=arxiv.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arxiv.d.ts","sources":["../../../src/lib/arxiv/arxiv.ts"],"names":[],"mappings":"AAkCA,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM;;;;;;KASlB;AAyDD,eAAO,MAAM,UAAU,kFAiBrB,CAAC"}
@@ -1,145 +0,0 @@
1
- // packages/orchestrator/src/lib/arxiv/arxiv.ts
2
- import { openai } from "@ai-sdk/openai";
3
- import { tool } from "ai";
4
- import { z } from "zod";
5
- import { agent, execute, input, instructions, user } from "@deepagents/agent";
6
- import {
7
- fastembed,
8
- nodeSQLite,
9
- similaritySearch
10
- } from "@deepagents/retrieval";
11
- import { pdfFile } from "@deepagents/retrieval/connectors";
12
- var QueryPaperSchema = z.object({
13
- query: z.string().min(1).describe("The question to ask about the paper")
14
- });
15
- var PaperSummarySchema = z.object({
16
- title: z.string().describe("Paper title"),
17
- abstract: z.string().describe("Paper abstract or overview"),
18
- main_contribution: z.string().describe("Main contribution of the paper"),
19
- methodology: z.string().describe("Key methodology or approach used"),
20
- key_results: z.string().describe("Main results and findings"),
21
- limitations: z.string().optional().describe("Limitations mentioned in the paper"),
22
- future_work: z.string().optional().describe("Future work suggestions")
23
- });
24
- async function queryArxivPaper(query, pdfUrl, storePath) {
25
- const results = await similaritySearch(query, {
26
- connector: pdfFile(pdfUrl),
27
- store: nodeSQLite(storePath, 384),
28
- embedder: fastembed()
29
- });
30
- return results.slice(0, 5);
31
- }
32
- var queryPaperTool = tool({
33
- description: "Query the ingested arXiv paper using semantic search. Returns relevant sections from the paper.",
34
- inputSchema: QueryPaperSchema,
35
- execute: async ({ query }, { context }) => {
36
- try {
37
- const results = await queryArxivPaper(
38
- query,
39
- context.pdf_url,
40
- context.store_path
41
- );
42
- if (results.length === 0) {
43
- return "No relevant information found in the paper.";
44
- }
45
- const formattedResults = results.map(
46
- (r, i) => `[Chunk ${i + 1}] (similarity: ${r.similarity.toFixed(3)})
47
- ${r.content}
48
- `
49
- ).join("\n---\n\n");
50
- return formattedResults;
51
- } catch (error) {
52
- return `Error querying paper: ${Error.isError(error) ? error.message : "Unknown error"}`;
53
- }
54
- }
55
- });
56
- var summarizerAgent = agent({
57
- name: "paper_summarizer",
58
- model: openai("gpt-4.1-nano"),
59
- output: PaperSummarySchema,
60
- prompt: instructions({
61
- purpose: [
62
- "You are a research paper analyst.",
63
- "Given relevant sections from an academic paper, extract and summarize key information."
64
- ],
65
- routine: [
66
- "Read through the provided paper sections carefully",
67
- "Extract the title, abstract, main contribution, methodology, key results, and any limitations",
68
- "If certain sections are not available, infer from context or leave blank",
69
- "Return a structured summary following the schema"
70
- ]
71
- })
72
- });
73
- var arxivAgent = agent({
74
- name: "arxiv_researcher",
75
- model: openai("gpt-4o"),
76
- prompt: instructions({
77
- purpose: [
78
- "You are an arXiv research assistant.",
79
- "You help users analyze academic papers by ingesting PDFs and answering questions about them."
80
- ],
81
- routine: [
82
- "Answer questions about the paper using the query_paper tool to find relevant sections",
83
- "Synthesize information from multiple chunks to provide comprehensive answers",
84
- "When asked for a summary, gather relevant information and provide a structured overview"
85
- ]
86
- }),
87
- tools: {
88
- query_paper: queryPaperTool
89
- }
90
- });
91
- if (import.meta.main) {
92
- console.log("<\uFFFD ArXiv Research Assistant\n");
93
- const pdfUrl = await input("https://arxiv.org/pdf/2103.00020.pdf");
94
- const url = pdfUrl.trim();
95
- console.log(`
96
- Using URL: ${url}
97
- `);
98
- const context = {
99
- pdf_url: url,
100
- store_path: "./arxiv_papers.db"
101
- };
102
- console.log("\nPaper ready for questions!\n");
103
- console.log("Example questions:");
104
- console.log(" - What is the main contribution of this paper?");
105
- console.log(" - Explain the methodology used");
106
- console.log(" - What are the key results?");
107
- console.log(" - What are the limitations mentioned?\n");
108
- while (true) {
109
- const question = await input('\nYour question (or "quit" to exit): ');
110
- if (question.toLowerCase() === "quit" || question.toLowerCase() === "exit") {
111
- console.log("\n=K Goodbye!");
112
- break;
113
- }
114
- if (!question.trim()) {
115
- continue;
116
- }
117
- console.log("\n> Searching paper...\n");
118
- const results = await queryArxivPaper(question, url, context.store_path);
119
- if (results.length === 0) {
120
- console.log("L No relevant information found.\n");
121
- continue;
122
- }
123
- const answer = (await execute(
124
- arxivAgent,
125
- [
126
- user(
127
- `Based on these sections from the paper, answer: ${question}
128
-
129
- Sections:
130
- ${results.map((r) => r.content).join("\n\n")}`
131
- )
132
- ],
133
- context
134
- )).text;
135
- console.log(`
136
- =\uFFFD Answer:
137
- ${answer}
138
- `);
139
- }
140
- }
141
- export {
142
- arxivAgent,
143
- queryArxivPaper
144
- };
145
- //# sourceMappingURL=arxiv.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/lib/arxiv/arxiv.ts"],
4
- "sourcesContent": ["import { openai } from '@ai-sdk/openai';\nimport { type ToolExecutionOptions, tool } from 'ai';\nimport { z } from 'zod';\n\nimport { agent, execute, input, instructions, user } from '@deepagents/agent';\nimport {\n fastembed,\n ingest,\n nodeSQLite,\n similaritySearch,\n} from '@deepagents/retrieval';\nimport { pdfFile } from '@deepagents/retrieval/connectors';\n\nconst QueryPaperSchema = z.object({\n query: z.string().min(1).describe('The question to ask about the paper'),\n});\n\nconst PaperSummarySchema = z.object({\n title: z.string().describe('Paper title'),\n abstract: z.string().describe('Paper abstract or overview'),\n main_contribution: z.string().describe('Main contribution of the paper'),\n methodology: z.string().describe('Key methodology or approach used'),\n key_results: z.string().describe('Main results and findings'),\n limitations: z\n .string()\n .optional()\n .describe('Limitations mentioned in the paper'),\n future_work: z.string().optional().describe('Future work suggestions'),\n});\n\n// ============================\n// State Management\n// ============================\n\ntype ArxivAgentContext = {\n pdf_url: string;\n store_path: string;\n};\n\nexport async function queryArxivPaper(\n query: string,\n pdfUrl: string,\n storePath: string,\n) {\n const results = await similaritySearch(query, {\n connector: pdfFile(pdfUrl),\n store: nodeSQLite(storePath, 384),\n embedder: fastembed(),\n });\n\n return results.slice(0, 5);\n}\n\nconst queryPaperTool = tool({\n description:\n 'Query the ingested arXiv paper using semantic search. Returns relevant sections from the paper.',\n inputSchema: QueryPaperSchema,\n execute: async (\n { query },\n { context }: ToolExecutionOptions<ArxivAgentContext>,\n ) => {\n try {\n const results = await queryArxivPaper(\n query,\n context.pdf_url,\n context.store_path,\n );\n\n if (results.length === 0) {\n return 'No relevant information found in the paper.';\n }\n\n const formattedResults = results\n .map(\n (r, i) =>\n `[Chunk ${i + 1}] (similarity: ${r.similarity.toFixed(3)})\\n${r.content}\\n`,\n )\n .join('\\n---\\n\\n');\n\n return formattedResults;\n } catch (error) {\n return `Error querying paper: ${Error.isError(error) ? error.message : 'Unknown error'}`;\n }\n },\n});\n\n// ============================\n// Agents\n// ============================\n\nconst summarizerAgent = agent({\n name: 'paper_summarizer',\n model: openai('gpt-4.1-nano'),\n output: PaperSummarySchema,\n prompt: instructions({\n purpose: [\n 'You are a research paper analyst.',\n 'Given relevant sections from an academic paper, extract and summarize key information.',\n ],\n routine: [\n 'Read through the provided paper sections carefully',\n 'Extract the title, abstract, main contribution, methodology, key results, and any limitations',\n 'If certain sections are not available, infer from context or leave blank',\n 'Return a structured summary following the schema',\n ],\n }),\n});\n\nexport const arxivAgent = agent<unknown, ArxivAgentContext>({\n name: 'arxiv_researcher',\n model: openai('gpt-4o'),\n prompt: instructions({\n purpose: [\n 'You are an arXiv research assistant.',\n 'You help users analyze academic papers by ingesting PDFs and answering questions about them.',\n ],\n routine: [\n 'Answer questions about the paper using the query_paper tool to find relevant sections',\n 'Synthesize information from multiple chunks to provide comprehensive answers',\n 'When asked for a summary, gather relevant information and provide a structured overview',\n ],\n }),\n tools: {\n query_paper: queryPaperTool,\n },\n});\n\n// ============================\n// Interactive Example\n// ============================\n\nif (import.meta.main) {\n console.log('<\uFFFD ArXiv Research Assistant\\n');\n\n // Get PDF URL from user\n const pdfUrl = await input('https://arxiv.org/pdf/2103.00020.pdf');\n const url = pdfUrl.trim();\n\n console.log(`\\nUsing URL: ${url}\\n`);\n\n // Initialize context\n const context: ArxivAgentContext = {\n pdf_url: url,\n store_path: './arxiv_papers.db',\n };\n\n console.log('\\nPaper ready for questions!\\n');\n console.log('Example questions:');\n console.log(' - What is the main contribution of this paper?');\n console.log(' - Explain the methodology used');\n console.log(' - What are the key results?');\n console.log(' - What are the limitations mentioned?\\n');\n\n // Interactive Q&A loop\n while (true) {\n const question = await input('\\nYour question (or \"quit\" to exit): ');\n\n if (\n question.toLowerCase() === 'quit' ||\n question.toLowerCase() === 'exit'\n ) {\n console.log('\\n=K Goodbye!');\n break;\n }\n\n if (!question.trim()) {\n continue;\n }\n\n console.log('\\n> Searching paper...\\n');\n\n const results = await queryArxivPaper(question, url, context.store_path);\n\n if (results.length === 0) {\n console.log('L No relevant information found.\\n');\n continue;\n }\n\n const answer = (\n await execute(\n arxivAgent,\n [\n user(\n `Based on these sections from the paper, answer: ${question}\\n\\nSections:\\n${results.map((r) => r.content).join('\\n\\n')}`,\n ),\n ],\n context,\n )\n ).text;\n\n console.log(`\\n=\uFFFD Answer:\\n${answer}\\n`);\n }\n}\n"],
5
- "mappings": ";AAAA,SAAS,cAAc;AACvB,SAAoC,YAAY;AAChD,SAAS,SAAS;AAElB,SAAS,OAAO,SAAS,OAAO,cAAc,YAAY;AAC1D;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AAExB,IAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,qCAAqC;AACzE,CAAC;AAED,IAAM,qBAAqB,EAAE,OAAO;AAAA,EAClC,OAAO,EAAE,OAAO,EAAE,SAAS,aAAa;AAAA,EACxC,UAAU,EAAE,OAAO,EAAE,SAAS,4BAA4B;AAAA,EAC1D,mBAAmB,EAAE,OAAO,EAAE,SAAS,gCAAgC;AAAA,EACvE,aAAa,EAAE,OAAO,EAAE,SAAS,kCAAkC;AAAA,EACnE,aAAa,EAAE,OAAO,EAAE,SAAS,2BAA2B;AAAA,EAC5D,aAAa,EACV,OAAO,EACP,SAAS,EACT,SAAS,oCAAoC;AAAA,EAChD,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,yBAAyB;AACvE,CAAC;AAWD,eAAsB,gBACpB,OACA,QACA,WACA;AACA,QAAM,UAAU,MAAM,iBAAiB,OAAO;AAAA,IAC5C,WAAW,QAAQ,MAAM;AAAA,IACzB,OAAO,WAAW,WAAW,GAAG;AAAA,IAChC,UAAU,UAAU;AAAA,EACtB,CAAC;AAED,SAAO,QAAQ,MAAM,GAAG,CAAC;AAC3B;AAEA,IAAM,iBAAiB,KAAK;AAAA,EAC1B,aACE;AAAA,EACF,aAAa;AAAA,EACb,SAAS,OACP,EAAE,MAAM,GACR,EAAE,QAAQ,MACP;AACH,QAAI;AACF,YAAM,UAAU,MAAM;AAAA,QACpB;AAAA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IAAI,oBAAoB;AAChC,UAAQ,IAAI,kDAAkD;AAC9D,UAAQ,IAAI,kCAAkC;AAC9C,UAAQ,IAAI,+BAA+B;AAC3C,UAAQ,IAAI,2CAA2C;AAGvD,SAAO,MAAM;AACX,UAAM,WAAW,MAAM,MAAM,uCAAuC;AAEpE,QACE,SAAS,YAAY,MAAM,UAC3B,SAAS,YAAY,MAAM,QAC3B;AACA,cAAQ,IAAI,eAAe;AAC3B;AAAA,IACF;AAEA,QAAI,CAAC,SAAS,KAAK,GAAG;AACpB;AAAA,IACF;AAEA,YAAQ,IAAI,0BAA0B;AAEtC,UAAM,UAAU,MAAM,gBAAgB,UAAU,KAAK,QAAQ,UAAU;AAEvE,QAAI,QAAQ,WAAW,GAAG;AACxB,cAAQ,IAAI,oCAAoC;AAChD;AAAA,IACF;AAEA,UAAM,UACJ,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,QACE;AAAA,UACE,mDAAmD,QAAQ;AAAA;AAAA;AAAA,EAAkB,QAAQ,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC;AAAA,QACzH;AAAA,MACF;AAAA,MACA;AAAA,IACF,GACA;AAEF,YAAQ,IAAI;AAAA;AAAA,EAAiB,MAAM;AAAA,CAAI;AAAA,EACzC;AACF;",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=citation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"citation.d.ts","sources":["../../src/lib/citation.ts"],"names":[],"mappings":""}
@@ -1,117 +0,0 @@
1
- // packages/orchestrator/src/lib/citation.ts
2
- import { groq } from "@ai-sdk/groq";
3
- import { defaultSettingsMiddleware, wrapLanguageModel } from "ai";
4
- import dedent from "dedent";
5
- import { createWriteStream } from "node:fs";
6
- import { cwd } from "node:process";
7
- import { Readable } from "node:stream";
8
- import {
9
- agent,
10
- stepBackPrompt,
11
- stream,
12
- user
13
- } from "@deepagents/agent";
14
- import { repoTree, search_content_tool } from "@deepagents/toolbox";
15
- var CODE_SEARCH_STEP_BACK_EXAMPLES = [
16
- {
17
- originalQuestion: "How to build an agent?",
18
- stepBackQuestion: "What is agent architecture? What are the core components and patterns for building agents?",
19
- stepBackAnswer: "Agent architecture consists of: 1) An agent definition with model and prompt, 2) Tools that provide capabilities, 3) State management for context, 4) A streaming interface for responses. The core pattern involves defining the agent's behavior through prompts and equipping it with tools to accomplish tasks.",
20
- finalAnswer: "Use the agent() function from @deepagents/agent with a prompt, model, and tools. Define the agent's behavior in the prompt and provide tools for specific capabilities."
21
- },
22
- {
23
- originalQuestion: "How does code search work in this codebase?",
24
- stepBackQuestion: "What are the fundamental principles of code search and content retrieval?",
25
- stepBackAnswer: "Code search requires: 1) Keyword-based content search across files, 2) Multiple search iterations with varied terms (broad and specific), 3) Result aggregation and citation tracking, 4) Balancing between high-level concepts and specific implementations.",
26
- finalAnswer: "Search using varied keywords (3-5 searches minimum), combine broad queries (architecture, patterns) with specific queries (class names, function names), and cite all sources."
27
- }
28
- ];
29
- var searchAgent = agent({
30
- name: "search_agent",
31
- model: wrapLanguageModel({
32
- model: groq("openai/gpt-oss-20b"),
33
- middleware: defaultSettingsMiddleware({
34
- settings: { temperature: 0.2 }
35
- })
36
- }),
37
- prompt: dedent`
38
- <context>
39
- This agent is Freya, a code search assistant that searches repositories thoroughly and answers questions with inline citations. This agent speaks in third person, referring to itself as "this agent" or "Freya".
40
- </context>
41
-
42
- <instructions>
43
- <task>
44
- Search the code repository to answer the user's question. All claims must be supported by citations from search results.
45
- </task>
46
-
47
- <strategy>
48
- ${stepBackPrompt("general", {
49
- examples: CODE_SEARCH_STEP_BACK_EXAMPLES,
50
- stepBackQuestionTemplate: "What are the high-level concepts, architectural patterns, and fundamental principles related to this code search question?"
51
- })}
52
-
53
- <search_requirements>
54
- - Conduct minimum 3-5 searches with different keywords and variations
55
- - Use both broad queries (abstractions) and specific queries (details)
56
- - Search for related concepts and alternative implementations
57
- - Before responding, verify: "Has this agent searched enough different ways to be thorough?"
58
- </search_requirements>
59
- </strategy>
60
-
61
- <requirements>
62
- <tool_usage>
63
- - This agent uses search_content_tool to find all information
64
- - This agent only makes claims backed by actual search results - never guesses
65
- - If this agent cannot find sufficient information, it states this clearly
66
- </tool_usage>
67
-
68
- <citation_rules>
69
- Each search result includes a pre-formatted "Citation:" field. This agent must copy it exactly and place it immediately after the supported claim.
70
-
71
- CRITICAL: Never modify the citation format - copy it exactly as provided.
72
- </citation_rules>
73
- </requirements>
74
- </instructions>
75
-
76
- <examples>
77
- <example>
78
- <search_result>
79
- File: packages/agent/src/lib/agent.ts
80
- Citation: [agent.ts](./packages/agent/src/lib/agent.ts)
81
- (followed by code snippet)
82
- </search_result>
83
-
84
- <correct_usage>
85
- "This agent found that the Agent class is defined in the core module [agent.ts](./packages/agent/src/lib/agent.ts)."
86
- </correct_usage>
87
-
88
- <incorrect_usage>
89
- "This agent found info in agent.ts" (missing citation)
90
- "[packages/agent/src/lib/agent.ts]" (wrong format)
91
- </incorrect_usage>
92
- </example>
93
- </examples>
94
-
95
- <quality_checklist>
96
- Before responding, this agent must verify:
97
- ✓ Has this agent searched at least 3-5 times with different queries?
98
- ✓ Are all claims backed by search results?
99
- ✓ Has this agent copied Citation fields exactly from search results?
100
- ✓ Are citations placed immediately after the claims they support?
101
- </quality_checklist>
102
- `,
103
- tools: {
104
- search_content_tool
105
- }
106
- });
107
- var state = {
108
- repo_path: cwd(),
109
- tree: await repoTree(cwd())
110
- };
111
- var result = await stream(
112
- searchAgent,
113
- [user(`How can we build an sqlite readonly agent chatbot?`)],
114
- state
115
- );
116
- Readable.fromWeb(result.textStream).pipe(createWriteStream("output.md"));
117
- //# sourceMappingURL=citation.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/lib/citation.ts"],
4
- "sourcesContent": ["import { groq } from '@ai-sdk/groq';\nimport { defaultSettingsMiddleware, wrapLanguageModel } from 'ai';\nimport dedent from 'dedent';\nimport { createWriteStream } from 'node:fs';\nimport { cwd } from 'node:process';\nimport { Readable } from 'node:stream';\n\nimport {\n type StepBackExample,\n agent,\n stepBackPrompt,\n stream,\n user,\n} from '@deepagents/agent';\nimport { repoTree, search_content_tool } from '@deepagents/toolbox';\n\ntype State = {\n tree: string;\n};\n\nconst CODE_SEARCH_STEP_BACK_EXAMPLES: StepBackExample[] = [\n {\n originalQuestion: 'How to build an agent?',\n stepBackQuestion:\n 'What is agent architecture? What are the core components and patterns for building agents?',\n stepBackAnswer:\n \"Agent architecture consists of: 1) An agent definition with model and prompt, 2) Tools that provide capabilities, 3) State management for context, 4) A streaming interface for responses. The core pattern involves defining the agent's behavior through prompts and equipping it with tools to accomplish tasks.\",\n finalAnswer:\n \"Use the agent() function from @deepagents/agent with a prompt, model, and tools. Define the agent's behavior in the prompt and provide tools for specific capabilities.\",\n },\n {\n originalQuestion: 'How does code search work in this codebase?',\n stepBackQuestion:\n 'What are the fundamental principles of code search and content retrieval?',\n stepBackAnswer:\n 'Code search requires: 1) Keyword-based content search across files, 2) Multiple search iterations with varied terms (broad and specific), 3) Result aggregation and citation tracking, 4) Balancing between high-level concepts and specific implementations.',\n finalAnswer:\n 'Search using varied keywords (3-5 searches minimum), combine broad queries (architecture, patterns) with specific queries (class names, function names), and cite all sources.',\n },\n];\n\nconst searchAgent = agent<unknown, State>({\n name: 'search_agent',\n model: wrapLanguageModel({\n model: groq('openai/gpt-oss-20b'),\n middleware: defaultSettingsMiddleware({\n settings: { temperature: 0.2 },\n }),\n }),\n prompt: dedent`\n<context>\nThis agent is Freya, a code search assistant that searches repositories thoroughly and answers questions with inline citations. This agent speaks in third person, referring to itself as \"this agent\" or \"Freya\".\n</context>\n\n<instructions>\n <task>\n Search the code repository to answer the user's question. All claims must be supported by citations from search results.\n </task>\n\n <strategy>\n ${stepBackPrompt('general', {\n examples: CODE_SEARCH_STEP_BACK_EXAMPLES,\n stepBackQuestionTemplate:\n 'What are the high-level concepts, architectural patterns, and fundamental principles related to this code search question?',\n })}\n\n <search_requirements>\n - Conduct minimum 3-5 searches with different keywords and variations\n - Use both broad queries (abstractions) and specific queries (details)\n - Search for related concepts and alternative implementations\n - Before responding, verify: \"Has this agent searched enough different ways to be thorough?\"\n </search_requirements>\n </strategy>\n\n <requirements>\n <tool_usage>\n - This agent uses search_content_tool to find all information\n - This agent only makes claims backed by actual search results - never guesses\n - If this agent cannot find sufficient information, it states this clearly\n </tool_usage>\n\n <citation_rules>\n Each search result includes a pre-formatted \"Citation:\" field. This agent must copy it exactly and place it immediately after the supported claim.\n\n CRITICAL: Never modify the citation format - copy it exactly as provided.\n </citation_rules>\n </requirements>\n</instructions>\n\n<examples>\n <example>\n <search_result>\n File: packages/agent/src/lib/agent.ts\n Citation: [agent.ts](./packages/agent/src/lib/agent.ts)\n (followed by code snippet)\n </search_result>\n\n <correct_usage>\n \"This agent found that the Agent class is defined in the core module [agent.ts](./packages/agent/src/lib/agent.ts).\"\n </correct_usage>\n\n <incorrect_usage>\n \"This agent found info in agent.ts\" (missing citation)\n \"[packages/agent/src/lib/agent.ts]\" (wrong format)\n </incorrect_usage>\n </example>\n</examples>\n\n<quality_checklist>\nBefore responding, this agent must verify:\n\u2713 Has this agent searched at least 3-5 times with different queries?\n\u2713 Are all claims backed by search results?\n\u2713 Has this agent copied Citation fields exactly from search results?\n\u2713 Are citations placed immediately after the claims they support?\n</quality_checklist>\n\t`,\n tools: {\n search_content_tool,\n },\n});\n\nconst state = {\n repo_path: cwd(),\n tree: await repoTree(cwd()),\n};\n\n// await printer.stdout(\n// stream(searchAgent, [user(`How do I build an agent?`)], state),\n// );\n\nconst result = await stream(\n searchAgent,\n [user(`How can we build an sqlite readonly agent chatbot?`)],\n state,\n);\nReadable.fromWeb(result.textStream).pipe(createWriteStream('output.md'));\n"],
5
- "mappings": ";AAAA,SAAS,YAAY;AACrB,SAAS,2BAA2B,yBAAyB;AAC7D,OAAO,YAAY;AACnB,SAAS,yBAAyB;AAClC,SAAS,WAAW;AACpB,SAAS,gBA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O,UAAU,EAAE,KAAK,kBAAkB,WAAW,CAAC;",
6
- "names": []
7
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Product Manager Executor Agent
3
- *
4
- * Specialized executor that approaches tasks from a Product Management perspective.
5
- * Primary responsibilities:
6
- * 1. Analyzing codebases to understand features and functionality
7
- * 2. Generating comprehensive user stories with acceptance criteria
8
- * 3. Identifying technical dependencies and complexity
9
- * 4. Prioritizing work based on business value and technical constraints
10
- * 5. Creating product documentation that bridges business and technical domains
11
- */
12
- export declare const productManagerExecutor: import("@deepagents/agent").Agent<unknown, import("@deepagents/agent").ContextVariables, import("@deepagents/agent").ContextVariables>;
13
- //# sourceMappingURL=product-manager-executor.d.ts.map