@sajou/mcp-server 0.6.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 (130) hide show
  1. package/README.md +78 -0
  2. package/dist/app.d.ts +32 -0
  3. package/dist/app.d.ts.map +1 -0
  4. package/dist/app.js +76 -0
  5. package/dist/app.js.map +1 -0
  6. package/dist/index.d.ts +18 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +65 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/mcp/transport.d.ts +18 -0
  11. package/dist/mcp/transport.d.ts.map +1 -0
  12. package/dist/mcp/transport.js +56 -0
  13. package/dist/mcp/transport.js.map +1 -0
  14. package/dist/middleware.d.ts +14 -0
  15. package/dist/middleware.d.ts.map +1 -0
  16. package/dist/middleware.js +14 -0
  17. package/dist/middleware.js.map +1 -0
  18. package/dist/routes/discovery.d.ts +8 -0
  19. package/dist/routes/discovery.d.ts.map +1 -0
  20. package/dist/routes/discovery.js +155 -0
  21. package/dist/routes/discovery.js.map +1 -0
  22. package/dist/routes/proxy.d.ts +10 -0
  23. package/dist/routes/proxy.d.ts.map +1 -0
  24. package/dist/routes/proxy.js +84 -0
  25. package/dist/routes/proxy.js.map +1 -0
  26. package/dist/routes/scene.d.ts +10 -0
  27. package/dist/routes/scene.d.ts.map +1 -0
  28. package/dist/routes/scene.js +298 -0
  29. package/dist/routes/scene.js.map +1 -0
  30. package/dist/routes/signals.d.ts +12 -0
  31. package/dist/routes/signals.d.ts.map +1 -0
  32. package/dist/routes/signals.js +61 -0
  33. package/dist/routes/signals.js.map +1 -0
  34. package/dist/routes/tap.d.ts +10 -0
  35. package/dist/routes/tap.d.ts.map +1 -0
  36. package/dist/routes/tap.js +115 -0
  37. package/dist/routes/tap.js.map +1 -0
  38. package/dist/server.d.ts +12 -0
  39. package/dist/server.d.ts.map +1 -0
  40. package/dist/server.js +103 -0
  41. package/dist/server.js.map +1 -0
  42. package/dist/state/mutations.d.ts +53 -0
  43. package/dist/state/mutations.d.ts.map +1 -0
  44. package/dist/state/mutations.js +409 -0
  45. package/dist/state/mutations.js.map +1 -0
  46. package/dist/state/store.d.ts +51 -0
  47. package/dist/state/store.d.ts.map +1 -0
  48. package/dist/state/store.js +149 -0
  49. package/dist/state/store.js.map +1 -0
  50. package/dist/tools/create-binding.d.ts +45 -0
  51. package/dist/tools/create-binding.d.ts.map +1 -0
  52. package/dist/tools/create-binding.js +82 -0
  53. package/dist/tools/create-binding.js.map +1 -0
  54. package/dist/tools/create-choreography.d.ts +76 -0
  55. package/dist/tools/create-choreography.d.ts.map +1 -0
  56. package/dist/tools/create-choreography.js +118 -0
  57. package/dist/tools/create-choreography.js.map +1 -0
  58. package/dist/tools/create-shader.d.ts +117 -0
  59. package/dist/tools/create-shader.d.ts.map +1 -0
  60. package/dist/tools/create-shader.js +150 -0
  61. package/dist/tools/create-shader.js.map +1 -0
  62. package/dist/tools/create-sketch.d.ts +96 -0
  63. package/dist/tools/create-sketch.d.ts.map +1 -0
  64. package/dist/tools/create-sketch.js +130 -0
  65. package/dist/tools/create-sketch.js.map +1 -0
  66. package/dist/tools/create-wire.d.ts +32 -0
  67. package/dist/tools/create-wire.d.ts.map +1 -0
  68. package/dist/tools/create-wire.js +84 -0
  69. package/dist/tools/create-wire.js.map +1 -0
  70. package/dist/tools/describe-scene.d.ts +22 -0
  71. package/dist/tools/describe-scene.d.ts.map +1 -0
  72. package/dist/tools/describe-scene.js +194 -0
  73. package/dist/tools/describe-scene.js.map +1 -0
  74. package/dist/tools/emit-signal.d.ts +36 -0
  75. package/dist/tools/emit-signal.d.ts.map +1 -0
  76. package/dist/tools/emit-signal.js +60 -0
  77. package/dist/tools/emit-signal.js.map +1 -0
  78. package/dist/tools/get-catalog.d.ts +27 -0
  79. package/dist/tools/get-catalog.d.ts.map +1 -0
  80. package/dist/tools/get-catalog.js +37 -0
  81. package/dist/tools/get-catalog.js.map +1 -0
  82. package/dist/tools/get-choreographies.d.ts +21 -0
  83. package/dist/tools/get-choreographies.d.ts.map +1 -0
  84. package/dist/tools/get-choreographies.js +70 -0
  85. package/dist/tools/get-choreographies.js.map +1 -0
  86. package/dist/tools/get-scene-state.d.ts +21 -0
  87. package/dist/tools/get-scene-state.d.ts.map +1 -0
  88. package/dist/tools/get-scene-state.js +48 -0
  89. package/dist/tools/get-scene-state.js.map +1 -0
  90. package/dist/tools/get-shaders.d.ts +16 -0
  91. package/dist/tools/get-shaders.d.ts.map +1 -0
  92. package/dist/tools/get-shaders.js +38 -0
  93. package/dist/tools/get-shaders.js.map +1 -0
  94. package/dist/tools/get-sketches.d.ts +16 -0
  95. package/dist/tools/get-sketches.d.ts.map +1 -0
  96. package/dist/tools/get-sketches.js +37 -0
  97. package/dist/tools/get-sketches.js.map +1 -0
  98. package/dist/tools/list-themes.d.ts +21 -0
  99. package/dist/tools/list-themes.d.ts.map +1 -0
  100. package/dist/tools/list-themes.js +32 -0
  101. package/dist/tools/list-themes.js.map +1 -0
  102. package/dist/tools/map-signals.d.ts +30 -0
  103. package/dist/tools/map-signals.d.ts.map +1 -0
  104. package/dist/tools/map-signals.js +44 -0
  105. package/dist/tools/map-signals.js.map +1 -0
  106. package/dist/tools/place-entity.d.ts +47 -0
  107. package/dist/tools/place-entity.d.ts.map +1 -0
  108. package/dist/tools/place-entity.js +85 -0
  109. package/dist/tools/place-entity.js.map +1 -0
  110. package/dist/tools/remove-item.d.ts +25 -0
  111. package/dist/tools/remove-item.d.ts.map +1 -0
  112. package/dist/tools/remove-item.js +55 -0
  113. package/dist/tools/remove-item.js.map +1 -0
  114. package/dist/tools/set-sketch-param.d.ts +29 -0
  115. package/dist/tools/set-sketch-param.d.ts.map +1 -0
  116. package/dist/tools/set-sketch-param.js +49 -0
  117. package/dist/tools/set-sketch-param.js.map +1 -0
  118. package/dist/tools/set-uniform.d.ts +29 -0
  119. package/dist/tools/set-uniform.d.ts.map +1 -0
  120. package/dist/tools/set-uniform.js +49 -0
  121. package/dist/tools/set-uniform.js.map +1 -0
  122. package/dist/tools/update-shader.d.ts +119 -0
  123. package/dist/tools/update-shader.d.ts.map +1 -0
  124. package/dist/tools/update-shader.js +81 -0
  125. package/dist/tools/update-shader.js.map +1 -0
  126. package/dist/tools/update-sketch.d.ts +99 -0
  127. package/dist/tools/update-sketch.d.ts.map +1 -0
  128. package/dist/tools/update-sketch.js +75 -0
  129. package/dist/tools/update-sketch.js.map +1 -0
  130. package/package.json +55 -0
