@frockbot/plugin-identity 0.0.0 → 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/frockbot.json +15 -0
- package/package.json +30 -6
- package/src/agent.test.ts +69 -0
- package/src/agent.ts +37 -0
- package/src/index.ts +2 -0
- package/src/manifest.ts +3 -0
- package/tsconfig.json +15 -0
- package/README.md +0 -3
package/frockbot.json
ADDED
package/package.json
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frockbot/plugin-identity",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/index.ts",
|
|
8
|
+
"./agent": "./src/agent.ts",
|
|
9
|
+
"./manifest": "./src/manifest.ts",
|
|
10
|
+
"./frockbot.json": "./frockbot.json",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"frockbot": {
|
|
14
|
+
"manifest": "./frockbot.json"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "bun test src",
|
|
18
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@frockbot/kernel-contracts": "0.1.0",
|
|
22
|
+
"@frockbot/plugin-prompt": "0.1.0",
|
|
23
|
+
"cordis": "4.0.0-rc.8"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@frockbot/plugin-testkit": "0.1.0",
|
|
27
|
+
"@types/bun": "1.4.0",
|
|
28
|
+
"typescript": "^7.0.2"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
6
33
|
"repository": {
|
|
7
34
|
"type": "git",
|
|
8
35
|
"url": "git+https://github.com/timoconnellaus/frockbot.git",
|
|
9
36
|
"directory": "packages/plugin-identity"
|
|
10
|
-
},
|
|
11
|
-
"publishConfig": {
|
|
12
|
-
"access": "public"
|
|
13
37
|
}
|
|
14
38
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { SystemPromptRegistry } from "@frockbot/plugin-prompt";
|
|
3
|
+
import {
|
|
4
|
+
createPluginHarness,
|
|
5
|
+
verifyPluginPackage,
|
|
6
|
+
} from "@frockbot/plugin-testkit";
|
|
7
|
+
import manifest from "../frockbot.json" with { type: "json" };
|
|
8
|
+
import packageJson from "../package.json" with { type: "json" };
|
|
9
|
+
import { createIdentityPlugin, DEFAULT_IDENTITY_TEXT } from "./agent.js";
|
|
10
|
+
|
|
11
|
+
describe("identity plugin", () => {
|
|
12
|
+
test("registers and disposes a prompt section", async () => {
|
|
13
|
+
const harness = await createPluginHarness([SystemPromptRegistry]);
|
|
14
|
+
const fiber = await harness.mount(createIdentityPlugin());
|
|
15
|
+
|
|
16
|
+
expect(
|
|
17
|
+
await harness.root.systemPrompt.assemble({
|
|
18
|
+
sessionId: "session",
|
|
19
|
+
provider: "fixture",
|
|
20
|
+
model: "fixture",
|
|
21
|
+
turnType: "chat",
|
|
22
|
+
}),
|
|
23
|
+
).toMatchObject({
|
|
24
|
+
text: DEFAULT_IDENTITY_TEXT,
|
|
25
|
+
sections: [{ id: "identity", text: DEFAULT_IDENTITY_TEXT }],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
await fiber.dispose();
|
|
29
|
+
expect(
|
|
30
|
+
await harness.root.systemPrompt.assemble({
|
|
31
|
+
sessionId: "session",
|
|
32
|
+
provider: "fixture",
|
|
33
|
+
model: "fixture",
|
|
34
|
+
turnType: "chat",
|
|
35
|
+
}),
|
|
36
|
+
).toEqual({ text: "", sections: [] });
|
|
37
|
+
await harness.dispose();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("supports package-owned identity configuration", async () => {
|
|
41
|
+
const harness = await createPluginHarness([SystemPromptRegistry]);
|
|
42
|
+
await harness.mount(
|
|
43
|
+
createIdentityPlugin({
|
|
44
|
+
sectionId: "persona",
|
|
45
|
+
text: "You are a test bot.",
|
|
46
|
+
order: 50,
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
expect(
|
|
51
|
+
await harness.root.systemPrompt.assemble({
|
|
52
|
+
sessionId: "session",
|
|
53
|
+
provider: "fixture",
|
|
54
|
+
model: "fixture",
|
|
55
|
+
turnType: "chat",
|
|
56
|
+
}),
|
|
57
|
+
).toMatchObject({
|
|
58
|
+
sections: [{ id: "persona", text: "You are a test bot." }],
|
|
59
|
+
});
|
|
60
|
+
await harness.dispose();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("satisfies plugin package conventions", () => {
|
|
64
|
+
expect(verifyPluginPackage({ packageJson, manifest })).toMatchObject({
|
|
65
|
+
name: "@frockbot/plugin-identity",
|
|
66
|
+
contributionKinds: ["runtime"],
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
package/src/agent.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type PromptSection } from "@frockbot/kernel-contracts";
|
|
2
|
+
import type { Plugin } from "cordis";
|
|
3
|
+
|
|
4
|
+
// This contribution is runtime-neutral and can mount in Node or Workers.
|
|
5
|
+
export const DEFAULT_IDENTITY_SECTION = "identity";
|
|
6
|
+
export const DEFAULT_IDENTITY_TEXT =
|
|
7
|
+
"You are FrockBot running on the custom Cordis agent loop.";
|
|
8
|
+
|
|
9
|
+
export interface IdentityPluginConfig {
|
|
10
|
+
sectionId?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
order?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function createIdentityPlugin(
|
|
16
|
+
config: IdentityPluginConfig = {},
|
|
17
|
+
): Plugin.Function {
|
|
18
|
+
const sectionId = config.sectionId?.trim() || DEFAULT_IDENTITY_SECTION;
|
|
19
|
+
const text = config.text?.trim() || DEFAULT_IDENTITY_TEXT;
|
|
20
|
+
const order = config.order ?? 0;
|
|
21
|
+
if (!Number.isFinite(order)) {
|
|
22
|
+
throw new Error("identity section order must be finite");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const section: PromptSection = {
|
|
26
|
+
id: sectionId,
|
|
27
|
+
order,
|
|
28
|
+
render: () => text,
|
|
29
|
+
};
|
|
30
|
+
const plugin: Plugin.Function = (ctx) => ctx.systemPrompt.register(section);
|
|
31
|
+
plugin.inject = ["systemPrompt"];
|
|
32
|
+
return plugin;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const identityPlugin = createIdentityPlugin();
|
|
36
|
+
|
|
37
|
+
export default identityPlugin;
|
package/src/index.ts
ADDED
package/src/manifest.ts
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2023",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"allowImportingTsExtensions": true,
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"noEmit": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"lib": ["ES2023", "DOM"],
|
|
12
|
+
"types": ["bun"]
|
|
13
|
+
},
|
|
14
|
+
"include": ["src/**/*.ts"]
|
|
15
|
+
}
|
package/README.md
DELETED