clawnify 0.18.0 → 0.19.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.
@@ -619,7 +619,7 @@ async function pollUntilReady(resourceId, options = {}) {
619
619
  }
620
620
 
621
621
  // src/version.ts
622
- var VERSION = "0.18.0";
622
+ var VERSION = "0.19.0";
623
623
 
624
624
  export {
625
625
  OAUTH_CLIENT_ID,
@@ -643,4 +643,4 @@ export {
643
643
  pollUntilReady,
644
644
  VERSION
645
645
  };
646
- //# sourceMappingURL=chunk-IF377V6W.js.map
646
+ //# sourceMappingURL=chunk-PL5QYOO3.js.map
@@ -20,7 +20,7 @@ import {
20
20
  resolveOrgContext,
21
21
  saveAuth,
22
22
  saveProject
23
- } from "./chunk-IF377V6W.js";
23
+ } from "./chunk-PL5QYOO3.js";
24
24
 
25
25
  // src/cli.ts
26
26
  import { Command, Option } from "commander";
@@ -1754,7 +1754,7 @@ function agentByName(name) {
1754
1754
  var ALL_AGENTS = DETECTORS.map((d) => d.agent);
1755
1755
 
1756
1756
  // src/lib/skills/content.gen.ts
1757
- var CLI_VERSION = "0.18.0";
1757
+ var CLI_VERSION = "0.19.0";
1758
1758
  var BUNDLED_SKILLS = [
1759
1759
  {
1760
1760
  name: "build-a-clawnify-app",
@@ -2319,7 +2319,7 @@ async function initApp(dir, opts) {
2319
2319
  deploy: "clawnify deploy"
2320
2320
  },
2321
2321
  dependencies: {
2322
- "@clawnify/app": "^0.1.1",
2322
+ "@clawnify/app": "^0.2.2",
2323
2323
  "@clawnify/db": "^0.4.1",
2324
2324
  "@hono/zod-openapi": "^0.19.0",
2325
2325
  hono: "^4.0.0",
@@ -2776,8 +2776,8 @@ logs/
2776
2776
  console.log();
2777
2777
  }
2778
2778
  function writeBlankTemplate(dir, name) {
2779
- write(dir, "src/server/routes.ts", `import { OpenAPIHono, createRoute, z } from "@clawnify/app";
2780
- import { getDB, desc } from "@clawnify/db";
2779
+ write(dir, "src/server/routes.ts", `import { OpenAPIHono, createRoute, z, PageQuery, pageParams, pagedResponse } from "@clawnify/app";
2780
+ import { getDB, desc, like } from "@clawnify/db";
2781
2781
  import * as schema from "./schema";
2782
2782
 
2783
2783
  type Env = { Bindings: { DB: D1Database } };
@@ -2794,20 +2794,24 @@ api.openapi(
2794
2794
  method: "get",
2795
2795
  path: "/api/items",
2796
2796
  summary: "List items",
2797
- responses: {
2798
- 200: {
2799
- description: "List of items",
2800
- content: { "application/json": { schema: z.array(ItemSchema) } },
2801
- },
2802
- },
2797
+ // Every list endpoint pages: an agent reads this API through one tool,
2798
+ // and an unbounded list would land in its context whole.
2799
+ request: { query: PageQuery },
2800
+ responses: { 200: pagedResponse("items", ItemSchema) },
2803
2801
  }),
2804
2802
  async (c) => {
2803
+ const { page, limit, offset, search } = pageParams(c.req.valid("query"));
2805
2804
  const db = getDB(c.env, { schema });
2805
+ const where = search ? like(schema.items.name, "%" + search + "%") : undefined;
2806
+ const total = await db.$count(schema.items, where);
2806
2807
  const items = await db
2807
2808
  .select()
2808
2809
  .from(schema.items)
2809
- .orderBy(desc(schema.items.createdAt));
2810
- return c.json(items);
2810
+ .where(where)
2811
+ .orderBy(desc(schema.items.createdAt))
2812
+ .limit(limit)
2813
+ .offset(offset);
2814
+ return c.json({ items, total, page, limit }, 200);
2811
2815
  },
2812
2816
  );
2813
2817
 
@@ -2864,8 +2868,8 @@ export const items = sqliteTable("items", {
2864
2868
  createdAt: text("created_at").notNull().$default(() => new Date().toISOString()),
2865
2869
  });
2866
2870
  `);
2867
- write(dir, "src/server/routes.ts", `import { OpenAPIHono, createRoute, z } from "@clawnify/app";
2868
- import { getDB, eq, desc } from "@clawnify/db";
2871
+ write(dir, "src/server/routes.ts", `import { OpenAPIHono, createRoute, z, PageQuery, pageParams, pagedResponse } from "@clawnify/app";
2872
+ import { getDB, eq, desc, like } from "@clawnify/db";
2869
2873
  import * as schema from "./schema";
2870
2874
 
2871
2875
  type Env = { Bindings: { DB: D1Database } };
@@ -2891,20 +2895,24 @@ api.openapi(
2891
2895
  method: "get",
2892
2896
  path: "/api/items",
2893
2897
  summary: "List items",
2894
- responses: {
2895
- 200: {
2896
- description: "List of items",
2897
- content: { "application/json": { schema: z.array(ItemSchema) } },
2898
- },
2899
- },
2898
+ // Every list endpoint pages: an agent reads this API through one tool,
2899
+ // and an unbounded list would land in its context whole.
2900
+ request: { query: PageQuery },
2901
+ responses: { 200: pagedResponse("items", ItemSchema) },
2900
2902
  }),
2901
2903
  async (c) => {
2904
+ const { page, limit, offset, search } = pageParams(c.req.valid("query"));
2902
2905
  const db = getDB(c.env, { schema });
2906
+ const where = search ? like(schema.items.title, "%" + search + "%") : undefined;
2907
+ const total = await db.$count(schema.items, where);
2903
2908
  const items = await db
2904
2909
  .select()
2905
2910
  .from(schema.items)
2906
- .orderBy(desc(schema.items.createdAt));
2907
- return c.json(items);
2911
+ .where(where)
2912
+ .orderBy(desc(schema.items.createdAt))
2913
+ .limit(limit)
2914
+ .offset(offset);
2915
+ return c.json({ items, total, page, limit }, 200);
2908
2916
  },
2909
2917
  );
2910
2918
 
@@ -2993,7 +3001,7 @@ export function App() {
2993
3001
 
2994
3002
  async function load() {
2995
3003
  const res = await fetch("/api/items");
2996
- setItems(await res.json());
3004
+ setItems(((await res.json()) as { items: Item[] }).items);
2997
3005
  }
2998
3006
 
2999
3007
  useEffect(() => { load(); }, []);
@@ -4453,4 +4461,4 @@ async function runCli() {
4453
4461
  export {
4454
4462
  runCli
4455
4463
  };
4456
- //# sourceMappingURL=cli-ONUETCNY.js.map
4464
+ //# sourceMappingURL=cli-HOY7B3PC.js.map