@flowdrop/flowdrop 2.4.0 → 2.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 (57) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/chat/commandClassifier.d.ts +17 -0
  3. package/dist/chat/commandClassifier.js +29 -0
  4. package/dist/chat/index.d.ts +1 -1
  5. package/dist/chat/index.js +1 -1
  6. package/dist/components/App.svelte +8 -0
  7. package/dist/components/BindablePortListbox.svelte +426 -0
  8. package/dist/components/BindablePortListbox.svelte.d.ts +23 -0
  9. package/dist/components/WorkflowInterfaceEditor.svelte +142 -36
  10. package/dist/components/WorkflowInterfaceEditor.svelte.d.ts +8 -0
  11. package/dist/components/WorkflowInterfaceEntryCard.svelte +537 -294
  12. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +6 -3
  13. package/dist/components/WorkflowInterfaceEntryComposer.svelte +331 -0
  14. package/dist/components/WorkflowInterfaceEntryComposer.svelte.d.ts +19 -0
  15. package/dist/config/defaultPortConfig.js +27 -9
  16. package/dist/messages/context.d.ts +6 -0
  17. package/dist/messages/context.js +8 -0
  18. package/dist/messages/defaults.d.ts +45 -2
  19. package/dist/messages/defaults.js +36 -3
  20. package/dist/messages/index.d.ts +1 -1
  21. package/dist/messages/index.js +1 -1
  22. package/dist/openapi/v1/openapi.yaml +14 -1
  23. package/dist/schemas/v1/workflow.schema.json +9 -2
  24. package/dist/stores/instanceContainer.svelte.d.ts +26 -0
  25. package/dist/stores/instanceContainer.svelte.js +24 -0
  26. package/dist/stories/WebMCPFakeAgent.svelte +229 -0
  27. package/dist/stories/WebMCPFakeAgent.svelte.d.ts +10 -0
  28. package/dist/styles/base.css +4 -2
  29. package/dist/styles/tokens.css +20 -0
  30. package/dist/svelte-app.d.ts +20 -0
  31. package/dist/svelte-app.js +49 -1
  32. package/dist/types/index.d.ts +26 -1
  33. package/dist/utils/focus.d.ts +18 -0
  34. package/dist/utils/focus.js +24 -0
  35. package/dist/utils/whenWorkflowLoaded.svelte.d.ts +17 -0
  36. package/dist/utils/whenWorkflowLoaded.svelte.js +42 -0
  37. package/dist/utils/workflowInterface.d.ts +47 -3
  38. package/dist/utils/workflowInterface.js +84 -9
  39. package/dist/webmcp/WebMCP.stories.svelte +101 -0
  40. package/dist/webmcp/WebMCP.stories.svelte.d.ts +18 -0
  41. package/dist/webmcp/WebMCPConfirm.svelte +170 -0
  42. package/dist/webmcp/WebMCPConfirm.svelte.d.ts +11 -0
  43. package/dist/webmcp/descriptors.d.ts +59 -0
  44. package/dist/webmcp/descriptors.js +464 -0
  45. package/dist/webmcp/fake.d.ts +23 -0
  46. package/dist/webmcp/fake.js +42 -0
  47. package/dist/webmcp/gate.d.ts +40 -0
  48. package/dist/webmcp/gate.js +92 -0
  49. package/dist/webmcp/index.d.ts +34 -0
  50. package/dist/webmcp/index.js +31 -0
  51. package/dist/webmcp/register.d.ts +33 -0
  52. package/dist/webmcp/register.js +267 -0
  53. package/dist/webmcp/types.d.ts +166 -0
  54. package/dist/webmcp/types.js +23 -0
  55. package/dist/webmcp/validate.d.ts +32 -0
  56. package/dist/webmcp/validate.js +118 -0
  57. package/package.json +6 -1
