@botbotgo/agent-harness 0.0.432 → 0.0.434

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.
@@ -1,2 +1,2 @@
1
- export declare const AGENT_HARNESS_VERSION = "0.0.432";
1
+ export declare const AGENT_HARNESS_VERSION = "0.0.434";
2
2
  export declare const AGENT_HARNESS_RELEASE_DATE = "2026-05-03";
@@ -1,2 +1,2 @@
1
- export const AGENT_HARNESS_VERSION = "0.0.432";
1
+ export const AGENT_HARNESS_VERSION = "0.0.434";
2
2
  export const AGENT_HARNESS_RELEASE_DATE = "2026-05-03";
@@ -1,6 +1 @@
1
1
  export declare function summarizeAssistantText(text: string): string;
2
- export declare function shouldDirectlyListWorkspaceFiles(input: string | Array<{
3
- type?: unknown;
4
- text?: unknown;
5
- }>): boolean;
6
- export declare function renderDirectWorkspaceListing(workspaceRoot: string, targetPath?: string): string;
@@ -1,20 +1,5 @@
1
- import { readdirSync } from "node:fs";
2
- import path from "node:path";
3
- const DIRECT_LISTING_PATTERNS = [
4
- /^ls$/iu,
5
- /^list files$/iu,
6
- /^list all files$/iu,
7
- /^list the files$/iu,
8
- /^list all the files$/iu,
9
- /^list files in (?:the )?(?:current )?directory$/iu,
10
- /^list all files in (?:the )?(?:current )?directory$/iu,
11
- /^show files$/iu,
12
- /^show me the files$/iu,
13
- /^show the files$/iu,
14
- ];
15
1
  const GENERIC_ASSISTANT_SUMMARY_MAX_CHARS = 180;
16
2
  const GENERIC_ASSISTANT_SUMMARY_MAX_LINES = 6;
17
- const DIRECT_LISTING_MAX_ENTRIES = 400;
18
3
  function parseListingEntry(line) {
19
4
  const trimmed = line.trim();
20
5
  if (!trimmed || trimmed === "...[truncated]" || trimmed === "... [truncated]") {
@@ -103,66 +88,3 @@ export function summarizeAssistantText(text) {
103
88
  }
104
89
  return summarizeGenericAssistantResponse(normalized);
105
90
  }
106
- function extractPlainTextInput(input) {
107
- if (typeof input === "string") {
108
- const normalized = input.trim();
109
- return normalized.length > 0 ? normalized : undefined;
110
- }
111
- if (!Array.isArray(input)) {
112
- return undefined;
113
- }
114
- const text = input
115
- .filter((part) => part?.type === "text" && typeof part.text === "string")
116
- .map((part) => part.text.trim())
117
- .filter((part) => part.length > 0)
118
- .join("\n")
119
- .trim();
120
- return text.length > 0 ? text : undefined;
121
- }
122
- function normalizeDirectListingInput(text) {
123
- return text
124
- .trim()
125
- .toLowerCase()
126
- .replace(/[。!?!?,,;;::]/gu, " ")
127
- .replace(/\s+/gu, " ")
128
- .replace(/^(?:please|pls|can you|could you|would you|help me)\s+/u, "")
129
- .replace(/\s+(?:please)$/u, "")
130
- .trim();
131
- }
132
- function isChineseDirectListingPrompt(text) {
133
- const normalized = text
134
- .trim()
135
- .replace(/[。!?!?,,;;::\s]/gu, "");
136
- if (!normalized) {
137
- return false;
138
- }
139
- if (!/(?:列出|查看)/u.test(normalized)) {
140
- return false;
141
- }
142
- if (!/(?:文件|文件列表)/u.test(normalized)) {
143
- return false;
144
- }
145
- return /^(?:请|麻烦|帮我|请帮我)?(?:列出|查看)(?:当前目录下?)?(?:所有)?(?:的)?文件(?:列表)?(?:一下)?$/u.test(normalized);
146
- }
147
- export function shouldDirectlyListWorkspaceFiles(input) {
148
- const plainText = extractPlainTextInput(input);
149
- if (!plainText) {
150
- return false;
151
- }
152
- const normalized = normalizeDirectListingInput(plainText);
153
- return DIRECT_LISTING_PATTERNS.some((pattern) => pattern.test(normalized)) || isChineseDirectListingPrompt(plainText);
154
- }
155
- export function renderDirectWorkspaceListing(workspaceRoot, targetPath = ".") {
156
- const resolvedTarget = path.resolve(workspaceRoot, targetPath);
157
- const entries = readdirSync(resolvedTarget, { withFileTypes: true })
158
- .sort((left, right) => left.name.localeCompare(right.name))
159
- .slice(0, DIRECT_LISTING_MAX_ENTRIES + 1);
160
- const lines = entries.slice(0, DIRECT_LISTING_MAX_ENTRIES).map((entry) => {
161
- const renderedPath = path.join(targetPath, entry.name).replace(/\\/g, "/");
162
- return entry.isDirectory() ? `${renderedPath} (directory)` : renderedPath;
163
- });
164
- if (entries.length > DIRECT_LISTING_MAX_ENTRIES) {
165
- lines.push("...[truncated]");
166
- }
167
- return lines.join("\n");
168
- }
@@ -227,6 +227,17 @@ function buildEvidenceToolArgs(tool, taskText, evidenceText = taskText) {
227
227
  }
228
228
  return args;
229
229
  }
