@botbotgo/agent-harness 0.0.298 → 0.0.300

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.
Files changed (166) hide show
  1. package/README.md +78 -38
  2. package/README.zh.md +80 -31
  3. package/dist/acp.d.ts +3 -0
  4. package/dist/acp.js +10 -2
  5. package/dist/api.d.ts +14 -2
  6. package/dist/api.js +19 -3
  7. package/dist/cli.d.ts +18 -1
  8. package/dist/cli.js +1408 -319
  9. package/dist/client/acp.d.ts +9 -3
  10. package/dist/client/acp.js +55 -1
  11. package/dist/client/in-process.d.ts +5 -2
  12. package/dist/client/in-process.js +4 -6
  13. package/dist/client/index.d.ts +1 -1
  14. package/dist/client/types.d.ts +6 -5
  15. package/dist/config/agents/direct.yaml +7 -17
  16. package/dist/config/agents/orchestra.yaml +9 -65
  17. package/dist/config/catalogs/embedding-models.yaml +1 -1
  18. package/dist/config/catalogs/stores.yaml +1 -1
  19. package/dist/config/knowledge/knowledge-runtime.yaml +36 -2
  20. package/dist/config/knowledge/procedural-memory-runtime.yaml +78 -0
  21. package/dist/config/{catalogs/models.yaml → models.yaml} +2 -2
  22. package/dist/config/prompts/direct-system.md +16 -0
  23. package/dist/config/prompts/orchestra-system.md +62 -0
  24. package/dist/config/prompts/routing-system.md +14 -0
  25. package/dist/config/runtime/runtime-memory.yaml +39 -5
  26. package/dist/config/runtime/workspace.yaml +7 -16
  27. package/dist/contracts/runtime.d.ts +242 -1
  28. package/dist/contracts/workspace.d.ts +2 -0
  29. package/dist/index.d.ts +5 -3
  30. package/dist/index.js +2 -1
  31. package/dist/init-project.js +178 -33
  32. package/dist/knowledge/contracts.d.ts +5 -0
  33. package/dist/knowledge/module.d.ts +5 -0
  34. package/dist/knowledge/module.js +340 -18
  35. package/dist/package-version.d.ts +1 -1
  36. package/dist/package-version.js +1 -1
  37. package/dist/persistence/file-store.d.ts +5 -1
  38. package/dist/persistence/file-store.js +16 -0
  39. package/dist/persistence/sqlite-store.d.ts +4 -1
  40. package/dist/persistence/sqlite-store.js +88 -14
  41. package/dist/persistence/types.d.ts +4 -1
  42. package/dist/procedural/config.d.ts +63 -0
  43. package/dist/procedural/config.js +125 -0
  44. package/dist/procedural/index.d.ts +2 -0
  45. package/dist/procedural/index.js +1 -0
  46. package/dist/protocol/ag-ui/http.d.ts +3 -0
  47. package/dist/protocol/ag-ui/http.js +10 -0
  48. package/dist/request-events.d.ts +63 -0
  49. package/dist/request-events.js +400 -0
  50. package/dist/resource/isolation.js +11 -0
  51. package/dist/resource/resource-impl.d.ts +1 -0
  52. package/dist/resource/resource-impl.js +103 -12
  53. package/dist/resources/init-templates/agent-context/deep-research.md +5 -0
  54. package/dist/resources/init-templates/prompts/research-analyst-basic.md +1 -0
  55. package/dist/resources/init-templates/prompts/research-analyst-web-search.md +1 -0
  56. package/dist/resources/init-templates/prompts/research-host-deep-research-basic.md +1 -0
  57. package/dist/resources/init-templates/prompts/research-host-deep-research-web-search.md +1 -0
  58. package/dist/resources/init-templates/prompts/research-host-single-agent-basic.md +1 -0
  59. package/dist/resources/init-templates/prompts/research-host-single-agent-web-search.md +1 -0
  60. package/dist/resources/prompts/runtime/browser-capability-disclaimer-recovery.md +1 -0
  61. package/dist/resources/prompts/runtime/default-subagent.md +2 -0
  62. package/dist/resources/prompts/runtime/durable-memory-context.md +7 -0
  63. package/dist/resources/prompts/runtime/execution-with-tool-evidence-retry.md +1 -0
  64. package/dist/resources/prompts/runtime/execution-with-tool-evidence.md +1 -0
  65. package/dist/resources/prompts/runtime/invalid-tool-selection-recovery.md +1 -0
  66. package/dist/resources/prompts/runtime/memory-manager.md +31 -0
  67. package/dist/resources/prompts/runtime/memory-mutation-reconciliation.md +22 -0
  68. package/dist/resources/prompts/runtime/slash-command-skill.md +6 -0
  69. package/dist/resources/prompts/runtime/strict-tool-json.md +1 -0
  70. package/dist/resources/prompts/runtime/workspace-boundary-guidance.md +3 -0
  71. package/dist/resources/prompts/runtime/workspace-relative-path.md +1 -0
  72. package/dist/resources/prompts/runtime/write-todos-descriptive-content.md +1 -0
  73. package/dist/resources/prompts/runtime/write-todos-full-entry.md +1 -0
  74. package/dist/resources/prompts/runtime/write-todos-non-empty-initial-list.md +1 -0
  75. package/dist/resources/tools/_runtime_tool_helpers.mjs +152 -0
  76. package/dist/resources/tools/cancel_request.mjs +21 -0
  77. package/dist/resources/tools/fetch_url.mjs +23 -0
  78. package/dist/resources/tools/http_request.mjs +30 -0
  79. package/dist/resources/tools/inspect_approvals.mjs +27 -0
  80. package/dist/resources/tools/inspect_artifacts.mjs +21 -0
  81. package/dist/resources/tools/inspect_events.mjs +21 -0
  82. package/dist/resources/tools/inspect_requests.mjs +27 -0
  83. package/dist/resources/tools/inspect_sessions.mjs +21 -0
  84. package/dist/resources/tools/list_files.mjs +27 -0
  85. package/dist/resources/tools/read_artifact.mjs +22 -0
  86. package/dist/resources/tools/request_approval.mjs +27 -0
  87. package/dist/resources/tools/run_command.mjs +21 -0
  88. package/dist/resources/tools/schedule_task.mjs +76 -0
  89. package/dist/resources/tools/search_files.mjs +47 -0
  90. package/dist/resources/tools/send_message.mjs +23 -0
  91. package/dist/runtime/adapter/direct-builtin-utility.d.ts +1 -0
  92. package/dist/runtime/adapter/direct-builtin-utility.js +90 -0
  93. package/dist/runtime/adapter/flow/execution-context.d.ts +1 -1
  94. package/dist/runtime/adapter/flow/execution-context.js +1 -1
  95. package/dist/runtime/adapter/flow/invocation-flow.d.ts +1 -0
  96. package/dist/runtime/adapter/flow/invocation-flow.js +9 -1
  97. package/dist/runtime/adapter/flow/invoke-runtime.d.ts +1 -1
  98. package/dist/runtime/adapter/flow/stream-runtime.d.ts +5 -1
  99. package/dist/runtime/adapter/flow/stream-runtime.js +556 -35
  100. package/dist/runtime/adapter/invocation-result.js +3 -2
  101. package/dist/runtime/adapter/local-tool-invocation.d.ts +1 -1
  102. package/dist/runtime/adapter/local-tool-invocation.js +28 -4
  103. package/dist/runtime/adapter/middleware-assembly.js +3 -1
  104. package/dist/runtime/adapter/model/invocation-request.d.ts +4 -1
  105. package/dist/runtime/adapter/model/invocation-request.js +138 -16
  106. package/dist/runtime/adapter/model/message-assembly.js +2 -6
  107. package/dist/runtime/adapter/model/model-providers.js +103 -5
  108. package/dist/runtime/adapter/resilience.js +17 -2
  109. package/dist/runtime/adapter/runtime-adapter-support.d.ts +11 -7
  110. package/dist/runtime/adapter/runtime-adapter-support.js +39 -5
  111. package/dist/runtime/adapter/tool/builtin-middleware-tools.d.ts +63 -1
  112. package/dist/runtime/adapter/tool/builtin-middleware-tools.js +193 -21
  113. package/dist/runtime/adapter/tool/tool-arguments.d.ts +3 -1
  114. package/dist/runtime/adapter/tool/tool-arguments.js +52 -17
  115. package/dist/runtime/adapter/tool-resolution.d.ts +1 -0
  116. package/dist/runtime/adapter/tool-resolution.js +4 -2
  117. package/dist/runtime/agent-runtime-adapter.d.ts +27 -0
  118. package/dist/runtime/agent-runtime-adapter.js +163 -11
  119. package/dist/runtime/harness/events/event-bus.d.ts +1 -0
  120. package/dist/runtime/harness/events/event-bus.js +3 -0
  121. package/dist/runtime/harness/events/event-sink.d.ts +3 -0
  122. package/dist/runtime/harness/events/event-sink.js +16 -7
  123. package/dist/runtime/harness/events/streaming.d.ts +18 -1
  124. package/dist/runtime/harness/events/streaming.js +23 -10
  125. package/dist/runtime/harness/run/inspection.js +26 -5
  126. package/dist/runtime/harness/run/stream-run.d.ts +13 -4
  127. package/dist/runtime/harness/run/stream-run.js +448 -4
  128. package/dist/runtime/harness/run/surface-semantics.js +7 -34
  129. package/dist/runtime/harness/system/runtime-memory-manager.d.ts +3 -0
  130. package/dist/runtime/harness/system/runtime-memory-manager.js +384 -69
  131. package/dist/runtime/harness/system/runtime-memory-policy.d.ts +20 -1
  132. package/dist/runtime/harness/system/runtime-memory-policy.js +65 -17
  133. package/dist/runtime/harness/system/runtime-memory-records.js +100 -0
  134. package/dist/runtime/harness/system/runtime-memory-sync.js +2 -2
  135. package/dist/runtime/harness/system/store.d.ts +4 -0
  136. package/dist/runtime/harness/system/store.js +153 -0
  137. package/dist/runtime/harness.d.ts +9 -1
  138. package/dist/runtime/harness.js +141 -7
  139. package/dist/runtime/maintenance/sqlite-checkpoint-saver.d.ts +8 -3
  140. package/dist/runtime/maintenance/sqlite-checkpoint-saver.js +152 -53
  141. package/dist/runtime/parsing/output-parsing.d.ts +10 -2
  142. package/dist/runtime/parsing/output-parsing.js +223 -16
  143. package/dist/runtime/parsing/stream-event-parsing.d.ts +7 -0
  144. package/dist/runtime/parsing/stream-event-parsing.js +51 -1
  145. package/dist/runtime/scheduling/system-schedule-manager.d.ts +41 -0
  146. package/dist/runtime/scheduling/system-schedule-manager.js +532 -0
  147. package/dist/runtime/support/embedding-models.d.ts +1 -1
  148. package/dist/runtime/support/embedding-models.js +5 -2
  149. package/dist/runtime/support/runtime-factories.js +1 -1
  150. package/dist/runtime/support/runtime-layout.d.ts +3 -0
  151. package/dist/runtime/support/runtime-layout.js +10 -1
  152. package/dist/runtime/support/runtime-prompts.d.ts +30 -0
  153. package/dist/runtime/support/runtime-prompts.js +55 -0
  154. package/dist/runtime/support/vector-stores.d.ts +1 -1
  155. package/dist/runtime/support/vector-stores.js +5 -2
  156. package/dist/upstream-events.js +8 -7
  157. package/dist/utils/bundled-text.d.ts +3 -0
  158. package/dist/utils/bundled-text.js +25 -0
  159. package/dist/utils/id.js +3 -2
  160. package/dist/workspace/agent-binding-compiler.js +53 -13
  161. package/dist/workspace/object-loader.js +64 -2
  162. package/dist/workspace/support/workspace-ref-utils.d.ts +2 -1
  163. package/dist/workspace/support/workspace-ref-utils.js +24 -5
  164. package/dist/workspace/yaml-object-reader.d.ts +1 -0
  165. package/dist/workspace/yaml-object-reader.js +95 -17
  166. package/package.json +11 -5
