hammer-ai 0.2.3 → 0.2.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.
- package/dist/index.d.ts +7 -29
- package/dist/index.js +13 -33
- package/dist/index.js.map +1 -1
- package/dist/node.js +4 -7
- package/dist/node.js.map +1 -1
- package/package.json +2 -10
package/dist/index.d.ts
CHANGED
|
@@ -1754,13 +1754,9 @@ declare abstract class WebToolLoopAgentRuntime<TState extends WebToolLoopRuntime
|
|
|
1754
1754
|
* Agent Memory Layer Factory — Shared factory for creating pre-configured
|
|
1755
1755
|
* AgentMemoryLayer instances.
|
|
1756
1756
|
*
|
|
1757
|
-
*
|
|
1758
|
-
*
|
|
1759
|
-
*
|
|
1760
|
-
* Usage:
|
|
1761
|
-
* import { createAgentMemoryLayer } from "./agent-memory-factory"
|
|
1762
|
-
* const memory = createAgentMemoryLayer("hammer", { logger: myLogger })
|
|
1763
|
-
* const memory = createAgentMemoryLayer("magic", { toolMemoryExtractor: canvasExtractor })
|
|
1757
|
+
* All agents share the same workspace-agent preset. Callers still pass
|
|
1758
|
+
* a preset name string (currently ignored) for call-site readability and
|
|
1759
|
+
* future differentiation.
|
|
1764
1760
|
*/
|
|
1765
1761
|
|
|
1766
1762
|
interface AgentMemoryFactoryOverrides {
|
|
@@ -1776,30 +1772,13 @@ interface AgentMemoryFactoryOverrides {
|
|
|
1776
1772
|
logger?: AgentMemoryLogger;
|
|
1777
1773
|
}
|
|
1778
1774
|
/**
|
|
1779
|
-
* Create an AgentMemoryLayer pre-configured
|
|
1775
|
+
* Create an AgentMemoryLayer pre-configured with the shared workspace defaults.
|
|
1780
1776
|
*
|
|
1781
|
-
* @param
|
|
1777
|
+
* @param _preset - Ignored. All agents share the same preset. Kept for call-site compatibility.
|
|
1782
1778
|
* @param overrides - Optional overrides for any preset value.
|
|
1783
1779
|
* @returns Configured AgentMemoryLayer instance.
|
|
1784
|
-
*
|
|
1785
|
-
* @example
|
|
1786
|
-
* ```ts
|
|
1787
|
-
* // Hammer (Node.js — use TiktokenEstimator for precision)
|
|
1788
|
-
* const memory = createAgentMemoryLayer("hammer", {
|
|
1789
|
-
* compactionClient,
|
|
1790
|
-
* tokenEstimator: new TiktokenEstimator(),
|
|
1791
|
-
* logger: hammerLogger,
|
|
1792
|
-
* })
|
|
1793
|
-
*
|
|
1794
|
-
* // Magic/Monoslides/Monospace (browser — CharTokenEstimator is default)
|
|
1795
|
-
* const memory = createAgentMemoryLayer("magic", {
|
|
1796
|
-
* compactionClient,
|
|
1797
|
-
* getToolDefinitions: () => registry.getToolDefinitions(),
|
|
1798
|
-
* toolMemoryExtractor: MAGIC_TOOL_MEMORY_EXTRACTOR,
|
|
1799
|
-
* })
|
|
1800
|
-
* ```
|
|
1801
1780
|
*/
|
|
1802
|
-
declare function createAgentMemoryLayer(
|
|
1781
|
+
declare function createAgentMemoryLayer(_preset: string, overrides?: AgentMemoryFactoryOverrides): AgentMemoryLayer;
|
|
1803
1782
|
|
|
1804
1783
|
/**
|
|
1805
1784
|
* Shared structured control-segment prompt fragments used across agent loops.
|
|
@@ -1818,7 +1797,6 @@ interface BashCommandsSectionOptions {
|
|
|
1818
1797
|
declare const STANDARD_TOOL_CALL_FORMAT_RULES: string[];
|
|
1819
1798
|
declare const SINGLE_TOOL_CALL_RUN_LINE_EXAMPLE: string;
|
|
1820
1799
|
declare const SHARED_TOOL_CALL_EXAMPLE_LINES: string[];
|
|
1821
|
-
declare const CONTINUE_TOOL_CALL_RESPONSE_EXAMPLE: string;
|
|
1822
1800
|
|
|
1823
1801
|
/**
|
|
1824
1802
|
* Shared prompt building utilities for agentic loops.
|
|
@@ -2405,4 +2383,4 @@ declare function runStructuredLLMCompaction<TMessage extends MemoryMessage, TSta
|
|
|
2405
2383
|
parseState: (obj: Record<string, unknown>) => TState | null;
|
|
2406
2384
|
}): Promise<TState | null>;
|
|
2407
2385
|
|
|
2408
|
-
export { AGENT_MACHINE_STATES, AgentLoop, type AgentLoopCallbacks, type AgentLoopDeps, type AgentMachineContext, type AgentMachineEvent, type AgentMachineState, type AgentMemoryCitation, type AgentMemoryConstraint, type AgentMemoryEvidence, type AgentMemoryFactoryOverrides, AgentMemoryLayer, type AgentMemoryLayerConfig, type AgentMemoryLogger, type AgentMemoryNote, type AgentMemoryTask, type AgentMessage, type AgentPhase, type AgentState, ApiError, type BackgroundBashAction, BackgroundBashRunCommand, BaseMemoryLayer, BaseValidationEnforcer, BashRunCommand, type BuildMemoryCompactionPromptOptions, CODE_QUALITY_RULE_LINE,
|
|
2386
|
+
export { AGENT_MACHINE_STATES, AgentLoop, type AgentLoopCallbacks, type AgentLoopDeps, type AgentMachineContext, type AgentMachineEvent, type AgentMachineState, type AgentMemoryCitation, type AgentMemoryConstraint, type AgentMemoryEvidence, type AgentMemoryFactoryOverrides, AgentMemoryLayer, type AgentMemoryLayerConfig, type AgentMemoryLogger, type AgentMemoryNote, type AgentMemoryTask, type AgentMessage, type AgentPhase, type AgentState, ApiError, type BackgroundBashAction, BackgroundBashRunCommand, BaseMemoryLayer, BaseValidationEnforcer, BashRunCommand, type BuildMemoryCompactionPromptOptions, CODE_QUALITY_RULE_LINE, CharTokenEstimator, type ChatMessage, type CommandRuntime, type CommandTargetInfo, type CompactionCursor, type CompactionLLMClient, type ConversationAdapter, type ConversationSink, type CreateWebRuntimeSetupOptions, DEFAULT_AGENT_FALLBACK_SYSTEM_PROMPT, DEFAULT_ALLOWED_RUN_TARGETS, DEFAULT_RUN_COMMAND_REGISTRY, DEFAULT_THREAD_AUTO_SCROLL_BOTTOM_THRESHOLD, DEFAULT_TOOL_MEMORY_EXTRACTOR, ERROR_RECOVERY_RULE_LINE, ERROR_TRUNCATED_RESPONSE, type EnforcerResult, type ExecuteWebLoopRunOptions, type FetchLike, type FetchResponseLike, type HammerAgentConfig, type HammerAgentProviderPreset, INCREMENTAL_TESTING_RULE_LINE, JUST_BASH_SCRIPT_EXECUTION_RESTRICTION_LINES, JUST_BASH_SHELL_NATIVE_WORKFLOW_COMMAND_EXAMPLES, LLMClient, type LLMClientResponse, type LLMProviderConfig, type LLMRequest, type LLMRequestOptions, type LLMResponse, LLMResponseSchema, type LoopOutcome, MAX_TOOL_RESULT_CHARS, type MemoryMessage, type MemoryProvenance, type MemoryStorage, PORT_CONFLICT_RULE_LINE, type ParseAgentResponseOptions, type ParsedAgentResponse, type ParsedBackgroundBashCommand, type ParsedStepInput, PendingAgentMessageBuffer, type PersistedMemoryData, type ProviderName, ProxyTool, type ProxyToolExecutor, ROOT_CAUSES_RULE_LINE, type RawMessage, RunCommand, type RunCommandParseResult, type RunCommandPromptAvailability, RunCommandRegistry, type RunInvocationTarget, type RuntimeController, type RuntimeSnapshotUpdater, type RuntimeStore, type RuntimeSubscriber, SHARED_TOOL_CALL_EXAMPLE_LINES, SHARED_TOOL_USAGE_RULE, SINGLE_TOOL_CALL_RUN_LINE_EXAMPLE, SKILL_INVOKE_READ_RULE_LINE, STANDARD_TOOL_CALL_FORMAT_RULES, SUPPORTED_RUN_TARGETS, type SkillSummaryLike, type StepResult, type StreamCallbacks, StreamingToolParser, type StreamingToolParserCallbacks, type SystemPromptBuildContext, type SystemPromptCustomizer, type SystemPromptSections, TODO_LIST_FIRST_RESPONSE_RULE_LINE, TOOL_CALL_SEPARATOR_RULE, type TodoItem, type TodoStatus, type TokenEstimator, Tool, type ToolCall, ToolCallSchema, type ToolDataPrimitive, type ToolDataSchema, type ToolDataValue, type ToolDefinition, type ToolDefinitionMetadata, type ToolExecutionResult, type ToolLike, ToolLoopAgentRuntime, type ToolLoopAgentRuntimeDeps, type ToolLoopRuntimeExecuteStepResult, type ToolLoopRuntimeHooks, type ToolLoopRuntimeInfrastructure, type ToolLoopRuntimeLLMRequest, type ToolLoopRuntimeLLMResponse, type ToolLoopRuntimeRunStepOptions, type ToolLoopRuntimeRunStepResult, type ToolLoopRuntimeSetup, type ToolLoopRuntimeStepContext, type ToolLoopStepExecutionResult, type ToolLoopStepExecutorCallbacks, type ToolLoopStepExecutorOptions, type ToolLoopStepExecutorResponse, type ToolMemoryCitationKind, type ToolMemoryEvidenceKind, type ToolMemoryEvidencePolicy, type ToolMemoryExtractor, type ToolMemoryMetadata, type ToolMemoryNoteKind, type ToolMemoryNotePolicy, type ToolMemoryNoteScope, type ToolMetadata, type ToolParameterDefinition, ToolRegistry, type ToolRegistryBeforeExecuteContext, type ToolRegistryMissingToolContext, type ToolRegistryOptions, type ToolResult, ToolRunCommand, type ToolSchema, type TruncatedToolInfo, VALIDATE_AFTER_CHANGES_RULE_LINE, type WebSearchToolActionInput, WebToolLoopAgentRuntime, type WebToolLoopAgentRuntimeConstructorOptions, type WebToolLoopRuntimeStateLike, WebValidationEnforcer, type WorkspaceCodingStaticRulesOptions, agentMachine, applyIdleWebAgentState, applyInitialWebAgentRunState, buildAgentIdentityLine, buildAgentSystemPrompt, buildCompactionEntry, buildCoreStaticRules, buildNoStructuredResponseFoundError, buildParseFeedback, buildSkillAwareStaticContext, buildSkillsSection, buildStepUserMessage, buildToolLogRevealFrames, buildToolUsageExample, buildValidationErrorMessage, buildWebRuntimeRules, buildWorkspaceCodingStaticRules, canonicalizeCompactionText, coerceToolCallToDefinition, configure, containsStandaloneStructuredInvocationStart, createAgentMemoryLayer, createAppendToolsSectionCustomizer, createBackgroundBashDefinition, createConversationSink, createCustomRunCommandRegistry, createInitialWebAgentState, createRunCommandRuntimeBindings, createRuntimeStore, createToolAgentMessage, createToolRegistry, createToolsSectionOverrideCustomizer, createWebAgentMessageIdGenerator, createWebSearchToolActions, createWebToolLoopCallbacks, decodeEscapedShellText, defineRuntimeController, enrichToolResultWithUnixMetadata, executeBackgroundUnixCommandString, executeToolCallWithRunCommands, executeToolLoopStep, executeToolSafe, executeUnixCommandString, extractPrimaryCommandMetadata, extractTruncatedToolInfo, formatToolCallAsUnixCommand, formatToolDefinitions, formatToolResultMessage, formatToolsSection, formatUnixToolSurface, formatZodValidationError, getDiagnosticSummaryLine, getProviderConfig, getRunCommandPromptAvailability, getToolLogSummaryLine, isBackgroundBashToolCall, isBashToolCall, limitEntriesByRecency, machineStateToWebAgentPhase, mapConversationRoleToAgentRole, parseAgentResponse, parseResponseWithRecovery, parseStructuredAgentText, parseToolResultMessage, parseUnixToolCommand, readDiagnosticLevel, readDiagnosticSource, resolveToolDefinitionForInvocation, runStructuredLLMCompaction, selectLatestByKey, shouldAutoScrollThread, shouldSkipStepUserMessage, stripDiagnosticMessagePrefix, suppressWebValidationLog, tokenizeUnixCommand, truncateToolResult };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { encodingForModel } from 'js-tiktoken';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { setup, assign, createActor } from 'xstate';
|
|
4
4
|
|
|
@@ -24,10 +24,10 @@ var init_tiktoken_estimator = __esm({
|
|
|
24
24
|
encoder;
|
|
25
25
|
constructor() {
|
|
26
26
|
try {
|
|
27
|
-
this.encoder =
|
|
27
|
+
this.encoder = encodingForModel("gpt-4");
|
|
28
28
|
} catch (err) {
|
|
29
29
|
throw new Error(
|
|
30
|
-
`Failed to initialize tiktoken encoder
|
|
30
|
+
`Failed to initialize tiktoken encoder: ${err instanceof Error ? err.message : err}`
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -36,10 +36,7 @@ var init_tiktoken_estimator = __esm({
|
|
|
36
36
|
return this.encoder.encode(text).length;
|
|
37
37
|
}
|
|
38
38
|
dispose() {
|
|
39
|
-
|
|
40
|
-
this.encoder.free();
|
|
41
|
-
this.encoder = null;
|
|
42
|
-
}
|
|
39
|
+
this.encoder = null;
|
|
43
40
|
}
|
|
44
41
|
};
|
|
45
42
|
}
|
|
@@ -1010,10 +1007,6 @@ var SHARED_TOOL_CALL_EXAMPLE_LINES = [
|
|
|
1010
1007
|
` \u2717 ${INCORRECT_INLINE_PROSE_AND_TOOL_SLUG_EXAMPLE}`,
|
|
1011
1008
|
` \u2717 ${INCORRECT_INLINE_HEADER_AND_PAYLOAD_EXAMPLE}`
|
|
1012
1009
|
];
|
|
1013
|
-
var CONTINUE_TOOL_CALL_RESPONSE_EXAMPLE = [
|
|
1014
|
-
"I need to inspect the file first.",
|
|
1015
|
-
SINGLE_TOOL_CALL_RUN_LINE_EXAMPLE
|
|
1016
|
-
].join("\n");
|
|
1017
1010
|
function buildBashCommandsSection(options) {
|
|
1018
1011
|
return buildBashCommandsSectionLines(options).join("\n");
|
|
1019
1012
|
}
|
|
@@ -5776,30 +5769,20 @@ var SHARED_WORKSPACE_AGENT_MEMORY_PRESET = {
|
|
|
5776
5769
|
systemPromptOverhead: 4e3,
|
|
5777
5770
|
toolMemoryExtractor: DEFAULT_TOOL_MEMORY_EXTRACTOR
|
|
5778
5771
|
};
|
|
5779
|
-
|
|
5780
|
-
hammer: SHARED_WORKSPACE_AGENT_MEMORY_PRESET,
|
|
5781
|
-
magic: SHARED_WORKSPACE_AGENT_MEMORY_PRESET,
|
|
5782
|
-
monoslides: SHARED_WORKSPACE_AGENT_MEMORY_PRESET,
|
|
5783
|
-
monospace: SHARED_WORKSPACE_AGENT_MEMORY_PRESET
|
|
5784
|
-
};
|
|
5785
|
-
function createAgentMemoryLayer(preset, overrides) {
|
|
5786
|
-
const presetConfig = PRESETS[preset];
|
|
5787
|
-
if (!presetConfig) {
|
|
5788
|
-
throw new Error(`Unknown memory preset: "${preset}". Available: ${Object.keys(PRESETS).join(", ")}`);
|
|
5789
|
-
}
|
|
5772
|
+
function createAgentMemoryLayer(_preset, overrides) {
|
|
5790
5773
|
return new AgentMemoryLayer({
|
|
5791
|
-
compactionTokenThreshold:
|
|
5792
|
-
protectedContextTokens:
|
|
5793
|
-
stateBudgetTokens:
|
|
5794
|
-
maxRawHistory:
|
|
5795
|
-
compactionDebounceTurns:
|
|
5796
|
-
systemPromptOverhead:
|
|
5774
|
+
compactionTokenThreshold: SHARED_WORKSPACE_AGENT_MEMORY_PRESET.compactionTokenThreshold,
|
|
5775
|
+
protectedContextTokens: SHARED_WORKSPACE_AGENT_MEMORY_PRESET.protectedContextTokens,
|
|
5776
|
+
stateBudgetTokens: SHARED_WORKSPACE_AGENT_MEMORY_PRESET.stateBudgetTokens,
|
|
5777
|
+
maxRawHistory: SHARED_WORKSPACE_AGENT_MEMORY_PRESET.maxRawHistory,
|
|
5778
|
+
compactionDebounceTurns: SHARED_WORKSPACE_AGENT_MEMORY_PRESET.compactionDebounceTurns,
|
|
5779
|
+
systemPromptOverhead: SHARED_WORKSPACE_AGENT_MEMORY_PRESET.systemPromptOverhead,
|
|
5797
5780
|
tokenEstimator: overrides?.tokenEstimator ?? new CharTokenEstimator(),
|
|
5798
5781
|
compactionClient: overrides?.compactionClient,
|
|
5799
5782
|
compactionTemperature: getCompactionLlmTemperature(),
|
|
5800
5783
|
compactionMaxTokens: getCompactionLlmMaxTokens(),
|
|
5801
5784
|
getToolDefinitions: overrides?.getToolDefinitions,
|
|
5802
|
-
toolMemoryExtractor: overrides?.toolMemoryExtractor ??
|
|
5785
|
+
toolMemoryExtractor: overrides?.toolMemoryExtractor ?? SHARED_WORKSPACE_AGENT_MEMORY_PRESET.toolMemoryExtractor,
|
|
5803
5786
|
logger: overrides?.logger
|
|
5804
5787
|
});
|
|
5805
5788
|
}
|
|
@@ -7158,9 +7141,6 @@ function splitToolLogRevealSegments(content) {
|
|
|
7158
7141
|
function createWebSearchToolActions(deps) {
|
|
7159
7142
|
return {
|
|
7160
7143
|
executeWebTool: async (input) => {
|
|
7161
|
-
if (input.tool !== "BraveWebSearch" && input.tool !== "BochaWebSearch") {
|
|
7162
|
-
throw new Error(`Unknown tool: ${String(input.tool)}`);
|
|
7163
|
-
}
|
|
7164
7144
|
return deps.executeWebSearch(input.tool, input.input);
|
|
7165
7145
|
}
|
|
7166
7146
|
};
|
|
@@ -7420,6 +7400,6 @@ async function executeToolLoopStep(options) {
|
|
|
7420
7400
|
};
|
|
7421
7401
|
}
|
|
7422
7402
|
|
|
7423
|
-
export { AGENT_MACHINE_STATES, AgentLoop, AgentMemoryLayer, ApiError, BackgroundBashRunCommand, BaseMemoryLayer, BaseValidationEnforcer, BashRunCommand, CODE_QUALITY_RULE_LINE,
|
|
7403
|
+
export { AGENT_MACHINE_STATES, AgentLoop, AgentMemoryLayer, ApiError, BackgroundBashRunCommand, BaseMemoryLayer, BaseValidationEnforcer, BashRunCommand, CODE_QUALITY_RULE_LINE, CharTokenEstimator, DEFAULT_AGENT_FALLBACK_SYSTEM_PROMPT, DEFAULT_ALLOWED_RUN_TARGETS, DEFAULT_RUN_COMMAND_REGISTRY, DEFAULT_THREAD_AUTO_SCROLL_BOTTOM_THRESHOLD, DEFAULT_TOOL_MEMORY_EXTRACTOR, ERROR_RECOVERY_RULE_LINE, ERROR_TRUNCATED_RESPONSE, INCREMENTAL_TESTING_RULE_LINE, JUST_BASH_SCRIPT_EXECUTION_RESTRICTION_LINES, JUST_BASH_SHELL_NATIVE_WORKFLOW_COMMAND_EXAMPLES, LLMClient, LLMResponseSchema, MAX_TOOL_RESULT_CHARS, PORT_CONFLICT_RULE_LINE, PendingAgentMessageBuffer, ProxyTool, ROOT_CAUSES_RULE_LINE, RunCommand, RunCommandRegistry, SHARED_TOOL_CALL_EXAMPLE_LINES, SHARED_TOOL_USAGE_RULE, SINGLE_TOOL_CALL_RUN_LINE_EXAMPLE, SKILL_INVOKE_READ_RULE_LINE, STANDARD_TOOL_CALL_FORMAT_RULES, SUPPORTED_RUN_TARGETS, StreamingToolParser, TODO_LIST_FIRST_RESPONSE_RULE_LINE, TOOL_CALL_SEPARATOR_RULE, Tool, ToolCallSchema, ToolLoopAgentRuntime, ToolRegistry, ToolRunCommand, VALIDATE_AFTER_CHANGES_RULE_LINE, WebToolLoopAgentRuntime, WebValidationEnforcer, agentMachine, applyIdleWebAgentState, applyInitialWebAgentRunState, buildAgentIdentityLine, buildAgentSystemPrompt, buildCompactionEntry, buildCoreStaticRules, buildNoStructuredResponseFoundError, buildParseFeedback, buildSkillAwareStaticContext, buildSkillsSection, buildStepUserMessage, buildToolLogRevealFrames, buildToolUsageExample, buildValidationErrorMessage, buildWebRuntimeRules, buildWorkspaceCodingStaticRules, canonicalizeCompactionText, coerceToolCallToDefinition, configure, containsStandaloneStructuredInvocationStart, createAgentMemoryLayer, createAppendToolsSectionCustomizer, createBackgroundBashDefinition, createConversationSink, createCustomRunCommandRegistry, createInitialWebAgentState, createRunCommandRuntimeBindings, createRuntimeStore, createToolAgentMessage, createToolRegistry, createToolsSectionOverrideCustomizer, createWebAgentMessageIdGenerator, createWebSearchToolActions, createWebToolLoopCallbacks, decodeEscapedShellText, defineRuntimeController, enrichToolResultWithUnixMetadata, executeBackgroundUnixCommandString, executeToolCallWithRunCommands, executeToolLoopStep, executeToolSafe, executeUnixCommandString, extractPrimaryCommandMetadata, extractTruncatedToolInfo, formatToolCallAsUnixCommand, formatToolDefinitions, formatToolResultMessage, formatToolsSection, formatUnixToolSurface, formatZodValidationError, getDiagnosticSummaryLine, getProviderConfig, getRunCommandPromptAvailability, getToolLogSummaryLine, isBackgroundBashToolCall, isBashToolCall, limitEntriesByRecency, machineStateToWebAgentPhase, mapConversationRoleToAgentRole, parseAgentResponse, parseResponseWithRecovery, parseStructuredAgentText, parseToolResultMessage, parseUnixToolCommand, readDiagnosticLevel, readDiagnosticSource, resolveToolDefinitionForInvocation, runStructuredLLMCompaction, selectLatestByKey, shouldAutoScrollThread, shouldSkipStepUserMessage, stripDiagnosticMessagePrefix, suppressWebValidationLog, tokenizeUnixCommand, truncateToolResult };
|
|
7424
7404
|
//# sourceMappingURL=index.js.map
|
|
7425
7405
|
//# sourceMappingURL=index.js.map
|