@cef-ai/cli 1.4.0 → 1.5.0

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 (39) hide show
  1. package/README.md +5 -1
  2. package/dist/cli-program.d.ts +6 -0
  3. package/dist/cli-program.d.ts.map +1 -1
  4. package/dist/cli-program.js +112 -0
  5. package/dist/cli-program.js.map +1 -1
  6. package/dist/commands/deploy.d.ts +38 -0
  7. package/dist/commands/deploy.d.ts.map +1 -0
  8. package/dist/commands/deploy.js +317 -0
  9. package/dist/commands/deploy.js.map +1 -0
  10. package/dist/commands/init.d.ts +41 -0
  11. package/dist/commands/init.d.ts.map +1 -0
  12. package/dist/commands/init.js +191 -0
  13. package/dist/commands/init.js.map +1 -0
  14. package/dist/commands/publish.d.ts.map +1 -1
  15. package/dist/commands/publish.js +4 -1
  16. package/dist/commands/publish.js.map +1 -1
  17. package/dist/lib/ddc.d.ts.map +1 -1
  18. package/dist/lib/ddc.js +18 -1
  19. package/dist/lib/ddc.js.map +1 -1
  20. package/dist/lib.d.ts +4 -0
  21. package/dist/lib.d.ts.map +1 -1
  22. package/dist/lib.js +2 -0
  23. package/dist/lib.js.map +1 -1
  24. package/package.json +3 -2
  25. package/templates/hello-world/AGENTS.md +41 -0
  26. package/templates/hello-world/CLAUDE.md +9 -0
  27. package/templates/hello-world/README.md +55 -0
  28. package/templates/hello-world/cef.config.ts +24 -0
  29. package/templates/hello-world/claude/settings.json +23 -0
  30. package/templates/hello-world/deployments/default.jsonc +9 -0
  31. package/templates/hello-world/deployments/sandbox-canary.jsonc +12 -0
  32. package/templates/hello-world/gitignore +3 -0
  33. package/templates/hello-world/migrations/history/001-init.sql +5 -0
  34. package/templates/hello-world/package.json +23 -0
  35. package/templates/hello-world/src/agent.ts +44 -0
  36. package/templates/hello-world/test/agent.test.ts +28 -0
  37. package/templates/hello-world/tsconfig.json +19 -0
  38. package/templates/hello-world/widgets/hello/app.js +8 -0
  39. package/templates/hello-world/widgets/hello/hello.html +5 -0
