The open-source agent harness - the runtime layer that turns an LLM into a working agent.
Own JsonValue and CapabilityState on AgentCapability.
debajyoti-truefoundry7adeab36f605
diff --git a/packages/harness/src/agent-session/store/ISessionStore.ts b/packages/harness/src/agent-session/store/ISessionStore.tsindex af4b589ad..fc48197e8 100644--- a/packages/harness/src/agent-session/store/ISessionStore.ts+++ b/packages/harness/src/agent-session/store/ISessionStore.ts@@ -1,9 +1,9 @@+import type { JsonValue } from '../../core/capabilities/AgentCapability';import type { MCPServerInitInfo, ThreadOverwriteContextEvent } from '../../core/events/schema';import type { CompletionUsage } from '../../core/llm/LLMTypes';import type {AgentThreadSnapshot,ContextMessage,- JsonValue,SubAgentCompletionMarker,} from '../../core/runtime/AgentThread.types';import type { SandboxInfo } from '../../core/sandbox/Sandbox';diff --git a/packages/harness/src/core/capabilities/AgentCapability.ts b/packages/harness/src/core/capabilities/AgentCapability.tsindex d8bc831b1..959f838f4 100644--- a/packages/harness/src/core/capabilities/AgentCapability.ts+++ b/packages/harness/src/core/capabilities/AgentCapability.ts@@ -1,6 +1,5 @@import type { InstructionBuilder } from '../InstructionBuilder';import type { IToolSet } from '../mcp/IMCPServer';-import type { JsonValue } from '../runtime/AgentThread.types';import type {PostToolCallAgentContextProcessor,PreLLMAgentContextProcessor,@@ -9,6 +8,15 @@ import type {} from './AgentContextProcessor';import type { ToolResponseProcessor } from './ToolResponseProcessor';+/**+ * JSON-serializable value. Excludes `undefined` — durability is jsonb/JSON, so+ * clears use `null` and absent data omits the key or the map.+ */+export type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };++/** Cross-turn capability KV map. Keys: capability.state.key; `tfy.` reserved for builtins. */+export type CapabilityState = Record<string, JsonValue>;+export interface AgentCapability {readonly systemToolSets?: readonly IToolSet[] | undefined;readonly preSendProcessors?: readonly PreSendContextProcessor[] | undefined;diff --git a/packages/harness/src/core/index.ts b/packages/harness/src/core/index.tsindex 07b227960..f3631b248 100644--- a/packages/harness/src/core/index.ts+++ b/packages/harness/src/core/index.ts@@ -23,7 +23,7 @@ export { isAgentInputUserMessage, isEmptyMessageContent, isFileContentPart } froexport type { AgentInputUserMessage } from './runtime/UserInputMessage';// Capability contracts-export type { AgentCapability } from './capabilities/AgentCapability';+export type { AgentCapability, CapabilityState, JsonValue } from './capabilities/AgentCapability';export type {AgentContextProcessorOutput,AgentThreadExecutionContext,@@ -116,7 +116,7 @@ export type {ThreadOverwriteContextEvent,} from './events/schema';export { InternalEventType } from './runtime/AgentThread.types';-export type { AgentThreadSendBatch, CapabilityState, ContextMessage, JsonValue } from './runtime/AgentThread.types';+export type { AgentThreadSendBatch, ContextMessage } from './runtime/AgentThread.types';export type { AgentThreadMetrics } from './runtime/metrics';// Tracingdiff --git a/packages/harness/src/core/runtime/AgentThread.ts b/packages/harness/src/core/runtime/AgentThread.tsindex bb842a3b5..72bb38d04 100644--- a/packages/harness/src/core/runtime/AgentThread.ts+++ b/packages/harness/src/core/runtime/AgentThread.ts@@ -4,7 +4,7 @@ import type {ChatCompletionTool,} from 'openai/resources/chat';import type { Logger } from 'winston';-import type { AgentCapability } from '../capabilities/AgentCapability';+import type { AgentCapability, CapabilityState } from '../capabilities/AgentCapability';import type {AgentContextProcessorOutput,AgentContextProcessorOverwriteContext,@@ -64,7 +64,6 @@ import type {AgentThreadRuntimeSendBatch,AgentThreadRuntimeSendInput,AgentThreadSnapshot,- CapabilityState,} from './AgentThread.types';import {InternalEventType,diff --git a/packages/harness/src/core/runtime/AgentThread.types.ts b/packages/harness/src/core/runtime/AgentThread.types.tsindex 64996de41..dd05418ce 100644--- a/packages/harness/src/core/runtime/AgentThread.types.ts+++ b/packages/harness/src/core/runtime/AgentThread.types.ts@@ -1,6 +1,6 @@import type { Logger } from 'winston';import { z } from 'zod';-import type { AgentCapability } from '../capabilities/AgentCapability';+import type { AgentCapability, CapabilityState, JsonValue } from '../capabilities/AgentCapability';import type { RegisteredPassthroughEvent, WithRegisteredPassthrough } from '../events/PassthroughEvents';import type {ActionRequiredEvent,@@ -49,15 +49,6 @@ export const InternalEventType = {CAPABILITY_STATE: 'internal.capability.state',} as const;-/**- * JSON-serializable value. Excludes `undefined` — durability is jsonb/JSON, so- * clears use `null` and absent data omits the key or the map.- */-export type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };--/** Cross-turn capability KV map. Keys: capability.state.key; `tfy.` reserved for builtins. */-export type CapabilityState = Record<string, JsonValue>;-/*** Cross-turn capability KV write. Processors emit without `thread_id`* ({@link AgentContextProcessorOutput}); AgentThread stamps `thread_id` when yielding.diff --git a/packages/harness/tests/agent-session/capabilityState.test.ts b/packages/harness/tests/agent-session/capabilityState.test.tsindex e3132e05b..d24113fb4 100644--- a/packages/harness/tests/agent-session/capabilityState.test.ts+++ b/packages/harness/tests/agent-session/capabilityState.test.ts@@ -7,10 +7,10 @@ import { MAIN_THREAD_ID } from '../../src/agent-session/models/TurnRecord';import { EventType } from '../../src/agent-session/schemas/events';import { Sessions } from '../../src/agent-session/Sessions';import { InMemorySessionStore } from '../../src/agent-session/store/InMemorySessionStore';-import type { AgentCapability } from '../../src/core/capabilities/AgentCapability';+import type { AgentCapability, JsonValue } from '../../src/core/capabilities/AgentCapability';import type { AgentContextProcessorOutput } from '../../src/core/capabilities/AgentContextProcessor';import { AgentThread } from '../../src/core/runtime/AgentThread';-import { InternalEventType, type JsonValue } from '../../src/core/runtime/AgentThread.types';+import { InternalEventType } from '../../src/core/runtime/AgentThread.types';import { NOOP_AGENT_TRACING } from '../../src/core/tracing/NoopAgentTracing';import { emptyLlmStream, makeAgentSpec, makeMockILLM, makeSilentLogger, makeTestResolver } from './testHelpers';