@kazzle/app 0.1.699 → 0.1.700

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/dist/index.d.ts CHANGED
@@ -1,11 +1,3 @@
1
- export interface KazzleComponentRuntime {
2
- /** Command to start the dev server (e.g. "bun run dev", "vite") */
3
- dev?: string;
4
- /** Command to build for production (e.g. "bun run build", "vite build") */
5
- build?: string;
6
- /** Command to start in production (e.g. "bun run start") */
7
- run?: string;
8
- }
9
1
  export interface KazzleComponentEnv {
10
2
  /** Secret collection slug */
11
3
  collection: string;
@@ -14,6 +6,20 @@ export interface KazzleComponentEnv {
14
6
  /** Only inject these env var names. If omitted, inject all from collection+environment. */
15
7
  include?: string[];
16
8
  }
9
+ export interface KazzleRuntimeMode {
10
+ /** Command to start the component in this mode (e.g. "bun run dev", "bun run start") */
11
+ command: string;
12
+ /** Command to build for this mode (used by production deploys, e.g. "bun run build") */
13
+ build?: string;
14
+ /** Mode-specific secret collection + environment. Falls back to the component env. */
15
+ env?: KazzleComponentEnv;
16
+ }
17
+ export interface KazzleComponentRuntime {
18
+ /** Local dev / preview runtime */
19
+ dev?: KazzleRuntimeMode;
20
+ /** Production runtime */
21
+ prod?: KazzleRuntimeMode;
22
+ }
17
23
  /**
18
24
  * A single trigger entry on a process component. One component can declare
19
25
  * many triggers — for example, a daily cron AND a webhook handler that both
@@ -49,7 +55,9 @@ export interface KazzleComponent {
49
55
  type: 'ui' | 'process';
50
56
  /** Entry path within the app directory */
51
57
  path: string;
52
- /** Commands for dev, build, and run phases */
58
+ /** Default secret collection + environment for env var injection. */
59
+ env?: KazzleComponentEnv;
60
+ /** Commands and optional env overrides for dev and production modes */
53
61
  runtime?: KazzleComponentRuntime;
54
62
  /**
55
63
  * Execution lifecycle for process components.
@@ -63,8 +71,6 @@ export interface KazzleComponent {
63
71
  processMode?: 'persistent' | 'triggered';
64
72
  /** Schedule and webhook triggers. One component may declare many. */
65
73
  triggers?: KazzleTrigger[];
66
- /** Secret collection + environment for env var injection. */
67
- env?: KazzleComponentEnv;
68
74
  }
