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

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 (44) hide show
  1. package/README.md +387 -19
  2. package/TRADEMARKS.md +23 -0
  3. package/dist/cli.d.ts +4 -0
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +20 -8723
  6. package/dist/runner.mjs +12759 -0
  7. package/docs/README.md +36 -0
  8. package/docs/getting-started-own-database.md +460 -0
  9. package/docs/http-mcp.md +242 -0
  10. package/docs/limitations.md +95 -0
  11. package/docs/local-mode.md +351 -0
  12. package/docs/mcp-audit.md +152 -0
  13. package/docs/mcp-client-setup.md +231 -0
  14. package/docs/recipes.md +61 -0
  15. package/docs/release-notes.md +129 -0
  16. package/docs/security-boundary.md +94 -0
  17. package/docs/troubleshooting-first-run.md +248 -0
  18. package/docs/writeback-executors.md +209 -0
  19. package/examples/app-owned-writeback/README.md +120 -0
  20. package/examples/app-owned-writeback/business-actions.md +221 -0
  21. package/examples/app-owned-writeback/command-handler.mjs +46 -0
  22. package/examples/app-owned-writeback/node-fastify-handler.mjs +55 -0
  23. package/examples/app-owned-writeback/python-fastapi-handler.py +57 -0
  24. package/examples/dangerous-mcp-tools.json +88 -0
  25. package/examples/openai-agents-http/README.md +56 -0
  26. package/examples/openai-agents-http/agent.py +54 -0
  27. package/examples/openai-agents-http/requirements.txt +1 -0
  28. package/examples/openai-agents-stdio/README.md +62 -0
  29. package/examples/openai-agents-stdio/agent.py +70 -0
  30. package/examples/openai-agents-stdio/requirements.txt +1 -0
  31. package/examples/reference-support-billing-app/README.md +137 -0
  32. package/examples/reference-support-billing-app/docker-compose.yml +13 -0
  33. package/examples/reference-support-billing-app/mcp-client.generic.json +11 -0
  34. package/examples/reference-support-billing-app/schema.sql +68 -0
  35. package/examples/reference-support-billing-app/scripts/run-demo.sh +7 -0
  36. package/examples/reference-support-billing-app/seed.sql +33 -0
  37. package/examples/reference-support-billing-app/synapsor.runner.json +241 -0
  38. package/package.json +12 -4
  39. package/recipes/accounts.trial_extension.json +42 -0
  40. package/recipes/billing.late_fee_waiver.json +46 -0
  41. package/recipes/credits.account_credit.json +45 -0
  42. package/recipes/orders.refund_review.json +57 -0
  43. package/recipes/support.ticket_resolution.json +51 -0
  44. package/dist/bin.cjs +0 -13