@@ -0,0 +1,117 @@
1
+ /**
2
+ * MCP tool: create_shader
3
+ *
4
+ * Creates a GLSL shader in the scene-builder with uniforms that the
5
+ * choreographer can tween at runtime.
6
+ */
7
+ import { z } from "zod";
8
+ export declare const name = "create_shader";
9
+ export declare const description: string;
10
+ export declare const inputSchema: z.ZodObject<{
11
+ name: z.ZodString;
12
+ fragmentSource: z.ZodString;
13
+ vertexSource: z.ZodOptional<z.ZodString>;
14
+ uniforms: z.ZodOptional<z.ZodArray<z.ZodObject<{
15
+ name: z.ZodString;
16
+ type: z.ZodEnum<["float", "int", "bool", "vec2", "vec3", "vec4"]>;
17
+ control: z.ZodEnum<["slider", "color", "toggle", "xy"]>;
18
+ value: z.ZodUnion<[z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodNumber, "many">]>;
19
+ min: z.ZodOptional<z.ZodNumber>;
20
+ max: z.ZodOptional<z.ZodNumber>;
21
+ step: z.ZodOptional<z.ZodNumber>;
22
+ objectId: z.ZodOptional<z.ZodString>;
23
+ bind: z.ZodOptional<z.ZodObject<{
24
+ semantic: z.ZodString;
25
+ }, "strip", z.ZodTypeAny, {
26
+ semantic: string;
27
+ }, {
28
+ semantic: string;
29
+ }>>;
30
+ }, "strip", z.ZodTypeAny, {
31
+ name: string;
32
+ type: "float" | "bool" | "int" | "vec2" | "vec3" | "vec4";
33
+ control: "slider" | "color" | "toggle" | "xy";
34
+ value: number | boolean | number[];
35
+ min?: number | undefined;
36
+ max?: number | undefined;
37
+ step?: number | undefined;
38
+ objectId?: string | undefined;
39
+ bind?: {
40
+ semantic: string;
41
+ } | undefined;
42
+ }, {
43
+ name: string;
44
+ type: "float" | "bool" | "int" | "vec2" | "vec3" | "vec4";
45
+ control: "slider" | "color" | "toggle" | "xy";
46
+ value: number | boolean | number[];
47
+ min?: number | undefined;
48
+ max?: number | undefined;
49
+ step?: number | undefined;
50
+ objectId?: string | undefined;
51
+ bind?: {
52
+ semantic: string;
53
+ } | undefined;
54
+ }>, "many">>;
55
+ objects: z.ZodOptional<z.ZodArray<z.ZodObject<{
56
+ id: z.ZodString;
57
+ label: z.ZodString;
58
+ }, "strip", z.ZodTypeAny, {
59
+ id: string;
60
+ label: string;
61
+ }, {
62
+ id: string;
63
+ label: string;
64
+ }>, "many">>;
65
+ passes: z.ZodOptional<z.ZodNumber>;
66
+ }, "strip", z.ZodTypeAny, {
67
+ name: string;
68
+ fragmentSource: string;
69
+ uniforms?: {
70
+ name: string;
71
+ type: "float" | "bool" | "int" | "vec2" | "vec3" | "vec4";
72
+ control: "slider" | "color" | "toggle" | "xy";
73
+ value: number | boolean | number[];
74
+ min?: number | undefined;
75
+ max?: number | undefined;
76
+ step?: number | undefined;
77
+ objectId?: string | undefined;
78
+ bind?: {
79
+ semantic: string;
80
+ } | undefined;
81
+ }[] | undefined;
82
+ objects?: {
83
+ id: string;
84
+ label: string;
85
+ }[] | undefined;
86
+ vertexSource?: string | undefined;
87
+ passes?: number | undefined;
88
+ }, {
89
+ name: string;
90
+ fragmentSource: string;
91
+ uniforms?: {
92
+ name: string;
93
+ type: "float" | "bool" | "int" | "vec2" | "vec3" | "vec4";
94
+ control: "slider" | "color" | "toggle" | "xy";
95
+ value: number | boolean | number[];
96
+ min?: number | undefined;
97
+ max?: number | undefined;
98
+ step?: number | undefined;
99
+ objectId?: string | undefined;
100
+ bind?: {
101
+ semantic: string;
102
+ } | undefined;
103
+ }[] | undefined;
104
+ objects?: {
105
+ id: string;
106
+ label: string;
107
+ }[] | undefined;
108
+ vertexSource?: string | undefined;
109
+ passes?: number | undefined;
110
+ }>;
111
+ export declare function handler(params: z.infer<typeof inputSchema>): Promise<{
112
+ content: Array<{
113
+ type: "text";
114
+ text: string;
115
+ }>;
116
+ }>;
117
+ //# sourceMappingURL=create-shader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-shader.d.ts","sourceRoot":"","sources":["../../src/tools/create-shader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,IAAI,kBAAkB,CAAC;AAEpC,eAAO,MAAM,WAAW,QAgCuD,CAAC;AAoChF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BtB,CAAC;AAiBH,wBAAsB,OAAO,CAC3B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,GAClC,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAuC7D"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * MCP tool: create_shader
3
+ *
4
+ * Creates a GLSL shader in the scene-builder with uniforms that the
5
+ * choreographer can tween at runtime.
6
+ */
7
+ import { z } from "zod";
8
+ import { addShader } from "../state/mutations.js";
9
+ export const name = "create_shader";
10
+ export const description = "Create a GLSL shader — a visual layer that renders custom fragment/vertex shaders on the sajou scene. " +
11
+ "Shaders are the most expressive visual primitive: they run per-pixel GPU code every frame.\n\n" +
12
+ "**Uniforms** are the knobs the choreographer can tween. Declare them in the GLSL source and in the " +
13
+ "`uniforms` array so the UI and choreographer know about them. Each uniform has a control type " +
14
+ "(slider, color, toggle, xy) and value range.\n\n" +
15
+ "**@object grouping**: Use the `objects` array to declare virtual objects (e.g. 'sphere', 'camera'). " +
16
+ "Then set `objectId` on uniforms to group them under that object in the UI. This is purely organizational.\n\n" +
17
+ "**@bind semantic**: Set `bind: { semantic: 'intensity' }` on a uniform to connect it to choreographer signals. " +
18
+ "The choreographer can then tween that uniform in response to agent events.\n\n" +
19
+ "**Multi-pass**: Set `passes: 2` (or more) for ping-pong feedback effects (e.g. reaction-diffusion, fluid sim). " +
20
+ "The previous frame is available as `iChannel0`.\n\n" +
21
+ "**Auto-injected uniforms** (do NOT declare these — they are always available):\n" +
22
+ "- `iTime` (float) — elapsed time in seconds\n" +
23
+ "- `iTimeDelta` (float) — time since last frame\n" +
24
+ "- `iResolution` (vec3) — canvas width, height, pixel ratio\n" +
25
+ "- `iMouse` (vec4) — mouse position\n" +
26
+ "- `iFrame` (int) — frame counter\n" +
27
+ "- `iChannel0` (sampler2D) — previous frame (multi-pass only)\n\n" +
28
+ "**Minimal example** — animated gradient:\n" +
29
+ "```glsl\n" +
30
+ "#version 300 es\n" +
31
+ "precision highp float;\n" +
32
+ "in vec2 vUv;\n" +
33
+ "out vec4 fragColor;\n" +
34
+ "uniform float uSpeed; // @ui: slider\n" +
35
+ "void main() {\n" +
36
+ " vec3 col = 0.5 + 0.5 * cos(iTime * uSpeed + vUv.xyx + vec3(0,2,4));\n" +
37
+ " fragColor = vec4(col, 1.0);\n" +
38
+ "}\n" +
39
+ "```\n\n" +
40
+ "After creating a shader, use `set_uniform` to tweak parameters in real-time, " +
41
+ "or wire it to the choreographer via `create_wire` (choreographer → shader).";
42
+ const uniformSchema = z.object({
43
+ name: z
44
+ .string()
45
+ .describe("Uniform name as declared in GLSL (e.g. 'uSpeed', 'uColor')."),
46
+ type: z
47
+ .enum(["float", "int", "bool", "vec2", "vec3", "vec4"])
48
+ .describe("GLSL type of the uniform."),
49
+ control: z
50
+ .enum(["slider", "color", "toggle", "xy"])
51
+ .describe("UI control widget. 'slider' for numeric, 'color' for vec3 RGB, " +
52
+ "'toggle' for bool, 'xy' for vec2 position."),
53
+ value: z
54
+ .union([z.number(), z.boolean(), z.array(z.number())])
55
+ .describe("Initial value. number for float/int, boolean for bool, number[] for vecN."),
56
+ min: z.number().optional().describe("Minimum value for slider controls. Default: 0."),
57
+ max: z.number().optional().describe("Maximum value for slider controls. Default: 1."),
58
+ step: z.number().optional().describe("Step increment for slider controls. Default: 0.01."),
59
+ objectId: z
60
+ .string()
61
+ .optional()
62
+ .describe("Virtual object ID this uniform belongs to (matches an entry in the objects array)."),
63
+ bind: z
64
+ .object({ semantic: z.string().describe("Semantic role: 'intensity', 'position', 'scale', 'rotation', etc.") })
65
+ .optional()
66
+ .describe("Choreographer binding hint — connects this uniform to a signal semantic."),
67
+ });
68
+ const objectSchema = z.object({
69
+ id: z.string().describe("Object identifier (e.g. 'sphere', 'camera')."),
70
+ label: z.string().describe("Display label in the UI panel."),
71
+ });
72
+ export const inputSchema = z.object({
73
+ name: z
74
+ .string()
75
+ .describe("Display name for the shader (e.g. 'Plasma Background', 'Agent Glow')."),
76
+ fragmentSource: z
77
+ .string()
78
+ .describe("GLSL fragment shader source code (ES 3.0). Must include #version 300 es, " +
79
+ "precision qualifier, and output to fragColor. Auto-injected uniforms (iTime, etc.) " +
80
+ "are available without declaring them."),
81
+ vertexSource: z
82
+ .string()
83
+ .optional()
84
+ .describe("GLSL vertex shader source. If omitted, a default passthrough vertex shader is used " +
85
+ "that passes UVs to the fragment shader via vUv."),
86
+ uniforms: z
87
+ .array(uniformSchema)
88
+ .optional()
89
+ .describe("User-defined uniforms exposed in the editor and available to the choreographer."),
90
+ objects: z
91
+ .array(objectSchema)
92
+ .optional()
93
+ .describe("Virtual objects for grouping related uniforms in the UI."),
94
+ passes: z
95
+ .number()
96
+ .optional()
97
+ .describe("Number of render passes. 1 = single-pass (default), 2+ = ping-pong feedback."),
98
+ });
99
+ /** Default passthrough vertex shader. */
100
+ const DEFAULT_VERTEX = `#version 300 es
101
+ precision highp float;
102
+
103
+ in vec3 position;
104
+ in vec2 uv;
105
+
106
+ out vec2 vUv;
107
+
108
+ void main() {
109
+ vUv = uv;
110
+ gl_Position = vec4(position, 1.0);
111
+ }
112
+ `;
113
+ export async function handler(params) {
114
+ const shaderId = crypto.randomUUID();
115
+ const uniformsPayload = (params.uniforms ?? []).map((u) => ({
116
+ name: u.name,
117
+ type: u.type,
118
+ control: u.control,
119
+ value: u.value,
120
+ defaultValue: u.value,
121
+ min: u.min ?? 0,
122
+ max: u.max ?? 1,
123
+ step: u.step ?? 0.01,
124
+ objectId: u.objectId,
125
+ bind: u.bind,
126
+ }));
127
+ addShader({
128
+ id: shaderId,
129
+ name: params.name,
130
+ fragmentSource: params.fragmentSource,
131
+ vertexSource: params.vertexSource ?? DEFAULT_VERTEX,
132
+ uniforms: uniformsPayload,
133
+ objects: params.objects ?? [],
134
+ passes: params.passes ?? 1,
135
+ });
136
+ return {
137
+ content: [
138
+ {
139
+ type: "text",
140
+ text: JSON.stringify({
141
+ ok: true,
142
+ shaderId,
143
+ hint: `Shader '${params.name}' created with ID ${shaderId}. ` +
144
+ `Use set_uniform to tweak parameters, or create_wire to connect it to the choreographer.`,
145
+ }),
146
+ },
147
+ ],
148
+ };
149
+ }
150
+ //# sourceMappingURL=create-shader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-shader.js","sourceRoot":"","sources":["../../src/tools/create-shader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,MAAM,CAAC,MAAM,IAAI,GAAG,eAAe,CAAC;AAEpC,MAAM,CAAC,MAAM,WAAW,GACtB,wGAAwG;IACxG,gGAAgG;IAChG,qGAAqG;IACrG,gGAAgG;IAChG,kDAAkD;IAClD,sGAAsG;IACtG,+GAA+G;IAC/G,iHAAiH;IACjH,gFAAgF;IAChF,iHAAiH;IACjH,qDAAqD;IACrD,kFAAkF;IAClF,+CAA+C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 /**
2
+ * MCP tool: create_sketch
3
+ *
4
+ * Creates a p5.js or Three.js sketch in the scene-builder.
5
+ */
6
+ import { z } from "zod";
7
+ export declare const name = "create_sketch";
8
+ export declare const description: string;
9
+ export declare const inputSchema: z.ZodObject<{
10
+ name: z.ZodString;
11
+ code: z.ZodString;
12
+ mode: z.ZodOptional<z.ZodEnum<["p5", "threejs"]>>;
13
+ params: z.ZodOptional<z.ZodArray<z.ZodObject<{
14
+ name: z.ZodString;
15
+ type: z.ZodOptional<z.ZodEnum<["float", "int", "bool", "vec2", "vec3", "vec4"]>>;
16
+ control: z.ZodOptional<z.ZodEnum<["slider", "color", "toggle", "xy"]>>;
17
+ value: z.ZodUnion<[z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodNumber, "many">]>;
18
+ min: z.ZodOptional<z.ZodNumber>;
19
+ max: z.ZodOptional<z.ZodNumber>;
20
+ step: z.ZodOptional<z.ZodNumber>;
21
+ bind: z.ZodOptional<z.ZodObject<{
22
+ semantic: z.ZodString;
23
+ }, "strip", z.ZodTypeAny, {
24
+ semantic: string;
25
+ }, {
26
+ semantic: string;
27
+ }>>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ name: string;
30
+ value: number | boolean | number[];
31
+ type?: "float" | "bool" | "int" | "vec2" | "vec3" | "vec4" | undefined;
32
+ control?: "slider" | "color" | "toggle" | "xy" | undefined;
33
+ min?: number | undefined;
34
+ max?: number | undefined;
35
+ step?: number | undefined;
36
+ bind?: {
37
+ semantic: string;
38
+ } | undefined;
39
+ }, {
40
+ name: string;
41
+ value: number | boolean | number[];
42
+ type?: "float" | "bool" | "int" | "vec2" | "vec3" | "vec4" | undefined;
43
+ control?: "slider" | "color" | "toggle" | "xy" | undefined;
44
+ min?: number | undefined;
45
+ max?: number | undefined;
46
+ step?: number | undefined;
47
+ bind?: {
48
+ semantic: string;
49
+ } | undefined;
50
+ }>, "many">>;
51
+ width: z.ZodOptional<z.ZodNumber>;
52
+ height: z.ZodOptional<z.ZodNumber>;
53
+ }, "strip", z.ZodTypeAny, {
54
+ name: string;
55
+ code: string;
56
+ params?: {
57
+ name: string;
58
+ value: number | boolean | number[];
59
+ type?: "float" | "bool" | "int" | "vec2" | "vec3" | "vec4" | undefined;
60
+ control?: "slider" | "color" | "toggle" | "xy" | undefined;
61
+ min?: number | undefined;
62
+ max?: number | undefined;
63
+ step?: number | undefined;
64
+ bind?: {
65
+ semantic: string;
66
+ } | undefined;
67
+ }[] | undefined;
68
+ mode?: "p5" | "threejs" | undefined;
69
+ width?: number | undefined;
70
+ height?: number | undefined;
71
+ }, {
72
+ name: string;
73
+ code: string;
74
+ params?: {
75
+ name: string;
76
+ value: number | boolean | number[];
77
+ type?: "float" | "bool" | "int" | "vec2" | "vec3" | "vec4" | undefined;
78
+ control?: "slider" | "color" | "toggle" | "xy" | undefined;
79
+ min?: number | undefined;
80
+ max?: number | undefined;
81
+ step?: number | undefined;
82
+ bind?: {
83
+ semantic: string;
84
+ } | undefined;
85
+ }[] | undefined;
86
+ mode?: "p5" | "threejs" | undefined;
87
+ width?: number | undefined;
88
+ height?: number | undefined;
89
+ }>;
90
+ export declare function handler(params: z.infer<typeof inputSchema>): Promise<{
91
+ content: Array<{
92
+ type: "text";
93
+ text: string;
94
+ }>;
95
+ }>;
96
+ //# sourceMappingURL=create-sketch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-sketch.d.ts","sourceRoot":"","sources":["../../src/tools/create-sketch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,IAAI,kBAAkB,CAAC;AAEpC,eAAO,MAAM,WAAW,QAoC8B,CAAC;AA0BvD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BtB,CAAC;AAEH,wBAAsB,OAAO,CAC3B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,GAClC,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAsC7D"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * MCP tool: create_sketch
3
+ *
4
+ * Creates a p5.js or Three.js sketch in the scene-builder.
5
+ */
6
+ import { z } from "zod";
7
+ import { addP5Sketch } from "../state/mutations.js";
8
+ export const name = "create_sketch";
9
+ export const description = "Create a live-coded sketch — a visual layer that runs JavaScript every frame inside the sajou scene. " +
10
+ "Sketches support two runtime modes:\n\n" +
11
+ "**p5.js mode** (`mode: \"p5\"`, default) — instance-mode p5 sketch.\n" +
12
+ "- The sketch receives a `p` object (p5 instance) with `p.sajou.*` for parameters.\n" +
13
+ "- Auto-injected params: `_width`, `_height`, `_time`, `_mouse`.\n" +
14
+ "- Example:\n" +
15
+ "```js\n" +
16
+ "// @param: speed, slider, 1.0, 0.1, 5.0\n" +
17
+ "p.setup = () => p.createCanvas(p.sajou._width, p.sajou._height);\n" +
18
+ "p.draw = () => {\n" +
19
+ " p.background(20);\n" +
20
+ " p.circle(p.width/2, p.height/2, 100 * Math.sin(p.sajou._time * p.sajou.speed));\n" +
21
+ "};\n" +
22
+ "```\n\n" +
23
+ "**Three.js mode** (`mode: \"threejs\"`) — `setup(ctx)` / `draw(ctx, state)` API.\n" +
24
+ "- `ctx.scene`, `ctx.camera`, `ctx.renderer`, `ctx.THREE` — full Three.js access.\n" +
25
+ "- `ctx.sajou.*` for parameters. Auto-injected: `_width`, `_height`, `_time`, `_deltaTime`, `_mouse`.\n" +
26
+ "- Example:\n" +
27
+ "```js\n" +
28
+ "// @param: radius, slider, 1.0, 0.1, 5.0\n" +
29
+ "function setup(ctx) {\n" +
30
+ " const geo = new ctx.THREE.BoxGeometry(1, 1, 1);\n" +
31
+ " const mat = new ctx.THREE.MeshNormalMaterial();\n" +
32
+ " ctx.mesh = new ctx.THREE.Mesh(geo, mat);\n" +
33
+ " ctx.scene.add(ctx.mesh);\n" +
34
+ "}\n" +
35
+ "function draw(ctx, state) {\n" +
36
+ " ctx.mesh.rotation.y = ctx.sajou._time;\n" +
37
+ " ctx.mesh.scale.setScalar(ctx.sajou.radius);\n" +
38
+ "}\n" +
39
+ "```\n\n" +
40
+ "**Annotations** (parsed from code comments):\n" +
41
+ "- `// @param: name, control, value, min?, max?, step?` — declare a tweakable parameter.\n" +
42
+ "- `// @bind: name, semantic` — connect a parameter to choreographer signals.\n\n" +
43
+ "After creating a sketch, use `set_sketch_param` to tweak parameters in real-time, " +
44
+ "or wire it to the choreographer via `create_wire`.";
45
+ const paramSchema = z.object({
46
+ name: z
47
+ .string()
48
+ .describe("Parameter name (e.g. 'speed', 'radius')."),
49
+ type: z
50
+ .enum(["float", "int", "bool", "vec2", "vec3", "vec4"])
51
+ .optional()
52
+ .describe("Parameter type. Default: 'float'."),
53
+ control: z
54
+ .enum(["slider", "color", "toggle", "xy"])
55
+ .optional()
56
+ .describe("UI control widget. Default: 'slider'."),
57
+ value: z
58
+ .union([z.number(), z.boolean(), z.array(z.number())])
59
+ .describe("Initial value."),
60
+ min: z.number().optional().describe("Minimum for slider. Default: 0."),
61
+ max: z.number().optional().describe("Maximum for slider. Default: 1."),
62
+ step: z.number().optional().describe("Step for slider. Default: 0.01."),
63
+ bind: z
64
+ .object({ semantic: z.string().describe("Semantic role: 'intensity', 'position', etc.") })
65
+ .optional()
66
+ .describe("Choreographer binding hint."),
67
+ });
68
+ export const inputSchema = z.object({
69
+ name: z
70
+ .string()
71
+ .describe("Display name for the sketch (e.g. 'Particle Field', 'Rotating Cube')."),
72
+ code: z
73
+ .string()
74
+ .describe("JavaScript source code for the sketch. " +
75
+ "In p5 mode: instance-mode sketch using `p` object. " +
76
+ "In Three.js mode: must export `setup(ctx)` and/or `draw(ctx, state)` functions."),
77
+ mode: z
78
+ .enum(["p5", "threejs"])
79
+ .optional()
80
+ .describe("Runtime mode. 'p5' for p5.js instance mode (default), 'threejs' for Three.js setup/draw API."),
81
+ params: z
82
+ .array(paramSchema)
83
+ .optional()
84
+ .describe("Pre-declared parameters exposed in the editor and available to the choreographer."),
85
+ width: z
86
+ .number()
87
+ .optional()
88
+ .describe("Canvas width in pixels. 0 = fit container (default)."),
89
+ height: z
90
+ .number()
91
+ .optional()
92
+ .describe("Canvas height in pixels. 0 = fit container (default)."),
93
+ });
94
+ export async function handler(params) {
95
+ const sketchId = crypto.randomUUID();
96
+ const paramsPayload = (params.params ?? []).map((p) => ({
97
+ name: p.name,
98
+ type: p.type ?? "float",
99
+ control: p.control ?? "slider",
100
+ value: p.value,
101
+ defaultValue: p.value,
102
+ min: p.min ?? 0,
103
+ max: p.max ?? 1,
104
+ step: p.step ?? 0.01,
105
+ bind: p.bind,
106
+ }));
107
+ addP5Sketch({
108
+ id: sketchId,
109
+ name: params.name,
110
+ source: params.code,
111
+ mode: params.mode ?? "p5",
112
+ params: paramsPayload,
113
+ width: params.width ?? 0,
114
+ height: params.height ?? 0,
115
+ });
116
+ return {
117
+ content: [
118
+ {
119
+ type: "text",
120
+ text: JSON.stringify({
121
+ ok: true,
122
+ sketchId,
123
+ hint: `Sketch '${params.name}' created with ID ${sketchId}. ` +
124
+ `Use set_sketch_param to tweak parameters, or create_wire to connect it to the choreographer.`,
125
+ }),
126
+ },
127
+ ],
128
+ };
129
+ }
130
+ //# sourceMappingURL=create-sketch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-sketch.js","sourceRoot":"","sources":["../../src/tools/create-sketch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,CAAC,MAAM,IAAI,GAAG,eAAe,CAAC;AAEpC,MAAM,CAAC,MAAM,WAAW,G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MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACtD,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,OAAO;QACvB,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,QAAQ;QAC9B,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,YAAY,EAAE,CAAC,CAAC,KAAK;QACrB,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;QACf,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;QACf,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI;QACpB,IAAI,EAAE,CAAC,CAAC,IAAI;KACb,CAAC,CAAC,CAAC;IAEJ,WAAW,CAAC;QACV,EAAE,EAAE,QAAQ;QACZ,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,IAAI;QACnB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI;QACzB,MAAM,EAAE,aAAa;QACrB,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;QACxB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC;KAC3B,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,EAAE,EAAE,IAAI;oBACR,QAAQ;oBACR,IAAI,EAAE,WAAW,MAAM,CAAC,IAAI,qBAAqB,QAAQ,IAAI;wBAC3D,8FAA8F;iBACjG,CAAC;aACH;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * MCP tool: create_wire
3
+ *
4
+ * Creates a wire connection between two zones in the sajou patch bay.
5
+ * Wires define the data flow: signal sources → signal types → choreographies → theme.
6
+ */
7
+ import { z } from "zod";
8
+ export declare const name = "create_wire";
9
+ export declare const description: string;
10
+ export declare const inputSchema: z.ZodObject<{
11
+ fromZone: z.ZodEnum<["signal", "signal-type", "choreographer"]>;
12
+ fromId: z.ZodString;
13
+ toZone: z.ZodEnum<["signal-type", "choreographer", "theme", "shader"]>;
14
+ toId: z.ZodString;
15
+ }, "strip", z.ZodTypeAny, {
16
+ toZone: "shader" | "choreographer" | "signal-type" | "theme";
17
+ toId: string;
18
+ fromZone: "choreographer" | "signal" | "signal-type";
19
+ fromId: string;
20
+ }, {
21
+ toZone: "shader" | "choreographer" | "signal-type" | "theme";
22
+ toId: string;
23
+ fromZone: "choreographer" | "signal" | "signal-type";
24
+ fromId: string;
25
+ }>;
26
+ export declare function handler(params: z.infer<typeof inputSchema>): Promise<{
27
+ content: Array<{
28
+ type: "text";
29
+ text: string;
30
+ }>;
31
+ }>;
32
+ //# sourceMappingURL=create-wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-wire.d.ts","sourceRoot":"","sources":["../../src/tools/create-wire.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,IAAI,gBAAgB,CAAC;AAElC,eAAO,MAAM,WAAW,QAO4D,CAAC;AAErF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;EAmCtB,CAAC;AAEH,wBAAsB,OAAO,CAC3B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,GAClC,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAyC7D"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * MCP tool: create_wire
3
+ *
4
+ * Creates a wire connection between two zones in the sajou patch bay.
5
+ * Wires define the data flow: signal sources → signal types → choreographies → theme.
6
+ */
7
+ import { z } from "zod";
8
+ import { addWire } from "../state/mutations.js";
9
+ export const name = "create_wire";
10
+ export const description = "Create a wire connection in the sajou patch bay. " +
11
+ "Wires define data flow through 3 layers: " +
12
+ "(1) signal → signal-type: connects a signal source to a signal channel, " +
13
+ "(2) signal-type → choreographer: triggers a choreography when that signal type arrives, " +
14
+ "(3) choreographer → theme: sends choreography output to the theme renderer. " +
15
+ "Example flow: wire 'local:claude-code' (signal source) → 'tool_call' (signal type) → choreography-id (choreographer). " +
16
+ "This means: when Claude Code emits a tool_call signal, trigger the choreography.";
17
+ export const inputSchema = z.object({
18
+ fromZone: z
19
+ .enum(["signal", "signal-type", "choreographer"])
20
+ .describe("Source zone. " +
21
+ "'signal' — a signal source (e.g. 'local:claude-code', a WebSocket source ID). " +
22
+ "'signal-type' — a signal type channel (e.g. 'tool_call', 'agent_state_change'). " +
23
+ "'choreographer' — a choreography node (use its ID)."),
24
+ fromId: z
25
+ .string()
26
+ .describe("ID of the source endpoint. " +
27
+ "For 'signal' zone: the signal source ID (e.g. 'local:claude-code'). " +
28
+ "For 'signal-type' zone: the signal type name (e.g. 'tool_call'). " +
29
+ "For 'choreographer' zone: the choreography ID."),
30
+ toZone: z
31
+ .enum(["signal-type", "choreographer", "theme", "shader"])
32
+ .describe("Destination zone. " +
33
+ "'signal-type' — route a source to a signal type channel. " +
34
+ "'choreographer' — trigger a choreography from a signal type. " +
35
+ "'theme' — send choreography output to the theme renderer. " +
36
+ "'shader' — connect to a shader uniform (format: '{shaderId}:{uniformName}')."),
37
+ toId: z
38
+ .string()
39
+ .describe("ID of the destination endpoint. " +
40
+ "For 'signal-type' zone: the signal type name. " +
41
+ "For 'choreographer' zone: the choreography ID. " +
42
+ "For 'theme' zone: the theme slot name. " +
43
+ "For 'shader' zone: '{shaderId}:{uniformName}'."),
44
+ });
45
+ export async function handler(params) {
46
+ // Validate zone flow direction
47
+ const validFlows = {
48
+ signal: ["signal-type"],
49
+ "signal-type": ["choreographer"],
50
+ choreographer: ["theme", "shader"],
51
+ };
52
+ const allowed = validFlows[params.fromZone];
53
+ if (!allowed?.includes(params.toZone)) {
54
+ return {
55
+ content: [
56
+ {
57
+ type: "text",
58
+ text: JSON.stringify({
59
+ ok: false,
60
+ error: `Invalid wire direction: ${params.fromZone} → ${params.toZone}. ` +
61
+ `Valid flows: signal → signal-type, signal-type → choreographer, choreographer → theme/shader.`,
62
+ }),
63
+ },
64
+ ],
65
+ };
66
+ }
67
+ addWire({
68
+ fromZone: params.fromZone,
69
+ fromId: params.fromId,
70
+ toZone: params.toZone,
71
+ toId: params.toId,
72
+ });
73
+ return {
74
+ content: [
75
+ {
76
+ type: "text",
77
+ text: JSON.stringify({
78
+ ok: true,
79
+ }),
80
+ },
81
+ ],
82
+ };
83
+ }
84
+ //# sourceMappingURL=create-wire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-wire.js","sourceRoot":"","sources":["../../src/tools/create-wire.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC;AAElC,MAAM,CAAC,MAAM,WAAW,GACtB,mDAAmD;IACnD,2CAA2C;IAC3C,0EAA0E;IAC1E,0FAA0F;IAC1F,8EAA8E;IAC9E,wHAAwH;IACxH,kFAAkF,CAAC;AAErF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,QAAQ,EAAE,CAAC;SACR,IAAI,CAAC,CAAC,QAAQ,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;SAChD,QAAQ,CACP,eAAe;QACf,gFAAgF;QAChF,kFAAkF;QAClF,qDAAqD,CACtD;IACH,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,QAAQ,CACP,6BAA6B;QAC7B,sEAAsE;QACtE,mEAAmE;QACnE,gDAAgD,CACjD;IACH,MAAM,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