@probelabs/probe 0.6.0-rc231 → 0.6.0-rc233

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 (59) hide show
  1. package/bin/binaries/probe-v0.6.0-rc233-aarch64-apple-darwin.tar.gz +0 -0
  2. package/bin/binaries/probe-v0.6.0-rc233-aarch64-unknown-linux-musl.tar.gz +0 -0
  3. package/bin/binaries/probe-v0.6.0-rc233-x86_64-apple-darwin.tar.gz +0 -0
  4. package/bin/binaries/probe-v0.6.0-rc233-x86_64-pc-windows-msvc.zip +0 -0
  5. package/bin/binaries/probe-v0.6.0-rc233-x86_64-unknown-linux-musl.tar.gz +0 -0
  6. package/build/agent/ProbeAgent.d.ts +2 -0
  7. package/build/agent/ProbeAgent.js +105 -12
  8. package/build/agent/dsl/agent-test.mjs +341 -0
  9. package/build/agent/dsl/analyze-test.mjs +237 -0
  10. package/build/agent/dsl/diag-test.mjs +78 -0
  11. package/build/agent/dsl/environment.js +387 -0
  12. package/build/agent/dsl/manual-test.mjs +662 -0
  13. package/build/agent/dsl/output-buffer-test.mjs +124 -0
  14. package/build/agent/dsl/pipeline-direct-test.mjs +147 -0
  15. package/build/agent/dsl/pipeline-test.mjs +223 -0
  16. package/build/agent/dsl/runtime.js +206 -0
  17. package/build/agent/dsl/sandbox-experiment.mjs +309 -0
  18. package/build/agent/dsl/transformer.js +156 -0
  19. package/build/agent/dsl/trigger-test.mjs +159 -0
  20. package/build/agent/dsl/validator.js +183 -0
  21. package/build/agent/index.js +18776 -7675
  22. package/build/agent/probeTool.js +9 -0
  23. package/build/agent/tools.js +9 -1
  24. package/build/delegate.js +12 -6
  25. package/build/index.js +5 -0
  26. package/build/tools/common.js +7 -0
  27. package/build/tools/executePlan.js +761 -0
  28. package/build/tools/index.js +4 -0
  29. package/cjs/agent/ProbeAgent.cjs +12891 -1797
  30. package/cjs/index.cjs +12395 -1292
  31. package/package.json +5 -1
  32. package/src/agent/ProbeAgent.d.ts +2 -0
  33. package/src/agent/ProbeAgent.js +105 -12
  34. package/src/agent/dsl/agent-test.mjs +341 -0
  35. package/src/agent/dsl/analyze-test.mjs +237 -0
  36. package/src/agent/dsl/diag-test.mjs +78 -0
  37. package/src/agent/dsl/environment.js +387 -0
  38. package/src/agent/dsl/manual-test.mjs +662 -0
  39. package/src/agent/dsl/output-buffer-test.mjs +124 -0
  40. package/src/agent/dsl/pipeline-direct-test.mjs +147 -0
  41. package/src/agent/dsl/pipeline-test.mjs +223 -0
  42. package/src/agent/dsl/runtime.js +206 -0
  43. package/src/agent/dsl/sandbox-experiment.mjs +309 -0
  44. package/src/agent/dsl/transformer.js +156 -0
  45. package/src/agent/dsl/trigger-test.mjs +159 -0
  46. package/src/agent/dsl/validator.js +183 -0
  47. package/src/agent/index.js +8 -0
  48. package/src/agent/probeTool.js +9 -0
  49. package/src/agent/tools.js +9 -1
  50. package/src/delegate.js +12 -6
  51. package/src/index.js +5 -0
  52. package/src/tools/common.js +7 -0
  53. package/src/tools/executePlan.js +761 -0
  54. package/src/tools/index.js +4 -0
  55. package/bin/binaries/probe-v0.6.0-rc231-aarch64-apple-darwin.tar.gz +0 -0
  56. package/bin/binaries/probe-v0.6.0-rc231-aarch64-unknown-linux-musl.tar.gz +0 -0
  57. package/bin/binaries/probe-v0.6.0-rc231-x86_64-apple-darwin.tar.gz +0 -0
  58. package/bin/binaries/probe-v0.6.0-rc231-x86_64-pc-windows-msvc.zip +0 -0
  59. package/bin/binaries/probe-v0.6.0-rc231-x86_64-unknown-linux-musl.tar.gz +0 -0
