@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/approval/index.js
CHANGED
|
@@ -2132,7 +2132,6 @@ var init_i18n = __esm(() => {
|
|
|
2132
2132
|
});
|
|
2133
2133
|
|
|
2134
2134
|
// src/approval/workflow.ts
|
|
2135
|
-
init_i18n();
|
|
2136
2135
|
import { randomUUID } from "crypto";
|
|
2137
2136
|
|
|
2138
2137
|
class InMemoryApprovalStore {
|
|
@@ -2270,6 +2269,12 @@ function createApprovalWorkflow(store) {
|
|
|
2270
2269
|
const options = store;
|
|
2271
2270
|
return new ApprovalWorkflow(new InMemoryApprovalStore(options));
|
|
2272
2271
|
}
|
|
2272
|
+
var init_workflow = __esm(() => {
|
|
2273
|
+
init_i18n();
|
|
2274
|
+
});
|
|
2275
|
+
|
|
2276
|
+
// src/approval/index.ts
|
|
2277
|
+
init_workflow();
|
|
2273
2278
|
export {
|
|
2274
2279
|
createApprovalWorkflow,
|
|
2275
2280
|
InMemoryApprovalStore,
|
|
@@ -2132,7 +2132,6 @@ var init_i18n = __esm(() => {
|
|
|
2132
2132
|
});
|
|
2133
2133
|
|
|
2134
2134
|
// src/approval/workflow.ts
|
|
2135
|
-
init_i18n();
|
|
2136
2135
|
import { randomUUID } from "crypto";
|
|
2137
2136
|
|
|
2138
2137
|
class InMemoryApprovalStore {
|
|
@@ -2270,6 +2269,11 @@ function createApprovalWorkflow(store) {
|
|
|
2270
2269
|
const options = store;
|
|
2271
2270
|
return new ApprovalWorkflow(new InMemoryApprovalStore(options));
|
|
2272
2271
|
}
|
|
2272
|
+
var init_workflow = __esm(() => {
|
|
2273
|
+
init_i18n();
|
|
2274
|
+
});
|
|
2275
|
+
init_workflow();
|
|
2276
|
+
|
|
2273
2277
|
export {
|
|
2274
2278
|
createApprovalWorkflow,
|
|
2275
2279
|
InMemoryApprovalStore,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Exports ContractSpec AgentSpec definitions to formats compatible with
|
|
5
5
|
* @anthropic-ai/claude-agent-sdk and Claude Code CLI.
|
|
6
6
|
*/
|
|
7
|
-
import type
|
|
7
|
+
import { type AgentSpec } from '@contractspec/lib.contracts-spec/agent';
|
|
8
8
|
import type { ClaudeAgentExportOptions, ClaudeAgentExportResult, Exporter } from './types';
|
|
9
9
|
/**
|
|
10
10
|
* Claude Agent SDK Exporter.
|
|
@@ -2131,59 +2131,11 @@ var init_i18n = __esm(() => {
|
|
|
2131
2131
|
init_messages();
|
|
2132
2132
|
});
|
|
2133
2133
|
|
|
2134
|
-
// src/spec/spec.ts
|
|
2135
|
-
function defineAgent(spec) {
|
|
2136
|
-
const i18n = createAgentI18n(spec.locale);
|
|
2137
|
-
if (!spec.meta?.key) {
|
|
2138
|
-
throw new Error(i18n.t("error.agentKeyRequired"));
|
|
2139
|
-
}
|
|
2140
|
-
if (typeof spec.meta.version !== "string") {
|
|
2141
|
-
throw new Error(i18n.t("error.agentMissingVersion", { key: spec.meta.key }));
|
|
2142
|
-
}
|
|
2143
|
-
if (!spec.instructions?.trim()) {
|
|
2144
|
-
throw new Error(i18n.t("error.agentRequiresInstructions", { key: spec.meta.key }));
|
|
2145
|
-
}
|
|
2146
|
-
if (!spec.tools?.length) {
|
|
2147
|
-
throw new Error(i18n.t("error.agentRequiresTool", { key: spec.meta.key }));
|
|
2148
|
-
}
|
|
2149
|
-
for (const [portName, portRef] of Object.entries(spec.runtime?.ports ?? {})) {
|
|
2150
|
-
if (portRef !== undefined && portRef.trim().length === 0) {
|
|
2151
|
-
throw new Error(`Agent ${spec.meta.key} has invalid runtime config: port "${portName}" must not be empty`);
|
|
2152
|
-
}
|
|
2153
|
-
}
|
|
2154
|
-
const toolNames = new Set;
|
|
2155
|
-
for (const tool of spec.tools) {
|
|
2156
|
-
if (toolNames.has(tool.name)) {
|
|
2157
|
-
throw new Error(i18n.t("error.agentDuplicateTool", {
|
|
2158
|
-
key: spec.meta.key,
|
|
2159
|
-
name: tool.name
|
|
2160
|
-
}));
|
|
2161
|
-
}
|
|
2162
|
-
toolNames.add(tool.name);
|
|
2163
|
-
if (tool.subagentRef && tool.operationRef) {
|
|
2164
|
-
throw new Error(`Agent ${spec.meta.key} tool "${tool.name}" cannot have both subagentRef and operationRef. Use one.`);
|
|
2165
|
-
}
|
|
2166
|
-
const outputRefCount = [
|
|
2167
|
-
tool.outputPresentation,
|
|
2168
|
-
tool.outputForm,
|
|
2169
|
-
tool.outputDataView
|
|
2170
|
-
].filter(Boolean).length;
|
|
2171
|
-
if (outputRefCount > 1) {
|
|
2172
|
-
throw new Error(`Agent ${spec.meta.key} tool "${tool.name}" has multiple output refs (outputPresentation, outputForm, outputDataView). Use at most one.`);
|
|
2173
|
-
}
|
|
2174
|
-
}
|
|
2175
|
-
return Object.freeze(spec);
|
|
2176
|
-
}
|
|
2177
|
-
function agentKey(meta) {
|
|
2178
|
-
return `${meta.key}.v${meta.version}`;
|
|
2179
|
-
}
|
|
2180
|
-
var init_spec = __esm(() => {
|
|
2181
|
-
init_i18n();
|
|
2182
|
-
});
|
|
2183
|
-
|
|
2184
2134
|
// src/exporters/claude-agent-exporter.ts
|
|
2185
2135
|
init_i18n();
|
|
2186
|
-
|
|
2136
|
+
import {
|
|
2137
|
+
agentKey
|
|
2138
|
+
} from "@contractspec/lib.contracts-spec/agent";
|
|
2187
2139
|
|
|
2188
2140
|
class ClaudeAgentExporter {
|
|
2189
2141
|
format = "claude-agent";
|
package/dist/exporters/index.js
CHANGED
|
@@ -2131,56 +2131,6 @@ var init_i18n = __esm(() => {
|
|
|
2131
2131
|
init_messages();
|
|
2132
2132
|
});
|
|
2133
2133
|
|
|
2134
|
-
// src/spec/spec.ts
|
|
2135
|
-
function defineAgent(spec) {
|
|
2136
|
-
const i18n = createAgentI18n(spec.locale);
|
|
2137
|
-
if (!spec.meta?.key) {
|
|
2138
|
-
throw new Error(i18n.t("error.agentKeyRequired"));
|
|
2139
|
-
}
|
|
2140
|
-
if (typeof spec.meta.version !== "string") {
|
|
2141
|
-
throw new Error(i18n.t("error.agentMissingVersion", { key: spec.meta.key }));
|
|
2142
|
-
}
|
|
2143
|
-
if (!spec.instructions?.trim()) {
|
|
2144
|
-
throw new Error(i18n.t("error.agentRequiresInstructions", { key: spec.meta.key }));
|
|
2145
|
-
}
|
|
2146
|
-
if (!spec.tools?.length) {
|
|
2147
|
-
throw new Error(i18n.t("error.agentRequiresTool", { key: spec.meta.key }));
|
|
2148
|
-
}
|
|
2149
|
-
for (const [portName, portRef] of Object.entries(spec.runtime?.ports ?? {})) {
|
|
2150
|
-
if (portRef !== undefined && portRef.trim().length === 0) {
|
|
2151
|
-
throw new Error(`Agent ${spec.meta.key} has invalid runtime config: port "${portName}" must not be empty`);
|
|
2152
|
-
}
|
|
2153
|
-
}
|
|
2154
|
-
const toolNames = new Set;
|
|
2155
|
-
for (const tool of spec.tools) {
|
|
2156
|
-
if (toolNames.has(tool.name)) {
|
|
2157
|
-
throw new Error(i18n.t("error.agentDuplicateTool", {
|
|
2158
|
-
key: spec.meta.key,
|
|
2159
|
-
name: tool.name
|
|
2160
|
-
}));
|
|
2161
|
-
}
|
|
2162
|
-
toolNames.add(tool.name);
|
|
2163
|
-
if (tool.subagentRef && tool.operationRef) {
|
|
2164
|
-
throw new Error(`Agent ${spec.meta.key} tool "${tool.name}" cannot have both subagentRef and operationRef. Use one.`);
|
|
2165
|
-
}
|
|
2166
|
-
const outputRefCount = [
|
|
2167
|
-
tool.outputPresentation,
|
|
2168
|
-
tool.outputForm,
|
|
2169
|
-
tool.outputDataView
|
|
2170
|
-
].filter(Boolean).length;
|
|
2171
|
-
if (outputRefCount > 1) {
|
|
2172
|
-
throw new Error(`Agent ${spec.meta.key} tool "${tool.name}" has multiple output refs (outputPresentation, outputForm, outputDataView). Use at most one.`);
|
|
2173
|
-
}
|
|
2174
|
-
}
|
|
2175
|
-
return Object.freeze(spec);
|
|
2176
|
-
}
|
|
2177
|
-
function agentKey(meta) {
|
|
2178
|
-
return `${meta.key}.v${meta.version}`;
|
|
2179
|
-
}
|
|
2180
|
-
var init_spec = __esm(() => {
|
|
2181
|
-
init_i18n();
|
|
2182
|
-
});
|
|
2183
|
-
|
|
2184
2134
|
// src/providers/opencode-sdk/tool-bridge.ts
|
|
2185
2135
|
function specToolToOpenCodeTool(tool) {
|
|
2186
2136
|
return {
|
|
@@ -2469,7 +2419,9 @@ var init_agent_bridge = __esm(() => {
|
|
|
2469
2419
|
|
|
2470
2420
|
// src/exporters/claude-agent-exporter.ts
|
|
2471
2421
|
init_i18n();
|
|
2472
|
-
|
|
2422
|
+
import {
|
|
2423
|
+
agentKey
|
|
2424
|
+
} from "@contractspec/lib.contracts-spec/agent";
|
|
2473
2425
|
|
|
2474
2426
|
class ClaudeAgentExporter {
|
|
2475
2427
|
format = "claude-agent";
|
|
@@ -2710,7 +2662,9 @@ function validateForClaudeAgent(spec) {
|
|
|
2710
2662
|
// src/exporters/opencode-exporter.ts
|
|
2711
2663
|
init_i18n();
|
|
2712
2664
|
init_agent_bridge();
|
|
2713
|
-
|
|
2665
|
+
import {
|
|
2666
|
+
agentKey as agentKey2
|
|
2667
|
+
} from "@contractspec/lib.contracts-spec/agent";
|
|
2714
2668
|
|
|
2715
2669
|
class OpenCodeExporter {
|
|
2716
2670
|
format = "opencode";
|
|
@@ -2721,7 +2675,7 @@ class OpenCodeExporter {
|
|
|
2721
2675
|
jsonConfig,
|
|
2722
2676
|
markdownConfig,
|
|
2723
2677
|
exportedAt: new Date,
|
|
2724
|
-
sourceSpec:
|
|
2678
|
+
sourceSpec: agentKey2(spec.meta)
|
|
2725
2679
|
};
|
|
2726
2680
|
}
|
|
2727
2681
|
exportMany(specs, options = {}) {
|
|
@@ -2865,7 +2819,7 @@ class OpenCodeExporter {
|
|
|
2865
2819
|
lines.push("");
|
|
2866
2820
|
lines.push("---");
|
|
2867
2821
|
lines.push("");
|
|
2868
|
-
lines.push(i18n.t("export.generatedFrom", { key:
|
|
2822
|
+
lines.push(i18n.t("export.generatedFrom", { key: agentKey2(spec.meta) }));
|
|
2869
2823
|
lines.push(i18n.t("export.exportedAt", { date: new Date().toISOString() }));
|
|
2870
2824
|
return lines.join(`
|
|
2871
2825
|
`);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Exports ContractSpec AgentSpec definitions to formats compatible with
|
|
5
5
|
* @opencode-ai/sdk (JSON config and markdown agent files).
|
|
6
6
|
*/
|
|
7
|
-
import type
|
|
7
|
+
import { type AgentSpec } from '@contractspec/lib.contracts-spec/agent';
|
|
8
8
|
import type { Exporter, OpenCodeAgentJSON, OpenCodeExportOptions, OpenCodeExportResult } from './types';
|
|
9
9
|
/**
|
|
10
10
|
* OpenCode SDK Exporter.
|
|
@@ -2131,56 +2131,6 @@ var init_i18n = __esm(() => {
|
|
|
2131
2131
|
init_messages();
|
|
2132
2132
|
});
|
|
2133
2133
|
|
|
2134
|
-
// src/spec/spec.ts
|
|
2135
|
-
function defineAgent(spec) {
|
|
2136
|
-
const i18n = createAgentI18n(spec.locale);
|
|
2137
|
-
if (!spec.meta?.key) {
|
|
2138
|
-
throw new Error(i18n.t("error.agentKeyRequired"));
|
|
2139
|
-
}
|
|
2140
|
-
if (typeof spec.meta.version !== "string") {
|
|
2141
|
-
throw new Error(i18n.t("error.agentMissingVersion", { key: spec.meta.key }));
|
|
2142
|
-
}
|
|
2143
|
-
if (!spec.instructions?.trim()) {
|
|
2144
|
-
throw new Error(i18n.t("error.agentRequiresInstructions", { key: spec.meta.key }));
|
|
2145
|
-
}
|
|
2146
|
-
if (!spec.tools?.length) {
|
|
2147
|
-
throw new Error(i18n.t("error.agentRequiresTool", { key: spec.meta.key }));
|
|
2148
|
-
}
|
|
2149
|
-
for (const [portName, portRef] of Object.entries(spec.runtime?.ports ?? {})) {
|
|
2150
|
-
if (portRef !== undefined && portRef.trim().length === 0) {
|
|
2151
|
-
throw new Error(`Agent ${spec.meta.key} has invalid runtime config: port "${portName}" must not be empty`);
|
|
2152
|
-
}
|
|
2153
|
-
}
|
|
2154
|
-
const toolNames = new Set;
|
|
2155
|
-
for (const tool of spec.tools) {
|
|
2156
|
-
if (toolNames.has(tool.name)) {
|
|
2157
|
-
throw new Error(i18n.t("error.agentDuplicateTool", {
|
|
2158
|
-
key: spec.meta.key,
|
|
2159
|
-
name: tool.name
|
|
2160
|
-
}));
|
|
2161
|
-
}
|
|
2162
|
-
toolNames.add(tool.name);
|
|
2163
|
-
if (tool.subagentRef && tool.operationRef) {
|
|
2164
|
-
throw new Error(`Agent ${spec.meta.key} tool "${tool.name}" cannot have both subagentRef and operationRef. Use one.`);
|
|
2165
|
-
}
|
|
2166
|
-
const outputRefCount = [
|
|
2167
|
-
tool.outputPresentation,
|
|
2168
|
-
tool.outputForm,
|
|
2169
|
-
tool.outputDataView
|
|
2170
|
-
].filter(Boolean).length;
|
|
2171
|
-
if (outputRefCount > 1) {
|
|
2172
|
-
throw new Error(`Agent ${spec.meta.key} tool "${tool.name}" has multiple output refs (outputPresentation, outputForm, outputDataView). Use at most one.`);
|
|
2173
|
-
}
|
|
2174
|
-
}
|
|
2175
|
-
return Object.freeze(spec);
|
|
2176
|
-
}
|
|
2177
|
-
function agentKey(meta) {
|
|
2178
|
-
return `${meta.key}.v${meta.version}`;
|
|
2179
|
-
}
|
|
2180
|
-
var init_spec = __esm(() => {
|
|
2181
|
-
init_i18n();
|
|
2182
|
-
});
|
|
2183
|
-
|
|
2184
2134
|
// src/providers/opencode-sdk/tool-bridge.ts
|
|
2185
2135
|
function specToolToOpenCodeTool(tool) {
|
|
2186
2136
|
return {
|
|
@@ -2470,7 +2420,9 @@ var init_agent_bridge = __esm(() => {
|
|
|
2470
2420
|
// src/exporters/opencode-exporter.ts
|
|
2471
2421
|
init_i18n();
|
|
2472
2422
|
init_agent_bridge();
|
|
2473
|
-
|
|
2423
|
+
import {
|
|
2424
|
+
agentKey
|
|
2425
|
+
} from "@contractspec/lib.contracts-spec/agent";
|
|
2474
2426
|
|
|
2475
2427
|
class OpenCodeExporter {
|
|
2476
2428
|
format = "opencode";
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Exporters convert ContractSpec AgentSpec definitions into formats
|
|
5
5
|
* compatible with external agent SDKs.
|
|
6
6
|
*/
|
|
7
|
+
import type { AgentSpec } from '@contractspec/lib.contracts-spec/agent';
|
|
7
8
|
import type { OpenCodeAgentType } from '../providers/types';
|
|
8
|
-
import type { AgentSpec } from '../spec/spec';
|
|
9
9
|
import type { McpClientConfig } from '../tools/mcp-client';
|
|
10
10
|
/**
|
|
11
11
|
* Base export options.
|
package/dist/index.d.ts
CHANGED