@frockbot/plugin-prompt 0.0.0 → 0.1.1

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 ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "id": "prompt",
4
+ "displayName": "Prompt",
5
+ "version": "0.0.1",
6
+ "compatibility": {
7
+ "frockbot": ">=0.0.1"
8
+ },
9
+ "contributions": {
10
+ "runtime": {
11
+ "entry": "./agent"
12
+ }
13
+ },
14
+ "permissions": []
15
+ }
package/package.json CHANGED
@@ -1,14 +1,35 @@
1
1
  {
2
2
  "name": "@frockbot/plugin-prompt",
3
- "version": "0.0.0",
4
- "description": "Placeholder reserving this name for trusted publishing. Superseded by the first release.",
5
- "license": "UNLICENSED",
3
+ "version": "0.1.1",
4
+ "private": false,
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./src/index.ts",
8
+ "./agent": "./src/system-prompt.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
+ "typecheck": "tsc --noEmit -p tsconfig.json"
18
+ },
19
+ "dependencies": {
20
+ "@frockbot/kernel-contracts": "0.1.1",
21
+ "cordis": "4.0.0-rc.8"
22
+ },
23
+ "devDependencies": {
24
+ "@types/bun": "1.4.0",
25
+ "typescript": "^7.0.2"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
6
30
  "repository": {
7
31
  "type": "git",
8
32
  "url": "git+https://github.com/timoconnellaus/frockbot.git",
9
33
  "directory": "packages/plugin-prompt"
10
- },
11
- "publishConfig": {
12
- "access": "public"
13
34
  }
14
35
  }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./system-prompt.js";
2
+ export { default as promptManifest } from "./manifest.js";
@@ -0,0 +1,3 @@
1
+ import manifest from "../frockbot.json" with { type: "json" };
2
+
3
+ export default manifest;
@@ -0,0 +1,50 @@
1
+ import { type Context, Service } from "cordis";
2
+ import type {
3
+ PromptAssembly,
4
+ PromptAssemblyContext,
5
+ PromptAssemblyService,
6
+ PromptSection,
7
+ } from "@frockbot/kernel-contracts";
8
+
9
+ export class SystemPromptRegistry
10
+ extends Service
11
+ implements PromptAssemblyService
12
+ {
13
+ private sections = new Map<string, PromptSection>();
14
+
15
+ constructor(ctx: Context) {
16
+ super(ctx, "systemPrompt");
17
+ }
18
+
19
+ register(section: PromptSection): () => void {
20
+ if (this.sections.has(section.id)) {
21
+ throw new Error(`prompt section "${section.id}" is already registered`);
22
+ }
23
+ this.sections.set(section.id, section);
24
+ return () => {
25
+ if (this.sections.get(section.id) === section)
26
+ this.sections.delete(section.id);
27
+ };
28
+ }
29
+
30
+ assemble(context: PromptAssemblyContext): Promise<PromptAssembly> {
31
+ return this.ctx.waterfall("system-prompt/assemble", context, async () => {
32
+ const sections = [...this.sections.values()].sort(
33
+ (left, right) => (left.order ?? 0) - (right.order ?? 0),
34
+ );
35
+ const rendered = await Promise.all(
36
+ sections.map(async (section) => ({
37
+ id: section.id,
38
+ text: await section.render(context),
39
+ })),
40
+ );
41
+ return {
42
+ sections: rendered,
43
+ text: rendered
44
+ .map((section) => section.text.trim())
45
+ .filter(Boolean)
46
+ .join("\n\n"),
47
+ };
48
+ });
49
+ }
50
+ }
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
@@ -1,3 +0,0 @@
1
- # @frockbot/plugin-prompt
2
-
3
- Placeholder reserving this name. See https://github.com/timoconnellaus/frockbot.