@bluefly/openstandardagents 0.4.9 → 0.5.1

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.
Files changed (259) hide show
  1. package/.version.json +3 -3
  2. package/CHANGELOG.md +35 -4
  3. package/README.md +77 -62
  4. package/dist/.version.json +3 -3
  5. package/dist/adapters/a2a/a2a-protocol.js +4 -2
  6. package/dist/adapters/a2a/a2a-tool.js +4 -2
  7. package/dist/adapters/a2a/mcp-integration.d.ts +2 -1
  8. package/dist/adapters/a2a/mcp-integration.js +6 -3
  9. package/dist/adapters/browser/browser-exporter.d.ts +26 -0
  10. package/dist/adapters/browser/browser-exporter.js +73 -0
  11. package/dist/adapters/browser/browser-runner.d.ts +23 -0
  12. package/dist/adapters/browser/browser-runner.js +46 -0
  13. package/dist/adapters/browser/index.d.ts +9 -0
  14. package/dist/adapters/browser/index.js +9 -0
  15. package/dist/adapters/claude-code/adapter.js +2 -2
  16. package/dist/adapters/docker/generators.js +19 -19
  17. package/dist/adapters/docker/index.d.ts +2 -0
  18. package/dist/adapters/docker/index.js +2 -0
  19. package/dist/adapters/docker/openclaw-bridge.d.ts +57 -0
  20. package/dist/adapters/docker/openclaw-bridge.js +173 -0
  21. package/dist/adapters/drupal/generator.js +76 -76
  22. package/dist/adapters/drupal/index.d.ts +1 -0
  23. package/dist/adapters/drupal/index.js +2 -0
  24. package/dist/adapters/drupal/twig-renderer.d.ts +23 -0
  25. package/dist/adapters/drupal/twig-renderer.js +99 -0
  26. package/dist/adapters/gitlab/agent-generator.js +2 -1
  27. package/dist/adapters/openai-agents/adapter.js +2 -2
  28. package/dist/api/index.js +2 -1
  29. package/dist/api/routes/mcp.router.js +3 -1
  30. package/dist/api/routes/wizard.router.js +3 -1
  31. package/dist/cli/commands/agent/discover-type.command.js +1 -1
  32. package/dist/cli/commands/agent-card.command.js +37 -10
  33. package/dist/cli/commands/agents-sync.command.d.ts +2 -2
  34. package/dist/cli/commands/agents-sync.command.js +27 -17
  35. package/dist/cli/commands/catalog/config.js +1 -1
  36. package/dist/cli/commands/catalog/validate.command.js +2 -2
  37. package/dist/cli/commands/config.command.js +2 -2
  38. package/dist/cli/commands/daemon.command.js +32 -8
  39. package/dist/cli/commands/discover.d.ts +1 -1
  40. package/dist/cli/commands/discover.js +16 -8
  41. package/dist/cli/commands/economics.command.d.ts +9 -0
  42. package/dist/cli/commands/economics.command.js +113 -0
  43. package/dist/cli/commands/export.command.js +6 -3
  44. package/dist/cli/commands/mcp.command.js +3 -1
  45. package/dist/cli/commands/memory.command.d.ts +18 -0
  46. package/dist/cli/commands/memory.command.js +168 -0
  47. package/dist/cli/commands/publish.command.js +7 -4
  48. package/dist/cli/commands/serve-builder-routes.js +1 -1
  49. package/dist/cli/commands/usie-skills.command.d.ts +24 -0
  50. package/dist/cli/commands/usie-skills.command.js +297 -0
  51. package/dist/cli/commands/validate.command.js +8 -1
  52. package/dist/cli/commands/verify.d.ts +3 -3
  53. package/dist/cli/commands/verify.js +12 -6
  54. package/dist/cli/commands/workspace.command.d.ts +1 -0
  55. package/dist/cli/commands/workspace.command.js +28 -4
  56. package/dist/cli/index.js +12 -0
  57. package/dist/cli/schema-driven/schema-loader.js +5 -5
  58. package/dist/cli/workspace-validate.d.ts +23 -0
  59. package/dist/cli/workspace-validate.js +117 -0
  60. package/dist/data/platform-matrix.js +1 -4
  61. package/dist/generated/types.d.ts +97 -97
  62. package/dist/index.d.ts +2 -0
  63. package/dist/index.js +2 -0
  64. package/dist/mcp-server/index.js +658 -982
  65. package/dist/mesh/discovery-gkg.d.ts +26 -0
  66. package/dist/mesh/discovery-gkg.js +92 -0
  67. package/dist/messenger/Handler/AgentBatchHandler.js +3 -2
  68. package/dist/messenger/Handler/AgentExecutionHandler.js +6 -1
  69. package/dist/package.json +43 -14
  70. package/dist/sdks/shared/types.d.ts +1 -1
  71. package/dist/services/agent-card-generator.js +6 -2
  72. package/dist/services/daemon/audit-log.service.js +3 -1
  73. package/dist/services/daemon/execution.service.js +8 -4
  74. package/dist/services/daemon/fs-watcher.service.js +6 -7
  75. package/dist/services/daemon/pairing.service.js +2 -1
  76. package/dist/services/daemon/skill-aggregator.service.js +105 -21
  77. package/dist/services/daemon/sse-endpoints.js +1 -1
  78. package/dist/services/daemon/ws-server.js +10 -3
  79. package/dist/services/export/langchain/langchain-exporter.js +2 -2
  80. package/dist/services/export/langchain/memory-generator.js +2 -2
  81. package/dist/services/export/testing/test-generator.js +1 -1
  82. package/dist/services/governance/cedar-provider.js +12 -8
  83. package/dist/services/governance/cedar-validator.service.js +1 -1
  84. package/dist/services/mcp/bridge.service.js +40 -9
  85. package/dist/services/openapi-extensions-validation.d.ts +20 -0
  86. package/dist/services/openapi-extensions-validation.js +193 -0
  87. package/dist/services/release-automation/merge-request.service.d.ts +4 -4
  88. package/dist/services/release-automation/release-buttons.js +3 -3
  89. package/dist/services/release-automation/schemas/release.schema.d.ts +3 -3
  90. package/dist/services/runtime/openai.adapter.d.ts +46 -13
  91. package/dist/services/runtime/openai.adapter.js +169 -131
  92. package/dist/services/skill-registry.service.d.ts +1 -1
  93. package/dist/services/skills-pipeline/skills-research.service.js +47 -7
  94. package/dist/services/taxonomy-service.d.ts +3 -3
  95. package/dist/services/trust/trust.service.js +6 -4
  96. package/dist/services/validation-zod.service.js +3 -22
  97. package/dist/services/validators/index.d.ts +1 -0
  98. package/dist/services/validators/index.js +1 -0
  99. package/dist/services/validators/registry.d.ts +21 -0
  100. package/dist/services/validators/registry.js +42 -0
  101. package/dist/skills/test-skill/package.json +1 -1
  102. package/dist/spec/extensions/cognition.schema.json +87 -0
  103. package/dist/spec/extensions/role-manifest.md +188 -0
  104. package/dist/spec/layer4-economics/duadp-examples.json +44 -0
  105. package/dist/spec/v0.4/agent.schema.json +14 -0
  106. package/dist/spec/v0.4/extensions/mcp/README.md +1 -1
  107. package/dist/spec/v0.5/agent-builder-openapi.yaml +230 -0
  108. package/dist/spec/v0.5/agent.schema.json +34 -2
  109. package/dist/spec/v0.5/extensions/cognition/cognition.schema.json +78 -1
  110. package/dist/spec/v0.5/extensions/economics/context-pack.schema.json +91 -0
  111. package/dist/spec/v0.5/extensions/economics/execution-profile.schema.json +148 -0
  112. package/dist/spec/v0.5/extensions/economics/failure-semantics.schema.json +32 -0
  113. package/dist/spec/v0.5/extensions/economics/replay-packet.schema.json +120 -0
  114. package/dist/spec/v0.5/memory-hierarchy.yaml +120 -0
  115. package/dist/spec/v0.5/role.schema.json +268 -0
  116. package/dist/spec/v1/agent-card.schema.json +254 -0
  117. package/dist/types/cognition.zod.d.ts +312 -0
  118. package/dist/types/cognition.zod.js +223 -0
  119. package/dist/types/identity.zod.d.ts +5 -5
  120. package/dist/types/index.d.ts +54 -6
  121. package/dist/types/index.js +6 -2
  122. package/dist/types/personality.zod.d.ts +3 -3
  123. package/dist/types/role.d.ts +126 -0
  124. package/dist/types/role.js +38 -0
  125. package/dist/utils/http-client.d.ts +22 -0
  126. package/dist/utils/http-client.js +51 -0
  127. package/dist/utils/index.d.ts +3 -0
  128. package/dist/utils/index.js +3 -0
  129. package/dist/utils/proxy-resolver.d.ts +36 -0
  130. package/dist/utils/proxy-resolver.js +59 -0
  131. package/dist/utils/user-agent.d.ts +11 -0
  132. package/dist/utils/user-agent.js +17 -0
  133. package/dist/validation/validator.js +1 -1
  134. package/dist/validation/version-compliance.js +1 -1
  135. package/examples/agents/01-customer-support-bot/agent.ossa.yaml +24 -31
  136. package/examples/agents/05-sales-assistant/agent.ossa.yaml +35 -23
  137. package/examples/agents/07-research-assistant/agent.ossa.yaml +27 -21
  138. package/examples/agents/10-meeting-assistant/agent.ossa.yaml +27 -35
  139. package/examples/agents/security-audit-agent.ossa.yaml +234 -0
  140. package/examples/agentscope/react-assistant/README.md +1 -1
  141. package/examples/agentscope/react-assistant/agent.ossa.yaml +37 -33
  142. package/examples/drupal/content-moderator.ossa.yaml +2 -2
  143. package/examples/drupal/drupal-contributor-agent/.eslintrc.json +58 -0
  144. package/examples/drupal/drupal-contributor-agent/.prettierrc.json +10 -0
  145. package/examples/drupal/drupal-contributor-agent/package.json +55 -0
  146. package/examples/drupal/drupal-contributor-agent/src/core/index.ts +10 -0
  147. package/examples/drupal/drupal-contributor-agent/src/index.ts +17 -0
  148. package/examples/drupal/drupal-contributor-agent/src/types/index.ts +180 -0
  149. package/examples/drupal/drupal-contributor-agent/tsconfig.json +36 -0
  150. package/examples/drupal/drupal-contributor.ossa.yaml +247 -0
  151. package/examples/export/langchain/production-agent-with-memory/README.md +1 -1
  152. package/examples/export/langchain/production-agent-with-memory/agent.ossa.yaml +13 -23
  153. package/examples/export/langchain/production-agent-with-streaming/agent.ossa.yaml +1 -15
  154. package/examples/export/langchain/production-agent-with-tools/agent.ossa.yaml +28 -29
  155. package/examples/getting-started/01-minimal-agent.ossa.yaml +1 -1
  156. package/examples/getting-started/02-agent-with-tools.ossa.yaml +1 -1
  157. package/examples/getting-started/03-agent-with-safety.ossa.yaml +1 -1
  158. package/examples/getting-started/04-agent-with-messaging.ossa.yaml +1 -1
  159. package/examples/getting-started/05-workflow-composition.ossa.yaml +1 -1
  160. package/examples/getting-started/README.md +3 -3
  161. package/examples/getting-started/hello-world-complete.ossa.yaml +1 -1
  162. package/examples/gitlab-agents/gitlab-ci-agent.ossa.yaml +221 -0
  163. package/examples/hierarchical-agent.ossa.yaml +10 -53
  164. package/examples/kagent/ossa-kagent-anthropic.ossa.yaml +2 -25
  165. package/examples/kagent/ossa-kagent-mcp-tools.ossa.yaml +2 -30
  166. package/examples/kagent/ossa-kagent-multi-tool.ossa.yaml +2 -18
  167. package/examples/kagent/ossa-kagent-poc.ossa.yaml +2 -16
  168. package/examples/pipeline-agent.ossa.yaml +3 -3
  169. package/examples/platform-specific/claude-code-subagent.yaml +1 -1
  170. package/examples/platform-specific/cursor-coding-agent.yaml +1 -1
  171. package/examples/platform-specific/warp-terminal-agent.yaml +1 -1
  172. package/examples/production-ready/01-customer-support-bot/agent.ossa.yaml +24 -31
  173. package/examples/production-ready/05-sales-assistant/agent.ossa.yaml +35 -23
  174. package/examples/production-ready/07-research-assistant/agent.ossa.yaml +27 -19
  175. package/examples/production-ready/10-meeting-assistant/agent.ossa.yaml +27 -35
  176. package/examples/roles/drupal-developer.role.yaml +37 -0
  177. package/examples/roles/platform-operator.role.yaml +28 -0
  178. package/examples/roles/security-auditor.role.yaml +27 -0
  179. package/examples/swarm-agent.ossa.yaml +13 -51
  180. package/examples/team-agent.ossa.yaml +12 -61
  181. package/examples/team-lead-teammate.ossa.yaml +12 -17
  182. package/openapi/agent-cognition-sessions.yaml +580 -0
  183. package/openapi/agent-communication.yaml +260 -212
  184. package/openapi/agent-crud.yaml +237 -207
  185. package/openapi/agent-discovery.yaml +119 -81
  186. package/openapi/agent-identity.yaml +219 -187
  187. package/openapi/agent-taxonomy.yaml +95 -38
  188. package/openapi/agents-md-service.yaml +103 -30
  189. package/openapi/cli/openapi.yaml +147 -40
  190. package/openapi/core/ossa-core-api.openapi.yaml +327 -271
  191. package/openapi/core/ossa-registry-api.openapi.yaml +299 -236
  192. package/openapi/core/ossa-registry.openapi.yaml +299 -159
  193. package/openapi/core/unified-agent-gateway.openapi.yaml +234 -170
  194. package/openapi/daemon-api.openapi.yaml +323 -181
  195. package/openapi/dev-cli/openapi.yaml +137 -113
  196. package/openapi/github-sync.yaml +62 -19
  197. package/openapi/marketplace-plugin.openapi.yaml +539 -466
  198. package/openapi/ossa-api.openapi.yaml +354 -213
  199. package/openapi/ossa-cli-enhancements.openapi.yaml +109 -90
  200. package/openapi/ossa-cli.yaml +260 -184
  201. package/openapi/protocols/sse-streams.yaml +66 -74
  202. package/openapi/protocols/websocket-events.yaml +61 -54
  203. package/openapi/reference-implementations/aiflow-bridge-api.openapi.yaml +37 -20
  204. package/openapi/reference-implementations/compliance-agent-api.openapi.yaml +35 -23
  205. package/openapi/reference-implementations/crewai-agent-api.openapi.yaml +29 -18
  206. package/openapi/reference-implementations/critic-agent-api.openapi.yaml +45 -19
  207. package/openapi/reference-implementations/document-analyzer-api.openapi.yaml +30 -24
  208. package/openapi/reference-implementations/drupal-agent-api.openapi.yaml +101 -50
  209. package/openapi/reference-implementations/getting-started-hello-world-api.openapi.yaml +33 -22
  210. package/openapi/reference-implementations/gitlab-ml-recommender-api.openapi.yaml +20 -16
  211. package/openapi/reference-implementations/governor-agent-api.openapi.yaml +41 -23
  212. package/openapi/reference-implementations/helm-generator.openapi.yaml +88 -46
  213. package/openapi/reference-implementations/integrator-agent-api.openapi.yaml +30 -20
  214. package/openapi/reference-implementations/judge-agent-api.openapi.yaml +22 -16
  215. package/openapi/reference-implementations/k8s-troubleshooter-api.openapi.yaml +32 -18
  216. package/openapi/reference-implementations/langchain-agent-api.openapi.yaml +32 -21
  217. package/openapi/reference-implementations/monitor-agent-api.openapi.yaml +34 -21
  218. package/openapi/reference-implementations/orchestrator-agent-api.openapi.yaml +49 -27
  219. package/openapi/reference-implementations/quickstart-support-agent-api.openapi.yaml +27 -19
  220. package/openapi/reference-implementations/self-evolving-ecosystem.openapi.yaml +427 -293
  221. package/openapi/reference-implementations/worker-agent-api.openapi.yaml +34 -23
  222. package/openapi/reference-implementations/workflow-orchestrator-api.openapi.yaml +35 -21
  223. package/openapi/release-automation.openapi.yaml +48 -14
  224. package/openapi/schemas/common/agent.yaml +30 -29
  225. package/openapi/schemas/common/economics.yaml +98 -0
  226. package/openapi/schemas/common/errors.yaml +13 -3
  227. package/openapi/schemas/common/metadata.yaml +22 -7
  228. package/openapi/schemas/common/pagination.yaml +18 -6
  229. package/openapi/schemas/common/security.yaml +13 -5
  230. package/openapi/schemas/index.yaml +49 -42
  231. package/openapi/uadp-asyncapi.yaml +5 -3
  232. package/openapi/uadp-openapi.yaml +243 -165
  233. package/openapi/version-management.openapi.yaml +142 -135
  234. package/package.json +43 -14
  235. package/spec/extensions/cognition.schema.json +87 -0
  236. package/spec/extensions/role-manifest.md +188 -0
  237. package/spec/layer4-economics/duadp-examples.json +44 -0
  238. package/spec/v0.4/agent.schema.json +14 -0
  239. package/spec/v0.4/extensions/mcp/README.md +1 -1
  240. package/spec/v0.5/agent-builder-openapi.yaml +230 -0
  241. package/spec/v0.5/agent.schema.json +34 -2
  242. package/spec/v0.5/extensions/cognition/cognition.schema.json +78 -1
  243. package/spec/v0.5/extensions/economics/context-pack.schema.json +91 -0
  244. package/spec/v0.5/extensions/economics/execution-profile.schema.json +148 -0
  245. package/spec/v0.5/extensions/economics/failure-semantics.schema.json +32 -0
  246. package/spec/v0.5/extensions/economics/replay-packet.schema.json +120 -0
  247. package/spec/v0.5/memory-hierarchy.yaml +120 -0
  248. package/spec/v0.5/role.schema.json +268 -0
  249. package/spec/v1/agent-card.schema.json +254 -0
  250. package/dist/adapters/a2a/__tests__/mcp-integration.spec.d.ts +0 -5
  251. package/dist/adapters/a2a/__tests__/mcp-integration.spec.js +0 -268
  252. package/dist/adapters/a2a/__tests__/mcp-transport.spec.d.ts +0 -5
  253. package/dist/adapters/a2a/__tests__/mcp-transport.spec.js +0 -203
  254. package/dist/mcp-server/__tests__/mcp-server.spec.d.ts +0 -8
  255. package/dist/mcp-server/__tests__/mcp-server.spec.js +0 -557
  256. package/dist/validation/__tests__/error-codes.test.d.ts +0 -5
  257. package/dist/validation/__tests__/error-codes.test.js +0 -252
  258. package/dist/version-management/core/version-manager.test.d.ts +0 -2
  259. package/dist/version-management/core/version-manager.test.js +0 -210
