@botbotgo/agent-harness 0.0.313 → 0.0.314

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 +1 @@
1
- export declare const AGENT_HARNESS_VERSION = "0.0.312";
1
+ export declare const AGENT_HARNESS_VERSION = "0.0.313";
@@ -1 +1 @@
1
- export const AGENT_HARNESS_VERSION = "0.0.312";
1
+ export const AGENT_HARNESS_VERSION = "0.0.313";
@@ -1 +1,5 @@
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;
@@ -1,3 +1,15 @@
1
+ const DIRECT_LISTING_PATTERNS = [
2
+ /^ls$/iu,
3
+ /^list files$/iu,
4
+ /^list the files$/iu,
5
+ /^list files in (?:the )?(?:current )?directory$/iu,
6
+ /^show files$/iu,
7
+ /^show me the files$/iu,
8
+ /^show the files$/iu,
9
+ /^列出文件$/u,
10
+ /^列出当前目录(?:下)?文件$/u,
11
+ /^查看文件列表$/u,
12
+ ];
1
13
  const GENERIC_ASSISTANT_SUMMARY_MAX_CHARS = 180;
2
14
  const GENERIC_ASSISTANT_SUMMARY_MAX_LINES = 6;
3
15
  function parseListingEntry(line) {
@@ -88,3 +100,26 @@ export function summarizeAssistantText(text) {
88
100
  }
89
101
  return summarizeGenericAssistantResponse(normalized);
90
102
  }
103
+ function extractPlainTextInput(input) {
104
+ if (typeof input === "string") {
105
+ const normalized = input.trim();
106
+ return normalized.length > 0 ? normalized : undefined;
107
+ }
108
+ if (!Array.isArray(input)) {
109
+ return undefined;
110
+ }
111
+ const text = input
112
+ .filter((part) => part?.type === "text" && typeof part.text === "string")
113
+ .map((part) => part.text.trim())
114
+ .filter((part) => part.length > 0)
115
+ .join("\n")
116
+ .trim();
117
+ return text.length > 0 ? text : undefined;
118
+ }
119
+ export function shouldDirectlyListWorkspaceFiles(input) {
120
+ const normalized = extractPlainTextInput(input);
121
+ if (!normalized) {
122
+ return false;
123
+ }
124
+ return DIRECT_LISTING_PATTERNS.some((pattern) => pattern.test(normalized));
125
+ }
@@ -32,6 +32,7 @@ export declare class AgentRuntimeAdapter {
32
32
  private resolveFilesystemRootDir;
33
33
  private resolveBuiltinMiddlewareBackend;
34
34
  private buildFunctionToolRuntimeContext;
35
+ private tryHandleDirectWorkspaceListing;
35
36
  private createDeclaredMiddlewareResolverOptions;
36
37
  private createAssemblyResolvers;
37
38
  private invokeBuiltinTaskTool;
@@ -11,6 +11,7 @@ import { applyToolRecoveryInstruction as applyToolRecoveryInstructionHelper, app
11
11
  import { invokeBuiltinTaskTool as invokeBuiltinTaskToolHelper, materializeAutomaticSummarizationMiddleware as materializeAutomaticSummarizationMiddlewareHelper, resolveBuiltinMiddlewareBackend as resolveBuiltinMiddlewareBackendHelper, resolveBuiltinMiddlewareTools as resolveBuiltinMiddlewareToolsHelper, resolveLangChainRuntimeExtensionMiddleware as resolveLangChainRuntimeExtensionMiddlewareHelper, resolveMiddleware as resolveMiddlewareHelper, resolveSubagents as resolveSubagentsHelper, } from "./adapter/middleware-assembly.js";
12
12
  import { resolveBindingTimeout, resolveStreamIdleTimeout, } from "./adapter/resilience.js";
13
13
  import { createResolvedModel } from "./adapter/model/model-providers.js";
14
+ import { shouldDirectlyListWorkspaceFiles } from "./adapter/direct-builtin-utility.js";
14
15
  import { resolveAdapterTools } from "./adapter/tool-resolution.js";
15
16
  import { resolveRuntimeStreamExecutionContext, } from "./adapter/flow/execution-context.js";
16
17
  import { isRetryableProviderError } from "./adapter/resilience.js";
@@ -173,6 +174,30 @@ export class AgentRuntimeAdapter {
173
174
  },
174
175
  };
175
176
  }
