digital-products 2.0.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 (110) hide show
  1. package/.turbo/turbo-build.log +5 -0
  2. package/CHANGELOG.md +9 -0
  3. package/README.md +535 -0
  4. package/dist/api.d.ts +99 -0
  5. package/dist/api.d.ts.map +1 -0
  6. package/dist/api.js +129 -0
  7. package/dist/api.js.map +1 -0
  8. package/dist/app.d.ts +79 -0
  9. package/dist/app.d.ts.map +1 -0
  10. package/dist/app.js +107 -0
  11. package/dist/app.js.map +1 -0
  12. package/dist/content.d.ts +58 -0
  13. package/dist/content.d.ts.map +1 -0
  14. package/dist/content.js +78 -0
  15. package/dist/content.js.map +1 -0
  16. package/dist/data.d.ts +67 -0
  17. package/dist/data.d.ts.map +1 -0
  18. package/dist/data.js +107 -0
  19. package/dist/data.js.map +1 -0
  20. package/dist/dataset.d.ts +32 -0
  21. package/dist/dataset.d.ts.map +1 -0
  22. package/dist/dataset.js +50 -0
  23. package/dist/dataset.js.map +1 -0
  24. package/dist/entities/ai.d.ts +53 -0
  25. package/dist/entities/ai.d.ts.map +1 -0
  26. package/dist/entities/ai.js +859 -0
  27. package/dist/entities/ai.js.map +1 -0
  28. package/dist/entities/content.d.ts +52 -0
  29. package/dist/entities/content.d.ts.map +1 -0
  30. package/dist/entities/content.js +784 -0
  31. package/dist/entities/content.js.map +1 -0
  32. package/dist/entities/index.d.ts +112 -0
  33. package/dist/entities/index.d.ts.map +1 -0
  34. package/dist/entities/index.js +89 -0
  35. package/dist/entities/index.js.map +1 -0
  36. package/dist/entities/interfaces.d.ts +67 -0
  37. package/dist/entities/interfaces.d.ts.map +1 -0
  38. package/dist/entities/interfaces.js +930 -0
  39. package/dist/entities/interfaces.js.map +1 -0
  40. package/dist/entities/lifecycle.d.ts +51 -0
  41. package/dist/entities/lifecycle.d.ts.map +1 -0
  42. package/dist/entities/lifecycle.js +804 -0
  43. package/dist/entities/lifecycle.js.map +1 -0
  44. package/dist/entities/products.d.ts +53 -0
  45. package/dist/entities/products.d.ts.map +1 -0
  46. package/dist/entities/products.js +798 -0
  47. package/dist/entities/products.js.map +1 -0
  48. package/dist/entities/web.d.ts +44 -0
  49. package/dist/entities/web.d.ts.map +1 -0
  50. package/dist/entities/web.js +658 -0
  51. package/dist/entities/web.js.map +1 -0
  52. package/dist/index.d.ts +29 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/index.js +36 -0
  55. package/dist/index.js.map +1 -0
  56. package/dist/mcp.d.ts +101 -0
  57. package/dist/mcp.d.ts.map +1 -0
  58. package/dist/mcp.js +140 -0
  59. package/dist/mcp.js.map +1 -0
  60. package/dist/product.d.ts +37 -0
  61. package/dist/product.d.ts.map +1 -0
  62. package/dist/product.js +54 -0
  63. package/dist/product.js.map +1 -0
  64. package/dist/registry.d.ts +9 -0
  65. package/dist/registry.d.ts.map +1 -0
  66. package/dist/registry.js +32 -0
  67. package/dist/registry.js.map +1 -0
  68. package/dist/sdk.d.ts +99 -0
  69. package/dist/sdk.d.ts.map +1 -0
  70. package/dist/sdk.js +128 -0
  71. package/dist/sdk.js.map +1 -0
  72. package/dist/site.d.ts +85 -0
  73. package/dist/site.d.ts.map +1 -0
  74. package/dist/site.js +113 -0
  75. package/dist/site.js.map +1 -0
  76. package/dist/types.d.ts +528 -0
  77. package/dist/types.d.ts.map +1 -0
  78. package/dist/types.js +5 -0
  79. package/dist/types.js.map +1 -0
  80. package/example.ts +236 -0
  81. package/package.json +35 -0
  82. package/src/api.ts +140 -0
  83. package/src/app.ts +117 -0
  84. package/src/content.ts +82 -0
  85. package/src/data.ts +129 -0
  86. package/src/dataset.ts +53 -0
  87. package/src/entities/ai.ts +932 -0
  88. package/src/entities/content.ts +851 -0
  89. package/src/entities/index.ts +156 -0
  90. package/src/entities/interfaces.ts +1017 -0
  91. package/src/entities/lifecycle.ts +872 -0
  92. package/src/entities/products.ts +867 -0
  93. package/src/entities/web.ts +719 -0
  94. package/src/index.ts +55 -0
  95. package/src/mcp.ts +163 -0
  96. package/src/product.ts +59 -0
  97. package/src/registry.ts +41 -0
  98. package/src/sdk.ts +148 -0
  99. package/src/site.ts +127 -0
  100. package/src/types.ts +558 -0
  101. package/test/api.test.ts +247 -0
  102. package/test/app.test.ts +220 -0
  103. package/test/content.test.ts +171 -0
  104. package/test/data.test.ts +201 -0
  105. package/test/dataset.test.ts +181 -0
  106. package/test/mcp.test.ts +230 -0
  107. package/test/product.test.ts +200 -0
  108. package/test/sdk.test.ts +236 -0
  109. package/test/site.test.ts +245 -0
  110. package/tsconfig.json +9 -0
