@synapsor/dsl 0.1.0 → 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 (2) hide show
  1. package/README.md +58 -0
  2. package/package.json +11 -2
package/README.md CHANGED
@@ -5,6 +5,41 @@
5
5
  The DSL is not the source of truth. It compiles to `@synapsor/spec` JSON, and
6
6
  the generated JSON is validated by `@synapsor/spec`.
7
7
 
8
+ Part of the Synapsor OSS toolchain:
9
+
10
+ - [`@synapsor/runner`](https://www.npmjs.com/package/@synapsor/runner): local MCP runtime that serves compiled contracts.
11
+ - [`@synapsor/spec`](https://www.npmjs.com/package/@synapsor/spec): canonical contract schemas, types, and validation.
12
+ - [Source and issues on GitHub](https://github.com/Synapsor/Synapsor-Runner).
13
+
14
+ ## Example
15
+
16
+ ```sql
17
+ CREATE AGENT CONTEXT local_operator
18
+ BIND tenant_id FROM ENVIRONMENT SYNAPSOR_TENANT_ID REQUIRED
19
+ BIND principal FROM ENVIRONMENT SYNAPSOR_PRINCIPAL REQUIRED
20
+ TENANT BINDING tenant_id
21
+ PRINCIPAL BINDING principal
22
+ END
23
+
24
+ CREATE CAPABILITY billing.inspect_invoice
25
+ USING CONTEXT local_operator
26
+ SOURCE local_postgres
27
+ ON public.invoices
28
+ PRIMARY KEY id
29
+ TENANT KEY tenant_id
30
+ CONFLICT GUARD updated_at
31
+ LOOKUP invoice_id BY id
32
+ ARG invoice_id STRING REQUIRED MAX 128
33
+ ALLOW READ id, tenant_id, status, late_fee_cents, updated_at
34
+ REQUIRE EVIDENCE
35
+ MAX ROWS 1
36
+ END
37
+ ```
38
+
39
+ A longer worked contract lives in
40
+ [`examples/billing-late-fee.synapsor`](https://github.com/Synapsor/Synapsor-Runner/blob/main/packages/dsl/examples/billing-late-fee.synapsor),
41
+ and the runner README walks the full compile → validate → bundle → serve flow.
42
+
8
43
  ## CLI
9
44
 
10
45
  ```bash
@@ -19,6 +54,29 @@ synapsor-runner dsl validate ./contract.synapsor
19
54
  synapsor-runner dsl compile ./contract.synapsor --out ./synapsor.contract.json
20
55
  ```
21
56
 
57
+ ## Programmatic API
58
+
59
+ ```ts
60
+ import { compileAgentDsl, parseAgentDsl, validateAgentDsl, formatAgentDsl, AgentDslError } from "@synapsor/dsl";
61
+ import { assertValidContract, normalizeContract } from "@synapsor/spec";
62
+
63
+ const source = `CREATE AGENT CONTEXT ...`;
64
+
65
+ const result = validateAgentDsl(source); // { ok, errors, warnings } with line/column entries
66
+ const ast = parseAgentDsl(source); // AST with line/column spans
67
+
68
+ try {
69
+ const contract = compileAgentDsl(source); // @synapsor/spec contract JSON
70
+ assertValidContract(normalizeContract(contract));
71
+ } catch (error) {
72
+ if (error instanceof AgentDslError) {
73
+ console.error(`${error.message} at ${error.line}:${error.column}`);
74
+ }
75
+ }
76
+ ```
77
+
78
+ `formatAgentDsl(source)` returns a canonically formatted copy of the DSL text.
79
+
22
80
  ## Supported Preview Constructs
23
81
 
24
82
  - `CREATE AGENT CONTEXT`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synapsor/dsl",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Preview SQL-like Synapsor authoring DSL compiler for canonical @synapsor/spec contracts.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  "package.json"
17
17
  ],
18
18
  "dependencies": {
19
- "@synapsor/spec": "^0.1.0"
19
+ "@synapsor/spec": "^0.1.1"
20
20
  },
21
21
  "devDependencies": {
22
22
  "typescript": "^5.7.0",
@@ -35,6 +35,15 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/Synapsor/Synapsor-Runner.git",
41
+ "directory": "packages/dsl"
42
+ },
43
+ "homepage": "https://github.com/Synapsor/Synapsor-Runner/tree/main/packages/dsl#readme",
44
+ "bugs": {
45
+ "url": "https://github.com/Synapsor/Synapsor-Runner/issues"
46
+ },
38
47
  "scripts": {
39
48
  "build": "tsc -b",
40
49
  "test": "vitest run"