@@ -2,198 +2,236 @@
2
2
  * OpenAI Runtime Adapter
3
3
  * Runs OSSA agents using OpenAI's function calling API
4
4
  */
5
- import OpenAI from 'openai';
5
+ import * as crypto from 'crypto';
6
+ import { createOpenAI } from '@ai-sdk/openai';
7
+ import { ToolLoopAgent, stepCountIs } from 'ai';
8
+ import { z } from 'zod';
6
9
  export class OpenAIAdapter {
7
- client;
8
10
  manifest;
9
11
  tools = new Map();
10
12
  messages = [];
13
+ apiKey;
11
14
  constructor(manifest, apiKey) {
12
15
  this.manifest = manifest;
13
- this.client = new OpenAI({
14
- apiKey: apiKey || process.env.OPENAI_API_KEY,
15
- });
16
+ this.apiKey = apiKey || process.env.OPENAI_API_KEY;
16
17
  }
17
18
  /**
18
19
  * Get the model to use from manifest
19
20
  */
20
- getModel() {
21
- // Check OpenAI extension first
21
+ getModelName() {
22
22
  if (this.manifest.extensions?.openai_agents?.model) {
23
23
  return this.manifest.extensions.openai_agents.model;
24
24
  }
25
- // Fall back to LLM config
26
25
  if (this.manifest.spec.llm?.model) {
27
26
  return this.manifest.spec.llm.model;
28
27
  }
29
- // Default
30
28
  return 'gpt-4o-mini';
31
29
  }
32
30
  /**
33
31
  * Get system prompt from manifest
34
32
  */
35
33
  getSystemPrompt() {
36
- // Check OpenAI extension first
37
34
  if (this.manifest.extensions?.openai_agents?.instructions) {
38
35
  return this.manifest.extensions.openai_agents.instructions;
39
36
  }
40
- // Fall back to role
41
37
  return this.manifest.spec.role;
42
38
  }
43
39
  /**
44
- * Convert OSSA tools to OpenAI function calling format
40
+ * Register a tool handler
45
41
  */
46
- getOpenAITools() {
47
- const openaiTools = [];
48
- // Check for tools_mapping in OpenAI extension
42
+ registerToolHandler(name, handler) {
43
+ // Basic tool mapping from manifest
49
44
  const toolsMapping = this.manifest.extensions?.openai_agents?.tools_mapping;
50
45
  if (toolsMapping) {
51
46
  for (const mapping of toolsMapping) {
52
- const toolDef = {
53
- name: mapping.openai_tool_name || mapping.ossa_capability,
54
- description: mapping.description || `Execute ${mapping.ossa_capability}`,
55
- parameters: mapping.parameters || {
56
- type: 'object',
57
- properties: {},
58
- required: [],
59
- },
60
- };
61
- this.tools.set(toolDef.name, toolDef);
62
- openaiTools.push({
63
- type: 'function',
64
- function: {
65
- name: toolDef.name,
66
- description: toolDef.description,
67
- parameters: toolDef.parameters,
68
- },
69
- });
47
+ const tName = mapping.openai_tool_name || mapping.ossa_capability;
48
+ if (tName === name) {
49
+ this.tools.set(name, {
50
+ name,
51
+ description: mapping.description || `Execute ${mapping.ossa_capability}`,
52
+ parameters: mapping.parameters || { type: 'object', properties: {} },
53
+ handler,
54
+ });
55
+ return;
56
+ }
70
57
  }
71
58
  }
72
- // Also check spec.tools for basic tool definitions
59
+ // Fallback for spec.tools
73
60
  if (this.manifest.spec.tools) {
74
61
  for (const tool of this.manifest.spec.tools) {
75
- if (tool.name && !this.tools.has(tool.name)) {
76
- const toolDef = {
77
- name: tool.name,
62
+ if (tool.name === name) {
63
+ this.tools.set(name, {
64
+ name,
78
65
  description: `Execute ${tool.name} (${tool.type})`,
79
- parameters: {
80
- type: 'object',
81
- properties: {},
82
- required: [],
83
- },
84
- };
85
- this.tools.set(tool.name, toolDef);
86
- openaiTools.push({
87
- type: 'function',
88
- function: {
89
- name: tool.name,
90
- description: toolDef.description,
91
- parameters: toolDef.parameters,
92
- },
66
+ parameters: { type: 'object', properties: {} },
67
+ handler,
93
68
  });
69
+ return;
94
70
  }
95
71
  }
96
72
  }
97
- return openaiTools;
98
- }
99
- /**
100
- * Register a tool handler
101
- */
102
- registerToolHandler(name, handler) {
103
- const tool = this.tools.get(name);
104
- if (tool) {
105
- tool.handler = handler;
106
- }
107
- }
108
- /**
109
- * Execute a tool call
110
- */
111
- async executeTool(name, args) {
112
- const tool = this.tools.get(name);
113
- if (!tool) {
114
- return `Error: Tool '${name}' not found`;
115
- }
116
- if (tool.handler) {
117
- try {
118
- return await tool.handler(args);
119
- }
120
- catch (error) {
121
- return `Error executing ${name}: ${error instanceof Error ? error.message : String(error)}`;
122
- }
123
- }
124
- // No handler registered - fail explicitly
125
- throw new Error(`No handler registered for tool: ${name}`);
126
73
  }
127
74
  /**
128
75
  * Initialize the conversation
129
76
  */
130
77
  initialize() {
131
- this.messages = [
132
- {
133
- role: 'system',
134
- content: this.getSystemPrompt(),
135
- },
136
- ];
78
+ this.messages = [];
137
79
  }
138
80
  /**
139
- * Send a message and get a response
81
+ * Send a message and get a response using AI SDK ToolLoopAgent.
82
+ * Publishes StateClaims and ReplayPackets to ContractPlane.
140
83
  */
141
84
  async chat(userMessage, options) {
142
- // Add user message
85
+ const contractPlaneUrl = process.env.CONTRACTPLANE_URL || 'https://contractplane.blueflyagents.com';
86
+ const startTime = new Date().toISOString();
87
+ // 1. Resolve Context Packs (Economy Layer)
88
+ const contextPacks = await this.resolveContextPacks(contractPlaneUrl);
89
+ const enrichedSystemPrompt = this.getSystemPrompt() + "\n\nContext Packs:\n" + JSON.stringify(contextPacks);
143
90
  this.messages.push({
144
91
  role: 'user',
145
92
  content: userMessage,
146
93
  });
147
- const tools = this.getOpenAITools();
148
- let turnCount = 0;
149
- const maxTurns = options?.maxTurns || 10;
150
- while (turnCount < maxTurns) {
151
- turnCount++;
152
- // Call OpenAI
153
- const response = await this.client.chat.completions.create({
154
- model: this.getModel(),
155
- messages: this.messages,
156
- tools: tools.length > 0 ? tools : undefined,
157
- temperature: this.manifest.spec.llm?.temperature ?? 0.7,
158
- max_tokens: this.manifest.spec.llm?.maxTokens,
159
- });
160
- const choice = response.choices[0];
161
- const message = choice.message;
162
- // Add assistant message to history
163
- this.messages.push(message);
164
- // Check if we need to call tools
165
- if (message.tool_calls && message.tool_calls.length > 0) {
166
- if (options?.verbose) {
167
- console.log(`\n[Calling ${message.tool_calls.length} tool(s)...]`);
168
- }
169
- // Execute each tool call
170
- for (const toolCall of message.tool_calls) {
171
- // Type guard for function tool calls
172
- if (toolCall.type !== 'function')
173
- continue;
174
- const funcCall = toolCall;
175
- const args = JSON.parse(funcCall.function.arguments);
94
+ // Convert internal tools to AI SDK tools
95
+ const sdkTools = {};
96
+ for (const [name, def] of this.tools) {
97
+ sdkTools[name] = {
98
+ description: def.description,
99
+ parameters: z.any(),
100
+ execute: async (args) => {
176
101
  if (options?.verbose) {
177
- console.log(` → ${funcCall.function.name}(${JSON.stringify(args)})`);
102
+ console.log(` → ${name}(${JSON.stringify(args)})`);
178
103
  }
179
- const result = await this.executeTool(funcCall.function.name, args);
104
+ const result = await def.handler(args);
105
+ // Publish tool execution as a StateClaim (Evidence)
106
+ await this.publishStateClaim(contractPlaneUrl, {
107
+ subject: `task:${this.manifest.metadata.name}`,
108
+ claim_type: 'evidence.tool_execution',
109
+ payload: {
110
+ tool: name,
111
+ args,
112
+ result_summary: result.substring(0, 500)
113
+ }
114
+ });
180
115
  if (options?.verbose) {
181
116
  console.log(` ← ${result.substring(0, 100)}${result.length > 100 ? '...' : ''}`);
182
117
  }
183
- // Add tool result to messages
184
- this.messages.push({
185
- role: 'tool',
186
- tool_call_id: toolCall.id,
187
- content: result,
188
- });
118
+ return result;
119
+ },
120
+ };
121
+ }
122
+ // 2. Execute with Economics (ExecutionProfile) via ToolLoopAgent
123
+ const openaiProvider = createOpenAI({
124
+ apiKey: this.apiKey,
125
+ });
126
+ const agent = new ToolLoopAgent({
127
+ model: openaiProvider(this.getModelName()),
128
+ instructions: enrichedSystemPrompt,
129
+ tools: sdkTools,
130
+ stopWhen: stepCountIs(options?.maxTurns || 10),
131
+ });
132
+ const result = await agent.generate({
133
+ prompt: userMessage,
134
+ });
135
+ // Sync result back to history
136
+ this.messages.push({
137
+ role: 'assistant',
138
+ content: result.text,
139
+ });
140
+ // 3. Publish final intent/judgment as a StateClaim
141
+ await this.publishStateClaim(contractPlaneUrl, {
142
+ subject: `conversation:${this.manifest.metadata.name}`,
143
+ claim_type: 'intent.response',
144
+ payload: {
145
+ text: result.text,
146
+ usage: result.usage,
147
+ }
148
+ });
149
+ // 4. Generate and Publish Replay Packet (Reproducibility & Escrow)
150
+ const reasoningTrace = JSON.stringify(this.messages);
151
+ const reasoningHash = crypto.createHash('sha256').update(reasoningTrace).digest('hex');
152
+ await this.publishReplayPacket(contractPlaneUrl, {
153
+ metadata: {
154
+ id: `replay:${Math.random().toString(36).substring(7)}`,
155
+ timestamp: startTime,
156
+ agent_id: this.manifest.metadata.name
157
+ },
158
+ spec: {
159
+ execution_profile: this.manifest.economics?.execution_profile || 'default-balanced',
160
+ model_class: this.manifest.economics?.token_class || 'balanced-work',
161
+ inputs: {
162
+ prompts: [enrichedSystemPrompt, userMessage],
163
+ context_packs: this.manifest.spec.tools?.filter(t => t.type === 'context_pack').map(t => t.name) || []
164
+ },
165
+ accounting: {
166
+ compute_tokens: result.usage.totalTokens,
167
+ context_tokens: 0 // Calculated by mesh
168
+ },
169
+ escrow: {
170
+ mode: 'structured-only',
171
+ reasoning_hash: reasoningHash,
172
+ policy_gate: 'audit_only'
173
+ },
174
+ output: {
175
+ text: result.text,
176
+ confidence: 1.0 // Simple heuristic for now
177
+ }
178
+ }
179
+ });
180
+ return result.text;
181
+ }
182
+ /**
183
+ * Resolves context packs via the State Plane.
184
+ */
185
+ async resolveContextPacks(baseUrl) {
186
+ const packs = [];
187
+ const contextPackRefs = this.manifest.spec.tools?.filter(t => t.type === 'context_pack') || [];
188
+ for (const ref of contextPackRefs) {
189
+ try {
190
+ const response = await fetch(`${baseUrl}/api/v1/statemesh/context/${ref.name}`);
191
+ if (response.ok) {
192
+ packs.push(await response.json());
189
193
  }
190
- // Continue the loop to get the final response
191
- continue;
192
194
  }
193
- // No tool calls, return the response
194
- return message.content || '';
195
+ catch (e) {
196
+ console.error(`Failed to resolve context pack: ${ref.name}`);
197
+ }
198
+ }
199
+ return packs;
200
+ }
201
+ /**
202
+ * Publish a Replay Packet to ContractPlane.
203
+ */
204
+ async publishReplayPacket(baseUrl, packet) {
205
+ try {
206
+ await fetch(`${baseUrl}/api/v1/statemesh/replays`, {
207
+ method: 'POST',
208
+ headers: { 'Content-Type': 'application/json' },
209
+ body: JSON.stringify(packet)
210
+ });
211
+ }
212
+ catch (e) {
213
+ console.error('Failed to record Replay Packet');
214
+ }
215
+ }
216
+ /**
217
+ * Publish a claim to the ContractPlane State Plane API
218
+ */
219
+ async publishStateClaim(baseUrl, claim) {
220
+ try {
221
+ await fetch(`${baseUrl}/api/v1/statemesh/claims`, {
222
+ method: 'POST',
223
+ headers: { 'Content-Type': 'application/json' },
224
+ body: JSON.stringify({
225
+ ...claim,
226
+ producer_id: `agent://${this.manifest.metadata.name}`,
227
+ confidence: 100,
228
+ trust_tier: this.manifest.security?.tier || 'unverified'
229
+ })
230
+ });
231
+ }
232
+ catch (error) {
233
+ console.error(`Failed to publish StateClaim: ${error instanceof Error ? error.message : String(error)}`);
195
234
  }
196
- return 'Max turns reached without completion';
197
235
  }
198
236
  /**
199
237
  * Get agent info
@@ -201,7 +239,7 @@ export class OpenAIAdapter {
201
239
  getAgentInfo() {
202
240
  return {
203
241
  name: this.manifest.metadata.name,
204
- model: this.getModel(),
242
+ model: this.getModelName(),
205
243
  tools: Array.from(this.tools.keys()),
206
244
  };
207
245
  }
@@ -16,9 +16,9 @@ declare const SkillMetadataSchema: z.ZodObject<{
16
16
  description: z.ZodString;
17
17
  priority: z.ZodDefault<z.ZodNumber>;
18
18
  contexts: z.ZodDefault<z.ZodArray<z.ZodEnum<{
19
+ review: "review";
19
20
  production: "production";
20
21
  development: "development";
21
- review: "review";
22
22
  testing: "testing";
23
23
  }>>>;
24
24
  enabled: z.ZodDefault<z.ZodBoolean>;
@@ -58,13 +58,53 @@ const DEFAULT_SOURCES = [
58
58
  * Common English stop words to exclude from trigger extraction
59
59
  */
60
60
  const STOP_WORDS = new Set([
61
- 'the', 'and', 'for', 'are', 'but', 'not', 'you', 'all',
62
- 'can', 'her', 'was', 'one', 'our', 'out', 'has', 'have',
63
- 'with', 'this', 'that', 'from', 'they', 'been', 'said',
64
- 'each', 'which', 'their', 'will', 'other', 'about', 'many',
65
- 'then', 'them', 'these', 'some', 'would', 'make', 'like',
66
- 'into', 'could', 'time', 'very', 'when', 'come', 'made',
67
- 'use', 'using', 'used',
61
+ 'the',
62
+ 'and',
63
+ 'for',
64
+ 'are',
65
+ 'but',
66
+ 'not',
67
+ 'you',
68
+ 'all',
69
+ 'can',
70
+ 'her',
71
+ 'was',
72
+ 'one',
73
+ 'our',
74
+ 'out',
75
+ 'has',
76
+ 'have',
77
+ 'with',
78
+ 'this',
79
+ 'that',
80
+ 'from',
81
+ 'they',
82
+ 'been',
83
+ 'said',
84
+ 'each',
85
+ 'which',
86
+ 'their',
87
+ 'will',
88
+ 'other',
89
+ 'about',
90
+ 'many',
91
+ 'then',
92
+ 'them',
93
+ 'these',
94
+ 'some',
95
+ 'would',
96
+ 'make',
97
+ 'like',
98
+ 'into',
99
+ 'could',
100
+ 'time',
101
+ 'very',
102
+ 'when',
103
+ 'come',
104
+ 'made',
105
+ 'use',
106
+ 'using',
107
+ 'used',
68
108
  ]);
69
109
  let SkillsResearchService = class SkillsResearchService {
70
110
  indexPath;
@@ -6,8 +6,8 @@ import { z } from 'zod';
6
6
  export declare const TaxonomyCategoryTypeSchema: z.ZodEnum<{
7
7
  custom: "custom";
8
8
  runtime: "runtime";
9
- capability: "capability";
10
9
  role: "role";
10
+ capability: "capability";
11
11
  domain: "domain";
12
12
  }>;
13
13
  export declare const TaxonomyCategoryInputSchema: z.ZodObject<{
@@ -16,8 +16,8 @@ export declare const TaxonomyCategoryInputSchema: z.ZodObject<{
16
16
  type: z.ZodEnum<{
17
17
  custom: "custom";
18
18
  runtime: "runtime";
19
- capability: "capability";
20
19
  role: "role";
20
+ capability: "capability";
21
21
  domain: "domain";
22
22
  }>;
23
23
  level: z.ZodNumber;
@@ -31,8 +31,8 @@ export declare const TaxonomyCategorySchema: z.ZodObject<{
31
31
  type: z.ZodEnum<{
32
32
  custom: "custom";
33
33
  runtime: "runtime";
34
- capability: "capability";
35
34
  role: "role";
35
+ capability: "capability";
36
36
  domain: "domain";
37
37
  }>;
38
38
  level: z.ZodNumber;
@@ -157,7 +157,9 @@ export async function verifyAgentSignature(manifest, signature, agentId) {
157
157
  ...base,
158
158
  verified,
159
159
  tier: verified ? 'verified-signature' : 'signed',
160
- reason: verified ? undefined : 'Signature verification failed — payload mismatch or invalid key',
160
+ reason: verified
161
+ ? undefined
162
+ : 'Signature verification failed — payload mismatch or invalid key',
161
163
  };
162
164
  }
163
165
  catch (err) {
@@ -190,7 +192,7 @@ export async function signAgentManifest(manifest, privateKeyHex, issuer) {
190
192
  type: 'Ed25519',
191
193
  value: signatureB64,
192
194
  publicKey: publicKeyB64,
193
- timestamp: new Date().toISOString()
195
+ timestamp: new Date().toISOString(),
194
196
  };
195
197
  if (issuer) {
196
198
  signature.issuer = issuer;
@@ -201,8 +203,8 @@ export async function signAgentManifest(manifest, privateKeyHex, issuer) {
201
203
  ...manifest,
202
204
  metadata: {
203
205
  ...metadata,
204
- 'x-signature': signature
205
- }
206
+ 'x-signature': signature,
207
+ },
206
208
  };
207
209
  }
208
210
  // ─── Utilities ──────────────────────────────────────────────
@@ -22,16 +22,7 @@ import { z } from 'zod';
22
22
  import { inject, injectable } from 'inversify';
23
23
  import { SchemaRepository } from '../repositories/schema.repository.js';
24
24
  import { MessagingValidator } from './validators/messaging.validator.js';
25
- import { CursorValidator } from './validators/cursor.validator.js';
26
- import { OpenAIValidator } from './validators/openai.validator.js';
27
- import { CrewAIValidator } from './validators/crewai.validator.js';
28
- import { LangChainValidator } from './validators/langchain.validator.js';
29
- import { AnthropicValidator } from './validators/anthropic.validator.js';
30
- import { LangflowValidator } from './validators/langflow.validator.js';
31
- import { AutoGenValidator } from './validators/autogen.validator.js';
32
- import { VercelAIValidator } from './validators/vercel-ai.validator.js';
33
- import { LlamaIndexValidator } from './validators/llamaindex.validator.js';
34
- import { LangGraphValidator } from './validators/langgraph.validator.js';
25
+ import { createValidatorRegistry, } from './validators/registry.js';
35
26
  /**
36
27
  * Convert Zod error to Ajv ErrorObject format for compatibility
37
28
  */
@@ -85,18 +76,8 @@ let ValidationZodService = class ValidationZodService {
85
76
  platformValidators;
86
77
  constructor(schemaRepository) {
87
78
  this.schemaRepository = schemaRepository;
88
- // Initialize platform validators
89
- this.platformValidators = new Map();
90
- this.platformValidators.set('cursor', new CursorValidator());
91
- this.platformValidators.set('openai_agents', new OpenAIValidator());
92
- this.platformValidators.set('crewai', new CrewAIValidator());
93
- this.platformValidators.set('langchain', new LangChainValidator());
94
- this.platformValidators.set('anthropic', new AnthropicValidator());
95
- this.platformValidators.set('langflow', new LangflowValidator());
96
- this.platformValidators.set('autogen', new AutoGenValidator());
97
- this.platformValidators.set('vercel_ai', new VercelAIValidator());
98
- this.platformValidators.set('llamaindex', new LlamaIndexValidator());
99
- this.platformValidators.set('langgraph', new LangGraphValidator());
79
+ // Single source of truth: all platform validators live in registry.ts
80
+ this.platformValidators = createValidatorRegistry();
100
81
  }
101
82
  /**
102
83
  * Validate OSSA agent manifest using Zod
@@ -2,6 +2,7 @@
2
2
  * Platform Validators Index
3
3
  * Exports all platform-specific validators
4
4
  */
5
+ export { createValidatorRegistry, type PlatformValidator } from './registry.js';
5
6
  export { CursorValidator } from './cursor.validator.js';
6
7
  export { OpenAIValidator } from './openai.validator.js';
7
8
  export { CrewAIValidator } from './crewai.validator.js';
@@ -3,6 +3,7 @@
3
3
  * Platform Validators Index
4
4
  * Exports all platform-specific validators
5
5
  */
6
+ export { createValidatorRegistry } from './registry.js';
6
7
  export { CursorValidator } from './cursor.validator.js';
7
8
  export { OpenAIValidator } from './openai.validator.js';
8
9
  export { CrewAIValidator } from './crewai.validator.js';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Validator Registry Factory
3
+ *
4
+ * Single source of truth for all platform validators — add new validators here only.
5
+ *
6
+ * DRY: eliminates duplicate Map initialization across ValidationService implementations.
7
+ * To add a new platform validator: import it here and add one entry to the Map.
8
+ */
9
+ import type { OssaAgent, ValidationResult } from '../../types/index.js';
10
+ /** Shared interface for all platform validators registered in the registry. */
11
+ export interface PlatformValidator {
12
+ validate(manifest: OssaAgent): ValidationResult;
13
+ }
14
+ /**
15
+ * Create the canonical map of platform validators.
16
+ *
17
+ * Keys match the extension names used in OSSA agent manifests
18
+ * (i.e. the keys of `manifest.extensions`).
19
+ */
20
+ export declare function createValidatorRegistry(): Map<string, PlatformValidator>;
21
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1,42 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * Validator Registry Factory
4
+ *
5
+ * Single source of truth for all platform validators — add new validators here only.
6
+ *
7
+ * DRY: eliminates duplicate Map initialization across ValidationService implementations.
8
+ * To add a new platform validator: import it here and add one entry to the Map.
9
+ */
10
+ import { CursorValidator } from './cursor.validator.js';
11
+ import { OpenAIValidator } from './openai.validator.js';
12
+ import { CrewAIValidator } from './crewai.validator.js';
13
+ import { LangChainValidator } from './langchain.validator.js';
14
+ import { AnthropicValidator } from './anthropic.validator.js';
15
+ import { LangflowValidator } from './langflow.validator.js';
16
+ import { AutoGenValidator } from './autogen.validator.js';
17
+ import { VercelAIValidator } from './vercel-ai.validator.js';
18
+ import { LlamaIndexValidator } from './llamaindex.validator.js';
19
+ import { LangGraphValidator } from './langgraph.validator.js';
20
+ import { KagentValidator } from './kagent.validator.js';
21
+ /**
22
+ * Create the canonical map of platform validators.
23
+ *
24
+ * Keys match the extension names used in OSSA agent manifests
25
+ * (i.e. the keys of `manifest.extensions`).
26
+ */
27
+ export function createValidatorRegistry() {
28
+ return new Map([
29
+ ['cursor', new CursorValidator()],
30
+ ['openai_agents', new OpenAIValidator()],
31
+ ['crewai', new CrewAIValidator()],
32
+ ['langchain', new LangChainValidator()],
33
+ ['anthropic', new AnthropicValidator()],
34
+ ['langflow', new LangflowValidator()],
35
+ ['autogen', new AutoGenValidator()],
36
+ ['vercel_ai', new VercelAIValidator()],
37
+ ['llamaindex', new LlamaIndexValidator()],
38
+ ['langgraph', new LangGraphValidator()],
39
+ ['kagent', new KagentValidator()],
40
+ ]);
41
+ }
42
+ //# sourceMappingURL=registry.js.map
@@ -31,6 +31,6 @@
31
31
  ],
32
32
  "ossa": {
33
33
  "type": "claude-skill",
34
- "skillPath": "/var/folders/48/d86hncy50j93r_vzsv6knttr0000gn/T/ossa-export-test-1773084155160/test-skill"
34
+ "skillPath": "/var/folders/48/d86hncy50j93r_vzsv6knttr0000gn/T/ossa-export-test-1774702067895/test-skill"
35
35
  }
36
36
  }