@contractspec/lib.ai-agent 1.45.1 → 1.45.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/dist/spec/spec.js +1 -1
- package/dist/spec/spec.js.map +1 -1
- package/package.json +5 -5
package/dist/spec/spec.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
function defineAgent(spec) {
|
|
10
10
|
if (!spec.meta?.key) throw new Error("Agent key is required");
|
|
11
|
-
if (
|
|
11
|
+
if (typeof spec.meta.version !== "string") throw new Error(`Agent ${spec.meta.key} is missing a string version`);
|
|
12
12
|
if (!spec.instructions?.trim()) throw new Error(`Agent ${spec.meta.key} requires instructions`);
|
|
13
13
|
if (!spec.tools?.length) throw new Error(`Agent ${spec.meta.key} must expose at least one tool`);
|
|
14
14
|
const toolNames = /* @__PURE__ */ new Set();
|
package/dist/spec/spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.js","names":[],"sources":["../../src/spec/spec.ts"],"sourcesContent":["import type { OwnerShipMeta } from '@contractspec/lib.contracts/ownership';\nimport type { KnowledgeCategory } from '@contractspec/lib.contracts/knowledge/spec';\nimport type { PolicyRef } from '@contractspec/lib.contracts/policy/spec';\n\n/**\n * Metadata for an agent specification.\n */\nexport type AgentMeta = OwnerShipMeta;\n\n/**\n * Configuration for a tool that an agent can use.\n */\nexport interface AgentToolConfig {\n /** Tool name (unique within the agent) */\n name: string;\n /** Human-readable description for the LLM */\n description?: string;\n /** JSON Schema fragment for tool parameters */\n schema?: Record<string, unknown>;\n /** Optional cooldown in milliseconds between invocations */\n cooldownMs?: number;\n /** Maximum execution time before timeout */\n timeoutMs?: number;\n /** Whether the tool can be executed without human approval (AI SDK needsApproval = !automationSafe) */\n automationSafe?: boolean;\n /** Explicit approval requirement (overrides automationSafe) */\n requiresApproval?: boolean;\n /** Optional policy guard that must evaluate to allow the tool call */\n policy?: PolicyRef;\n}\n\n/**\n * Reference to a knowledge space that the agent can access.\n */\nexport interface AgentKnowledgeRef {\n /** Knowledge space key */\n key: string;\n /** Optional specific version */\n version?: number;\n /** Filter by knowledge category */\n category?: KnowledgeCategory;\n /** Whether the knowledge is required (static injection) or optional (dynamic RAG) */\n required?: boolean;\n /** Additional instructions appended when the space is available */\n instructions?: string;\n}\n\n/**\n * Memory configuration for agent session persistence.\n */\nexport interface AgentMemoryConfig {\n /** Maximum entries to keep in memory */\n maxEntries?: number;\n /** Time-to-live in minutes */\n ttlMinutes?: number;\n /** Number of messages before triggering summarization */\n summaryTrigger?: number;\n /** Whether to persist to long-term storage */\n persistLongTerm?: boolean;\n}\n\n/**\n * Confidence policy for agent responses.\n */\nexport interface AgentConfidencePolicy {\n /** Minimum acceptable confidence before escalation. Defaults to 0.7 */\n min?: number;\n /** Default value used when provider does not report confidence */\n default?: number;\n}\n\n/**\n * Escalation policy for handling uncertain or failed agent responses.\n */\nexport interface AgentEscalationPolicy {\n /** Auto escalate when confidence < threshold */\n confidenceThreshold?: number;\n /** Escalate when a tool throws irrecoverable errors */\n onToolFailure?: boolean;\n /** Escalate when iteration budget exceeded */\n onTimeout?: boolean;\n /** Optional human approval workflow ID */\n approvalWorkflow?: string;\n}\n\n/**\n * Combined policy configuration for an agent.\n */\nexport interface AgentPolicy {\n confidence?: AgentConfidencePolicy;\n escalation?: AgentEscalationPolicy;\n /** Feature flags to apply to this agent */\n flags?: string[];\n}\n\n/**\n * Complete specification for a ContractSpec agent.\n */\nexport interface AgentSpec {\n meta: AgentMeta;\n /** System instructions for the agent */\n instructions: string;\n /** Human-readable description */\n description?: string;\n /** Tags for categorization */\n tags?: string[];\n /** Tools the agent can use */\n tools: AgentToolConfig[];\n /** Memory/session configuration */\n memory?: AgentMemoryConfig;\n /** Knowledge spaces the agent can access */\n knowledge?: AgentKnowledgeRef[];\n /** Policy configuration */\n policy?: AgentPolicy;\n /** Maximum steps per generation (defaults to 10) */\n maxSteps?: number;\n}\n\n/**\n * Define and validate an agent specification.\n *\n * @param spec - The agent specification\n * @returns The frozen, validated specification\n * @throws Error if the specification is invalid\n */\nexport function defineAgent(spec: AgentSpec): AgentSpec {\n if (!spec.meta?.key) {\n throw new Error('Agent key is required');\n }\n if (
|
|
1
|
+
{"version":3,"file":"spec.js","names":[],"sources":["../../src/spec/spec.ts"],"sourcesContent":["import type { OwnerShipMeta } from '@contractspec/lib.contracts/ownership';\nimport type { KnowledgeCategory } from '@contractspec/lib.contracts/knowledge/spec';\nimport type { PolicyRef } from '@contractspec/lib.contracts/policy/spec';\n\n/**\n * Metadata for an agent specification.\n */\nexport type AgentMeta = OwnerShipMeta;\n\n/**\n * Configuration for a tool that an agent can use.\n */\nexport interface AgentToolConfig {\n /** Tool name (unique within the agent) */\n name: string;\n /** Human-readable description for the LLM */\n description?: string;\n /** JSON Schema fragment for tool parameters */\n schema?: Record<string, unknown>;\n /** Optional cooldown in milliseconds between invocations */\n cooldownMs?: number;\n /** Maximum execution time before timeout */\n timeoutMs?: number;\n /** Whether the tool can be executed without human approval (AI SDK needsApproval = !automationSafe) */\n automationSafe?: boolean;\n /** Explicit approval requirement (overrides automationSafe) */\n requiresApproval?: boolean;\n /** Optional policy guard that must evaluate to allow the tool call */\n policy?: PolicyRef;\n}\n\n/**\n * Reference to a knowledge space that the agent can access.\n */\nexport interface AgentKnowledgeRef {\n /** Knowledge space key */\n key: string;\n /** Optional specific version */\n version?: number;\n /** Filter by knowledge category */\n category?: KnowledgeCategory;\n /** Whether the knowledge is required (static injection) or optional (dynamic RAG) */\n required?: boolean;\n /** Additional instructions appended when the space is available */\n instructions?: string;\n}\n\n/**\n * Memory configuration for agent session persistence.\n */\nexport interface AgentMemoryConfig {\n /** Maximum entries to keep in memory */\n maxEntries?: number;\n /** Time-to-live in minutes */\n ttlMinutes?: number;\n /** Number of messages before triggering summarization */\n summaryTrigger?: number;\n /** Whether to persist to long-term storage */\n persistLongTerm?: boolean;\n}\n\n/**\n * Confidence policy for agent responses.\n */\nexport interface AgentConfidencePolicy {\n /** Minimum acceptable confidence before escalation. Defaults to 0.7 */\n min?: number;\n /** Default value used when provider does not report confidence */\n default?: number;\n}\n\n/**\n * Escalation policy for handling uncertain or failed agent responses.\n */\nexport interface AgentEscalationPolicy {\n /** Auto escalate when confidence < threshold */\n confidenceThreshold?: number;\n /** Escalate when a tool throws irrecoverable errors */\n onToolFailure?: boolean;\n /** Escalate when iteration budget exceeded */\n onTimeout?: boolean;\n /** Optional human approval workflow ID */\n approvalWorkflow?: string;\n}\n\n/**\n * Combined policy configuration for an agent.\n */\nexport interface AgentPolicy {\n confidence?: AgentConfidencePolicy;\n escalation?: AgentEscalationPolicy;\n /** Feature flags to apply to this agent */\n flags?: string[];\n}\n\n/**\n * Complete specification for a ContractSpec agent.\n */\nexport interface AgentSpec {\n meta: AgentMeta;\n /** System instructions for the agent */\n instructions: string;\n /** Human-readable description */\n description?: string;\n /** Tags for categorization */\n tags?: string[];\n /** Tools the agent can use */\n tools: AgentToolConfig[];\n /** Memory/session configuration */\n memory?: AgentMemoryConfig;\n /** Knowledge spaces the agent can access */\n knowledge?: AgentKnowledgeRef[];\n /** Policy configuration */\n policy?: AgentPolicy;\n /** Maximum steps per generation (defaults to 10) */\n maxSteps?: number;\n}\n\n/**\n * Define and validate an agent specification.\n *\n * @param spec - The agent specification\n * @returns The frozen, validated specification\n * @throws Error if the specification is invalid\n */\nexport function defineAgent(spec: AgentSpec): AgentSpec {\n if (!spec.meta?.key) {\n throw new Error('Agent key is required');\n }\n if (typeof spec.meta.version !== 'string') {\n throw new Error(`Agent ${spec.meta.key} is missing a string version`);\n }\n if (!spec.instructions?.trim()) {\n throw new Error(`Agent ${spec.meta.key} requires instructions`);\n }\n if (!spec.tools?.length) {\n throw new Error(`Agent ${spec.meta.key} must expose at least one tool`);\n }\n\n // Validate tool names are unique\n const toolNames = new Set<string>();\n for (const tool of spec.tools) {\n if (toolNames.has(tool.name)) {\n throw new Error(\n `Agent ${spec.meta.key} has duplicate tool name: ${tool.name}`\n );\n }\n toolNames.add(tool.name);\n }\n\n return Object.freeze(spec);\n}\n\n/**\n * Generate a unique key for an agent spec.\n */\nexport function agentKey(meta: AgentMeta): string {\n return `${meta.key}.v${meta.version}`;\n}\n"],"mappings":";;;;;;;;AA6HA,SAAgB,YAAY,MAA4B;AACtD,KAAI,CAAC,KAAK,MAAM,IACd,OAAM,IAAI,MAAM,wBAAwB;AAE1C,KAAI,OAAO,KAAK,KAAK,YAAY,SAC/B,OAAM,IAAI,MAAM,SAAS,KAAK,KAAK,IAAI,8BAA8B;AAEvE,KAAI,CAAC,KAAK,cAAc,MAAM,CAC5B,OAAM,IAAI,MAAM,SAAS,KAAK,KAAK,IAAI,wBAAwB;AAEjE,KAAI,CAAC,KAAK,OAAO,OACf,OAAM,IAAI,MAAM,SAAS,KAAK,KAAK,IAAI,gCAAgC;CAIzE,MAAM,4BAAY,IAAI,KAAa;AACnC,MAAK,MAAM,QAAQ,KAAK,OAAO;AAC7B,MAAI,UAAU,IAAI,KAAK,KAAK,CAC1B,OAAM,IAAI,MACR,SAAS,KAAK,KAAK,IAAI,4BAA4B,KAAK,OACzD;AAEH,YAAU,IAAI,KAAK,KAAK;;AAG1B,QAAO,OAAO,OAAO,KAAK;;;;;AAM5B,SAAgB,SAAS,MAAyB;AAChD,QAAO,GAAG,KAAK,IAAI,IAAI,KAAK"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/lib.ai-agent",
|
|
3
|
-
"version": "1.45.
|
|
3
|
+
"version": "1.45.2",
|
|
4
4
|
"description": "AI agent orchestration with MCP and tool support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contractspec",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"@ai-sdk/mistral": "3.0.1",
|
|
41
41
|
"@ai-sdk/openai": "3.0.1",
|
|
42
42
|
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
43
|
-
"@contractspec/lib.contracts": "1.45.
|
|
44
|
-
"@contractspec/lib.knowledge": "1.45.
|
|
43
|
+
"@contractspec/lib.contracts": "1.45.2",
|
|
44
|
+
"@contractspec/lib.knowledge": "1.45.2",
|
|
45
45
|
"compare-versions": "^6.1.1",
|
|
46
46
|
"zod": "^4.1.13"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@contractspec/tool.tsdown": "1.45.
|
|
50
|
-
"@contractspec/tool.typescript": "1.45.
|
|
49
|
+
"@contractspec/tool.tsdown": "1.45.2",
|
|
50
|
+
"@contractspec/tool.typescript": "1.45.2",
|
|
51
51
|
"tsdown": "^0.18.3",
|
|
52
52
|
"typescript": "^5.9.3"
|
|
53
53
|
},
|