@openserv-labs/sdk 1.0.0
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/LICENSE +21 -0
- package/README.md +608 -0
- package/dist/agent.d.ts +369 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +643 -0
- package/dist/capability.d.ts +11 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +16 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +13 -0
- package/dist/types.d.ts +1308 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +165 -0
- package/package.json +89 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAA;AAKnF,MAAM,MAAM,oBAAoB,CAAC,MAAM,SAAS,CAAC,CAAC,UAAU,IAAI;IAC9D,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACrB,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;CACtC,CAAA;AAED,eAAO,MAAM,SAAS,8CAA4C,CAAA;AAElE,eAAO,MAAM,gBAAgB,gGAEC,CAAA;AAE9B,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEzD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAA;IACtC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAAA;IAC/B,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,GAAG,6BAA6B,CAAA;IAC5C,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,UAAU,CAAA;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,0BAA0B,EAAE,CAAA;CACvC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFilesParamsSchema = exports.actionSchema = exports.respondChatMessageActionSchema = exports.doTaskActionSchema = exports.taskStatusSchema = exports.agentKind = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const zod_to_openapi_1 = require("@asteasolutions/zod-to-openapi");
|
|
6
|
+
(0, zod_to_openapi_1.extendZodWithOpenApi)(zod_1.z);
|
|
7
|
+
exports.agentKind = zod_1.z.enum(['external', 'eliza', 'openserv']);
|
|
8
|
+
exports.taskStatusSchema = zod_1.z
|
|
9
|
+
.enum(['to-do', 'in-progress', 'human-assistance-required', 'error', 'done', 'cancelled'])
|
|
10
|
+
.openapi('taskStatusSchema');
|
|
11
|
+
exports.doTaskActionSchema = zod_1.z
|
|
12
|
+
.object({
|
|
13
|
+
type: zod_1.z.literal('do-task'),
|
|
14
|
+
me: zod_1.z
|
|
15
|
+
.intersection(zod_1.z.object({
|
|
16
|
+
id: zod_1.z.number(),
|
|
17
|
+
name: zod_1.z.string(),
|
|
18
|
+
kind: exports.agentKind
|
|
19
|
+
}), zod_1.z
|
|
20
|
+
.union([
|
|
21
|
+
zod_1.z.object({
|
|
22
|
+
isBuiltByAgentBuilder: zod_1.z.literal(false)
|
|
23
|
+
}),
|
|
24
|
+
zod_1.z.object({
|
|
25
|
+
isBuiltByAgentBuilder: zod_1.z.literal(true),
|
|
26
|
+
systemPrompt: zod_1.z.string()
|
|
27
|
+
})
|
|
28
|
+
])
|
|
29
|
+
.openapi({
|
|
30
|
+
description: 'This information is for internal agents only'
|
|
31
|
+
}))
|
|
32
|
+
.openapi({ description: 'Your agent instance' }),
|
|
33
|
+
task: zod_1.z.object({
|
|
34
|
+
id: zod_1.z.number().openapi({ description: 'The ID of the task' }),
|
|
35
|
+
description: zod_1.z.string().openapi({
|
|
36
|
+
description: "Short description of the task. Usually in the format of 'Do [something]'"
|
|
37
|
+
}),
|
|
38
|
+
body: zod_1.z.string().nullish().openapi({
|
|
39
|
+
description: 'Additional task information or data. Usually 2-3 sentences if available.'
|
|
40
|
+
}),
|
|
41
|
+
expectedOutput: zod_1.z.string().nullish().openapi({ description: 'Preferred output of the task' }),
|
|
42
|
+
input: zod_1.z.string().nullish().openapi({
|
|
43
|
+
description: "The input information for the task. Typically, it's an output of another task."
|
|
44
|
+
}),
|
|
45
|
+
dependencies: zod_1.z
|
|
46
|
+
.array(zod_1.z.object({
|
|
47
|
+
id: zod_1.z.number(),
|
|
48
|
+
description: zod_1.z.string(),
|
|
49
|
+
output: zod_1.z.string().nullish(),
|
|
50
|
+
status: exports.taskStatusSchema,
|
|
51
|
+
attachments: zod_1.z.array(zod_1.z.object({
|
|
52
|
+
id: zod_1.z.number(),
|
|
53
|
+
path: zod_1.z.string(),
|
|
54
|
+
fullUrl: zod_1.z.string(),
|
|
55
|
+
summary: zod_1.z.string().nullish()
|
|
56
|
+
}))
|
|
57
|
+
}))
|
|
58
|
+
.openapi({ description: 'List of dependant tasks' }),
|
|
59
|
+
humanAssistanceRequests: zod_1.z.array(zod_1.z
|
|
60
|
+
.object({
|
|
61
|
+
agentDump: zod_1.z.unknown().openapi({
|
|
62
|
+
description: "Agent's internal data. Anything the agent wanted to store in the context of this human assistant request."
|
|
63
|
+
}),
|
|
64
|
+
humanResponse: zod_1.z
|
|
65
|
+
.string()
|
|
66
|
+
.nullish()
|
|
67
|
+
.openapi({ description: "Human's response to the question" }),
|
|
68
|
+
id: zod_1.z.number(),
|
|
69
|
+
question: zod_1.z.string().openapi({ description: "Agent's question for the user" }),
|
|
70
|
+
status: zod_1.z.enum(['pending', 'responded']),
|
|
71
|
+
type: zod_1.z.enum(['text', 'project-manager-plan-review']).openapi({
|
|
72
|
+
description: "'project-manager-plan-review' is initiaded by a Project Manager agent to let the user confirm the project plan for this workspace."
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
.openapi({ description: 'List of Human Assistance Requests' }))
|
|
76
|
+
}),
|
|
77
|
+
workspace: zod_1.z.object({
|
|
78
|
+
id: zod_1.z.number(),
|
|
79
|
+
goal: zod_1.z.string(),
|
|
80
|
+
bucket_folder: zod_1.z.string(),
|
|
81
|
+
agents: zod_1.z.array(zod_1.z.object({
|
|
82
|
+
id: zod_1.z.number(),
|
|
83
|
+
name: zod_1.z.string(),
|
|
84
|
+
capabilities_description: zod_1.z.string()
|
|
85
|
+
}))
|
|
86
|
+
}),
|
|
87
|
+
integrations: zod_1.z.array(zod_1.z.object({
|
|
88
|
+
id: zod_1.z.number(),
|
|
89
|
+
connection_id: zod_1.z.string(),
|
|
90
|
+
provider_config_key: zod_1.z.string(),
|
|
91
|
+
provider: zod_1.z.string(),
|
|
92
|
+
created: zod_1.z.string(),
|
|
93
|
+
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullish(),
|
|
94
|
+
scopes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
95
|
+
openAPI: zod_1.z.object({
|
|
96
|
+
title: zod_1.z.string(),
|
|
97
|
+
description: zod_1.z.string()
|
|
98
|
+
})
|
|
99
|
+
})),
|
|
100
|
+
memories: zod_1.z.array(zod_1.z.object({
|
|
101
|
+
id: zod_1.z.number(),
|
|
102
|
+
memory: zod_1.z.string(),
|
|
103
|
+
createdAt: zod_1.z.coerce.date()
|
|
104
|
+
}))
|
|
105
|
+
})
|
|
106
|
+
.openapi('doTaskActionSchema');
|
|
107
|
+
exports.respondChatMessageActionSchema = zod_1.z
|
|
108
|
+
.object({
|
|
109
|
+
type: zod_1.z.literal('respond-chat-message'),
|
|
110
|
+
me: zod_1.z.intersection(zod_1.z.object({
|
|
111
|
+
id: zod_1.z.number(),
|
|
112
|
+
name: zod_1.z.string(),
|
|
113
|
+
kind: exports.agentKind
|
|
114
|
+
}), zod_1.z.discriminatedUnion('isBuiltByAgentBuilder', [
|
|
115
|
+
zod_1.z.object({
|
|
116
|
+
isBuiltByAgentBuilder: zod_1.z.literal(false)
|
|
117
|
+
}),
|
|
118
|
+
zod_1.z.object({
|
|
119
|
+
isBuiltByAgentBuilder: zod_1.z.literal(true),
|
|
120
|
+
systemPrompt: zod_1.z.string()
|
|
121
|
+
})
|
|
122
|
+
])),
|
|
123
|
+
messages: zod_1.z.array(zod_1.z.object({
|
|
124
|
+
author: zod_1.z.enum(['agent', 'user']),
|
|
125
|
+
createdAt: zod_1.z.coerce.date(),
|
|
126
|
+
id: zod_1.z.number(),
|
|
127
|
+
message: zod_1.z.string()
|
|
128
|
+
})),
|
|
129
|
+
workspace: zod_1.z.object({
|
|
130
|
+
id: zod_1.z.number(),
|
|
131
|
+
goal: zod_1.z.string(),
|
|
132
|
+
bucket_folder: zod_1.z.string(),
|
|
133
|
+
agents: zod_1.z.array(zod_1.z.object({
|
|
134
|
+
id: zod_1.z.number(),
|
|
135
|
+
name: zod_1.z.string(),
|
|
136
|
+
capabilities_description: zod_1.z.string()
|
|
137
|
+
}))
|
|
138
|
+
}),
|
|
139
|
+
integrations: zod_1.z.array(zod_1.z.object({
|
|
140
|
+
id: zod_1.z.number(),
|
|
141
|
+
connection_id: zod_1.z.string(),
|
|
142
|
+
provider_config_key: zod_1.z.string(),
|
|
143
|
+
provider: zod_1.z.string(),
|
|
144
|
+
created: zod_1.z.string().optional(),
|
|
145
|
+
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullish().optional(),
|
|
146
|
+
scopes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
147
|
+
openAPI: zod_1.z.object({
|
|
148
|
+
title: zod_1.z.string(),
|
|
149
|
+
description: zod_1.z.string()
|
|
150
|
+
})
|
|
151
|
+
})),
|
|
152
|
+
memories: zod_1.z.array(zod_1.z.object({
|
|
153
|
+
id: zod_1.z.number(),
|
|
154
|
+
memory: zod_1.z.string(),
|
|
155
|
+
createdAt: zod_1.z.coerce.date()
|
|
156
|
+
}))
|
|
157
|
+
})
|
|
158
|
+
.openapi('respondChatMessageActionSchema');
|
|
159
|
+
exports.actionSchema = zod_1.z.discriminatedUnion('type', [
|
|
160
|
+
exports.doTaskActionSchema,
|
|
161
|
+
exports.respondChatMessageActionSchema
|
|
162
|
+
]);
|
|
163
|
+
exports.getFilesParamsSchema = zod_1.z.object({
|
|
164
|
+
workspaceId: zod_1.z.number().int().positive()
|
|
165
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openserv-labs/sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "OpenServ Agent SDK - Create AI agents easily",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"dev": "tsc --watch",
|
|
10
|
+
"dev:example": "ts-node-dev --respawn --transpile-only examples/marketing-agent.ts",
|
|
11
|
+
"dev:custom-agent": "ts-node-dev --respawn --transpile-only examples/custom-agent.ts",
|
|
12
|
+
"check-types": "tsc --noEmit",
|
|
13
|
+
"prepublishOnly": "npm run build && npm run lint && npm run check-types && npm run test",
|
|
14
|
+
"prepare": "npm run build",
|
|
15
|
+
"lint": "eslint . --ext .ts",
|
|
16
|
+
"lint:fix": "eslint . --ext .ts --fix",
|
|
17
|
+
"format": "prettier --write \"**/*.{ts,json,md}\"",
|
|
18
|
+
"format:check": "prettier --check \"**/*.{ts,json,md}\"",
|
|
19
|
+
"test": "node --import tsx --test test/**/*.test.ts",
|
|
20
|
+
"test:watch": "node --import tsx --test --watch test/**/*.test.ts",
|
|
21
|
+
"test:coverage": "node --import tsx --test --enable-source-maps --experimental-test-coverage --test-timeout=5000 test/**/*.test.ts"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/openserv-labs/sdk.git"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/openserv-labs/sdk/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/openserv-labs/sdk#readme",
|
|
31
|
+
"keywords": [
|
|
32
|
+
"ai",
|
|
33
|
+
"agent",
|
|
34
|
+
"sdk",
|
|
35
|
+
"openserv",
|
|
36
|
+
"llm",
|
|
37
|
+
"function-calling",
|
|
38
|
+
"typescript"
|
|
39
|
+
],
|
|
40
|
+
"author": "OpenServ Labs",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@asteasolutions/zod-to-openapi": "^7.3.0",
|
|
44
|
+
"axios": "^1.6.8",
|
|
45
|
+
"axios-retry": "^4.1.0",
|
|
46
|
+
"compression": "^1.7.4",
|
|
47
|
+
"express": "^4.19.2",
|
|
48
|
+
"express-async-router": "^0.1.15",
|
|
49
|
+
"helmet": "^8.0.0",
|
|
50
|
+
"hpp": "^0.2.3",
|
|
51
|
+
"http-errors": "^2.0.0",
|
|
52
|
+
"pino": "^9.6.0",
|
|
53
|
+
"zod": "^3.22.4",
|
|
54
|
+
"zod-to-json-schema": "^3.22.4"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@tsconfig/strictest": "^2.0.3",
|
|
58
|
+
"@types/compression": "^1.7.5",
|
|
59
|
+
"@types/express": "^4.17.21",
|
|
60
|
+
"@types/helmet": "^0.0.48",
|
|
61
|
+
"@types/hpp": "^0.2.6",
|
|
62
|
+
"@types/node": "^22.10.2",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
|
64
|
+
"@typescript-eslint/parser": "^7.3.1",
|
|
65
|
+
"dotenv": "^16.4.5",
|
|
66
|
+
"eslint": "^8.56.0",
|
|
67
|
+
"eslint-config-prettier": "^9.1.0",
|
|
68
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
69
|
+
"prettier": "^3.2.5",
|
|
70
|
+
"ts-node-dev": "^2.0.0",
|
|
71
|
+
"tsx": "^4.19.2",
|
|
72
|
+
"typescript": "^5.4.2"
|
|
73
|
+
},
|
|
74
|
+
"files": [
|
|
75
|
+
"dist",
|
|
76
|
+
"README.md",
|
|
77
|
+
"LICENSE"
|
|
78
|
+
],
|
|
79
|
+
"publishConfig": {
|
|
80
|
+
"access": "public",
|
|
81
|
+
"registry": "https://registry.npmjs.org/"
|
|
82
|
+
},
|
|
83
|
+
"engines": {
|
|
84
|
+
"node": ">=18.0.0"
|
|
85
|
+
},
|
|
86
|
+
"peerDependencies": {
|
|
87
|
+
"openai": "^4.0.0"
|
|
88
|
+
}
|
|
89
|
+
}
|