@frockbot/plugin-provider-foundation 0.3.2 → 0.3.3

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/runtime.ts +32 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frockbot/plugin-provider-foundation",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
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.2",
22
- "@frockbot/plugin-models": "0.3.2",
21
+ "@frockbot/kernel-contracts": "0.3.3",
22
+ "@frockbot/plugin-models": "0.3.3",
23
23
  "cordis": "4.0.0-rc.8"
24
24
  },
25
25
  "devDependencies": {
26
- "@frockbot/plugin-testkit": "0.3.2",
26
+ "@frockbot/plugin-testkit": "0.3.3",
27
27
  "@types/bun": "1.4.0",
28
28
  "typescript": "^7.0.2"
29
29
  },
package/src/runtime.ts CHANGED
@@ -7,6 +7,36 @@ import type { Plugin } from "cordis";
7
7
  export const FOUNDATION_PROVIDER = "foundation";
8
8
  export const FOUNDATION_MODEL = "deterministic-v1";
9
9
 
10
+ function presentedToolName(
11
+ request: Parameters<LlmProvider["stream"]>[0],
12
+ toolCallId: string,
13
+ name: string,
14
+ ): string {
15
+ if (name !== "call_dynamic_tool") return name;
16
+ const call = request.messages
17
+ .toReversed()
18
+ .find((message) => message.role === "assistant")
19
+ ?.toolCalls.find((candidate) => candidate.id === toolCallId);
20
+ if (
21
+ !call ||
22
+ typeof call.input !== "object" ||
23
+ call.input === null ||
24
+ Array.isArray(call.input)
25
+ ) {
26
+ return name;
27
+ }
28
+ const input = call.input as Record<string, unknown>;
29
+ if (
30
+ typeof input.namespace !== "string" ||
31
+ typeof input.toolName !== "string"
32
+ ) {
33
+ return name;
34
+ }
35
+ return input.namespace === "frockbot"
36
+ ? input.toolName
37
+ : `${input.namespace}/${input.toolName}`;
38
+ }
39
+
10
40
  async function* foundationStream(
11
41
  request: Parameters<LlmProvider["stream"]>[0],
12
42
  signal: AbortSignal,
@@ -14,7 +44,8 @@ async function* foundationStream(
14
44
  signal.throwIfAborted();
15
45
  const latest = request.messages.at(-1);
16
46
  if (latest?.role === "tool") {
17
- const label = latest.name === "echo" ? "Echo" : latest.name;
47
+ const name = presentedToolName(request, latest.callId, latest.name);
48
+ const label = name === "echo" ? "Echo" : name;
18
49
  yield { type: "text-delta", text: `${label}: ` };
19
50
  await Promise.resolve();
20
51
  signal.throwIfAborted();