@@ -0,0 +1,12 @@
1
+ // Example audience deployment: only sandbox vaults get this pinned build;
2
+ // everyone else falls through to default.jsonc. Edit or delete freely.
3
+ //
4
+ // targeting is a CEL expression over vault.id / vault.scope / event.type.
5
+ // Among matching deployments the LOWEST priority wins; within a tier, traffic
6
+ // splits by weight (that's how you run an A/B test).
7
+ {
8
+ "priority": 10, // lower than the default (99) => wins for matching vaults
9
+ "targeting": "vault.scope == 'sandbox'",
10
+ "version": "0.1.0",
11
+ "weight": 1
12
+ }
@@ -0,0 +1,3 @@
1
+ node_modules/
2
+ dist/
3
+ .cef/
@@ -0,0 +1,5 @@
1
+ CREATE TABLE messages (
2
+ id INTEGER PRIMARY KEY,
3
+ text TEXT NOT NULL,
4
+ ts INTEGER NOT NULL
5
+ );
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "{{projectName}}",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "build": "cef build",
8
+ "typegen": "cef typegen",
9
+ "test": "vitest run",
10
+ "push": "cef push",
11
+ "deploy": "cef deploy",
12
+ "publish": "cef publish"
13
+ },
14
+ "dependencies": {
15
+ "@cef-ai/agent-sdk": "^1.4.0"
16
+ },
17
+ "devDependencies": {
18
+ "@cef-ai/cli": "^1.4.0",
19
+ "@cef-ai/testing": "^1.1.9",
20
+ "typescript": "^5.4.0",
21
+ "vitest": "^1.5.0"
22
+ }
23
+ }
@@ -0,0 +1,44 @@
1
+ import {
2
+ Engagement,
3
+ OnEvent,
4
+ OnStart,
5
+ OnClose,
6
+ type Context,
7
+ type Event,
8
+ } from "@cef-ai/agent-sdk";
9
+
10
+ interface UserMessage {
11
+ text: string;
12
+ }
13
+
14
+ @Engagement({
15
+ id: "default",
16
+ goal: "reply to a user message and remember it",
17
+ })
18
+ export default class HelloAgent {
19
+ @OnStart
20
+ async onStart() {
21
+ // Plain logging goes to the sandbox console; `ctx` is only for
22
+ // CEF-specific calls (cubby / publish / models / close).
23
+ console.info("hello-world agent started");
24
+ }
25
+
26
+ @OnEvent("user_message")
27
+ async onMessage(event: Event<UserMessage>, ctx: Context) {
28
+ await ctx
29
+ .cubby("history")
30
+ .exec("INSERT INTO messages(id, text, ts) VALUES (?, ?, ?)", [
31
+ Date.now(),
32
+ event.payload.text,
33
+ event.ts,
34
+ ]);
35
+ await ctx.publish("reply", {
36
+ text: `hello — you said: ${event.payload.text}`,
37
+ });
38
+ }
39
+
40
+ @OnClose
41
+ async onClose(_ctx: Context, reason: string) {
42
+ console.info("hello-world agent closing", { reason });
43
+ }
44
+ }
@@ -0,0 +1,28 @@
1
+ import { describe, it, expect, afterEach } from "vitest";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { testAgent, type TestHarness } from "@cef-ai/testing";
5
+ import HelloAgent from "../src/agent.js";
6
+
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+ const HISTORY_MIGRATIONS = path.resolve(__dirname, "../migrations/history");
9
+
10
+ describe("hello-world agent", () => {
11
+ let h: TestHarness | undefined;
12
+ afterEach(() => h?.dispose());
13
+
14
+ it("replies to user_message and persists to history", async () => {
15
+ h = testAgent(HelloAgent, {
16
+ cubbies: [{ alias: "history", migrations: HISTORY_MIGRATIONS }],
17
+ });
18
+ const events = await h.dispatch({
19
+ type: "user_message",
20
+ payload: { text: "hi" },
21
+ });
22
+ expect(events.map((e) => e.type)).toContain("reply");
23
+ const rows = await h
24
+ .cubby("history")
25
+ .query<{ text: string }>("SELECT text FROM messages");
26
+ expect(rows.map((r) => r.text)).toEqual(["hi"]);
27
+ });
28
+ });
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "lib": ["ES2022"],
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "isolatedModules": true,
12
+ "resolveJsonModule": true,
13
+ "experimentalDecorators": true,
14
+ "emitDecoratorMetadata": false,
15
+ "noEmit": true
16
+ },
17
+ "include": ["src/**/*", "test/**/*", "cef.config.ts"],
18
+ "exclude": ["dist", ".cef", "node_modules"]
19
+ }
@@ -0,0 +1,8 @@
1
+ // A minimal, self-contained widget (plain HTML + JS — no build step).
2
+ //
3
+ // When the @cef-ai/widget-runtime ships, you can read this agent's cubby
4
+ // and publish events from here, e.g.:
5
+ // const { rows } = await window.WidgetRuntime.query("SELECT text FROM messages");
6
+ // await window.WidgetRuntime.publish("user_message", { text: "hi" });
7
+ document.getElementById("root").textContent =
8
+ "hello from {{agentId}} — this is your widget";
@@ -0,0 +1,5 @@
1
+ <!doctype html>
2
+ <meta charset="utf-8" />
3
+ <title>Hello — {{agentId}}</title>
4
+ <div id="root"></div>
5
+ <script src="./app.js"></script>