@synapsor/runner 0.1.0-alpha.10 → 0.1.0-alpha.13

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