@synergenius/flow-weaver-pack-weaver 0.9.3 → 0.9.5

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 (89) hide show
  1. package/dist/bot/ansi.d.ts +13 -0
  2. package/dist/bot/ansi.d.ts.map +1 -0
  3. package/dist/bot/ansi.js +13 -0
  4. package/dist/bot/ansi.js.map +1 -0
  5. package/dist/bot/assistant-core.d.ts.map +1 -1
  6. package/dist/bot/assistant-core.js +68 -32
  7. package/dist/bot/assistant-core.js.map +1 -1
  8. package/dist/bot/assistant-tools.d.ts +3 -2
  9. package/dist/bot/assistant-tools.d.ts.map +1 -1
  10. package/dist/bot/assistant-tools.js +6 -284
  11. package/dist/bot/assistant-tools.js.map +1 -1
  12. package/dist/bot/conversation-store.d.ts.map +1 -1
  13. package/dist/bot/conversation-store.js +1 -1
  14. package/dist/bot/conversation-store.js.map +1 -1
  15. package/dist/bot/error-classifier.d.ts +27 -0
  16. package/dist/bot/error-classifier.d.ts.map +1 -0
  17. package/dist/bot/error-classifier.js +71 -0
  18. package/dist/bot/error-classifier.js.map +1 -0
  19. package/dist/bot/error-guide.d.ts +2 -7
  20. package/dist/bot/error-guide.d.ts.map +1 -1
  21. package/dist/bot/error-guide.js +2 -31
  22. package/dist/bot/error-guide.js.map +1 -1
  23. package/dist/bot/paths.d.ts +11 -0
  24. package/dist/bot/paths.d.ts.map +1 -0
  25. package/dist/bot/paths.js +26 -0
  26. package/dist/bot/paths.js.map +1 -0
  27. package/dist/bot/response-formatter.d.ts +15 -0
  28. package/dist/bot/response-formatter.d.ts.map +1 -0
  29. package/dist/bot/response-formatter.js +40 -0
  30. package/dist/bot/response-formatter.js.map +1 -0
  31. package/dist/bot/retry-utils.d.ts +2 -16
  32. package/dist/bot/retry-utils.d.ts.map +1 -1
  33. package/dist/bot/retry-utils.js +2 -61
  34. package/dist/bot/retry-utils.js.map +1 -1
  35. package/dist/bot/rich-input.d.ts +39 -0
  36. package/dist/bot/rich-input.d.ts.map +1 -0
  37. package/dist/bot/rich-input.js +308 -0
  38. package/dist/bot/rich-input.js.map +1 -0
  39. package/dist/bot/safety.d.ts +10 -0
  40. package/dist/bot/safety.d.ts.map +1 -0
  41. package/dist/bot/safety.js +14 -0
  42. package/dist/bot/safety.js.map +1 -0
  43. package/dist/bot/slash-commands.d.ts +20 -0
  44. package/dist/bot/slash-commands.d.ts.map +1 -0
  45. package/dist/bot/slash-commands.js +93 -0
  46. package/dist/bot/slash-commands.js.map +1 -0
  47. package/dist/bot/steering.js +2 -2
  48. package/dist/bot/steering.js.map +1 -1
  49. package/dist/bot/task-queue.d.ts.map +1 -1
  50. package/dist/bot/task-queue.js +2 -15
  51. package/dist/bot/task-queue.js.map +1 -1
  52. package/dist/bot/terminal-renderer.d.ts.map +1 -1
  53. package/dist/bot/terminal-renderer.js +12 -13
  54. package/dist/bot/terminal-renderer.js.map +1 -1
  55. package/dist/bot/tool-registry.d.ts +24 -0
  56. package/dist/bot/tool-registry.d.ts.map +1 -0
  57. package/dist/bot/tool-registry.js +458 -0
  58. package/dist/bot/tool-registry.js.map +1 -0
  59. package/dist/bot/weaver-tools.d.ts +2 -2
  60. package/dist/bot/weaver-tools.d.ts.map +1 -1
  61. package/dist/bot/weaver-tools.js +4 -95
  62. package/dist/bot/weaver-tools.js.map +1 -1
  63. package/dist/cli-handlers.d.ts.map +1 -1
  64. package/dist/cli-handlers.js +1 -2
  65. package/dist/cli-handlers.js.map +1 -1
  66. package/dist/node-types/agent-execute.d.ts.map +1 -1
  67. package/dist/node-types/agent-execute.js +4 -8
  68. package/dist/node-types/agent-execute.js.map +1 -1
  69. package/flowweaver.manifest.json +1 -1
  70. package/package.json +1 -1
  71. package/src/bot/ansi.ts +12 -0
  72. package/src/bot/assistant-core.ts +70 -33
  73. package/src/bot/assistant-tools.ts +7 -294
  74. package/src/bot/conversation-store.ts +1 -1
  75. package/src/bot/error-classifier.ts +90 -0
  76. package/src/bot/error-guide.ts +2 -32
  77. package/src/bot/paths.ts +27 -0
  78. package/src/bot/response-formatter.ts +42 -0
  79. package/src/bot/retry-utils.ts +2 -74
  80. package/src/bot/rich-input.ts +307 -0
  81. package/src/bot/safety.ts +16 -0
  82. package/src/bot/slash-commands.ts +114 -0
  83. package/src/bot/steering.ts +2 -2
  84. package/src/bot/task-queue.ts +2 -16
  85. package/src/bot/terminal-renderer.ts +11 -14
  86. package/src/bot/tool-registry.ts +477 -0
  87. package/src/bot/weaver-tools.ts +4 -95
  88. package/src/cli-handlers.ts +1 -2
  89. package/src/node-types/agent-execute.ts +3 -6