@@ -0,0 +1,55 @@
1
+ import { readBundledText, renderBundledTemplate, renderTemplateText } from "../../utils/bundled-text.js";
2
+ function readRuntimePrompt(name) {
3
+ return readBundledText(`prompts/runtime/${name}.md`).trim();
4
+ }
5
+ export const WORKSPACE_BOUNDARY_GUIDANCE = readRuntimePrompt("workspace-boundary-guidance");
6
+ export const DEFAULT_SUBAGENT_PROMPT = readRuntimePrompt("default-subagent");
7
+ export const STRICT_TOOL_JSON_INSTRUCTION = readRuntimePrompt("strict-tool-json");
8
+ export const BROWSER_CAPABILITY_DISCLAIMER_RECOVERY_INSTRUCTION = readRuntimePrompt("browser-capability-disclaimer-recovery");
9
+ export const INVALID_TOOL_SELECTION_RECOVERY_INSTRUCTION = readRuntimePrompt("invalid-tool-selection-recovery");
10
+ export const WRITE_TODOS_FULL_ENTRY_INSTRUCTION = readRuntimePrompt("write-todos-full-entry");
11
+ export const WRITE_TODOS_NON_EMPTY_INITIAL_LIST_INSTRUCTION = readRuntimePrompt("write-todos-non-empty-initial-list");
12
+ export const WRITE_TODOS_DESCRIPTIVE_CONTENT_INSTRUCTION = readRuntimePrompt("write-todos-descriptive-content");
13
+ export const EXECUTION_WITH_TOOL_EVIDENCE_INSTRUCTION = readRuntimePrompt("execution-with-tool-evidence");
14
+ export const EXECUTION_WITH_TOOL_EVIDENCE_RETRY_INSTRUCTION = readRuntimePrompt("execution-with-tool-evidence-retry");
15
+ export const WORKSPACE_RELATIVE_PATH_INSTRUCTION = readRuntimePrompt("workspace-relative-path");
16
+ export function renderDurableMemoryContextPrompt(memoryContext) {
17
+ return renderBundledTemplate("prompts/runtime/durable-memory-context.md", {
18
+ memoryContext: memoryContext.trim(),
19
+ });
20
+ }
21
+ export function renderSlashCommandSkillInstruction(input) {
22
+ return renderBundledTemplate("prompts/runtime/slash-command-skill.md", {
23
+ skillQualifier: input.skillQualifier,
24
+ skillName: input.skillName,
25
+ argumentText: JSON.stringify(input.argumentText),
26
+ dryRunHint: input.dryRunHint,
27
+ });
28
+ }
29
+ export function renderRuntimeMemoryManagerPrompt(input) {
30
+ const existing = input.existingRecords.length === 0
31
+ ? "(none)"
32
+ : input.existingRecords
33
+ .map((record) => `- scope=${record.scope}; kind=${record.kind}; summary=${record.summary}; status=${record.status};${record.knowledgeIdentity ? ` knowledge_identity=${record.knowledgeIdentity}; knowledge_operation=${record.knowledgeOperation ?? "create"};` : ""}${record.operationalRule ? ` operational_rule=${record.operationalRule.trigger}->${record.operationalRule.action}(${record.operationalRule.target})[${record.operationalRule.effect ?? "apply"}];` : ""} content=${record.content.replace(/\s+/g, " ").slice(0, 220)}`)
34
+ .join("\n");
35
+ const values = {
36
+ sessionId: input.sessionId,
37
+ requestId: input.requestId,
38
+ candidateJson: JSON.stringify(input.candidate, null, 2),
39
+ existingRecords: existing,
40
+ };
41
+ return input.template
42
+ ? renderTemplateText(input.template, values)
43
+ : renderBundledTemplate("prompts/runtime/memory-manager.md", values);
44
+ }
45
+ export function renderRuntimeMemoryMutationReconciliationPrompt(input) {
46
+ const existing = input.existingRecords.length === 0
47
+ ? "(none)"
48
+ : input.existingRecords
49
+ .map((record) => `- knowledge_identity=${record.knowledgeIdentity ?? "(none)"}; scope=${record.scope}; kind=${record.kind}; status=${record.status}; summary=${record.summary};${record.operationalRule ? ` operational_rule=${record.operationalRule.trigger}->${record.operationalRule.action}(${record.operationalRule.target})[${record.operationalRule.effect ?? "apply"}];` : ""} content=${record.content.replace(/\s+/g, " ").slice(0, 220)}`)
50
+ .join("\n");
51
+ return renderBundledTemplate("prompts/runtime/memory-mutation-reconciliation.md", {
52
+ candidateJson: JSON.stringify(input.candidate, null, 2),
53
+ existingRecords: existing,
54
+ });
55
+ }
@@ -1,5 +1,5 @@
1
1
  import type { CompiledVectorStore, RuntimeEmbeddingModelResolver, RuntimeVectorStoreResolver, WorkspaceBundle } from "../../contracts/types.js";
