@skillful-ai/skai-sdk 1.0.7 → 1.0.8

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 (90) hide show
  1. package/.eslintrc.json +15 -0
  2. package/package.json +7 -18
  3. package/project.json +31 -0
  4. package/src/clients/admin-client.ts +72 -0
  5. package/src/clients/agents-client.ts +561 -0
  6. package/src/clients/base-client.ts +178 -0
  7. package/src/clients/index.ts +5 -0
  8. package/src/clients/training-hub-client.ts +507 -0
  9. package/src/clients/user-client.ts +172 -0
  10. package/src/constants.ts +12 -0
  11. package/src/errors.ts +21 -0
  12. package/src/{index.d.ts → index.ts} +21 -17
  13. package/src/streaming/index.ts +12 -0
  14. package/src/types/admin-api-types.ts +60 -0
  15. package/src/types/agents-api-types.ts +184 -0
  16. package/src/types/api-types.ts +26 -0
  17. package/src/types/index.ts +5 -0
  18. package/src/types/streaming.ts +123 -0
  19. package/src/types/training-hub-api-types.ts +272 -0
  20. package/src/types/user-api-types.ts +89 -0
  21. package/src/utils/index.ts +1 -0
  22. package/src/utils/{logger-adapter.js → logger-adapter.ts} +17 -19
  23. package/src/utils/skai-helpers.ts +69 -0
  24. package/src/utils/{stream-metrics.js → stream-metrics.ts} +58 -42
  25. package/src/utils/stream-parser.ts +198 -0
  26. package/tsconfig.json +19 -0
  27. package/tsconfig.lib.json +11 -0
  28. package/src/clients/admin-client.d.ts +0 -39
  29. package/src/clients/admin-client.js +0 -51
  30. package/src/clients/admin-client.js.map +0 -1
  31. package/src/clients/agents-client.d.ts +0 -101
  32. package/src/clients/agents-client.js +0 -437
  33. package/src/clients/agents-client.js.map +0 -1
  34. package/src/clients/base-client.d.ts +0 -22
  35. package/src/clients/base-client.js +0 -148
  36. package/src/clients/base-client.js.map +0 -1
  37. package/src/clients/index.d.ts +0 -5
  38. package/src/clients/index.js +0 -9
  39. package/src/clients/index.js.map +0 -1
  40. package/src/clients/training-hub-client.d.ts +0 -127
  41. package/src/clients/training-hub-client.js +0 -404
  42. package/src/clients/training-hub-client.js.map +0 -1
  43. package/src/clients/user-client.d.ts +0 -77
  44. package/src/clients/user-client.js +0 -134
  45. package/src/clients/user-client.js.map +0 -1
  46. package/src/constants.d.ts +0 -6
  47. package/src/constants.js +0 -13
  48. package/src/constants.js.map +0 -1
  49. package/src/errors.d.ts +0 -18
  50. package/src/errors.js +0 -23
  51. package/src/errors.js.map +0 -1
  52. package/src/index.js +0 -55
  53. package/src/index.js.map +0 -1
  54. package/src/streaming/index.d.ts +0 -6
  55. package/src/streaming/index.js +0 -13
  56. package/src/streaming/index.js.map +0 -1
  57. package/src/types/admin-api-types.d.ts +0 -70
  58. package/src/types/admin-api-types.js +0 -48
  59. package/src/types/admin-api-types.js.map +0 -1
  60. package/src/types/agents-api-types.d.ts +0 -192
  61. package/src/types/agents-api-types.js +0 -135
  62. package/src/types/agents-api-types.js.map +0 -1
  63. package/src/types/api-types.d.ts +0 -20
  64. package/src/types/api-types.js +0 -12
  65. package/src/types/api-types.js.map +0 -1
  66. package/src/types/index.d.ts +0 -5
  67. package/src/types/index.js +0 -9
  68. package/src/types/index.js.map +0 -1
  69. package/src/types/streaming.d.ts +0 -109
  70. package/src/types/streaming.js +0 -55
  71. package/src/types/streaming.js.map +0 -1
  72. package/src/types/training-hub-api-types.d.ts +0 -223
  73. package/src/types/training-hub-api-types.js +0 -9
  74. package/src/types/training-hub-api-types.js.map +0 -1
  75. package/src/types/user-api-types.d.ts +0 -83
  76. package/src/types/user-api-types.js +0 -66
  77. package/src/types/user-api-types.js.map +0 -1
  78. package/src/utils/index.d.ts +0 -1
  79. package/src/utils/index.js +0 -5
  80. package/src/utils/index.js.map +0 -1
  81. package/src/utils/logger-adapter.d.ts +0 -7
  82. package/src/utils/logger-adapter.js.map +0 -1
  83. package/src/utils/skai-helpers.d.ts +0 -24
  84. package/src/utils/skai-helpers.js +0 -56
  85. package/src/utils/skai-helpers.js.map +0 -1
  86. package/src/utils/stream-metrics.d.ts +0 -55
  87. package/src/utils/stream-metrics.js.map +0 -1
  88. package/src/utils/stream-parser.d.ts +0 -49
  89. package/src/utils/stream-parser.js +0 -181
  90. package/src/utils/stream-parser.js.map +0 -1
package/.eslintrc.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": ["../../../.eslintrc.json"],
3
+ "ignorePatterns": ["!**/*"],
4
+ "overrides": [
5
+ {
6
+ "files": ["*.ts", "*.tsx"],
7
+ "rules": {}
8
+ },
9
+ {
10
+ "files": ["*.json"],
11
+ "parser": "jsonc-eslint-parser",
12
+ "rules": {}
13
+ }
14
+ ]
15
+ }
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "@skillful-ai/skai-sdk",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "SKAI SDK for interacting with Skillful AI Agents API",
5
- "main": "./src/index.js",
6
- "types": "./src/index.d.ts",
5
+ "main": "./dist/src/index.js",
6
+ "types": "./dist/src/index.d.ts",
7
7
  "type": "commonjs",