69
75
  export interface KazzleSkill {
70
76
  /** Skill name */
package/dist/tools.d.ts CHANGED
@@ -1,6 +1,61 @@
1
1
  import type { z } from 'zod';
2
2
  /** Zod schema for a tool's input object. Use .default(), .optional(), .transform(), etc. */
3
3
  export type KazzleToolInputSchema = z.ZodType<Record<string, unknown>>;
4
+ export type ToolRequestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
5
+ export interface ToolRequestSpec {
6
+ method: ToolRequestMethod;
7
+ query?: Record<string, string>;
8
+ headers?: Record<string, string>;
9
+ body?: unknown;
10
+ }
11
+ export type KazzleTarget = ({
12
+ type: 'app';
13
+ component: string;
14
+ path: string;
15
+ } & ToolRequestSpec) | ({
16
+ type: 'url';
17
+ url: string;
18
+ } & ToolRequestSpec) | {
19
+ type: 'kazzle';
20
+ name: string;
21
+ };
22
+ export interface ToolInputButtonElement {
23
+ type: 'button';
24
+ id: string;
25
+ label: string;
26
+ input?: Record<string, unknown>;
27
+ target?: KazzleTarget;
28
+ }
29
+ export type ToolInputControlElement = {
30
+ type: 'text';
31
+ id: string;
32
+ label: string;
33
+ path: string;
34
+ required?: boolean;
35
+ } | {
36
+ type: 'select';
37
+ id: string;
38
+ label: string;
39
+ path: string;
40
+ options: Array<{
41
+ label: string;
42
+ value: string;
43
+ }>;
44
+ required?: boolean;
45
+ } | {
46
+ type: 'checkbox';
47
+ id: string;
48
+ label: string;
49
+ path: string;
50
+ required?: boolean;
51
+ };
52
+ export type ToolInputElement = ToolInputButtonElement | ToolInputControlElement;
53
+ export interface KazzlePendingInput {
54
+ type: 'pending_input';
55
+ title: string;
56
+ description?: string;
57
+ elements: ToolInputElement[];
58
+ }
4
59
  interface KazzleToolBase {
5
60
  /** Provider-safe identifier: letters, numbers, underscores, or hyphens. */
6
61
  name: string;
@@ -9,26 +64,29 @@ interface KazzleToolBase {
9
64
  /** AI-facing description for when to call this tool. */
10
65
  description: string;
11
66
  }
12
- /** A tool served by one of this app's own components. */
13
- export interface KazzleAppTool extends KazzleToolBase {
14
- type: 'app';
67
+ interface KazzleModeledToolBase extends KazzleToolBase {
15
68
  /** Zod schema for tool input. Use .default(), .optional(), .transform(), etc. here. */
16
69
  input: KazzleToolInputSchema;
17
- /** Component name from kazzle.config.ts that serves this tool. */
18
- component: string;
19
- /** POST route on that component. */
20
- path: string;
70
+ /** Addressing and HTTP request shape for dispatch. */
71
+ target: KazzleTarget;
72
+ }
73
+ /** A tool served by one of this app's own components. */
74
+ export interface KazzleAppTool extends KazzleModeledToolBase {
75
+ target: Extract<KazzleTarget, {
76
+ type: 'app';
77
+ }>;
21
78
  }
22
79
  /** A tool served by an external publisher-hosted HTTP endpoint. */
23
- export interface KazzleUrlTool extends KazzleToolBase {
24
- type: 'url';
25
- input: KazzleToolInputSchema;
26
- /** Literal absolute URL, used verbatim. */
27
- url: string;
80
+ export interface KazzleUrlTool extends KazzleModeledToolBase {
81
+ target: Extract<KazzleTarget, {
82
+ type: 'url';
83
+ }>;
28
84
  }
29
85
  /** A name-only reference to a platform/native tool resolved from the code registry. */
30
86
  export interface KazzleNativeTool extends KazzleToolBase {
31
- type: 'kazzle';
87
+ target: Extract<KazzleTarget, {
88
+ type: 'kazzle';
89
+ }>;
32
90
  }
33
91
  export type KazzleTool = KazzleAppTool | KazzleUrlTool | KazzleNativeTool;
34
92
  /** Type-safe tools helper. Use: export const tools = defineTools([...]) */
package/dist/tools.js CHANGED
@@ -14,7 +14,7 @@
14
14
  // Publish-time, the server compiles these Zod schemas into provider JSON schema
15
15
  // for model exposure AND server-side repair validation. That compiler is
16
16
  // server/apps/apps.skills.tools.ts — it reads the SAME shape defined here
17
- // (`type`, `name`, `displayName`, `description`, `input`, `component`/`path`/`url`).
17
+ // (`name`, `displayName`, `description`, `input`, `target`).
18
18
  // If you change this contract, update that compiler and its tests together.
19
19
  /** Type-safe tools helper. Use: export const tools = defineTools([...]) */
20
20
  export function defineTools(tools) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kazzle/app",
3
- "version": "0.1.699",
3
+ "version": "0.1.700",
4
4
  "description": "Contracts, tool helpers, Vite helper, and templates for building Kazzle apps.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -4,6 +4,6 @@ export default defineConfig({
4
4
  icon: 'components/ui/public/favicon.svg',
5
5
  components: [
6
6
  { name: 'ui', type: 'ui', path: './components/ui' },
7
- { name: 'server', type: 'process', path: './components/server/index.ts', runtime: { dev: 'bun run dev', run: 'bun run start' } },
7
+ { name: 'server', type: 'process', path: './components/server/index.ts', runtime: { dev: { command: 'bun run dev' }, prod: { command: 'bun run start' } } },
8
8
  ],
9
9
  });
@@ -109,14 +109,14 @@ const server = Bun.serve({
109
109
  // ── AI tool handlers (the "kitchen") ─────────────────────────────────
110
110
  //
111
111
  // Each tool declared in skills/tools/tools.ts is backed by a route here.
112
- // When the AI calls `save_bookmark`, Kazzle POSTs { input } to this path
112
+ // When the AI calls `save_bookmark`, Kazzle POSTs the tool input to this path
113
113
  // with the app identity as `Authorization: Bearer <token>`. Return either
114
114
  // plain text or JSON { content } — that becomes the tool result the AI sees.
115
115
  //
116
116
  // To add a tool: add it to tools.ts (name + Zod input + path), then add
117
117
  // its matching `POST <path>` route below.
118
118
  if (req.method === 'POST' && url.pathname === '/tools/save-bookmark') {
119
- const { input } = (await req.json().catch(() => ({}))) as { input?: unknown };
119
+ const input = await req.json().catch(() => ({}));
120
120
  const parsed = SaveBookmarkInput.safeParse(input);
121
121
  if (!parsed.success) {
122
122
  return Response.json({ content: parsed.error.issues.map(issue => issue.message).join('; ') }, { status: 400 });
@@ -9,7 +9,7 @@ export default defineConfig({
9
9
  name: '{{APP_NAME}}',
10
10
  type: 'process',
11
11
  path: './components/process/index.ts',
12
- runtime: { dev: 'bun run dev', run: 'bun run start' },
12
+ runtime: { dev: { command: 'bun run dev' }, prod: { command: 'bun run start' } },
13
13
  // Persistent processes are long-running servers. The platform posts
14
14
  // triggers into the running server at each trigger's `path` with
15
15
  // `Authorization: Bearer ${KAZZLE_TRIGGER_SECRET}`. Customer code
@@ -8,12 +8,16 @@ export const SaveBookmarkInput = z.object({
8
8
 
9
9
  export const tools = [
10
10
  {
11
- type: 'app',
12
11
  name: 'save_bookmark',
13
12
  displayName: 'Save bookmark',
14
13
  description: 'Save a bookmark URL and return a confirmation.',
15
- component: '{{APP_NAME}}',
16
- path: '/tools/save-bookmark',
17
14
  input: SaveBookmarkInput,
15
+ target: {
16
+ type: 'app',
17
+ component: '{{APP_NAME}}',
18
+ path: '/tools/save-bookmark',
19
+ method: 'POST',
20
+ body: '${input}',
21
+ },
18
22
  },
19
23
  ] as const satisfies readonly KazzleTool[];
@@ -6,6 +6,6 @@ export default defineConfig({
6
6
  /** App components — each entry defines a deployable unit. Max 1 UI component. */
7
7
  components: [
8
8
  { name: 'ui', type: 'ui', path: './components/ui' },
9
- { name: 'server', type: 'process', path: './components/server/index.ts', runtime: { dev: 'bun run dev', run: 'bun run start' } },
9
+ { name: 'server', type: 'process', path: './components/server/index.ts', runtime: { dev: { command: 'bun run dev' }, prod: { command: 'bun run start' } } },
10
10
  ],
11
11
  });
@@ -4,6 +4,6 @@ export default defineConfig({
4
4
  icon: 'components/ui/public/favicon.svg',
5
5
  components: [
6
6
  { name: 'ui', type: 'ui', path: './components/ui' },
7
- { name: 'server', type: 'process', path: './components/server/index.ts', runtime: { dev: 'bun run dev', run: 'bun run start' } },
7
+ { name: 'server', type: 'process', path: './components/server/index.ts', runtime: { dev: { command: 'bun run dev' }, prod: { command: 'bun run start' } } },
8
8
  ],
9
9
  });