@dcdr/contracts 1.9.6
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.
- package/LICENSE +176 -0
- package/README.md +411 -0
- package/dist/capabilities.contract.d.ts +69 -0
- package/dist/capabilities.contract.d.ts.map +1 -0
- package/dist/capabilities.contract.js +126 -0
- package/dist/control.contract.d.ts +39 -0
- package/dist/control.contract.d.ts.map +1 -0
- package/dist/control.contract.js +2 -0
- package/dist/credentials.contract.d.ts +37 -0
- package/dist/credentials.contract.d.ts.map +1 -0
- package/dist/credentials.contract.js +15 -0
- package/dist/entitlements.contract.d.ts +107 -0
- package/dist/entitlements.contract.d.ts.map +1 -0
- package/dist/entitlements.contract.js +11 -0
- package/dist/errors.contract.d.ts +47 -0
- package/dist/errors.contract.d.ts.map +1 -0
- package/dist/errors.contract.js +48 -0
- package/dist/execution.contract.d.ts +240 -0
- package/dist/execution.contract.d.ts.map +1 -0
- package/dist/execution.contract.js +22 -0
- package/dist/http.contract.d.ts +20 -0
- package/dist/http.contract.d.ts.map +1 -0
- package/dist/http.contract.js +8 -0
- package/dist/implementations.contract.d.ts +120 -0
- package/dist/implementations.contract.d.ts.map +1 -0
- package/dist/implementations.contract.js +2 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/intent.contract.d.ts +137 -0
- package/dist/intent.contract.d.ts.map +1 -0
- package/dist/intent.contract.js +76 -0
- package/dist/logs.contract.d.ts +10 -0
- package/dist/logs.contract.d.ts.map +1 -0
- package/dist/logs.contract.js +2 -0
- package/dist/messages.contract.d.ts +16 -0
- package/dist/messages.contract.d.ts.map +1 -0
- package/dist/messages.contract.js +2 -0
- package/dist/policies.contract.d.ts +253 -0
- package/dist/policies.contract.d.ts.map +1 -0
- package/dist/policies.contract.js +283 -0
- package/dist/prompt-variable-schema.contract.d.ts +75 -0
- package/dist/prompt-variable-schema.contract.d.ts.map +1 -0
- package/dist/prompt-variable-schema.contract.js +572 -0
- package/dist/prompts.contract.d.ts +97 -0
- package/dist/prompts.contract.d.ts.map +1 -0
- package/dist/prompts.contract.js +87 -0
- package/dist/provider.contract.d.ts +477 -0
- package/dist/provider.contract.d.ts.map +1 -0
- package/dist/provider.contract.js +3310 -0
- package/dist/registry.stats.contract.d.ts +39 -0
- package/dist/registry.stats.contract.d.ts.map +1 -0
- package/dist/registry.stats.contract.js +9 -0
- package/dist/runtime.client.d.ts +362 -0
- package/dist/runtime.client.d.ts.map +1 -0
- package/dist/runtime.client.js +545 -0
- package/dist/service-tokens.contract.d.ts +29 -0
- package/dist/service-tokens.contract.d.ts.map +1 -0
- package/dist/service-tokens.contract.js +10 -0
- package/dist/session.contract.d.ts +51 -0
- package/dist/session.contract.d.ts.map +1 -0
- package/dist/session.contract.js +187 -0
- package/dist/subscription.contract.d.ts +37 -0
- package/dist/subscription.contract.d.ts.map +1 -0
- package/dist/subscription.contract.js +45 -0
- package/dist/utils.contract.d.ts +21 -0
- package/dist/utils.contract.d.ts.map +1 -0
- package/dist/utils.contract.js +79 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
# @dcdr/contracts
|
|
2
|
+
|
|
3
|
+
> ⚙️ Intent-based AI runtime + control plane for production systems
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@dcdr/contracts)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
|
|
9
|
+
DCDR runs AI capabilities as stable, versioned Intents (with configurable routing/retries) instead of hardcoding model calls in application code.
|
|
10
|
+
|
|
11
|
+
## Why DCDR
|
|
12
|
+
|
|
13
|
+
Most applications hardcode model calls, prompts, and retry logic directly in code — making changes slow and risky.
|
|
14
|
+
|
|
15
|
+
DCDR moves this into a versioned, configurable layer so you can:
|
|
16
|
+
|
|
17
|
+
- change models without redeploying
|
|
18
|
+
- iterate prompts safely
|
|
19
|
+
- control routing and fallback centrally
|
|
20
|
+
- use execution logs + QC workflows to review and correct outputs, enabling fast iteration on prompts and models based on real traffic
|
|
21
|
+
|
|
22
|
+
Learn more: <https://dcdr.ai>
|
|
23
|
+
|
|
24
|
+
## 💣 What problem does this solve?
|
|
25
|
+
|
|
26
|
+
Shipping AI to production hurts because:
|
|
27
|
+
|
|
28
|
+
- Models drift and outputs change without warning.
|
|
29
|
+
- Prompts and retries live in app code, so every fix needs a redeploy.
|
|
30
|
+
- Failures are hard to reproduce, diagnose, and roll back.
|
|
31
|
+
|
|
32
|
+
DCDR pulls this into a versioned runtime + Registry layer so you can change prompts/models/routing safely, add fallbacks, and debug real executions — without touching application deploys.
|
|
33
|
+
|
|
34
|
+
On top of that, every failure can be reviewed, corrected, and turned into training data for continuous improvement.
|
|
35
|
+
|
|
36
|
+
## What this package provides
|
|
37
|
+
|
|
38
|
+
- **Public TypeScript contracts** (interfaces/enums) for DCDR Registries and runtime API payloads.
|
|
39
|
+
- **`DcdrRuntimeClient`**: a strongly-typed TypeScript HTTP client for calling a DCDR Runtime instance.
|
|
40
|
+
|
|
41
|
+
## Who should use it
|
|
42
|
+
|
|
43
|
+
- Node.js / TypeScript applications that call the DCDR Runtime HTTP API.
|
|
44
|
+
- Tooling that reads/writes `registry.json` (Runtime (self-hosted)) and wants stable types.
|
|
45
|
+
|
|
46
|
+
## When to use it
|
|
47
|
+
|
|
48
|
+
- You want compile-time type safety for runtime requests/responses (for example `ExecuteIntentRequest` / `ExecuteIntentResponse`).
|
|
49
|
+
- You want stable types when authoring DCDR Registries and Intent definitions (`DcdrRegistry`, `IntentContract`, policies, implementations).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## ⚡ When should I use DCDR?
|
|
54
|
+
|
|
55
|
+
### Use DCDR if
|
|
56
|
+
|
|
57
|
+
- You need stable AI interfaces (intents)
|
|
58
|
+
- You want to decouple prompts from code
|
|
59
|
+
- You need retries, fallback, routing
|
|
60
|
+
- You need structured outputs (JSON enforcement)
|
|
61
|
+
|
|
62
|
+
### Do NOT use DCDR if
|
|
63
|
+
|
|
64
|
+
- You only need simple one-off OpenAI calls
|
|
65
|
+
- You don't need control over execution or quality
|
|
66
|
+
|
|
67
|
+
DCDR does not replace model providers (OpenAI, local models, etc.). It orchestrates how they are used.
|
|
68
|
+
|
|
69
|
+
### Fastest way to try it
|
|
70
|
+
|
|
71
|
+
- Run Runtime (self-hosted) with Docker
|
|
72
|
+
- Call a built-in demo intent (no API key required)
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 🧠 Mental model
|
|
77
|
+
|
|
78
|
+
- Your app calls an Intent.
|
|
79
|
+
- The runtime resolves configuration from the Registry.
|
|
80
|
+
- A prompt is rendered.
|
|
81
|
+
- An Implementation is selected.
|
|
82
|
+
- Execution + retries + fallback happen.
|
|
83
|
+
- A structured result is returned.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## ⚡ 30-second quickstart
|
|
88
|
+
|
|
89
|
+
Run a working intent in seconds, no API key required:
|
|
90
|
+
|
|
91
|
+
1. Run runtime container:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
docker run --rm -p 8000:8000 dcdrai/runtime:latest --demo
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
1. Call a built-in demo Intent:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
curl -sS -H 'Content-Type: application/json' \
|
|
101
|
+
-X POST http://localhost:8000/api/execution/demo/DCDR_LOCAL_DEMO \
|
|
102
|
+
-d '{"vars":{"name":"Ada"}}'
|
|
103
|
+
|
|
104
|
+
# Optional: remote demo (calls dcdr.ai; falls back to local if blocked)
|
|
105
|
+
curl -sS -H 'Content-Type: application/json' \
|
|
106
|
+
-X POST http://localhost:8000/api/execution/demo/DCDR_REMOTE_DEMO \
|
|
107
|
+
-d '{"vars":{"name":"Ada"}}'
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Choose your path
|
|
113
|
+
|
|
114
|
+
- **Smoke test (no tokens, no registry)** → [30-second quickstart](#-30-second-quickstart)
|
|
115
|
+
- **Self-hosted (registry.json + auth)** → [Quickstart (Docker runtime – registry.json setup)](#quickstart-docker-runtime--registryjson-setup)
|
|
116
|
+
- **Managed cloud (DCDR Cloud / Cloud Pro)** → [docs/PLATFORM_OVERVIEW.md](docs/PLATFORM_OVERVIEW.md)
|
|
117
|
+
- **TypeScript client only** → [Use the TypeScript client](#use-the-typescript-client)
|
|
118
|
+
- **Define intents / registry authoring** → [docs/CONTRACTS.md](docs/CONTRACTS.md)
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Table of contents
|
|
123
|
+
|
|
124
|
+
- [When should I use DCDR?](#-when-should-i-use-dcdr)
|
|
125
|
+
- [30-second quickstart](#-30-second-quickstart)
|
|
126
|
+
- [Quickstart (Docker runtime – registry.json setup)](#quickstart-docker-runtime--registryjson-setup)
|
|
127
|
+
- [Use the TypeScript client](#use-the-typescript-client)
|
|
128
|
+
- [Common patterns (recipes)](#-common-patterns-recipes)
|
|
129
|
+
- [More docs](#more-docs)
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Quickstart (Docker runtime – registry.json setup)
|
|
134
|
+
|
|
135
|
+
This quickstart is for **Runtime (self-hosted)** with a local `registry.json`.
|
|
136
|
+
|
|
137
|
+
Notes
|
|
138
|
+
|
|
139
|
+
- This is a production-oriented setup: `/api/execution/*` endpoints require auth + session.
|
|
140
|
+
- If you only want to confirm the runtime works (no tokens, no registry), use the [30-second quickstart](#-30-second-quickstart) with `--demo`.
|
|
141
|
+
|
|
142
|
+
If you are using **Cloud** or **Cloud Pro**, skip this section and see [docs/PLATFORM_OVERVIEW.md](docs/PLATFORM_OVERVIEW.md).
|
|
143
|
+
|
|
144
|
+
Docker image:
|
|
145
|
+
|
|
146
|
+
- `dcdrai/runtime:latest`
|
|
147
|
+
|
|
148
|
+
### 1) Create a local `registry.json` (HELLO_WORLD)
|
|
149
|
+
|
|
150
|
+
Copy the example file and edit it:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
cp ./src/contracts/examples/registry.hello_world.json ./registry.json
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Then replace:
|
|
157
|
+
|
|
158
|
+
- `REPLACE_ME_OPENAI_API_KEY` → your real OpenAI API key
|
|
159
|
+
|
|
160
|
+
This example includes:
|
|
161
|
+
|
|
162
|
+
- 1 intent (`HELLO_WORLD`)
|
|
163
|
+
- 2 implementations (same provider `OPEN_AI`, two models)
|
|
164
|
+
- `executionPolicy.type = WEIGHTED` and implementation `weight` values (conventionally **0..1**, but any positive numbers work)
|
|
165
|
+
- OpenAI `endpoint` set to **`https://api.openai.com/v1`** (base URL)
|
|
166
|
+
|
|
167
|
+
### 2) Run the runtime container
|
|
168
|
+
|
|
169
|
+
#### Windows PowerShell
|
|
170
|
+
|
|
171
|
+
```powershell
|
|
172
|
+
docker pull dcdrai/runtime:latest
|
|
173
|
+
docker run --rm -p 8000:8000 `
|
|
174
|
+
-e API_TOKEN='dev-token' `
|
|
175
|
+
-e SESSION_BYPASS_TOKEN='dev-session-bypass' `
|
|
176
|
+
-v "${PWD}/registry.json:/data/registry.json:ro" `
|
|
177
|
+
dcdrai/runtime:latest --registry /data/registry.json
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### Linux / macOS
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
docker pull dcdrai/runtime:latest
|
|
184
|
+
docker run --rm -p 8000:8000 \
|
|
185
|
+
-e API_TOKEN='dev-token' \
|
|
186
|
+
-e SESSION_BYPASS_TOKEN='dev-session-bypass' \
|
|
187
|
+
-v "$PWD/registry.json:/data/registry.json:ro" \
|
|
188
|
+
dcdrai/runtime:latest --registry /data/registry.json
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 3) Call the runtime (curl)
|
|
192
|
+
|
|
193
|
+
Healthcheck:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
curl -sS -H 'token: dev-token' http://localhost:8000/api/system/healthcheck
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Execute the `HELLO_WORLD` intent:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
curl -sS \
|
|
203
|
+
-H 'Content-Type: application/json' \
|
|
204
|
+
-H 'token: dev-token' \
|
|
205
|
+
-H 'x-session-bypass: dev-session-bypass' \
|
|
206
|
+
-X POST http://localhost:8000/api/execution/run/HELLO_WORLD \
|
|
207
|
+
-d '{"vars":{"name":"Ada"}}'
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### 4) Swagger / OpenAPI
|
|
211
|
+
|
|
212
|
+
- Swagger UI: `http://localhost:8000/api/docs`
|
|
213
|
+
- OpenAPI JSON: `http://localhost:8000/api/openapi.json`
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Use the TypeScript client
|
|
218
|
+
|
|
219
|
+
### Client config & auth modes
|
|
220
|
+
|
|
221
|
+
`DcdrRuntimeClient` supports two auth modes:
|
|
222
|
+
|
|
223
|
+
- **Customer mode (Cloud; also Cloud Pro)**: `bearerToken` → sends `Authorization: Bearer <DcdrSessionToken>`
|
|
224
|
+
- You obtain the `DcdrSessionToken` in Cloud.
|
|
225
|
+
- **Internal/dev mode (Runtime (self-hosted))**: `apiToken` → sends `token: <token>`
|
|
226
|
+
- Note: `/api/execution/*` endpoints require a session. For dev/testing you can set `SESSION_BYPASS_TOKEN` on the runtime and pass `sessionBypassToken` in the client (sends `x-session-bypass`).
|
|
227
|
+
|
|
228
|
+
Install (in a Node/TS app):
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
npm i @dcdr/contracts
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Example (internal/dev mode):
|
|
235
|
+
|
|
236
|
+
```ts
|
|
237
|
+
import { DcdrRuntimeClient } from "@dcdr/contracts/runtime.client";
|
|
238
|
+
|
|
239
|
+
const client = new DcdrRuntimeClient({
|
|
240
|
+
baseUrl: "http://localhost:8000",
|
|
241
|
+
apiToken: "dev-token",
|
|
242
|
+
sessionBypassToken: "dev-session-bypass",
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const health = await client.healthcheck();
|
|
246
|
+
const res = await client.executeIntent("HELLO_WORLD", {
|
|
247
|
+
vars: { name: "Ada" },
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
console.log(health.status);
|
|
251
|
+
console.log(res.status, res.output);
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Example (customer mode / live):
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
import { DcdrRuntimeClient } from "@dcdr/contracts/runtime.client";
|
|
258
|
+
|
|
259
|
+
const client = new DcdrRuntimeClient({
|
|
260
|
+
// baseUrl defaults to https://runtime.dcdr.ai
|
|
261
|
+
bearerToken: process.env.DCDR_SESSION_TOKEN,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// 1) Verify token is accepted (recommended during setup/debugging)
|
|
265
|
+
const auth = await client.authCheck();
|
|
266
|
+
console.log(auth.valid, auth.authMode, auth.cid);
|
|
267
|
+
|
|
268
|
+
// 2) Execute your first Intent (must exist in your Registry)
|
|
269
|
+
const res = await client.executeIntent("MY_FIRST_INTENT", {
|
|
270
|
+
vars: { topic: "hello", language: "es" },
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
console.log(res.status, res.output);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Full client reference: [docs/CLIENT.md](docs/CLIENT.md)
|
|
277
|
+
|
|
278
|
+
Prometheus metrics: [docs/PROMETHEUS_METRICS.md](docs/PROMETHEUS_METRICS.md)
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 🧪 Common patterns (recipes)
|
|
283
|
+
|
|
284
|
+
### 1) Strict JSON output Intent
|
|
285
|
+
|
|
286
|
+
Use this pattern when you need guaranteed machine-readable outputs.
|
|
287
|
+
|
|
288
|
+
```json
|
|
289
|
+
{
|
|
290
|
+
"id": "INTENT_ID",
|
|
291
|
+
"intent": "FORMAT_PARSER",
|
|
292
|
+
"type": "CHAT",
|
|
293
|
+
"active": true,
|
|
294
|
+
"outputSchema": {
|
|
295
|
+
"result": { "type": "string", "required": true }
|
|
296
|
+
},
|
|
297
|
+
"defaultPrompt": {
|
|
298
|
+
"id": "PROMPT_ID",
|
|
299
|
+
"version": "v1",
|
|
300
|
+
"name": "format-parser",
|
|
301
|
+
"sha256": "PROMPT_SHA256",
|
|
302
|
+
"semanticHash": "PROMPT_SEMANTIC_HASH",
|
|
303
|
+
"messages": [
|
|
304
|
+
{ "role": "system", "content": "Return JSON only." },
|
|
305
|
+
{ "role": "user", "content": "Input: {{text}}" }
|
|
306
|
+
],
|
|
307
|
+
"variablesInterpolationType": "MUSTACHE",
|
|
308
|
+
"params": { "response_format": "json_schema" }
|
|
309
|
+
},
|
|
310
|
+
"retryPolicy": {
|
|
311
|
+
"maxAttempts": 3,
|
|
312
|
+
"allowFallback": true,
|
|
313
|
+
"repairOnParseFail": true,
|
|
314
|
+
"retryOn": ["PARSE_FAIL", "SCHEMA_FAIL"]
|
|
315
|
+
},
|
|
316
|
+
"implementations": [
|
|
317
|
+
{
|
|
318
|
+
"id": "IMPL_ID",
|
|
319
|
+
"provider": "OPEN_AI",
|
|
320
|
+
"name": "openai-format-parser",
|
|
321
|
+
"version": "v1",
|
|
322
|
+
"sha256": "IMPL_SHA256",
|
|
323
|
+
"semanticHash": "IMPL_SEMANTIC_HASH",
|
|
324
|
+
"model": "gpt-4.1-mini",
|
|
325
|
+
"endpoint": "https://api.openai.com/v1",
|
|
326
|
+
"active": true
|
|
327
|
+
}
|
|
328
|
+
]
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### 2) Weighted routing across two models
|
|
333
|
+
|
|
334
|
+
```json
|
|
335
|
+
{
|
|
336
|
+
"executionPolicy": { "type": "WEIGHTED" },
|
|
337
|
+
"implementations": [
|
|
338
|
+
{
|
|
339
|
+
"id": "IMPL_PRIMARY",
|
|
340
|
+
"provider": "OPEN_AI",
|
|
341
|
+
"name": "primary",
|
|
342
|
+
"version": "v1",
|
|
343
|
+
"sha256": "IMPL_SHA256_1",
|
|
344
|
+
"semanticHash": "IMPL_SEMANTIC_HASH_1",
|
|
345
|
+
"model": "gpt-4.1-mini",
|
|
346
|
+
"endpoint": "https://api.openai.com/v1",
|
|
347
|
+
"active": true,
|
|
348
|
+
"weight": 0.7
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
"id": "IMPL_SECONDARY",
|
|
352
|
+
"provider": "OPEN_AI",
|
|
353
|
+
"name": "secondary",
|
|
354
|
+
"version": "v1",
|
|
355
|
+
"sha256": "IMPL_SHA256_2",
|
|
356
|
+
"semanticHash": "IMPL_SEMANTIC_HASH_2",
|
|
357
|
+
"model": "gpt-4.1",
|
|
358
|
+
"endpoint": "https://api.openai.com/v1",
|
|
359
|
+
"active": true,
|
|
360
|
+
"weight": 0.3
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### 3) Debugging Intent rendering (`dryRun`)
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
curl -sS \
|
|
370
|
+
-H 'Content-Type: application/json' \
|
|
371
|
+
-H 'token: dev-token' \
|
|
372
|
+
-X POST http://localhost:8000/api/execution/dry-run/HELLO_WORLD \
|
|
373
|
+
-d '{"vars":{"name":"Ada"}}'
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Shows rendered messages and resolved execution configuration, without calling an external provider.
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## ⚙️ Introduction to execution modes
|
|
381
|
+
|
|
382
|
+
- Runtime (self-hosted): you run the runtime; you manage the Registry in `registry.json`.
|
|
383
|
+
- Cloud: managed runtime + managed Registry/configuration.
|
|
384
|
+
- Cloud Pro: Cloud + Cloud Pro entitlements.
|
|
385
|
+
|
|
386
|
+
See full feature matrix: [docs/TIERS_FEATURE_MATRIX.md](docs/TIERS_FEATURE_MATRIX.md)
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## More docs
|
|
391
|
+
|
|
392
|
+
### Core concepts
|
|
393
|
+
|
|
394
|
+
- [docs/CONTRACTS.md](docs/CONTRACTS.md) — How Registries, Intents, implementations, policies, and capabilities fit together.
|
|
395
|
+
- [docs/PLATFORM_OVERVIEW.md](docs/PLATFORM_OVERVIEW.md) — Runtime (self-hosted) vs Cloud vs Cloud Pro (what runs where, who owns what).
|
|
396
|
+
- [docs/TIERS_FEATURE_MATRIX.md](docs/TIERS_FEATURE_MATRIX.md) — One-page feature/tier reference.
|
|
397
|
+
|
|
398
|
+
### Development
|
|
399
|
+
|
|
400
|
+
- [docs/CLIENT.md](docs/CLIENT.md) — Full `DcdrRuntimeClient` reference (methods, auth options, errors).
|
|
401
|
+
- [docs/EXECUTION_ERROR_CODES.md](docs/EXECUTION_ERROR_CODES.md) — Stable runtime execution error codes and their meanings.
|
|
402
|
+
- [docs/CLI.md](docs/CLI.md) — CLI usage patterns (healthcheck, run, demo, dry-run).
|
|
403
|
+
- [docs/STREAMING_EXECUTION_SSE.md](docs/STREAMING_EXECUTION_SSE.md) — Streaming intent execution over SSE (`/api/execution/stream/:intent`).
|
|
404
|
+
- [docs/RUNTIME_ADVANCED_CONFIG.md](docs/RUNTIME_ADVANCED_CONFIG.md) — Runtime (self-hosted) env vars (SSL/HTTPS, networking, auth, logs, metrics).
|
|
405
|
+
|
|
406
|
+
### Integrations
|
|
407
|
+
|
|
408
|
+
- [docs/OPENAPI_SDKS.md](docs/OPENAPI_SDKS.md) — Generate Python/C#/Java SDKs from `openapi.runtime.json`.
|
|
409
|
+
- [docs/PROMETHEUS_METRICS.md](docs/PROMETHEUS_METRICS.md) — Metrics endpoint + the Prometheus gauges/counters we expose.
|
|
410
|
+
- [docs/EXAMPLES.md](docs/EXAMPLES.md) — End-to-end examples and small recipes.
|
|
411
|
+
- [CHANGELOG.md](CHANGELOG.md) — Release notes (synced from the runtime repo changelog; entries start with <kbd>RUNTIME</kbd> / <kbd>CONTRACTS</kbd>).
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { DcdrRegistry } from "./control.contract";
|
|
2
|
+
import { IntentContract } from "./intent.contract";
|
|
3
|
+
/**
|
|
4
|
+
* Stable, public capability identifiers derived from configuration/registry usage.
|
|
5
|
+
*
|
|
6
|
+
* Purpose
|
|
7
|
+
* - Provide a single, exportable vocabulary to describe what a given registry/config *requires*.
|
|
8
|
+
* - Enable:
|
|
9
|
+
* - Freeware runtime (`runtime` mode) to reject advanced features (allowlist).
|
|
10
|
+
* - Backend tier enforcement to map subscriptions/features to required runtime capabilities.
|
|
11
|
+
*
|
|
12
|
+
* Notes
|
|
13
|
+
* - These are *technical* capabilities, not billing/subscription concepts.
|
|
14
|
+
* - Keep values stable; they can become part of wire-level compatibility checks.
|
|
15
|
+
*/
|
|
16
|
+
export declare enum CapabilityKey {
|
|
17
|
+
/** Prompt canary rollouts (canary prompt + weight). */
|
|
18
|
+
AI_PROMPTS_CANARY = "AI_PROMPTS_CANARY",
|
|
19
|
+
/** Any non-default/advanced execution policy (non-WEIGHTED). */
|
|
20
|
+
AI_INTENTS_ADVANCED_EXECUTION_POLICY = "AI_INTENTS_ADVANCED_EXECUTION_POLICY",
|
|
21
|
+
/** ExecutionPolicy exploration enabled (epsilon-greedy / top-K sampling). */
|
|
22
|
+
AI_INTENTS_EXPLORATION_POLICY = "AI_INTENTS_EXPLORATION_POLICY",
|
|
23
|
+
/** Response caching enabled with per-implementation TTL configuration. */
|
|
24
|
+
AI_RUNTIME_CACHE_TTL_CONFIGURABLE = "AI_RUNTIME_CACHE_TTL_CONFIGURABLE",
|
|
25
|
+
/** Execution window override at the implementation level. */
|
|
26
|
+
AI_BASE_MODEL_EXECUTION_WINDOWS_OVERRIDE_PER_IMPLEMENTATION = "AI_BASE_MODEL_EXECUTION_WINDOWS_OVERRIDE_PER_IMPLEMENTATION",
|
|
27
|
+
/** Backend registry sync (cloud/cloud-pro control plane). */
|
|
28
|
+
AI_RUNTIME_BACKEND_REGISTRY_SYNC = "AI_RUNTIME_BACKEND_REGISTRY_SYNC",
|
|
29
|
+
/** Backend log ingestion (cloud/cloud-pro; runtime/freeware should not send logs to backend). */
|
|
30
|
+
AI_OBSERVABILITY_BACKEND_LOG_INGESTION = "AI_OBSERVABILITY_BACKEND_LOG_INGESTION",
|
|
31
|
+
/** Internal backend bypass auth mode (backend-to-runtime trusted traffic). */
|
|
32
|
+
AI_SECURITY_INTERNAL_BYPASS = "AI_SECURITY_INTERNAL_BYPASS"
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Extracts required capabilities for a single intent.
|
|
36
|
+
* @param intent The intent contract to inspect.
|
|
37
|
+
* @returns Required capabilities for this intent.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getRequiredCapabilitiesForIntent(intent: IntentContract): CapabilityKey[];
|
|
40
|
+
/**
|
|
41
|
+
* Derives the set of required capabilities implied by a registry.
|
|
42
|
+
*
|
|
43
|
+
* Intended usage
|
|
44
|
+
* - Runtime freeware mode: compare with an allowlist and fail loudly when unsupported.
|
|
45
|
+
* - Backend: map subscription/module-features to capabilities and enforce before emitting a registry.
|
|
46
|
+
*
|
|
47
|
+
* @param registry The registry to inspect.
|
|
48
|
+
* @returns Unique capability keys required by the registry.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getRequiredCapabilitiesFromRegistry(registry: DcdrRegistry): CapabilityKey[];
|
|
51
|
+
/**
|
|
52
|
+
* Returns the capabilities that are required but not present in the allowlist.
|
|
53
|
+
* @param required Required capabilities.
|
|
54
|
+
* @param allowed Allowed capabilities.
|
|
55
|
+
* @returns Missing capabilities.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getMissingCapabilities(required: CapabilityKey[], allowed: CapabilityKey[]): CapabilityKey[];
|
|
58
|
+
/**
|
|
59
|
+
* Asserts that all required capabilities are in the allowlist.
|
|
60
|
+
*
|
|
61
|
+
* Intended usage
|
|
62
|
+
* - Freeware runtime mode: reject registries/configurations that require pro/cloud capabilities.
|
|
63
|
+
*
|
|
64
|
+
* @param required Required capabilities.
|
|
65
|
+
* @param allowed Allowed capabilities.
|
|
66
|
+
* @param context Optional context string included in error messages.
|
|
67
|
+
*/
|
|
68
|
+
export declare function assertCapabilitiesAllowed(required: CapabilityKey[], allowed: CapabilityKey[], context?: string): void;
|
|
69
|
+
//# sourceMappingURL=capabilities.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.contract.d.ts","sourceRoot":"","sources":["../src/capabilities.contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD;;;;;;;;;;;;GAYG;AACH,oBAAY,aAAa;IACvB,uDAAuD;IACvD,iBAAiB,sBAAsB;IAEvC,gEAAgE;IAChE,oCAAoC,yCAAyC;IAE7E,6EAA6E;IAC7E,6BAA6B,kCAAkC;IAE/D,0EAA0E;IAC1E,iCAAiC,sCAAsC;IAEvE,6DAA6D;IAC7D,2DAA2D,gEAAgE;IAM3H,6DAA6D;IAC7D,gCAAgC,qCAAqC;IAErE,iGAAiG;IACjG,sCAAsC,2CAA2C;IAEjF,8EAA8E;IAC9E,2BAA2B,gCAAgC;CAC5D;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,cAAc,GAAG,aAAa,EAAE,CA+BxF;AAED;;;;;;;;;GASG;AACH,wBAAgB,mCAAmC,CAAC,QAAQ,EAAE,YAAY,GAAG,aAAa,EAAE,CAW3F;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE,CAS3G;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAMrH"}
|