@inhuman.tools/plugin-sdk 0.0.0-stage → 0.1.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.md +7 -0
- package/README.md +104 -2
- package/dist/index.d.ts +153 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +187 -0
- package/dist/index.js.map +1 -0
- package/dist/normalize.d.ts +112 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/normalize.js +220 -0
- package/dist/normalize.js.map +1 -0
- package/dist/projection.d.ts +37 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +7 -0
- package/dist/projection.js.map +1 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/plugin.d.ts +1392 -0
- package/dist/schemas/plugin.d.ts.map +1 -0
- package/dist/schemas/plugin.js +242 -0
- package/dist/schemas/plugin.js.map +1 -0
- package/dist/shape.d.ts +1007 -0
- package/dist/shape.d.ts.map +1 -0
- package/dist/shape.js +204 -0
- package/dist/shape.js.map +1 -0
- package/package.json +59 -3
- package/src/index.ts +320 -0
- package/src/normalize.ts +353 -0
- package/src/projection.ts +38 -0
- package/src/schemas/index.ts +1 -0
- package/src/schemas/plugin.ts +295 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { botCallToolDef, botDef, exclusiveSlotsDef, functionToolDef, inhumanBrand, inhumanShape, mcpServerDef, pluginProjectionDef, REASONING_EFFORTS, } from "./schemas/plugin.js";
|
|
3
|
+
function parseNamed(schema, value, context) {
|
|
4
|
+
const result = schema.safeParse(value);
|
|
5
|
+
if (result.success)
|
|
6
|
+
return result.data;
|
|
7
|
+
const issue = result.error.issues[0];
|
|
8
|
+
throw new Error(`${context}: ${issue?.message ?? "invalid"}`);
|
|
9
|
+
}
|
|
10
|
+
function declaredRepresentation(value, fallback) {
|
|
11
|
+
return value === "tool" || value === "symbol" || value === "both" ? value : fallback;
|
|
12
|
+
}
|
|
13
|
+
export function isReasoningEffort(value) {
|
|
14
|
+
return z.enum(REASONING_EFFORTS).safeParse(value).success;
|
|
15
|
+
}
|
|
16
|
+
function toolRecord(value) {
|
|
17
|
+
if (value == null || typeof value !== "object")
|
|
18
|
+
return null;
|
|
19
|
+
if (value[inhumanBrand.tool] === true) {
|
|
20
|
+
const tool = value;
|
|
21
|
+
return tool.toToolDefinition();
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
function actionRecord(value) {
|
|
26
|
+
if (value == null || typeof value !== "object")
|
|
27
|
+
return null;
|
|
28
|
+
if (value[inhumanBrand.action] === true) {
|
|
29
|
+
const action = value;
|
|
30
|
+
return {
|
|
31
|
+
name: action.name,
|
|
32
|
+
description: action.description,
|
|
33
|
+
seat: action.seat,
|
|
34
|
+
input: action.input,
|
|
35
|
+
run: action.run,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
function pluginBag(value) {
|
|
41
|
+
if (value == null || typeof value !== "object")
|
|
42
|
+
return null;
|
|
43
|
+
const record = value;
|
|
44
|
+
if (value[inhumanBrand.plugin] === true) {
|
|
45
|
+
const plugin = value;
|
|
46
|
+
return {
|
|
47
|
+
apiVersion: plugin.apiVersion,
|
|
48
|
+
tools: plugin.tools,
|
|
49
|
+
actions: plugin.actions,
|
|
50
|
+
envCapabilities: plugin.envCapabilities,
|
|
51
|
+
bots: plugin.bots,
|
|
52
|
+
mcpServers: plugin.mcpServers,
|
|
53
|
+
exclusiveSlots: plugin.exclusiveSlots,
|
|
54
|
+
projection: plugin.projection,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if ("default" in record && record.default != null)
|
|
58
|
+
return pluginBag(record.default);
|
|
59
|
+
return record;
|
|
60
|
+
}
|
|
61
|
+
export function validateSupportedVersion(bag, pluginName = "") {
|
|
62
|
+
const version = bag.apiVersion;
|
|
63
|
+
if (version === undefined)
|
|
64
|
+
return;
|
|
65
|
+
if (version === 1)
|
|
66
|
+
return;
|
|
67
|
+
throw new Error(`${pluginName}: unsupported plugin apiVersion ${String(version)}`);
|
|
68
|
+
}
|
|
69
|
+
function normalizeTool(raw, index, pluginName) {
|
|
70
|
+
const row = toolRecord(raw);
|
|
71
|
+
if (row == null)
|
|
72
|
+
throw new Error(`${pluginName}: tools[${index}] is not an object`);
|
|
73
|
+
if (row.type === "bot-message") {
|
|
74
|
+
throw new Error(`${pluginName}: tools[${index}] type bot-message is reserved in v1`);
|
|
75
|
+
}
|
|
76
|
+
const context = `${pluginName}: tools[${index}]`;
|
|
77
|
+
const parsed = row.type === "bot-call"
|
|
78
|
+
? parseNamed(botCallToolDef, row, context)
|
|
79
|
+
: parseNamed(functionToolDef, row.type === "function" ? row : { ...row, type: undefined }, context);
|
|
80
|
+
const base = {
|
|
81
|
+
name: parsed.name,
|
|
82
|
+
description: parsed.description,
|
|
83
|
+
class: parsed.class,
|
|
84
|
+
representation: declaredRepresentation(parsed.representation, parsed.type === "bot-call" ? "tool" : "symbol"),
|
|
85
|
+
input: parsed.input,
|
|
86
|
+
output: parsed.output,
|
|
87
|
+
triggersReactLoop: parsed.triggersReactLoop !== false,
|
|
88
|
+
isSideChannel: parsed.isSideChannel === true,
|
|
89
|
+
tapeHidden: parsed.tapeHidden === true,
|
|
90
|
+
question: parsed.question,
|
|
91
|
+
effect: parsed.effect,
|
|
92
|
+
caption: parsed.caption,
|
|
93
|
+
};
|
|
94
|
+
if (parsed.type === "bot-call") {
|
|
95
|
+
return {
|
|
96
|
+
type: "bot-call",
|
|
97
|
+
...base,
|
|
98
|
+
target: parsed.target,
|
|
99
|
+
prepare: parsed.prepare,
|
|
100
|
+
background: parsed.background === true,
|
|
101
|
+
lifetime: parsed.lifetime,
|
|
102
|
+
show: parsed.show,
|
|
103
|
+
deadlineMs: parsed.deadlineMs,
|
|
104
|
+
maxResultTokens: parsed.maxResultTokens,
|
|
105
|
+
supportsNotify: parsed.supportsNotify === true,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const exam = parsed.exam;
|
|
109
|
+
if (exam != null && parsed.run == null) {
|
|
110
|
+
return {
|
|
111
|
+
type: "function",
|
|
112
|
+
...base,
|
|
113
|
+
exam,
|
|
114
|
+
run: () => {
|
|
115
|
+
throw new TypeError(`${pluginName}: tools[${index}] exam tools do not execute through run`);
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
type: "function",
|
|
121
|
+
...base,
|
|
122
|
+
exam,
|
|
123
|
+
run: parsed.run,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function normalizeProjection(raw, pluginName) {
|
|
127
|
+
if (raw == null)
|
|
128
|
+
return undefined;
|
|
129
|
+
return parseNamed(pluginProjectionDef, raw, `${pluginName}: projection`);
|
|
130
|
+
}
|
|
131
|
+
function parseExclusiveSlots(pluginName, bag) {
|
|
132
|
+
const raw = Array.isArray(bag.exclusiveSlots) ? bag.exclusiveSlots : [];
|
|
133
|
+
return parseNamed(exclusiveSlotsDef, raw, `${pluginName}: exclusiveSlots`);
|
|
134
|
+
}
|
|
135
|
+
export function normalizeDefinitions(exported, pluginName = "") {
|
|
136
|
+
const bag = pluginBag(exported);
|
|
137
|
+
if (bag == null)
|
|
138
|
+
throw new Error(`${pluginName}: plugin export is not an object`);
|
|
139
|
+
validateSupportedVersion(bag, pluginName);
|
|
140
|
+
const toolsRaw = Array.isArray(bag.tools) ? bag.tools : [];
|
|
141
|
+
const actionsRaw = Array.isArray(bag.actions) ? bag.actions : [];
|
|
142
|
+
const envRaw = Array.isArray(bag.envCapabilities) ? bag.envCapabilities : [];
|
|
143
|
+
const botsRaw = Array.isArray(bag.bots) ? bag.bots : [];
|
|
144
|
+
const serversRaw = Array.isArray(bag.mcpServers) ? bag.mcpServers : [];
|
|
145
|
+
const tools = toolsRaw.map((tool, index) => normalizeTool(tool, index, pluginName));
|
|
146
|
+
const toolNames = new Set();
|
|
147
|
+
for (const tool of tools) {
|
|
148
|
+
if (toolNames.has(tool.name))
|
|
149
|
+
throw new Error(`${pluginName}: tool "${tool.name}" collides`);
|
|
150
|
+
toolNames.add(tool.name);
|
|
151
|
+
}
|
|
152
|
+
const actions = actionsRaw.map((action, index) => {
|
|
153
|
+
const row = actionRecord(action);
|
|
154
|
+
if (row == null)
|
|
155
|
+
throw new Error(`${pluginName}: actions[${index}] is not an object`);
|
|
156
|
+
return parseNamed(inhumanShape.normalizedActionDef, row, `${pluginName}: actions[${index}]`);
|
|
157
|
+
});
|
|
158
|
+
const actionNames = new Set();
|
|
159
|
+
for (const action of actions) {
|
|
160
|
+
if (actionNames.has(action.name))
|
|
161
|
+
throw new Error(`${pluginName}: action "${action.name}" collides`);
|
|
162
|
+
actionNames.add(action.name);
|
|
163
|
+
}
|
|
164
|
+
const envCapabilities = envRaw.map((cap, index) => {
|
|
165
|
+
try {
|
|
166
|
+
return inhumanShape.envCapability.parse(cap);
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
throw new Error(`${pluginName}: envCapabilities[${index}] is invalid`);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const bots = botsRaw.map((bot, index) => parseNamed(botDef, bot, `${pluginName}: bots[${index}]`));
|
|
173
|
+
const botNames = new Set();
|
|
174
|
+
for (const bot of bots) {
|
|
175
|
+
if (botNames.has(bot.name))
|
|
176
|
+
throw new Error(`${pluginName}: bot "${bot.name}" collides`);
|
|
177
|
+
botNames.add(bot.name);
|
|
178
|
+
}
|
|
179
|
+
const mcpServers = serversRaw.map((server, index) => parseNamed(mcpServerDef, server, `${pluginName}: mcpServers[${index}]`));
|
|
180
|
+
const serverNames = new Set();
|
|
181
|
+
for (const server of mcpServers) {
|
|
182
|
+
if (serverNames.has(server.name))
|
|
183
|
+
throw new Error(`${pluginName}: mcpServer "${server.name}" collides`);
|
|
184
|
+
serverNames.add(server.name);
|
|
185
|
+
}
|
|
186
|
+
const projection = normalizeProjection(bag.projection, pluginName);
|
|
187
|
+
return {
|
|
188
|
+
apiVersion: 1,
|
|
189
|
+
tools,
|
|
190
|
+
bots,
|
|
191
|
+
mcpServers,
|
|
192
|
+
actions,
|
|
193
|
+
envCapabilities,
|
|
194
|
+
exclusiveSlots: parseExclusiveSlots(pluginName, bag),
|
|
195
|
+
projection,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
export function resolveReferences(definition, pluginName = "") {
|
|
199
|
+
const botNames = new Set(definition.bots.map((bot) => bot.name));
|
|
200
|
+
const serverNames = new Set(definition.mcpServers.map((server) => server.name));
|
|
201
|
+
for (const tool of definition.tools) {
|
|
202
|
+
if (tool.type === "bot-call" && !botNames.has(tool.target)) {
|
|
203
|
+
throw new Error(`${pluginName}: tool "${tool.name}" target "${tool.target}" is unresolved`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
for (const bot of definition.bots) {
|
|
207
|
+
for (const binding of bot.mcp ?? []) {
|
|
208
|
+
if (!serverNames.has(binding.server)) {
|
|
209
|
+
throw new Error(`${pluginName}: bot "${bot.name}" binding server "${binding.server}" is unresolved`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
for (const target of bot.invokes ?? []) {
|
|
213
|
+
if (!botNames.has(target)) {
|
|
214
|
+
throw new Error(`${pluginName}: bot "${bot.name}" invokes unresolved "${target}"`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return definition;
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAW,MAAM,KAAK,CAAC;AAGjC,OAAO,EACL,cAAc,EACd,MAAM,EACN,iBAAiB,EACjB,eA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AAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACrC,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,UAAU,GAAG,CAAC,IAAI,qBAAqB,OAAO,CAAC,MAAM,iBAAiB,CAAC,CAAC;YACvG,CAAC;QACH,CAAC;QACD,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;YACvC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,UAAU,GAAG,CAAC,IAAI,yBAAyB,MAAM,GAAG,CAAC,CAAC;YACrF,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trajectory projection ABI. The host runs each pack `reduce` over plugin
|
|
3
|
+
* metadata on the session graph. Hooks read the head projection and stamp the wire.
|
|
4
|
+
* This package does not import the session document.
|
|
5
|
+
*/
|
|
6
|
+
export type PluginProjection<S = unknown, A = unknown> = {
|
|
7
|
+
readonly initial: () => S;
|
|
8
|
+
readonly reduce: (state: S, action: A) => S;
|
|
9
|
+
/** Model-proposed metadata that may only be written sealed by the host. */
|
|
10
|
+
readonly hostOnly?: (action: A) => boolean;
|
|
11
|
+
};
|
|
12
|
+
/** Prefix projection at this invocation. `propose` is the action, not the next state. */
|
|
13
|
+
export type PluginStorageHandles<S = unknown, A = unknown> = {
|
|
14
|
+
readonly session: S;
|
|
15
|
+
readonly invocation: S;
|
|
16
|
+
readonly project?: S;
|
|
17
|
+
readonly global?: S;
|
|
18
|
+
propose(action: A): void;
|
|
19
|
+
};
|
|
20
|
+
/** Host-computed exam result. Pack `settle` turns this into metadata. */
|
|
21
|
+
export type ExamVerdict = {
|
|
22
|
+
readonly ok: boolean;
|
|
23
|
+
readonly comments: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Frozen exam admit. Host copies `program` into a ProgrammaticJob and
|
|
27
|
+
* seals `admit` onto that node. Model `expr` is ignored. `settle` is
|
|
28
|
+
* the sealed close — host does not know the pack's verdict action.
|
|
29
|
+
*/
|
|
30
|
+
export type ExamAdmit<TIn = unknown, S = unknown, A = unknown> = {
|
|
31
|
+
readonly program: (state: S, input: TIn) => string | {
|
|
32
|
+
readonly error: string;
|
|
33
|
+
};
|
|
34
|
+
readonly admit: (state: S, input: TIn) => A;
|
|
35
|
+
readonly settle?: (state: S, input: TIn, result: ExamVerdict) => A;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI;IACvD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;IAC5C,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC;CAC5C,CAAC;AAEF,yFAAyF;AACzF,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI;IAC3D,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACpB,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,yEAAyE;AACzE,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,GAAG,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI;IAC/D,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,MAAM,GAAG;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAChF,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC;IAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,KAAK,CAAC,CAAC;CACpE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trajectory projection ABI. The host runs each pack `reduce` over plugin
|
|
3
|
+
* metadata on the session graph. Hooks read the head projection and stamp the wire.
|
|
4
|
+
* This package does not import the session document.
|
|
5
|
+
*/
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|