@@ -9,101 +9,10 @@
9
9
  import { execFileSync } from 'node:child_process';
10
10
  import { executeStep } from './step-executor.js';
11
11
  import type { ToolDefinition } from '@synergenius/flow-weaver/agent';
12
+ import { BOT_TOOLS as WEAVER_TOOLS } from './tool-registry.js';
13
+ import { isBlockedUrl } from './safety.js';
12
14
 
13
- export const WEAVER_TOOLS: ToolDefinition[] = [
14
- {
15
- name: 'validate',
16
- description: 'Run flow-weaver validate on a workflow file. Returns JSON with errors and warnings. Use this FIRST to discover issues, and AFTER patching to confirm fixes.',
17
- inputSchema: { type: 'object', properties: { file: { type: 'string', description: 'Path to the workflow file to validate' } }, required: ['file'] },
18
- },
19
- {
20
- name: 'read_file',
21
- description: 'Read a file and return its full contents. Use this to understand file structure before patching.',
22
- inputSchema: { type: 'object', properties: { file: { type: 'string', description: 'Path to the file to read' } }, required: ['file'] },
23
- },
24
- {
25
- name: 'patch_file',
26
- description: 'Apply surgical find-and-replace patches to a file. Each patch must have exact "find" and "replace" strings. Preferred over write_file for modifications.',
27
- inputSchema: {
28
- type: 'object',
29
- properties: {
30
- file: { type: 'string', description: 'Path to the file to patch' },
31
- patches: {
32
- type: 'array',
33
- items: {
34
- type: 'object',
35
- properties: {
36
- find: { type: 'string', description: 'Exact string to find' },
37
- replace: { type: 'string', description: 'String to replace with' },
38
- },
39
- required: ['find', 'replace'],
40
- },
41
- description: 'Array of find/replace patches',
42
- },
43
- },
44
- required: ['file', 'patches'],
45
- },
46
- },
47
- {
48
- name: 'run_shell',
49
- description: 'Execute a shell command and return output. Use for: npx flow-weaver validate, git status, etc. Blocked: rm -rf, git push, sudo.',
50
- inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'Shell command to execute' } }, required: ['command'] },
51
- },
52
- {
53
- name: 'list_files',
54
- description: 'List files in a directory, optionally filtered by regex pattern.',
55
- inputSchema: {
56
- type: 'object',
57
- properties: {
58
- directory: { type: 'string', description: 'Directory to list' },
59
- pattern: { type: 'string', description: 'Optional regex filter pattern' },
60
- },
61
- required: ['directory'],
62
- },
63
- },
64
- {
65
- name: 'write_file',
66
- description: 'Write content to a file (creates or overwrites). Use patch_file instead for modifications to existing files.',
67
- inputSchema: {
68
- type: 'object',
69
- properties: {
70
- file: { type: 'string', description: 'Path to the file to write' },
71
- content: { type: 'string', description: 'Complete file content' },
72
- },
73
- required: ['file', 'content'],
74
- },
75
- },
76
- {
77
- name: 'web_fetch',
78
- description: 'Fetch HTTP content. Returns text body (max 10KB).',
79
- inputSchema: { type: 'object', properties: { url: { type: 'string' }, method: { type: 'string', enum: ['GET', 'POST'] } }, required: ['url'] },
80
- },
81
- {
82
- name: 'tsc_check',
83
- description: 'Run TypeScript compiler check (no emit). Returns errors if any.',
84
- inputSchema: { type: 'object', properties: {}, required: [] },
85
- },
86
- {
87
- name: 'run_tests',
88
- description: 'Run project tests. Returns structured results with pass/fail counts.',
89
- inputSchema: { type: 'object', properties: { pattern: { type: 'string', description: 'Test file pattern (optional)' } }, required: [] },
90
- },
91
- {
92
- name: 'ask_user',
93
- description: 'Ask the user a question and wait for response. Use when you need a decision.',
94
- inputSchema: { type: 'object', properties: { question: { type: 'string' } }, required: ['question'] },
95
- },
96
- {
97
- name: 'learn',
98
- description: 'Store a fact for future tasks. Key should be descriptive (e.g. "file:src/agent.ts:port-issue").',
99
- inputSchema: { type: 'object', properties: { key: { type: 'string' }, value: { type: 'string' } }, required: ['key', 'value'] },
100
- },
101
- {
102
- name: 'recall',
103
- description: 'Look up stored knowledge. Returns matching entries.',
104
- inputSchema: { type: 'object', properties: { query: { type: 'string' } }, required: ['query'] },
105
- },
106
- ];
15
+ export { WEAVER_TOOLS };
107
16
 