8
+ "scripts": {
9
+ "build": "tsc -p tsconfig.lib.json"
10
+ },
8
11
  "dependencies": {
9
12
  "@sinclair/typebox": "0.34.11",
10
13
  "axios": "^1.8.3",
11
- "fastify": "5.4.0",
12
14
  "tslib": "^2.3.0"
13
15
  },
14
16
  "keywords": [
@@ -19,18 +21,5 @@
19
21
  "sdk"
20
22
  ],
21
23
  "author": "Skillful AI",
22
- "license": "MIT",
23
- "overrides": {
24
- "@tryfabric/martian": {
25
- "@notionhq/client": "$@notionhq/client"
26
- },
27
- "vite": {
28
- "rollup": "npm:@rollup/wasm-node"
29
- },
30
- "undici": "6.19.8"
31
- },
32
- "resolutions": {
33
- "rollup": "npm:@rollup/wasm-node",
34
- "undici": "6.19.8"
35
- }
24
+ "license": "MIT"
36
25
  }
package/project.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "skai-sdk",
3
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/custom/skai-sdk",
5
+ "projectType": "library",
6
+ "targets": {
7
+ "build": {
8
+ "executor": "@nx/js:tsc",
9
+ "outputs": ["{options.outputPath}"],
10
+ "options": {
11
+ "outputPath": "dist/packages/custom/skai-sdk",
12
+ "main": "packages/custom/skai-sdk/src/index.ts",
13
+ "tsConfig": "packages/custom/skai-sdk/tsconfig.lib.json",
14
+ "packageJson": "packages/custom/skai-sdk/package.json",
15
+ "assets": [
16
+ "packages/custom/skai-sdk/*.md"
17
+ ],
18
+ "buildableProjectDepsInPackageJsonType": "dependencies",
19
+ "updateBuildableProjectDepsInPackageJson": true
20
+ }
21
+ },
22
+ "lint": {
23
+ "executor": "@nx/eslint:lint",
24
+ "outputs": ["{options.outputFile}"],
25
+ "options": {
26
+ "lintFilePatterns": ["packages/custom/skai-sdk/**/*.ts"]
27
+ }
28
+ }
29
+ },
30
+ "tags": []
31
+ }
@@ -0,0 +1,72 @@
1
+ import { GetOrgAPIKeyResponse, GetUserAPIKeyResponse, GetUserAPIKeysResponse } from '../types/admin-api-types'
2
+ import { Logger, SkaiBaseClient } from './base-client'
3
+
4
+ /**
5
+ * Configuration for SKAI Admin Client
6
+ */
7
+ export interface SkaiAdminClientConfig {
8
+ /** Base URL for SKAI API (e.g., 'https://api-dev.agents.skillfulai.io') */
9
+ baseUrl: string
10
+ /** Admin API key for privileged operations */
11
+ adminApiKey: string
12
+ /** Request timeout in milliseconds (optional, defaults to 5 minutes) */
13
+ timeout?: number
14
+ }
15
+
16
+ export class SkaiAdminClient extends SkaiBaseClient {
17
+ private readonly adminApiKey: string
18
+
19
+ constructor(
20
+ log: Logger,
21
+ config: SkaiAdminClientConfig,
22
+ ) {
23
+ super(log, config.baseUrl, config.timeout)
24
+ this.adminApiKey = config.adminApiKey
25
+
26
+ // Set admin API key in default headers (SKAI API uses raw API key, not Bearer token)
27
+ this.httpClient.defaults.headers.common['Authorization'] = this.adminApiKey
28
+ }
29
+
30
+ /**
31
+ * Get all system-managed API keys for a specific user
32
+ * @param userId The ID of the user whose API keys to retrieve
33
+ * @returns GetUserAPIKeysResponse containing the user's system-managed API keys
34
+ */
35
+ async getUserApiKeys(userId: string): Promise<GetUserAPIKeysResponse> {
36
+ return this.makeRequest<GetUserAPIKeysResponse>(
37
+ 'GET',
38
+ `/admin/system-api-keys/${userId}`,
39
+ )
40
+ }
41
+
42
+ /**
43
+ * Get a system-managed API key for a user
44
+ * @param userId The ID of the user whose API key to retrieve
45
+ * @returns GetUserAPIKeyResponse containing the API key
46
+ */
47
+ async getUserApiKey(userId: string): Promise<GetUserAPIKeyResponse> {
48
+ return this.makeRequest<GetUserAPIKeyResponse>(
49
+ 'GET',
50
+ `/admin/system-api-key/${userId}`,
51
+ )
52
+ }
53
+
54
+ /**
55
+ * Get or create a system-managed API key for an organization
56
+ * @param organizationId The UUID of the organization
57
+ * @returns GetOrgAPIKeyResponse containing the API key
58
+ */
59
+ async getOrgApiKey(organizationId: string): Promise<GetOrgAPIKeyResponse> {
60
+ return this.makeRequest<GetOrgAPIKeyResponse>(
61
+ 'GET',
62
+ `/admin/org-api-key/${organizationId}`,
63
+ )
64
+ }
65
+
66
+ /**
67
+ * Create a new SKAI Admin client instance
68
+ */
69
+ static create(log: Logger, config: SkaiAdminClientConfig): SkaiAdminClient {
70
+ return new SkaiAdminClient(log, config)
71
+ }
72
+ }