@botbotgo/agent-harness 0.0.309 → 0.0.311

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 (195) hide show
  1. package/README.md +14 -0
  2. package/README.zh.md +14 -0
  3. package/dist/acp.d.ts +1 -116
  4. package/dist/acp.js +1 -310
  5. package/dist/api.d.ts +1 -1
  6. package/dist/api.js +1 -1
  7. package/dist/cli/chat-interactive.d.ts +24 -0
  8. package/dist/cli/chat-interactive.js +244 -0
  9. package/dist/cli/chat-rendering.d.ts +9 -0
  10. package/dist/cli/chat-rendering.js +102 -0
  11. package/dist/cli/chat-stream.d.ts +23 -0
  12. package/dist/cli/chat-stream.js +330 -0
  13. package/dist/cli/chat-ui.d.ts +20 -0
  14. package/dist/cli/chat-ui.js +198 -0
  15. package/dist/cli/chat-workspace.d.ts +15 -0
  16. package/dist/cli/chat-workspace.js +205 -0
  17. package/dist/cli/main.d.ts +52 -0
  18. package/dist/cli/main.js +323 -0
  19. package/dist/cli/managed-service-commands.d.ts +23 -0
  20. package/dist/cli/managed-service-commands.js +63 -0
  21. package/dist/cli/managed-service.d.ts +27 -0
  22. package/dist/cli/managed-service.js +61 -0
  23. package/dist/cli/options-init-chat.d.ts +16 -0
  24. package/dist/cli/options-init-chat.js +108 -0
  25. package/dist/cli/options-runtime.d.ts +27 -0
  26. package/dist/cli/options-runtime.js +158 -0
  27. package/dist/cli/options-serve.d.ts +24 -0
  28. package/dist/cli/options-serve.js +166 -0
  29. package/dist/cli/options.d.ts +5 -0
  30. package/dist/cli/options.js +47 -0
  31. package/dist/cli/process-guards.d.ts +14 -0
  32. package/dist/cli/process-guards.js +139 -0
  33. package/dist/cli/request-tree.d.ts +12 -0
  34. package/dist/cli/request-tree.js +296 -0
  35. package/dist/cli/runtime-commands.d.ts +15 -0
  36. package/dist/cli/runtime-commands.js +247 -0
  37. package/dist/cli/runtime-output.d.ts +5 -0
  38. package/dist/cli/runtime-output.js +124 -0
  39. package/dist/cli/server-commands.d.ts +36 -0
  40. package/dist/cli/server-commands.js +250 -0
  41. package/dist/cli/workspace.d.ts +6 -0
  42. package/dist/cli/workspace.js +71 -0
  43. package/dist/cli.d.ts +1 -77
  44. package/dist/cli.js +2 -3023
  45. package/dist/client/acp.d.ts +1 -50
  46. package/dist/client/acp.js +1 -219
  47. package/dist/client/in-process.d.ts +5 -5
  48. package/dist/client/index.d.ts +2 -2
  49. package/dist/client/index.js +1 -1
  50. package/dist/contracts/runtime-evaluation.d.ts +103 -0
  51. package/dist/contracts/runtime-evaluation.js +1 -0
  52. package/dist/contracts/runtime-memory.d.ts +162 -0
  53. package/dist/contracts/runtime-memory.js +1 -0
  54. package/dist/contracts/runtime-observability.d.ts +248 -0
  55. package/dist/contracts/runtime-observability.js +1 -0
  56. package/dist/contracts/runtime-requests.d.ts +342 -0
  57. package/dist/contracts/runtime-requests.js +1 -0
  58. package/dist/contracts/runtime-scheduling.d.ts +146 -0
  59. package/dist/contracts/runtime-scheduling.js +1 -0
  60. package/dist/contracts/runtime.d.ts +5 -1042
  61. package/dist/contracts/runtime.js +27 -1
  62. package/dist/flow/build-flow-graph.js +4 -875
  63. package/dist/flow/flow-graph-normalization.d.ts +56 -0
  64. package/dist/flow/flow-graph-normalization.js +214 -0
  65. package/dist/flow/flow-graph-runtime.d.ts +8 -0
  66. package/dist/flow/flow-graph-runtime.js +107 -0
  67. package/dist/flow/flow-graph-upstream.d.ts +18 -0
  68. package/dist/flow/flow-graph-upstream.js +498 -0
  69. package/dist/flow/types.d.ts +1 -1
  70. package/dist/index.d.ts +3 -3
  71. package/dist/index.js +1 -1
  72. package/dist/init-project.d.ts +1 -12
  73. package/dist/init-project.js +1 -651
  74. package/dist/{procedural → knowledge/procedural}/manager.d.ts +3 -3
  75. package/dist/{procedural → knowledge/procedural}/manager.js +6 -6
  76. package/dist/mcp.d.ts +2 -76
  77. package/dist/mcp.js +2 -428
  78. package/dist/package-version.d.ts +1 -1
  79. package/dist/package-version.js +1 -1
  80. package/dist/persistence/file-store.js +1 -1
  81. package/dist/persistence/sqlite-runtime.d.ts +19 -0
  82. package/dist/persistence/sqlite-runtime.js +86 -0
  83. package/dist/persistence/sqlite-store.js +11 -99
  84. package/dist/{request-events.d.ts → projections/request-events.d.ts} +1 -1
  85. package/dist/{upstream-events.js → projections/upstream-events.js} +1 -1
  86. package/dist/protocol/a2a/http-discovery.d.ts +39 -0
  87. package/dist/protocol/a2a/http-discovery.js +178 -0
  88. package/dist/protocol/a2a/http-rpc.d.ts +28 -0
  89. package/dist/protocol/a2a/http-rpc.js +623 -0
  90. package/dist/protocol/a2a/http.d.ts +72 -1
  91. package/dist/protocol/a2a/http.js +14 -1124
  92. package/dist/protocol/a2a/task-state.d.ts +29 -0
  93. package/dist/protocol/a2a/task-state.js +317 -0
  94. package/dist/protocol/acp/client.js +1 -1
  95. package/dist/protocol/acp/harness-client.d.ts +50 -0
  96. package/dist/protocol/acp/harness-client.js +219 -0
  97. package/dist/protocol/acp/server.d.ts +116 -0
  98. package/dist/protocol/acp/server.js +310 -0
  99. package/dist/protocol/ag-ui/http.js +1 -1
  100. package/dist/protocol/mcp/server.d.ts +76 -0
  101. package/dist/protocol/mcp/server.js +428 -0
  102. package/dist/resource/backend/workspace-scoped-backend.d.ts +40 -0
  103. package/dist/resource/backend/workspace-scoped-backend.js +296 -0
  104. package/dist/resource/mcp/tool-support.d.ts +35 -0
  105. package/dist/resource/mcp/tool-support.js +296 -0
  106. package/dist/resource/mcp-tool-support.d.ts +2 -35
  107. package/dist/resource/mcp-tool-support.js +2 -296
  108. package/dist/resource/providers/resource-provider.d.ts +22 -0
  109. package/dist/resource/providers/resource-provider.js +215 -0
  110. package/dist/resource/resource-impl.d.ts +3 -33
  111. package/dist/resource/resource-impl.js +2 -808
  112. package/dist/resource/resource-types.d.ts +33 -0
  113. package/dist/resource/resource-types.js +1 -0
  114. package/dist/resource/tools/function-tool-resolver.d.ts +2 -0
  115. package/dist/resource/tools/function-tool-resolver.js +306 -0
  116. package/dist/runtime/adapter/middleware-assembly.js +1 -1
  117. package/dist/runtime/adapter/model/invocation-request.js +2 -2
  118. package/dist/runtime/adapter/model/message-assembly.js +1 -1
  119. package/dist/runtime/agent-runtime-adapter.d.ts +3 -63
  120. package/dist/runtime/agent-runtime-adapter.js +7 -235
  121. package/dist/runtime/agent-runtime-assembly.d.ts +67 -0
  122. package/dist/runtime/agent-runtime-assembly.js +211 -0
  123. package/dist/runtime/harness/background-runtime.d.ts +1 -1
  124. package/dist/runtime/harness/events/event-sink.js +1 -1
  125. package/dist/runtime/harness/events/runtime-event-operations.d.ts +1 -1
  126. package/dist/runtime/harness/events/streaming.js +1 -1
  127. package/dist/runtime/harness/public-shapes.d.ts +43 -0
  128. package/dist/runtime/harness/public-shapes.js +186 -0
  129. package/dist/runtime/harness/run/inspection.js +2 -2
  130. package/dist/runtime/harness/run/resources.js +1 -1
  131. package/dist/runtime/harness/run/surface-semantics.js +1 -1
  132. package/dist/runtime/harness/system/inventory.d.ts +1 -1
  133. package/dist/runtime/harness/system/inventory.js +2 -2
  134. package/dist/runtime/harness/system/policy-engine.js +1 -1
  135. package/dist/runtime/harness/system/runtime-memory-manager.js +1 -1
  136. package/dist/runtime/harness/system/skill-requirements.d.ts +1 -1
  137. package/dist/runtime/harness/system/skill-requirements.js +1 -1
  138. package/dist/runtime/harness.d.ts +2 -2
  139. package/dist/runtime/harness.js +7 -191
  140. package/dist/runtime/maintenance/checkpoint-maintenance.js +1 -1
  141. package/dist/runtime/maintenance/runtime-record-maintenance.js +1 -1
  142. package/dist/runtime/parsing/output-content.d.ts +11 -0
  143. package/dist/runtime/parsing/output-content.js +442 -0
  144. package/dist/runtime/parsing/output-parsing.d.ts +3 -29
  145. package/dist/runtime/parsing/output-parsing.js +3 -806
  146. package/dist/runtime/parsing/output-recovery.d.ts +14 -0
  147. package/dist/runtime/parsing/output-recovery.js +288 -0
  148. package/dist/runtime/parsing/output-tool-args.d.ts +4 -0
  149. package/dist/runtime/parsing/output-tool-args.js +120 -0
  150. package/dist/runtime/support/runtime-factories.js +1 -1
  151. package/dist/scaffold/init-project.d.ts +12 -0
  152. package/dist/scaffold/init-project.js +651 -0
  153. package/dist/{extensions.d.ts → tooling/extensions.d.ts} +1 -1
  154. package/dist/{extensions.js → tooling/extensions.js} +3 -3
  155. package/dist/{tool-modules.d.ts → tooling/module-loader.d.ts} +1 -1
  156. package/dist/{tool-modules.js → tooling/module-loader.js} +2 -2
  157. package/dist/workspace/agent-binding-compiler.js +2 -2
  158. package/dist/workspace/compile.js +2 -2
  159. package/dist/workspace/object-loader-paths.d.ts +11 -0
  160. package/dist/workspace/object-loader-paths.js +75 -0
  161. package/dist/workspace/object-loader-readers.d.ts +21 -0
  162. package/dist/workspace/object-loader-readers.js +187 -0
  163. package/dist/workspace/object-loader.d.ts +0 -1
  164. package/dist/workspace/object-loader.js +6 -260
  165. package/dist/workspace/resource-compilers.js +1 -1
  166. package/dist/workspace/support/discovery.js +1 -1
  167. package/package.json +1 -1
  168. package/dist/runtime/adapter/index.d.ts +0 -13
  169. package/dist/runtime/adapter/index.js +0 -13
  170. package/dist/runtime/harness/index.d.ts +0 -19
  171. package/dist/runtime/harness/index.js +0 -19
  172. package/dist/runtime/maintenance/index.d.ts +0 -4
  173. package/dist/runtime/maintenance/index.js +0 -4
  174. package/dist/runtime/parsing/index.d.ts +0 -2
  175. package/dist/runtime/parsing/index.js +0 -2
  176. package/dist/runtime/support/index.d.ts +0 -4
  177. package/dist/runtime/support/index.js +0 -4
  178. package/dist/workspace/support/index.d.ts +0 -2
  179. package/dist/workspace/support/index.js +0 -2
  180. /package/dist/{procedural → knowledge/procedural}/config.d.ts +0 -0
  181. /package/dist/{procedural → knowledge/procedural}/config.js +0 -0
  182. /package/dist/{procedural → knowledge/procedural}/index.d.ts +0 -0
  183. /package/dist/{procedural → knowledge/procedural}/index.js +0 -0
  184. /package/dist/{presentation.d.ts → projections/presentation.d.ts} +0 -0
  185. /package/dist/{presentation.js → projections/presentation.js} +0 -0
  186. /package/dist/{request-events.js → projections/request-events.js} +0 -0
  187. /package/dist/{upstream-events.d.ts → projections/upstream-events.d.ts} +0 -0
  188. /package/dist/runtime/{support → env}/runtime-env.d.ts +0 -0
  189. /package/dist/runtime/{support → env}/runtime-env.js +0 -0
  190. /package/dist/runtime/{support → layout}/runtime-layout.d.ts +0 -0
  191. /package/dist/runtime/{support → layout}/runtime-layout.js +0 -0
  192. /package/dist/runtime/{support → prompts}/runtime-prompts.d.ts +0 -0
  193. /package/dist/runtime/{support → prompts}/runtime-prompts.js +0 -0
  194. /package/dist/runtime/{support → skills}/skill-metadata.d.ts +0 -0
  195. /package/dist/runtime/{support → skills}/skill-metadata.js +0 -0