@@ -0,0 +1,118 @@
1
+ /**
2
+ * WebMCP adapter — argument validation.
3
+ *
4
+ * A hand-written validator for exactly the JSON Schema subset the tool
5
+ * descriptors use. That subset is `ToolSchemaProperty` in `./types.ts`: the
6
+ * type is the contract, and this file must understand every keyword it
7
+ * declares — `VALIDATOR_KEYWORDS` lists them, and a test in
8
+ * `tests/unit/webmcp` walks every schema and fails when a schema uses a key
9
+ * this set lacks. Adding a keyword therefore means adding it in three places:
10
+ * the type, the check below, and the set. No dependency is taken for this;
11
+ * the schemas are small, hand-written, and never come from outside the
12
+ * library.
13
+ *
14
+ * The runtime is supposed to validate too. Chrome's behaviour there is not
15
+ * something to lean on yet, and validating here keeps behaviour identical
16
+ * across runtimes and against the fake used in tests.
17
+ *
18
+ * @module webmcp/validate
19
+ */
20
+ import { ToolArgumentError } from './types.js';
21
+ /**
22
+ * Every schema keyword the validator understands. `description` is listed
23
+ * because it is a keyword schemas use, even though it needs no check.
24
+ */
25
+ export const VALIDATOR_KEYWORDS = new Set([
26
+ 'type',
27
+ 'description',
28
+ 'enum',
29
+ 'properties',
30
+ 'required',
31
+ 'additionalProperties',
32
+ 'items',
33
+ 'anyOf',
34
+ 'minimum',
35
+ 'maximum'
36
+ ]);
37
+ function typeOf(value) {
38
+ if (value === null)
39
+ return 'null';
40
+ if (Array.isArray(value))
41
+ return 'array';
42
+ return typeof value;
43
+ }
44
+ function matchesType(value, type) {
45
+ switch (type) {
46
+ case 'string':
47
+ case 'boolean':
48
+ return typeof value === type;
49
+ case 'number':
50
+ return typeof value === 'number' && Number.isFinite(value);
51
+ case 'integer':
52
+ return typeof value === 'number' && Number.isInteger(value);
53
+ case 'object':
54
+ return typeOf(value) === 'object';
55
+ case 'array':
56
+ return Array.isArray(value);
57
+ }
58
+ }
59
+ function validateProperty(path, value, schema) {
60
+ if (schema.anyOf) {
61
+ if (!schema.anyOf.some((alt) => !alt.type || matchesType(value, alt.type))) {
62
+ throw new ToolArgumentError(`${path}: expected one of ${schema.anyOf.map((a) => a.type).join(', ')}, got ${typeOf(value)}`);
63
+ }
64
+ return;
65
+ }
66
+ if (schema.type && !matchesType(value, schema.type)) {
67
+ throw new ToolArgumentError(`${path}: expected ${schema.type}, got ${typeOf(value)}`);
68
+ }
69
+ if (schema.enum && !schema.enum.includes(value)) {
70
+ throw new ToolArgumentError(`${path}: expected one of ${schema.enum.map((v) => JSON.stringify(v)).join(', ')}, got ${JSON.stringify(value)}`);
71
+ }
72
+ if (schema.minimum !== undefined && value < schema.minimum) {
73
+ throw new ToolArgumentError(`${path}: must be >= ${schema.minimum}`);
74
+ }
75
+ if (schema.maximum !== undefined && value > schema.maximum) {
76
+ throw new ToolArgumentError(`${path}: must be <= ${schema.maximum}`);
77
+ }
78
+ if (schema.type === 'object' && schema.properties) {
79
+ validateObject(path, value, schema);
80
+ }
81
+ if (schema.type === 'array' && schema.items) {
82
+ value.forEach((item, i) => validateProperty(`${path}[${i}]`, item, schema.items));
83
+ }
84
+ }
85
+ function validateObject(path, value, schema) {
86
+ const props = schema.properties ?? {};
87
+ for (const key of schema.required ?? []) {
88
+ if (value[key] === undefined) {
89
+ throw new ToolArgumentError(`${path ? path + '.' : ''}${key} is required`);
90
+ }
91
+ }
92
+ for (const [key, v] of Object.entries(value)) {
93
+ if (v === undefined)
94
+ continue;
95
+ const prop = props[key];
96
+ if (!prop) {
97
+ if (schema.additionalProperties === false) {
98
+ throw new ToolArgumentError(`${path ? path + '.' : ''}${key}: unknown property`);
99
+ }
100
+ continue;
101
+ }
102
+ validateProperty(`${path ? path + '.' : ''}${key}`, v, prop);
103
+ }
104
+ }
105
+ /**
106
+ * Validate raw tool input against a tool's schema and return it typed as an
107
+ * argument object.
108
+ *
109
+ * @throws ToolArgumentError
110
+ */
111
+ export function validateToolArgs(schema, input) {
112
+ const args = input === undefined || input === null ? {} : input;
113
+ if (typeOf(args) !== 'object') {
114
+ throw new ToolArgumentError(`arguments must be an object, got ${typeOf(args)}`);
115
+ }
116
+ validateObject('', args, schema);
117
+ return args;
118
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A drop-in visual workflow editor for any web application. You own the backend. You own the data. You own the orchestration.",
4
4
  "license": "MIT",
5
5
  "private": false,
6
- "version": "2.4.0",
6
+ "version": "2.6.0",
7
7
  "author": "Shibin Das (D34dMan)",
8
8
  "bugs": {
9
9
  "url": "https://github.com/flowdrop-io/flowdrop/issues"
@@ -123,6 +123,11 @@
123
123
  "svelte": "./dist/chat/index.js",
124
124
  "default": "./dist/chat/index.js"
125
125
  },
126
+ "./webmcp": {
127
+ "types": "./dist/webmcp/index.d.ts",
128
+ "svelte": "./dist/webmcp/index.js",
129
+ "default": "./dist/webmcp/index.js"
130
+ },
126
131
  "./schema/v1": {
127
132
  "default": "./dist/schemas/v1/workflow.schema.json"
128
133
  },