@@ -0,0 +1,183 @@
1
+ /**
2
+ * DSL Validator - AST whitelist validation for LLM-generated code.
3
+ *
4
+ * Parses code with Acorn and walks the AST, rejecting any node type
5
+ * not in the whitelist. This is an allow-list approach — unknown syntax
6
+ * is rejected by default.
7
+ */
8
+
9
+ import * as acorn from 'acorn';
10
+ import * as walk from 'acorn-walk';
11
+
12
+ // Node types the LLM is allowed to generate
13
+ const ALLOWED_NODE_TYPES = new Set([
14
+ 'Program',
15
+ 'ExpressionStatement',
16
+ 'BlockStatement',
17
+ 'VariableDeclaration',
18
+ 'VariableDeclarator',
19
+ 'ArrowFunctionExpression',
20
+ 'FunctionExpression',
21
+ 'CallExpression',
22
+ 'MemberExpression',
23
+ 'Identifier',
24
+ 'Literal',
25
+ 'TemplateLiteral',
26
+ 'TemplateElement',
27
+ 'ArrayExpression',
28
+ 'ObjectExpression',
29
+ 'SpreadElement',
30
+ 'IfStatement',
31
+ 'ConditionalExpression',
32
+ 'ForOfStatement',
33
+ 'ForInStatement',
34
+ 'ForStatement',
35
+ 'WhileStatement',
36
+ 'TryStatement',
37
+ 'CatchClause',
38
+ 'ThrowStatement',
39
+ 'ReturnStatement',
40
+ 'BreakStatement',
41
+ 'ContinueStatement',
42
+ 'AssignmentExpression',
43
+ 'UpdateExpression',
44
+ 'BinaryExpression',
45
+ 'LogicalExpression',
46
+ 'UnaryExpression',
47
+ 'Property',
48
+ 'SequenceExpression',
49
+ 'ChainExpression',
50
+ ]);
51
+
52
+ // Identifiers that are never allowed
53
+ const BLOCKED_IDENTIFIERS = new Set([
54
+ 'eval',
55
+ 'Function',
56
+ 'require',
57
+ 'process',
58
+ 'globalThis',
59
+ '__proto__',
60
+ 'constructor',
61
+ 'prototype',
62
+ 'import',
63
+ 'exports',
64
+ 'setTimeout',
65
+ 'setInterval',
66
+ 'setImmediate',
67
+ 'queueMicrotask',
68
+ 'Proxy',
69
+ 'Reflect',
70
+ 'Symbol',
71
+ ]);
72
+
73
+ // Property names that are never allowed on member expressions
74
+ const BLOCKED_PROPERTIES = new Set([
75
+ '__proto__',
76
+ 'constructor',
77
+ 'prototype',
78
+ '__defineGetter__',
79
+ '__defineSetter__',
80
+ '__lookupGetter__',
81
+ '__lookupSetter__',
82
+ ]);
83
+
84
+ /**
85
+ * Validate DSL code against the whitelist.
86
+ *
87
+ * @param {string} code - The LLM-generated code to validate
88
+ * @returns {{ valid: boolean, errors: string[] }}
89
+ */
90
+ export function validateDSL(code) {
91
+ const errors = [];
92
+
93
+ // Step 1: Parse with Acorn
94
+ let ast;
95
+ try {
96
+ ast = acorn.parse(code, {
97
+ ecmaVersion: 2022,
98
+ sourceType: 'script',
99
+ allowReturnOutsideFunction: true,
100
+ });
101
+ } catch (e) {
102
+ return { valid: false, errors: [`Syntax error: ${e.message}`] };
103
+ }
104
+
105
+ // Step 2: Walk every node and validate
106
+ walk.full(ast, (node) => {
107
+ // Check node type against whitelist
108
+ if (!ALLOWED_NODE_TYPES.has(node.type)) {
109
+ errors.push(`Blocked node type: ${node.type} at position ${node.start}`);
110
+ return;
111
+ }
112
+
113
+ // Block async functions (LLM should not write async/await)
114
+ if (
115
+ (node.type === 'ArrowFunctionExpression' ||
116
+ node.type === 'FunctionExpression') &&
117
+ node.async
118
+ ) {
119
+ errors.push(`Async functions are not allowed at position ${node.start}. Write synchronous code — the runtime handles async.`);
120
+ }
121
+
122
+ // Block generator functions
123
+ if (
124
+ (node.type === 'FunctionExpression') &&
125
+ node.generator
126
+ ) {
127
+ errors.push(`Generator functions are not allowed at position ${node.start}`);
128
+ }
129
+
130
+ // Block regex literals — SandboxJS doesn't support them
131
+ if (node.type === 'Literal' && node.regex) {
132
+ errors.push(`Regex literals are not supported at position ${node.start}. Use String methods like indexOf(), includes(), startsWith() instead.`);
133
+ }
134
+
135
+ // Check identifiers against blocklist
136
+ if (node.type === 'Identifier' && BLOCKED_IDENTIFIERS.has(node.name)) {
137
+ errors.push(`Blocked identifier: '${node.name}' at position ${node.start}`);
138
+ }
139
+
140
+ // Check member expressions for blocked properties
141
+ if (node.type === 'MemberExpression' && !node.computed) {
142
+ if (node.property.type === 'Identifier' && BLOCKED_PROPERTIES.has(node.property.name)) {
143
+ errors.push(`Blocked property access: '.${node.property.name}' at position ${node.property.start}`);
144
+ }
145
+ }
146
+
147
+ // Block computed member expressions with blocked string literals
148
+ if (node.type === 'MemberExpression' && node.computed) {
149
+ if (node.property.type === 'Literal' && typeof node.property.value === 'string') {
150
+ if (BLOCKED_PROPERTIES.has(node.property.value) || BLOCKED_IDENTIFIERS.has(node.property.value)) {
151
+ errors.push(`Blocked computed property access: '["${node.property.value}"]' at position ${node.property.start}`);
152
+ }
153
+ }
154
+ }
155
+
156
+ // Block variable declarations named with blocked identifiers
157
+ if (node.type === 'VariableDeclarator' && node.id.type === 'Identifier') {
158
+ if (BLOCKED_IDENTIFIERS.has(node.id.name)) {
159
+ errors.push(`Cannot declare variable with blocked name: '${node.id.name}' at position ${node.id.start}`);
160
+ }
161
+ }
162
+ });
163
+
164
+ return {
165
+ valid: errors.length === 0,
166
+ errors,
167
+ };
168
+ }
169
+
170
+ /**
171
+ * Parse DSL code into an AST.
172
+ * Exported for use by the transformer.
173
+ *
174
+ * @param {string} code
175
+ * @returns {import('acorn').Node}
176
+ */
177
+ export function parseDSL(code) {
178
+ return acorn.parse(code, {
179
+ ecmaVersion: 2022,
180
+ sourceType: 'script',
181
+ allowReturnOutsideFunction: true,
182
+ });
183
+ }
@@ -142,6 +142,8 @@ function parseArgs() {
142
142
  skillDirs: null, // Comma-separated list of repo-relative skill directories
143
143
  // Task management
144
144
  enableTasks: false, // Enable task tracking for progress management
145
+ // Execute plan DSL tool
146
+ enableExecutePlan: false,
145
147
  // Bash tool configuration
146
148
  enableBash: false,
147
149
  bashAllow: null,
@@ -218,6 +220,8 @@ function parseArgs() {
218
220
  config.skillDirs = args[++i].split(',').map(dir => dir.trim()).filter(Boolean);
219
221
  } else if (arg === '--allow-tasks') {
220
222
  config.enableTasks = true;
223
+ } else if (arg === '--enable-execute-plan') {
224
+ config.enableExecutePlan = true;
221
225
  } else if (arg === '--enable-bash') {
222
226
  config.enableBash = true;
223
227
  } else if (arg === '--bash-allow' && i + 1 < args.length) {
@@ -295,6 +299,9 @@ Options:
295
299
  --no-mermaid-validation Disable automatic mermaid diagram validation and fixing
296
300
  --help, -h Show this help message
297
301
 
302
+ DSL Orchestration:
303
+ --enable-execute-plan Enable execute_plan DSL tool for programmatic orchestration
304
+
298
305
  Bash Tool Options:
299
306
  --enable-bash Enable bash command execution for system exploration
300
307
  --bash-allow <patterns> Additional bash command patterns to allow (comma-separated)
@@ -843,6 +850,7 @@ async function main() {
843
850
  disableTools: config.disableTools,
844
851
  allowSkills: config.allowSkills,
845
852
  skillDirs: config.skillDirs,
853
+ enableExecutePlan: config.enableExecutePlan,
846
854
  enableBash: config.enableBash,
847
855
  bashConfig: bashConfig,
848
856
  enableTasks: config.enableTasks
@@ -211,6 +211,15 @@ export function createWrappedTools(baseTools) {
211
211
  );
212
212
  }
213
213
 
214
+ // Wrap execute_plan tool
215
+ if (baseTools.executePlanTool) {
216
+ wrappedTools.executePlanToolInstance = wrapToolWithEmitter(
217
+ baseTools.executePlanTool,
218
+ 'execute_plan',
219
+ baseTools.executePlanTool.execute
220
+ );
221
+ }
222
+
214
223
  // Wrap bash tool
215
224
  if (baseTools.bashTool) {
216
225
  wrappedTools.bashToolInstance = wrapToolWithEmitter(
@@ -5,6 +5,7 @@ import {
5
5
  extractTool,
6
6
  delegateTool,
7
7
  analyzeAllTool,
8
+ createExecutePlanTool,
8
9
  bashTool,
9
10
  editTool,
10
11
  createTool,
@@ -16,6 +17,7 @@ import {
16
17
  extractSchema,
17
18
  delegateSchema,
18
19
  analyzeAllSchema,
20
+ executePlanSchema,
19
21
  bashSchema,
20
22
  editSchema,
21
23
  createSchema,
@@ -24,6 +26,7 @@ import {
24
26
  extractToolDefinition,
25
27
  delegateToolDefinition,
26
28
  analyzeAllToolDefinition,
29
+ getExecutePlanToolDefinition,
27
30
  bashToolDefinition,
28
31
  editToolDefinition,
29
32
  createToolDefinition,
@@ -58,7 +61,10 @@ export function createTools(configOptions) {
58
61
  if (configOptions.enableDelegate && isToolAllowed('delegate')) {
59
62
  tools.delegateTool = delegateTool(configOptions);
60
63
  }
61
- if (isToolAllowed('analyze_all')) {
64
+ if (configOptions.enableExecutePlan && isToolAllowed('execute_plan')) {
65
+ tools.executePlanTool = createExecutePlanTool(configOptions);
66
+ } else if (isToolAllowed('analyze_all')) {
67
+ // analyze_all is fallback when execute_plan is not enabled
62
68
  tools.analyzeAllTool = analyzeAllTool(configOptions);
63
69
  }
64
70
 
@@ -97,6 +103,7 @@ export {
97
103
  extractSchema,
98
104
  delegateSchema,
99
105
  analyzeAllSchema,
106
+ executePlanSchema,
100
107
  bashSchema,
101
108
  editSchema,
102
109
  createSchema,
@@ -106,6 +113,7 @@ export {
106
113
  extractToolDefinition,
107
114
  delegateToolDefinition,
108
115
  analyzeAllToolDefinition,
116
+ getExecutePlanToolDefinition,
109
117
  bashToolDefinition,
110
118
  editToolDefinition,
111
119
  createToolDefinition,
package/src/delegate.js CHANGED
@@ -19,11 +19,14 @@ import { ProbeAgent } from './agent/ProbeAgent.js';
19
19
  * - For long-running processes, periodic cleanup of stale sessions may be needed
20
20
  */
21
21
  class DelegationManager {
22
- constructor() {
23
- this.maxConcurrent = parseInt(process.env.MAX_CONCURRENT_DELEGATIONS || '3', 10);
24
- this.maxPerSession = parseInt(process.env.MAX_DELEGATIONS_PER_SESSION || '10', 10);
22
+ constructor(options = {}) {
23
+ this.maxConcurrent = options.maxConcurrent
24
+ ?? parseInt(process.env.MAX_CONCURRENT_DELEGATIONS || '3', 10);
25
+ this.maxPerSession = options.maxPerSession
26
+ ?? parseInt(process.env.MAX_DELEGATIONS_PER_SESSION || '10', 10);
25
27
  // Default queue timeout: 60 seconds. Set DELEGATION_QUEUE_TIMEOUT=0 to disable.
26
- this.defaultQueueTimeout = parseInt(process.env.DELEGATION_QUEUE_TIMEOUT || '60000', 10);
28
+ this.defaultQueueTimeout = options.queueTimeout
29
+ ?? parseInt(process.env.DELEGATION_QUEUE_TIMEOUT || '60000', 10);
27
30
 
28
31
  // Track delegations per session with timestamp for potential TTL cleanup
29
32
  // Map<string, { count: number, lastUpdated: number }>
@@ -353,6 +356,7 @@ const DEFAULT_DELEGATE_TIMEOUT = parseInt(process.env.DELEGATE_TIMEOUT, 10) || 3
353
356
  * @param {boolean} [options.enableMcp=false] - Enable MCP tool integration (inherited from parent)
354
357
  * @param {Object} [options.mcpConfig] - MCP configuration object (inherited from parent)
355
358
  * @param {string} [options.mcpConfigPath] - Path to MCP configuration file (inherited from parent)
359
+ * @param {Object} [options.concurrencyLimiter=null] - Global AI concurrency limiter (DelegationManager instance)
356
360
  * @returns {Promise<string>} The response from the delegate agent
357
361
  */
358
362
  export async function delegate({
@@ -379,7 +383,8 @@ export async function delegate({
379
383
  enableMcp = false,
380
384
  mcpConfig = null,
381
385
  mcpConfigPath = null,
382
- delegationManager = null // Optional per-instance manager, falls back to default singleton
386
+ delegationManager = null, // Optional per-instance manager, falls back to default singleton
387
+ concurrencyLimiter = null // Optional global AI concurrency limiter
383
388
  }) {
384
389
  if (!task || typeof task !== 'string') {
385
390
  throw new Error('Task parameter is required and must be a string');
@@ -464,7 +469,8 @@ export async function delegate({
464
469
  enableTasks, // Inherit from parent (subagent gets isolated TaskManager)
465
470
  enableMcp, // Inherit from parent (subagent creates own MCPXmlBridge)
466
471
  mcpConfig, // Inherit from parent
467
- mcpConfigPath // Inherit from parent
472
+ mcpConfigPath, // Inherit from parent
473
+ concurrencyLimiter // Inherit global AI concurrency limiter
468
474
  });
469
475
 
470
476
  if (debug) {
package/src/index.js CHANGED
@@ -26,6 +26,7 @@ import {
26
26
  extractSchema,
27
27
  delegateSchema,
28
28
  analyzeAllSchema,
29
+ executePlanSchema,
29
30
  attemptCompletionSchema,
30
31
  bashSchema,
31
32
  searchToolDefinition,
@@ -46,6 +47,7 @@ import {
46
47
  createToolDefinition
47
48
  } from './tools/edit.js';
48
49
  import { searchTool, queryTool, extractTool, delegateTool, analyzeAllTool } from './tools/vercel.js';
50
+ import { createExecutePlanTool, getExecutePlanToolDefinition } from './tools/executePlan.js';
49
51
  import { bashTool } from './tools/bash.js';
50
52
  import { editTool, createTool } from './tools/edit.js';
51
53
  import { ProbeAgent } from './agent/ProbeAgent.js';
@@ -90,6 +92,7 @@ export {
90
92
  extractTool,
91
93
  delegateTool,
92
94
  analyzeAllTool,
95
+ createExecutePlanTool,
93
96
  bashTool,
94
97
  editTool,
95
98
  createTool,
@@ -102,6 +105,7 @@ export {
102
105
  extractSchema,
103
106
  delegateSchema,
104
107
  analyzeAllSchema,
108
+ executePlanSchema,
105
109
  attemptCompletionSchema,
106
110
  bashSchema,
107
111
  editSchema,
@@ -112,6 +116,7 @@ export {
112
116
  extractToolDefinition,
113
117
  delegateToolDefinition,
114
118
  analyzeAllToolDefinition,
119
+ getExecutePlanToolDefinition,
115
120
  attemptCompletionToolDefinition,
116
121
  bashToolDefinition,
117
122
  editToolDefinition,
@@ -54,6 +54,11 @@ export const analyzeAllSchema = z.object({
54
54
  path: z.string().optional().default('.').describe('Directory path to search in')
55
55
  });
56
56
 
57
+ export const executePlanSchema = z.object({
58
+ code: z.string().min(1).describe('JavaScript DSL code to execute. All function calls look synchronous — do NOT use async/await. Use map(items, fn) for batch operations. Use LLM(instruction, data) for AI processing.'),
59
+ description: z.string().optional().describe('Human-readable description of what this plan does, for logging.')
60
+ });
61
+
57
62
  // Schema for the attempt_completion tool - flexible validation for direct XML response
58
63
  export const attemptCompletionSchema = {
59
64
  // Custom validation that requires result parameter but allows direct XML response
@@ -425,6 +430,7 @@ export const DEFAULT_VALID_TOOLS = [
425
430
  'extract',
426
431
  'delegate',
427
432
  'analyze_all',
433
+ 'execute_plan',
428
434
  'listSkills',
429
435
  'useSkill',
430
436
  'listFiles',
@@ -463,6 +469,7 @@ function getValidParamsForTool(toolName) {
463
469
  extract: extractSchema,
464
470
  delegate: delegateSchema,
465
471
  analyze_all: analyzeAllSchema,
472
+ execute_plan: executePlanSchema,
466
473
  listSkills: listSkillsSchema,
467
474
  useSkill: useSkillSchema,
468
475
  bash: bashSchema,