@frockbot/plugin-provider-foundation 0.3.14 → 0.3.16
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/package.json +4 -4
- package/src/runtime.test.ts +6 -0
- package/src/runtime.ts +33 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frockbot/plugin-provider-foundation",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.16",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@frockbot/kernel-contracts": "0.3.
|
|
22
|
-
"@frockbot/plugin-models": "0.3.
|
|
21
|
+
"@frockbot/kernel-contracts": "0.3.16",
|
|
22
|
+
"@frockbot/plugin-models": "0.3.16",
|
|
23
23
|
"cordis": "4.0.0-rc.8"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@frockbot/plugin-testkit": "0.3.
|
|
26
|
+
"@frockbot/plugin-testkit": "0.3.16",
|
|
27
27
|
"@types/bun": "1.4.0",
|
|
28
28
|
"typescript": "^7.0.2"
|
|
29
29
|
},
|
package/src/runtime.test.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import manifest from "../frockbot.json" with { type: "json" };
|
|
12
12
|
import packageJson from "../package.json" with { type: "json" };
|
|
13
13
|
import foundationProviderPlugin, {
|
|
14
|
+
classifyFoundationFailureV1,
|
|
14
15
|
FOUNDATION_MODEL,
|
|
15
16
|
FOUNDATION_PROVIDER,
|
|
16
17
|
} from "./runtime.js";
|
|
@@ -33,6 +34,11 @@ async function collect(
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
describe("foundation provider plugin", () => {
|
|
37
|
+
test("classifies its only pre-stream failure shape as unknown", () => {
|
|
38
|
+
const failure = classifyFoundationFailureV1(new Error("local failure"));
|
|
39
|
+
expect(failure.classification).toBe("unknown");
|
|
40
|
+
expect(failure.providerReason).toBe("local failure");
|
|
41
|
+
});
|
|
36
42
|
test("registers deterministic provider behavior for its fiber lifetime", async () => {
|
|
37
43
|
const harness = await createPluginHarness([LlmRegistry]);
|
|
38
44
|
const fiber = await harness.mount(foundationProviderPlugin);
|
package/src/runtime.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type LlmProvider,
|
|
3
3
|
type LlmStreamEvent,
|
|
4
|
+
ModelProviderFailureError,
|
|
4
5
|
} from "@frockbot/kernel-contracts";
|
|
5
6
|
import type { Plugin } from "cordis";
|
|
6
7
|
|
|
@@ -73,9 +74,40 @@ async function foundationReconciliation(
|
|
|
73
74
|
return events;
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
/** Foundation has no remote status surface; an unexpected pre-stream fault is unknown. */
|
|
78
|
+
export function classifyFoundationFailureV1(
|
|
79
|
+
error: unknown,
|
|
80
|
+
): ModelProviderFailureError {
|
|
81
|
+
return error instanceof ModelProviderFailureError
|
|
82
|
+
? error
|
|
83
|
+
: new ModelProviderFailureError({
|
|
84
|
+
classification: "unknown",
|
|
85
|
+
reason:
|
|
86
|
+
error instanceof Error
|
|
87
|
+
? error.message
|
|
88
|
+
: "Foundation model failed before replying",
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function* classifiedFoundationStream(
|
|
93
|
+
request: Parameters<LlmProvider["stream"]>[0],
|
|
94
|
+
signal: AbortSignal,
|
|
95
|
+
): AsyncGenerator<LlmStreamEvent> {
|
|
96
|
+
let started = false;
|
|
97
|
+
try {
|
|
98
|
+
for await (const event of foundationStream(request, signal)) {
|
|
99
|
+
started = true;
|
|
100
|
+
yield event;
|
|
101
|
+
}
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (started || signal.aborted) throw error;
|
|
104
|
+
throw classifyFoundationFailureV1(error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
76
108
|
export const foundationProvider: LlmProvider = {
|
|
77
109
|
id: FOUNDATION_PROVIDER,
|
|
78
|
-
stream:
|
|
110
|
+
stream: classifiedFoundationStream,
|
|
79
111
|
reconciliation: {
|
|
80
112
|
retrieve: async (effect, signal) =>
|
|
81
113
|
({
|