@frockbot/plugin-clock 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,12 @@
1
+ {
2
+ "schemaVersion": 3,
3
+ "id": "clock",
4
+ "displayName": "Clock",
5
+ "version": "0.0.1",
6
+ "compatibility": { "frockbot": ">=0.0.1" },
7
+ "dependencies": {},
8
+ "contributions": {
9
+ "runtime": { "entry": "./agent" }
10
+ },
11
+ "permissions": ["time:read"]
12
+ }
package/package.json CHANGED
@@ -1,14 +1,35 @@
1
1
  {
2
2
  "name": "@frockbot/plugin-clock",
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/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
+ "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/node": "26.2.0",
25
+ "typescript": "5.9.3"
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-clock"
10
- },
11
- "publishConfig": {
12
- "access": "public"
13
34
  }
14
35
  }
package/src/agent.ts ADDED
@@ -0,0 +1,56 @@
1
+ import {
2
+ type LlmStreamEvent,
3
+ type NormalizedModelRequest,
4
+ type ToolDefinition,
5
+ } from "@frockbot/kernel-contracts";
6
+ import type { Plugin } from "cordis";
7
+
8
+ function currentTime(): string {
9
+ return new Intl.DateTimeFormat(undefined, {
10
+ dateStyle: "medium",
11
+ timeStyle: "long",
12
+ }).format(new Date());
13
+ }
14
+
15
+ const clockTool: ToolDefinition = {
16
+ name: "current_time",
17
+ description: "Return the current local date and time.",
18
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
19
+ idempotent: true,
20
+ validate: (input: unknown) => typeof input === "object" && input !== null,
21
+ execute: async () => ({ content: currentTime(), isError: false }),
22
+ };
23
+
24
+ async function* requestClockTool(
25
+ signal: AbortSignal,
26
+ ): AsyncIterable<LlmStreamEvent> {
27
+ signal.throwIfAborted();
28
+ yield {
29
+ // pi-lens-ignore: ts:2322
30
+ type: "tool-call",
31
+ call: { id: crypto.randomUUID(), name: "current_time", input: {} },
32
+ };
33
+ yield {
34
+ type: "finish",
35
+ // pi-lens-ignore: ts:2322
36
+ reason: "tool-calls",
37
+ };
38
+ }
39
+
40
+ function shouldRequestClock(request: NormalizedModelRequest): boolean {
41
+ if (request.messages.at(-1)?.role === "tool") return false;
42
+ const user = request.messages.findLast((message) => message.role === "user");
43
+ return user?.role === "user" && user.content.trim() === "/time";
44
+ }
45
+
46
+ export const clockAgentPlugin: Plugin.Function = (ctx) => {
47
+ const tool = ctx.tools.register(clockTool);
48
+ const llm = ctx.on("llm/stream", (request, signal, next) => {
49
+ if (!shouldRequestClock(request)) return next();
50
+ return requestClockTool(signal);
51
+ });
52
+ return [tool, llm];
53
+ };
54
+ clockAgentPlugin.inject = ["tools", "llm"];
55
+
56
+ export default clockAgentPlugin;
package/src/env.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ declare module "*.vue" {
2
+ import type { DefineComponent } from "vue";
3
+
4
+ const component: DefineComponent<
5
+ Record<string, never>,
6
+ Record<string, never>,
7
+ unknown
8
+ >;
9
+ export default component;
10
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./agent.ts";
2
+ export { default as clockManifest } from "./manifest.ts";
@@ -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", "DOM.Iterable"],
12
+ "types": ["node"]
13
+ },
14
+ "include": ["src/**/*.ts"]
15
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # @frockbot/plugin-clock
2
-
3
- Placeholder reserving this name. See https://github.com/timoconnellaus/frockbot.