@marifold/core 0.60.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/LICENSE +674 -0
- package/dist/agent/AgentEvents.d.ts +106 -0
- package/dist/agent/AgentEvents.d.ts.map +1 -0
- package/dist/agent/AgentEvents.js +3 -0
- package/dist/agent/AgentEvents.js.map +1 -0
- package/dist/agent/AgentHistory.d.ts +27 -0
- package/dist/agent/AgentHistory.d.ts.map +1 -0
- package/dist/agent/AgentHistory.js +42 -0
- package/dist/agent/AgentHistory.js.map +1 -0
- package/dist/agent/AgentRunner.d.ts +149 -0
- package/dist/agent/AgentRunner.d.ts.map +1 -0
- package/dist/agent/AgentRunner.js +727 -0
- package/dist/agent/AgentRunner.js.map +1 -0
- package/dist/agent/ApprovalPolicy.d.ts +71 -0
- package/dist/agent/ApprovalPolicy.d.ts.map +1 -0
- package/dist/agent/ApprovalPolicy.js +29 -0
- package/dist/agent/ApprovalPolicy.js.map +1 -0
- package/dist/agent/ControlBlockTools.d.ts +9 -0
- package/dist/agent/ControlBlockTools.d.ts.map +1 -0
- package/dist/agent/ControlBlockTools.js +49 -0
- package/dist/agent/ControlBlockTools.js.map +1 -0
- package/dist/agent/RunWorkspace.d.ts +92 -0
- package/dist/agent/RunWorkspace.d.ts.map +1 -0
- package/dist/agent/RunWorkspace.js +328 -0
- package/dist/agent/RunWorkspace.js.map +1 -0
- package/dist/agent/ScopedProcess.d.ts +35 -0
- package/dist/agent/ScopedProcess.d.ts.map +1 -0
- package/dist/agent/ScopedProcess.js +280 -0
- package/dist/agent/ScopedProcess.js.map +1 -0
- package/dist/agent/ToolRegistry.d.ts +80 -0
- package/dist/agent/ToolRegistry.d.ts.map +1 -0
- package/dist/agent/ToolRegistry.js +45 -0
- package/dist/agent/ToolRegistry.js.map +1 -0
- package/dist/agent/UserInput.d.ts +59 -0
- package/dist/agent/UserInput.d.ts.map +1 -0
- package/dist/agent/UserInput.js +203 -0
- package/dist/agent/UserInput.js.map +1 -0
- package/dist/agent/tools/AskUserTool.d.ts +71 -0
- package/dist/agent/tools/AskUserTool.d.ts.map +1 -0
- package/dist/agent/tools/AskUserTool.js +70 -0
- package/dist/agent/tools/AskUserTool.js.map +1 -0
- package/dist/agent/tools/DelegateTool.d.ts +49 -0
- package/dist/agent/tools/DelegateTool.d.ts.map +1 -0
- package/dist/agent/tools/DelegateTool.js +62 -0
- package/dist/agent/tools/DelegateTool.js.map +1 -0
- package/dist/agent/tools/InspectAttachmentTool.d.ts +25 -0
- package/dist/agent/tools/InspectAttachmentTool.d.ts.map +1 -0
- package/dist/agent/tools/InspectAttachmentTool.js +129 -0
- package/dist/agent/tools/InspectAttachmentTool.js.map +1 -0
- package/dist/agent/tools/PythonPackageTool.d.ts +26 -0
- package/dist/agent/tools/PythonPackageTool.d.ts.map +1 -0
- package/dist/agent/tools/PythonPackageTool.js +105 -0
- package/dist/agent/tools/PythonPackageTool.js.map +1 -0
- package/dist/agent/tools/ReadFileTool.d.ts +24 -0
- package/dist/agent/tools/ReadFileTool.d.ts.map +1 -0
- package/dist/agent/tools/ReadFileTool.js +112 -0
- package/dist/agent/tools/ReadFileTool.js.map +1 -0
- package/dist/agent/tools/ShellExecTool.d.ts +23 -0
- package/dist/agent/tools/ShellExecTool.d.ts.map +1 -0
- package/dist/agent/tools/ShellExecTool.js +75 -0
- package/dist/agent/tools/ShellExecTool.js.map +1 -0
- package/dist/agent/tools/WebSearchTool.d.ts +26 -0
- package/dist/agent/tools/WebSearchTool.d.ts.map +1 -0
- package/dist/agent/tools/WebSearchTool.js +52 -0
- package/dist/agent/tools/WebSearchTool.js.map +1 -0
- package/dist/agent/tools/WriteFileTool.d.ts +30 -0
- package/dist/agent/tools/WriteFileTool.d.ts.map +1 -0
- package/dist/agent/tools/WriteFileTool.js +155 -0
- package/dist/agent/tools/WriteFileTool.js.map +1 -0
- package/dist/app/AppActionResolver.d.ts +15 -0
- package/dist/app/AppActionResolver.d.ts.map +1 -0
- package/dist/app/AppActionResolver.js +98 -0
- package/dist/app/AppActionResolver.js.map +1 -0
- package/dist/app/AppSchema.d.ts +83 -0
- package/dist/app/AppSchema.d.ts.map +1 -0
- package/dist/app/AppSchema.js +17 -0
- package/dist/app/AppSchema.js.map +1 -0
- package/dist/app/AppStore.d.ts +14 -0
- package/dist/app/AppStore.d.ts.map +1 -0
- package/dist/app/AppStore.js +146 -0
- package/dist/app/AppStore.js.map +1 -0
- package/dist/app/AppValidator.d.ts +10 -0
- package/dist/app/AppValidator.d.ts.map +1 -0
- package/dist/app/AppValidator.js +503 -0
- package/dist/app/AppValidator.js.map +1 -0
- package/dist/app/SkillAppCompiler.d.ts +5 -0
- package/dist/app/SkillAppCompiler.d.ts.map +1 -0
- package/dist/app/SkillAppCompiler.js +632 -0
- package/dist/app/SkillAppCompiler.js.map +1 -0
- package/dist/app/SkillAppDsl.d.ts +93 -0
- package/dist/app/SkillAppDsl.d.ts.map +1 -0
- package/dist/app/SkillAppDsl.js +72 -0
- package/dist/app/SkillAppDsl.js.map +1 -0
- package/dist/app/SkillAppInstanceRegistry.d.ts +25 -0
- package/dist/app/SkillAppInstanceRegistry.d.ts.map +1 -0
- package/dist/app/SkillAppInstanceRegistry.js +218 -0
- package/dist/app/SkillAppInstanceRegistry.js.map +1 -0
- package/dist/app/SkillAppResolver.d.ts +12 -0
- package/dist/app/SkillAppResolver.d.ts.map +1 -0
- package/dist/app/SkillAppResolver.js +89 -0
- package/dist/app/SkillAppResolver.js.map +1 -0
- package/dist/app/SkillAppSchema.d.ts +116 -0
- package/dist/app/SkillAppSchema.d.ts.map +1 -0
- package/dist/app/SkillAppSchema.js +5 -0
- package/dist/app/SkillAppSchema.js.map +1 -0
- package/dist/channels/TelegramBridge.d.ts +103 -0
- package/dist/channels/TelegramBridge.d.ts.map +1 -0
- package/dist/channels/TelegramBridge.js +565 -0
- package/dist/channels/TelegramBridge.js.map +1 -0
- package/dist/channels/respond.d.ts +46 -0
- package/dist/channels/respond.d.ts.map +1 -0
- package/dist/channels/respond.js +41 -0
- package/dist/channels/respond.js.map +1 -0
- package/dist/config/ChatGptTokenRefresh.d.ts +18 -0
- package/dist/config/ChatGptTokenRefresh.d.ts.map +1 -0
- package/dist/config/ChatGptTokenRefresh.js +63 -0
- package/dist/config/ChatGptTokenRefresh.js.map +1 -0
- package/dist/config/ConfigBackup.d.ts +20 -0
- package/dist/config/ConfigBackup.d.ts.map +1 -0
- package/dist/config/ConfigBackup.js +197 -0
- package/dist/config/ConfigBackup.js.map +1 -0
- package/dist/config/ConfigLoader.d.ts +28 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -0
- package/dist/config/ConfigLoader.js +335 -0
- package/dist/config/ConfigLoader.js.map +1 -0
- package/dist/config/ConfigManager.d.ts +55 -0
- package/dist/config/ConfigManager.d.ts.map +1 -0
- package/dist/config/ConfigManager.js +707 -0
- package/dist/config/ConfigManager.js.map +1 -0
- package/dist/config/ConfigSchema.d.ts +231 -0
- package/dist/config/ConfigSchema.d.ts.map +1 -0
- package/dist/config/ConfigSchema.js +15 -0
- package/dist/config/ConfigSchema.js.map +1 -0
- package/dist/config/GitHubCopilotAuth.d.ts +7 -0
- package/dist/config/GitHubCopilotAuth.d.ts.map +1 -0
- package/dist/config/GitHubCopilotAuth.js +40 -0
- package/dist/config/GitHubCopilotAuth.js.map +1 -0
- package/dist/config/MarifoldOpenAICompatProvider.d.ts +39 -0
- package/dist/config/MarifoldOpenAICompatProvider.d.ts.map +1 -0
- package/dist/config/MarifoldOpenAICompatProvider.js +158 -0
- package/dist/config/MarifoldOpenAICompatProvider.js.map +1 -0
- package/dist/config/OpenAICompatUrls.d.ts +7 -0
- package/dist/config/OpenAICompatUrls.d.ts.map +1 -0
- package/dist/config/OpenAICompatUrls.js +47 -0
- package/dist/config/OpenAICompatUrls.js.map +1 -0
- package/dist/config/ProviderFactory.d.ts +12 -0
- package/dist/config/ProviderFactory.d.ts.map +1 -0
- package/dist/config/ProviderFactory.js +61 -0
- package/dist/config/ProviderFactory.js.map +1 -0
- package/dist/config/ProviderInspector.d.ts +46 -0
- package/dist/config/ProviderInspector.d.ts.map +1 -0
- package/dist/config/ProviderInspector.js +356 -0
- package/dist/config/ProviderInspector.js.map +1 -0
- package/dist/config/ProviderRegistry.d.ts +19 -0
- package/dist/config/ProviderRegistry.d.ts.map +1 -0
- package/dist/config/ProviderRegistry.js +301 -0
- package/dist/config/ProviderRegistry.js.map +1 -0
- package/dist/config/XaiTokenRefresh.d.ts +15 -0
- package/dist/config/XaiTokenRefresh.d.ts.map +1 -0
- package/dist/config/XaiTokenRefresh.js +73 -0
- package/dist/config/XaiTokenRefresh.js.map +1 -0
- package/dist/errors/MarifoldError.d.ts +34 -0
- package/dist/errors/MarifoldError.d.ts.map +1 -0
- package/dist/errors/MarifoldError.js +100 -0
- package/dist/errors/MarifoldError.js.map +1 -0
- package/dist/images/ImageOptimizer.d.ts +34 -0
- package/dist/images/ImageOptimizer.d.ts.map +1 -0
- package/dist/images/ImageOptimizer.js +225 -0
- package/dist/images/ImageOptimizer.js.map +1 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +193 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/MemoryControls.d.ts +26 -0
- package/dist/memory/MemoryControls.d.ts.map +1 -0
- package/dist/memory/MemoryControls.js +388 -0
- package/dist/memory/MemoryControls.js.map +1 -0
- package/dist/memory/MemoryStore.d.ts +122 -0
- package/dist/memory/MemoryStore.d.ts.map +1 -0
- package/dist/memory/MemoryStore.js +1096 -0
- package/dist/memory/MemoryStore.js.map +1 -0
- package/dist/profiles/ProfileManager.d.ts +139 -0
- package/dist/profiles/ProfileManager.d.ts.map +1 -0
- package/dist/profiles/ProfileManager.js +475 -0
- package/dist/profiles/ProfileManager.js.map +1 -0
- package/dist/profiles/ProfileResolver.d.ts +18 -0
- package/dist/profiles/ProfileResolver.d.ts.map +1 -0
- package/dist/profiles/ProfileResolver.js +280 -0
- package/dist/profiles/ProfileResolver.js.map +1 -0
- package/dist/runs/RunRegistry.d.ts +140 -0
- package/dist/runs/RunRegistry.d.ts.map +1 -0
- package/dist/runs/RunRegistry.js +432 -0
- package/dist/runs/RunRegistry.js.map +1 -0
- package/dist/runtime/MarifoldRuntime.d.ts +244 -0
- package/dist/runtime/MarifoldRuntime.d.ts.map +1 -0
- package/dist/runtime/MarifoldRuntime.js +1099 -0
- package/dist/runtime/MarifoldRuntime.js.map +1 -0
- package/dist/runtime/MarifoldTypes.d.ts +70 -0
- package/dist/runtime/MarifoldTypes.d.ts.map +1 -0
- package/dist/runtime/MarifoldTypes.js +3 -0
- package/dist/runtime/MarifoldTypes.js.map +1 -0
- package/dist/schedule/ScheduleStore.d.ts +60 -0
- package/dist/schedule/ScheduleStore.d.ts.map +1 -0
- package/dist/schedule/ScheduleStore.js +212 -0
- package/dist/schedule/ScheduleStore.js.map +1 -0
- package/dist/schedule/Scheduler.d.ts +28 -0
- package/dist/schedule/Scheduler.d.ts.map +1 -0
- package/dist/schedule/Scheduler.js +65 -0
- package/dist/schedule/Scheduler.js.map +1 -0
- package/dist/search/DuckDuckGoBackend.d.ts +18 -0
- package/dist/search/DuckDuckGoBackend.d.ts.map +1 -0
- package/dist/search/DuckDuckGoBackend.js +37 -0
- package/dist/search/DuckDuckGoBackend.js.map +1 -0
- package/dist/search/FirecrawlBackend.d.ts +28 -0
- package/dist/search/FirecrawlBackend.d.ts.map +1 -0
- package/dist/search/FirecrawlBackend.js +76 -0
- package/dist/search/FirecrawlBackend.js.map +1 -0
- package/dist/search/SearchBackend.d.ts +18 -0
- package/dist/search/SearchBackend.d.ts.map +1 -0
- package/dist/search/SearchBackend.js +24 -0
- package/dist/search/SearchBackend.js.map +1 -0
- package/dist/search/createSearchBackend.d.ts +16 -0
- package/dist/search/createSearchBackend.d.ts.map +1 -0
- package/dist/search/createSearchBackend.js +30 -0
- package/dist/search/createSearchBackend.js.map +1 -0
- package/dist/sessions/ResponseMetrics.d.ts +17 -0
- package/dist/sessions/ResponseMetrics.d.ts.map +1 -0
- package/dist/sessions/ResponseMetrics.js +3 -0
- package/dist/sessions/ResponseMetrics.js.map +1 -0
- package/dist/sessions/SessionResolver.d.ts +135 -0
- package/dist/sessions/SessionResolver.d.ts.map +1 -0
- package/dist/sessions/SessionResolver.js +1173 -0
- package/dist/sessions/SessionResolver.js.map +1 -0
- package/dist/skill/BuiltInSkillManager.d.ts +11 -0
- package/dist/skill/BuiltInSkillManager.d.ts.map +1 -0
- package/dist/skill/BuiltInSkillManager.js +98 -0
- package/dist/skill/BuiltInSkillManager.js.map +1 -0
- package/dist/skill/SkillInvocation.d.ts +30 -0
- package/dist/skill/SkillInvocation.d.ts.map +1 -0
- package/dist/skill/SkillInvocation.js +135 -0
- package/dist/skill/SkillInvocation.js.map +1 -0
- package/dist/skill/SkillSchema.d.ts +37 -0
- package/dist/skill/SkillSchema.d.ts.map +1 -0
- package/dist/skill/SkillSchema.js +26 -0
- package/dist/skill/SkillSchema.js.map +1 -0
- package/dist/skill/SkillStore.d.ts +41 -0
- package/dist/skill/SkillStore.d.ts.map +1 -0
- package/dist/skill/SkillStore.js +184 -0
- package/dist/skill/SkillStore.js.map +1 -0
- package/dist/skill/SkillTemplater.d.ts +19 -0
- package/dist/skill/SkillTemplater.d.ts.map +1 -0
- package/dist/skill/SkillTemplater.js +36 -0
- package/dist/skill/SkillTemplater.js.map +1 -0
- package/dist/skill/SkillValidator.d.ts +10 -0
- package/dist/skill/SkillValidator.d.ts.map +1 -0
- package/dist/skill/SkillValidator.js +131 -0
- package/dist/skill/SkillValidator.js.map +1 -0
- package/dist/skill/SkillVars.d.ts +10 -0
- package/dist/skill/SkillVars.d.ts.map +1 -0
- package/dist/skill/SkillVars.js +65 -0
- package/dist/skill/SkillVars.js.map +1 -0
- package/dist/skill/index.d.ts +10 -0
- package/dist/skill/index.d.ts.map +1 -0
- package/dist/skill/index.js +22 -0
- package/dist/skill/index.js.map +1 -0
- package/dist/skillapp/SkillAppActionResolver.d.ts +13 -0
- package/dist/skillapp/SkillAppActionResolver.d.ts.map +1 -0
- package/dist/skillapp/SkillAppActionResolver.js +95 -0
- package/dist/skillapp/SkillAppActionResolver.js.map +1 -0
- package/dist/skillapp/SkillAppSchema.d.ts +79 -0
- package/dist/skillapp/SkillAppSchema.d.ts.map +1 -0
- package/dist/skillapp/SkillAppSchema.js +20 -0
- package/dist/skillapp/SkillAppSchema.js.map +1 -0
- package/dist/skillapp/SkillAppStore.d.ts +11 -0
- package/dist/skillapp/SkillAppStore.d.ts.map +1 -0
- package/dist/skillapp/SkillAppStore.js +98 -0
- package/dist/skillapp/SkillAppStore.js.map +1 -0
- package/dist/skillapp/SkillAppValidator.d.ts +10 -0
- package/dist/skillapp/SkillAppValidator.d.ts.map +1 -0
- package/dist/skillapp/SkillAppValidator.js +522 -0
- package/dist/skillapp/SkillAppValidator.js.map +1 -0
- package/dist/tasks/TaskStore.d.ts +110 -0
- package/dist/tasks/TaskStore.d.ts.map +1 -0
- package/dist/tasks/TaskStore.js +371 -0
- package/dist/tasks/TaskStore.js.map +1 -0
- package/dist/util/fetchRetry.d.ts +11 -0
- package/dist/util/fetchRetry.d.ts.map +1 -0
- package/dist/util/fetchRetry.js +48 -0
- package/dist/util/fetchRetry.js.map +1 -0
- package/dist/util/idToken.d.ts +12 -0
- package/dist/util/idToken.d.ts.map +1 -0
- package/dist/util/idToken.js +32 -0
- package/dist/util/idToken.js.map +1 -0
- package/dist/util/proxy.d.ts +18 -0
- package/dist/util/proxy.d.ts.map +1 -0
- package/dist/util/proxy.js +28 -0
- package/dist/util/proxy.js.map +1 -0
- package/dist/workspace/Workspace.d.ts +9 -0
- package/dist/workspace/Workspace.d.ts.map +1 -0
- package/dist/workspace/Workspace.js +55 -0
- package/dist/workspace/Workspace.js.map +1 -0
- package/dist/workspace/WorkspaceInitializer.d.ts +40 -0
- package/dist/workspace/WorkspaceInitializer.d.ts.map +1 -0
- package/dist/workspace/WorkspaceInitializer.js +212 -0
- package/dist/workspace/WorkspaceInitializer.js.map +1 -0
- package/dist/workspace/WorkspacePaths.d.ts +11 -0
- package/dist/workspace/WorkspacePaths.d.ts.map +1 -0
- package/dist/workspace/WorkspacePaths.js +82 -0
- package/dist/workspace/WorkspacePaths.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DelegateTool.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/DelegateTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAqC,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE1H,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACjE,gBAAgB,EAAE,MAAM,MAAM,EAAE,CAAC;CAClC;AAED;;;;GAIG;AACH,qBAAa,YAAa,YAAW,SAAS;IAmBhC,OAAO,CAAC,QAAQ,CAAC,IAAI;IAlBjC,QAAQ,CAAC,IAAI,EAAG,UAAU,CAAU;IACpC,QAAQ,CAAC,UAAU;QACjB,IAAI;QACJ,WAAW;QAKX,UAAU;YACR,IAAI;YACJ,UAAU;gBACR,OAAO;oBAAI,IAAI;oBAAY,WAAW;;gBACtC,MAAM;oBAAI,IAAI;oBAAY,WAAW;;;YAEvC,QAAQ;;MAEV;IAEF,YAA6B,IAAI,EAAE,gBAAgB,EAAI;IAEvD,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,CAGtD;IAEK,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAyBvG;CACF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DelegateTool = void 0;
|
|
4
|
+
const ToolRegistry_1 = require("../ToolRegistry");
|
|
5
|
+
/**
|
|
6
|
+
* Minimal multi-model orchestration: run a one-shot request through another
|
|
7
|
+
* profile (and therefore that profile's provider/model). Delegated requests
|
|
8
|
+
* are plain asks — no tools — so delegation depth is structurally 1.
|
|
9
|
+
*/
|
|
10
|
+
class DelegateTool {
|
|
11
|
+
deps;
|
|
12
|
+
kind = 'delegate';
|
|
13
|
+
definition = {
|
|
14
|
+
name: 'ask_profile',
|
|
15
|
+
description: [
|
|
16
|
+
'Send a one-shot prompt to another Marifold profile, which may use a different model, and return its reply without tools.',
|
|
17
|
+
'When to use: a known specialized profile is materially better suited to a bounded subtask, such as translation.',
|
|
18
|
+
'When NOT to use: ordinary work the active profile can complete, tool-using or multi-step delegation, implicit profile discovery, or recursive delegation.',
|
|
19
|
+
].join(' '),
|
|
20
|
+
parameters: {
|
|
21
|
+
type: 'object',
|
|
22
|
+
properties: {
|
|
23
|
+
profile: { type: 'string', description: 'Name of the target profile.' },
|
|
24
|
+
prompt: { type: 'string', description: 'The prompt to send to that profile.' },
|
|
25
|
+
},
|
|
26
|
+
required: ['profile', 'prompt'],
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
constructor(deps) {
|
|
30
|
+
this.deps = deps;
|
|
31
|
+
}
|
|
32
|
+
summarizeCall(input) {
|
|
33
|
+
const profile = typeof input.profile === 'string' ? input.profile : '<missing profile>';
|
|
34
|
+
return `ask profile '${profile}'`;
|
|
35
|
+
}
|
|
36
|
+
async execute(input, ctx) {
|
|
37
|
+
const profile = (0, ToolRegistry_1.requireStringInput)(input, 'profile', 'ask_profile');
|
|
38
|
+
const prompt = (0, ToolRegistry_1.requireStringInput)(input, 'prompt', 'ask_profile');
|
|
39
|
+
const known = this.deps.listProfileNames();
|
|
40
|
+
if (!known.includes(profile)) {
|
|
41
|
+
return {
|
|
42
|
+
content: `Profile '${profile}' does not exist. Available profiles: ${known.join(', ') || '(none)'}.`,
|
|
43
|
+
summary: `unknown profile '${profile}'`,
|
|
44
|
+
isError: true,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const result = await this.deps.ask({ prompt, profile });
|
|
48
|
+
if (!result.ok) {
|
|
49
|
+
return {
|
|
50
|
+
content: `Profile '${profile}' request failed: ${result.error?.message ?? 'unknown error'}`,
|
|
51
|
+
summary: `profile '${profile}' failed`,
|
|
52
|
+
isError: true,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
content: (0, ToolRegistry_1.capToolOutput)(result.text, ctx.outputLimit),
|
|
57
|
+
summary: `profile '${profile}' replied`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.DelegateTool = DelegateTool;
|
|
62
|
+
//# sourceMappingURL=DelegateTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DelegateTool.js","sourceRoot":"","sources":["../../../src/agent/tools/DelegateTool.ts"],"names":[],"mappings":";;;AACA,kDAA0H;AAkB1H;;;;GAIG;AACH;IAmB+B,IAAI;IAlBxB,IAAI,GAAG,UAAmB,CAAC;IAC3B,UAAU,GAAG;QACpB,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE;YACX,0HAA0H;YAC1H,iHAAiH;YACjH,2JAA2J;SAC5J,CAAC,IAAI,CAAC,GAAG,CAAC;QACX,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE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AO,qBAAqB,MAAM,CAAC,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE;gBAC3F,OAAO,EAAE,YAAY,OAAO,UAAU;gBACtC,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,IAAA,4BAAa,EAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,WAAW,CAAC;YACpD,OAAO,EAAE,YAAY,OAAO,WAAW;SACxC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { JSONValue } from '@priest-ai/core';
|
|
2
|
+
import { AgentTool, ToolExecutionContext, ToolExecutionResult, ToolRiskAssessment } from '../ToolRegistry';
|
|
3
|
+
/** Attachment-scoped, read-only inspection. The model supplies an opaque ID,
|
|
4
|
+
* never a host path; the run workspace resolves that ID to the exact upload. */
|
|
5
|
+
export declare class InspectAttachmentTool implements AgentTool {
|
|
6
|
+
readonly kind: 'read';
|
|
7
|
+
readonly definition: {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
parameters: {
|
|
11
|
+
type: string;
|
|
12
|
+
properties: {
|
|
13
|
+
attachment_id: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
required: string[];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
summarizeCall(input: Record<string, JSONValue>): string;
|
|
22
|
+
assessRisk(): ToolRiskAssessment;
|
|
23
|
+
execute(input: Record<string, JSONValue>, ctx: ToolExecutionContext): Promise<ToolExecutionResult>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=InspectAttachmentTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InspectAttachmentTool.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/InspectAttachmentTool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,SAAS,EAGT,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAUzB;gFACgF;AAChF,qBAAa,qBAAsB,YAAW,SAAS;IACrD,QAAQ,CAAC,IAAI,EAAG,MAAM,CAAU;IAChC,QAAQ,CAAC,UAAU;QACjB,IAAI;QACJ,WAAW;QAMX,UAAU;YACR,IAAI;YACJ,UAAU;gBACR,aAAa;oBACX,IAAI;oBACJ,WAAW;;;YAGf,QAAQ;;MAEV;IAEF,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,CAEtD;IAED,UAAU,IAAI,kBAAkB,CAK/B;IAEK,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAuCvG;CACF"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.InspectAttachmentTool = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const ToolRegistry_1 = require("../ToolRegistry");
|
|
40
|
+
const ReadFileTool_1 = require("./ReadFileTool");
|
|
41
|
+
const TEXT_EXTENSIONS = new Set([
|
|
42
|
+
'.txt', '.md', '.markdown', '.json', '.jsonl', '.yaml', '.yml', '.toml', '.ini',
|
|
43
|
+
'.csv', '.tsv', '.xml', '.html', '.css', '.js', '.mjs', '.cjs', '.ts', '.tsx',
|
|
44
|
+
'.jsx', '.py', '.rb', '.go', '.rs', '.java', '.kt', '.swift', '.c', '.h', '.cpp',
|
|
45
|
+
'.hpp', '.cs', '.sh', '.zsh', '.bash', '.fish', '.sql', '.log', '.diff', '.patch',
|
|
46
|
+
]);
|
|
47
|
+
/** Attachment-scoped, read-only inspection. The model supplies an opaque ID,
|
|
48
|
+
* never a host path; the run workspace resolves that ID to the exact upload. */
|
|
49
|
+
class InspectAttachmentTool {
|
|
50
|
+
kind = 'read';
|
|
51
|
+
definition = {
|
|
52
|
+
name: 'inspect_attachment',
|
|
53
|
+
description: [
|
|
54
|
+
'Inspect one attachment uploaded for the current run by its attachment ID.',
|
|
55
|
+
'Images become visible to the model; text and pre-extracted documents return bounded readable text; other binaries return safe metadata and their read-only run path.',
|
|
56
|
+
'When to use: the objective or skill depends on an attached image, document, spreadsheet, audio file, or other upload.',
|
|
57
|
+
'When NOT to use: arbitrary filesystem paths, bundled skill files, or information already present in the prompt.',
|
|
58
|
+
].join(' '),
|
|
59
|
+
parameters: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: {
|
|
62
|
+
attachment_id: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
description: 'Opaque ID from the current run attachment manifest, such as attachment-1.',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
required: ['attachment_id'],
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
summarizeCall(input) {
|
|
71
|
+
return `inspect ${typeof input.attachment_id === 'string' ? input.attachment_id : '<missing attachment>'}`;
|
|
72
|
+
}
|
|
73
|
+
assessRisk() {
|
|
74
|
+
// The ID can resolve only inside the current run manifest. Uploading the
|
|
75
|
+
// attachment is the user's explicit grant to inspect it; no host path can
|
|
76
|
+
// be smuggled through this tool.
|
|
77
|
+
return { escalate: false, trusted: true };
|
|
78
|
+
}
|
|
79
|
+
async execute(input, ctx) {
|
|
80
|
+
const id = (0, ToolRegistry_1.requireStringInput)(input, 'attachment_id', 'inspect_attachment');
|
|
81
|
+
const attachment = ctx.workspace?.attachments.find(candidate => candidate.id === id);
|
|
82
|
+
if (!attachment) {
|
|
83
|
+
const available = ctx.workspace?.attachments.map(candidate => candidate.id).join(', ') || '(none)';
|
|
84
|
+
return {
|
|
85
|
+
content: `Attachment '${id}' is not available in this run. Available attachment IDs: ${available}.`,
|
|
86
|
+
summary: `attachment ${id} not found`,
|
|
87
|
+
isError: true,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (attachment.image) {
|
|
91
|
+
return {
|
|
92
|
+
content: `Attachment ${attachment.id} (${attachment.name}, ${attachment.mediaType}) is now visible as image input. Inspect the image itself before answering.`,
|
|
93
|
+
images: [attachment.image],
|
|
94
|
+
summary: `opened image ${attachment.name}`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const text = attachment.inspectionText ?? readTextAttachment(attachment.path, attachment.name, attachment.mediaType);
|
|
98
|
+
if (text !== undefined) {
|
|
99
|
+
return {
|
|
100
|
+
content: (0, ToolRegistry_1.capToolOutput)(text, ctx.outputLimit),
|
|
101
|
+
summary: `inspected ${attachment.name}`,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const location = attachment.path ? `\nRead-only run path: ${attachment.path}` : '';
|
|
105
|
+
return {
|
|
106
|
+
content: [
|
|
107
|
+
`Attachment: ${attachment.name}`,
|
|
108
|
+
`Media type: ${attachment.mediaType}`,
|
|
109
|
+
`Size: ${(0, ReadFileTool_1.formatBytes)(attachment.size)}`,
|
|
110
|
+
location,
|
|
111
|
+
'No built-in readable preview is available for this format. Use a format-specific local tool against the run path if the task requires deeper inspection.',
|
|
112
|
+
].filter(Boolean).join('\n'),
|
|
113
|
+
summary: `inspected metadata for ${attachment.name}`,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.InspectAttachmentTool = InspectAttachmentTool;
|
|
118
|
+
function readTextAttachment(filePath, name, mediaType) {
|
|
119
|
+
if (!filePath || (!mediaType.startsWith('text/') && !TEXT_EXTENSIONS.has(path.extname(name).toLowerCase()))) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
return fs.readFileSync(filePath, 'utf8');
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
return `Could not read ${name}: ${error instanceof Error ? error.message : String(error)}`;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=InspectAttachmentTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InspectAttachmentTool.js","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K,CAAC,EAAE,CAAC;IAC7F,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { JSONValue } from '@priest-ai/core';
|
|
2
|
+
import { AgentTool, ToolExecutionContext, ToolExecutionResult, ToolRiskAssessment } from '../ToolRegistry';
|
|
3
|
+
export declare class PythonPackageTool implements AgentTool {
|
|
4
|
+
readonly kind: 'network';
|
|
5
|
+
readonly definition: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
parameters: {
|
|
9
|
+
type: string;
|
|
10
|
+
properties: {
|
|
11
|
+
packages: {
|
|
12
|
+
type: string;
|
|
13
|
+
items: {
|
|
14
|
+
type: string;
|
|
15
|
+
};
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
required: string[];
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
summarizeCall(input: Record<string, JSONValue>): string;
|
|
23
|
+
assessRisk(_input: Record<string, JSONValue>, _ctx: ToolExecutionContext): ToolRiskAssessment;
|
|
24
|
+
execute(input: Record<string, JSONValue>, ctx: ToolExecutionContext): Promise<ToolExecutionResult>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=PythonPackageTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PythonPackageTool.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/PythonPackageTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAO5C,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAOzB,qBAAa,iBAAkB,YAAW,SAAS;IACjD,QAAQ,CAAC,IAAI,EAAG,SAAS,CAAU;IACnC,QAAQ,CAAC,UAAU;QACjB,IAAI;QACJ,WAAW;QAMX,UAAU;YACR,IAAI;YACJ,UAAU;gBACR,QAAQ;oBACN,IAAI;oBACJ,KAAK;wBAAI,IAAI;;oBACb,WAAW;;;YAGf,QAAQ;;MAEV;IAEF,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,CAGtD;IAED,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,oBAAoB,GAAG,kBAAkB,CAM5F;IAEK,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAqDvG;CACF"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PythonPackageTool = void 0;
|
|
4
|
+
const ScopedProcess_1 = require("../ScopedProcess");
|
|
5
|
+
const MAX_PACKAGES_PER_CALL = 20;
|
|
6
|
+
// Registry requirement with optional extras/version markers. Deliberately
|
|
7
|
+
// excludes flags, filesystem paths, URLs, Git sources, and editable installs.
|
|
8
|
+
const SAFE_REQUIREMENT = /^[A-Za-z0-9][A-Za-z0-9._-]*(?:\[[A-Za-z0-9._,-]+\])?(?:\s*(?:===|==|~=|!=|<=|>=|<|>)\s*[A-Za-z0-9*+!._-]+)?$/;
|
|
9
|
+
class PythonPackageTool {
|
|
10
|
+
kind = 'network';
|
|
11
|
+
definition = {
|
|
12
|
+
name: 'python_package_install',
|
|
13
|
+
description: [
|
|
14
|
+
'Install Python registry packages into this run’s disposable uv environment.',
|
|
15
|
+
'When to use: a required Python import is missing and installing a named PyPI dependency is necessary to complete the objective.',
|
|
16
|
+
'When NOT to use: speculative dependencies, packages already available, non-Python tools, URLs, Git sources, paths, flags, or global installs.',
|
|
17
|
+
'Use this instead of pip/uv inside shell_exec.',
|
|
18
|
+
].join(' '),
|
|
19
|
+
parameters: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
packages: {
|
|
23
|
+
type: 'array',
|
|
24
|
+
items: { type: 'string' },
|
|
25
|
+
description: 'PyPI requirement names, preferably version-pinned (for example openpyxl==3.1.5).',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ['packages'],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
summarizeCall(input) {
|
|
32
|
+
const packages = packageInputs(input);
|
|
33
|
+
return `install ${packages.length > 0 ? packages.join(', ') : '<missing packages>'} into this run’s Python environment`;
|
|
34
|
+
}
|
|
35
|
+
assessRisk(_input, _ctx) {
|
|
36
|
+
return {
|
|
37
|
+
escalate: true,
|
|
38
|
+
persistable: false,
|
|
39
|
+
reason: 'package installation downloads and executes third-party code for this run',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async execute(input, ctx) {
|
|
43
|
+
const packages = packageInputs(input);
|
|
44
|
+
const invalid = packages.find(pkg => !SAFE_REQUIREMENT.test(pkg));
|
|
45
|
+
if (packages.length === 0 || packages.length > MAX_PACKAGES_PER_CALL || invalid) {
|
|
46
|
+
return {
|
|
47
|
+
content: invalid
|
|
48
|
+
? `Refused unsafe Python requirement '${invalid}'. Use a registry package name with an optional version constraint.`
|
|
49
|
+
: `Provide between 1 and ${MAX_PACKAGES_PER_CALL} Python package requirements.`,
|
|
50
|
+
summary: 'refused Python package installation',
|
|
51
|
+
isError: true,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (!ctx.workspace) {
|
|
55
|
+
return {
|
|
56
|
+
content: 'Marifold refused package installation without an isolated run workspace.',
|
|
57
|
+
summary: 'blocked Python package installation',
|
|
58
|
+
isError: true,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const environmentError = await (0, ScopedProcess_1.ensurePythonEnvironment)(ctx.workspace, ctx.outputLimit, ctx.signal);
|
|
62
|
+
if (environmentError)
|
|
63
|
+
return environmentError;
|
|
64
|
+
const uv = (0, ScopedProcess_1.findExecutable)(process.platform === 'win32' ? 'uv.exe' : 'uv');
|
|
65
|
+
if (!uv) {
|
|
66
|
+
return {
|
|
67
|
+
content: 'uv is required for isolated package installation, but it was not found on PATH.',
|
|
68
|
+
summary: 'could not install Python packages',
|
|
69
|
+
isError: true,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const installerRoots = [
|
|
73
|
+
ctx.workspace.workDir,
|
|
74
|
+
ctx.workspace.homeDir,
|
|
75
|
+
ctx.workspace.tempDir,
|
|
76
|
+
ctx.workspace.cacheDir,
|
|
77
|
+
ctx.workspace.venvDir,
|
|
78
|
+
];
|
|
79
|
+
return (0, ScopedProcess_1.runScopedProcess)({
|
|
80
|
+
executable: uv,
|
|
81
|
+
args: ['pip', 'install', '--python', (0, ScopedProcess_1.pythonInVenv)(ctx.workspace), ...packages],
|
|
82
|
+
workspace: ctx.workspace,
|
|
83
|
+
cwd: ctx.workspace.workDir,
|
|
84
|
+
// Package build hooks are untrusted third-party code. While network is
|
|
85
|
+
// enabled they may only see the disposable environment, never attached
|
|
86
|
+
// files, the selected repository, or trusted host folders.
|
|
87
|
+
readRoots: installerRoots,
|
|
88
|
+
writeRoots: installerRoots,
|
|
89
|
+
network: true,
|
|
90
|
+
timeoutMs: 180_000,
|
|
91
|
+
outputLimit: ctx.outputLimit,
|
|
92
|
+
signal: ctx.signal,
|
|
93
|
+
successSummary: `installed ${packages.join(', ')} into this run’s Python environment`,
|
|
94
|
+
failureSummary: `could not install ${packages.join(', ')}`,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.PythonPackageTool = PythonPackageTool;
|
|
99
|
+
function packageInputs(input) {
|
|
100
|
+
const value = input.packages;
|
|
101
|
+
if (!Array.isArray(value))
|
|
102
|
+
return [];
|
|
103
|
+
return value.flatMap(item => typeof item === 'string' && item.trim() ? [item.trim()] : []);
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=PythonPackageTool.js.map
|
|
@@ -0,0 +1 @@
|
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AC;YACtB,UAAU,EAAE,EAAE;YACd,IAAI,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,IAAA,4BAAY,EAAC,GAAG,CAAC,SAAS,CAAC,EAAE,GAAG,QAAQ,CAAC;YAC9E,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,GAAG,EAAE,GAAG,CAAC,SAAS,CAAC,OAAO;YAC1B,uEAAuE;YACvE,uEAAuE;YACvE,2DAA2D;YAC3D,SAAS,EAAE,cAAc;YACzB,UAAU,EAAE,cAAc;YAC1B,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,OAAO;YAClB,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,cAAc,EAAE,aAAa,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,qCAAqC;YACrF,cAAc,EAAE,qBAAqB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;SAC3D,CAAC,CAAC;IACL,CAAC;CACF;;AAED,SAAS,aAAa,CAAC,KAAgC;IACrD,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC;IAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { JSONValue } from '@priest-ai/core';
|
|
2
|
+
import { AgentTool, ToolExecutionContext, ToolExecutionResult, ToolRiskAssessment } from '../ToolRegistry';
|
|
3
|
+
export declare class ReadFileTool implements AgentTool {
|
|
4
|
+
readonly kind: 'read';
|
|
5
|
+
readonly definition: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
parameters: {
|
|
9
|
+
type: string;
|
|
10
|
+
properties: {
|
|
11
|
+
path: {
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
required: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
summarizeCall(input: Record<string, JSONValue>): string;
|
|
20
|
+
assessRisk(input: Record<string, JSONValue>, ctx: ToolExecutionContext): ToolRiskAssessment;
|
|
21
|
+
execute(input: Record<string, JSONValue>, ctx: ToolExecutionContext): Promise<ToolExecutionResult>;
|
|
22
|
+
}
|
|
23
|
+
export declare function formatBytes(bytes: number): string;
|
|
24
|
+
//# sourceMappingURL=ReadFileTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadFileTool.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/ReadFileTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAO5C,OAAO,EACL,SAAS,EAGT,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAEzB,qBAAa,YAAa,YAAW,SAAS;IAC5C,QAAQ,CAAC,IAAI,EAAG,MAAM,CAAU;IAChC,QAAQ,CAAC,UAAU;QACjB,IAAI;QACJ,WAAW;QAKX,UAAU;YACR,IAAI;YACJ,UAAU;gBACR,IAAI;oBAAI,IAAI;oBAAY,WAAW;;;YAErC,QAAQ;;MAEV;IAEF,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,CAEtD;IAED,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,oBAAoB,GAAG,kBAAkB,CAa1F;IAEK,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA4BvG;CACF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIjD"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ReadFileTool = void 0;
|
|
37
|
+
exports.formatBytes = formatBytes;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const RunWorkspace_1 = require("../RunWorkspace");
|
|
40
|
+
const ToolRegistry_1 = require("../ToolRegistry");
|
|
41
|
+
class ReadFileTool {
|
|
42
|
+
kind = 'read';
|
|
43
|
+
definition = {
|
|
44
|
+
name: 'read_file',
|
|
45
|
+
description: [
|
|
46
|
+
'Read one local UTF-8 text file with bounded output, or list one known directory level.',
|
|
47
|
+
'When to use: inspect an exact path, read source or instructions before acting, or confirm a written file.',
|
|
48
|
+
'When NOT to use: broad content search, binary-file extraction, facts already available in context, or speculative filesystem exploration.',
|
|
49
|
+
].join(' '),
|
|
50
|
+
parameters: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
properties: {
|
|
53
|
+
path: { type: 'string', description: 'File path, absolute, relative to the working directory, or ~/ relative to the user home.' },
|
|
54
|
+
},
|
|
55
|
+
required: ['path'],
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
summarizeCall(input) {
|
|
59
|
+
return `read ${typeof input.path === 'string' ? input.path : '<missing path>'}`;
|
|
60
|
+
}
|
|
61
|
+
assessRisk(input, ctx) {
|
|
62
|
+
if (typeof input.path !== 'string' || !ctx.workspace)
|
|
63
|
+
return { escalate: false };
|
|
64
|
+
const target = (0, RunWorkspace_1.resolveToolPath)(input.path, ctx.workspace, ctx.cwd);
|
|
65
|
+
if ((0, RunWorkspace_1.isInsideAnyRoot)(target, ctx.workspace.readRoots))
|
|
66
|
+
return { escalate: false };
|
|
67
|
+
const nonPersistable = (0, RunWorkspace_1.isOutsideUserHome)(target, ctx.workspace) || (0, RunWorkspace_1.isSensitiveHostPath)(target, ctx.workspace);
|
|
68
|
+
return {
|
|
69
|
+
escalate: true,
|
|
70
|
+
persistable: !nonPersistable,
|
|
71
|
+
reason: nonPersistable
|
|
72
|
+
? `reading ${target} is outside this run's persistent filesystem scope`
|
|
73
|
+
: `reading ${target} is outside this run's working and trusted folders`,
|
|
74
|
+
targetPath: target,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async execute(input, ctx) {
|
|
78
|
+
const target = (0, RunWorkspace_1.resolveToolPath)((0, ToolRegistry_1.requireStringInput)(input, 'path', 'read_file'), ctx.workspace, ctx.cwd);
|
|
79
|
+
let content;
|
|
80
|
+
try {
|
|
81
|
+
const stat = fs.statSync(target);
|
|
82
|
+
if (stat.isDirectory()) {
|
|
83
|
+
const entries = fs.readdirSync(target).sort((a, b) => a.localeCompare(b));
|
|
84
|
+
return {
|
|
85
|
+
content: entries.join('\n'),
|
|
86
|
+
summary: `listed ${entries.length} entries in ${target}`,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
content = fs.readFileSync(target, 'utf-8');
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
return {
|
|
93
|
+
content: `Could not read ${target}: ${error instanceof Error ? error.message : String(error)}`,
|
|
94
|
+
summary: `failed to read ${target}`,
|
|
95
|
+
isError: true,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
content: (0, ToolRegistry_1.capToolOutput)(content, ctx.outputLimit),
|
|
100
|
+
summary: `read ${formatBytes(Buffer.byteLength(content, 'utf-8'))} from ${target}`,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.ReadFileTool = ReadFileTool;
|
|
105
|
+
function formatBytes(bytes) {
|
|
106
|
+
if (bytes < 1024)
|
|
107
|
+
return `${bytes}B`;
|
|
108
|
+
if (bytes < 1024 * 1024)
|
|
109
|
+
return `${(bytes / 1024).toFixed(1)}KB`;
|
|
110
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=ReadFileTool.js.map
|
|
@@ -0,0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KAAK,CAAC,EAAE;gBAC9F,OAAO,EAAE,kBAAkB,MAAM,EAAE;gBACnC,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,IAAA,4BAAa,EAAC,OAAO,EAAE,GAAG,CAAC,WAAW,CAAC;YAChD,OAAO,EAAE,QAAQ,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE;SACnF,CAAC;IACJ,CAAC;CACF;;AAED,qBAA4B,KAAa;IACvC,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,GAAG,CAAC;IACrC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACjE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { JSONValue } from '@priest-ai/core';
|
|
2
|
+
import { AgentTool, ToolExecutionContext, ToolExecutionResult, ToolRiskAssessment } from '../ToolRegistry';
|
|
3
|
+
export declare class ShellExecTool implements AgentTool {
|
|
4
|
+
readonly kind: 'shell';
|
|
5
|
+
readonly definition: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
parameters: {
|
|
9
|
+
type: string;
|
|
10
|
+
properties: {
|
|
11
|
+
command: {
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
required: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
summarizeCall(input: Record<string, JSONValue>): string;
|
|
20
|
+
assessRisk(_input: Record<string, JSONValue>, ctx: ToolExecutionContext): ToolRiskAssessment;
|
|
21
|
+
execute(input: Record<string, JSONValue>, ctx: ToolExecutionContext): Promise<ToolExecutionResult>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=ShellExecTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShellExecTool.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/ShellExecTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EACL,SAAS,EAET,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAEzB,qBAAa,aAAc,YAAW,SAAS;IAC7C,QAAQ,CAAC,IAAI,EAAG,OAAO,CAAU;IACjC,QAAQ,CAAC,UAAU;QACjB,IAAI;QACJ,WAAW;QAOX,UAAU;YACR,IAAI;YACJ,UAAU;gBACR,OAAO;oBAAI,IAAI;oBAAY,WAAW;;;YAExC,QAAQ;;MAEV;IAEF,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,CAEtD;IAED,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,oBAAoB,GAAG,kBAAkB,CAkB3F;IAEK,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAwBvG;CACF"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShellExecTool = void 0;
|
|
4
|
+
const ScopedProcess_1 = require("../ScopedProcess");
|
|
5
|
+
const ToolRegistry_1 = require("../ToolRegistry");
|
|
6
|
+
class ShellExecTool {
|
|
7
|
+
kind = 'shell';
|
|
8
|
+
definition = {
|
|
9
|
+
name: 'shell_exec',
|
|
10
|
+
description: [
|
|
11
|
+
'Run a shell command in the working directory and return stdout/stderr. Commands time out after 60 seconds.',
|
|
12
|
+
'When to use: run a focused test, build, formatter, program, or filesystem/process operation that dedicated tools cannot perform.',
|
|
13
|
+
'When NOT to use: read a known text file, write exact file content, access the network, install Python packages, or demonstrate unnecessary command execution.',
|
|
14
|
+
'The process sandbox can write only the working directory, configured trusted folders, and private run directories—even after the user approves execution.',
|
|
15
|
+
'For an explicit output file elsewhere, use write_file instead of shell redirection.',
|
|
16
|
+
].join(' '),
|
|
17
|
+
parameters: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
command: { type: 'string', description: 'The shell command to run. ~ and $HOME refer to the user home; filesystem sandbox limits still apply.' },
|
|
21
|
+
},
|
|
22
|
+
required: ['command'],
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
summarizeCall(input) {
|
|
26
|
+
return `run \`${typeof input.command === 'string' ? input.command : '<missing command>'}\``;
|
|
27
|
+
}
|
|
28
|
+
assessRisk(_input, ctx) {
|
|
29
|
+
if (!ctx.workspace) {
|
|
30
|
+
return {
|
|
31
|
+
blocked: true,
|
|
32
|
+
escalate: false,
|
|
33
|
+
persistable: false,
|
|
34
|
+
reason: 'shell execution has no isolated run workspace',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (ctx.workspace.externalRoots.length > 0) {
|
|
38
|
+
return {
|
|
39
|
+
escalate: true,
|
|
40
|
+
persistable: false,
|
|
41
|
+
reason: `this run can write an external root: ${ctx.workspace.externalRoots.join(', ')}`,
|
|
42
|
+
targetPath: ctx.workspace.externalRoots[0],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return { escalate: false };
|
|
46
|
+
}
|
|
47
|
+
async execute(input, ctx) {
|
|
48
|
+
const command = (0, ToolRegistry_1.requireStringInput)(input, 'command', 'shell_exec');
|
|
49
|
+
if (!ctx.workspace) {
|
|
50
|
+
return {
|
|
51
|
+
content: 'Marifold refused to run a shell command without an isolated run workspace.',
|
|
52
|
+
summary: `\`${command}\` blocked`,
|
|
53
|
+
isError: true,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (/\b(?:python(?:3(?:\.\d+)?)?|pip3?|uv)\b/.test(command)) {
|
|
57
|
+
const environmentError = await (0, ScopedProcess_1.ensurePythonEnvironment)(ctx.workspace, ctx.outputLimit, ctx.signal);
|
|
58
|
+
if (environmentError)
|
|
59
|
+
return environmentError;
|
|
60
|
+
}
|
|
61
|
+
return (0, ScopedProcess_1.runScopedProcess)({
|
|
62
|
+
executable: '/bin/sh',
|
|
63
|
+
args: ['-c', command],
|
|
64
|
+
workspace: ctx.workspace,
|
|
65
|
+
cwd: ctx.workspace.cwd,
|
|
66
|
+
network: false,
|
|
67
|
+
outputLimit: ctx.outputLimit,
|
|
68
|
+
signal: ctx.signal,
|
|
69
|
+
successSummary: `ran \`${command}\` in isolated workspace`,
|
|
70
|
+
failureSummary: `\`${command}\` failed in isolated workspace`,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.ShellExecTool = ShellExecTool;
|
|
75
|
+
//# sourceMappingURL=ShellExecTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShellExecTool.js","sourceRoot":"","sources":["../../../src/agent/tools/ShellExecTool.ts"],"names":[],"mappings":";;;AACA,oDAA6E;AAC7E,kDAMyB;AAEzB;IACW,IAAI,GAAG,OAAgB,CAAC;IACxB,UAAU,GAAG;QACpB,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE;YACX,4GAA4G;YAC5G,kIAAkI;YAClI,+JAA+J;YAC/J,2JAA2J;YAC3J,qFAAqF;SACtF,CAAC,IAAI,CAAC,GAAG,CAAC;QACX,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sGAAsG,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