@decocms/bindings 1.1.1 → 1.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/bindings",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "check": "tsc --noEmit",
@@ -13,6 +13,10 @@
13
13
  "zod": "^4.0.0",
14
14
  "zod-from-json-schema": "^0.5.2"
15
15
  },
16
+ "devDependencies": {
17
+ "hono": "^4.7.10",
18
+ "kysely": "^0.27.5"
19
+ },
16
20
  "exports": {
17
21
  ".": "./src/index.ts",
18
22
  "./collections": "./src/well-known/collections.ts",
@@ -24,7 +28,8 @@
24
28
  "./prompt": "./src/well-known/prompt.ts",
25
29
  "./workflow": "./src/well-known/workflow.ts",
26
30
  "./plugins": "./src/core/plugins.ts",
27
- "./plugin-router": "./src/core/plugin-router.tsx"
31
+ "./plugin-router": "./src/core/plugin-router.tsx",
32
+ "./server-plugin": "./src/core/server-plugin.ts"
28
33
  },
29
34
  "engines": {
30
35
  "node": ">=24.0.0"
@@ -43,14 +43,21 @@ export interface PluginRenderHeaderProps {
43
43
  onConnectionChange: (connectionId: string) => void;
44
44
  }
45
45
 
46
- export interface Plugin<TBinding extends Binder> {
46
+ /**
47
+ * Client Plugin interface.
48
+ *
49
+ * Defines the contract for client-side plugins that extend the Mesh UI.
50
+ * Client plugins are separate from server plugins to avoid bundling
51
+ * server code into the client bundle.
52
+ */
53
+ export interface ClientPlugin<TBinding extends Binder> {
47
54
  id: string;
48
55
  /**
49
56
  * Short description of the plugin shown in the settings UI.
50
57
  */
51
58
  description?: string;
52
59
  binding: TBinding;
53
- setup: PluginSetup;
60
+ setup?: PluginSetup;
54
61
  /**
55
62
  * Optional custom layout component for this plugin.
56
63
  * If not provided, a default layout with connection selector will be used.
@@ -68,7 +75,16 @@ export interface Plugin<TBinding extends Binder> {
68
75
  renderEmptyState?: () => ReactNode;
69
76
  }
70
77
 
71
- export type AnyPlugin = Plugin<any>;
78
+ /**
79
+ * @deprecated Use ClientPlugin instead
80
+ */
81
+ export interface Plugin<TBinding extends Binder>
82
+ extends ClientPlugin<TBinding> {
83
+ setup: PluginSetup; // Required for backwards compatibility
84
+ }
85
+
86
+ export type AnyClientPlugin = ClientPlugin<Binder>;
87
+ export type AnyPlugin = Plugin<Binder>;
72
88
 
73
89
  // Re-export plugin router utilities
74
90
  export {
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Server Plugin Interface
3
+ *
4
+ * Defines the contract for server-side plugins that can extend Mesh with:
5
+ * - MCP tools
6
+ * - API routes (authenticated and public)
7
+ * - Database migrations
8
+ * - Storage factories
9
+ *
10
+ * Server plugins are separate from client plugins to avoid bundling
11
+ * server code into the client bundle.
12
+ */
13
+
14
+ import type { Hono } from "hono";
15
+ import type { Kysely } from "kysely";
16
+
17
+ /**
18
+ * Tool definition compatible with MCP tools.
19
+ * This is a simplified type - the actual implementation uses the full ToolDefinition from mesh.
20
+ */
21
+ export interface ServerPluginToolDefinition {
22
+ name: string;
23
+ description?: string;
24
+ inputSchema: unknown;
25
+ outputSchema?: unknown;
26
+ handler: (input: unknown, ctx: unknown) => Promise<unknown>;
27
+ }
28
+
29
+ /**
30
+ * Database migration definition for plugins.
31
+ */
32
+ export interface ServerPluginMigration {
33
+ /** Unique name for ordering (e.g., "001-initial-schema") */
34
+ name: string;
35
+ /** Apply the migration */
36
+ up: (db: Kysely<unknown>) => Promise<void>;
37
+ /** Revert the migration */
38
+ down: (db: Kysely<unknown>) => Promise<void>;
39
+ }
40
+
41
+ /**
42
+ * Context provided to server plugins for route registration and storage creation.
43
+ */
44
+ export interface ServerPluginContext {
45
+ /** Database instance */
46
+ db: Kysely<unknown>;
47
+ /** Credential vault for encrypting sensitive data */
48
+ vault: {
49
+ encrypt: (value: string) => Promise<string>;
50
+ decrypt: (value: string) => Promise<string>;
51
+ };
52
+ }
53
+
54
+ /**
55
+ * Server Plugin interface.
56
+ *
57
+ * Plugins export this interface from their server entry point.
58
+ * Tools are registered at startup but gated by org settings at runtime.
59
+ */
60
+ export interface ServerPlugin {
61
+ /** Unique plugin identifier (e.g., "user-sandbox") */
62
+ id: string;
63
+
64
+ /** Short description shown in settings UI */
65
+ description?: string;
66
+
67
+ /**
68
+ * MCP tools this plugin provides.
69
+ * Tools are wrapped with org-enabled gating at registration time.
70
+ */
71
+ tools?: ServerPluginToolDefinition[];
72
+
73
+ /**
74
+ * Authenticated API routes.
75
+ * Mounted at /api/plugins/:pluginId/*
76
+ * Requires Mesh authentication.
77
+ */
78
+ routes?: (app: Hono, ctx: ServerPluginContext) => void;
79
+
80
+ /**
81
+ * Public API routes (no authentication required).
82
+ * Mounted at the root level.
83
+ * Use for endpoints that external users access (e.g., connect flow).
84
+ */
85
+ publicRoutes?: (app: Hono, ctx: ServerPluginContext) => void;
86
+
87
+ /**
88
+ * Database migrations for this plugin.
89
+ * Run alongside core migrations in name order.
90
+ */
91
+ migrations?: ServerPluginMigration[];
92
+
93
+ /**
94
+ * Factory to create plugin-specific storage adapters.
95
+ * Called during context initialization.
96
+ */
97
+ createStorage?: (ctx: ServerPluginContext) => unknown;
98
+ }
99
+
100
+ /**
101
+ * Type helper for any server plugin
102
+ */
103
+ export type AnyServerPlugin = ServerPlugin;
@@ -137,6 +137,16 @@ export const StepSchema = z.object({
137
137
  "Optional JSON Schema describing the expected output of the step.",
138
138
  ),
139
139
  config: StepConfigSchema.optional().describe("Retry and timeout settings"),
140
+ forEach: z
141
+ .object({
142
+ ref: z.string().describe("@ ref to the step to iterate over"),
143
+ concurrency: z
144
+ .number()
145
+ .optional()
146
+ .default(1)
147
+ .describe("max parallel iterations. default is 1 (sequential)"),
148
+ })
149
+ .optional(),
140
150
  });
141
151
 
142
152
  export type Step = z.infer<typeof StepSchema>;
@@ -205,12 +215,21 @@ export const WorkflowExecutionSchema = BaseCollectionEntitySchema.extend({
205
215
  completed_steps: z
206
216
  .object({
207
217
  success: z
208
- .array(z.string())
218
+ .array(
219
+ z.object({
220
+ name: z.string(),
221
+ completed_at_epoch_ms: z.number(),
222
+ }),
223
+ )
209
224
  .describe("Names of the steps that were completed successfully"),
210
225
  error: z.array(z.string()).describe("Names of the steps that errored"),
211
226
  })
212
227
  .optional()
213
228
  .describe("Names of the steps that were completed and their status"),
229
+ running_steps: z
230
+ .array(z.string())
231
+ .optional()
232
+ .describe("Names of the steps that are currently running"),
214
233
  });
215
234
  export type WorkflowExecution = z.infer<typeof WorkflowExecutionSchema>;
216
235