hammer-ai 0.2.1 → 0.2.3
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 +106 -1
- package/dist/index.js +38 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import * as xstate from 'xstate';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -260,6 +261,107 @@ declare function configure(options: HammerAgentConfig): void;
|
|
|
260
261
|
*/
|
|
261
262
|
declare function getProviderConfig(name: ProviderName): LLMProviderConfig;
|
|
262
263
|
|
|
264
|
+
/**
|
|
265
|
+
* Zod schemas for LLM response validation and normalization.
|
|
266
|
+
*
|
|
267
|
+
* Handles common model mistakes such as garbled status strings.
|
|
268
|
+
*
|
|
269
|
+
* Shared across Hammer, Magic, Monoslides, Monospace, and any other agent consumer.
|
|
270
|
+
*/
|
|
271
|
+
|
|
272
|
+
declare const ToolCallSchema: z.ZodEffects<z.ZodObject<{
|
|
273
|
+
kind: z.ZodOptional<z.ZodEnum<["tool", "bash", "background_bash"]>>;
|
|
274
|
+
name: z.ZodString;
|
|
275
|
+
parameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
276
|
+
rawInvocation: z.ZodOptional<z.ZodString>;
|
|
277
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
278
|
+
}, "strict", z.ZodTypeAny, {
|
|
279
|
+
name: string;
|
|
280
|
+
parameters: Record<string, any>;
|
|
281
|
+
kind?: "tool" | "bash" | "background_bash" | undefined;
|
|
282
|
+
rawInvocation?: string | undefined;
|
|
283
|
+
truncated?: boolean | undefined;
|
|
284
|
+
}, {
|
|
285
|
+
name: string;
|
|
286
|
+
kind?: "tool" | "bash" | "background_bash" | undefined;
|
|
287
|
+
parameters?: Record<string, any> | undefined;
|
|
288
|
+
rawInvocation?: string | undefined;
|
|
289
|
+
truncated?: boolean | undefined;
|
|
290
|
+
}>, {
|
|
291
|
+
name: string;
|
|
292
|
+
parameters: Record<string, any>;
|
|
293
|
+
kind?: "tool" | "bash" | "background_bash" | undefined;
|
|
294
|
+
rawInvocation?: string | undefined;
|
|
295
|
+
truncated?: boolean | undefined;
|
|
296
|
+
}, {
|
|
297
|
+
name: string;
|
|
298
|
+
kind?: "tool" | "bash" | "background_bash" | undefined;
|
|
299
|
+
parameters?: Record<string, any> | undefined;
|
|
300
|
+
rawInvocation?: string | undefined;
|
|
301
|
+
truncated?: boolean | undefined;
|
|
302
|
+
}>;
|
|
303
|
+
declare const LLMResponseSchema: z.ZodObject<{
|
|
304
|
+
content: z.ZodOptional<z.ZodString>;
|
|
305
|
+
reasoning: z.ZodDefault<z.ZodString>;
|
|
306
|
+
scratchpad: z.ZodOptional<z.ZodString>;
|
|
307
|
+
selectedToolCall: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
308
|
+
kind: z.ZodOptional<z.ZodEnum<["tool", "bash", "background_bash"]>>;
|
|
309
|
+
name: z.ZodString;
|
|
310
|
+
parameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
311
|
+
rawInvocation: z.ZodOptional<z.ZodString>;
|
|
312
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
313
|
+
}, "strict", z.ZodTypeAny, {
|
|
314
|
+
name: string;
|
|
315
|
+
parameters: Record<string, any>;
|
|
316
|
+
kind?: "tool" | "bash" | "background_bash" | undefined;
|
|
317
|
+
rawInvocation?: string | undefined;
|
|
318
|
+
truncated?: boolean | undefined;
|
|
319
|
+
}, {
|
|
320
|
+
name: string;
|
|
321
|
+
kind?: "tool" | "bash" | "background_bash" | undefined;
|
|
322
|
+
parameters?: Record<string, any> | undefined;
|
|
323
|
+
rawInvocation?: string | undefined;
|
|
324
|
+
truncated?: boolean | undefined;
|
|
325
|
+
}>, {
|
|
326
|
+
name: string;
|
|
327
|
+
parameters: Record<string, any>;
|
|
328
|
+
kind?: "tool" | "bash" | "background_bash" | undefined;
|
|
329
|
+
rawInvocation?: string | undefined;
|
|
330
|
+
truncated?: boolean | undefined;
|
|
331
|
+
}, {
|
|
332
|
+
name: string;
|
|
333
|
+
kind?: "tool" | "bash" | "background_bash" | undefined;
|
|
334
|
+
parameters?: Record<string, any> | undefined;
|
|
335
|
+
rawInvocation?: string | undefined;
|
|
336
|
+
truncated?: boolean | undefined;
|
|
337
|
+
}>>;
|
|
338
|
+
outcome: z.ZodEffects<z.ZodEnum<["continue", "success", "failure"]>, "success" | "continue" | "failure", unknown>;
|
|
339
|
+
}, "strict", z.ZodTypeAny, {
|
|
340
|
+
reasoning: string;
|
|
341
|
+
outcome: "success" | "continue" | "failure";
|
|
342
|
+
content?: string | undefined;
|
|
343
|
+
scratchpad?: string | undefined;
|
|
344
|
+
selectedToolCall?: {
|
|
345
|
+
name: string;
|
|
346
|
+
parameters: Record<string, any>;
|
|
347
|
+
kind?: "tool" | "bash" | "background_bash" | undefined;
|
|
348
|
+
rawInvocation?: string | undefined;
|
|
349
|
+
truncated?: boolean | undefined;
|
|
350
|
+
} | undefined;
|
|
351
|
+
}, {
|
|
352
|
+
content?: string | undefined;
|
|
353
|
+
reasoning?: string | undefined;
|
|
354
|
+
scratchpad?: string | undefined;
|
|
355
|
+
selectedToolCall?: {
|
|
356
|
+
name: string;
|
|
357
|
+
kind?: "tool" | "bash" | "background_bash" | undefined;
|
|
358
|
+
parameters?: Record<string, any> | undefined;
|
|
359
|
+
rawInvocation?: string | undefined;
|
|
360
|
+
truncated?: boolean | undefined;
|
|
361
|
+
} | undefined;
|
|
362
|
+
outcome?: unknown;
|
|
363
|
+
}>;
|
|
364
|
+
|
|
263
365
|
/**
|
|
264
366
|
* LLMClient – generic, browser-compatible streaming client for
|
|
265
367
|
* OpenAI-compatible chat completion endpoints.
|
|
@@ -1706,6 +1808,7 @@ declare function createAgentMemoryLayer(preset: string, overrides?: AgentMemoryF
|
|
|
1706
1808
|
* letting each agent layer domain-specific constraints on top.
|
|
1707
1809
|
*/
|
|
1708
1810
|
declare const TOOL_CALL_SEPARATOR_RULE = "The slug header is a hard separator between prose/thought and command/action. Put all prose before the slug, put the standalone slug header on its own line, and put only the executable payload on the following line(s). There must be a newline before the slug header and a newline after the slug header.";
|
|
1811
|
+
declare const SHARED_TOOL_USAGE_RULE = "Use only the tools that are actually listed in the tool section. Do not invent tools, parameters, wrapper flags, bare assignment-style arguments, or capabilities that are not explicitly listed. Follow each tool's description, usage surface, and parameter schema exactly.";
|
|
1709
1812
|
declare const JUST_BASH_SHELL_NATIVE_WORKFLOW_COMMAND_EXAMPLES: string;
|
|
1710
1813
|
declare const JUST_BASH_SCRIPT_EXECUTION_RESTRICTION_LINES: string[];
|
|
1711
1814
|
interface BashCommandsSectionOptions {
|
|
@@ -1730,6 +1833,7 @@ declare const ROOT_CAUSES_RULE_LINE = "**ROOT CAUSES**: Fix root causes rather t
|
|
|
1730
1833
|
declare const VALIDATE_AFTER_CHANGES_RULE_LINE = "**VALIDATE AFTER CHANGES**: Check syntax, imports, and obvious integration errors after editing.";
|
|
1731
1834
|
declare const INCREMENTAL_TESTING_RULE_LINE = "**INCREMENTAL TESTING**: Write \u2192 test \u2192 fix before moving on. Verify deliverables actually work before finishing successfully.";
|
|
1732
1835
|
declare const CODE_QUALITY_RULE_LINE = "**CODE QUALITY**: For TypeScript, prefer `tsc --noEmit` or the repo's build/test command after meaningful edits.";
|
|
1836
|
+
declare const SKILL_INVOKE_READ_RULE_LINE = "If the user says invoke /skill-name, treat that as asking you to read the skill-name skill with ReadSkill before proceeding.";
|
|
1733
1837
|
declare const TODO_LIST_FIRST_RESPONSE_RULE_LINE = "You MUST call the manage_todo_list tool in your very first response to plan your work before executing any other tool. Break the task into specific, actionable steps. On subsequent responses, update the todo list to reflect progress.";
|
|
1734
1838
|
interface FormatToolsSectionOptions {
|
|
1735
1839
|
bashAvailable?: boolean;
|
|
@@ -1761,6 +1865,7 @@ interface SkillSummaryLike {
|
|
|
1761
1865
|
description: string;
|
|
1762
1866
|
};
|
|
1763
1867
|
}
|
|
1868
|
+
declare function buildSkillsSection(allSkills: SkillSummaryLike[]): string;
|
|
1764
1869
|
declare function buildSkillAwareStaticContext(options: {
|
|
1765
1870
|
allSkills: SkillSummaryLike[];
|
|
1766
1871
|
staticRules: string;
|
|
@@ -2300,4 +2405,4 @@ declare function runStructuredLLMCompaction<TMessage extends MemoryMessage, TSta
|
|
|
2300
2405
|
parseState: (obj: Record<string, unknown>) => TState | null;
|
|
2301
2406
|
}): Promise<TState | null>;
|
|
2302
2407
|
|
|
2303
|
-
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, CONTINUE_TOOL_CALL_RESPONSE_EXAMPLE, 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, 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, SINGLE_TOOL_CALL_RUN_LINE_EXAMPLE, 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, 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, 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 };
|
|
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, CONTINUE_TOOL_CALL_RESPONSE_EXAMPLE, 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,6 +1,6 @@
|
|
|
1
1
|
import { encoding_for_model } from 'tiktoken';
|
|
2
|
-
import { setup, assign, createActor } from 'xstate';
|
|
3
2
|
import { z } from 'zod';
|
|
3
|
+
import { setup, assign, createActor } from 'xstate';
|
|
4
4
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -133,6 +133,42 @@ function getCompactionLlmTemperature() {
|
|
|
133
133
|
function getCompactionLlmMaxTokens() {
|
|
134
134
|
return _config.compactionLlmMaxTokens;
|
|
135
135
|
}
|
|
136
|
+
function normalizeToolCallName(name) {
|
|
137
|
+
return name.replace(/[\s_-]+/g, "").toLowerCase();
|
|
138
|
+
}
|
|
139
|
+
var ToolCallSchema = z.object({
|
|
140
|
+
kind: z.enum(["tool", "bash", "background_bash"]).optional(),
|
|
141
|
+
name: z.string().min(1, "Tool call name is required"),
|
|
142
|
+
parameters: z.record(z.string(), z.any()).default({}),
|
|
143
|
+
rawInvocation: z.string().optional(),
|
|
144
|
+
truncated: z.boolean().optional()
|
|
145
|
+
}).strict().superRefine((value, ctx) => {
|
|
146
|
+
const normalizedName = normalizeToolCallName(value.name);
|
|
147
|
+
if (normalizedName === "bash" && value.kind !== "bash") {
|
|
148
|
+
ctx.addIssue({
|
|
149
|
+
code: z.ZodIssueCode.custom,
|
|
150
|
+
path: ["name"],
|
|
151
|
+
message: 'Bash is not a registered tool name. Use kind: "bash" instead.'
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (normalizedName === "backgroundbash" && value.kind !== "background_bash") {
|
|
155
|
+
ctx.addIssue({
|
|
156
|
+
code: z.ZodIssueCode.custom,
|
|
157
|
+
path: ["name"],
|
|
158
|
+
message: 'BackgroundBash is not a registered tool name. Use kind: "background_bash" instead.'
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
var LLMResponseSchema = z.object({
|
|
163
|
+
content: z.string().optional(),
|
|
164
|
+
reasoning: z.string().default("No reasoning provided"),
|
|
165
|
+
scratchpad: z.string().optional(),
|
|
166
|
+
selectedToolCall: ToolCallSchema.optional(),
|
|
167
|
+
outcome: z.preprocess(
|
|
168
|
+
(v) => typeof v === "string" ? v.toLowerCase() : v,
|
|
169
|
+
z.enum(["continue", "success", "failure"])
|
|
170
|
+
)
|
|
171
|
+
}).strict();
|
|
136
172
|
|
|
137
173
|
// src/llm-client.ts
|
|
138
174
|
function shouldOmitTemperature(config) {
|
|
@@ -3389,42 +3425,6 @@ function parseDuration(raw) {
|
|
|
3389
3425
|
}
|
|
3390
3426
|
return Number(trimmed) || 0;
|
|
3391
3427
|
}
|
|
3392
|
-
function normalizeToolCallName(name) {
|
|
3393
|
-
return name.replace(/[\s_-]+/g, "").toLowerCase();
|
|
3394
|
-
}
|
|
3395
|
-
var ToolCallSchema = z.object({
|
|
3396
|
-
kind: z.enum(["tool", "bash", "background_bash"]).optional(),
|
|
3397
|
-
name: z.string().min(1, "Tool call name is required"),
|
|
3398
|
-
parameters: z.record(z.string(), z.any()).default({}),
|
|
3399
|
-
rawInvocation: z.string().optional(),
|
|
3400
|
-
truncated: z.boolean().optional()
|
|
3401
|
-
}).strict().superRefine((value, ctx) => {
|
|
3402
|
-
const normalizedName = normalizeToolCallName(value.name);
|
|
3403
|
-
if (normalizedName === "bash" && value.kind !== "bash") {
|
|
3404
|
-
ctx.addIssue({
|
|
3405
|
-
code: z.ZodIssueCode.custom,
|
|
3406
|
-
path: ["name"],
|
|
3407
|
-
message: 'Bash is not a registered tool name. Use kind: "bash" instead.'
|
|
3408
|
-
});
|
|
3409
|
-
}
|
|
3410
|
-
if (normalizedName === "backgroundbash" && value.kind !== "background_bash") {
|
|
3411
|
-
ctx.addIssue({
|
|
3412
|
-
code: z.ZodIssueCode.custom,
|
|
3413
|
-
path: ["name"],
|
|
3414
|
-
message: 'BackgroundBash is not a registered tool name. Use kind: "background_bash" instead.'
|
|
3415
|
-
});
|
|
3416
|
-
}
|
|
3417
|
-
});
|
|
3418
|
-
var LLMResponseSchema = z.object({
|
|
3419
|
-
content: z.string().optional(),
|
|
3420
|
-
reasoning: z.string().default("No reasoning provided"),
|
|
3421
|
-
scratchpad: z.string().optional(),
|
|
3422
|
-
selectedToolCall: ToolCallSchema.optional(),
|
|
3423
|
-
outcome: z.preprocess(
|
|
3424
|
-
(v) => typeof v === "string" ? v.toLowerCase() : v,
|
|
3425
|
-
z.enum(["continue", "success", "failure"])
|
|
3426
|
-
)
|
|
3427
|
-
}).strict();
|
|
3428
3428
|
|
|
3429
3429
|
// src/agent-response-parser.ts
|
|
3430
3430
|
function parseAgentResponse(content, options) {
|
|
@@ -7420,6 +7420,6 @@ async function executeToolLoopStep(options) {
|
|
|
7420
7420
|
};
|
|
7421
7421
|
}
|
|
7422
7422
|
|
|
7423
|
-
export { AGENT_MACHINE_STATES, AgentLoop, AgentMemoryLayer, ApiError, BackgroundBashRunCommand, BaseMemoryLayer, BaseValidationEnforcer, BashRunCommand, CODE_QUALITY_RULE_LINE, CONTINUE_TOOL_CALL_RESPONSE_EXAMPLE, 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, MAX_TOOL_RESULT_CHARS, PORT_CONFLICT_RULE_LINE, PendingAgentMessageBuffer, ProxyTool, ROOT_CAUSES_RULE_LINE, RunCommand, RunCommandRegistry, SHARED_TOOL_CALL_EXAMPLE_LINES, SINGLE_TOOL_CALL_RUN_LINE_EXAMPLE, STANDARD_TOOL_CALL_FORMAT_RULES, SUPPORTED_RUN_TARGETS, StreamingToolParser, TODO_LIST_FIRST_RESPONSE_RULE_LINE, TOOL_CALL_SEPARATOR_RULE, Tool, ToolLoopAgentRuntime, ToolRegistry, ToolRunCommand, VALIDATE_AFTER_CHANGES_RULE_LINE, WebToolLoopAgentRuntime, WebValidationEnforcer, agentMachine, applyIdleWebAgentState, applyInitialWebAgentRunState, buildAgentIdentityLine, buildAgentSystemPrompt, buildCompactionEntry, buildCoreStaticRules, buildNoStructuredResponseFoundError, buildParseFeedback, buildSkillAwareStaticContext, 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 };
|
|
7423
|
+
export { AGENT_MACHINE_STATES, AgentLoop, AgentMemoryLayer, ApiError, BackgroundBashRunCommand, BaseMemoryLayer, BaseValidationEnforcer, BashRunCommand, CODE_QUALITY_RULE_LINE, CONTINUE_TOOL_CALL_RESPONSE_EXAMPLE, 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
7424
|
//# sourceMappingURL=index.js.map
|
|
7425
7425
|
//# sourceMappingURL=index.js.map
|