@frockbot/plugin-models 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": "models",
4
+ "displayName": "Models",
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-models",
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/llm.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-models"
10
- },
11
- "publishConfig": {
12
- "access": "public"
13
34
  }
14
35
  }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./llm.js";
2
+ export { default as modelsManifest } from "./manifest.js";
package/src/llm.ts ADDED
@@ -0,0 +1,85 @@
1
+ import { type Context, Service } from "cordis";
2
+ import {
3
+ LlmEffectNotStartedError,
4
+ type LlmProvider,
5
+ type LlmReconciliationOutcome,
6
+ type LlmStreamEvent,
7
+ type ModelInvocation,
8
+ type NormalizedModelRequest,
9
+ } from "@frockbot/kernel-contracts";
10
+
11
+ export class LlmRegistry extends Service implements ModelInvocation {
12
+ private providers = new Map<string, LlmProvider>();
13
+
14
+ constructor(ctx: Context) {
15
+ super(ctx, "llm");
16
+ }
17
+
18
+ register(provider: LlmProvider): () => void {
19
+ if (this.providers.has(provider.id)) {
20
+ throw new Error(`LLM provider "${provider.id}" is already registered`);
21
+ }
22
+ this.providers.set(provider.id, provider);
23
+ return () => {
24
+ if (this.providers.get(provider.id) === provider) {
25
+ this.providers.delete(provider.id);
26
+ }
27
+ };
28
+ }
29
+
30
+ get(providerId: string): LlmProvider | undefined {
31
+ return this.providers.get(providerId);
32
+ }
33
+
34
+ list(): LlmProvider[] {
35
+ return [...this.providers.values()];
36
+ }
37
+
38
+ stream(
39
+ request: NormalizedModelRequest,
40
+ signal: AbortSignal,
41
+ ): AsyncIterable<LlmStreamEvent> {
42
+ const provider = this.providers.get(request.provider);
43
+ if (!provider)
44
+ throw new LlmEffectNotStartedError(
45
+ `LLM provider "${request.provider}" is unavailable`,
46
+ );
47
+ return this.ctx.waterfall("llm/stream", request, signal, () =>
48
+ provider.stream(request, signal),
49
+ );
50
+ }
51
+
52
+ async reconcile(
53
+ request: NormalizedModelRequest,
54
+ signal: AbortSignal,
55
+ ): Promise<LlmReconciliationOutcome> {
56
+ const provider = this.providers.get(request.provider);
57
+ if (!provider) {
58
+ return {
59
+ status: "unavailable",
60
+ reason: `LLM provider "${request.provider}" is unavailable`,
61
+ };
62
+ }
63
+ if (!provider.reconciliation) {
64
+ return {
65
+ status: "unavailable",
66
+ reason: `LLM provider "${request.provider}" does not support provider-bound retrieval`,
67
+ };
68
+ }
69
+ try {
70
+ return await provider.reconciliation.retrieve(
71
+ { providerEffectId: request.requestId, request },
72
+ signal,
73
+ );
74
+ } catch (error) {
75
+ signal.throwIfAborted();
76
+ return {
77
+ status: "unavailable",
78
+ reason:
79
+ error instanceof Error
80
+ ? error.message
81
+ : "Provider-bound retrieval failed",
82
+ };
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,3 @@
1
+ import manifest from "../frockbot.json" with { type: "json" };
2
+
3
+ export default manifest;
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-models
2
-
3
- Placeholder reserving this name. See https://github.com/timoconnellaus/frockbot.