2
- import { type VectorStoreRuntimeLike } from "./llamaindex.js";
2
+ import type { VectorStoreRuntimeLike } from "./llamaindex.js";
3
3
  export declare function resolveCompiledVectorStoreRef(workspace: WorkspaceBundle, vectorStoreRef?: string): CompiledVectorStore;
4
4
  export declare function resolveCompiledVectorStore(workspace: WorkspaceBundle, vectorStore: CompiledVectorStore, options?: {
5
5
  embeddingModelResolver?: RuntimeEmbeddingModelResolver;
@@ -7,7 +7,6 @@ import { QdrantClient } from "@qdrant/js-client-rest";
7
7
  import { compileVectorStore } from "../../workspace/resource-compilers.js";
8
8
  import { getRuntimeStorageRoots, resolveRefId } from "../../workspace/support/workspace-ref-utils.js";
9
9
  import { resolveCompiledEmbeddingModel, resolveCompiledEmbeddingModelRef } from "./embedding-models.js";
10
- import { createLlamaIndexVectorStore } from "./llamaindex.js";
11
10
  function resolveFileUrl(rawUrl, workspaceRoot) {
12
11
  if (!rawUrl.startsWith("file:")) {
13
12
  return rawUrl;
@@ -74,6 +73,10 @@ async function ensureQdrantCollection(client, collection, dimensions) {
74
73
  },
75
74
  });
76
75
  }
76
+ async function createLazyLlamaIndexVectorStore(dataRoot, vectorStore, embeddings) {
77
+ const { createLlamaIndexVectorStore } = await import("./llamaindex.js");
78
+ return createLlamaIndexVectorStore(dataRoot, vectorStore, embeddings);
79
+ }
77
80
  export function resolveCompiledVectorStoreRef(workspace, vectorStoreRef) {
78
81
  const resolvedId = vectorStoreRef ? resolveRefId(vectorStoreRef) : "default";
79
82
  const vectorStore = workspace.vectorStores.get(resolvedId);
@@ -96,7 +99,7 @@ export async function resolveCompiledVectorStore(workspace, vectorStore, options
96
99
  if (vectorStore.kind === "LlamaIndexSimpleVectorStore") {
97
100
  const embeddingModel = resolveCompiledEmbeddingModelRef(workspace, vectorStore.embeddingModelRef);
98
101
  const embeddings = await resolveCompiledEmbeddingModel(embeddingModel, options.embeddingModelResolver);
99
- return createLlamaIndexVectorStore(dataRoot, vectorStore, embeddings);
102
+ return createLazyLlamaIndexVectorStore(dataRoot, vectorStore, embeddings);
100
103
  }
101
104
  if (vectorStore.kind === "QdrantVectorStore") {
102
105
  const embeddingModel = resolveCompiledEmbeddingModelRef(workspace, vectorStore.embeddingModelRef);
@@ -28,9 +28,6 @@ function readEventContext(event) {
28
28
  ns: readStringArray(typed?.ns),
29
29
  };
30
30
  }
31
- function containsSemanticHint(values, hint) {
32
- return values.some((value) => hint.test(value));
33
- }
34
31
  function normalizeSemanticHint(value) {
35
32
  return value
36
33
  .replace(/([a-z0-9])([A-Z])/g, "$1 $2")
@@ -40,14 +37,18 @@ function normalizeSemanticHint(value) {
40
37
  .trim()
41
38
  .toLowerCase();
42
39
  }
40
+ function isExactSemanticHint(values, expected) {
41
+ return values.includes(expected);
42
+ }
43
43
  function classifyStepCategory(context) {
44
44
  const hints = [context.name, context.runType, ...context.tags, ...context.ns].map(normalizeSemanticHint);
45
- if (containsSemanticHint(hints, /\b(skill|skills)\b/)) {
46
- return "skill";
47
- }
48
- if (containsSemanticHint(hints, /\b(memory|recall|store|checkpoint)\b/)) {
45
+ if (context.runType === "memory"
46
+ || isExactSemanticHint(hints, "memory")) {
49
47
  return "memory";
50
48
  }
49
+ if (isExactSemanticHint(hints, "skill")) {
50
+ return "skill";
51
+ }
51
52
  if (context.eventName.startsWith("on_tool_") || context.runType === "tool") {
52
53
  return "tool";
53
54
  }
@@ -0,0 +1,3 @@
1
+ export declare function readBundledText(relativePath: string): string;
2
+ export declare function renderTemplateText(template: string, values: Record<string, string | number | boolean | undefined>): string;
3
+ export declare function renderBundledTemplate(relativePath: string, values: Record<string, string | number | boolean | undefined>): string;
@@ -0,0 +1,25 @@
1
+ import { readFileSync } from "node:fs";
2
+ const bundledTextCache = new Map();
3
+ export function readBundledText(relativePath) {
4
+ const normalized = relativePath.replace(/^\.?\//, "");
5
+ const cached = bundledTextCache.get(normalized);
6
+ if (cached !== undefined) {
7
+ return cached;
8
+ }
9
+ const value = readFileSync(new URL(`../../resources/${normalized}`, import.meta.url), "utf8");
10
+ bundledTextCache.set(normalized, value);
11
+ return value;
12
+ }
13
+ export function renderTemplateText(template, values) {
14
+ return template
15
+ .replace(/\{\{([a-zA-Z0-9_]+)\}\}/g, (_match, key) => {
16
+ const value = values[key];
17
+ return value === undefined ? "" : String(value);
18
+ })
19
+ .replace(/[ \t]+\n/g, "\n")
20
+ .replace(/\n{3,}/g, "\n\n")
21
+ .trim();
22
+ }
23
+ export function renderBundledTemplate(relativePath, values) {
24
+ return renderTemplateText(readBundledText(relativePath), values);
25
+ }
package/dist/utils/id.js CHANGED
@@ -1,8 +1,9 @@
1
- import { randomUUID } from "node:crypto";
1
+ import { randomBytes } from "node:crypto";
2
2
  export function createPersistentId(now = new Date()) {
3
3
  const iso = now.toISOString();
4
4
  const compact = iso.replace(/[-:]/g, "").replace(/\./g, "").replace("Z", "");
5
5
  const [date, time] = compact.split("T");
6
6
  const hhmmss = time.slice(0, 9);
7
- return `${date}T${hhmmss}-${randomUUID()}`;
7
+ const suffix = randomBytes(6).toString("hex");
8
+ return `${date}T${hhmmss}-${suffix}`;
8
9
  }
@@ -5,10 +5,8 @@ import { compileModel, compileTool } from "./resource-compilers.js";
5
5
  import { inferAgentCapabilities } from "./support/agent-capabilities.js";
6
6
  import { getAgentExecutionConfigValue, getAgentExecutionObject, getAgentExecutionString } from "./support/agent-execution-config.js";
7
7
  import { discoverSkillPaths } from "./support/discovery.js";
8
- import { compileAgentMemories, getResilienceConfig, getRuntimeDefaults, getRuntimeMemoryDefaults, getRuntimeStorageRoots, getWorkspaceObject, resolvePromptValue, resolveRefId, } from "./support/workspace-ref-utils.js";
9
- const WORKSPACE_BOUNDARY_GUIDANCE = "Keep repository and file exploration bounded to the current workspace root unless the user explicitly asks for broader host or filesystem access. " +
10
- "Do not inspect absolute paths outside the workspace, system directories, or unrelated repos by default. " +
11
- "Prefer workspace-local tools, relative paths, and the current repository checkout when analyzing code.";
8
+ import { compileAgentMemories, getProceduralMemoryDefaults, getResilienceConfig, getRuntimeDefaults, getRuntimeMemoryDefaults, getRuntimeStorageRoots, getWorkspaceObject, resolvePromptValue, resolveRefId, } from "./support/workspace-ref-utils.js";
9
+ import { WORKSPACE_BOUNDARY_GUIDANCE } from "../runtime/support/runtime-prompts.js";
12
10
  function requireSkills(pathEntries, workspaceRoot) {
13
11
  return Array.from(new Set(discoverSkillPaths(pathEntries, workspaceRoot)));
14
12
  }
@@ -169,7 +167,7 @@ export function requireTools(tools, bindings, ownerId) {
169
167
  return Array.from(deduped.values());
170
168
  }
171
169
  function buildSubagent(agent, workspaceRoot, models, tools, parentSkills, parentModel) {
172
- const execution = compileExecutionCore(agent, models, tools);
170
+ const execution = compileExecutionCore(agent, workspaceRoot, models, tools);
173
171
  return {
174
172
  name: resolveAgentRuntimeName(agent),
175
173
  description: agent.description,
@@ -182,8 +180,9 @@ function buildSubagent(agent, workspaceRoot, models, tools, parentSkills, parent
182
180
  middleware: execution.middleware,
183
181
  };
184
182
  }
185
- function resolveSystemPrompt(agent) {
186
- const prompt = resolvePromptValue(getAgentExecutionConfigValue(agent, "systemPrompt"));
183
+ function resolveSystemPrompt(agent, workspaceRoot) {
184
+ const promptBaseDir = path.dirname(agent.sourcePath || workspaceRoot);
185
+ const prompt = resolvePromptValue(getAgentExecutionConfigValue(agent, "systemPrompt"), promptBaseDir);
187
186
  if (agent.executionMode !== "deepagent") {
188
187
  return prompt;
189
188
  }
@@ -230,11 +229,11 @@ function compileDeepAgentSubagents(agent, agents, workspaceRoot, models, tools,
230
229
  ...compileAsyncSubagents(agent),
231
230
  ];
232
231
  }
233
- function compileExecutionCore(agent, models, tools) {
232
+ function compileExecutionCore(agent, workspaceRoot, models, tools) {
234
233
  return {
235
234
  model: requireModel(models, agent.modelRef, agent.id),
236
235
  tools: requireTools(tools, getAgentToolBindings(agent), agent.id),
237
- systemPrompt: resolveSystemPrompt(agent),
236
+ systemPrompt: resolveSystemPrompt(agent, workspaceRoot),
238
237
  responseFormat: resolveResponseFormat(agent),
239
238
  contextSchema: resolveContextSchema(agent),
240
239
  middleware: resolveCompiledMiddleware(agent, models),
@@ -296,6 +295,30 @@ function materializeWorkspaceObjectConfig(refs, ref, allowedKinds, ownerLabel) {
296
295
  }
297
296
  return config;
298
297
  }
298
+ function materializeRuntimeMemoryConfig(refs, config, ownerLabel) {
299
+ const runtimeMemory = { ...config };
300
+ const nestedStore = asObject(runtimeMemory.store);
301
+ if (nestedStore && isRefConfig(nestedStore)) {
302
+ runtimeMemory.store = materializeWorkspaceObjectConfig(refs, nestedStore.ref, ["store"], `${ownerLabel} runtimeMemory.store`);
303
+ }
304
+ return runtimeMemory;
305
+ }
306
+ function materializeProceduralMemoryConfig(refs, config, ownerLabel) {
307
+ const proceduralMemory = { ...config };
308
+ const nestedStore = asObject(proceduralMemory.store);
309
+ if (nestedStore && isRefConfig(nestedStore)) {
310
+ proceduralMemory.store = materializeWorkspaceObjectConfig(refs, nestedStore.ref, ["store"], `${ownerLabel} proceduralMemory.store`);
311
+ }
312
+ const nestedVectorStore = asObject(proceduralMemory.vectorStore);
313
+ if (nestedVectorStore && isRefConfig(nestedVectorStore)) {
314
+ proceduralMemory.vectorStore = materializeWorkspaceObjectConfig(refs, nestedVectorStore.ref, ["vector-store"], `${ownerLabel} proceduralMemory.vectorStore`);
315
+ }
316
+ const nestedEmbeddingModel = asObject(proceduralMemory.embeddingModel);
317
+ if (nestedEmbeddingModel && isRefConfig(nestedEmbeddingModel)) {
318
+ proceduralMemory.embeddingModel = materializeWorkspaceObjectConfig(refs, nestedEmbeddingModel.ref, ["embedding-model"], `${ownerLabel} proceduralMemory.embeddingModel`);
319
+ }
320
+ return proceduralMemory;
321
+ }
299
322
  function resolveStoreConfig(agent, refs) {
300
323
  const inlineStore = getAgentExecutionObject(agent, "store");
301
324
  if (!inlineStore) {
@@ -328,13 +351,28 @@ function resolveRuntimeMemoryConfig(agent, refs) {
328
351
  if (inlineRuntimeMemory) {
329
352
  if (isRefConfig(inlineRuntimeMemory)) {
330
353
  return {
331
- config: materializeWorkspaceObjectConfig(refs, inlineRuntimeMemory.ref, ["runtime-memory"], `Agent ${agent.id} runtimeMemory`),
354
+ config: materializeRuntimeMemoryConfig(refs, materializeWorkspaceObjectConfig(refs, inlineRuntimeMemory.ref, ["runtime-memory"], `Agent ${agent.id} runtimeMemory`), `Agent ${agent.id}`),
332
355
  };
333
356
  }
334
- return { config: inlineRuntimeMemory };
357
+ return { config: materializeRuntimeMemoryConfig(refs, inlineRuntimeMemory, `Agent ${agent.id}`) };
335
358
  }
336
359
  const runtimeMemoryDefaults = getRuntimeMemoryDefaults(refs);
337
- return runtimeMemoryDefaults ? { config: runtimeMemoryDefaults } : undefined;
360
+ return runtimeMemoryDefaults ? { config: materializeRuntimeMemoryConfig(refs, runtimeMemoryDefaults, `Agent ${agent.id}`) } : undefined;
361
+ }
362
+ function resolveProceduralMemoryConfig(agent, refs) {
363
+ const inlineProceduralMemory = agent.proceduralMemory ?? getAgentExecutionObject(agent, "proceduralMemory");
364
+ if (inlineProceduralMemory) {
365
+ if (isRefConfig(inlineProceduralMemory)) {
366
+ return {
367
+ config: materializeProceduralMemoryConfig(refs, materializeWorkspaceObjectConfig(refs, inlineProceduralMemory.ref, ["procedural-memory"], `Agent ${agent.id} proceduralMemory`), `Agent ${agent.id}`),
368
+ };
369
+ }
370
+ return { config: materializeProceduralMemoryConfig(refs, inlineProceduralMemory, `Agent ${agent.id}`) };
371
+ }
372
+ const proceduralMemoryDefaults = getProceduralMemoryDefaults(refs);
373
+ return proceduralMemoryDefaults
374
+ ? { config: materializeProceduralMemoryConfig(refs, proceduralMemoryDefaults, `Agent ${agent.id}`) }
375
+ : undefined;
338
376
  }
339
377
  export function compileBinding(workspaceRoot, agent, agents, referencedSubagentIds, refs, models, tools) {
340
378
  const internalSubagent = referencedSubagentIds.has(agent.id);
@@ -346,13 +384,14 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
346
384
  const executionCore = compileExecutionCore({
347
385
  ...agent,
348
386
  modelRef: agent.modelRef || (internalSubagent ? "model/default" : ""),
349
- }, models, tools);
387
+ }, workspaceRoot, models, tools);
350
388
  const passthrough = resolvePassthrough(agent);
351
389
  const compiledAgentModel = executionCore.model;
352
390
  const backend = resolveBackendConfig(agent, refs);
353
391
  const store = resolveStoreConfig(agent, refs);
354
392
  const checkpointer = resolveCheckpointerConfig(agent, refs);
355
393
  const runtimeMemory = resolveRuntimeMemoryConfig(agent, refs);
394
+ const proceduralMemory = resolveProceduralMemoryConfig(agent, refs);
356
395
  const runtimeFilesystemDefaults = agent.executionMode === "langchain-v1"
357
396
  ? asObject(runtimeDefaults?.filesystem)
358
397
  : undefined;
@@ -401,6 +440,7 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
401
440
  ...(checkpointer ? { checkpointer: checkpointer.config } : {}),
402
441
  ...(store ? { store: store.config } : {}),
403
442
  ...(runtimeMemory ? { runtimeMemory: runtimeMemory.config } : {}),
443
+ ...(proceduralMemory ? { proceduralMemory: proceduralMemory.config } : {}),
404
444
  },
405
445
  };
406
446
  if (agent.executionMode !== "deepagent") {
@@ -258,6 +258,7 @@ const CONSUMED_AGENT_CONFIG_KEYS = [
258
258
  "backend",
259
259
  "store",
260
260
  "runtimeMemory",
261
+ "proceduralMemory",
261
262
  "taskDescription",
262
263
  "generalPurposeAgent",
263
264
  "filesystem",
@@ -317,6 +318,12 @@ function normalizeAgentItemForMerge(item) {
317
318
  normalized.runtime = nextRuntime;
318
319
  delete config.runtimeMemory;
319
320
  }
321
+ if (config.proceduralMemory !== undefined && runtime?.proceduralMemory === undefined) {
322
+ const nextRuntime = asMutableObject(normalized.runtime) ?? runtime ?? {};
323
+ nextRuntime.proceduralMemory = cloneConfigValue(config.proceduralMemory);
324
+ normalized.runtime = nextRuntime;
325
+ delete config.proceduralMemory;
326
+ }
320
327
  }
321
328
  if (config && Object.keys(config).length > 0) {
322
329
  normalized.config = config;
@@ -367,6 +374,32 @@ function readRuntimeMemoryConfig(item, runtime) {
367
374
  }
368
375
  return undefined;
369
376
  }
377
+ function readProceduralMemoryConfig(item, runtime) {
378
+ if (typeof runtime?.proceduralMemory === "string" && runtime.proceduralMemory.trim()) {
379
+ return {
380
+ ref: runtime.proceduralMemory.startsWith("procedural-memory/")
381
+ ? runtime.proceduralMemory
382
+ : `procedural-memory/${runtime.proceduralMemory.trim()}`,
383
+ };
384
+ }
385
+ if (typeof runtime?.proceduralMemory === "object" && runtime.proceduralMemory && !Array.isArray(runtime.proceduralMemory)) {
386
+ return cloneConfigValue(runtime.proceduralMemory);
387
+ }
388
+ const legacyExecutionConfig = readExecutionAgentConfig(item);
389
+ if (typeof legacyExecutionConfig.proceduralMemory === "string" && legacyExecutionConfig.proceduralMemory.trim()) {
390
+ return {
391
+ ref: legacyExecutionConfig.proceduralMemory.startsWith("procedural-memory/")
392
+ ? legacyExecutionConfig.proceduralMemory
393
+ : `procedural-memory/${legacyExecutionConfig.proceduralMemory.trim()}`,
394
+ };
395
+ }
396
+ if (typeof legacyExecutionConfig.proceduralMemory === "object" &&
397
+ legacyExecutionConfig.proceduralMemory &&
398
+ !Array.isArray(legacyExecutionConfig.proceduralMemory)) {
399
+ return cloneConfigValue(legacyExecutionConfig.proceduralMemory);
400
+ }
401
+ return undefined;
402
+ }
370
403
  function cloneConfigValue(value) {
371
404
  if (Array.isArray(value)) {
372
405
  return value.map((item) => cloneConfigValue(item));
@@ -510,6 +543,7 @@ export function parseAgentItem(item, sourcePath) {
510
543
  id: String(normalizedItem.id),
511
544
  executionMode: executionMode,
512
545
  runtimeMemory: readRuntimeMemoryConfig(normalizedItem, runtime),
546
+ proceduralMemory: readProceduralMemoryConfig(normalizedItem, runtime),
513
547
  capabilities: readCapabilities(normalizedItem.capabilities) ?? (executionMode === "deepagent"
514
548
  ? { delegation: true, memory: true }
515
549
  : { delegation: true, memory: true }),
@@ -594,6 +628,31 @@ function mergeAgentRecord(records, item, sourcePath) {
594
628
  if (!id) {
595
629
  return null;
596
630
  }
631
+ const current = records.get(id);
632
+ const incomingHasSystemPrompt = normalizedItem.systemPrompt !== undefined;
633
+ const currentSystemPrompt = current?.item.systemPrompt;
634
+ const currentCarriesRelativePromptPath = typeof currentSystemPrompt === "object"
635
+ && currentSystemPrompt !== null
636
+ && !Array.isArray(currentSystemPrompt)
637
+ && typeof currentSystemPrompt.path === "string"
638
+ && !!currentSystemPrompt.path.trim()
639
+ && !path.isAbsolute(currentSystemPrompt.path);
640
+ if (current && currentCarriesRelativePromptPath && !incomingHasSystemPrompt) {
641
+ const currentPromptConfig = currentSystemPrompt;
642
+ const absolutizedCurrent = {
643
+ ...current.item,
644
+ systemPrompt: {
645
+ ...currentPromptConfig,
646
+ path: path.resolve(path.dirname(current.sourcePath), currentPromptConfig.path),
647
+ },
648
+ };
649
+ const mergedRecord = {
650
+ item: mergeValues(absolutizedCurrent, normalizedItem),
651
+ sourcePath,
652
+ };
653
+ records.set(id, mergedRecord);
654
+ return mergedRecord;
655
+ }
597
656
  return mergeRawItemRecord(records, id, normalizedItem, sourcePath);
598
657
  }
599
658
  function mergeWorkspaceObjectRecord(records, workspaceObject, item, sourcePath) {
@@ -892,12 +951,15 @@ export async function loadWorkspaceObjects(workspaceRoot, options = {}) {
892
951
  const refs = new Map();
893
952
  const mergedAgents = new Map();
894
953
  const mergedObjects = new Map();
895
- const roots = [frameworkWorkspaceRoot(), ...(options.overlayRoots ?? []), workspaceRoot];
954
+ const defaultRoot = frameworkWorkspaceRoot();
955
+ const roots = [defaultRoot, ...(options.overlayRoots ?? []), workspaceRoot];
896
956
  for (const root of roots) {
897
957
  const configRoot = conventionalConfigRoot(root) ?? root;
898
958
  await loadConfigYamlForRoot(root, configRoot, mergedAgents, mergedObjects);
899
959
  await loadModuleAgentsForRoot(root, mergedAgents);
900
- await loadConventionalObjectsForRoot(root, mergedObjects, getMergedToolModuleDiscoveryScope(mergedObjects));
960
+ if (root !== defaultRoot) {
961
+ await loadConventionalObjectsForRoot(root, mergedObjects, getMergedToolModuleDiscoveryScope(mergedObjects));
962
+ }
901
963
  await loadModuleObjectsForRoot(root, mergedObjects);
902
964
  await loadRootObjects(root, mergedObjects);
903
965
  }
@@ -46,6 +46,7 @@ export declare function getRuntimeStorageRoots(refs: Map<string, WorkspaceObject
46
46
  export declare function getRuntimeResources(refs: Map<string, WorkspaceObject | ParsedAgentObject>): string[];
47
47
  export declare function getToolModuleDiscoveryConfig(refs: Map<string, WorkspaceObject | ParsedAgentObject>): ToolModuleDiscoveryConfig;
48
48
  export declare function getRuntimeMemoryDefaults(refs: Map<string, WorkspaceObject | ParsedAgentObject>): Record<string, unknown> | undefined;
49
+ export declare function getProceduralMemoryDefaults(refs: Map<string, WorkspaceObject | ParsedAgentObject>): Record<string, unknown> | undefined;
49
50
  export declare function getRecoveryConfig(refs: Map<string, WorkspaceObject | ParsedAgentObject>): RecoveryConfig;
50
51
  export declare function getConcurrencyConfig(refs: Map<string, WorkspaceObject | ParsedAgentObject>): ConcurrencyConfig;
51
52
  export declare function getResilienceConfig(refs: Map<string, WorkspaceObject | ParsedAgentObject>): ResilienceConfig;
@@ -55,7 +56,7 @@ export declare function matchRoutingRule(input: string, rule: RoutingRule, optio
55
56
  sessionId?: string;
56
57
  legacySessionId?: string;
57
58
  }): boolean;
58
- export declare function resolvePromptValue(promptConfig: unknown): string | undefined;
59
+ export declare function resolvePromptValue(promptConfig: unknown, baseDir?: string): string | undefined;
59
60
  export declare function resolveRefId(ref: string): string;
60
61
  export declare function resolvePathList(refs: Map<string, WorkspaceObject | ParsedAgentObject>, workspaceRoot: string, refList: string[]): string[];
61
62
  export declare function compileAgentMemories(workspaceRoot: string, sources: string[]): string[];
@@ -43,7 +43,7 @@ export function getRuntimeStorageRoots(refs, workspaceRoot) {
43
43
  ? (path.isAbsolute(configuredDataRoot)
44
44
  ? configuredDataRoot
45
45
  : path.resolve(applicationRoot, configuredDataRoot))
46
- : path.join(applicationRoot, ".agent");
46
+ : path.join(applicationRoot, ".botbotgo");
47
47
  const runtimeProfile = configuredProfile ?? "default";
48
48
  return {
49
49
  applicationRoot,
@@ -72,13 +72,31 @@ export function getToolModuleDiscoveryConfig(refs) {
72
72
  export function getRuntimeMemoryDefaults(refs) {
73
73
  const runtimeMemories = Array.from(refs.values()).filter((object) => !("executionMode" in object) && object.kind === "runtime-memory");
74
74
  if (runtimeMemories.length === 0) {
75
- return undefined;
75
+ const runtimeDefaults = getRuntimeDefaults(refs);
76
+ return typeof runtimeDefaults?.runtimeMemory === "object" && runtimeDefaults.runtimeMemory && !Array.isArray(runtimeDefaults.runtimeMemory)
77
+ ? runtimeDefaults.runtimeMemory
78
+ : undefined;
76
79
  }
77
80
  if (runtimeMemories.length > 1) {
78
81
  throw new Error(`Expected at most one RuntimeMemory object, found ${runtimeMemories.length}`);
79
82
  }
80
83
  return runtimeMemories[0].value;
81
84
  }
85
+ export function getProceduralMemoryDefaults(refs) {
86
+ const proceduralMemories = Array.from(refs.values()).filter((object) => !("executionMode" in object) && object.kind === "procedural-memory");
87
+ if (proceduralMemories.length === 0) {
88
+ const runtimeDefaults = getRuntimeDefaults(refs);
89
+ return typeof runtimeDefaults?.proceduralMemory === "object" &&
90
+ runtimeDefaults.proceduralMemory &&
91
+ !Array.isArray(runtimeDefaults.proceduralMemory)
92
+ ? runtimeDefaults.proceduralMemory
93
+ : undefined;
94
+ }
95
+ if (proceduralMemories.length > 1) {
96
+ throw new Error(`Expected at most one ProceduralMemoryRuntime object, found ${proceduralMemories.length}`);
97
+ }
98
+ return proceduralMemories[0].value;
99
+ }
82
100
  export function getRecoveryConfig(refs) {
83
101
  const runtimeDefaults = getRuntimeDefaults(refs);
84
102
  const recovery = typeof runtimeDefaults?.recovery === "object" && runtimeDefaults.recovery
@@ -263,7 +281,7 @@ export function matchRoutingRule(input, rule, options = {}) {
263
281
  }
264
282
  return true;
265
283
  }
266
- export function resolvePromptValue(promptConfig) {
284
+ export function resolvePromptValue(promptConfig, baseDir) {
267
285
  if (typeof promptConfig === "string" && promptConfig.trim()) {
268
286
  return promptConfig;
269
287
  }
@@ -272,7 +290,8 @@ export function resolvePromptValue(promptConfig) {
272
290
  ? promptConfig.path
273
291
  : undefined;
274
292
  if (promptPath?.trim()) {
275
- return readFileSync(promptPath, "utf8");
293
+ const resolvedPath = baseDir && !path.isAbsolute(promptPath) ? path.resolve(baseDir, promptPath) : promptPath;
294
+ return readFileSync(resolvedPath, "utf8");
276
295
  }
277
296
  }
278
297
  return undefined;
@@ -282,7 +301,7 @@ export function resolveRefId(ref) {
282
301
  if (rest.length === 0) {
283
302
  return ref;
284
303
  }
285
- if (["agent", "embedding-model", "mcp", "model", "object", "prompt", "runtime", "runtime-memory", "tool", "vector-store"].includes(namespace)) {
304
+ if (["agent", "embedding-model", "mcp", "model", "object", "procedural-memory", "prompt", "runtime", "runtime-memory", "tool", "vector-store"].includes(namespace)) {
286
305
  return rest.join("/");
287
306
  }
288
307
  return ref;
@@ -1,3 +1,4 @@
1
+ export declare function interpolateEnvPlaceholders(value: unknown, sourcePath: string, envOverrides?: Record<string, string | undefined>): unknown;
1
2
  export declare function normalizeYamlItem(item: Record<string, unknown>): Record<string, unknown>;
2
3
  export declare function readYamlItems(root: string, relativeDir?: string, options?: {
3
4
  recursive?: boolean;