108
17
  /** Map tool names to step-executor operations. */
109
18
  const OPERATION_MAP: Record<string, string> = {
@@ -129,7 +38,7 @@ export function createWeaverExecutor(projectDir: string) {
129
38
  case 'web_fetch': {
130
39
  const url = String(args.url);
131
40
  // Safety: block localhost, internal IPs
132
- if (/localhost|127\.0\.0\.1|0\.0\.0\.0|10\.\d|172\.(1[6-9]|2\d|3[01])\.|192\.168\./i.test(url)) {
41
+ if (isBlockedUrl(url)) {
133
42
  return { result: 'Blocked: cannot fetch internal/localhost URLs.', isError: true };
134
43
  }
135
44
  const resp = await fetch(url, { method: (args.method as string) ?? 'GET', signal: AbortSignal.timeout(15_000) });
@@ -1347,8 +1347,7 @@ export async function handleSession(opts: ParsedArgs): Promise<void> {
1347
1347
 
1348
1348
  // Continuous mode: loop until deadline/maxTasks/interrupt
1349
1349
  const { TaskQueue } = await import('./bot/task-queue.js');
1350
- const { isTransientError } = await import('./bot/retry-utils.js');
1351
- const { getErrorGuidance } = await import('./bot/error-guide.js');
1350
+ const { isTransientError, getErrorGuidance } = await import('./bot/error-classifier.js');
1352
1351
  const queue = new TaskQueue();
1353
1352
  let taskCount = 0;
1354
1353
  let interrupted = false;
@@ -13,7 +13,7 @@ import {
13
13
  } from '@synergenius/flow-weaver/agent';
14
14
  import { WEAVER_TOOLS, createWeaverExecutor } from '../bot/weaver-tools.js';
15
15
  import { auditEmit } from '../bot/audit-logger.js';
16
- import { withRetry } from '../bot/retry-utils.js';
16
+ import { withRetry, getErrorGuidance } from '../bot/error-classifier.js';
17
17
  import { CostTracker } from '../bot/cost-tracker.js';
18
18
 
19
19
  // Clean up persistent sessions on process exit
@@ -237,11 +237,8 @@ export async function weaverAgentExecute(
237
237
  } catch (err: unknown) {
238
238
  const msg = err instanceof Error ? err.message : String(err);
239
239
  let errorDetail = msg;
240
- try {
241
- const { getErrorGuidance } = await import('../bot/error-guide.js');
242
- const guidance = getErrorGuidance(msg);
243
- if (guidance) errorDetail = `${msg}\n Hint: ${guidance}`;
244
- } catch { /* error guide not available */ }
240
+ const guidance = getErrorGuidance(msg);
241
+ if (guidance) errorDetail = `${msg}\n Hint: ${guidance}`;
245
242
  renderer.error('Agent error', errorDetail);
246
243
 
247
244
  context.resultJson = JSON.stringify({ success: false, error: msg });