@@ -0,0 +1,932 @@
1
+ /**
2
+ * AI Entity Types (Nouns)
3
+ *
4
+ * AI-native products: AIProduct, Model, Agent, Prompt, Tool
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+
9
+ import type { Noun } from 'ai-database'
10
+
11
+ // =============================================================================
12
+ // AIProduct
13
+ // =============================================================================
14
+
15
+ /**
16
+ * AIProduct entity
17
+ *
18
+ * AI-powered digital product.
19
+ */
20
+ export const AIProduct: Noun = {
21
+ singular: 'ai-product',
22
+ plural: 'ai-products',
23
+ description: 'An AI-powered digital product',
24
+
25
+ properties: {
26
+ // Identity
27
+ name: {
28
+ type: 'string',
29
+ description: 'Product name',
30
+ },
31
+ slug: {
32
+ type: 'string',
33
+ optional: true,
34
+ description: 'URL-friendly identifier',
35
+ },
36
+ description: {
37
+ type: 'string',
38
+ optional: true,
39
+ description: 'Product description',
40
+ },
41
+
42
+ // Classification
43
+ type: {
44
+ type: 'string',
45
+ description: 'AI product type',
46
+ examples: ['chatbot', 'copilot', 'assistant', 'generator', 'analyzer', 'classifier', 'recommender', 'autonomous'],
47
+ },
48
+ domain: {
49
+ type: 'string',
50
+ optional: true,
51
+ description: 'Application domain',
52
+ },
53
+
54
+ // AI Configuration
55
+ primaryModel: {
56
+ type: 'string',
57
+ optional: true,
58
+ description: 'Primary AI model',
59
+ examples: ['gpt-4', 'claude-3', 'gemini', 'llama', 'mistral', 'custom'],
60
+ },
61
+ modelProvider: {
62
+ type: 'string',
63
+ optional: true,
64
+ description: 'Model provider',
65
+ examples: ['openai', 'anthropic', 'google', 'meta', 'custom'],
66
+ },
67
+
68
+ // Capabilities
69
+ capabilities: {
70
+ type: 'string',
71
+ array: true,
72
+ optional: true,
73
+ description: 'AI capabilities',
74
+ examples: ['text-generation', 'code-generation', 'image-generation', 'speech', 'vision', 'reasoning'],
75
+ },
76
+ modalities: {
77
+ type: 'string',
78
+ array: true,
79
+ optional: true,
80
+ description: 'Supported modalities',
81
+ examples: ['text', 'image', 'audio', 'video', 'code'],
82
+ },
83
+
84
+ // Integration
85
+ hasTools: {
86
+ type: 'boolean',
87
+ optional: true,
88
+ description: 'Has tool/function calling',
89
+ },
90
+ hasRAG: {
91
+ type: 'boolean',
92
+ optional: true,
93
+ description: 'Has retrieval augmented generation',
94
+ },
95
+ hasMemory: {
96
+ type: 'boolean',
97
+ optional: true,
98
+ description: 'Has conversation memory',
99
+ },
100
+ hasAgents: {
101
+ type: 'boolean',
102
+ optional: true,
103
+ description: 'Has autonomous agents',
104
+ },
105
+
106
+ // Autonomy
107
+ autonomyLevel: {
108
+ type: 'string',
109
+ optional: true,
110
+ description: 'Level of autonomous operation',
111
+ examples: ['manual', 'assisted', 'supervised', 'autonomous'],
112
+ },
113
+
114
+ // Safety
115
+ contentFiltering: {
116
+ type: 'boolean',
117
+ optional: true,
118
+ description: 'Content filtering enabled',
119
+ },
120
+ moderationEnabled: {
121
+ type: 'boolean',
122
+ optional: true,
123
+ description: 'Moderation enabled',
124
+ },
125
+
126
+ // Metrics
127
+ requestsPerDay: {
128
+ type: 'number',
129
+ optional: true,
130
+ description: 'Average daily requests',
131
+ },
132
+ averageLatencyMs: {
133
+ type: 'number',
134
+ optional: true,
135
+ description: 'Average latency in ms',
136
+ },
137
+
138
+ // Status
139
+ status: {
140
+ type: 'string',
141
+ description: 'Product status',
142
+ examples: ['draft', 'alpha', 'beta', 'production', 'deprecated'],
143
+ },
144
+ },
145
+
146
+ relationships: {
147
+ product: {
148
+ type: 'DigitalProduct',
149
+ description: 'Parent product',
150
+ },
151
+ models: {
152
+ type: 'Model[]',
153
+ description: 'AI models used',
154
+ },
155
+ agents: {
156
+ type: 'Agent[]',
157
+ description: 'AI agents',
158
+ },
159
+ prompts: {
160
+ type: 'Prompt[]',
161
+ description: 'Prompt templates',
162
+ },
163
+ tools: {
164
+ type: 'Tool[]',
165
+ description: 'Available tools',
166
+ },
167
+ },
168
+
169
+ actions: [
170
+ 'create',
171
+ 'update',
172
+ 'deploy',
173
+ 'addModel',
174
+ 'removeModel',
175
+ 'addAgent',
176
+ 'removeAgent',
177
+ 'evaluate',
178
+ 'deprecate',
179
+ ],
180
+
181
+ events: [
182
+ 'created',
183
+ 'updated',
184
+ 'deployed',
185
+ 'modelAdded',
186
+ 'modelRemoved',
187
+ 'agentAdded',
188
+ 'agentRemoved',
189
+ 'evaluated',
190
+ 'deprecated',
191
+ ],
192
+ }
193
+
194
+ // =============================================================================
195
+ // Model
196
+ // =============================================================================
197
+
198
+ /**
199
+ * Model entity
200
+ *
201
+ * ML/AI model definition.
202
+ */
203
+ export const Model: Noun = {
204
+ singular: 'model',
205
+ plural: 'models',
206
+ description: 'An ML/AI model',
207
+
208
+ properties: {
209
+ // Identity
210
+ name: {
211
+ type: 'string',
212
+ description: 'Model name',
213
+ },
214
+ slug: {
215
+ type: 'string',
216
+ optional: true,
217
+ description: 'URL-friendly identifier',
218
+ },
219
+ description: {
220
+ type: 'string',
221
+ optional: true,
222
+ description: 'Model description',
223
+ },
224
+
225
+ // Type
226
+ type: {
227
+ type: 'string',
228
+ description: 'Model type',
229
+ examples: ['llm', 'embedding', 'classification', 'regression', 'generation', 'vision', 'speech', 'multimodal'],
230
+ },
231
+ architecture: {
232
+ type: 'string',
233
+ optional: true,
234
+ description: 'Model architecture',
235
+ examples: ['transformer', 'diffusion', 'cnn', 'rnn', 'custom'],
236
+ },
237
+
238
+ // Provider
239
+ provider: {
240
+ type: 'string',
241
+ optional: true,
242
+ description: 'Model provider',
243
+ examples: ['openai', 'anthropic', 'google', 'meta', 'mistral', 'huggingface', 'custom'],
244
+ },
245
+ modelId: {
246
+ type: 'string',
247
+ optional: true,
248
+ description: 'Provider model ID',
249
+ },
250
+
251
+ // Capabilities
252
+ contextWindow: {
253
+ type: 'number',
254
+ optional: true,
255
+ description: 'Context window size (tokens)',
256
+ },
257
+ maxOutputTokens: {
258
+ type: 'number',
259
+ optional: true,
260
+ description: 'Max output tokens',
261
+ },
262
+ supportsFunctions: {
263
+ type: 'boolean',
264
+ optional: true,
265
+ description: 'Supports function calling',
266
+ },
267
+ supportsVision: {
268
+ type: 'boolean',
269
+ optional: true,
270
+ description: 'Supports image input',
271
+ },
272
+ supportsStreaming: {
273
+ type: 'boolean',
274
+ optional: true,
275
+ description: 'Supports streaming output',
276
+ },
277
+
278
+ // Fine-tuning
279
+ fineTuned: {
280
+ type: 'boolean',
281
+ optional: true,
282
+ description: 'Is fine-tuned',
283
+ },
284
+ baseModel: {
285
+ type: 'string',
286
+ optional: true,
287
+ description: 'Base model for fine-tuning',
288
+ },
289
+ trainingDataset: {
290
+ type: 'string',
291
+ optional: true,
292
+ description: 'Training dataset',
293
+ },
294
+
295
+ // Hosting
296
+ hostingType: {
297
+ type: 'string',
298
+ optional: true,
299
+ description: 'Hosting type',
300
+ examples: ['api', 'self-hosted', 'edge', 'serverless'],
301
+ },
302
+ endpoint: {
303
+ type: 'string',
304
+ optional: true,
305
+ description: 'API endpoint',
306
+ },
307
+
308
+ // Performance
309
+ latencyP50: {
310
+ type: 'number',
311
+ optional: true,
312
+ description: 'P50 latency (ms)',
313
+ },
314
+ latencyP99: {
315
+ type: 'number',
316
+ optional: true,
317
+ description: 'P99 latency (ms)',
318
+ },
319
+ tokensPerSecond: {
320
+ type: 'number',
321
+ optional: true,
322
+ description: 'Tokens per second',
323
+ },
324
+
325
+ // Pricing
326
+ inputPricePerMillion: {
327
+ type: 'number',
328
+ optional: true,
329
+ description: 'Price per million input tokens',
330
+ },
331
+ outputPricePerMillion: {
332
+ type: 'number',
333
+ optional: true,
334
+ description: 'Price per million output tokens',
335
+ },
336
+
337
+ // Status
338
+ status: {
339
+ type: 'string',
340
+ description: 'Model status',
341
+ examples: ['training', 'evaluating', 'active', 'deprecated'],
342
+ },
343
+ version: {
344
+ type: 'string',
345
+ optional: true,
346
+ description: 'Model version',
347
+ },
348
+ },
349
+
350
+ relationships: {
351
+ aiProduct: {
352
+ type: 'AIProduct',
353
+ required: false,
354
+ description: 'Parent AI product',
355
+ },
356
+ evaluations: {
357
+ type: 'ModelEvaluation[]',
358
+ description: 'Model evaluations',
359
+ },
360
+ },
361
+
362
+ actions: [
363
+ 'create',
364
+ 'update',
365
+ 'train',
366
+ 'evaluate',
367
+ 'deploy',
368
+ 'undeploy',
369
+ 'deprecate',
370
+ ],
371
+
372
+ events: [
373
+ 'created',
374
+ 'updated',
375
+ 'trained',
376
+ 'evaluated',
377
+ 'deployed',
378
+ 'undeployed',
379
+ 'deprecated',
380
+ ],
381
+ }
382
+
383
+ // =============================================================================
384
+ // Agent
385
+ // =============================================================================
386
+
387
+ /**
388
+ * Agent entity
389
+ *
390
+ * Autonomous AI agent product.
391
+ */
392
+ export const Agent: Noun = {
393
+ singular: 'agent',
394
+ plural: 'agents',
395
+ description: 'An autonomous AI agent',
396
+
397
+ properties: {
398
+ // Identity
399
+ name: {
400
+ type: 'string',
401
+ description: 'Agent name',
402
+ },
403
+ slug: {
404
+ type: 'string',
405
+ optional: true,
406
+ description: 'URL-friendly identifier',
407
+ },
408
+ description: {
409
+ type: 'string',
410
+ optional: true,
411
+ description: 'Agent description',
412
+ },
413
+
414
+ // Purpose
415
+ role: {
416
+ type: 'string',
417
+ optional: true,
418
+ description: 'Agent role',
419
+ },
420
+ goal: {
421
+ type: 'string',
422
+ optional: true,
423
+ description: 'Agent goal',
424
+ },
425
+ backstory: {
426
+ type: 'string',
427
+ optional: true,
428
+ description: 'Agent backstory/context',
429
+ },
430
+
431
+ // Configuration
432
+ systemPrompt: {
433
+ type: 'string',
434
+ optional: true,
435
+ description: 'System prompt',
436
+ },
437
+ model: {
438
+ type: 'string',
439
+ optional: true,
440
+ description: 'AI model used',
441
+ },
442
+ temperature: {
443
+ type: 'number',
444
+ optional: true,
445
+ description: 'Model temperature',
446
+ },
447
+
448
+ // Capabilities
449
+ tools: {
450
+ type: 'string',
451
+ array: true,
452
+ optional: true,
453
+ description: 'Available tools',
454
+ },
455
+ allowedActions: {
456
+ type: 'string',
457
+ array: true,
458
+ optional: true,
459
+ description: 'Allowed actions',
460
+ },
461
+
462
+ // Autonomy
463
+ autonomyLevel: {
464
+ type: 'string',
465
+ description: 'Autonomy level',
466
+ examples: ['advisory', 'assisted', 'supervised', 'autonomous'],
467
+ },
468
+ maxIterations: {
469
+ type: 'number',
470
+ optional: true,
471
+ description: 'Max iterations per task',
472
+ },
473
+ requiresApproval: {
474
+ type: 'boolean',
475
+ optional: true,
476
+ description: 'Requires human approval',
477
+ },
478
+ approvalThreshold: {
479
+ type: 'number',
480
+ optional: true,
481
+ description: 'Confidence threshold for auto-approval',
482
+ },
483
+
484
+ // Memory
485
+ memoryEnabled: {
486
+ type: 'boolean',
487
+ optional: true,
488
+ description: 'Memory enabled',
489
+ },
490
+ memoryType: {
491
+ type: 'string',
492
+ optional: true,
493
+ description: 'Memory type',
494
+ examples: ['short-term', 'long-term', 'episodic', 'semantic'],
495
+ },
496
+
497
+ // Collaboration
498
+ canDelegate: {
499
+ type: 'boolean',
500
+ optional: true,
501
+ description: 'Can delegate to other agents',
502
+ },
503
+ canCollaborate: {
504
+ type: 'boolean',
505
+ optional: true,
506
+ description: 'Can collaborate with other agents',
507
+ },
508
+
509
+ // Safety
510
+ guardrails: {
511
+ type: 'string',
512
+ array: true,
513
+ optional: true,
514
+ description: 'Safety guardrails',
515
+ },
516
+ escalationRules: {
517
+ type: 'json',
518
+ optional: true,
519
+ description: 'Escalation rules',
520
+ },
521
+
522
+ // Status
523
+ status: {
524
+ type: 'string',
525
+ description: 'Agent status',
526
+ examples: ['draft', 'testing', 'active', 'paused', 'deprecated'],
527
+ },
528
+ },
529
+
530
+ relationships: {
531
+ aiProduct: {
532
+ type: 'AIProduct',
533
+ required: false,
534
+ description: 'Parent AI product',
535
+ },
536
+ modelRef: {
537
+ type: 'Model',
538
+ required: false,
539
+ description: 'AI model',
540
+ },
541
+ toolRefs: {
542
+ type: 'Tool[]',
543
+ description: 'Available tools',
544
+ },
545
+ crew: {
546
+ type: 'Agent[]',
547
+ description: 'Collaborating agents',
548
+ },
549
+ tasks: {
550
+ type: 'AgentTask[]',
551
+ description: 'Assigned tasks',
552
+ },
553
+ },
554
+
555
+ actions: [
556
+ 'create',
557
+ 'update',
558
+ 'activate',
559
+ 'pause',
560
+ 'assignTask',
561
+ 'execute',
562
+ 'escalate',
563
+ 'evaluate',
564
+ 'deprecate',
565
+ ],
566
+
567
+ events: [
568
+ 'created',
569
+ 'updated',
570
+ 'activated',
571
+ 'paused',
572
+ 'taskAssigned',
573
+ 'executed',
574
+ 'escalated',
575
+ 'evaluated',
576
+ 'deprecated',
577
+ ],
578
+ }
579
+
580
+ // =============================================================================
581
+ // Prompt
582
+ // =============================================================================
583
+
584
+ /**
585
+ * Prompt entity
586
+ *
587
+ * Prompt template or library.
588
+ */
589
+ export const Prompt: Noun = {
590
+ singular: 'prompt',
591
+ plural: 'prompts',
592
+ description: 'A prompt template for AI interactions',
593
+
594
+ properties: {
595
+ // Identity
596
+ name: {
597
+ type: 'string',
598
+ description: 'Prompt name',
599
+ },
600
+ slug: {
601
+ type: 'string',
602
+ optional: true,
603
+ description: 'URL-friendly identifier',
604
+ },
605
+ description: {
606
+ type: 'string',
607
+ optional: true,
608
+ description: 'Prompt description',
609
+ },
610
+
611
+ // Content
612
+ template: {
613
+ type: 'string',
614
+ description: 'Prompt template',
615
+ },
616
+ systemPrompt: {
617
+ type: 'string',
618
+ optional: true,
619
+ description: 'System prompt portion',
620
+ },
621
+
622
+ // Classification
623
+ type: {
624
+ type: 'string',
625
+ description: 'Prompt type',
626
+ examples: ['system', 'user', 'assistant', 'few-shot', 'chain-of-thought', 'function'],
627
+ },
628
+ category: {
629
+ type: 'string',
630
+ optional: true,
631
+ description: 'Prompt category',
632
+ },
633
+
634
+ // Variables
635
+ variables: {
636
+ type: 'json',
637
+ optional: true,
638
+ description: 'Template variables schema',
639
+ },
640
+ defaultValues: {
641
+ type: 'json',
642
+ optional: true,
643
+ description: 'Default variable values',
644
+ },
645
+
646
+ // Examples
647
+ exampleInput: {
648
+ type: 'string',
649
+ optional: true,
650
+ description: 'Example input',
651
+ },
652
+ exampleOutput: {
653
+ type: 'string',
654
+ optional: true,
655
+ description: 'Expected output',
656
+ },
657
+
658
+ // Target
659
+ targetModel: {
660
+ type: 'string',
661
+ optional: true,
662
+ description: 'Target model',
663
+ },
664
+ targetModels: {
665
+ type: 'string',
666
+ array: true,
667
+ optional: true,
668
+ description: 'Compatible models',
669
+ },
670
+
671
+ // Output
672
+ outputFormat: {
673
+ type: 'string',
674
+ optional: true,
675
+ description: 'Expected output format',
676
+ examples: ['text', 'json', 'markdown', 'code', 'structured'],
677
+ },
678
+ outputSchema: {
679
+ type: 'json',
680
+ optional: true,
681
+ description: 'Output schema for structured output',
682
+ },
683
+
684
+ // Metrics
685
+ averageTokens: {
686
+ type: 'number',
687
+ optional: true,
688
+ description: 'Average token usage',
689
+ },
690
+ useCount: {
691
+ type: 'number',
692
+ optional: true,
693
+ description: 'Number of uses',
694
+ },
695
+ successRate: {
696
+ type: 'number',
697
+ optional: true,
698
+ description: 'Success rate (0-1)',
699
+ },
700
+
701
+ // Status
702
+ status: {
703
+ type: 'string',
704
+ description: 'Prompt status',
705
+ examples: ['draft', 'testing', 'active', 'deprecated'],
706
+ },
707
+ version: {
708
+ type: 'string',
709
+ optional: true,
710
+ description: 'Prompt version',
711
+ },
712
+ },
713
+
714
+ relationships: {
715
+ aiProduct: {
716
+ type: 'AIProduct',
717
+ required: false,
718
+ description: 'Parent AI product',
719
+ },
720
+ mcp: {
721
+ type: 'MCP',
722
+ required: false,
723
+ description: 'MCP server',
724
+ },
725
+ versions: {
726
+ type: 'PromptVersion[]',
727
+ description: 'Prompt versions',
728
+ },
729
+ },
730
+
731
+ actions: [
732
+ 'create',
733
+ 'update',
734
+ 'test',
735
+ 'publish',
736
+ 'version',
737
+ 'deprecate',
738
+ ],
739
+
740
+ events: [
741
+ 'created',
742
+ 'updated',
743
+ 'tested',
744
+ 'published',
745
+ 'versioned',
746
+ 'deprecated',
747
+ ],
748
+ }
749
+
750
+ // =============================================================================
751
+ // Tool
752
+ // =============================================================================
753
+
754
+ /**
755
+ * Tool entity
756
+ *
757
+ * AI tool definition for function calling.
758
+ */
759
+ export const Tool: Noun = {
760
+ singular: 'tool',
761
+ plural: 'tools',
762
+ description: 'A tool for AI function calling',
763
+
764
+ properties: {
765
+ // Identity
766
+ name: {
767
+ type: 'string',
768
+ description: 'Tool name',
769
+ },
770
+ description: {
771
+ type: 'string',
772
+ description: 'Tool description for AI',
773
+ },
774
+
775
+ // Classification
776
+ type: {
777
+ type: 'string',
778
+ description: 'Tool type',
779
+ examples: ['function', 'api', 'database', 'file', 'web', 'system', 'custom'],
780
+ },
781
+ category: {
782
+ type: 'string',
783
+ optional: true,
784
+ description: 'Tool category',
785
+ },
786
+
787
+ // Interface
788
+ inputSchema: {
789
+ type: 'json',
790
+ description: 'Input parameters schema',
791
+ },
792
+ outputSchema: {
793
+ type: 'json',
794
+ optional: true,
795
+ description: 'Output schema',
796
+ },
797
+
798
+ // Execution
799
+ handler: {
800
+ type: 'string',
801
+ optional: true,
802
+ description: 'Handler function/endpoint',
803
+ },
804
+ async: {
805
+ type: 'boolean',
806
+ optional: true,
807
+ description: 'Async execution',
808
+ },
809
+ timeoutMs: {
810
+ type: 'number',
811
+ optional: true,
812
+ description: 'Execution timeout',
813
+ },
814
+
815
+ // Permissions
816
+ requiresAuth: {
817
+ type: 'boolean',
818
+ optional: true,
819
+ description: 'Requires authentication',
820
+ },
821
+ requiredScopes: {
822
+ type: 'string',
823
+ array: true,
824
+ optional: true,
825
+ description: 'Required permission scopes',
826
+ },
827
+ dangerous: {
828
+ type: 'boolean',
829
+ optional: true,
830
+ description: 'Potentially dangerous operation',
831
+ },
832
+ requiresConfirmation: {
833
+ type: 'boolean',
834
+ optional: true,
835
+ description: 'Requires user confirmation',
836
+ },
837
+
838
+ // Rate Limiting
839
+ rateLimit: {
840
+ type: 'number',
841
+ optional: true,
842
+ description: 'Rate limit per minute',
843
+ },
844
+ cooldownMs: {
845
+ type: 'number',
846
+ optional: true,
847
+ description: 'Cooldown between calls',
848
+ },
849
+
850
+ // Metrics
851
+ callCount: {
852
+ type: 'number',
853
+ optional: true,
854
+ description: 'Total call count',
855
+ },
856
+ successRate: {
857
+ type: 'number',
858
+ optional: true,
859
+ description: 'Success rate (0-1)',
860
+ },
861
+ averageLatencyMs: {
862
+ type: 'number',
863
+ optional: true,
864
+ description: 'Average latency',
865
+ },
866
+
867
+ // Status
868
+ status: {
869
+ type: 'string',
870
+ description: 'Tool status',
871
+ examples: ['draft', 'active', 'deprecated'],
872
+ },
873
+ },
874
+
875
+ relationships: {
876
+ aiProduct: {
877
+ type: 'AIProduct',
878
+ required: false,
879
+ description: 'Parent AI product',
880
+ },
881
+ mcp: {
882
+ type: 'MCP',
883
+ required: false,
884
+ description: 'MCP server',
885
+ },
886
+ agent: {
887
+ type: 'Agent',
888
+ required: false,
889
+ description: 'Assigned agent',
890
+ },
891
+ },
892
+
893
+ actions: [
894
+ 'create',
895
+ 'update',
896
+ 'enable',
897
+ 'disable',
898
+ 'execute',
899
+ 'test',
900
+ 'deprecate',
901
+ ],
902
+
903
+ events: [
904
+ 'created',
905
+ 'updated',
906
+ 'enabled',
907
+ 'disabled',
908
+ 'executed',
909
+ 'tested',
910
+ 'deprecated',
911
+ ],
912
+ }
913
+
914
+ // =============================================================================
915
+ // Exports
916
+ // =============================================================================
917
+
918
+ export const AIEntities = {
919
+ AIProduct,
920
+ Model,
921
+ Agent,
922
+ Prompt,
923
+ Tool,
924
+ }
925
+
926
+ export const AICategories = {
927
+ products: ['AIProduct'],
928
+ models: ['Model'],
929
+ agents: ['Agent'],
930
+ prompts: ['Prompt'],
931
+ tools: ['Tool'],
932
+ } as const