@synapsor/runner 0.1.0-alpha.9 → 0.1.1

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 (85) hide show
  1. package/CHANGELOG.md +189 -0
  2. package/README.md +949 -164
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/runner.mjs +2982 -238
  6. package/docs/README.md +90 -15
  7. package/docs/app-owned-executors.md +38 -0
  8. package/docs/capability-authoring.md +265 -0
  9. package/docs/cloud-mode.md +24 -0
  10. package/docs/current-scope.md +29 -0
  11. package/docs/dependency-license-inventory.md +35 -0
  12. package/docs/doctor.md +98 -0
  13. package/docs/getting-started-own-database.md +131 -46
  14. package/docs/handler-helper.md +228 -0
  15. package/docs/http-mcp.md +85 -17
  16. package/docs/licensing.md +36 -0
  17. package/docs/local-mode.md +44 -25
  18. package/docs/mcp-audit.md +8 -8
  19. package/docs/mcp-client-setup.md +59 -21
  20. package/docs/openai-agents-sdk.md +57 -0
  21. package/docs/recipes.md +6 -6
  22. package/docs/release-notes.md +348 -0
  23. package/docs/release-policy.md +125 -0
  24. package/docs/result-envelope-v2.md +151 -0
  25. package/docs/rfcs/001-result-envelope-v2.md +143 -0
  26. package/docs/rfcs/002-app-owned-handler-helper.md +161 -0
  27. package/docs/rfcs/003-integrator-feedback-teardown.md +97 -0
  28. package/docs/store-lifecycle.md +83 -0
  29. package/docs/troubleshooting-first-run.md +6 -6
  30. package/docs/use-your-own-database.md +18 -0
  31. package/docs/writeback-executors.md +92 -1
  32. package/examples/app-owned-writeback/README.md +128 -0
  33. package/examples/app-owned-writeback/business-actions.md +221 -0
  34. package/examples/app-owned-writeback/command-handler.mjs +55 -0
  35. package/examples/app-owned-writeback/node-fastify-handler.mjs +64 -0
  36. package/examples/app-owned-writeback/python-fastapi-handler.py +66 -0
  37. package/examples/claude-desktop-postgres/Makefile +6 -0
  38. package/examples/claude-desktop-postgres/README.md +40 -0
  39. package/examples/cursor-postgres/Makefile +6 -0
  40. package/examples/cursor-postgres/README.md +30 -0
  41. package/examples/mcp-postgres-billing-app-handler/README.md +94 -0
  42. package/examples/mcp-postgres-billing-app-handler/app-handler.mjs +123 -0
  43. package/examples/mcp-postgres-billing-app-handler/docker-compose.yml +13 -0
  44. package/examples/mcp-postgres-billing-app-handler/schema.sql +59 -0
  45. package/examples/mcp-postgres-billing-app-handler/scripts/run-demo.sh +100 -0
  46. package/examples/mcp-postgres-billing-app-handler/seed.sql +39 -0
  47. package/examples/mcp-postgres-billing-app-handler/synapsor-handler.mjs +437 -0
  48. package/examples/mcp-postgres-billing-app-handler/synapsor.runner.json +158 -0
  49. package/examples/mysql-refund-agent/Makefile +4 -0
  50. package/examples/mysql-refund-agent/README.md +36 -0
  51. package/examples/openai-agents-http/Makefile +6 -0
  52. package/examples/openai-agents-http/README.md +33 -12
  53. package/examples/openai-agents-http/agent.py +29 -65
  54. package/examples/openai-agents-stdio/Makefile +6 -0
  55. package/examples/openai-agents-stdio/README.md +24 -6
  56. package/examples/openai-agents-stdio/agent.py +4 -2
  57. package/examples/raw-sql-vs-synapsor/Makefile +11 -0
  58. package/examples/raw-sql-vs-synapsor/README.md +41 -0
  59. package/examples/reference-support-billing-app/README.md +16 -16
  60. package/examples/reference-support-billing-app/mcp-client.generic.json +1 -1
  61. package/examples/support-billing-agent/Makefile +19 -0
  62. package/examples/support-billing-agent/README.md +89 -0
  63. package/examples/support-billing-agent/app/README.md +13 -0
  64. package/examples/support-billing-agent/db/schema.sql +91 -0
  65. package/examples/support-billing-agent/db/seed.sql +43 -0
  66. package/examples/support-billing-agent/docker-compose.yml +13 -0
  67. package/examples/support-billing-agent/scripts/run-demo.sh +15 -0
  68. package/examples/support-billing-agent/synapsor.runner.json +233 -0
  69. package/fixtures/benchmark/mcp-efficiency.json +53 -0
  70. package/fixtures/benchmark/mcp-efficiency.txt +25 -0
  71. package/fixtures/protocol/MANIFEST.json +54 -0
  72. package/fixtures/protocol/change-set.late-fee-waiver.v1.json +72 -0
  73. package/fixtures/protocol/execution-receipt.applied.v1.json +14 -0
  74. package/fixtures/protocol/execution-receipt.conflict.v1.json +15 -0
  75. package/fixtures/protocol/runner-registration.v1.json +22 -0
  76. package/fixtures/protocol/writeback-job.late-fee-waiver.v1.json +44 -0
  77. package/package.json +27 -4
  78. package/schemas/change-set.v1.schema.json +140 -0
  79. package/schemas/execution-receipt.v1.schema.json +34 -0
  80. package/schemas/onboarding-selection.v1.schema.json +132 -0
  81. package/schemas/runner-registration.v1.schema.json +48 -0
  82. package/schemas/synapsor.app-handler-receipt.v1.json +39 -0
  83. package/schemas/synapsor.app-handler-request.v1.json +119 -0
  84. package/schemas/synapsor.runner.schema.json +415 -0
  85. package/schemas/writeback-job.v1.schema.json +121 -0