@@ -0,0 +1,186 @@
1
+ import { extractMessageText } from "../../utils/message-content.js";
2
+ export function toPublicRequestResultShape(result) {
3
+ return {
4
+ sessionId: result.sessionId ?? result.legacySessionId ?? "",
5
+ requestId: result.requestId ?? result.legacyRequestId ?? "",
6
+ state: result.state,
7
+ output: result.output,
8
+ finalMessageText: result.finalMessageText,
9
+ outputContent: result.outputContent,
10
+ contentBlocks: result.contentBlocks,
11
+ structuredResponse: result.structuredResponse,
12
+ interruptContent: result.interruptContent,
13
+ agentId: result.agentId,
14
+ approvalId: result.approvalId,
15
+ pendingActionId: result.pendingActionId,
16
+ delegationId: result.delegationId,
17
+ artifacts: result.artifacts,
18
+ metadata: result.metadata,
19
+ };
20
+ }
21
+ export function toPublicHarnessStreamItem(item) {
22
+ switch (item.type) {
23
+ case "commentary":
24
+ return {
25
+ type: "commentary",
26
+ sessionId: item.sessionId,
27
+ requestId: item.requestId,
28
+ agentId: item.agentId,
29
+ content: item.content,
30
+ };
31
+ case "content":
32
+ return {
33
+ type: "content",
34
+ sessionId: item.sessionId,
35
+ requestId: item.requestId,
36
+ agentId: item.agentId,
37
+ content: item.content,
38
+ };
39
+ case "content-blocks":
40
+ return {
41
+ type: "content-blocks",
42
+ sessionId: item.sessionId,
43
+ requestId: item.requestId,
44
+ agentId: item.agentId,
45
+ contentBlocks: item.contentBlocks,
46
+ };
47
+ case "tool-result":
48
+ return {
49
+ type: "tool-result",
50
+ sessionId: item.sessionId,
51
+ requestId: item.requestId,
52
+ agentId: item.agentId,
53
+ toolName: item.toolName,
54
+ output: item.output,
55
+ ...(item.isError !== undefined ? { isError: item.isError } : {}),
56
+ };
57
+ case "plan-state":
58
+ return {
59
+ type: "plan-state",
60
+ sessionId: item.sessionId,
61
+ requestId: item.requestId,
62
+ agentId: item.agentId,
63
+ planState: item.planState,
64
+ };
65
+ case "upstream-event":
66
+ return {
67
+ type: "upstream-event",
68
+ sessionId: item.sessionId,
69
+ requestId: item.requestId,
70
+ ...(item.surfaceItem ? { surfaceItem: item.surfaceItem } : {}),
71
+ event: item.event,
72
+ };
73
+ case "result":
74
+ return {
75
+ type: "result",
76
+ result: toPublicRequestResultShape(item.result),
77
+ };
78
+ default:
79
+ return item;
80
+ }
81
+ }
82
+ export function mergeMemoryItems(...groups) {
83
+ const merged = new Map();
84
+ for (const group of groups) {
85
+ for (const item of group) {
86
+ if (!merged.has(item.id)) {
87
+ merged.set(item.id, item);
88
+ }
89
+ }
90
+ }
91
+ return Array.from(merged.values());
92
+ }
93
+ function normalizeSessionListText(content, limit) {
94
+ if (!content) {
95
+ return undefined;
96
+ }
97
+ const collapsed = extractMessageText(content).replace(/\s+/g, " ").trim();
98
+ if (!collapsed) {
99
+ return undefined;
100
+ }
101
+ return collapsed.length > limit ? `${collapsed.slice(0, limit - 1).trimEnd()}…` : collapsed;
102
+ }
103
+ export function toSessionListSummary(session) {
104
+ const titleSource = session.firstMessage?.role === "user" ? session.firstMessage : session.lastMessage;
105
+ return {
106
+ agentId: session.agentId,
107
+ entryAgentId: session.entryAgentId,
108
+ sessionId: session.sessionId,
109
+ latestRequestId: session.latestRequestId,
110
+ createdAt: session.createdAt,
111
+ updatedAt: session.updatedAt,
112
+ status: session.status,
113
+ currentAgentId: session.currentAgentId,
114
+ messageCount: session.messageCount,
115
+ hasVisibleMessages: session.messageCount > 0,
116
+ lastMessageRole: session.lastMessage?.role,
117
+ title: normalizeSessionListText(titleSource?.content, 72),
118
+ snippet: normalizeSessionListText(session.lastMessage?.content, 160),
119
+ };
120
+ }
121
+ export function summarizeApprovalEvidence(approvals) {
122
+ const toolNames = Array.from(new Set(approvals
123
+ .map((approval) => approval.toolName)
124
+ .filter((toolName) => typeof toolName === "string" && toolName.trim().length > 0)));
125
+ const approvalReasons = Array.from(new Set(approvals
126
+ .map((approval) => approval.approvalReason)
127
+ .filter((reason) => typeof reason === "string" && reason.trim().length > 0)));
128
+ return {
129
+ total: approvals.length,
130
+ pending: approvals.filter((approval) => approval.status === "pending").length,
131
+ approved: approvals.filter((approval) => approval.status === "approved").length,
132
+ edited: approvals.filter((approval) => approval.status === "edited").length,
133
+ rejected: approvals.filter((approval) => approval.status === "rejected").length,
134
+ expired: approvals.filter((approval) => approval.status === "expired").length,
135
+ toolNames,
136
+ approvalReasons,
137
+ };
138
+ }
139
+ export function toRequestSummary(summary) {
140
+ return {
141
+ requestId: summary.requestId,
142
+ sessionId: summary.sessionId,
143
+ agentId: summary.agentId,
144
+ parentRequestId: summary.parentRequestId,
145
+ executionMode: summary.executionMode,
146
+ adapterKind: summary.adapterKind,
147
+ createdAt: summary.createdAt,
148
+ updatedAt: summary.updatedAt,
149
+ state: summary.state,
150
+ checkpointRef: summary.checkpointRef,
151
+ resumable: summary.resumable,
152
+ startedAt: summary.startedAt,
153
+ endedAt: summary.endedAt,
154
+ lastActivityAt: summary.lastActivityAt,
155
+ currentAgentId: summary.currentAgentId,
156
+ delegationChain: summary.delegationChain,
157
+ runtimeSnapshot: summary.runtimeSnapshot,
158
+ };
159
+ }
160
+ export function cloneRequestRecord(record) {
161
+ return {
162
+ ...toRequestSummary(record),
163
+ traceItems: record.traceItems,
164
+ runtimeTimeline: record.runtimeTimeline,
165
+ };
166
+ }
167
+ export function cloneSessionRecord(record) {
168
+ return {
169
+ sessionId: record.sessionId,
170
+ entryAgentId: record.entryAgentId,
171
+ currentAgentId: record.currentAgentId,
172
+ currentState: record.currentState,
173
+ latestRequestId: record.latestRequestId,
174
+ createdAt: record.createdAt,
175
+ updatedAt: record.updatedAt,
176
+ messages: record.messages,
177
+ requests: record.requests.map(cloneRequestRecord),
178
+ pendingDecision: record.pendingDecision,
179
+ };
180
+ }
181
+ export function deriveRequestInputFromTranscript(transcript, requestId) {
182
+ const candidate = [...transcript]
183
+ .reverse()
184
+ .find((message) => message.role === "user" && (!requestId || message.requestId === requestId));
185
+ return candidate ? { input: candidate.content } : null;
186
+ }
@@ -1,5 +1,5 @@
1
- import { readSkillMetadata } from "../../support/skill-metadata.js";
2
- import { createUpstreamTimelineReducer } from "../../../upstream-events.js";
1
+ import { readSkillMetadata } from "../../skills/skill-metadata.js";
2
+ import { createUpstreamTimelineReducer } from "../../../projections/upstream-events.js";
3
3
  import { formatAgentName } from "../../../utils/agent-display.js";
