@southwind-ai/server-sdk 0.1.2 → 0.1.3
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/index.ts +11 -0
- package/package.json +4 -2
- package/src/ai-operation-registration.ts +31 -0
- package/src/module-host.ts +5 -0
- package/src/tool-host-port.ts +22 -0
package/index.ts
CHANGED
|
@@ -40,8 +40,19 @@ export type {
|
|
|
40
40
|
ModuleTaskHandlerRegistration,
|
|
41
41
|
ModuleTaskResult,
|
|
42
42
|
} from "./src/task-registration.js";
|
|
43
|
+
export type {
|
|
44
|
+
ModuleAgentToolHostPort,
|
|
45
|
+
ModuleAgentToolInvocation,
|
|
46
|
+
ModuleAgentToolResult,
|
|
47
|
+
} from "./src/tool-host-port.js";
|
|
43
48
|
export type {
|
|
44
49
|
ModuleToolContext,
|
|
45
50
|
ModuleToolHandlerRegistration,
|
|
46
51
|
ModuleToolResult,
|
|
47
52
|
} from "./src/tool-registration.js";
|
|
53
|
+
export type {
|
|
54
|
+
ModuleAiJsonValue,
|
|
55
|
+
ModuleAiOperationContext,
|
|
56
|
+
ModuleAiOperationHandlerRegistration,
|
|
57
|
+
ModuleAiOperationPlan,
|
|
58
|
+
} from "./src/ai-operation-registration.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@southwind-ai/server-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"index.ts",
|
|
11
11
|
"src/actor.ts",
|
|
12
|
+
"src/ai-operation-registration.ts",
|
|
12
13
|
"src/audit-port.ts",
|
|
13
14
|
"src/jobs-port.ts",
|
|
14
15
|
"src/module-host.ts",
|
|
@@ -19,7 +20,8 @@
|
|
|
19
20
|
"src/search-provider-port.ts",
|
|
20
21
|
"src/storage-port.ts",
|
|
21
22
|
"src/task-registration.ts",
|
|
22
|
-
"src/tool-registration.ts"
|
|
23
|
+
"src/tool-registration.ts",
|
|
24
|
+
"src/tool-host-port.ts"
|
|
23
25
|
],
|
|
24
26
|
"scripts": {
|
|
25
27
|
"test": "bun test",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ModuleActor } from "./actor.js";
|
|
2
|
+
|
|
3
|
+
export type ModuleAiJsonValue =
|
|
4
|
+
| string
|
|
5
|
+
| number
|
|
6
|
+
| boolean
|
|
7
|
+
| null
|
|
8
|
+
| ModuleAiJsonValue[]
|
|
9
|
+
| { [key: string]: ModuleAiJsonValue };
|
|
10
|
+
|
|
11
|
+
export interface ModuleAiOperationContext {
|
|
12
|
+
readonly actor: ModuleActor;
|
|
13
|
+
readonly requestId: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 业务模块只负责把类型化输入收敛为模型无关的指令和用户消息。
|
|
18
|
+
* Provider、Deployment、Secret、Execution Grant 与 Tool 授权均由宿主持有。
|
|
19
|
+
*/
|
|
20
|
+
export interface ModuleAiOperationPlan {
|
|
21
|
+
readonly instructions: string;
|
|
22
|
+
readonly userPrompt: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ModuleAiOperationHandlerRegistration {
|
|
26
|
+
readonly operationKey: string;
|
|
27
|
+
prepare(
|
|
28
|
+
input: ModuleAiJsonValue,
|
|
29
|
+
context: ModuleAiOperationContext,
|
|
30
|
+
): Promise<ModuleAiOperationPlan> | ModuleAiOperationPlan;
|
|
31
|
+
}
|
package/src/module-host.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DurableHandlerDefinition } from "@southwind-ai/jobs";
|
|
2
|
+
import type { ModuleAiOperationHandlerRegistration } from "./ai-operation-registration.js";
|
|
2
3
|
import type { ModuleRolePreset } from "./role-preset.js";
|
|
3
4
|
import type { ModuleRouteDefinition } from "./route-definition.js";
|
|
4
5
|
import type { ModuleSearchProvider } from "./search-provider-port.js";
|
|
@@ -35,6 +36,10 @@ export interface ModuleHost {
|
|
|
35
36
|
registerToolHandlers(
|
|
36
37
|
registrations: readonly ModuleToolHandlerRegistration[],
|
|
37
38
|
): void;
|
|
39
|
+
/** 注册 Manifest `aiOperations` 已声明的模型无关 Operation 执行计划。 */
|
|
40
|
+
registerAiOperationHandlers(
|
|
41
|
+
registrations: readonly ModuleAiOperationHandlerRegistration[],
|
|
42
|
+
): void;
|
|
38
43
|
/** 注册角色预设;permissionKeys 须属于本模块 Manifest 权限声明。 */
|
|
39
44
|
registerRolePresets(presets: readonly ModuleRolePreset[]): void;
|
|
40
45
|
/** 注册 Manifest `providers` 已声明的搜索 Provider。 */
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ModuleAiJsonValue } from "./ai-operation-registration.js";
|
|
2
|
+
|
|
3
|
+
export interface ModuleAgentToolInvocation {
|
|
4
|
+
readonly runId: string;
|
|
5
|
+
readonly toolCallId: string;
|
|
6
|
+
readonly toolKey: string;
|
|
7
|
+
readonly arguments: Readonly<Record<string, ModuleAiJsonValue>>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ModuleAgentToolResult {
|
|
11
|
+
readonly value: ModuleAiJsonValue;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 宿主创建并绑定 Operation、Actor 与 Scope 的受限 Tool Host Port。
|
|
16
|
+
* 调用方不能传 Permission、Feature、License 或数据范围作为授权事实。
|
|
17
|
+
*/
|
|
18
|
+
export interface ModuleAgentToolHostPort {
|
|
19
|
+
execute(
|
|
20
|
+
invocation: ModuleAgentToolInvocation,
|
|
21
|
+
): Promise<ModuleAgentToolResult>;
|
|
22
|
+
}
|