@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,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-runtime2-example",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Standalone example app using agent-runtime2 with real LLM",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc --incremental --tsBuildInfoFile .tsbuildinfo",
|
|
9
|
+
"start": "node --import tsx index.ts",
|
|
10
|
+
"start:prod": "npm --prefix .. run build && npm run build && node dist/index.js",
|
|
11
|
+
"report:serve": "node serve-output.mjs",
|
|
12
|
+
"dev": "tsx index.ts",
|
|
13
|
+
"test": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@botbotgo/runtime": "file:..",
|
|
17
|
+
"@langchain/core": "^1.1.31",
|
|
18
|
+
"@langchain/openai": "^1.2.12",
|
|
19
|
+
"deepagents": "^1.8.1"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^22.10.1",
|
|
23
|
+
"tsx": "^4.19.2",
|
|
24
|
+
"typescript": "^5.7.2"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createServer } from "node:http";
|
|
3
|
+
import { readFileSync, statSync } from "node:fs";
|
|
4
|
+
import { extname, join, normalize, resolve } from "node:path";
|
|
5
|
+
|
|
6
|
+
const rootDir = resolve(process.cwd(), "output");
|
|
7
|
+
const port = Number(process.env.REPORT_PORT || 8787);
|
|
8
|
+
const host = process.env.REPORT_HOST || "127.0.0.1";
|
|
9
|
+
|
|
10
|
+
const contentTypes = new Map([
|
|
11
|
+
[".html", "text/html; charset=utf-8"],
|
|
12
|
+
[".json", "application/json; charset=utf-8"],
|
|
13
|
+
[".css", "text/css; charset=utf-8"],
|
|
14
|
+
[".js", "application/javascript; charset=utf-8"],
|
|
15
|
+
[".txt", "text/plain; charset=utf-8"],
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
function safePath(urlPath) {
|
|
19
|
+
const decoded = decodeURIComponent(urlPath.split("?")[0] || "/");
|
|
20
|
+
const normalized = normalize(decoded).replace(/^(\.\.(\/|\\|$))+/, "");
|
|
21
|
+
const rel = normalized === "/" ? "company-report.html" : normalized.replace(/^[/\\]/, "");
|
|
22
|
+
const abs = resolve(rootDir, rel);
|
|
23
|
+
if (!abs.startsWith(rootDir)) {
|
|
24
|
+
throw new Error("Path traversal blocked");
|
|
25
|
+
}
|
|
26
|
+
return abs;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const server = createServer((req, res) => {
|
|
30
|
+
try {
|
|
31
|
+
const abs = safePath(req.url || "/");
|
|
32
|
+
const st = statSync(abs);
|
|
33
|
+
if (!st.isFile()) {
|
|
34
|
+
res.statusCode = 404;
|
|
35
|
+
res.end("Not Found");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const body = readFileSync(abs);
|
|
39
|
+
const type = contentTypes.get(extname(abs)) || "application/octet-stream";
|
|
40
|
+
res.setHeader("Content-Type", type);
|
|
41
|
+
res.statusCode = 200;
|
|
42
|
+
res.end(body);
|
|
43
|
+
} catch {
|
|
44
|
+
res.statusCode = 404;
|
|
45
|
+
res.end("Not Found");
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
server.listen(port, host, () => {
|
|
50
|
+
const url = `http://${host}:${port}/company-report.html`;
|
|
51
|
+
process.stdout.write(`Report server running at ${url}\n`);
|
|
52
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"baseUrl": ".",
|
|
7
|
+
"paths": {
|
|
8
|
+
"#agent-runtime2": ["../dist/index.d.ts"],
|
|
9
|
+
"@botbotgo/runtime": ["../dist/index.d.ts"]
|
|
10
|
+
},
|
|
11
|
+
"outDir": "dist",
|
|
12
|
+
"rootDir": ".",
|
|
13
|
+
"strict": true,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"skipLibCheck": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["index.ts"],
|
|
18
|
+
"exclude": ["node_modules", "dist"]
|
|
19
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@botbotgo/runtime",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Runtime service and YAML config loader for deepagents-based agent apps",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"preinstall": "node scripts/resolve-deps.js",
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"test": "npm run build && npm run typecheck && node --import tsx --test --test-force-exit test/unit/config/loader.test.ts test/unit/runtime/*.test.ts test/integration/*.test.ts",
|
|
19
|
+
"test:integration": "npm run build && npm run typecheck && node --import tsx --test --test-force-exit test/integration/*.test.ts",
|
|
20
|
+
"test:watch": "npm run build && npm run typecheck && node --import tsx --test --watch test/unit/config/loader.test.ts test/unit/runtime/*.test.ts test/integration/*.test.ts",
|
|
21
|
+
"release": "semantic-release"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"agent",
|
|
25
|
+
"skills",
|
|
26
|
+
"deepagents",
|
|
27
|
+
"langchain",
|
|
28
|
+
"yaml",
|
|
29
|
+
"config"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@botbotgo/common": "latest",
|
|
34
|
+
"@botbotgo/memory": "latest",
|
|
35
|
+
"@botbotgo/model": "latest",
|
|
36
|
+
"@botbotgo/kit": "latest"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@semantic-release/commit-analyzer": "^13.0.0",
|
|
40
|
+
"@semantic-release/git": "^10.0.1",
|
|
41
|
+
"@semantic-release/npm": "^12.0.0",
|
|
42
|
+
"@semantic-release/release-notes-generator": "^14.0.0",
|
|
43
|
+
"@langchain/core": "^1.1.31",
|
|
44
|
+
"@types/node": "^22.10.1",
|
|
45
|
+
"semantic-release": "^24.2.0",
|
|
46
|
+
"tsx": "^4.19.2",
|
|
47
|
+
"typescript": "^5.7.2"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@langchain/core": "^1.1.31",
|
|
51
|
+
"deepagents": "^1.8.1"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@langchain/core": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"deepagents": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"repository": {
|
|
62
|
+
"type": "git",
|
|
63
|
+
"url": "https://github.com/botbotgo/runtime.git"
|
|
64
|
+
},
|
|
65
|
+
"homepage": "https://github.com/botbotgo/runtime#readme",
|
|
66
|
+
"bugs": {
|
|
67
|
+
"url": "https://github.com/botbotgo/runtime/issues"
|
|
68
|
+
},
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"access": "public",
|
|
71
|
+
"registry": "https://registry.npmjs.org/"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
+
|
|
7
|
+
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const helperPath = resolve(scriptDir, "../../../scripts/internal-package-refs.mjs");
|
|
9
|
+
const packageJsonPath = resolve(scriptDir, "../package.json");
|
|
10
|
+
|
|
11
|
+
function fallbackRewriteCurrentPackage() {
|
|
12
|
+
const pkg = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
13
|
+
let changed = false;
|
|
14
|
+
const packageDir = resolve(scriptDir, "..");
|
|
15
|
+
|
|
16
|
+
for (const section of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
17
|
+
const deps = pkg[section];
|
|
18
|
+
if (!deps || typeof deps !== "object") continue;
|
|
19
|
+
for (const [name, version] of Object.entries(deps)) {
|
|
20
|
+
if (!name.startsWith("@botbotgo/")) continue;
|
|
21
|
+
if (typeof version !== "string" || !version.startsWith("file:")) continue;
|
|
22
|
+
if (existsSync(resolve(packageDir, version.slice("file:".length)))) continue;
|
|
23
|
+
deps[name] = "latest";
|
|
24
|
+
changed = true;
|
|
25
|
+
console.log(`[resolve-deps:fallback] ${section}.${name}: ${version} -> ${deps[name]}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (changed) {
|
|
30
|
+
writeFileSync(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!existsSync(helperPath)) {
|
|
35
|
+
fallbackRewriteCurrentPackage();
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { syncCurrentPackageFromScript } = await import(pathToFileURL(helperPath).href);
|
|
40
|
+
syncCurrentPackageFromScript(import.meta.url, "auto");
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export {
|
|
2
|
+
loadFromFile,
|
|
3
|
+
loadFromDirectory,
|
|
4
|
+
loadFromString,
|
|
5
|
+
parseResource,
|
|
6
|
+
parseAllResources,
|
|
7
|
+
ConfigError,
|
|
8
|
+
} from "./loader.js";
|
|
9
|
+
export type { LoadOptions } from "./loader.js";
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
resolveAgentConfig,
|
|
13
|
+
buildDeepAgentOptions,
|
|
14
|
+
} from "./resolveRuntimeConfig.js";
|
|
15
|
+
export type {
|
|
16
|
+
ResolvedAgentConfig,
|
|
17
|
+
ResolvedMemoryConfig,
|
|
18
|
+
ResolvedAgentRuntimeConfig,
|
|
19
|
+
MemoryStoreResolved,
|
|
20
|
+
} from "./resolveRuntimeConfig.js";
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
loadAgentRuntimeConfig,
|
|
24
|
+
AgentRuntimeConfigService,
|
|
25
|
+
} from "./runtimeConfigLoader.js";
|
|
26
|
+
export type {
|
|
27
|
+
LoadAgentRuntimeConfigOptions,
|
|
28
|
+
AgentRuntimeConfigResult,
|
|
29
|
+
} from "./runtimeConfigLoader.js";
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load K8s-style YAML config from file, directory, or string.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
loadYamlFile,
|
|
7
|
+
parseYamlContent,
|
|
8
|
+
} from "@botbotgo/common/config";
|
|
9
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
10
|
+
import { join, extname } from "node:path";
|
|
11
|
+
import type { Resource } from "./resources.js";
|
|
12
|
+
|
|
13
|
+
const YAML_EXTS = [".yaml", ".yml"];
|
|
14
|
+
const SUPPORTED_API = "botbotgo.world/v1";
|
|
15
|
+
const SUPPORTED_KINDS = ["MemoryConfig", "SkillsConfig", "AgentRuntimeConfig"] as const;
|
|
16
|
+
|
|
17
|
+
export interface LoadOptions {
|
|
18
|
+
/** If true, skip invalid documents and continue; default false */
|
|
19
|
+
ignoreInvalid?: boolean;
|
|
20
|
+
/** Optional base directory for resolving relative paths in config (e.g. skill paths) */
|
|
21
|
+
baseDir?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class ConfigError extends Error {
|
|
25
|
+
constructor(
|
|
26
|
+
message: string,
|
|
27
|
+
public readonly path?: string,
|
|
28
|
+
public readonly cause?: unknown
|
|
29
|
+
) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.name = "ConfigError";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function splitYamlDocuments(yamlContent: string): string[] {
|
|
36
|
+
return yamlContent
|
|
37
|
+
.split(/^---(?:\s+#.*)?\s*$/m)
|
|
38
|
+
.map((part) => part.trim())
|
|
39
|
+
.filter((part) => part.length > 0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function isRecord(v: unknown): v is Record<string, unknown> {
|
|
43
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function hasRequiredFields(doc: unknown): doc is Resource<string, unknown> {
|
|
47
|
+
if (!isRecord(doc)) return false;
|
|
48
|
+
if (typeof doc.apiVersion !== "string" || typeof doc.kind !== "string")
|
|
49
|
+
return false;
|
|
50
|
+
if (!isRecord(doc.metadata) || typeof doc.metadata.name !== "string")
|
|
51
|
+
return false;
|
|
52
|
+
if (!(typeof doc.spec === "object" && doc.spec !== null)) return false;
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function validateResource(doc: unknown): Resource<string, unknown> {
|
|
57
|
+
if (doc === undefined || doc === null)
|
|
58
|
+
throw new ConfigError("YAML document is empty");
|
|
59
|
+
if (!hasRequiredFields(doc))
|
|
60
|
+
throw new ConfigError(
|
|
61
|
+
"Invalid resource: missing or invalid apiVersion, kind, metadata.name, or spec"
|
|
62
|
+
);
|
|
63
|
+
if (doc.apiVersion !== SUPPORTED_API)
|
|
64
|
+
throw new ConfigError(
|
|
65
|
+
`Unsupported apiVersion: ${doc.apiVersion}. Expected ${SUPPORTED_API}`
|
|
66
|
+
);
|
|
67
|
+
if (!SUPPORTED_KINDS.includes(doc.kind as (typeof SUPPORTED_KINDS)[number]))
|
|
68
|
+
throw new ConfigError(
|
|
69
|
+
`Unsupported kind: ${doc.kind}. Supported: ${SUPPORTED_KINDS.join(", ")}`
|
|
70
|
+
);
|
|
71
|
+
return doc as Resource<string, unknown>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Parse a single YAML document into a typed Resource.
|
|
76
|
+
* Does not validate spec shape per kind; use validators if needed.
|
|
77
|
+
*/
|
|
78
|
+
export function parseResource(yamlContent: string): Resource<string, unknown> {
|
|
79
|
+
return validateResource(parseYamlContent(yamlContent));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Parse YAML that may contain multiple documents (--- separated).
|
|
84
|
+
* Returns the first valid resource; throws if none valid.
|
|
85
|
+
*/
|
|
86
|
+
export function parseAllResources(
|
|
87
|
+
yamlContent: string,
|
|
88
|
+
options: LoadOptions = {}
|
|
89
|
+
): Resource<string, unknown>[] {
|
|
90
|
+
const out: Resource<string, unknown>[] = [];
|
|
91
|
+
const docs = splitYamlDocuments(yamlContent);
|
|
92
|
+
|
|
93
|
+
for (let i = 0; i < docs.length; i++) {
|
|
94
|
+
try {
|
|
95
|
+
out.push(validateResource(parseYamlContent(docs[i])));
|
|
96
|
+
} catch (e) {
|
|
97
|
+
if (!options.ignoreInvalid) throw e;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Load a single resource from a file path.
|
|
105
|
+
*/
|
|
106
|
+
export async function loadFromFile(
|
|
107
|
+
filePath: string,
|
|
108
|
+
options: LoadOptions = {}
|
|
109
|
+
): Promise<Resource<string, unknown>> {
|
|
110
|
+
try {
|
|
111
|
+
const doc = await loadYamlFile(filePath);
|
|
112
|
+
if (doc === undefined) {
|
|
113
|
+
throw new ConfigError(`Failed to read file: ${filePath}`, filePath);
|
|
114
|
+
}
|
|
115
|
+
return validateResource(doc);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
if (e instanceof ConfigError) {
|
|
118
|
+
throw new ConfigError(e.message, filePath, e.cause);
|
|
119
|
+
}
|
|
120
|
+
if ((e as { code?: string } | undefined)?.code === "ENOENT") {
|
|
121
|
+
throw new ConfigError(`Failed to read file: ${filePath}`, filePath, e);
|
|
122
|
+
}
|
|
123
|
+
throw new ConfigError(String(e), filePath, e);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Load all K8s-style resources from a directory.
|
|
129
|
+
* Scans for .yaml/.yml files (non-recursive by default).
|
|
130
|
+
*/
|
|
131
|
+
export async function loadFromDirectory(
|
|
132
|
+
dirPath: string,
|
|
133
|
+
options: LoadOptions & { recursive?: boolean } = {}
|
|
134
|
+
): Promise<Resource<string, unknown>[]> {
|
|
135
|
+
const { recursive = false, ...loadOpts } = options;
|
|
136
|
+
const entries = await readdir(dirPath, { withFileTypes: true }).catch((e) => {
|
|
137
|
+
throw new ConfigError(`Failed to read directory: ${dirPath}`, dirPath, e);
|
|
138
|
+
});
|
|
139
|
+
const results: Resource<string, unknown>[] = [];
|
|
140
|
+
for (const ent of entries) {
|
|
141
|
+
const full = join(dirPath, ent.name);
|
|
142
|
+
if (ent.isDirectory() && recursive) {
|
|
143
|
+
const sub = await loadFromDirectory(full, options);
|
|
144
|
+
results.push(...sub);
|
|
145
|
+
}
|
|
146
|
+
if (!ent.isFile() || !YAML_EXTS.includes(extname(ent.name))) continue;
|
|
147
|
+
try {
|
|
148
|
+
const content = await readFile(full, "utf-8");
|
|
149
|
+
const resources = parseAllResources(content, loadOpts);
|
|
150
|
+
results.push(...resources);
|
|
151
|
+
} catch (e) {
|
|
152
|
+
if (!loadOpts.ignoreInvalid)
|
|
153
|
+
throw new ConfigError(String(e), full, e);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return results;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Parse a single resource from a YAML string.
|
|
161
|
+
*/
|
|
162
|
+
export function loadFromString(
|
|
163
|
+
content: string,
|
|
164
|
+
options: LoadOptions = {}
|
|
165
|
+
): Resource<string, unknown> {
|
|
166
|
+
const multi = content.includes("---");
|
|
167
|
+
if (multi) {
|
|
168
|
+
const list = parseAllResources(content, options);
|
|
169
|
+
if (list.length === 0)
|
|
170
|
+
throw new ConfigError("No valid resource found in multi-document YAML");
|
|
171
|
+
return list[0];
|
|
172
|
+
}
|
|
173
|
+
return parseResource(content);
|
|
174
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map loaded K8s-style configs to options suitable for deepagents (createDeepAgent).
|
|
3
|
+
* Supports MemoryConfig, SkillsConfig, and AgentRuntimeConfig; memory shape is exposed for app use
|
|
4
|
+
* until deepagents exposes a matching memory API.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
AgentBackendConfigSpec,
|
|
9
|
+
AgentRuntimeConfigResource,
|
|
10
|
+
KnownResource,
|
|
11
|
+
MemoryConfigResource,
|
|
12
|
+
} from "./resources.js";
|
|
13
|
+
import { isAgentRuntimeConfig, isMemoryConfig } from "./resources.js";
|
|
14
|
+
|
|
15
|
+
export interface ResolvedAgentConfig {
|
|
16
|
+
/** Skill source paths to pass to createDeepAgent({ skills }) */
|
|
17
|
+
skills: string[];
|
|
18
|
+
/** Resolved memory config (thread/cross_thread/knowledge). Use for your own store/checkpointer or when deepagents supports it. */
|
|
19
|
+
memory: ResolvedMemoryConfig | null;
|
|
20
|
+
/** Observability and privacy from MemoryConfig, if present */
|
|
21
|
+
observability: { trace: boolean };
|
|
22
|
+
privacy: { forbiddenMetadataKeys: string[] };
|
|
23
|
+
/** Runtime defaults from AgentRuntimeConfig, if present */
|
|
24
|
+
runtime: ResolvedAgentRuntimeConfig;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ResolvedMemoryConfig {
|
|
28
|
+
thread: MemoryStoreResolved;
|
|
29
|
+
cross_thread: MemoryStoreResolved;
|
|
30
|
+
knowledge: MemoryStoreResolved;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface MemoryStoreResolved {
|
|
34
|
+
store: { type: string; options?: Record<string, unknown> };
|
|
35
|
+
allowWrite: boolean;
|
|
36
|
+
maxItems: number;
|
|
37
|
+
sessionCompaction?: {
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
maxTokens: number;
|
|
40
|
+
keepRecentTurns: number;
|
|
41
|
+
summaryKey: string;
|
|
42
|
+
checkEveryTurns: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ResolvedAgentRuntimeConfig {
|
|
47
|
+
artifacts?: Array<{
|
|
48
|
+
key: string;
|
|
49
|
+
path: string;
|
|
50
|
+
}>;
|
|
51
|
+
stateDirName?: string;
|
|
52
|
+
legacyOutputState?: boolean;
|
|
53
|
+
executeTimeoutMs?: number;
|
|
54
|
+
blockTaskTool?: boolean;
|
|
55
|
+
systemPrompt?: string;
|
|
56
|
+
llmIdleTimeoutMs?: number;
|
|
57
|
+
backend?: AgentBackendConfigSpec;
|
|
58
|
+
incompleteRunMaxRetries?: number;
|
|
59
|
+
emptyRunMaxRetries?: number;
|
|
60
|
+
malformedToolCallMaxRetries?: number;
|
|
61
|
+
idleTimeoutMaxRetries?: number;
|
|
62
|
+
heartbeatIntervalMs?: number;
|
|
63
|
+
debug?: {
|
|
64
|
+
run?: boolean;
|
|
65
|
+
workspace?: boolean;
|
|
66
|
+
toolCall?: boolean;
|
|
67
|
+
stream?: boolean;
|
|
68
|
+
close?: boolean;
|
|
69
|
+
};
|
|
70
|
+
eventLogLevel?: "silent" | "lifecycle" | "tools" | "verbose";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const DEFAULT_OBSERVABILITY = { trace: false };
|
|
74
|
+
const DEFAULT_PRIVACY = { forbiddenMetadataKeys: [] as string[] };
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Reduce an array of loaded resources into a single ResolvedAgentConfig.
|
|
78
|
+
* - SkillsConfig: parsed for compatibility, but skill roots are resolved outside this module.
|
|
79
|
+
* - MemoryConfig: first one wins (by name order or array order); optional merge strategy could be added.
|
|
80
|
+
*/
|
|
81
|
+
export function resolveAgentConfig(resources: KnownResource[]): ResolvedAgentConfig {
|
|
82
|
+
let skills: string[] = [];
|
|
83
|
+
let memory: ResolvedMemoryConfig | null = null;
|
|
84
|
+
let observability = DEFAULT_OBSERVABILITY;
|
|
85
|
+
let privacy = DEFAULT_PRIVACY;
|
|
86
|
+
let runtime: ResolvedAgentRuntimeConfig = {};
|
|
87
|
+
|
|
88
|
+
for (const r of resources) {
|
|
89
|
+
if (isMemoryConfig(r)) {
|
|
90
|
+
if (!memory) {
|
|
91
|
+
memory = {
|
|
92
|
+
thread: resolveStore(r.spec.memory.thread),
|
|
93
|
+
cross_thread: resolveStore(r.spec.memory.cross_thread),
|
|
94
|
+
knowledge: resolveStore(r.spec.memory.knowledge),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (r.spec.observability) {
|
|
98
|
+
observability = { trace: r.spec.observability.trace ?? false };
|
|
99
|
+
}
|
|
100
|
+
if (r.spec.privacy?.forbiddenMetadataKeys) {
|
|
101
|
+
privacy = { forbiddenMetadataKeys: [...r.spec.privacy.forbiddenMetadataKeys] };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (isAgentRuntimeConfig(r)) {
|
|
105
|
+
runtime = resolveRuntime(r.spec);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
skills,
|
|
111
|
+
memory,
|
|
112
|
+
observability,
|
|
113
|
+
privacy,
|
|
114
|
+
runtime,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function resolveStore(s: MemoryConfigResource["spec"]["memory"]["thread"]): MemoryStoreResolved {
|
|
119
|
+
return {
|
|
120
|
+
store: { type: s.store.type, options: s.store.options },
|
|
121
|
+
allowWrite: s.allowWrite,
|
|
122
|
+
maxItems: s.maxItems,
|
|
123
|
+
sessionCompaction: s.sessionCompaction,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function resolveRuntime(s: AgentRuntimeConfigResource["spec"]): ResolvedAgentRuntimeConfig {
|
|
128
|
+
return {
|
|
129
|
+
artifacts: s.artifacts,
|
|
130
|
+
stateDirName: s.stateDirName,
|
|
131
|
+
legacyOutputState: s.legacyOutputState,
|
|
132
|
+
executeTimeoutMs: s.executeTimeoutMs,
|
|
133
|
+
blockTaskTool: s.blockTaskTool,
|
|
134
|
+
systemPrompt: s.systemPrompt,
|
|
135
|
+
llmIdleTimeoutMs: s.llmIdleTimeoutMs,
|
|
136
|
+
backend: s.backend,
|
|
137
|
+
incompleteRunMaxRetries: s.incompleteRunMaxRetries,
|
|
138
|
+
emptyRunMaxRetries: s.emptyRunMaxRetries,
|
|
139
|
+
malformedToolCallMaxRetries: s.malformedToolCallMaxRetries,
|
|
140
|
+
idleTimeoutMaxRetries: s.idleTimeoutMaxRetries,
|
|
141
|
+
heartbeatIntervalMs: s.heartbeatIntervalMs,
|
|
142
|
+
debug: s.debug,
|
|
143
|
+
eventLogLevel: s.eventLogLevel,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Build options object for createDeepAgent from resolved config.
|
|
149
|
+
* Pass skills; use resolvedAgentConfig.memory / observability / privacy in your app as needed.
|
|
150
|
+
*/
|
|
151
|
+
export function buildDeepAgentOptions(resolved: ResolvedAgentConfig): {
|
|
152
|
+
skills: string[];
|
|
153
|
+
/** Optional: attach to run/config for observability and privacy (app-specific) */
|
|
154
|
+
_resolved: ResolvedAgentConfig;
|
|
155
|
+
} {
|
|
156
|
+
return {
|
|
157
|
+
skills: resolved.skills.length > 0 ? resolved.skills : [],
|
|
158
|
+
_resolved: resolved,
|
|
159
|
+
};
|
|
160
|
+
}
|