@botbotgo/runtime 1.0.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.
- package/.github/workflows/ci.yml +46 -0
- package/.github/workflows/release.yml +79 -0
- package/README.md +71 -0
- package/config/examples/memory.yaml +39 -0
- package/config/examples/model.yaml +21 -0
- package/config/examples/runtime.yaml +44 -0
- package/config/examples/skills.yaml +8 -0
- package/config/examples/tool.yaml +16 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +4 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +41 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +140 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/resolveRuntimeConfig.d.ts +83 -0
- package/dist/config/resolveRuntimeConfig.d.ts.map +1 -0
- package/dist/config/resolveRuntimeConfig.js +85 -0
- package/dist/config/resolveRuntimeConfig.js.map +1 -0
- package/dist/config/resources.d.ts +112 -0
- package/dist/config/resources.d.ts.map +1 -0
- package/dist/config/resources.js +20 -0
- package/dist/config/resources.js.map +1 -0
- package/dist/config/runtimeConfigLoader.d.ts +28 -0
- package/dist/config/runtimeConfigLoader.d.ts.map +1 -0
- package/dist/config/runtimeConfigLoader.js +38 -0
- package/dist/config/runtimeConfigLoader.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/agentMiddleware.d.ts +3 -0
- package/dist/runtime/agentMiddleware.d.ts.map +1 -0
- package/dist/runtime/agentMiddleware.js +2 -0
- package/dist/runtime/agentMiddleware.js.map +1 -0
- package/dist/runtime/bootstrap/runtimeFactory.d.ts +7 -0
- package/dist/runtime/bootstrap/runtimeFactory.d.ts.map +1 -0
- package/dist/runtime/bootstrap/runtimeFactory.js +139 -0
- package/dist/runtime/bootstrap/runtimeFactory.js.map +1 -0
- package/dist/runtime/bootstrap/runtimeModuleInitializer.d.ts +5 -0
- package/dist/runtime/bootstrap/runtimeModuleInitializer.d.ts.map +1 -0
- package/dist/runtime/bootstrap/runtimeModuleInitializer.js +32 -0
- package/dist/runtime/bootstrap/runtimeModuleInitializer.js.map +1 -0
- package/dist/runtime/context/agentContext.d.ts +5 -0
- package/dist/runtime/context/agentContext.d.ts.map +1 -0
- package/dist/runtime/context/agentContext.js +19 -0
- package/dist/runtime/context/agentContext.js.map +1 -0
- package/dist/runtime/context/globalContext.d.ts +19 -0
- package/dist/runtime/context/globalContext.d.ts.map +1 -0
- package/dist/runtime/context/globalContext.js +47 -0
- package/dist/runtime/context/globalContext.js.map +1 -0
- package/dist/runtime/events/eventPublisher.d.ts +15 -0
- package/dist/runtime/events/eventPublisher.d.ts.map +1 -0
- package/dist/runtime/events/eventPublisher.js +23 -0
- package/dist/runtime/events/eventPublisher.js.map +1 -0
- package/dist/runtime/execution/agentRunExecutor.d.ts +38 -0
- package/dist/runtime/execution/agentRunExecutor.d.ts.map +1 -0
- package/dist/runtime/execution/agentRunExecutor.js +378 -0
- package/dist/runtime/execution/agentRunExecutor.js.map +1 -0
- package/dist/runtime/execution/agentRunExecutor.types.d.ts +37 -0
- package/dist/runtime/execution/agentRunExecutor.types.d.ts.map +1 -0
- package/dist/runtime/execution/agentRunExecutor.types.js +2 -0
- package/dist/runtime/execution/agentRunExecutor.types.js.map +1 -0
- package/dist/runtime/execution/agentRunProgress.d.ts +8 -0
- package/dist/runtime/execution/agentRunProgress.d.ts.map +1 -0
- package/dist/runtime/execution/agentRunProgress.js +46 -0
- package/dist/runtime/execution/agentRunProgress.js.map +1 -0
- package/dist/runtime/execution/agentRunState.d.ts +44 -0
- package/dist/runtime/execution/agentRunState.d.ts.map +1 -0
- package/dist/runtime/execution/agentRunState.js +17 -0
- package/dist/runtime/execution/agentRunState.js.map +1 -0
- package/dist/runtime/execution/policies/runCompletionPolicy.d.ts +5 -0
- package/dist/runtime/execution/policies/runCompletionPolicy.d.ts.map +1 -0
- package/dist/runtime/execution/policies/runCompletionPolicy.js +30 -0
- package/dist/runtime/execution/policies/runCompletionPolicy.js.map +1 -0
- package/dist/runtime/execution/policies/runErrorPolicy.d.ts +7 -0
- package/dist/runtime/execution/policies/runErrorPolicy.d.ts.map +1 -0
- package/dist/runtime/execution/policies/runErrorPolicy.js +40 -0
- package/dist/runtime/execution/policies/runErrorPolicy.js.map +1 -0
- package/dist/runtime/execution/policies/runPromptBuilder.d.ts +10 -0
- package/dist/runtime/execution/policies/runPromptBuilder.d.ts.map +1 -0
- package/dist/runtime/execution/policies/runPromptBuilder.js +34 -0
- package/dist/runtime/execution/policies/runPromptBuilder.js.map +1 -0
- package/dist/runtime/execution/policies/runSummaryFormatter.d.ts +6 -0
- package/dist/runtime/execution/policies/runSummaryFormatter.d.ts.map +1 -0
- package/dist/runtime/execution/policies/runSummaryFormatter.js +47 -0
- package/dist/runtime/execution/policies/runSummaryFormatter.js.map +1 -0
- package/dist/runtime/execution/policies/runtimeDelay.d.ts +4 -0
- package/dist/runtime/execution/policies/runtimeDelay.d.ts.map +1 -0
- package/dist/runtime/execution/policies/runtimeDelay.js +6 -0
- package/dist/runtime/execution/policies/runtimeDelay.js.map +1 -0
- package/dist/runtime/execution/policies/toolConfigReader.d.ts +8 -0
- package/dist/runtime/execution/policies/toolConfigReader.d.ts.map +1 -0
- package/dist/runtime/execution/policies/toolConfigReader.js +91 -0
- package/dist/runtime/execution/policies/toolConfigReader.js.map +1 -0
- package/dist/runtime/human-loop/consoleHumanLoop.d.ts +21 -0
- package/dist/runtime/human-loop/consoleHumanLoop.d.ts.map +1 -0
- package/dist/runtime/human-loop/consoleHumanLoop.js +102 -0
- package/dist/runtime/human-loop/consoleHumanLoop.js.map +1 -0
- package/dist/runtime/human-loop/humanLoop.d.ts +44 -0
- package/dist/runtime/human-loop/humanLoop.d.ts.map +1 -0
- package/dist/runtime/human-loop/humanLoop.js +36 -0
- package/dist/runtime/human-loop/humanLoop.js.map +1 -0
- package/dist/runtime/index.d.ts +10 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +6 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/middleware/agentToolMiddleware.d.ts +30 -0
- package/dist/runtime/middleware/agentToolMiddleware.d.ts.map +1 -0
- package/dist/runtime/middleware/agentToolMiddleware.js +259 -0
- package/dist/runtime/middleware/agentToolMiddleware.js.map +1 -0
- package/dist/runtime/middleware/commandPolicy.d.ts +8 -0
- package/dist/runtime/middleware/commandPolicy.d.ts.map +1 -0
- package/dist/runtime/middleware/commandPolicy.js +55 -0
- package/dist/runtime/middleware/commandPolicy.js.map +1 -0
- package/dist/runtime/middleware/frameworkPrompt.d.ts +4 -0
- package/dist/runtime/middleware/frameworkPrompt.d.ts.map +1 -0
- package/dist/runtime/middleware/frameworkPrompt.js +44 -0
- package/dist/runtime/middleware/frameworkPrompt.js.map +1 -0
- package/dist/runtime/middleware/index.d.ts +4 -0
- package/dist/runtime/middleware/index.d.ts.map +1 -0
- package/dist/runtime/middleware/index.js +3 -0
- package/dist/runtime/middleware/index.js.map +1 -0
- package/dist/runtime/middleware/skillPathMap.d.ts +3 -0
- package/dist/runtime/middleware/skillPathMap.d.ts.map +1 -0
- package/dist/runtime/middleware/skillPathMap.js +44 -0
- package/dist/runtime/middleware/skillPathMap.js.map +1 -0
- package/dist/runtime/middleware/toolArgsNormalizer.d.ts +21 -0
- package/dist/runtime/middleware/toolArgsNormalizer.d.ts.map +1 -0
- package/dist/runtime/middleware/toolArgsNormalizer.js +227 -0
- package/dist/runtime/middleware/toolArgsNormalizer.js.map +1 -0
- package/dist/runtime/middleware/toolCallGuard.d.ts +8 -0
- package/dist/runtime/middleware/toolCallGuard.d.ts.map +1 -0
- package/dist/runtime/middleware/toolCallGuard.js +60 -0
- package/dist/runtime/middleware/toolCallGuard.js.map +1 -0
- package/dist/runtime/middleware/toolFsHandlers.d.ts +12 -0
- package/dist/runtime/middleware/toolFsHandlers.d.ts.map +1 -0
- package/dist/runtime/middleware/toolFsHandlers.js +79 -0
- package/dist/runtime/middleware/toolFsHandlers.js.map +1 -0
- package/dist/runtime/middleware/toolRequestParser.d.ts +14 -0
- package/dist/runtime/middleware/toolRequestParser.d.ts.map +1 -0
- package/dist/runtime/middleware/toolRequestParser.js +72 -0
- package/dist/runtime/middleware/toolRequestParser.js.map +1 -0
- package/dist/runtime/middleware/types.d.ts +87 -0
- package/dist/runtime/middleware/types.d.ts.map +1 -0
- package/dist/runtime/middleware/types.js +3 -0
- package/dist/runtime/middleware/types.js.map +1 -0
- package/dist/runtime/providers/backendResolver.d.ts +26 -0
- package/dist/runtime/providers/backendResolver.d.ts.map +1 -0
- package/dist/runtime/providers/backendResolver.js +73 -0
- package/dist/runtime/providers/backendResolver.js.map +1 -0
- package/dist/runtime/providers/index.d.ts +14 -0
- package/dist/runtime/providers/index.d.ts.map +1 -0
- package/dist/runtime/providers/index.js +10 -0
- package/dist/runtime/providers/index.js.map +1 -0
- package/dist/runtime/providers/langchainRuntime.d.ts +11 -0
- package/dist/runtime/providers/langchainRuntime.d.ts.map +1 -0
- package/dist/runtime/providers/langchainRuntime.js +45 -0
- package/dist/runtime/providers/langchainRuntime.js.map +1 -0
- package/dist/runtime/providers/localShellBackend.d.ts +10 -0
- package/dist/runtime/providers/localShellBackend.d.ts.map +1 -0
- package/dist/runtime/providers/localShellBackend.js +23 -0
- package/dist/runtime/providers/localShellBackend.js.map +1 -0
- package/dist/runtime/providers/openaiDeepAgent.d.ts +9 -0
- package/dist/runtime/providers/openaiDeepAgent.d.ts.map +1 -0
- package/dist/runtime/providers/openaiDeepAgent.js +7 -0
- package/dist/runtime/providers/openaiDeepAgent.js.map +1 -0
- package/dist/runtime/providers/openaiLocalAgent.d.ts +17 -0
- package/dist/runtime/providers/openaiLocalAgent.d.ts.map +1 -0
- package/dist/runtime/providers/openaiLocalAgent.js +26 -0
- package/dist/runtime/providers/openaiLocalAgent.js.map +1 -0
- package/dist/runtime/providers/openaiLocalAgentFactory.d.ts +36 -0
- package/dist/runtime/providers/openaiLocalAgentFactory.d.ts.map +1 -0
- package/dist/runtime/providers/openaiLocalAgentFactory.js +139 -0
- package/dist/runtime/providers/openaiLocalAgentFactory.js.map +1 -0
- package/dist/runtime/providers/shared/agentProbe.d.ts +4 -0
- package/dist/runtime/providers/shared/agentProbe.d.ts.map +1 -0
- package/dist/runtime/providers/shared/agentProbe.js +17 -0
- package/dist/runtime/providers/shared/agentProbe.js.map +1 -0
- package/dist/runtime/providers/shared/moduleFallback.d.ts +2 -0
- package/dist/runtime/providers/shared/moduleFallback.d.ts.map +1 -0
- package/dist/runtime/providers/shared/moduleFallback.js +34 -0
- package/dist/runtime/providers/shared/moduleFallback.js.map +1 -0
- package/dist/runtime/providers/shared/resourceCloser.d.ts +6 -0
- package/dist/runtime/providers/shared/resourceCloser.d.ts.map +1 -0
- package/dist/runtime/providers/shared/resourceCloser.js +30 -0
- package/dist/runtime/providers/shared/resourceCloser.js.map +1 -0
- package/dist/runtime/runtimeService.d.ts +109 -0
- package/dist/runtime/runtimeService.d.ts.map +1 -0
- package/dist/runtime/runtimeService.js +90 -0
- package/dist/runtime/runtimeService.js.map +1 -0
- package/dist/runtime/stream/agentMessages.d.ts +40 -0
- package/dist/runtime/stream/agentMessages.d.ts.map +1 -0
- package/dist/runtime/stream/agentMessages.js +44 -0
- package/dist/runtime/stream/agentMessages.js.map +1 -0
- package/dist/runtime/stream/agentStream.d.ts +31 -0
- package/dist/runtime/stream/agentStream.d.ts.map +1 -0
- package/dist/runtime/stream/agentStream.js +106 -0
- package/dist/runtime/stream/agentStream.js.map +1 -0
- package/dist/runtime/stream/messageSummary.d.ts +20 -0
- package/dist/runtime/stream/messageSummary.d.ts.map +1 -0
- package/dist/runtime/stream/messageSummary.js +150 -0
- package/dist/runtime/stream/messageSummary.js.map +1 -0
- package/dist/runtime/stream/runArtifacts.d.ts +9 -0
- package/dist/runtime/stream/runArtifacts.d.ts.map +1 -0
- package/dist/runtime/stream/runArtifacts.js +48 -0
- package/dist/runtime/stream/runArtifacts.js.map +1 -0
- package/dist/state/index.d.ts +7 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +4 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/runState.d.ts +36 -0
- package/dist/state/runState.d.ts.map +1 -0
- package/dist/state/runState.js +51 -0
- package/dist/state/runState.js.map +1 -0
- package/dist/state/todos.d.ts +19 -0
- package/dist/state/todos.d.ts.map +1 -0
- package/dist/state/todos.js +45 -0
- package/dist/state/todos.js.map +1 -0
- package/dist/state/workspaceRunSession.d.ts +32 -0
- package/dist/state/workspaceRunSession.d.ts.map +1 -0
- package/dist/state/workspaceRunSession.js +67 -0
- package/dist/state/workspaceRunSession.js.map +1 -0
- package/dist/state/workspaceState.d.ts +94 -0
- package/dist/state/workspaceState.d.ts.map +1 -0
- package/dist/state/workspaceState.js +119 -0
- package/dist/state/workspaceState.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/example/.tsbuildinfo +1 -0
- package/example/build/.tsbuildinfo +1 -0
- package/example/config/memory.yaml +35 -0
- package/example/config/model.yaml +14 -0
- package/example/config/runtime.yaml +46 -0
- package/example/config/tool.yaml +24 -0
- package/example/index.ts +159 -0
- package/example/package-lock.json +1396 -0
- package/example/package.json +26 -0
- package/example/serve-output.mjs +52 -0
- package/example/tsconfig.json +19 -0
- package/package.json +73 -0
- package/scripts/resolve-deps.js +40 -0
- package/src/config/index.ts +29 -0
- package/src/config/loader.ts +174 -0
- package/src/config/resolveRuntimeConfig.ts +160 -0
- package/src/config/resources.ts +152 -0
- package/src/config/runtimeConfigLoader.ts +68 -0
- package/src/external-modules.d.ts +20 -0
- package/src/index.ts +36 -0
- package/src/runtime/agentMiddleware.ts +6 -0
- package/src/runtime/bootstrap/runtimeFactory.ts +212 -0
- package/src/runtime/bootstrap/runtimeModuleInitializer.ts +34 -0
- package/src/runtime/context/agentContext.ts +24 -0
- package/src/runtime/context/globalContext.ts +70 -0
- package/src/runtime/events/eventPublisher.ts +45 -0
- package/src/runtime/execution/agentRunExecutor.ts +499 -0
- package/src/runtime/execution/agentRunExecutor.types.ts +39 -0
- package/src/runtime/execution/agentRunProgress.ts +67 -0
- package/src/runtime/execution/agentRunState.ts +66 -0
- package/src/runtime/execution/policies/runCompletionPolicy.ts +30 -0
- package/src/runtime/execution/policies/runErrorPolicy.ts +50 -0
- package/src/runtime/execution/policies/runPromptBuilder.ts +39 -0
- package/src/runtime/execution/policies/runSummaryFormatter.ts +57 -0
- package/src/runtime/execution/policies/runtimeDelay.ts +5 -0
- package/src/runtime/execution/policies/toolConfigReader.ts +107 -0
- package/src/runtime/human-loop/consoleHumanLoop.ts +113 -0
- package/src/runtime/human-loop/humanLoop.ts +90 -0
- package/src/runtime/index.ts +36 -0
- package/src/runtime/middleware/agentToolMiddleware.ts +329 -0
- package/src/runtime/middleware/commandPolicy.ts +65 -0
- package/src/runtime/middleware/frameworkPrompt.ts +51 -0
- package/src/runtime/middleware/index.ts +7 -0
- package/src/runtime/middleware/skillPathMap.ts +49 -0
- package/src/runtime/middleware/toolArgsNormalizer.ts +277 -0
- package/src/runtime/middleware/toolCallGuard.ts +73 -0
- package/src/runtime/middleware/toolFsHandlers.ts +94 -0
- package/src/runtime/middleware/toolRequestParser.ts +84 -0
- package/src/runtime/middleware/types.ts +91 -0
- package/src/runtime/providers/backendResolver.ts +127 -0
- package/src/runtime/providers/index.ts +19 -0
- package/src/runtime/providers/langchainRuntime.ts +67 -0
- package/src/runtime/providers/localShellBackend.ts +54 -0
- package/src/runtime/providers/openaiDeepAgent.ts +17 -0
- package/src/runtime/providers/openaiLocalAgent.ts +35 -0
- package/src/runtime/providers/openaiLocalAgentFactory.ts +185 -0
- package/src/runtime/providers/shared/agentProbe.ts +24 -0
- package/src/runtime/providers/shared/moduleFallback.ts +41 -0
- package/src/runtime/providers/shared/resourceCloser.ts +30 -0
- package/src/runtime/runtimeService.ts +205 -0
- package/src/runtime/stream/agentMessages.ts +72 -0
- package/src/runtime/stream/agentStream.ts +168 -0
- package/src/runtime/stream/messageSummary.ts +164 -0
- package/src/runtime/stream/runArtifacts.ts +72 -0
- package/src/state/index.ts +19 -0
- package/src/state/runState.ts +84 -0
- package/src/state/todos.ts +59 -0
- package/src/state/workspaceRunSession.ts +96 -0
- package/src/state/workspaceState.ts +199 -0
- package/src/types/easynet-agent-common.d.ts +62 -0
- package/src/types.ts +1 -0
- package/test/integration/runtime-live.integration.test.ts +30 -0
- package/test/unit/config/loader.test.ts +429 -0
- package/test/unit/runtime/agentContext.test.ts +23 -0
- package/test/unit/runtime/agentRuntime.test.ts +99 -0
- package/test/unit/runtime/consoleHumanLoop.test.ts +52 -0
- package/test/unit/runtime/events.test.ts +11 -0
- package/test/unit/runtime/globalContext.test.ts +34 -0
- package/test/unit/runtime/humanLoop.test.ts +104 -0
- package/test/unit/runtime/toolArgsNormalizer.test.ts +136 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ToolArgs } from "../middleware/types.js";
|
|
2
|
+
export type HumanLoopRequestKind = "tool_approval";
|
|
3
|
+
export type HumanLoopDecisionAction = "approve" | "reject" | "revise";
|
|
4
|
+
export type HumanLoopRiskLevel = "low" | "medium" | "high";
|
|
5
|
+
export interface HumanLoopToolCallContext {
|
|
6
|
+
threadId?: string;
|
|
7
|
+
toolCallId?: string;
|
|
8
|
+
toolName: string;
|
|
9
|
+
args: ToolArgs;
|
|
10
|
+
rootDir: string;
|
|
11
|
+
}
|
|
12
|
+
export interface HumanLoopRequest {
|
|
13
|
+
id: string;
|
|
14
|
+
kind: HumanLoopRequestKind;
|
|
15
|
+
threadId?: string;
|
|
16
|
+
toolCallId?: string;
|
|
17
|
+
toolName: string;
|
|
18
|
+
title: string;
|
|
19
|
+
description: string;
|
|
20
|
+
args: ToolArgs;
|
|
21
|
+
rootDir: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
riskLevel?: HumanLoopRiskLevel;
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export interface HumanLoopDecision {
|
|
27
|
+
action: HumanLoopDecisionAction;
|
|
28
|
+
message?: string;
|
|
29
|
+
revisedArgs?: ToolArgs;
|
|
30
|
+
actor?: string;
|
|
31
|
+
decidedAt?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface HumanLoopService {
|
|
34
|
+
request(request: HumanLoopRequest): Promise<HumanLoopDecision>;
|
|
35
|
+
}
|
|
36
|
+
export interface HumanLoopToolPolicy {
|
|
37
|
+
buildRequest(context: HumanLoopToolCallContext): HumanLoopRequest | null | undefined;
|
|
38
|
+
}
|
|
39
|
+
export interface CreateDefaultHumanLoopToolPolicyOptions {
|
|
40
|
+
toolNames?: string[];
|
|
41
|
+
riskLevel?: HumanLoopRiskLevel;
|
|
42
|
+
}
|
|
43
|
+
export declare function createDefaultHumanLoopToolPolicy(options?: CreateDefaultHumanLoopToolPolicyOptions): HumanLoopToolPolicy;
|
|
44
|
+
//# sourceMappingURL=humanLoop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"humanLoop.d.ts","sourceRoot":"","sources":["../../../src/runtime/human-loop/humanLoop.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,MAAM,oBAAoB,GAAG,eAAe,CAAC;AACnD,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACtE,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE3D,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,E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
|
3
|
+
const riskyToolNames = new Set(options.toolNames ?? ["execute", "write_file", "edit_file"]);
|
|
4
|
+
const riskLevel = options.riskLevel ?? "high";
|
|
5
|
+
return {
|
|
6
|
+
buildRequest(context) {
|
|
7
|
+
if (!riskyToolNames.has(context.toolName)) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
id: randomUUID(),
|
|
12
|
+
kind: "tool_approval",
|
|
13
|
+
threadId: context.threadId,
|
|
14
|
+
toolCallId: context.toolCallId,
|
|
15
|
+
toolName: context.toolName,
|
|
16
|
+
title: `Approval required for ${context.toolName}`,
|
|
17
|
+
description: buildDefaultDescription(context.toolName, context.args),
|
|
18
|
+
args: context.args,
|
|
19
|
+
rootDir: context.rootDir,
|
|
20
|
+
createdAt: new Date().toISOString(),
|
|
21
|
+
riskLevel,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function buildDefaultDescription(toolName, args) {
|
|
27
|
+
if (toolName === "execute" && typeof args.command === "string") {
|
|
28
|
+
return `Command: ${args.command}`;
|
|
29
|
+
}
|
|
30
|
+
if ((toolName === "write_file" || toolName === "edit_file") &&
|
|
31
|
+
typeof (args.file_path ?? args.path) === "string") {
|
|
32
|
+
return `File: ${String(args.file_path ?? args.path)}`;
|
|
33
|
+
}
|
|
34
|
+
return `Tool args: ${JSON.stringify(args)}`;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=humanLoop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"humanLoop.js","sourceRoot":"","sources":["../../../src/runtime/human-loop/humanLoop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAmDzC,MAAM,UAAU,gCAAgC,CAC9C,UAAmD,EAAE;IAErD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,SAAS,EAAE,YAA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AI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { AgentRuntimeService, createAgentRuntime2, initializeAgentRuntimeModules, } from "./runtimeService.js";
|
|
2
|
+
export { ConsoleHumanLoopService } from "./human-loop/consoleHumanLoop.js";
|
|
3
|
+
export type { CreateAgentRuntimeFrameworkOptions } from "./runtimeService.js";
|
|
4
|
+
export { createDefaultHumanLoopToolPolicy, } from "./human-loop/humanLoop.js";
|
|
5
|
+
export type { HumanLoopDecision, HumanLoopRequest, HumanLoopService, HumanLoopToolCallContext, HumanLoopToolPolicy, } from "./human-loop/humanLoop.js";
|
|
6
|
+
export type { AgentEvent, AgentEventBus, AgentEventListener, } from "./events/eventPublisher.js";
|
|
7
|
+
export { clearAgentRuntimeGlobalContext, getAgentRuntimeGlobal, getAgentRuntimeGlobalContext, getOrRegisterAgentRuntimeGlobal, registerAgentRuntimeGlobal, } from "./context/globalContext.js";
|
|
8
|
+
export type { AgentRuntimeGlobalContext } from "./context/globalContext.js";
|
|
9
|
+
export { requireAgentRuntimeChatModel, requireAgentRuntimeContextValue, requireAgentRuntimeMemory, requireAgentRuntimeTools, } from "./context/agentContext.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,6BAA6B,GAC9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,YAAY,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EACL,gCAAgC,GACjC,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,UAAU,EACV,aAAa,EACb,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,4BAA4B,EAC5B,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,EAC/B,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AgentRuntimeService, createAgentRuntime2, initializeAgentRuntimeModules, } from "./runtimeService.js";
|
|
2
|
+
export { ConsoleHumanLoopService } from "./human-loop/consoleHumanLoop.js";
|
|
3
|
+
export { createDefaultHumanLoopToolPolicy, } from "./human-loop/humanLoop.js";
|
|
4
|
+
export { clearAgentRuntimeGlobalContext, getAgentRuntimeGlobal, getAgentRuntimeGlobalContext, getOrRegisterAgentRuntimeGlobal, registerAgentRuntimeGlobal, } from "./context/globalContext.js";
|
|
5
|
+
export { requireAgentRuntimeChatModel, requireAgentRuntimeContextValue, requireAgentRuntimeMemory, requireAgentRuntimeTools, } from "./context/agentContext.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,6BAA6B,GAC9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,OAAO,EACL,gCAAgC,GACjC,MAAM,2BAA2B,CAAC;AAanC,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,4BAA4B,EAC5B,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,EAC/B,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AgentMiddlewareLike, CreateAgentToolMiddlewareOptions } from "./types.js";
|
|
2
|
+
export declare class AgentToolMiddlewareFactory {
|
|
3
|
+
private readonly rootDir;
|
|
4
|
+
private readonly skillRoots;
|
|
5
|
+
private readonly skillPathMap;
|
|
6
|
+
private readonly createMiddleware;
|
|
7
|
+
private readonly ToolMessage;
|
|
8
|
+
private readonly events?;
|
|
9
|
+
private readonly executeTimeoutMs;
|
|
10
|
+
private readonly blockTaskTool;
|
|
11
|
+
private readonly allowedToolNames?;
|
|
12
|
+
private readonly logger;
|
|
13
|
+
private readonly persistTodos?;
|
|
14
|
+
private readonly humanLoop?;
|
|
15
|
+
private readonly humanLoopToolPolicy?;
|
|
16
|
+
private readonly beforeToolCall?;
|
|
17
|
+
private readonly afterToolCall?;
|
|
18
|
+
constructor(options: CreateAgentToolMiddlewareOptions);
|
|
19
|
+
create(): AgentMiddlewareLike;
|
|
20
|
+
private wrapModelCall;
|
|
21
|
+
private wrapToolCall;
|
|
22
|
+
private expandSyntheticFileEdits;
|
|
23
|
+
private handleSyntheticToolResponse;
|
|
24
|
+
private invokeToolHandler;
|
|
25
|
+
private requestHumanApprovalIfNeeded;
|
|
26
|
+
private resolveHumanLoopDecision;
|
|
27
|
+
private runTool;
|
|
28
|
+
private logToolStart;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=agentToolMiddleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentToolMiddleware.d.ts","sourceRoot":"","sources":["../../../src/runtime/middleware/agentToolMiddleware.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,mBAAmB,EACnB,gCAAgC,EAEjC,MAAM,YAAY,CAAC;AAEpB,qBAAa,0BAA0B;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAW;IACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAyB;IACtD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuD;IACxF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAkD;IAC9E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;IACxC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAW;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4B;IACnD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAA6C;IAC3E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAgD;IAC3E,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAA0D;IAC/F,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAqD;IACrF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAoD;gBAEhE,OAAO,EAAE,gCAAgC;IAkBrD,MAAM,IAAI,mBAAmB;YAQtB,aAAa;YAab,YAAY;YA8EZ,wBAAwB;YAOxB,2BAA2B;YAsB3B,iBAAiB;YAqDjB,4BAA4B;IAoC1C,OAAO,CAAC,wBAAwB;YA2BlB,OAAO;IAqBrB,OAAO,CAAC,YAAY;CAcrB"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { FrameworkPrompt } from "./frameworkPrompt.js";
|
|
2
|
+
import { ToolArgsNormalizer } from "./toolArgsNormalizer.js";
|
|
3
|
+
import { ToolCallGuard } from "./toolCallGuard.js";
|
|
4
|
+
import { ToolFsHandlers } from "./toolFsHandlers.js";
|
|
5
|
+
import { ToolRequestParser } from "./toolRequestParser.js";
|
|
6
|
+
import { buildSkillPathMap, expandSkillRoots } from "./skillPathMap.js";
|
|
7
|
+
export class AgentToolMiddlewareFactory {
|
|
8
|
+
rootDir;
|
|
9
|
+
skillRoots;
|
|
10
|
+
skillPathMap;
|
|
11
|
+
createMiddleware;
|
|
12
|
+
ToolMessage;
|
|
13
|
+
events;
|
|
14
|
+
executeTimeoutMs;
|
|
15
|
+
blockTaskTool;
|
|
16
|
+
allowedToolNames;
|
|
17
|
+
logger;
|
|
18
|
+
persistTodos;
|
|
19
|
+
humanLoop;
|
|
20
|
+
humanLoopToolPolicy;
|
|
21
|
+
beforeToolCall;
|
|
22
|
+
afterToolCall;
|
|
23
|
+
constructor(options) {
|
|
24
|
+
this.rootDir = options.rootDir;
|
|
25
|
+
this.skillRoots = expandSkillRoots(options.skillRoots ?? []);
|
|
26
|
+
this.skillPathMap = options.skillPathMap ?? buildSkillPathMap(this.skillRoots);
|
|
27
|
+
this.createMiddleware = options.createMiddleware;
|
|
28
|
+
this.ToolMessage = options.ToolMessage;
|
|
29
|
+
this.events = options.events;
|
|
30
|
+
this.executeTimeoutMs = options.executeTimeoutMs ?? 60_000;
|
|
31
|
+
this.blockTaskTool = options.blockTaskTool ?? false;
|
|
32
|
+
this.allowedToolNames = options.allowedToolNames?.filter((name) => typeof name === "string" && name.trim().length > 0);
|
|
33
|
+
this.logger = options.logger ?? (() => { });
|
|
34
|
+
this.persistTodos = options.persistTodos;
|
|
35
|
+
this.humanLoop = options.humanLoop;
|
|
36
|
+
this.humanLoopToolPolicy = options.humanLoopToolPolicy;
|
|
37
|
+
this.beforeToolCall = options.beforeToolCall;
|
|
38
|
+
this.afterToolCall = options.afterToolCall;
|
|
39
|
+
}
|
|
40
|
+
create() {
|
|
41
|
+
return this.createMiddleware({
|
|
42
|
+
name: "AgentToolMiddleware",
|
|
43
|
+
wrapModelCall: async (request, handler) => this.wrapModelCall(request, handler),
|
|
44
|
+
wrapToolCall: async (request, handler) => this.wrapToolCall(request, handler),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async wrapModelCall(request, handler) {
|
|
48
|
+
const modelRequest = ToolRequestParser.toModelRequest(request);
|
|
49
|
+
return handler({
|
|
50
|
+
...modelRequest,
|
|
51
|
+
systemPrompt: FrameworkPrompt.build(modelRequest.systemPrompt, this.blockTaskTool, this.allowedToolNames, this.skillPathMap),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async wrapToolCall(request, handler) {
|
|
55
|
+
const toolRequest = ToolRequestParser.toMiddlewareRequest(request);
|
|
56
|
+
const name = toolRequest.toolCall.name;
|
|
57
|
+
const toolCallId = toolRequest.toolCall.id;
|
|
58
|
+
if (this.blockTaskTool && name === "task") {
|
|
59
|
+
this.events?.emit({
|
|
60
|
+
name: "agent.runtime2.tool.call.blocked",
|
|
61
|
+
from: "agent-runtime2.middleware",
|
|
62
|
+
to: name,
|
|
63
|
+
payload: { toolCallId, reason: "task_tool_disabled" },
|
|
64
|
+
});
|
|
65
|
+
return new this.ToolMessage({
|
|
66
|
+
content: "Error: Do not use the task tool. Use execute(), write_file(), and read_file() directly.",
|
|
67
|
+
tool_call_id: toolCallId ?? "blocked",
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const args = ToolRequestParser.toToolArgs(toolRequest.toolCall.args);
|
|
71
|
+
const blocked = ToolCallGuard.maybeBlock(name, args, toolCallId, this.ToolMessage, this.rootDir, this.allowedToolNames, Object.values(this.skillPathMap));
|
|
72
|
+
if (blocked) {
|
|
73
|
+
this.events?.emit({
|
|
74
|
+
name: "agent.runtime2.tool.call.blocked",
|
|
75
|
+
from: "agent-runtime2.middleware",
|
|
76
|
+
to: name,
|
|
77
|
+
payload: { toolCallId, args, reason: "policy_violation" },
|
|
78
|
+
});
|
|
79
|
+
return blocked;
|
|
80
|
+
}
|
|
81
|
+
let nextArgs = ToolArgsNormalizer.normalizeToolArgs(this.rootDir, this.skillRoots, name, args, this.skillPathMap);
|
|
82
|
+
nextArgs = await this.expandSyntheticFileEdits(name, nextArgs);
|
|
83
|
+
const syntheticResult = await this.handleSyntheticToolResponse(name, toolRequest.toolCall.id, nextArgs);
|
|
84
|
+
if (syntheticResult) {
|
|
85
|
+
return syntheticResult;
|
|
86
|
+
}
|
|
87
|
+
const humanLoopResult = await this.requestHumanApprovalIfNeeded(toolRequest, name, nextArgs);
|
|
88
|
+
if (humanLoopResult?.result) {
|
|
89
|
+
return humanLoopResult.result;
|
|
90
|
+
}
|
|
91
|
+
if (humanLoopResult?.args) {
|
|
92
|
+
nextArgs = humanLoopResult.args;
|
|
93
|
+
}
|
|
94
|
+
const override = await this.beforeToolCall?.({
|
|
95
|
+
threadId: toolRequest.threadId,
|
|
96
|
+
name,
|
|
97
|
+
args,
|
|
98
|
+
nextArgs,
|
|
99
|
+
request: ToolRequestParser.toHookRequest(toolRequest),
|
|
100
|
+
rootDir: this.rootDir,
|
|
101
|
+
});
|
|
102
|
+
if (override?.result) {
|
|
103
|
+
return override.result;
|
|
104
|
+
}
|
|
105
|
+
if (override?.args) {
|
|
106
|
+
nextArgs = override.args;
|
|
107
|
+
}
|
|
108
|
+
return this.invokeToolHandler(toolRequest, name, nextArgs, handler);
|
|
109
|
+
}
|
|
110
|
+
async expandSyntheticFileEdits(name, args) {
|
|
111
|
+
if (name !== "edit_file") {
|
|
112
|
+
return args;
|
|
113
|
+
}
|
|
114
|
+
return ToolFsHandlers.expandEditFileContent(this.rootDir, args);
|
|
115
|
+
}
|
|
116
|
+
async handleSyntheticToolResponse(name, toolCallId, args) {
|
|
117
|
+
if (name === "write_file" && typeof args.content === "string") {
|
|
118
|
+
const result = await ToolFsHandlers.handleWriteFile(this.rootDir, args, this.logger);
|
|
119
|
+
if (result) {
|
|
120
|
+
return new this.ToolMessage({ content: result.content, tool_call_id: toolCallId ?? "write_file" });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (name === "ls" || name === "inspect_files") {
|
|
124
|
+
const result = await ToolFsHandlers.handleListFiles(this.rootDir, args);
|
|
125
|
+
if (result) {
|
|
126
|
+
this.logger(`[tool] ${name}: ${String(args.path ?? ".")}`);
|
|
127
|
+
this.logger(`[tool] ${name} done in 0ms`);
|
|
128
|
+
return new this.ToolMessage({ content: result.content, tool_call_id: toolCallId ?? name });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
async invokeToolHandler(toolRequest, name, nextArgs, handler) {
|
|
134
|
+
this.events?.emit({
|
|
135
|
+
name: "agent.runtime2.tool.call.start",
|
|
136
|
+
from: "agent-runtime2.middleware",
|
|
137
|
+
to: name,
|
|
138
|
+
payload: { toolCallId: toolRequest.toolCall.id, args: nextArgs },
|
|
139
|
+
});
|
|
140
|
+
this.logToolStart(name, nextArgs);
|
|
141
|
+
const startedAt = Date.now();
|
|
142
|
+
try {
|
|
143
|
+
const result = await this.runTool(name, nextArgs, toolRequest, handler);
|
|
144
|
+
const durationMs = Date.now() - startedAt;
|
|
145
|
+
this.logger(`[tool] ${name} done in ${durationMs}ms`);
|
|
146
|
+
if (name === "write_todos" && Array.isArray(nextArgs.todos)) {
|
|
147
|
+
await this.persistTodos?.(nextArgs.todos);
|
|
148
|
+
}
|
|
149
|
+
await this.afterToolCall?.({
|
|
150
|
+
threadId: toolRequest.threadId,
|
|
151
|
+
name,
|
|
152
|
+
args: nextArgs,
|
|
153
|
+
result,
|
|
154
|
+
request: ToolRequestParser.toAfterHookRequest(toolRequest),
|
|
155
|
+
rootDir: this.rootDir,
|
|
156
|
+
});
|
|
157
|
+
this.events?.emit({
|
|
158
|
+
name: "agent.runtime2.tool.call.done",
|
|
159
|
+
from: name,
|
|
160
|
+
to: "agent-runtime2.middleware",
|
|
161
|
+
payload: { toolCallId: toolRequest.toolCall.id, args: nextArgs, durationMs, result },
|
|
162
|
+
});
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
this.events?.emit({
|
|
167
|
+
name: "agent.runtime2.tool.call.error",
|
|
168
|
+
from: name,
|
|
169
|
+
to: "agent-runtime2.middleware",
|
|
170
|
+
payload: {
|
|
171
|
+
toolCallId: toolRequest.toolCall.id,
|
|
172
|
+
args: nextArgs,
|
|
173
|
+
durationMs: Date.now() - startedAt,
|
|
174
|
+
error: error instanceof Error ? error.message : String(error),
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async requestHumanApprovalIfNeeded(toolRequest, name, args) {
|
|
181
|
+
const request = this.humanLoopToolPolicy?.buildRequest({
|
|
182
|
+
threadId: toolRequest.threadId,
|
|
183
|
+
toolCallId: toolRequest.toolCall.id,
|
|
184
|
+
toolName: name,
|
|
185
|
+
args,
|
|
186
|
+
rootDir: this.rootDir,
|
|
187
|
+
});
|
|
188
|
+
if (!request || !this.humanLoop) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
this.events?.emit({
|
|
192
|
+
name: "agent.runtime2.human_loop.requested",
|
|
193
|
+
from: "agent-runtime2.middleware",
|
|
194
|
+
to: "human",
|
|
195
|
+
payload: request,
|
|
196
|
+
});
|
|
197
|
+
const decision = await this.humanLoop.request(request);
|
|
198
|
+
this.events?.emit({
|
|
199
|
+
name: "agent.runtime2.human_loop.resolved",
|
|
200
|
+
from: "human",
|
|
201
|
+
to: "agent-runtime2.middleware",
|
|
202
|
+
payload: {
|
|
203
|
+
request,
|
|
204
|
+
decision,
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
return this.resolveHumanLoopDecision(toolRequest.toolCall.id, request, decision);
|
|
208
|
+
}
|
|
209
|
+
resolveHumanLoopDecision(toolCallId, request, decision) {
|
|
210
|
+
if (decision.action === "approve") {
|
|
211
|
+
return decision.revisedArgs ? { args: decision.revisedArgs } : {};
|
|
212
|
+
}
|
|
213
|
+
if (decision.action === "revise") {
|
|
214
|
+
if (decision.revisedArgs) {
|
|
215
|
+
return { args: decision.revisedArgs };
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
result: new this.ToolMessage({
|
|
219
|
+
content: decision.message ?? "Error: human review requested revised args but none were provided.",
|
|
220
|
+
tool_call_id: toolCallId ?? request.id,
|
|
221
|
+
}),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
result: new this.ToolMessage({
|
|
226
|
+
content: decision.message ?? `Rejected by human reviewer for tool ${request.toolName}.`,
|
|
227
|
+
tool_call_id: toolCallId ?? request.id,
|
|
228
|
+
}),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
async runTool(name, nextArgs, toolRequest, handler) {
|
|
232
|
+
const runPromise = Promise.resolve(handler({
|
|
233
|
+
...toolRequest,
|
|
234
|
+
toolCall: { ...toolRequest.toolCall, args: nextArgs },
|
|
235
|
+
}));
|
|
236
|
+
if (name !== "execute") {
|
|
237
|
+
return runPromise;
|
|
238
|
+
}
|
|
239
|
+
return Promise.race([
|
|
240
|
+
runPromise,
|
|
241
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`execute timeout after ${this.executeTimeoutMs / 1000}s`)), this.executeTimeoutMs)),
|
|
242
|
+
]);
|
|
243
|
+
}
|
|
244
|
+
logToolStart(name, args) {
|
|
245
|
+
if (name === "execute" && typeof args.command === "string") {
|
|
246
|
+
const command = args.command.length > 120 ? `${args.command.slice(0, 117)}…` : args.command;
|
|
247
|
+
this.logger(`[tool] execute: ${command}`);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (name === "write_file") {
|
|
251
|
+
const filePath = String(args.file_path ?? args.path ?? "");
|
|
252
|
+
const length = typeof args.content === "string" ? args.content.length : 0;
|
|
253
|
+
this.logger(`[tool] write_file: ${filePath} (${length} chars)`);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
this.logger(`[tool] ${name}`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=agentToolMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentToolM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AQ,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;YAC3D,MAAM,MAAM,GAAG,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1E,IAAI,CAAC,MAAM,CAAC,sBAAsB,QAAQ,KAAK,MAAM,SAAS,CAAC,CAAC;YAChE,OAAO;QACT,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ToolMessageConstructorLike, ToolMessageLike } from "./types.js";
|
|
2
|
+
export declare class CommandPolicy {
|
|
3
|
+
static maybeBlockExecuteCommand(command: string, toolCallId: string | undefined, ToolMessage: ToolMessageConstructorLike, rootDir: string, allowedPathPrefixes?: string[]): ToolMessageLike | null;
|
|
4
|
+
private static getViolationMessage;
|
|
5
|
+
private static containsAbsolutePathOutsideWorkspace;
|
|
6
|
+
private static isSystemPath;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=commandPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandPolicy.d.ts","sourceRoot":"","sources":["../../../src/runtime/middleware/commandPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE9E,qBAAa,aAAa;WACV,wBAAwB,CACpC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,EAAE,0BAA0B,EACvC,OAAO,EAAE,MAAM,EACf,mBAAmB,GAAE,MAAM,EAAO,GACjC,eAAe,GAAG,IAAI;IAKzB,OAAO,CAAC,MAAM,CAAC,mBAAmB;IA2BlC,OAAO,CAAC,MAAM,CAAC,oCAAoC;IAmBnD,OAAO,CAAC,MAAM,CAAC,YAAY;CAI5B"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export class CommandPolicy {
|
|
2
|
+
static maybeBlockExecuteCommand(command, toolCallId, ToolMessage, rootDir, allowedPathPrefixes = []) {
|
|
3
|
+
const message = this.getViolationMessage(command, rootDir, allowedPathPrefixes);
|
|
4
|
+
return message ? new ToolMessage({ content: message, tool_call_id: toolCallId ?? "execute" }) : null;
|
|
5
|
+
}
|
|
6
|
+
static getViolationMessage(command, rootDir, allowedPathPrefixes) {
|
|
7
|
+
if (/\bls\b/.test(command) && command.includes("?")) {
|
|
8
|
+
return "Error: Do not run fuzzy ls probes with unknown paths. Continue with known workflow commands.";
|
|
9
|
+
}
|
|
10
|
+
if ((/\bbash\b/i.test(command) || /\/bin\/bash\b/i.test(command) || /\bzsh\b/i.test(command)) && command.includes("/scripts/")) {
|
|
11
|
+
return "Error: Do not wrap skill scripts with `bash`. Execute the script path directly.";
|
|
12
|
+
}
|
|
13
|
+
if (/\bchmod\s+\+x\b/i.test(command)) {
|
|
14
|
+
return "Error: Do not run chmod +x. Use direct execution of the target command or script.";
|
|
15
|
+
}
|
|
16
|
+
if (/\b(?:ba)?sh\s+-lc\b/i.test(command)) {
|
|
17
|
+
return "Error: Do not wrap command execution with shell -lc. Execute the target command directly.";
|
|
18
|
+
}
|
|
19
|
+
if (/\b(curl|wget)\b/i.test(command)) {
|
|
20
|
+
return "Error: Do not execute direct network fetch commands. Use provided scripts/tools and then write results with write_file/edit_file.";
|
|
21
|
+
}
|
|
22
|
+
if (/\|\s*reportgen\b/i.test(command)) {
|
|
23
|
+
return "Error: Do not pipe output to ad-hoc generators. Use write_file/edit_file for artifact generation.";
|
|
24
|
+
}
|
|
25
|
+
if (/(^|[\s;|&])(?:echo|cat|printf)[^|&;]*>\s*[^\s]+/i.test(command)) {
|
|
26
|
+
return "Error: Do not write files via shell redirection in execute. Use write_file/edit_file tools.";
|
|
27
|
+
}
|
|
28
|
+
return this.containsAbsolutePathOutsideWorkspace(command, rootDir, allowedPathPrefixes)
|
|
29
|
+
? "Error: Do not execute commands with absolute paths outside workspace root. Use workspace-relative paths only."
|
|
30
|
+
: null;
|
|
31
|
+
}
|
|
32
|
+
static containsAbsolutePathOutsideWorkspace(command, rootDir, allowedPathPrefixes) {
|
|
33
|
+
const normalizedRoot = rootDir.replace(/\\/g, "/");
|
|
34
|
+
const normalizedAllowed = allowedPathPrefixes.map((entry) => entry.replace(/\\/g, "/"));
|
|
35
|
+
const pathLikeMatches = [...command.matchAll(/(?:^|[\s=>(;|&])(["']?)(\/[^\s"'`<>|&;]+)\1/g)];
|
|
36
|
+
for (const match of pathLikeMatches) {
|
|
37
|
+
const pathToken = match[2];
|
|
38
|
+
if (!pathToken || pathToken.startsWith("//"))
|
|
39
|
+
continue;
|
|
40
|
+
if (this.isSystemPath(pathToken))
|
|
41
|
+
continue;
|
|
42
|
+
if (pathToken === normalizedRoot || pathToken.startsWith(`${normalizedRoot}/`))
|
|
43
|
+
continue;
|
|
44
|
+
if (normalizedAllowed.some((prefix) => pathToken === prefix || pathToken.startsWith(`${prefix}/`)))
|
|
45
|
+
continue;
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
static isSystemPath(pathToken) {
|
|
51
|
+
return ["/usr/", "/bin/", "/etc/", "/var/", "/dev/", "/proc/", "/System/", "/opt/"]
|
|
52
|
+
.some((prefix) => pathToken.startsWith(prefix));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=commandPolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandPolicy.js","sourceRoot":"","sources":["../../../src/runtime/middleware/commandPolicy.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAa;IACjB,MAAM,CAAC,wBAAwB,CACpC,OAAe,EACf,UAA8B,EAC9B,WAAuC,EACvC,OAAe,EACf,s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AO,CAAC;aAChF,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameworkPrompt.d.ts","sourceRoot":"","sources":["../../../src/runtime/middleware/frameworkPrompt.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAe;WACZ,KAAK,CACjB,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,aAAa,EAAE,OAAO,EACtB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAC3B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM;CA4CV"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export class FrameworkPrompt {
|
|
2
|
+
static build(currentPrompt, blockTaskTool, allowedToolNames, skillPathMap) {
|
|
3
|
+
const baseRules = [
|
|
4
|
+
"Framework execution rules:",
|
|
5
|
+
"- Follow SKILL instructions exactly as the source of truth.",
|
|
6
|
+
"- Execute required workflow steps in order; do not skip required steps.",
|
|
7
|
+
"- Do not add extra exploratory or redundant operations outside the SKILL workflow.",
|
|
8
|
+
"- Support both tool calls and script commands: use whichever the SKILL explicitly allows for each step.",
|
|
9
|
+
"- If a SKILL allows both tool and script for the same step, prefer the safer/more structured tool path.",
|
|
10
|
+
"- For independent operations with no data dependency, prefer parallel tool calls to reduce latency.",
|
|
11
|
+
"- Do not stop after intermediate reads/planning. Continue autonomously until required outputs are produced.",
|
|
12
|
+
'- Return strict JSON for tool arguments (example: {"offset":0}, never "offset=0").',
|
|
13
|
+
"- Use workspace-relative paths only; do not invent absolute filesystem paths unless provided by runtime placeholders.",
|
|
14
|
+
"- Do not inspect script source files unless explicitly requested.",
|
|
15
|
+
"- Runtime path variable `${WORKSPACE}` expands to the workspace root.",
|
|
16
|
+
];
|
|
17
|
+
if (blockTaskTool) {
|
|
18
|
+
baseRules.push("- The task tool is disabled. Never call task; complete work using available file and execute tools.");
|
|
19
|
+
}
|
|
20
|
+
if (allowedToolNames?.length) {
|
|
21
|
+
baseRules.push(`- Tool allowlist is enforced by config. Only call these tools: ${allowedToolNames.join(", ")}.`);
|
|
22
|
+
}
|
|
23
|
+
const skillEntries = Object.entries(skillPathMap ?? {});
|
|
24
|
+
if (skillEntries.length > 0) {
|
|
25
|
+
baseRules.push("- Active skills for this run:");
|
|
26
|
+
for (const [skillId, skillPath] of skillEntries) {
|
|
27
|
+
baseRules.push(` - ${skillId} => ${skillPath}`);
|
|
28
|
+
}
|
|
29
|
+
baseRules.push("- Use `${SKILL_PATH:<skill-id>}` to reference a specific skill directory from the active skill mapping above.");
|
|
30
|
+
if (skillEntries.length === 1) {
|
|
31
|
+
baseRules.push("- Because only one skill is active, `${SKILL_PATH}` also resolves to that skill directory.");
|
|
32
|
+
}
|
|
33
|
+
baseRules.push("- `${SKILL_PATH...}` is only for skill-owned assets such as scripts/, references/, templates, and static inputs explicitly required by the SKILL.");
|
|
34
|
+
baseRules.push("- Do not use `${SKILL_PATH...}` for exploration, listing, globbing, discovery, or inspection. Do not call ls/glob/read_file on a skill path unless the user explicitly asks for skill source or contents.");
|
|
35
|
+
baseRules.push("- If a SKILL provides an explicit script command using `${SKILL_PATH...}` and `${WORKSPACE}`, execute that command directly instead of exploring the skill directory first.");
|
|
36
|
+
}
|
|
37
|
+
const frameworkPrompt = baseRules.join("\n");
|
|
38
|
+
if (!currentPrompt?.trim() || currentPrompt.includes("Framework execution rules:")) {
|
|
39
|
+
return currentPrompt?.trim() ? currentPrompt : frameworkPrompt;
|
|
40
|
+
}
|
|
41
|
+
return `${currentPrompt}\n\n${frameworkPrompt}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=frameworkPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameworkPrompt.js","sourceRoot":"","sources":["../../../src/runtime/middleware/frameworkPr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,CAAC,CAAC;QAChM,CAAC;QAED,MAAM,eAAe,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,aAAa,CAAC,QAAQ,CAAC,4BAA4B,CAAC,EAAE,CAAC;YACnF,OAAO,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC;QACjE,CAAC;QACD,OAAO,GAAG,aAAa,OAAO,eAAe,EAAE,CAAC;IAClD,CAAC;CACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AgentToolMiddlewareFactory } from "./agentToolMiddleware.js";
|
|
2
|
+
export { buildSkillPathMap } from "./skillPathMap.js";
|
|
3
|
+
export type { CreateAgentToolMiddlewareOptions, ToolCallAfterHookContext, ToolCallHookContext, } from "./types.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EACV,gCAAgC,EAChC,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skillPathMap.d.ts","sourceRoot":"","sources":["../../../src/runtime/middleware/skillPathMap.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAc9E;AAUD,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAqB/D"}
|