@contractspec/lib.ai-agent 7.0.10 → 8.0.2
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 +45 -4
- package/dist/agent/agent-factory.d.ts +14 -3
- package/dist/agent/agent-factory.js +653 -113
- package/dist/agent/contract-spec-agent.d.ts +16 -2
- package/dist/agent/contract-spec-agent.js +649 -112
- package/dist/agent/index.js +660 -118
- package/dist/agent/json-runner.d.ts +1 -1
- package/dist/agent/json-runner.js +649 -112
- package/dist/agent/unified-agent.d.ts +2 -2
- package/dist/agent/unified-agent.js +660 -118
- package/dist/approval/index.js +6 -1
- package/dist/approval/workflow.js +5 -1
- package/dist/exporters/claude-agent-exporter.d.ts +1 -1
- package/dist/exporters/claude-agent-exporter.js +3 -51
- package/dist/exporters/index.js +8 -54
- package/dist/exporters/opencode-exporter.d.ts +1 -1
- package/dist/exporters/opencode-exporter.js +3 -51
- package/dist/exporters/types.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3805 -71
- package/dist/interop/index.js +3 -51
- package/dist/interop/spec-consumer.d.ts +1 -1
- package/dist/interop/spec-consumer.js +3 -51
- package/dist/interop/tool-consumer.d.ts +1 -1
- package/dist/interop/types.d.ts +1 -1
- package/dist/knowledge/injector.d.ts +1 -1
- package/dist/node/agent/agent-factory.js +653 -113
- package/dist/node/agent/contract-spec-agent.js +649 -112
- package/dist/node/agent/index.js +660 -118
- package/dist/node/agent/json-runner.js +649 -112
- package/dist/node/agent/unified-agent.js +660 -118
- package/dist/node/approval/index.js +6 -1
- package/dist/node/approval/workflow.js +5 -1
- package/dist/node/exporters/claude-agent-exporter.js +3 -51
- package/dist/node/exporters/index.js +8 -54
- package/dist/node/exporters/opencode-exporter.js +3 -51
- package/dist/node/index.js +3805 -71
- package/dist/node/interop/index.js +3 -51
- package/dist/node/interop/spec-consumer.js +3 -51
- package/dist/node/providers/claude-agent-sdk/adapter.js +3 -51
- package/dist/node/providers/claude-agent-sdk/index.js +3 -51
- package/dist/node/providers/index.js +8 -53
- package/dist/node/providers/opencode-sdk/adapter.js +4 -51
- package/dist/node/providers/opencode-sdk/index.js +4 -51
- package/dist/node/telemetry/adapter.js +2 -0
- package/dist/node/telemetry/index.js +2 -0
- package/dist/providers/claude-agent-sdk/adapter.d.ts +1 -1
- package/dist/providers/claude-agent-sdk/adapter.js +3 -51
- package/dist/providers/claude-agent-sdk/index.js +3 -51
- package/dist/providers/claude-agent-sdk/tool-bridge.d.ts +1 -8
- package/dist/providers/index.js +8 -53
- package/dist/providers/opencode-sdk/adapter.d.ts +1 -13
- package/dist/providers/opencode-sdk/adapter.js +4 -51
- package/dist/providers/opencode-sdk/agent-bridge.d.ts +1 -10
- package/dist/providers/opencode-sdk/index.js +4 -51
- package/dist/providers/opencode-sdk/tool-bridge.d.ts +1 -4
- package/dist/providers/types.d.ts +1 -8
- package/dist/session/store.d.ts +2 -2
- package/dist/telemetry/adapter.d.ts +1 -0
- package/dist/telemetry/adapter.js +2 -0
- package/dist/telemetry/index.js +2 -0
- package/dist/tools/knowledge-tool.d.ts +1 -1
- package/dist/tools/mcp-server.d.ts +1 -1
- package/dist/tools/operation-tool-handler.d.ts +1 -1
- package/dist/tools/tool-adapter.d.ts +1 -1
- package/dist/types.d.ts +13 -0
- package/package.json +7 -43
- package/dist/node/spec/index.js +0 -2233
- package/dist/node/spec/registry.js +0 -2178
- package/dist/node/spec/spec.js +0 -2188
- package/dist/spec/index.d.ts +0 -2
- package/dist/spec/index.js +0 -2233
- package/dist/spec/registry.d.ts +0 -41
- package/dist/spec/registry.js +0 -2178
- package/dist/spec/spec.d.ts +0 -218
- package/dist/spec/spec.js +0 -2188
- package/dist/spec/spec.test.d.ts +0 -1
package/dist/spec/spec.d.ts
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import type { DataViewRef, FormRef, PresentationRef } from '@contractspec/lib.contracts-spec/features';
|
|
2
|
-
import type { KnowledgeCategory } from '@contractspec/lib.contracts-spec/knowledge/spec';
|
|
3
|
-
import type { OwnerShipMeta } from '@contractspec/lib.contracts-spec/ownership';
|
|
4
|
-
import type { PolicyRef } from '@contractspec/lib.contracts-spec/policy/spec';
|
|
5
|
-
/**
|
|
6
|
-
* Metadata for an agent specification.
|
|
7
|
-
*/
|
|
8
|
-
export type AgentMeta = OwnerShipMeta;
|
|
9
|
-
export type AgentRuntimeAdapterKey = 'langgraph' | 'langchain' | 'workflow-devkit';
|
|
10
|
-
export interface AgentRuntimeCapabilities {
|
|
11
|
-
/** Optional external adapter availability map for runtime interoperability. */
|
|
12
|
-
adapters?: Partial<Record<AgentRuntimeAdapterKey, boolean>>;
|
|
13
|
-
/** Whether the agent should persist checkpoints for replay/resume. */
|
|
14
|
-
checkpointing?: boolean;
|
|
15
|
-
/** Whether the agent supports external suspend/resume semantics. */
|
|
16
|
-
suspendResume?: boolean;
|
|
17
|
-
/** Whether the agent can delegate approvals to external gateways. */
|
|
18
|
-
approvalGateway?: boolean;
|
|
19
|
-
}
|
|
20
|
-
export interface AgentRuntimePorts {
|
|
21
|
-
/** Symbolic checkpoint store adapter identifier. */
|
|
22
|
-
checkpointStore?: string;
|
|
23
|
-
/** Symbolic suspend/resume adapter identifier. */
|
|
24
|
-
suspension?: string;
|
|
25
|
-
/** Symbolic retry classifier identifier. */
|
|
26
|
-
retryClassifier?: string;
|
|
27
|
-
/** Symbolic approval gateway identifier. */
|
|
28
|
-
approvalGateway?: string;
|
|
29
|
-
}
|
|
30
|
-
export interface AgentRuntimeConfig {
|
|
31
|
-
capabilities?: AgentRuntimeCapabilities;
|
|
32
|
-
ports?: AgentRuntimePorts;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Reference to a ContractSpec operation that backs an agent tool.
|
|
36
|
-
* When set, the tool is a projection of the operation (one contract → REST, GraphQL, MCP, agent).
|
|
37
|
-
*/
|
|
38
|
-
export interface OperationRef {
|
|
39
|
-
/** Operation key (e.g., "knowledge.search") */
|
|
40
|
-
key: string;
|
|
41
|
-
/** Optional specific version; defaults to latest when omitted */
|
|
42
|
-
version?: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Reference to a subagent that backs an agent tool.
|
|
46
|
-
* When set, the tool delegates to the subagent; mutually exclusive with operationRef and manual handler.
|
|
47
|
-
*/
|
|
48
|
-
export interface SubagentRef {
|
|
49
|
-
/** Subagent identifier (resolved from subagent registry) */
|
|
50
|
-
agentId: string;
|
|
51
|
-
/** Whether to extract summary for toModelOutput (default: true) */
|
|
52
|
-
toModelSummary?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Pass full conversation history to subagent (opt-in).
|
|
55
|
-
* Defeats context isolation; use sparingly. Requires subagent to support generate({ messages }).
|
|
56
|
-
* Streaming is disabled when history is passed.
|
|
57
|
-
*/
|
|
58
|
-
passConversationHistory?: boolean;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Configuration for a tool that an agent can use.
|
|
62
|
-
*/
|
|
63
|
-
export interface AgentToolConfig {
|
|
64
|
-
/** Tool name (unique within the agent) */
|
|
65
|
-
name: string;
|
|
66
|
-
/**
|
|
67
|
-
* Reference to a ContractSpec operation. When set, the tool is backed by the operation:
|
|
68
|
-
* schema and handler are derived from the operation; no manual handler needed.
|
|
69
|
-
*/
|
|
70
|
-
operationRef?: OperationRef;
|
|
71
|
-
/**
|
|
72
|
-
* Reference to a subagent. When set, the tool delegates to the subagent.
|
|
73
|
-
* Mutually exclusive with operationRef; requires subagentRegistry in agent config.
|
|
74
|
-
*/
|
|
75
|
-
subagentRef?: SubagentRef;
|
|
76
|
-
/** Human-readable description for the LLM */
|
|
77
|
-
description?: string;
|
|
78
|
-
/** JSON Schema fragment for tool parameters (fallback when no operationRef) */
|
|
79
|
-
schema?: Record<string, unknown>;
|
|
80
|
-
/** Optional cooldown in milliseconds between invocations */
|
|
81
|
-
cooldownMs?: number;
|
|
82
|
-
/** Maximum execution time before timeout */
|
|
83
|
-
timeoutMs?: number;
|
|
84
|
-
/** Whether the tool can be executed without human approval (AI SDK needsApproval = !automationSafe) */
|
|
85
|
-
automationSafe?: boolean;
|
|
86
|
-
/** Explicit approval requirement (overrides automationSafe) */
|
|
87
|
-
requiresApproval?: boolean;
|
|
88
|
-
/** Optional policy guard that must evaluate to allow the tool call */
|
|
89
|
-
policy?: PolicyRef;
|
|
90
|
-
/**
|
|
91
|
-
* When set, wrap raw output as { presentationKey, data } for ToolResultRenderer.
|
|
92
|
-
* At most one of outputPresentation, outputForm, outputDataView per tool.
|
|
93
|
-
*/
|
|
94
|
-
outputPresentation?: PresentationRef;
|
|
95
|
-
/**
|
|
96
|
-
* When set, wrap raw output as { formKey, defaultValues } for ToolResultRenderer.
|
|
97
|
-
* At most one of outputPresentation, outputForm, outputDataView per tool.
|
|
98
|
-
*/
|
|
99
|
-
outputForm?: FormRef;
|
|
100
|
-
/**
|
|
101
|
-
* When set, wrap raw output as { dataViewKey, items } for ToolResultRenderer.
|
|
102
|
-
* At most one of outputPresentation, outputForm, outputDataView per tool.
|
|
103
|
-
*/
|
|
104
|
-
outputDataView?: DataViewRef;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Reference to a knowledge space that the agent can access.
|
|
108
|
-
*/
|
|
109
|
-
export interface AgentKnowledgeRef {
|
|
110
|
-
/** Knowledge space key */
|
|
111
|
-
key: string;
|
|
112
|
-
/** Optional specific version */
|
|
113
|
-
version?: number;
|
|
114
|
-
/** Filter by knowledge category */
|
|
115
|
-
category?: KnowledgeCategory;
|
|
116
|
-
/** Whether the knowledge is required (static injection) or optional (dynamic RAG) */
|
|
117
|
-
required?: boolean;
|
|
118
|
-
/** Additional instructions appended when the space is available */
|
|
119
|
-
instructions?: string;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Memory configuration for agent session persistence.
|
|
123
|
-
*/
|
|
124
|
-
export interface AgentMemoryConfig {
|
|
125
|
-
/** Maximum entries to keep in memory */
|
|
126
|
-
maxEntries?: number;
|
|
127
|
-
/** Time-to-live in minutes */
|
|
128
|
-
ttlMinutes?: number;
|
|
129
|
-
/** Number of messages before triggering summarization */
|
|
130
|
-
summaryTrigger?: number;
|
|
131
|
-
/** Whether to persist to long-term storage */
|
|
132
|
-
persistLongTerm?: boolean;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Memory tools config — model-accessible CRUD (Anthropic memory, custom).
|
|
136
|
-
* Distinct from AgentMemoryConfig (session summarization).
|
|
137
|
-
*
|
|
138
|
-
* @see https://ai-sdk.dev/docs/agents/memory
|
|
139
|
-
*/
|
|
140
|
-
export interface AgentMemoryToolsConfig {
|
|
141
|
-
/** Provider: anthropic uses memory_20250818; custom uses operationRef. */
|
|
142
|
-
provider: 'anthropic' | 'custom';
|
|
143
|
-
/** Storage adapter key when using knowledge-backed storage (e.g. ephemeral space) */
|
|
144
|
-
storageAdapter?: string;
|
|
145
|
-
/** Ephemeral KnowledgeSpaceSpec key when using knowledge-backed storage */
|
|
146
|
-
spaceKey?: string;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Confidence policy for agent responses.
|
|
150
|
-
*/
|
|
151
|
-
export interface AgentConfidencePolicy {
|
|
152
|
-
/** Minimum acceptable confidence before escalation. Defaults to 0.7 */
|
|
153
|
-
min?: number;
|
|
154
|
-
/** Default value used when provider does not report confidence */
|
|
155
|
-
default?: number;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Escalation policy for handling uncertain or failed agent responses.
|
|
159
|
-
*/
|
|
160
|
-
export interface AgentEscalationPolicy {
|
|
161
|
-
/** Auto escalate when confidence < threshold */
|
|
162
|
-
confidenceThreshold?: number;
|
|
163
|
-
/** Escalate when a tool throws irrecoverable errors */
|
|
164
|
-
onToolFailure?: boolean;
|
|
165
|
-
/** Escalate when iteration budget exceeded */
|
|
166
|
-
onTimeout?: boolean;
|
|
167
|
-
/** Optional human approval workflow ID */
|
|
168
|
-
approvalWorkflow?: string;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Combined policy configuration for an agent.
|
|
172
|
-
*/
|
|
173
|
-
export interface AgentPolicy {
|
|
174
|
-
confidence?: AgentConfidencePolicy;
|
|
175
|
-
escalation?: AgentEscalationPolicy;
|
|
176
|
-
/** Feature flags to apply to this agent */
|
|
177
|
-
flags?: string[];
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Complete specification for a ContractSpec agent.
|
|
181
|
-
*/
|
|
182
|
-
export interface AgentSpec {
|
|
183
|
-
meta: AgentMeta;
|
|
184
|
-
/** System instructions for the agent */
|
|
185
|
-
instructions: string;
|
|
186
|
-
/** Human-readable description */
|
|
187
|
-
description?: string;
|
|
188
|
-
/** Tags for categorization */
|
|
189
|
-
tags?: string[];
|
|
190
|
-
/** Default locale for the agent (e.g., 'en', 'fr'). Falls back to 'en' if unset. */
|
|
191
|
-
locale?: string;
|
|
192
|
-
/** Tools the agent can use */
|
|
193
|
-
tools: AgentToolConfig[];
|
|
194
|
-
/** Memory/session configuration */
|
|
195
|
-
memory?: AgentMemoryConfig;
|
|
196
|
-
/** Memory tools (model-accessible CRUD) — Anthropic or custom operation-backed */
|
|
197
|
-
memoryTools?: AgentMemoryToolsConfig;
|
|
198
|
-
/** Knowledge spaces the agent can access */
|
|
199
|
-
knowledge?: AgentKnowledgeRef[];
|
|
200
|
-
/** Policy configuration */
|
|
201
|
-
policy?: AgentPolicy;
|
|
202
|
-
/** Runtime adapter and portability config. */
|
|
203
|
-
runtime?: AgentRuntimeConfig;
|
|
204
|
-
/** Maximum steps per generation (defaults to 10) */
|
|
205
|
-
maxSteps?: number;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Define and validate an agent specification.
|
|
209
|
-
*
|
|
210
|
-
* @param spec - The agent specification
|
|
211
|
-
* @returns The frozen, validated specification
|
|
212
|
-
* @throws Error if the specification is invalid
|
|
213
|
-
*/
|
|
214
|
-
export declare function defineAgent(spec: AgentSpec): AgentSpec;
|
|
215
|
-
/**
|
|
216
|
-
* Generate a unique key for an agent spec.
|
|
217
|
-
*/
|
|
218
|
-
export declare function agentKey(meta: AgentMeta): string;
|