177
+ async tryHandleDirectWorkspaceListing(binding, input, options = {}) {
178
+ if (!shouldDirectlyListWorkspaceFiles(input)) {
179
+ return undefined;
180
+ }
181
+ const builtinTools = await this.resolveBuiltinMiddlewareTools(binding, {
182
+ context: options.context,
183
+ state: options.state,
184
+ files: options.files,
185
+ sessionId: options.sessionId,
186
+ requestId: options.requestId,
187
+ });
188
+ const listTool = builtinTools.get("list_files") ?? builtinTools.get("ls");
189
+ if (!listTool) {
190
+ return undefined;
191
+ }
192
+ const output = await listTool.invoke({ path: "." });
193
+ if (typeof output !== "string" || output.trim().length === 0) {
194
+ return undefined;
195
+ }
196
+ return {
197
+ toolName: listTool.name,
198
+ output,
199
+ };
200
+ }
176
201
  createDeclaredMiddlewareResolverOptions(binding, options = {}) {
177
202
  return {
178
203
  resolveModel: (model) => this.resolveModel(model),
@@ -398,6 +423,30 @@ export class AgentRuntimeAdapter {
398
423
  }
399
424
  }
400
425
  async invoke(binding, input, sessionId, requestId, resumePayload, history = [], options = {}) {
426
+ const directListing = await this.tryHandleDirectWorkspaceListing(binding, input, {
427
+ ...options,
428
+ sessionId,
429
+ requestId,
430
+ });
431
+ if (directListing) {
432
+ return {
433
+ sessionId,
434
+ requestId,
435
+ agentId: binding.agent.id,
436
+ state: "completed",
437
+ output: directListing.output,
438
+ finalMessageText: directListing.output,
439
+ metadata: {
440
+ executedToolResults: [{
441
+ toolName: directListing.toolName,
442
+ output: directListing.output,
443
+ }],
444
+ upstreamResult: {
445
+ directUtility: directListing.toolName,
446
+ },
447
+ },
448
+ };
449
+ }
401
450
  const callRuntime = async (activeBinding, activeRequest) => {
402
451
  return this.invokeWithProviderRetry(activeBinding, async () => {
403
452
  const runnable = await this.create(activeBinding, { sessionId });
@@ -444,6 +493,23 @@ export class AgentRuntimeAdapter {
444
493
  }));
445
494
  }
446
495
  async *stream(binding, input, sessionId, history = [], options = {}) {
496
+ const directListing = await this.tryHandleDirectWorkspaceListing(binding, input, {
497
+ ...options,
498
+ sessionId,
499
+ requestId: options.requestId,
500
+ });
501
+ if (directListing) {
502
+ yield {
503
+ kind: "tool-result",
504
+ toolName: directListing.toolName,
505
+ output: directListing.output,
506
+ };
507
+ yield {
508
+ kind: "content",
509
+ content: directListing.output,
510
+ };
511
+ return;
512
+ }
447
513
  const invokeTimeoutMs = resolveBindingTimeout(binding);
448
514
  const streamIdleTimeoutMs = resolveStreamIdleTimeout(binding);
449
515
  const streamDeadlineAt = invokeTimeoutMs ? Date.now() + invokeTimeoutMs : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbotgo/agent-harness",
3
- "version": "0.0.313",
3
+ "version": "0.0.314",
4
4
  "description": "Workspace runtime for multi-agent applications",
5
5
  "license": "MIT",
6
6
  "type": "module",