@denizokcu/haze 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/CHANGELOG.md +35 -9
  2. package/README.md +37 -35
  3. package/dist/cli/chat/inputSuggestions.js +2 -2
  4. package/dist/cli/chat/sessionRecorder.d.ts +3 -0
  5. package/dist/cli/chat/sessionRecorder.js +23 -8
  6. package/dist/cli/commands/chat.js +136 -124
  7. package/dist/cli/commands/chatModes.js +1 -1
  8. package/dist/cli/commands/commandHelp.js +2 -2
  9. package/dist/cli/commands/commands.d.ts +1 -1
  10. package/dist/cli/commands/commands.js +1 -1
  11. package/dist/cli/commands/formatters.d.ts +6 -0
  12. package/dist/cli/commands/formatters.js +41 -3
  13. package/dist/cli/commands/logsCommand.js +7 -21
  14. package/dist/cli/commands/mcpWizard.js +24 -2
  15. package/dist/cli/commands/providerWizard.js +18 -5
  16. package/dist/cli/commands/runCommand.js +7 -15
  17. package/dist/cli/commands/settingsSummary.js +3 -1
  18. package/dist/cli/commands/streaming/turnOutcome.d.ts +10 -0
  19. package/dist/cli/commands/streaming/turnOutcome.js +13 -0
  20. package/dist/cli/commands/streaming.js +99 -51
  21. package/dist/cli/commands/wizardPrompts.js +1 -1
  22. package/dist/cli/commands/wizardSuggestions.js +3 -2
  23. package/dist/cli/commands/wizardTransition.d.ts +33 -0
  24. package/dist/cli/commands/wizardTransition.js +44 -0
  25. package/dist/config/contextFiles.js +6 -3
  26. package/dist/config/endpointSecurity.d.ts +2 -0
  27. package/dist/config/endpointSecurity.js +28 -0
  28. package/dist/config/inputHistory.js +4 -2
  29. package/dist/config/privateStorage.d.ts +6 -0
  30. package/dist/config/privateStorage.js +61 -0
  31. package/dist/config/providers.js +5 -9
  32. package/dist/config/settings.d.ts +1 -0
  33. package/dist/config/settings.js +55 -3
  34. package/dist/config/updateCheck.js +4 -2
  35. package/dist/core/agent/compaction.js +2 -2
  36. package/dist/core/agent/errors.js +1 -1
  37. package/dist/core/agent/requestAssembly.d.ts +1 -0
  38. package/dist/core/agent/requestAssembly.js +13 -0
  39. package/dist/core/agent/toolOutputStore.d.ts +3 -0
  40. package/dist/core/agent/toolOutputStore.js +32 -11
  41. package/dist/core/bashOutput/registry.js +11 -9
  42. package/dist/core/goal/completionPolicy.d.ts +0 -28
  43. package/dist/core/goal/completionPolicy.js +1 -89
  44. package/dist/core/io/boundedRead.d.ts +15 -0
  45. package/dist/core/io/boundedRead.js +97 -0
  46. package/dist/core/limits/byteBudgets.d.ts +13 -0
  47. package/dist/core/limits/byteBudgets.js +13 -0
  48. package/dist/core/log/llmLog.d.ts +10 -0
  49. package/dist/core/log/llmLog.js +59 -13
  50. package/dist/core/persistence/orderedFileWriter.d.ts +11 -0
  51. package/dist/core/persistence/orderedFileWriter.js +29 -0
  52. package/dist/core/process/runBoundedProcess.d.ts +27 -0
  53. package/dist/core/process/runBoundedProcess.js +80 -0
  54. package/dist/core/session/sessionStore.js +48 -25
  55. package/dist/core/subagent/subagentRunner.d.ts +252 -9
  56. package/dist/core/subagent/subagentRunner.js +14 -19
  57. package/dist/core/toolOutput/reduction.d.ts +2 -0
  58. package/dist/core/toolOutput/reduction.js +12 -0
  59. package/dist/core/validation/outputParser.js +5 -3
  60. package/dist/llm/client.d.ts +2 -2
  61. package/dist/llm/client.js +19 -3
  62. package/dist/llm/hazeTools.d.ts +8103 -364
  63. package/dist/llm/hazeTools.js +43 -33
  64. package/dist/llm/initPrompt.js +1 -1
  65. package/dist/llm/lsp.d.ts +21 -3
  66. package/dist/llm/lsp.js +65 -14
  67. package/dist/llm/lspTools.d.ts +2358 -101
  68. package/dist/llm/mcp.d.ts +1 -1
  69. package/dist/llm/mcp.js +65 -16
  70. package/dist/llm/requestContext.d.ts +1 -0
  71. package/dist/llm/requestContext.js +6 -3
  72. package/dist/llm/systemPrompt.js +2 -2
  73. package/dist/llm/toolResultTypes.d.ts +1 -1
  74. package/dist/llm/tools/bashTool.d.ts +603 -5
  75. package/dist/llm/tools/bashTool.js +23 -60
  76. package/dist/llm/tools/fetchTool.d.ts +1201 -65
  77. package/dist/llm/tools/fetchTool.js +2 -1
  78. package/dist/llm/tools/grepRunner.d.ts +15 -0
  79. package/dist/llm/tools/grepRunner.js +85 -0
  80. package/dist/llm/tools/storedOutputTool.d.ts +351 -10
  81. package/dist/llm/tools/taskTool.d.ts +629 -28
  82. package/dist/llm/tools/toolContext.d.ts +7 -2
  83. package/dist/llm/tools/toolContext.js +11 -2
  84. package/dist/llm/webFetch.js +31 -21
  85. package/dist/skills/SkillLoader.js +17 -5
  86. package/dist/skills/SkillRegistry.js +19 -6
  87. package/dist/skills/builder/SkillBuilder.js +7 -7
  88. package/dist/skills/types.d.ts +5 -0
  89. package/dist/ui/components/TextInput.d.ts +7 -0
  90. package/dist/ui/components/TextInput.js +10 -0
  91. package/dist/utils/modelName.d.ts +2 -0
  92. package/dist/utils/modelName.js +15 -0
  93. package/dist/utils/path.d.ts +2 -0
  94. package/dist/utils/path.js +9 -4
  95. package/examples/skills/files/SKILL.md +1 -1
  96. package/package.json +14 -14
