@nextsparkjs/plugin-ai 0.1.0-beta.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 (34) hide show
  1. package/.env.example +79 -0
  2. package/README.md +529 -0
  3. package/api/README.md +65 -0
  4. package/api/ai-history/[id]/route.ts +112 -0
  5. package/api/embeddings/route.ts +129 -0
  6. package/api/generate/route.ts +160 -0
  7. package/docs/01-getting-started/01-introduction.md +237 -0
  8. package/docs/01-getting-started/02-installation.md +447 -0
  9. package/docs/01-getting-started/03-configuration.md +416 -0
  10. package/docs/02-features/01-text-generation.md +523 -0
  11. package/docs/02-features/02-embeddings.md +241 -0
  12. package/docs/02-features/03-ai-history.md +549 -0
  13. package/docs/03-advanced-usage/01-core-utilities.md +500 -0
  14. package/docs/04-use-cases/01-content-generation.md +453 -0
  15. package/entities/ai-history/ai-history.config.ts +123 -0
  16. package/entities/ai-history/ai-history.fields.ts +330 -0
  17. package/entities/ai-history/messages/en.json +56 -0
  18. package/entities/ai-history/messages/es.json +56 -0
  19. package/entities/ai-history/migrations/001_ai_history_table.sql +167 -0
  20. package/entities/ai-history/migrations/002_ai_history_metas.sql +103 -0
  21. package/lib/ai-history-meta-service.ts +379 -0
  22. package/lib/ai-history-service.ts +391 -0
  23. package/lib/ai-sdk.ts +7 -0
  24. package/lib/core-utils.ts +217 -0
  25. package/lib/plugin-env.ts +252 -0
  26. package/lib/sanitize.ts +122 -0
  27. package/lib/save-example.ts +237 -0
  28. package/lib/server-env.ts +104 -0
  29. package/package.json +23 -0
  30. package/plugin.config.ts +55 -0
  31. package/public/docs/login-404-error.png +0 -0
  32. package/tsconfig.json +47 -0
  33. package/tsconfig.tsbuildinfo +1 -0
  34. package/types/ai.types.ts +51 -0
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@nextsparkjs/plugin-ai",
3
+ "version": "0.1.0-beta.1",
4
+ "private": false,
5
+ "main": "./plugin.config.ts",
6
+ "requiredPlugins": [],
7
+ "dependencies": {
8
+ "@ai-sdk/anthropic": "^2.0.17",
9
+ "@ai-sdk/openai": "^2.0.32",
10
+ "@ai-sdk/openai-compatible": "^1.0.18",
11
+ "ai": "^5.0.46",
12
+ "ollama-ai-provider": "^1.2.0"
13
+ },
14
+ "peerDependencies": {
15
+ "@nextsparkjs/core": "workspace:*",
16
+ "@tanstack/react-query": "^5.0.0",
17
+ "lucide-react": "^0.539.0",
18
+ "next": "^15.0.0",
19
+ "react": "^19.0.0",
20
+ "react-dom": "^19.0.0",
21
+ "zod": "^4.0.0"
22
+ }
23
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * AI Plugin Configuration
3
+ *
4
+ * Ultra-dynamic AI plugin - provides only core utilities
5
+ * Users create their own endpoints, components, and hooks
6
+ */
7
+
8
+ import type { PluginConfig } from '@nextsparkjs/core/types/plugin'
9
+
10
+ // Core utilities for user endpoints
11
+ import {
12
+ selectModel,
13
+ calculateCost,
14
+ validatePlugin,
15
+ extractTokens,
16
+ handleAIError,
17
+ COST_CONFIG
18
+ } from './lib/core-utils'
19
+
20
+ // Types are available for import: './types/ai.types'
21
+
22
+ /**
23
+ * Ultra-dynamic AI plugin configuration
24
+ */
25
+ export const aiPluginConfig: PluginConfig = {
26
+ name: 'ai',
27
+ displayName: 'AI Core Utilities',
28
+ version: '1.0.0',
29
+ description: 'Core AI utilities for building custom endpoints and integrations',
30
+ enabled: true,
31
+ dependencies: [],
32
+
33
+ // Core API - users import these functions directly
34
+ api: {
35
+ selectModel,
36
+ calculateCost,
37
+ validatePlugin,
38
+ extractTokens,
39
+ handleAIError,
40
+ COST_CONFIG
41
+ },
42
+
43
+ // TypeScript types available for import
44
+ // Import from: '@/contents/plugins/ai/types/ai.types'
45
+
46
+ // Plugin lifecycle hooks
47
+ hooks: {
48
+ onLoad: async () => {
49
+ console.log('[AI Plugin] Core utilities loaded - ready for custom endpoints')
50
+ }
51
+ }
52
+ }
53
+
54
+ // Default export for compatibility
55
+ export default aiPluginConfig
Binary file
package/tsconfig.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "noEmit": true,
5
+ "baseUrl": ".",
6
+ "moduleResolution": "node",
7
+ "paths": {
8
+ "@/*": ["../../../*"],
9
+ "@/core/*": ["../../../core/*"],
10
+ "@/contents/*": ["../../../contents/*"],
11
+ "~/*": ["./*"]
12
+ }
13
+ },
14
+ "watchOptions": {
15
+ "watchFile": "useFsEvents",
16
+ "watchDirectory": "useFsEvents",
17
+ "fallbackPolling": "dynamicPriority",
18
+ "synchronousWatchDirectory": false,
19
+ "excludeDirectories": [
20
+ "**/node_modules",
21
+ "**/.next",
22
+ "**/dist",
23
+ "**/build",
24
+ "**/.turbo",
25
+ "**/coverage",
26
+ "**/.git"
27
+ ]
28
+ },
29
+ "include": [
30
+ "**/*.ts",
31
+ "**/*.tsx",
32
+ "plugin.config.ts"
33
+ ],
34
+ "exclude": [
35
+ "node_modules",
36
+ ".next",
37
+ "dist",
38
+ "build",
39
+ ".turbo",
40
+ "coverage",
41
+ ".git",
42
+ "**/*.test.ts",
43
+ "**/*.test.tsx",
44
+ "**/__tests__/**",
45
+ "**/tsconfig.tsbuildinfo"
46
+ ]
47
+ }