@shareai-lab/kode-sdk 1.0.0-beta.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/README.md +312 -0
- package/dist/core/agent.d.ts +85 -0
- package/dist/core/agent.js +687 -0
- package/dist/core/events.d.ts +19 -0
- package/dist/core/events.js +121 -0
- package/dist/core/hooks.d.ts +23 -0
- package/dist/core/hooks.js +71 -0
- package/dist/core/pool.d.ts +33 -0
- package/dist/core/pool.js +91 -0
- package/dist/core/room.d.ts +15 -0
- package/dist/core/room.js +57 -0
- package/dist/core/scheduler.d.ts +26 -0
- package/dist/core/scheduler.js +184 -0
- package/dist/core/types.d.ts +192 -0
- package/dist/core/types.js +13 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +57 -0
- package/dist/infra/provider.d.ts +58 -0
- package/dist/infra/provider.js +118 -0
- package/dist/infra/sandbox.d.ts +39 -0
- package/dist/infra/sandbox.js +77 -0
- package/dist/infra/store.d.ts +32 -0
- package/dist/infra/store.js +132 -0
- package/dist/tools/bash.d.ts +63 -0
- package/dist/tools/bash.js +99 -0
- package/dist/tools/builtin.d.ts +15 -0
- package/dist/tools/builtin.js +96 -0
- package/dist/tools/fs.d.ts +96 -0
- package/dist/tools/fs.js +96 -0
- package/dist/tools/task.d.ts +38 -0
- package/dist/tools/task.js +45 -0
- package/dist/utils/session-id.d.ts +21 -0
- package/dist/utils/session-id.js +64 -0
- package/package.json +47 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface SessionIdComponents {
|
|
2
|
+
orgId?: string;
|
|
3
|
+
teamId?: string;
|
|
4
|
+
userId?: string;
|
|
5
|
+
agentTemplate: string;
|
|
6
|
+
rootId: string;
|
|
7
|
+
forkIds: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare class SessionId {
|
|
10
|
+
static parse(id: string): SessionIdComponents;
|
|
11
|
+
static generate(opts: {
|
|
12
|
+
orgId?: string;
|
|
13
|
+
teamId?: string;
|
|
14
|
+
userId?: string;
|
|
15
|
+
agentTemplate: string;
|
|
16
|
+
parentSessionId?: string;
|
|
17
|
+
}): string;
|
|
18
|
+
static snapshot(sessionId: string, sfpIndex: number): string;
|
|
19
|
+
static label(sessionId: string, label: string): string;
|
|
20
|
+
private static randomId;
|
|
21
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionId = void 0;
|
|
4
|
+
class SessionId {
|
|
5
|
+
static parse(id) {
|
|
6
|
+
const parts = id.split('/');
|
|
7
|
+
const components = {
|
|
8
|
+
agentTemplate: '',
|
|
9
|
+
rootId: '',
|
|
10
|
+
forkIds: [],
|
|
11
|
+
};
|
|
12
|
+
for (const part of parts) {
|
|
13
|
+
if (part.startsWith('org:')) {
|
|
14
|
+
components.orgId = part.slice(4);
|
|
15
|
+
}
|
|
16
|
+
else if (part.startsWith('team:')) {
|
|
17
|
+
components.teamId = part.slice(5);
|
|
18
|
+
}
|
|
19
|
+
else if (part.startsWith('user:')) {
|
|
20
|
+
components.userId = part.slice(5);
|
|
21
|
+
}
|
|
22
|
+
else if (part.startsWith('agent:')) {
|
|
23
|
+
components.agentTemplate = part.slice(6);
|
|
24
|
+
}
|
|
25
|
+
else if (part.startsWith('session:')) {
|
|
26
|
+
components.rootId = part.slice(8);
|
|
27
|
+
}
|
|
28
|
+
else if (part.startsWith('fork:')) {
|
|
29
|
+
components.forkIds.push(part.slice(5));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return components;
|
|
33
|
+
}
|
|
34
|
+
static generate(opts) {
|
|
35
|
+
const parts = [];
|
|
36
|
+
if (opts.orgId)
|
|
37
|
+
parts.push(`org:${opts.orgId}`);
|
|
38
|
+
if (opts.teamId)
|
|
39
|
+
parts.push(`team:${opts.teamId}`);
|
|
40
|
+
if (opts.userId)
|
|
41
|
+
parts.push(`user:${opts.userId}`);
|
|
42
|
+
parts.push(`agent:${opts.agentTemplate}`);
|
|
43
|
+
if (opts.parentSessionId) {
|
|
44
|
+
const parent = SessionId.parse(opts.parentSessionId);
|
|
45
|
+
parts.push(`session:${parent.rootId}`);
|
|
46
|
+
parts.push(...parent.forkIds.map((id) => `fork:${id}`));
|
|
47
|
+
parts.push(`fork:${this.randomId()}`);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
parts.push(`session:${this.randomId()}`);
|
|
51
|
+
}
|
|
52
|
+
return parts.join('/');
|
|
53
|
+
}
|
|
54
|
+
static snapshot(sessionId, sfpIndex) {
|
|
55
|
+
return `${sessionId}@sfp:${sfpIndex}`;
|
|
56
|
+
}
|
|
57
|
+
static label(sessionId, label) {
|
|
58
|
+
return `${sessionId}@label:${label}`;
|
|
59
|
+
}
|
|
60
|
+
static randomId() {
|
|
61
|
+
return Math.random().toString(36).slice(2, 8);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.SessionId = SessionId;
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shareai-lab/kode-sdk",
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
|
+
"description": "Event-driven Agent Model Client SDK for building long-running, collaborative AI agents",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"dev": "tsc --watch",
|
|
10
|
+
"clean": "rm -rf dist",
|
|
11
|
+
"prepare": "npm run build",
|
|
12
|
+
"test:cli": "ts-node test-cli.ts",
|
|
13
|
+
"example:u1": "ts-node examples/u1-nextjs-backend.ts",
|
|
14
|
+
"example:u2": "ts-node examples/u2-permission-approval.ts",
|
|
15
|
+
"example:u3": "ts-node examples/u3-hook-guard.ts",
|
|
16
|
+
"example:u4": "ts-node examples/u4-scheduler.ts",
|
|
17
|
+
"example:u5": "ts-node examples/u5-sub-agent.ts",
|
|
18
|
+
"example:u6": "ts-node examples/u6-room-chat.ts",
|
|
19
|
+
"example:u7": "ts-node examples/u7-chatdev-team.ts"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"agent",
|
|
23
|
+
"ai",
|
|
24
|
+
"llm",
|
|
25
|
+
"anthropic",
|
|
26
|
+
"claude",
|
|
27
|
+
"event-driven",
|
|
28
|
+
"multi-agent",
|
|
29
|
+
"collaboration",
|
|
30
|
+
"automation"
|
|
31
|
+
],
|
|
32
|
+
"author": "",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^20.0.0",
|
|
36
|
+
"ts-node": "^10.9.0",
|
|
37
|
+
"typescript": "^5.3.0"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18.0.0"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"README.md",
|
|
45
|
+
"LICENSE"
|
|
46
|
+
]
|
|
47
|
+
}
|