@@ -0,0 +1,415 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://synapsor.ai/schemas/synapsor.runner.schema.json",
4
+ "title": "Synapsor Runner config",
5
+ "description": "Configuration for local Synapsor Runner MCP capabilities over Postgres/MySQL.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["version", "mode", "sources", "trusted_context", "capabilities"],
9
+ "properties": {
10
+ "version": {
11
+ "const": 1
12
+ },
13
+ "mode": {
14
+ "type": "string",
15
+ "enum": ["read_only", "shadow", "review", "cloud"]
16
+ },
17
+ "result_format": {
18
+ "description": "Set to 2 to return one stable ok/summary/data/proposal/error envelope from MCP tool calls.",
19
+ "type": "integer",
20
+ "enum": [1, 2],
21
+ "default": 1
22
+ },
23
+ "strict": {
24
+ "type": "boolean",
25
+ "default": true
26
+ },
27
+ "storage": {
28
+ "type": "object",
29
+ "additionalProperties": false,
30
+ "properties": {
31
+ "sqlite_path": {
32
+ "type": "string",
33
+ "minLength": 1
34
+ }
35
+ }
36
+ },
37
+ "sources": {
38
+ "type": "object",
39
+ "minProperties": 1,
40
+ "additionalProperties": {
41
+ "$ref": "#/$defs/source"
42
+ }
43
+ },
44
+ "trusted_context": {
45
+ "$ref": "#/$defs/trusted_context"
46
+ },
47
+ "contexts": {
48
+ "type": "object",
49
+ "additionalProperties": {
50
+ "$ref": "#/$defs/trusted_context"
51
+ }
52
+ },
53
+ "executors": {
54
+ "type": "object",
55
+ "additionalProperties": {
56
+ "$ref": "#/$defs/executor"
57
+ }
58
+ },
59
+ "capabilities": {
60
+ "type": "array",
61
+ "minItems": 1,
62
+ "items": {
63
+ "$ref": "#/$defs/capability"
64
+ }
65
+ },
66
+ "cloud": {
67
+ "type": "object",
68
+ "additionalProperties": true
69
+ }
70
+ },
71
+ "$defs": {
72
+ "env_name": {
73
+ "type": "string",
74
+ "pattern": "^[A-Z_][A-Z0-9_]*$"
75
+ },
76
+ "identifier": {
77
+ "type": "string",
78
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
79
+ },
80
+ "qualified_name": {
81
+ "type": "string",
82
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)+$"
83
+ },
84
+ "scalar": {
85
+ "type": ["string", "number", "boolean", "null"]
86
+ },
87
+ "source": {
88
+ "type": "object",
89
+ "additionalProperties": false,
90
+ "required": ["engine", "read_url_env"],
91
+ "properties": {
92
+ "engine": {
93
+ "type": "string",
94
+ "enum": ["postgres", "mysql"]
95
+ },
96
+ "read_url_env": {
97
+ "$ref": "#/$defs/env_name"
98
+ },
99
+ "write_url_env": {
100
+ "$ref": "#/$defs/env_name"
101
+ },
102
+ "read_only": {
103
+ "type": "boolean"
104
+ },
105
+ "statement_timeout_ms": {
106
+ "type": "integer",
107
+ "minimum": 1
108
+ },
109
+ "ssl": {
110
+ "type": "object",
111
+ "additionalProperties": true
112
+ }
113
+ }
114
+ },
115
+ "trusted_context": {
116
+ "type": "object",
117
+ "additionalProperties": false,
118
+ "required": ["provider"],
119
+ "properties": {
120
+ "provider": {
121
+ "type": "string",
122
+ "enum": ["static_dev", "environment", "http_claims", "cloud_session"]
123
+ },
124
+ "values": {
125
+ "type": "object",
126
+ "additionalProperties": true,
127
+ "properties": {
128
+ "tenant_id": {
129
+ "type": "string"
130
+ },
131
+ "principal": {
132
+ "type": "string"
133
+ },
134
+ "tenant_id_env": {
135
+ "$ref": "#/$defs/env_name"
136
+ },
137
+ "principal_env": {
138
+ "$ref": "#/$defs/env_name"
139
+ }
140
+ }
141
+ }
142
+ }
143
+ },
144
+ "executor": {
145
+ "type": "object",
146
+ "additionalProperties": false,
147
+ "required": ["type"],
148
+ "properties": {
149
+ "type": {
150
+ "type": "string",
151
+ "enum": ["sql_update", "http_handler", "command_handler"]
152
+ },
153
+ "url_env": {
154
+ "$ref": "#/$defs/env_name"
155
+ },
156
+ "method": {
157
+ "type": "string",
158
+ "enum": ["POST", "PUT", "PATCH"]
159
+ },
160
+ "auth": {
161
+ "type": "object",
162
+ "additionalProperties": false,
163
+ "properties": {
164
+ "type": {
165
+ "const": "bearer_env"
166
+ },
167
+ "token_env": {
168
+ "$ref": "#/$defs/env_name"
169
+ }
170
+ }
171
+ },
172
+ "signing_secret_env": {
173
+ "$ref": "#/$defs/env_name"
174
+ },
175
+ "timeout_ms": {
176
+ "type": "integer",
177
+ "minimum": 1
178
+ },
179
+ "command_env": {
180
+ "$ref": "#/$defs/env_name"
181
+ }
182
+ }
183
+ },
184
+ "capability": {
185
+ "type": "object",
186
+ "additionalProperties": false,
187
+ "required": ["name", "kind", "source", "target", "args", "lookup", "visible_columns"],
188
+ "properties": {
189
+ "name": {
190
+ "$ref": "#/$defs/qualified_name"
191
+ },
192
+ "kind": {
193
+ "type": "string",
194
+ "enum": ["read", "proposal"]
195
+ },
196
+ "description": {
197
+ "description": "Model-facing text shown in MCP tools/list. Describe when to use the tool.",
198
+ "type": "string",
199
+ "minLength": 1
200
+ },
201
+ "returns_hint": {
202
+ "description": "Model-facing hint about what the tool returns.",
203
+ "type": "string",
204
+ "minLength": 1
205
+ },
206
+ "source": {
207
+ "type": "string",
208
+ "minLength": 1
209
+ },
210
+ "context": {
211
+ "type": "string",
212
+ "minLength": 1
213
+ },
214
+ "executor": {
215
+ "type": "string",
216
+ "minLength": 1
217
+ },
218
+ "target": {
219
+ "$ref": "#/$defs/target"
220
+ },
221
+ "args": {
222
+ "type": "object",
223
+ "minProperties": 1,
224
+ "additionalProperties": {
225
+ "$ref": "#/$defs/arg"
226
+ }
227
+ },
228
+ "lookup": {
229
+ "type": "object",
230
+ "additionalProperties": false,
231
+ "required": ["id_from_arg"],
232
+ "properties": {
233
+ "id_from_arg": {
234
+ "type": "string",
235
+ "minLength": 1
236
+ }
237
+ }
238
+ },
239
+ "visible_columns": {
240
+ "type": "array",
241
+ "minItems": 1,
242
+ "items": {
243
+ "$ref": "#/$defs/identifier"
244
+ }
245
+ },
246
+ "evidence": {
247
+ "type": "string"
248
+ },
249
+ "max_rows": {
250
+ "type": "integer",
251
+ "minimum": 1
252
+ },
253
+ "patch": {
254
+ "type": "object",
255
+ "additionalProperties": {
256
+ "$ref": "#/$defs/patch_binding"
257
+ }
258
+ },
259
+ "allowed_columns": {
260
+ "type": "array",
261
+ "items": {
262
+ "$ref": "#/$defs/identifier"
263
+ }
264
+ },
265
+ "numeric_bounds": {
266
+ "type": "object",
267
+ "additionalProperties": {
268
+ "$ref": "#/$defs/numeric_bound"
269
+ }
270
+ },
271
+ "transition_guards": {
272
+ "type": "object",
273
+ "additionalProperties": {
274
+ "$ref": "#/$defs/transition_guard"
275
+ }
276
+ },
277
+ "conflict_guard": {
278
+ "type": "object",
279
+ "additionalProperties": false,
280
+ "properties": {
281
+ "column": {
282
+ "$ref": "#/$defs/identifier"
283
+ },
284
+ "weak_guard_ack": {
285
+ "type": "boolean"
286
+ }
287
+ }
288
+ },
289
+ "approval": {
290
+ "type": "object",
291
+ "additionalProperties": false,
292
+ "properties": {
293
+ "mode": {
294
+ "type": "string"
295
+ },
296
+ "required_role": {
297
+ "type": "string"
298
+ }
299
+ }
300
+ },
301
+ "single_tenant_dev_ack": {
302
+ "type": "boolean"
303
+ }
304
+ }
305
+ },
306
+ "target": {
307
+ "type": "object",
308
+ "additionalProperties": false,
309
+ "required": ["schema", "table", "primary_key"],
310
+ "properties": {
311
+ "schema": {
312
+ "$ref": "#/$defs/identifier"
313
+ },
314
+ "table": {
315
+ "$ref": "#/$defs/identifier"
316
+ },
317
+ "primary_key": {
318
+ "$ref": "#/$defs/identifier"
319
+ },
320
+ "tenant_key": {
321
+ "$ref": "#/$defs/identifier"
322
+ },
323
+ "single_tenant_dev": {
324
+ "type": "boolean"
325
+ }
326
+ }
327
+ },
328
+ "arg": {
329
+ "type": "object",
330
+ "additionalProperties": false,
331
+ "required": ["type"],
332
+ "properties": {
333
+ "type": {
334
+ "type": "string",
335
+ "enum": ["string", "number", "boolean"]
336
+ },
337
+ "description": {
338
+ "type": "string",
339
+ "minLength": 1
340
+ },
341
+ "required": {
342
+ "type": "boolean"
343
+ },
344
+ "max_length": {
345
+ "type": "integer",
346
+ "minimum": 1
347
+ },
348
+ "minimum": {
349
+ "type": "number"
350
+ },
351
+ "maximum": {
352
+ "type": "number"
353
+ },
354
+ "enum": {
355
+ "type": "array",
356
+ "items": {
357
+ "$ref": "#/$defs/scalar"
358
+ }
359
+ }
360
+ }
361
+ },
362
+ "patch_binding": {
363
+ "type": "object",
364
+ "additionalProperties": false,
365
+ "oneOf": [
366
+ {
367
+ "required": ["fixed"]
368
+ },
369
+ {
370
+ "required": ["from_arg"]
371
+ }
372
+ ],
373
+ "properties": {
374
+ "fixed": {
375
+ "$ref": "#/$defs/scalar"
376
+ },
377
+ "from_arg": {
378
+ "type": "string",
379
+ "minLength": 1
380
+ }
381
+ }
382
+ },
383
+ "numeric_bound": {
384
+ "type": "object",
385
+ "additionalProperties": false,
386
+ "properties": {
387
+ "minimum": {
388
+ "type": "number"
389
+ },
390
+ "maximum": {
391
+ "type": "number"
392
+ }
393
+ }
394
+ },
395
+ "transition_guard": {
396
+ "type": "object",
397
+ "additionalProperties": false,
398
+ "required": ["allowed"],
399
+ "properties": {
400
+ "from_column": {
401
+ "$ref": "#/$defs/identifier"
402
+ },
403
+ "allowed": {
404
+ "type": "object",
405
+ "additionalProperties": {
406
+ "type": "array",
407
+ "items": {
408
+ "type": "string"
409
+ }
410
+ }
411
+ }
412
+ }
413
+ }
414
+ }
415
+ }
@@ -0,0 +1,121 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.synapsor.ai/synapsor.writeback-job.v1.schema.json",
4
+ "title": "Synapsor Writeback Job v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schema_version",
9
+ "writeback_job_id",
10
+ "proposal_id",
11
+ "proposal_version",
12
+ "proposal_hash",
13
+ "runner_scope",
14
+ "engine",
15
+ "operation",
16
+ "target",
17
+ "tenant_guard",
18
+ "allowed_columns",
19
+ "patch",
20
+ "conflict_guard",
21
+ "idempotency_key",
22
+ "lease"
23
+ ],
24
+ "properties": {
25
+ "schema_version": { "const": "synapsor.writeback-job.v1" },
26
+ "writeback_job_id": { "type": "string", "minLength": 1 },
27
+ "proposal_id": { "type": "string", "minLength": 1 },
28
+ "proposal_version": { "type": "integer", "minimum": 1 },
29
+ "proposal_hash": { "type": "string", "pattern": "^sha256:.+" },
30
+ "runner_scope": {
31
+ "type": "object",
32
+ "additionalProperties": false,
33
+ "required": ["project_id", "source_id"],
34
+ "properties": {
35
+ "project_id": { "type": "string", "minLength": 1 },
36
+ "source_id": { "type": "string", "minLength": 1 }
37
+ }
38
+ },
39
+ "engine": { "enum": ["postgres", "mysql"] },
40
+ "operation": { "const": "single_row_update" },
41
+ "target": {
42
+ "type": "object",
43
+ "additionalProperties": false,
44
+ "required": ["schema", "table", "primary_key"],
45
+ "properties": {
46
+ "schema": { "$ref": "#/$defs/safeIdentifier" },
47
+ "table": { "$ref": "#/$defs/safeIdentifier" },
48
+ "primary_key": { "$ref": "#/$defs/columnValue" }
49
+ }
50
+ },
51
+ "tenant_guard": { "$ref": "#/$defs/columnValue" },
52
+ "allowed_columns": {
53
+ "type": "array",
54
+ "items": { "$ref": "#/$defs/safeIdentifier" },
55
+ "minItems": 1,
56
+ "uniqueItems": true
57
+ },
58
+ "patch": { "$ref": "#/$defs/scalarMap" },
59
+ "conflict_guard": {
60
+ "oneOf": [
61
+ {
62
+ "type": "object",
63
+ "additionalProperties": false,
64
+ "required": ["kind", "column", "expected_value"],
65
+ "properties": {
66
+ "kind": { "const": "column" },
67
+ "column": { "$ref": "#/$defs/safeIdentifier" },
68
+ "expected_value": { "$ref": "#/$defs/scalar" }
69
+ }
70
+ },
71
+ {
72
+ "type": "object",
73
+ "additionalProperties": false,
74
+ "required": ["kind", "expected_hash"],
75
+ "properties": {
76
+ "kind": { "const": "row_hash" },
77
+ "expected_hash": { "type": "string", "minLength": 1 }
78
+ }
79
+ },
80
+ {
81
+ "type": "object",
82
+ "additionalProperties": false,
83
+ "required": ["kind"],
84
+ "properties": {
85
+ "kind": { "const": "none" }
86
+ }
87
+ }
88
+ ]
89
+ },
90
+ "idempotency_key": { "type": "string", "minLength": 1 },
91
+ "lease": {
92
+ "type": "object",
93
+ "additionalProperties": false,
94
+ "required": ["lease_id", "attempt", "expires_at"],
95
+ "properties": {
96
+ "lease_id": { "type": "string", "minLength": 1 },
97
+ "attempt": { "type": "integer", "minimum": 1 },
98
+ "expires_at": { "type": "string", "format": "date-time" }
99
+ }
100
+ }
101
+ },
102
+ "$defs": {
103
+ "safeIdentifier": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" },
104
+ "scalar": { "type": ["string", "number", "boolean", "null"] },
105
+ "scalarMap": {
106
+ "type": "object",
107
+ "propertyNames": { "$ref": "#/$defs/safeIdentifier" },
108
+ "additionalProperties": { "$ref": "#/$defs/scalar" },
109
+ "minProperties": 1
110
+ },
111
+ "columnValue": {
112
+ "type": "object",
113
+ "additionalProperties": false,
114
+ "required": ["column", "value"],
115
+ "properties": {
116
+ "column": { "$ref": "#/$defs/safeIdentifier" },
117
+ "value": { "$ref": "#/$defs/scalar" }
118
+ }
119
+ }
120
+ }
121
+ }