4
4
  import { getBindingMemorySources, getBindingPrimaryModel, getBindingPrimaryTools, getBindingSkills, getBindingSubagents, isDeepAgentBinding, } from "../../support/compiled-binding.js";
5
5
  import { buildRuntimeGovernanceBundles } from "./governance.js";
@@ -1,7 +1,7 @@
1
1
  import { createCheckpointerForConfig, createStoreForConfig } from "../../support/runtime-factories.js";
2
2
  import { resolveCompiledEmbeddingModel, resolveCompiledEmbeddingModelRef } from "../../support/embedding-models.js";
3
3
  import { resolveCompiledVectorStore, resolveCompiledVectorStoreRef } from "../../support/vector-stores.js";
4
- import { resolveRuntimeCheckpointerPath } from "../../support/runtime-layout.js";
4
+ import { resolveRuntimeCheckpointerPath } from "../../layout/runtime-layout.js";
5
5
  export function resolveStoreFromConfig(stores, storeConfig, runtimeRoot) {
6
6
  const cacheKey = storeConfig ? `${runtimeRoot}:${JSON.stringify(storeConfig)}` : undefined;
7
7
  if (!storeConfig || !cacheKey) {
@@ -1,4 +1,4 @@
1
- import { readSkillMetadata } from "../../support/skill-metadata.js";
1
+ import { readSkillMetadata } from "../../skills/skill-metadata.js";
2
2
  import { formatAgentName } from "../../../utils/agent-display.js";
3
3
  import { getBindingMemorySources, getBindingSkills, } from "../../support/compiled-binding.js";
4
4
  function asObject(value) {
@@ -1,5 +1,5 @@
1
1
  import type { CompiledAgentBinding, WorkspaceBundle } from "../../../contracts/types.js";
2
- import type { OpenClawSkillMetadata } from "../../support/skill-metadata.js";
2
+ import type { OpenClawSkillMetadata } from "../../skills/skill-metadata.js";
3
3
  import { type RequirementAssessmentOptions, type SkillRequirementAssessment } from "./skill-requirements.js";
4
4
  export type InventoryToolRecord = {
5
5
  name: string;
@@ -1,7 +1,7 @@
1
- import { readSkillMetadata } from "../../support/skill-metadata.js";
1
+ import { readSkillMetadata } from "../../skills/skill-metadata.js";
2
2
  import { getBindingBackendConfig, getBindingPrimaryModel, getBindingPrimaryTools, getBindingSkills, getBindingSubagents, } from "../../support/compiled-binding.js";
3
3
  import { assessSkillRequirements, } from "./skill-requirements.js";
4
- import { createRuntimeEnv } from "../../support/runtime-env.js";
4
+ import { createRuntimeEnv } from "../../env/runtime-env.js";
5
5
  function listHostBindings(workspace) {
6
6
  return Array.from(workspace.bindings.values());
7
7
  }
@@ -1,4 +1,4 @@
1
- import { getPolicyEvaluators } from "../../../extensions.js";
1
+ import { getPolicyEvaluators } from "../../../tooling/extensions.js";
2
2
  export class PolicyEngine {
3
3
  /**
4
4
  * Runtime governance gate for a compiled binding.
@@ -4,7 +4,7 @@ import { createResolvedModel } from "../../adapter/model/model-providers.js";
4
4
  import { FileBackedStore } from "./store.js";
5
5
  import { compileModel } from "../../../workspace/resource-compilers.js";
6
6
  import { resolvePromptValue, resolveRefId } from "../../../workspace/support/workspace-ref-utils.js";
7
- import { renderRuntimeMemoryManagerPrompt, renderRuntimeMemoryMutationReconciliationPrompt } from "../../support/runtime-prompts.js";
7
+ import { renderRuntimeMemoryManagerPrompt, renderRuntimeMemoryMutationReconciliationPrompt } from "../../prompts/runtime-prompts.js";
8
8
  const FORMATION_EVENT_TYPES = new Set([
9
9
  "request.state.changed",
10
10
  "approval.resolved",
@@ -1,4 +1,4 @@
1
- import type { OpenClawSkillMetadata, SkillMetadata } from "../../support/skill-metadata.js";
1
+ import type { OpenClawSkillMetadata, SkillMetadata } from "../../skills/skill-metadata.js";
2
2
  export type RequirementStatus = "satisfied" | "missing" | "unknown";
3
3
  export type RequirementCheckRecord = {
4
4
  name: string;
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { existsSync } from "node:fs";
3
- import { augmentExecutablePath } from "../../support/runtime-env.js";
3
+ import { augmentExecutablePath } from "../../env/runtime-env.js";
4
4
  function dedupe(items) {
5
5
  return Array.from(new Set(items.filter(Boolean)));
6
6
  }
@@ -64,8 +64,8 @@ export declare class AgentHarnessRuntime {
64
64
  private createPrepareRunStartRuntime;
65
65
  private buildFunctionToolContext;
66
66
  constructor(workspace: WorkspaceBundle, runtimeAdapterOptions?: RuntimeAdapterOptions);
67
- manageSchedule(input: Parameters<SystemScheduleManager["manageSchedule"]>[0]): Promise<import("../contracts/runtime.js").RuntimeScheduleManageResult>;
68
- getSchedule(scheduleId: string): Promise<import("../contracts/runtime.js").RuntimeScheduleRecord | null>;
67
+ manageSchedule(input: Parameters<SystemScheduleManager["manageSchedule"]>[0]): Promise<import("../contracts/runtime-scheduling.js").RuntimeScheduleManageResult>;
68
+ getSchedule(scheduleId: string): Promise<import("../contracts/runtime-scheduling.js").RuntimeScheduleRecord | null>;
69
69
  runScheduledTask(scheduleId: string): Promise<RequestResult>;
70
70
  private createHealthMonitor;
71
71
  private recordLlmSuccess;
@@ -26,25 +26,26 @@ import { dropPendingRequestSlot, enqueuePendingRequestSlot } from "./harness/run
26
26
  import { getDefaultRuntimeEntryAgentId, resolveSelectedAgentId, routeAgentId } from "./harness/run/routing.js";
27
27
  import { resolveStoreFromConfig, resolveVectorStore, } from "./harness/run/resources.js";
28
28
  import { createRuntimeMcpServer, createToolMcpServerFromTools, serveRuntimeMcpOverStdio, serveToolsOverStdioFromHarness, } from "../mcp.js";
29
- import { closeMcpClientsForWorkspace } from "../resource/mcp-tool-support.js";
29
+ import { closeMcpClientsForWorkspace } from "../resource/mcp/tool-support.js";
30
30
  import { getBindingRuntimeExecutionMode, } from "./support/compiled-binding.js";
31
31
  import { bindingSupportsRunningReplay, getWorkspaceBinding, resolveWorkspaceAgentTools, } from "./harness/bindings.js";
32
32
  import { describeWorkspaceInventory, getAgentInventoryRecord, listAgentSkills as listWorkspaceAgentSkills, } from "./harness/system/inventory.js";
33
33
  import { createDefaultHealthSnapshot, isInventoryEnabled, isSessionMemorySyncEnabled, } from "./harness/runtime-defaults.js";
34
+ import { cloneRequestRecord, cloneSessionRecord, deriveRequestInputFromTranscript, mergeMemoryItems, summarizeApprovalEvidence, toPublicHarnessStreamItem, toPublicRequestResultShape, toSessionListSummary, } from "./harness/public-shapes.js";
34
35
  import { Mem0IngestionSync, Mem0SemanticRecall, readMem0RuntimeConfig, } from "./harness/system/mem0-ingestion-sync.js";
35
36
  import { createRuntimeMemoryManager, RuntimeMemoryFormationSync, readRuntimeMemoryFormationConfig, } from "./harness/system/runtime-memory-manager.js";
36
37
  import { readRuntimeMemoryMaintenanceConfig, readRuntimeMemoryPolicyConfig, resolveMemoryNamespace, } from "./harness/system/runtime-memory-policy.js";
37
38
  import { resolveRuntimeAdapterOptions } from "./support/runtime-adapter-options.js";
38
- import { resolveKnowledgeStorePath, resolveProceduralMemoryStorePath } from "./support/runtime-layout.js";
39
+ import { resolveKnowledgeStorePath, resolveProceduralMemoryStorePath } from "./layout/runtime-layout.js";
39
40
  import { SystemScheduleManager } from "./scheduling/system-schedule-manager.js";
40
41
  import { initializeHarnessRuntime, reclaimExpiredClaimedRequests as reclaimHarnessExpiredClaimedRequests, recoverStartupRequests as recoverHarnessStartupRequests, isStaleRunningRequest as isHarnessStaleRunningRequest, } from "./harness/run/startup-runtime.js";
41
42
  import { traceStartupStage } from "./startup-tracing.js";
42
- import { normalizeProcessExecutablePath } from "./support/runtime-env.js";
43
+ import { normalizeProcessExecutablePath } from "./env/runtime-env.js";
43
44
  import { streamHarnessRun } from "./harness/run/stream-run.js";
44
45
  import { defaultRequestedAgentId, prepareRunStart } from "./harness/run/start-run.js";
45
46
  import { buildRequestInspectionRecord, buildSessionInspectionRecord, deleteSessionRecord, getPublicApproval, listPublicApprovals, } from "./harness/run/session-records.js";
46
47
  import { createKnowledgeModule } from "../knowledge/index.js";
47
- import { createProceduralMemoryManager, ProceduralMemoryFormationSync, readProceduralMemoryRuntimeConfig, } from "../procedural/index.js";
48
+ import { createProceduralMemoryManager, ProceduralMemoryFormationSync, readProceduralMemoryRuntimeConfig, } from "../knowledge/procedural/index.js";
48
49
  const ACTIVE_REQUEST_STATES = [
49
50
  "queued",
50
51
  "claimed",
@@ -53,143 +54,6 @@ const ACTIVE_REQUEST_STATES = [
53
54
  "resuming",
54
55
  "cancelling",
55
56
  ];
56
- function toPublicRequestResultShape(result) {
57
- return {
58
- sessionId: result.sessionId ?? result.legacySessionId ?? "",
59
- requestId: result.requestId ?? result.legacyRequestId ?? "",
60
- state: result.state,
61
- output: result.output,
62
- finalMessageText: result.finalMessageText,
63
- outputContent: result.outputContent,
64
- contentBlocks: result.contentBlocks,
65
- structuredResponse: result.structuredResponse,
66
- interruptContent: result.interruptContent,
67
- agentId: result.agentId,
68
- approvalId: result.approvalId,
69
- pendingActionId: result.pendingActionId,
70
- delegationId: result.delegationId,
71
- artifacts: result.artifacts,
72
- metadata: result.metadata,
73
- };
74
- }
75
- function toPublicHarnessStreamItem(item) {
76
- switch (item.type) {
77
- case "commentary":
78
- return {
79
- type: "commentary",
80
- sessionId: item.sessionId,
81
- requestId: item.requestId,
82
- agentId: item.agentId,
83
- content: item.content,
84
- };
85
- case "content":
86
- return {
87
- type: "content",
88
- sessionId: item.sessionId,
89
- requestId: item.requestId,
90
- agentId: item.agentId,
91
- content: item.content,
92
- };
93
- case "content-blocks":
94
- return {
95
- type: "content-blocks",
96
- sessionId: item.sessionId,
97
- requestId: item.requestId,
98
- agentId: item.agentId,
99
- contentBlocks: item.contentBlocks,
100
- };
101
- case "tool-result":
102
- return {
103
- type: "tool-result",
104
- sessionId: item.sessionId,
105
- requestId: item.requestId,
106
- agentId: item.agentId,
107
- toolName: item.toolName,
108
- output: item.output,
109
- ...(item.isError !== undefined ? { isError: item.isError } : {}),
110
- };
111
- case "plan-state":
112
- return {
113
- type: "plan-state",
114
- sessionId: item.sessionId,
115
- requestId: item.requestId,
116
- agentId: item.agentId,
117
- planState: item.planState,
118
- };
119
- case "upstream-event":
120
- return {
121
- type: "upstream-event",
122
- sessionId: item.sessionId,
123
- requestId: item.requestId,
124
- ...(item.surfaceItem ? { surfaceItem: item.surfaceItem } : {}),
125
- event: item.event,
126
- };
127
- case "result":
128
- return {
129
- type: "result",
130
- result: toPublicRequestResultShape(item.result),
131
- };
132
- default:
133
- return item;
134
- }
135
- }
136
- function mergeMemoryItems(...groups) {
137
- const merged = new Map();
138
- for (const group of groups) {
139
- for (const item of group) {
140
- if (!merged.has(item.id)) {
141
- merged.set(item.id, item);
142
- }
143
- }
144
- }
145
- return Array.from(merged.values());
146
- }
147
- function normalizeSessionListText(content, limit) {
148
- if (!content) {
149
- return undefined;
150
- }
151
- const collapsed = extractMessageText(content).replace(/\s+/g, " ").trim();
152
- if (!collapsed) {
153
- return undefined;
154
- }
155
- return collapsed.length > limit ? `${collapsed.slice(0, limit - 1).trimEnd()}…` : collapsed;
156
- }
157
- function toSessionListSummary(session) {
158
- const titleSource = session.firstMessage?.role === "user" ? session.firstMessage : session.lastMessage;
159
- return {
160
- agentId: session.agentId,
161
- entryAgentId: session.entryAgentId,
162
- sessionId: session.sessionId,
163
- latestRequestId: session.latestRequestId,
164
- createdAt: session.createdAt,
165
- updatedAt: session.updatedAt,
166
- status: session.status,
167
- currentAgentId: session.currentAgentId,
168
- messageCount: session.messageCount,
169
- hasVisibleMessages: session.messageCount > 0,
170
- lastMessageRole: session.lastMessage?.role,
171
- title: normalizeSessionListText(titleSource?.content, 72),
172
- snippet: normalizeSessionListText(session.lastMessage?.content, 160),
173
- };
174
- }
175
- function summarizeApprovalEvidence(approvals) {
176
- const toolNames = Array.from(new Set(approvals
177
- .map((approval) => approval.toolName)
178
- .filter((toolName) => typeof toolName === "string" && toolName.trim().length > 0)));
179
- const approvalReasons = Array.from(new Set(approvals
180
- .map((approval) => approval.approvalReason)
181
- .filter((reason) => typeof reason === "string" && reason.trim().length > 0)));
182
- return {
183
- total: approvals.length,
184
- pending: approvals.filter((approval) => approval.status === "pending").length,
185
- approved: approvals.filter((approval) => approval.status === "approved").length,
186
- edited: approvals.filter((approval) => approval.status === "edited").length,
187
- rejected: approvals.filter((approval) => approval.status === "rejected").length,
188
- expired: approvals.filter((approval) => approval.status === "expired").length,
189
- toolNames,
190
- approvalReasons,
191
- };
192
- }
193
57
  export class AgentHarnessRuntime {
194
58
  workspace;
195
59
  runtimeAdapterOptions;
@@ -935,8 +799,8 @@ export class AgentHarnessRuntime {
935
799
  : {}),
936
800
  })));
937
801
  return {
938
- session: session ? toSessionRecord(session) : null,
939
- request: request ? toRequestRecord(request) : null,
802
+ session: session ? cloneSessionRecord(session) : null,
803
+ request: request ? cloneRequestRecord(request) : null,
940
804
  requestInput: requestInput
941
805
  ? {
942
806
  input: requestInput.input,
@@ -1569,51 +1433,3 @@ export class AgentHarnessRuntime {
1569
1433
  }, session, nowMs);
1570
1434
  }
1571
1435
  }
1572
- function toRequestSummary(summary) {
1573
- return {
1574
- requestId: summary.requestId,
1575
- sessionId: summary.sessionId,
1576
- agentId: summary.agentId,
1577
- parentRequestId: summary.parentRequestId,
1578
- executionMode: summary.executionMode,
1579
- adapterKind: summary.adapterKind,
1580
- createdAt: summary.createdAt,
1581
- updatedAt: summary.updatedAt,
1582
- state: summary.state,
1583
- checkpointRef: summary.checkpointRef,
1584
- resumable: summary.resumable,
1585
- startedAt: summary.startedAt,
1586
- endedAt: summary.endedAt,
1587
- lastActivityAt: summary.lastActivityAt,
1588
- currentAgentId: summary.currentAgentId,
1589
- delegationChain: summary.delegationChain,
1590
- runtimeSnapshot: summary.runtimeSnapshot,
1591
- };
1592
- }
1593
- function toSessionRecord(record) {
1594
- return {
1595
- sessionId: record.sessionId,
1596
- entryAgentId: record.entryAgentId,
1597
- currentAgentId: record.currentAgentId,
1598
- currentState: record.currentState,
1599
- latestRequestId: record.latestRequestId,
1600
- createdAt: record.createdAt,
1601
- updatedAt: record.updatedAt,
1602
- messages: record.messages,
1603
- requests: record.requests.map(toRequestRecord),
1604
- pendingDecision: record.pendingDecision,
1605
- };
1606
- }
1607
- function toRequestRecord(record) {
1608
- return {
1609
- ...toRequestSummary(record),
1610
- traceItems: record.traceItems,
1611
- runtimeTimeline: record.runtimeTimeline,
1612
- };
1613
- }
1614
- function deriveRequestInputFromTranscript(transcript, requestId) {
1615
- const candidate = [...transcript]
1616
- .reverse()
1617
- .find((message) => message.role === "user" && (!requestId || message.requestId === requestId));
1618
- return candidate ? { input: candidate.content } : null;
1619
- }
@@ -2,7 +2,7 @@ import path from "node:path";
2
2
  import { stat } from "node:fs/promises";
3
3
  import { createClient } from "@libsql/client";
4
4
  import { fileExists } from "../../utils/fs.js";
5
- import { resolveRuntimeCheckpointerPath } from "../support/runtime-layout.js";
5
+ import { resolveRuntimeCheckpointerPath } from "../layout/runtime-layout.js";
6
6
  import { getRuntimeDefaults } from "../../workspace/support/workspace-ref-utils.js";
7
7
  function asObject(value) {
8
8
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
@@ -2,7 +2,7 @@ import path from "node:path";
2
2
  import { rm } from "node:fs/promises";
3
3
  import { createClient } from "@libsql/client";
4
4
  import { fileExists } from "../../utils/fs.js";
5
- import { resolveRuntimeSqlitePath } from "../support/runtime-layout.js";
5
+ import { resolveRuntimeSqlitePath } from "../layout/runtime-layout.js";
6
6
  import { getRuntimeDefaults } from "../../workspace/support/workspace-ref-utils.js";
7
7
  function asObject(value) {
8
8
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
@@ -0,0 +1,11 @@
1
+ export declare function sanitizeVisibleText(value: string): string;
2
+ export declare function readTextContent(value: unknown): string;
3
+ export declare function hasToolCalls(value: unknown): boolean;
4
+ export declare function containsLikelySkillDocument(value: unknown): boolean;
5
+ export declare function extractToolFallbackContext(value: unknown): string;
6
+ export declare function extractVisibleOutput(value: unknown): string;
7
+ export declare function extractOutputContent(value: unknown): unknown;
8
+ export declare function extractContentBlocks(value: unknown): unknown[];
9
+ export declare function extractEmptyAssistantMessageFailure(value: unknown): string;
10
+ export declare function wrapNormalizedMessage<T>(value: T): T;
11
+ export declare function extractReasoningText(value: unknown): string;