@botbotgo/agent-harness 0.0.145 → 0.0.147
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/README.md +27 -1
- package/dist/api.d.ts +10 -1
- package/dist/api.js +16 -0
- package/dist/contracts/runtime.d.ts +7 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/runtime/harness/run/inspection.d.ts +3 -1
- package/dist/runtime/harness/run/inspection.js +32 -1
- package/dist/runtime/harness/run/start-run.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -346,7 +346,33 @@ Use `invocation` as the runtime-facing request envelope:
|
|
|
346
346
|
|
|
347
347
|
- `invocation.context` for request-scoped execution context
|
|
348
348
|
- `invocation.inputs` for structured runtime inputs
|
|
349
|
-
- `invocation.attachments` for
|
|
349
|
+
- `invocation.attachments` for auxiliary invocation-scoped attachment payloads that the active backend can interpret
|
|
350
|
+
|
|
351
|
+
For multimodal chat turns, keep the user-visible content in `input`.
|
|
352
|
+
|
|
353
|
+
- if the product would show the image or text in the chat transcript, it belongs in `input`
|
|
354
|
+
- if the payload is auxiliary run-scoped data rather than the chat turn itself, it belongs in `invocation.attachments`
|
|
355
|
+
- persistence, replay, and transcript inspection should treat `input` as the source of truth for user-visible multimodal chat content
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
import { normalizeUserChatInput, run } from "@botbotgo/agent-harness";
|
|
359
|
+
|
|
360
|
+
const result = await run(
|
|
361
|
+
runtime,
|
|
362
|
+
{
|
|
363
|
+
agentId: "orchestra",
|
|
364
|
+
...normalizeUserChatInput({
|
|
365
|
+
role: "user",
|
|
366
|
+
content: [
|
|
367
|
+
{ type: "text", text: "Describe the image and call out any risks." },
|
|
368
|
+
{ type: "image_url", image_url: "data:image/png;base64,..." },
|
|
369
|
+
],
|
|
370
|
+
}),
|
|
371
|
+
},
|
|
372
|
+
);
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Use `normalizeUserChatInput(...)` when a product already has chat-style user messages and wants to project one user turn onto the stable `run(..., { input, invocation })` surface without introducing a separate harness-owned chat API.
|
|
350
376
|
|
|
351
377
|
### Let The Runtime Route
|
|
352
378
|
|
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CancelOptions, RequestRecord, RequestSummary, ResumeOptions, RunDecisionOptions, RunResult, RunStartOptions, RuntimeHealthSnapshot, RuntimeAdapterOptions, SessionRecord, SessionSummary, WorkspaceLoadOptions } from "./contracts/types.js";
|
|
1
|
+
import type { CancelOptions, InvocationEnvelope, MessageContent, RequestRecord, RequestSummary, ResumeOptions, RunDecisionOptions, RunResult, RunStartOptions, RuntimeHealthSnapshot, RuntimeAdapterOptions, SessionRecord, SessionSummary, WorkspaceLoadOptions } from "./contracts/types.js";
|
|
2
2
|
import { AgentHarnessRuntime } from "./runtime/harness.js";
|
|
3
3
|
import type { InventoryAgentRecord, InventorySkillRecord } from "./runtime/harness/system/inventory.js";
|
|
4
4
|
import type { RequirementAssessmentOptions } from "./runtime/harness/system/skill-requirements.js";
|
|
@@ -34,6 +34,14 @@ type PublicRunResult = Omit<RunResult, "threadId" | "runId"> & {
|
|
|
34
34
|
sessionId: string;
|
|
35
35
|
requestId: string;
|
|
36
36
|
};
|
|
37
|
+
export type UserChatMessage = {
|
|
38
|
+
role: "user";
|
|
39
|
+
content: MessageContent;
|
|
40
|
+
};
|
|
41
|
+
export type UserChatInput = MessageContent | UserChatMessage;
|
|
42
|
+
export type NormalizeUserChatInputOptions = {
|
|
43
|
+
invocation?: InvocationEnvelope;
|
|
44
|
+
};
|
|
37
45
|
type CreateAgentHarnessOptions = {
|
|
38
46
|
/**
|
|
39
47
|
* Workspace loading behavior.
|
|
@@ -44,6 +52,7 @@ type CreateAgentHarnessOptions = {
|
|
|
44
52
|
};
|
|
45
53
|
export declare function createAgentHarness(): Promise<AgentHarnessRuntime>;
|
|
46
54
|
export declare function createAgentHarness(workspaceRoot: string, options?: CreateAgentHarnessOptions): Promise<AgentHarnessRuntime>;
|
|
55
|
+
export declare function normalizeUserChatInput(input: UserChatInput, options?: NormalizeUserChatInputOptions): Pick<RunStartOptions, "input" | "invocation">;
|
|
47
56
|
export declare function run(runtime: AgentHarnessRuntime, options: PublicRunOptions): Promise<PublicRunResult>;
|
|
48
57
|
export declare function subscribe(runtime: AgentHarnessRuntime, listener: Parameters<AgentHarnessRuntime["subscribe"]>[0]): () => void;
|
|
49
58
|
export declare function listSessions(runtime: AgentHarnessRuntime, filter?: Parameters<AgentHarnessRuntime["listThreads"]>[0]): Promise<SessionSummary[]>;
|
package/dist/api.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AgentHarnessRuntime } from "./runtime/harness.js";
|
|
2
|
+
import { normalizeMessageContent } from "./utils/message-content.js";
|
|
2
3
|
import { loadWorkspace } from "./workspace/compile.js";
|
|
3
4
|
export { AgentHarnessRuntime } from "./runtime/harness.js";
|
|
4
5
|
export { createUpstreamTimelineReducer } from "./upstream-events.js";
|
|
@@ -118,6 +119,12 @@ export async function createAgentHarness(workspaceRoot = process.cwd(), options
|
|
|
118
119
|
await harness.initialize();
|
|
119
120
|
return harness;
|
|
120
121
|
}
|
|
122
|
+
export function normalizeUserChatInput(input, options = {}) {
|
|
123
|
+
const content = typeof input === "object" && input !== null && "role" in input
|
|
124
|
+
? normalizeUserChatMessage(input).content
|
|
125
|
+
: normalizeMessageContent(input);
|
|
126
|
+
return options.invocation ? { input: content, invocation: options.invocation } : { input: content };
|
|
127
|
+
}
|
|
121
128
|
export async function run(runtime, options) {
|
|
122
129
|
return toPublicRunResult(await runtime.run(toInternalRunOptions(options)));
|
|
123
130
|
}
|
|
@@ -186,3 +193,12 @@ export async function createToolMcpServer(runtime, options) {
|
|
|
186
193
|
export async function serveToolsOverStdio(runtime, options) {
|
|
187
194
|
return runtime.serveToolsOverStdio(options);
|
|
188
195
|
}
|
|
196
|
+
function normalizeUserChatMessage(message) {
|
|
197
|
+
if (message.role !== "user") {
|
|
198
|
+
throw new Error("normalizeUserChatInput only accepts user-role chat messages.");
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
role: "user",
|
|
202
|
+
content: normalizeMessageContent(message.content),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
@@ -90,12 +90,19 @@ export type RuntimeSnapshotSkill = {
|
|
|
90
90
|
path: string;
|
|
91
91
|
description?: string;
|
|
92
92
|
};
|
|
93
|
+
export type RuntimeSnapshotTracing = {
|
|
94
|
+
enabled: boolean;
|
|
95
|
+
correlationId: string;
|
|
96
|
+
tags?: string[];
|
|
97
|
+
metadata?: Record<string, unknown>;
|
|
98
|
+
};
|
|
93
99
|
export type RuntimeSnapshot = {
|
|
94
100
|
agentId: string;
|
|
95
101
|
model?: RuntimeSnapshotModel;
|
|
96
102
|
tools: RuntimeSnapshotTool[];
|
|
97
103
|
skills: RuntimeSnapshotSkill[];
|
|
98
104
|
memory: string[];
|
|
105
|
+
tracing?: RuntimeSnapshotTracing;
|
|
99
106
|
};
|
|
100
107
|
export type MemoryCandidate = {
|
|
101
108
|
content: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { AgentHarnessRuntime, cancelRun, createAgentHarness, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, getAgent, getApproval, getRequest, getHealth, getSession, listAgentSkills, listApprovals, listRequests, listSessions, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
|
|
1
|
+
export { AgentHarnessRuntime, cancelRun, createAgentHarness, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, getAgent, getApproval, getRequest, getHealth, getSession, listAgentSkills, listApprovals, listRequests, listSessions, normalizeUserChatInput, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
|
|
2
|
+
export type { NormalizeUserChatInputOptions, UserChatInput, UserChatMessage } from "./api.js";
|
|
2
3
|
export type { ToolMcpServerOptions } from "./mcp.js";
|
|
3
4
|
export { tool } from "./tools.js";
|
|
4
5
|
export type { UpstreamTimelineProjection, UpstreamTimelineReducer } from "./upstream-events.js";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AgentHarnessRuntime, cancelRun, createAgentHarness, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, getAgent, getApproval, getRequest, getHealth, getSession, listAgentSkills, listApprovals, listRequests, listSessions, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
|
|
1
|
+
export { AgentHarnessRuntime, cancelRun, createAgentHarness, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, getAgent, getApproval, getRequest, getHealth, getSession, listAgentSkills, listApprovals, listRequests, listSessions, normalizeUserChatInput, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
|
|
2
2
|
export { tool } from "./tools.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.146";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.146";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { CompiledAgentBinding, RuntimeSnapshot } from "../../../contracts/types.js";
|
|
2
|
-
export declare function buildRunRuntimeSnapshot(binding: CompiledAgentBinding
|
|
2
|
+
export declare function buildRunRuntimeSnapshot(binding: CompiledAgentBinding, options?: {
|
|
3
|
+
runId?: string;
|
|
4
|
+
}): RuntimeSnapshot;
|
|
3
5
|
export declare function consumeRunInspectionUpstreamEvent(input: {
|
|
4
6
|
event: unknown;
|
|
5
7
|
currentAgentId: string;
|
|
@@ -6,8 +6,38 @@ function asObject(value) {
|
|
|
6
6
|
function readStringArray(value) {
|
|
7
7
|
return Array.isArray(value) ? value.filter((item) => typeof item === "string" && item.trim().length > 0) : [];
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
function readTracingConfig(binding) {
|
|
10
|
+
const deepAgentTracing = asObject(binding.harnessRuntime?.deepagent?.passthrough)?.tracing;
|
|
11
|
+
const langchainTracing = asObject(binding.harnessRuntime?.langchain?.passthrough)?.tracing;
|
|
12
|
+
const legacyDeepAgentTracing = asObject(binding.deepAgentParams?.passthrough)?.tracing;
|
|
13
|
+
const legacyLangChainTracing = asObject(binding.langchainAgentParams?.passthrough)?.tracing;
|
|
14
|
+
return (asObject(langchainTracing) ??
|
|
15
|
+
asObject(deepAgentTracing) ??
|
|
16
|
+
asObject(legacyLangChainTracing) ??
|
|
17
|
+
asObject(legacyDeepAgentTracing) ??
|
|
18
|
+
null);
|
|
19
|
+
}
|
|
20
|
+
function buildRuntimeSnapshotTracing(binding, runId) {
|
|
21
|
+
const tracing = readTracingConfig(binding);
|
|
22
|
+
if (!tracing) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const enabled = tracing.enabled !== false;
|
|
26
|
+
if (!enabled || !runId) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const tags = readStringArray(tracing.tags);
|
|
30
|
+
const metadata = asObject(tracing.metadata);
|
|
31
|
+
return {
|
|
32
|
+
enabled: true,
|
|
33
|
+
correlationId: runId,
|
|
34
|
+
...(tags.length > 0 ? { tags } : {}),
|
|
35
|
+
...(metadata && Object.keys(metadata).length > 0 ? { metadata: { ...metadata } } : {}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function buildRunRuntimeSnapshot(binding, options) {
|
|
10
39
|
const model = getBindingPrimaryModel(binding);
|
|
40
|
+
const tracing = buildRuntimeSnapshotTracing(binding, options?.runId);
|
|
11
41
|
const init = typeof model?.init === "object" && model.init ? model.init : {};
|
|
12
42
|
const baseUrl = typeof init.baseUrl === "string" && init.baseUrl.trim().length > 0
|
|
13
43
|
? init.baseUrl.trim()
|
|
@@ -37,6 +67,7 @@ export function buildRunRuntimeSnapshot(binding) {
|
|
|
37
67
|
};
|
|
38
68
|
}),
|
|
39
69
|
memory: getBindingMemorySources(binding),
|
|
70
|
+
...(tracing ? { tracing } : {}),
|
|
40
71
|
};
|
|
41
72
|
}
|
|
42
73
|
function maybeAppendAgent(chain, agentId) {
|
|
@@ -14,7 +14,7 @@ export async function ensureThreadStarted(runtime, input) {
|
|
|
14
14
|
const startedAt = createdAt;
|
|
15
15
|
const currentAgentId = selectedAgentId;
|
|
16
16
|
const delegationChain = [selectedAgentId];
|
|
17
|
-
const runtimeSnapshot = buildRunRuntimeSnapshot(binding);
|
|
17
|
+
const runtimeSnapshot = buildRunRuntimeSnapshot(binding, { runId });
|
|
18
18
|
const userMessage = {
|
|
19
19
|
role: "user",
|
|
20
20
|
content: normalizeMessageContent(message),
|