230
+ function escapeRegExp(value) {
231
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
232
+ }
233
+ function textExplicitlyNamesTool(text, toolName) {
234
+ const name = toolName.trim();
235
+ if (!name) {
236
+ return false;
237
+ }
238
+ const pattern = new RegExp(`(?:^|[^\\p{L}\\p{N}_-])${escapeRegExp(name)}(?:$|[^\\p{L}\\p{N}_-])`, "iu");
239
+ return pattern.test(text);
240
+ }
230
241
  function resolveCommittedEvidenceTools(input) {
231
242
  const availableTools = readResolvedEvidenceTools(input.resolvedTools)
232
243
  .filter((tool) => tool.name !== "write_todos" && tool.name !== "read_todos" && typeof tool.invoke === "function");
@@ -234,10 +245,9 @@ function resolveCommittedEvidenceTools(input) {
234
245
  return [];
235
246
  }
236
247
  const stateText = `${input.taskText}\n${stringifyTaskState(readMessages(input.result))}`;
237
- const selectionText = stateText.toLowerCase();
238
248
  const selected = [];
239
249
  for (const tool of availableTools) {
240
- if (!selectionText.includes(tool.name.toLowerCase())) {
250
+ if (!textExplicitlyNamesTool(stateText, tool.name)) {
241
251
  continue;
242
252
  }
243
253
  selected.push({
@@ -32,7 +32,6 @@ export declare class AgentRuntimeAdapter {
32
32
  private resolveFilesystemRootDir;
33
33
  private resolveBuiltinMiddlewareBackend;
34
34
  private buildFunctionToolRuntimeContext;
35
- private tryHandleDirectWorkspaceListing;
36
35
  private createDeclaredMiddlewareResolverOptions;
37
36
  private createAssemblyResolvers;
38
37
  private invokeBuiltinTaskTool;
@@ -16,7 +16,6 @@ import { applyToolRecoveryInstruction as applyToolRecoveryInstructionHelper, app
16
16
  import { extractSubagentRequestText, invokeBuiltinTaskTool as invokeBuiltinTaskToolHelper, materializeAutomaticSummarizationMiddleware as materializeAutomaticSummarizationMiddlewareHelper, resolveBuiltinMiddlewareBackend as resolveBuiltinMiddlewareBackendHelper, resolveBuiltinMiddlewareTools as resolveBuiltinMiddlewareToolsHelper, resolveLangChainRuntimeExtensionMiddleware as resolveLangChainRuntimeExtensionMiddlewareHelper, resolveMiddleware as resolveMiddlewareHelper, resolveSubagents as resolveSubagentsHelper, wrapRequestResultAsSubagentResponse, } from "./adapter/middleware-assembly.js";
17
17
  import { isEmptyFinalAiMessageError, resolveBindingTimeout, resolveStreamIdleTimeout, } from "./adapter/resilience.js";
18
18
  import { createResolvedModel } from "./adapter/model/model-providers.js";
19
- import { renderDirectWorkspaceListing, shouldDirectlyListWorkspaceFiles } from "./adapter/direct-builtin-utility.js";
20
19
  import { appendProviderToolCallAliasTools, resolveAdapterTools } from "./adapter/tool-resolution.js";
21
20
  import { normalizeToolArgsForSchema } from "./adapter/tool/tool-arguments.js";
22
21
  import { resolveRuntimeStreamExecutionContext, } from "./adapter/flow/execution-context.js";
@@ -860,29 +859,6 @@ export class AgentRuntimeAdapter {
860
859
  },
861
860
  };
862
861
  }
863
- async tryHandleDirectWorkspaceListing(binding, input, options = {}) {
864
- if (binding.agent.executionMode !== "deepagent") {
865
- return undefined;
866
- }
867
- if (!shouldDirectlyListWorkspaceFiles(input)) {
868
- return undefined;
869
- }
870
- const workspaceRoot = binding.harnessRuntime.workspaceRoot ?? process.cwd();
871
- let output = "";
872
- try {
873
- output = renderDirectWorkspaceListing(workspaceRoot, ".");
874
- }
875
- catch {
876
- return undefined;
877
- }
878
- if (output.trim().length === 0) {
879
- return undefined;
880
- }
881
- return {
882
- toolName: "list_files",
883
- output,
884
- };
885
- }
886
862
  createDeclaredMiddlewareResolverOptions(binding, options = {}) {
887
863
  return {
888
864
  resolveModel: (model) => this.resolveModel(model),
@@ -1298,30 +1274,6 @@ export class AgentRuntimeAdapter {
1298
1274
  }
1299
1275
  }
1300
1276
  async invoke(binding, input, sessionId, requestId, resumePayload, history = [], options = {}) {
1301
- const directListing = await this.tryHandleDirectWorkspaceListing(binding, input, {
1302
- ...options,
1303
- sessionId,
1304
- requestId,
1305
- });
1306
- if (directListing) {
1307
- return {
1308
- sessionId,
1309
- requestId,
1310
- agentId: binding.agent.id,
1311
- state: "completed",
1312
- output: directListing.output,
1313
- finalMessageText: directListing.output,
1314
- metadata: {
1315
- executedToolResults: [{
1316
- toolName: directListing.toolName,
1317
- output: directListing.output,
1318
- }],
1319
- upstreamResult: {
1320
- directUtility: directListing.toolName,
1321
- },
1322
- },
1323
- };
1324
- }
1325
1277
  const compactDelegation = await this.tryDelegateWithCompactRouter(binding, input, sessionId, requestId, {
1326
1278
  ...options,
1327
1279
  sessionId,
@@ -2337,23 +2289,6 @@ export class AgentRuntimeAdapter {
2337
2289
  };
2338
2290
  }
2339
2291
  async *stream(binding, input, sessionId, history = [], options = {}) {
2340
- const directListing = await this.tryHandleDirectWorkspaceListing(binding, input, {
2341
- ...options,
2342
- sessionId,
2343
- requestId: options.requestId,
2344
- });
2345
- if (directListing) {
2346
- yield {
2347
- kind: "tool-result",
2348
- toolName: directListing.toolName,
2349
- output: directListing.output,
2350
- };
2351
- yield {
2352
- kind: "content",
2353
- content: directListing.output,
2354
- };
2355
- return;
2356
- }
2357
2292
  if (isDelegationOnlyDeepAgentBinding(binding)) {
2358
2293
  yield {
2359
2294
  kind: "commentary",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbotgo/agent-harness",
3
- "version": "0.0.432",
3
+ "version": "0.0.434",
4
4
  "description": "Workspace runtime for multi-agent applications",
5
5
  "license": "MIT",
6
6
  "type": "module",