@@ -0,0 +1,70 @@
1
+ import asyncio
2
+ import os
3
+ import sys
4
+
5
+ try:
6
+ from agents import Agent, Runner
7
+ from agents.mcp import MCPServerStdio
8
+ except ImportError as exc:
9
+ raise SystemExit(
10
+ "This example requires the OpenAI Agents SDK with MCP stdio support. "
11
+ "Install with: pip install -r requirements.txt"
12
+ ) from exc
13
+
14
+
15
+ async def main() -> None:
16
+ config_path = os.environ.get("SYNAPSOR_CONFIG", "./synapsor.runner.json")
17
+ store_path = os.environ.get("SYNAPSOR_STORE", "./.synapsor/local.db")
18
+ invoice_id = os.environ.get("SYNAPSOR_INVOICE_ID", "INV-3001")
19
+
20
+ required = ["OPENAI_API_KEY", "DATABASE_URL", "SYNAPSOR_TENANT_ID", "SYNAPSOR_PRINCIPAL"]
21
+ missing = [name for name in required if not os.environ.get(name)]
22
+ if missing:
23
+ raise SystemExit(f"Missing required environment variables: {', '.join(missing)}")
24
+
25
+ params = {
26
+ "command": "npx",
27
+ "args": [
28
+ "-y",
29
+ "-p",
30
+ "@synapsor/runner@alpha",
31
+ "synapsor-runner",
32
+ "mcp",
33
+ "serve",
34
+ "--config",
35
+ config_path,
36
+ "--store",
37
+ store_path,
38
+ ],
39
+ "env": {
40
+ **os.environ,
41
+ "DATABASE_URL": os.environ["DATABASE_URL"],
42
+ "SYNAPSOR_TENANT_ID": os.environ["SYNAPSOR_TENANT_ID"],
43
+ "SYNAPSOR_PRINCIPAL": os.environ["SYNAPSOR_PRINCIPAL"],
44
+ },
45
+ }
46
+
47
+ async with MCPServerStdio(params=params) as mcp_server:
48
+ agent = Agent(
49
+ name="Synapsor stdio MCP demo agent",
50
+ instructions=(
51
+ "Use Synapsor MCP tools to inspect scoped database data. "
52
+ "Do not claim that you can run SQL, approve proposals, or commit writes."
53
+ ),
54
+ mcp_servers=[mcp_server],
55
+ )
56
+ result = await Runner.run(
57
+ agent,
58
+ (
59
+ f"Inspect invoice {invoice_id} using Synapsor. "
60
+ "Explain what you saw and whether you have write authority."
61
+ ),
62
+ )
63
+ print(result.final_output)
64
+
65
+
66
+ if __name__ == "__main__":
67
+ try:
68
+ asyncio.run(main())
69
+ except KeyboardInterrupt:
70
+ sys.exit(130)
@@ -0,0 +1 @@
1
+ openai-agents>=0.1.0
@@ -0,0 +1,137 @@
1
+ # Reference Support/Billing App
2
+
3
+ This is the main local reference app for Synapsor Runner.
4
+
5
+ It shows the commit-safe MCP loop against a disposable Postgres app database:
6
+
7
+ 1. The MCP model sees semantic tools, not `execute_sql`.
8
+ 2. Reads are scoped by trusted `SYNAPSOR_TENANT_ID` and `SYNAPSOR_PRINCIPAL`.
9
+ 3. Proposal tools create exact diffs and leave the source database unchanged.
10
+ 4. Approval happens through the local CLI or UI, outside MCP.
11
+ 5. The trusted runner applies one guarded update with tenant, allowed-column, idempotency, and `updated_at` conflict checks.
12
+ 6. Replay exports evidence, diff, approval, writeback receipt, and conflict outcome.
13
+
14
+ The app fixture is split into `schema.sql` and `seed.sql` so the database shape
15
+ and demo data are easy to inspect.
16
+
17
+ ## Start
18
+
19
+ From the repository root:
20
+
21
+ ```bash
22
+ docker compose -f examples/reference-support-billing-app/docker-compose.yml up -d
23
+
24
+ export REFERENCE_POSTGRES_READ_URL="postgresql://synapsor_reader:synapsor_reader_password@localhost:55435/synapsor_reference_support_billing"
25
+ export REFERENCE_POSTGRES_WRITE_URL="postgresql://synapsor_writer:synapsor_writer_password@localhost:55435/synapsor_reference_support_billing"
26
+ export SYNAPSOR_TENANT_ID="acme"
27
+ export SYNAPSOR_PRINCIPAL="local_support_operator"
28
+ ```
29
+
30
+ Or run the complete success/conflict/replay smoke:
31
+
32
+ ```bash
33
+ examples/reference-support-billing-app/scripts/run-demo.sh
34
+ ```
35
+
36
+ Validate the reviewed contract:
37
+
38
+ ```bash
39
+ npx -y -p @synapsor/runner@alpha synapsor-runner config validate --config examples/reference-support-billing-app/synapsor.runner.json
40
+ npx -y -p @synapsor/runner@alpha synapsor-runner doctor --config examples/reference-support-billing-app/synapsor.runner.json
41
+ ```
42
+
43
+ Serve MCP:
44
+
45
+ ```bash
46
+ npx -y -p @synapsor/runner@alpha synapsor-runner mcp serve \
47
+ --config examples/reference-support-billing-app/synapsor.runner.json \
48
+ --store ./tmp/reference-support-billing/local.db
49
+ ```
50
+
51
+ ## Tools
52
+
53
+ The model-facing MCP tools are:
54
+
55
+ - `support.inspect_ticket`
56
+ - `support.propose_ticket_resolution`
57
+ - `support.inspect_customer_account`
58
+ - `support.propose_plan_credit`
59
+ - `billing.inspect_invoice`
60
+ - `billing.propose_late_fee_waiver`
61
+ - `orders.inspect_order`
62
+ - `orders.propose_status_change`
63
+
64
+ The model does not receive approval tools, commit tools, write credentials, raw SQL, arbitrary table names, arbitrary column names, or tenant authority.
65
+
66
+ ## Safe Write Examples
67
+
68
+ After `synapsor-runner demo` or after starting this fixture manually, try the same
69
+ proposal-first loop without connecting an MCP client:
70
+
71
+ ```bash
72
+ npx -y -p @synapsor/runner@alpha synapsor-runner propose billing.propose_late_fee_waiver --sample
73
+ npx -y -p @synapsor/runner@alpha synapsor-runner proposals show latest
74
+ npx -y -p @synapsor/runner@alpha synapsor-runner proposals approve latest --yes
75
+ npx -y -p @synapsor/runner@alpha synapsor-runner apply latest
76
+ npx -y -p @synapsor/runner@alpha synapsor-runner replay latest
77
+ ```
78
+
79
+ Expected safety output:
80
+
81
+ ```text
82
+ Source DB changed:
83
+ no
84
+
85
+ Guarded writeback applied.
86
+ * proposal approved: yes
87
+ * primary key matched: yes
88
+ * tenant guard matched: yes
89
+ * allowed columns only: yes
90
+ * conflict guard passed: yes
91
+ ```
92
+
93
+ Other proposal examples use the same review/apply/replay path:
94
+
95
+ ```bash
96
+ npx -y -p @synapsor/runner@alpha synapsor-runner propose support.propose_plan_credit --sample
97
+ npx -y -p @synapsor/runner@alpha synapsor-runner propose orders.propose_status_change --sample
98
+ ```
99
+
100
+ Safety guarantees:
101
+
102
+ - proposals store evidence, a before/after diff, trusted tenant/principal
103
+ context, and query audit before any write;
104
+ - approval stays outside the model-facing MCP tool surface;
105
+ - writeback is single-row, primary-key targeted, tenant guarded,
106
+ allowed-column checked, idempotent, and conflict guarded;
107
+ - stale rows return `conflict` and are replayable.
108
+
109
+ Current limitation: v0.1 is intentionally local and single-user. It does not
110
+ provide hosted RBAC, workflow DAGs, branches, settlement policies, auto-merge,
111
+ or production-scale runner orchestration.
112
+
113
+ ## Review And Replay
114
+
115
+ After a proposal exists:
116
+
117
+ ```bash
118
+ npx -y -p @synapsor/runner@alpha synapsor-runner proposals list --store ./tmp/reference-support-billing/local.db
119
+ npx -y -p @synapsor/runner@alpha synapsor-runner proposals approve <proposal_id> --store ./tmp/reference-support-billing/local.db --actor local_reviewer --yes
120
+ npx -y -p @synapsor/runner@alpha synapsor-runner proposals writeback-job <proposal_id> --store ./tmp/reference-support-billing/local.db --output ./tmp/reference-support-billing/job.json
121
+ npx -y -p @synapsor/runner@alpha synapsor-runner apply --job ./tmp/reference-support-billing/job.json --store ./tmp/reference-support-billing/local.db
122
+ npx -y -p @synapsor/runner@alpha synapsor-runner replay export <proposal_id> --store ./tmp/reference-support-billing/local.db --output ./tmp/reference-support-billing/replay.json
123
+ ```
124
+
125
+ To inspect locally in a browser:
126
+
127
+ ```bash
128
+ npx -y -p @synapsor/runner@alpha synapsor-runner ui \
129
+ --config examples/reference-support-billing-app/synapsor.runner.json \
130
+ --store ./tmp/reference-support-billing/local.db
131
+ ```
132
+
133
+ ## Stop
134
+
135
+ ```bash
136
+ docker compose -f examples/reference-support-billing-app/docker-compose.yml down -v
137
+ ```
@@ -0,0 +1,13 @@
1
+ services:
2
+ postgres:
3
+ image: postgres:16
4
+ container_name: synapsor_runner_reference_support_billing
5
+ environment:
6
+ POSTGRES_DB: synapsor_reference_support_billing
7
+ POSTGRES_USER: synapsor_admin
8
+ POSTGRES_PASSWORD: synapsor_admin_password
9
+ ports:
10
+ - "55435:5432"
11
+ volumes:
12
+ - ./schema.sql:/docker-entrypoint-initdb.d/001_schema.sql:ro
13
+ - ./seed.sql:/docker-entrypoint-initdb.d/002_seed.sql:ro
@@ -0,0 +1,11 @@
1
+ {
2
+ "command": "synapsor-runner",
3
+ "args": [
4
+ "mcp",
5
+ "serve",
6
+ "--config",
7
+ "examples/reference-support-billing-app/synapsor.runner.json",
8
+ "--store",
9
+ "./tmp/reference-support-billing/local.db"
10
+ ]
11
+ }
@@ -0,0 +1,68 @@
1
+ CREATE TABLE IF NOT EXISTS public.tenants (
2
+ id text PRIMARY KEY,
3
+ name text NOT NULL,
4
+ created_at timestamptz NOT NULL DEFAULT now(),
5
+ updated_at timestamptz NOT NULL DEFAULT now()
6
+ );
7
+
8
+ CREATE TABLE IF NOT EXISTS public.customers (
9
+ id text PRIMARY KEY,
10
+ tenant_id text NOT NULL REFERENCES public.tenants(id),
11
+ name text NOT NULL,
12
+ email text,
13
+ plan text NOT NULL,
14
+ plan_credit_cents integer NOT NULL DEFAULT 0,
15
+ credit_reason text,
16
+ created_at timestamptz NOT NULL DEFAULT now(),
17
+ updated_at timestamptz NOT NULL DEFAULT now()
18
+ );
19
+
20
+ CREATE TABLE IF NOT EXISTS public.support_tickets (
21
+ id text PRIMARY KEY,
22
+ tenant_id text NOT NULL REFERENCES public.tenants(id),
23
+ customer_id text NOT NULL REFERENCES public.customers(id),
24
+ subject text NOT NULL,
25
+ status text NOT NULL,
26
+ resolution_note text,
27
+ updated_at timestamptz NOT NULL DEFAULT now()
28
+ );
29
+
30
+ CREATE TABLE IF NOT EXISTS public.invoices (
31
+ id text PRIMARY KEY,
32
+ tenant_id text NOT NULL REFERENCES public.tenants(id),
33
+ customer_id text NOT NULL REFERENCES public.customers(id),
34
+ status text NOT NULL,
35
+ balance_cents integer NOT NULL,
36
+ late_fee_cents integer NOT NULL,
37
+ waiver_reason text,
38
+ updated_at timestamptz NOT NULL DEFAULT now()
39
+ );
40
+
41
+ CREATE TABLE IF NOT EXISTS public.orders (
42
+ id text PRIMARY KEY,
43
+ tenant_id text NOT NULL REFERENCES public.tenants(id),
44
+ customer_id text NOT NULL REFERENCES public.customers(id),
45
+ status text NOT NULL,
46
+ status_change_reason text,
47
+ updated_at timestamptz NOT NULL DEFAULT now()
48
+ );
49
+
50
+ DO $$
51
+ BEGIN
52
+ IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'synapsor_reader') THEN
53
+ CREATE ROLE synapsor_reader LOGIN PASSWORD 'synapsor_reader_password';
54
+ END IF;
55
+ IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'synapsor_writer') THEN
56
+ CREATE ROLE synapsor_writer LOGIN PASSWORD 'synapsor_writer_password';
57
+ END IF;
58
+ END
59
+ $$;
60
+
61
+ GRANT CONNECT ON DATABASE synapsor_reference_support_billing TO synapsor_reader, synapsor_writer;
62
+ GRANT USAGE ON SCHEMA public TO synapsor_reader, synapsor_writer;
63
+ GRANT CREATE ON SCHEMA public TO synapsor_writer;
64
+ GRANT SELECT ON public.tenants, public.customers, public.support_tickets, public.invoices, public.orders TO synapsor_reader, synapsor_writer;
65
+ GRANT UPDATE (plan_credit_cents, credit_reason, updated_at) ON public.customers TO synapsor_writer;
66
+ GRANT UPDATE (status, resolution_note, updated_at) ON public.support_tickets TO synapsor_writer;
67
+ GRANT UPDATE (late_fee_cents, waiver_reason, updated_at) ON public.invoices TO synapsor_writer;
68
+ GRANT UPDATE (status, status_change_reason, updated_at) ON public.orders TO synapsor_writer;
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
5
+ cd "$ROOT_DIR"
6
+
7
+ corepack pnpm test:reference-app
@@ -0,0 +1,33 @@
1
+ INSERT INTO public.tenants (id, name, created_at, updated_at)
2
+ VALUES
3
+ ('acme', 'Acme Robotics', '2026-06-20T10:00:00Z', '2026-06-20T10:00:00Z'),
4
+ ('otherco', 'OtherCo Labs', '2026-06-20T10:00:00Z', '2026-06-20T10:00:00Z')
5
+ ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name, updated_at = EXCLUDED.updated_at;
6
+
7
+ INSERT INTO public.customers (id, tenant_id, name, email, plan, plan_credit_cents, credit_reason, created_at, updated_at)
8
+ VALUES
9
+ ('cust_acme_1', 'acme', 'Acme Robotics', 'ops@example.invalid', 'enterprise', 0, NULL, '2026-06-20T10:00:00Z', '2026-06-20T10:00:00Z'),
10
+ ('cust_acme_2', 'acme', 'Acme Field Ops', 'field@example.invalid', 'builder', 0, NULL, '2026-06-20T10:00:00Z', '2026-06-20T10:00:00Z'),
11
+ ('cust_other_1', 'otherco', 'OtherCo Labs', 'ops@otherco.invalid', 'builder', 0, NULL, '2026-06-20T10:00:00Z', '2026-06-20T10:00:00Z')
12
+ ON CONFLICT (id) DO UPDATE SET tenant_id = EXCLUDED.tenant_id, name = EXCLUDED.name, email = EXCLUDED.email, plan = EXCLUDED.plan, plan_credit_cents = EXCLUDED.plan_credit_cents, credit_reason = EXCLUDED.credit_reason, updated_at = EXCLUDED.updated_at;
13
+
14
+ INSERT INTO public.support_tickets (id, tenant_id, customer_id, subject, status, resolution_note, updated_at)
15
+ VALUES
16
+ ('T-1042', 'acme', 'cust_acme_1', 'Late fee waiver request for INV-3001', 'open', NULL, '2026-06-20T12:00:00Z'),
17
+ ('T-1043', 'acme', 'cust_acme_2', 'Duplicate card charge question', 'open', NULL, '2026-06-20T12:05:00Z'),
18
+ ('T-9001', 'otherco', 'cust_other_1', 'OtherCo private billing ticket', 'open', NULL, '2026-06-20T12:00:00Z')
19
+ ON CONFLICT (id) DO UPDATE SET tenant_id = EXCLUDED.tenant_id, customer_id = EXCLUDED.customer_id, subject = EXCLUDED.subject, status = EXCLUDED.status, resolution_note = EXCLUDED.resolution_note, updated_at = EXCLUDED.updated_at;
20
+
21
+ INSERT INTO public.invoices (id, tenant_id, customer_id, status, balance_cents, late_fee_cents, waiver_reason, updated_at)
22
+ VALUES
23
+ ('INV-3001', 'acme', 'cust_acme_1', 'overdue', 25500, 5500, NULL, '2026-06-20T14:31:08Z'),
24
+ ('INV-3002', 'acme', 'cust_acme_2', 'paid', 0, 0, NULL, '2026-06-20T14:40:00Z'),
25
+ ('INV-9001', 'otherco', 'cust_other_1', 'overdue', 25500, 5500, NULL, '2026-06-20T14:31:08Z')
26
+ ON CONFLICT (id) DO UPDATE SET tenant_id = EXCLUDED.tenant_id, customer_id = EXCLUDED.customer_id, status = EXCLUDED.status, balance_cents = EXCLUDED.balance_cents, late_fee_cents = EXCLUDED.late_fee_cents, waiver_reason = EXCLUDED.waiver_reason, updated_at = EXCLUDED.updated_at;
27
+
28
+ INSERT INTO public.orders (id, tenant_id, customer_id, status, status_change_reason, updated_at)
29
+ VALUES
30
+ ('O-1001', 'acme', 'cust_acme_1', 'paid', NULL, '2026-06-20T13:00:00Z'),
31
+ ('O-1002', 'acme', 'cust_acme_2', 'processing', NULL, '2026-06-20T13:05:00Z'),
32
+ ('O-9001', 'otherco', 'cust_other_1', 'paid', NULL, '2026-06-20T13:00:00Z')
33
+ ON CONFLICT (id) DO UPDATE SET tenant_id = EXCLUDED.tenant_id, customer_id = EXCLUDED.customer_id, status = EXCLUDED.status, status_change_reason = EXCLUDED.status_change_reason, updated_at = EXCLUDED.updated_at;
@@ -0,0 +1,241 @@
1
+ {
2
+ "version": 1,
3
+ "mode": "review",
4
+ "storage": {
5
+ "sqlite_path": "./tmp/reference-support-billing/local.db"
6
+ },
7
+ "sources": {
8
+ "app_postgres": {
9
+ "engine": "postgres",
10
+ "read_url_env": "REFERENCE_POSTGRES_READ_URL",
11
+ "write_url_env": "REFERENCE_POSTGRES_WRITE_URL",
12
+ "statement_timeout_ms": 3000
13
+ }
14
+ },
15
+ "trusted_context": {
16
+ "provider": "environment",
17
+ "values": {
18
+ "tenant_id_env": "SYNAPSOR_TENANT_ID",
19
+ "principal_env": "SYNAPSOR_PRINCIPAL"
20
+ }
21
+ },
22
+ "contexts": {
23
+ "local_operator": {
24
+ "provider": "environment",
25
+ "values": {
26
+ "tenant_id_env": "SYNAPSOR_TENANT_ID",
27
+ "principal_env": "SYNAPSOR_PRINCIPAL"
28
+ }
29
+ }
30
+ },
31
+ "capabilities": [
32
+ {
33
+ "name": "support.inspect_ticket",
34
+ "kind": "read",
35
+ "source": "app_postgres",
36
+ "context": "local_operator",
37
+ "target": {
38
+ "schema": "public",
39
+ "table": "support_tickets",
40
+ "primary_key": "id",
41
+ "tenant_key": "tenant_id"
42
+ },
43
+ "args": {
44
+ "ticket_id": { "type": "string", "required": true, "max_length": 128 }
45
+ },
46
+ "lookup": { "id_from_arg": "ticket_id" },
47
+ "visible_columns": ["id", "tenant_id", "customer_id", "subject", "status", "resolution_note", "updated_at"],
48
+ "evidence": "required",
49
+ "max_rows": 1
50
+ },
51
+ {
52
+ "name": "support.propose_ticket_resolution",
53
+ "kind": "proposal",
54
+ "source": "app_postgres",
55
+ "context": "local_operator",
56
+ "target": {
57
+ "schema": "public",
58
+ "table": "support_tickets",
59
+ "primary_key": "id",
60
+ "tenant_key": "tenant_id"
61
+ },
62
+ "args": {
63
+ "ticket_id": { "type": "string", "required": true, "max_length": 128 },
64
+ "resolution_note": { "type": "string", "required": true, "max_length": 1000 }
65
+ },
66
+ "lookup": { "id_from_arg": "ticket_id" },
67
+ "visible_columns": ["id", "tenant_id", "customer_id", "subject", "status", "resolution_note", "updated_at"],
68
+ "evidence": "required",
69
+ "max_rows": 1,
70
+ "patch": {
71
+ "status": { "fixed": "pending_review" },
72
+ "resolution_note": { "from_arg": "resolution_note" }
73
+ },
74
+ "allowed_columns": ["status", "resolution_note"],
75
+ "transition_guards": {
76
+ "status": {
77
+ "allowed": {
78
+ "open": ["pending_review"],
79
+ "pending_review": ["resolved"]
80
+ }
81
+ }
82
+ },
83
+ "conflict_guard": { "column": "updated_at" },
84
+ "approval": { "mode": "human", "required_role": "support_lead" }
85
+ },
86
+ {
87
+ "name": "support.inspect_customer_account",
88
+ "kind": "read",
89
+ "source": "app_postgres",
90
+ "context": "local_operator",
91
+ "target": {
92
+ "schema": "public",
93
+ "table": "customers",
94
+ "primary_key": "id",
95
+ "tenant_key": "tenant_id"
96
+ },
97
+ "args": {
98
+ "customer_id": { "type": "string", "required": true, "max_length": 128 }
99
+ },
100
+ "lookup": { "id_from_arg": "customer_id" },
101
+ "visible_columns": ["id", "tenant_id", "name", "plan", "plan_credit_cents", "credit_reason", "updated_at"],
102
+ "evidence": "required",
103
+ "max_rows": 1
104
+ },
105
+ {
106
+ "name": "support.propose_plan_credit",
107
+ "kind": "proposal",
108
+ "source": "app_postgres",
109
+ "context": "local_operator",
110
+ "target": {
111
+ "schema": "public",
112
+ "table": "customers",
113
+ "primary_key": "id",
114
+ "tenant_key": "tenant_id"
115
+ },
116
+ "args": {
117
+ "customer_id": { "type": "string", "required": true, "max_length": 128 },
118
+ "credit_cents": { "type": "number", "required": true, "minimum": 0, "maximum": 5000 },
119
+ "reason": { "type": "string", "required": true, "max_length": 500 }
120
+ },
121
+ "lookup": { "id_from_arg": "customer_id" },
122
+ "visible_columns": ["id", "tenant_id", "name", "plan", "plan_credit_cents", "credit_reason", "updated_at"],
123
+ "evidence": "required",
124
+ "max_rows": 1,
125
+ "patch": {
126
+ "plan_credit_cents": { "from_arg": "credit_cents" },
127
+ "credit_reason": { "from_arg": "reason" }
128
+ },
129
+ "allowed_columns": ["plan_credit_cents", "credit_reason"],
130
+ "numeric_bounds": {
131
+ "plan_credit_cents": { "minimum": 0, "maximum": 5000 }
132
+ },
133
+ "conflict_guard": { "column": "updated_at" },
134
+ "approval": { "mode": "human", "required_role": "support_lead" }
135
+ },
136
+ {
137
+ "name": "billing.inspect_invoice",
138
+ "kind": "read",
139
+ "source": "app_postgres",
140
+ "context": "local_operator",
141
+ "target": {
142
+ "schema": "public",
143
+ "table": "invoices",
144
+ "primary_key": "id",
145
+ "tenant_key": "tenant_id"
146
+ },
147
+ "args": {
148
+ "invoice_id": { "type": "string", "required": true, "max_length": 128 }
149
+ },
150
+ "lookup": { "id_from_arg": "invoice_id" },
151
+ "visible_columns": ["id", "tenant_id", "customer_id", "status", "balance_cents", "late_fee_cents", "waiver_reason", "updated_at"],
152
+ "evidence": "required",
153
+ "max_rows": 1
154
+ },
155
+ {
156
+ "name": "billing.propose_late_fee_waiver",
157
+ "kind": "proposal",
158
+ "source": "app_postgres",
159
+ "context": "local_operator",
160
+ "target": {
161
+ "schema": "public",
162
+ "table": "invoices",
163
+ "primary_key": "id",
164
+ "tenant_key": "tenant_id"
165
+ },
166
+ "args": {
167
+ "invoice_id": { "type": "string", "required": true, "max_length": 128 },
168
+ "reason": { "type": "string", "required": true, "max_length": 500 }
169
+ },
170
+ "lookup": { "id_from_arg": "invoice_id" },
171
+ "visible_columns": ["id", "tenant_id", "customer_id", "status", "balance_cents", "late_fee_cents", "waiver_reason", "updated_at"],
172
+ "evidence": "required",
173
+ "max_rows": 1,
174
+ "patch": {
175
+ "late_fee_cents": { "fixed": 0 },
176
+ "waiver_reason": { "from_arg": "reason" }
177
+ },
178
+ "allowed_columns": ["late_fee_cents", "waiver_reason"],
179
+ "numeric_bounds": {
180
+ "late_fee_cents": { "minimum": 0, "maximum": 10000 }
181
+ },
182
+ "conflict_guard": { "column": "updated_at" },
183
+ "approval": { "mode": "human", "required_role": "billing_lead" }
184
+ },
185
+ {
186
+ "name": "orders.inspect_order",
187
+ "kind": "read",
188
+ "source": "app_postgres",
189
+ "context": "local_operator",
190
+ "target": {
191
+ "schema": "public",
192
+ "table": "orders",
193
+ "primary_key": "id",
194
+ "tenant_key": "tenant_id"
195
+ },
196
+ "args": {
197
+ "order_id": { "type": "string", "required": true, "max_length": 128 }
198
+ },
199
+ "lookup": { "id_from_arg": "order_id" },
200
+ "visible_columns": ["id", "tenant_id", "customer_id", "status", "status_change_reason", "updated_at"],
201
+ "evidence": "required",
202
+ "max_rows": 1
203
+ },
204
+ {
205
+ "name": "orders.propose_status_change",
206
+ "kind": "proposal",
207
+ "source": "app_postgres",
208
+ "context": "local_operator",
209
+ "target": {
210
+ "schema": "public",
211
+ "table": "orders",
212
+ "primary_key": "id",
213
+ "tenant_key": "tenant_id"
214
+ },
215
+ "args": {
216
+ "order_id": { "type": "string", "required": true, "max_length": 128 },
217
+ "status": { "type": "string", "required": true, "enum": ["ready_to_ship", "canceled"] },
218
+ "reason": { "type": "string", "required": true, "max_length": 500 }
219
+ },
220
+ "lookup": { "id_from_arg": "order_id" },
221
+ "visible_columns": ["id", "tenant_id", "customer_id", "status", "status_change_reason", "updated_at"],
222
+ "evidence": "required",
223
+ "max_rows": 1,
224
+ "patch": {
225
+ "status": { "from_arg": "status" },
226
+ "status_change_reason": { "from_arg": "reason" }
227
+ },
228
+ "allowed_columns": ["status", "status_change_reason"],
229
+ "transition_guards": {
230
+ "status": {
231
+ "allowed": {
232
+ "paid": ["ready_to_ship", "canceled"],
233
+ "processing": ["ready_to_ship"]
234
+ }
235
+ }
236
+ },
237
+ "conflict_guard": { "column": "updated_at" },
238
+ "approval": { "mode": "human", "required_role": "orders_lead" }
239
+ }
240
+ ]
241
+ }
package/package.json CHANGED
@@ -1,22 +1,30 @@
1
1
  {
2
2
  "name": "@synapsor/runner",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.10",
4
4
  "description": "Commit-safe MCP runner for Postgres and MySQL agents",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "bin": {
8
- "synapsor-runner": "dist/bin.cjs"
8
+ "synapsor-runner": "dist/cli.js"
9
9
  },
10
10
  "files": [
11
- "dist/bin.cjs",
12
11
  "dist/cli.js",
13
12
  "dist/cli.d.ts",
14
13
  "dist/cli.d.ts.map",
15
14
  "dist/local-ui.d.ts",
16
15
  "dist/local-ui.d.ts.map",
16
+ "dist/runner.mjs",
17
+ "docs/**/*.md",
18
+ "examples/dangerous-mcp-tools.json",
19
+ "examples/app-owned-writeback/**",
20
+ "examples/openai-agents-http/**",
21
+ "examples/openai-agents-stdio/**",
22
+ "examples/reference-support-billing-app/**",
23
+ "recipes/**/*.json",
17
24
  "README.md",
18
25
  "LICENSE",
19
- "NOTICE"
26
+ "NOTICE",
27
+ "TRADEMARKS.md"
20
28
  ],
21
29
  "engines": {
22
30
  "node": ">=22.5.0"
@@ -0,0 +1,42 @@
1
+ {
2
+ "id": "accounts.trial_extension",
3
+ "title": "Trial extension",
4
+ "summary": "Inspect one account and propose a bounded trial extension.",
5
+ "expected_table_type": "accounts or subscriptions table",
6
+ "required_columns": ["id", "tenant_id", "trial_ends_at", "extension_reason", "updated_at"],
7
+ "recommended_primary_key": "id",
8
+ "recommended_tenant_key": "tenant_id",
9
+ "recommended_conflict_column": "updated_at",
10
+ "visible_columns": ["id", "tenant_id", "plan", "trial_ends_at", "extension_reason", "updated_at"],
11
+ "allowed_write_columns": ["trial_ends_at", "extension_reason"],
12
+ "semantic_tools": ["accounts.inspect_account", "accounts.propose_trial_extension"],
13
+ "notes": [
14
+ "Use a handler executor if trial changes must go through your billing service."
15
+ ],
16
+ "spec": {
17
+ "version": 1,
18
+ "engine": "postgres",
19
+ "mode": "review",
20
+ "schema": "public",
21
+ "table": "accounts",
22
+ "primary_key": "id",
23
+ "tenant_key": "tenant_id",
24
+ "conflict_column": "updated_at",
25
+ "namespace": "accounts",
26
+ "object_name": "account",
27
+ "inspect_tool_name": "accounts.inspect_account",
28
+ "proposal_tool_name": "accounts.propose_trial_extension",
29
+ "lookup_arg": "account_id",
30
+ "visible_columns": ["id", "tenant_id", "plan", "trial_ends_at", "extension_reason", "updated_at"],
31
+ "allowed_columns": ["trial_ends_at", "extension_reason"],
32
+ "patch": {
33
+ "trial_ends_at": { "from_arg": "trial_ends_at" },
34
+ "extension_reason": { "from_arg": "reason" }
35
+ },
36
+ "patch_args": {
37
+ "trial_ends_at": { "type": "string", "required": true, "max_length": 64 },
38
+ "reason": { "type": "string", "required": true, "max_length": 500 }
39
+ },
40
+ "approval": { "required_role": "account_admin" }
41
+ }
42
+ }