@@ -1,4 +1,3 @@
1
- import { spawn } from 'node:child_process';
2
1
  import { tool } from 'ai';
3
2
  import { z } from 'zod';
4
3
  import { classifyBashCommand, isValidationClassification } from '../../core/safety/bashClassifier.js';
@@ -7,75 +6,39 @@ import { filterBashOutput } from '../../core/bashOutput/registry.js';
7
6
  import { storeToolOutput } from '../../core/agent/toolOutputStore.js';
8
7
  import { workspaceRoot } from '../../utils/path.js';
9
8
  import { compactStoredOutput, COMPACT_COMMAND_CHARS } from './outputCap.js';
10
- import { runDedupedTool } from './toolContext.js';
9
+ import { hazeToolContextSchema, runDedupedTool } from './toolContext.js';
10
+ import { runBoundedProcess } from '../../core/process/runBoundedProcess.js';
11
+ import { BASH_STREAM_BYTES } from '../../core/limits/byteBudgets.js';
11
12
  const SHORT_VALIDATION_CHARS = 2_000;
12
13
  export const bashTool = tool({
13
- description: 'Run workspace tests, builds, validation, or inspection. Use file tools for edits.',
14
+ description: 'Run workspace tests, builds, validation, or inspection. Risk classification is informational; use file tools for edits.',
15
+ contextSchema: hazeToolContextSchema,
14
16
  inputSchema: z.object({
15
17
  command: z.string().min(1).describe('Command to execute with bash -lc'),
16
18
  timeoutSeconds: z.number().int().positive().max(600).optional().describe('Timeout in seconds; defaults to 60'),
17
19
  allowMutation: z.boolean().default(false).describe('Deprecated compatibility flag. Commands run without confirmation; retained for compatibility.'),
18
20
  }),
19
- execute: async ({ command, timeoutSeconds, allowMutation }, context) => runDedupedTool('bash', { command, timeoutSeconds, allowMutation }, context, async () => {
21
+ execute: async ({ command, timeoutSeconds }, context) => runDedupedTool('bash', { command, timeoutSeconds }, context, async () => {
20
22
  const cwd = workspaceRoot();
21
23
  const classification = classifyBashCommand(command);
22
24
  const timeoutMs = (timeoutSeconds ?? 60) * 1000;
23
25
  const startedAt = Date.now();
24
- return await new Promise(resolve => {
25
- const child = spawn('bash', ['-lc', command], { cwd, stdio: ['ignore', 'pipe', 'pipe'] });
26
- let stdout = '';
27
- let stderr = '';
28
- let settled = false;
29
- let timedOut = false;
30
- const timer = setTimeout(() => {
31
- if (!settled) {
32
- timedOut = true;
33
- child.kill('SIGTERM');
34
- }
35
- }, timeoutMs);
36
- const abort = () => child.kill('SIGTERM');
37
- context.abortSignal?.addEventListener('abort', abort, { once: true });
38
- child.stdout.on('data', data => stdout += data.toString());
39
- child.stderr.on('data', data => stderr += data.toString());
40
- child.on('close', code => {
41
- settled = true;
42
- clearTimeout(timer);
43
- context.abortSignal?.removeEventListener('abort', abort);
44
- const validationSummary = isValidationClassification(classification)
45
- ? parseValidationOutput({ command, code, stdout, stderr, timedOut, stdoutTruncated: stdout.length > COMPACT_COMMAND_CHARS, stderrTruncated: stderr.length > COMPACT_COMMAND_CHARS, classification })
46
- : undefined;
47
- const validationPassed = validationSummary?.status === 'passed';
48
- const output = filterBashOutput({
49
- command,
50
- code,
51
- stdout,
52
- stderr,
53
- timedOut,
54
- classification,
55
- validationSummary,
56
- storeRawOutput: storeToolOutput,
57
- fallbackCompact: compactStoredOutput,
58
- compactMaxChars: validationPassed ? SHORT_VALIDATION_CHARS : COMPACT_COMMAND_CHARS,
59
- });
60
- resolve({
61
- ok: code === 0 && !timedOut,
62
- code,
63
- command,
64
- cwd,
65
- classification,
66
- durationMs: Date.now() - startedAt,
67
- timedOut,
68
- stdout: output.stdout,
69
- stderr: output.stderr,
70
- validationSummary,
71
- });
72
- });
73
- child.on('error', error => {
74
- settled = true;
75
- clearTimeout(timer);
76
- context.abortSignal?.removeEventListener('abort', abort);
77
- resolve({ ok: false, command, cwd, classification, durationMs: Date.now() - startedAt, error: error.message });
78
- });
79
- });
26
+ const processResult = await runBoundedProcess({ command: 'bash', args: ['-lc', command], cwd, timeoutMs, signal: context.abortSignal, maxStdoutBytes: BASH_STREAM_BYTES, maxStderrBytes: BASH_STREAM_BYTES });
27
+ const { code, timedOut } = processResult;
28
+ const stdout = processResult.stdout.text;
29
+ const stderr = processResult.stderr.text;
30
+ const validationSummary = isValidationClassification(classification)
31
+ ? parseValidationOutput({ command, code, stdout, stderr, timedOut, stdoutTruncated: processResult.stdout.omittedBytes > 0, stderrTruncated: processResult.stderr.omittedBytes > 0, classification })
32
+ : undefined;
33
+ const validationPassed = validationSummary?.status === 'passed';
34
+ const output = filterBashOutput({ command, code, stdout, stderr, timedOut, classification, validationSummary, storeRawOutput: storeToolOutput, fallbackCompact: compactStoredOutput, compactMaxChars: validationPassed ? SHORT_VALIDATION_CHARS : COMPACT_COMMAND_CHARS });
35
+ return {
36
+ ok: code === 0 && !timedOut && !processResult.aborted && !processResult.error,
37
+ code, command, cwd, classification, durationMs: Date.now() - startedAt, timedOut,
38
+ aborted: processResult.aborted, signal: processResult.signal, forcedTermination: processResult.forced,
39
+ stdout: output.stdout, stderr: output.stderr, validationSummary,
40
+ stdoutBytes: processResult.stdout, stderrBytes: processResult.stderr,
41
+ ...(processResult.error ? { error: processResult.error } : {}),
42
+ };
80
43
  }),
81
44
  });