@xtrape/capsule-contracts-node 0.3.0 → 0.5.0
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/NOTICE +3 -3
- package/README.md +68 -25
- package/dist/index.cjs +363 -59
- package/dist/index.d.cts +4963 -957
- package/dist/index.d.ts +4963 -957
- package/dist/index.js +310 -59
- package/package.json +4 -3
- package/spec/.source +1 -1
- package/spec/enums/audit-actions.json +2 -2
- package/spec/enums/id-prefixes.json +1 -1
- package/spec/enums/status-enums.json +2 -2
- package/spec/errors.json +2 -2
- package/spec/errors.md +1 -1
- package/spec/openapi/opstage-ce-v0.1.yaml +14 -14
- package/spec/worker-compatibility-v0.4.json +53 -0
package/NOTICE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright 2026 Xtrape
|
|
1
|
+
Xtrape Contracts for Node.js
|
|
2
|
+
Copyright 2026 Xtrape contributors
|
|
3
3
|
|
|
4
|
-
This product includes software developed by the Xtrape
|
|
4
|
+
This product includes software developed by the Xtrape contributors.
|
package/README.md
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Xtrape Contracts for Node.js
|
|
2
2
|
|
|
3
|
-
> TypeScript contracts and Zod schemas for Xtrape
|
|
3
|
+
> TypeScript contracts and Zod schemas for Xtrape Agent, Worker, and Panel wire
|
|
4
4
|
> protocols.
|
|
5
5
|
|
|
6
|
+
The npm name `@xtrape/capsule-contracts-node` is a legacy compatibility
|
|
7
|
+
identifier. `Capsule` is not a current Xtrape concept. New code should use the
|
|
8
|
+
canonical `Worker*` exports; the existing `Capsule*` exports and `services` wire
|
|
9
|
+
field remain available until a versioned protocol migration removes them.
|
|
10
|
+
|
|
6
11
|
[](./LICENSE)
|
|
7
12
|
[](https://xtrape-com.github.io/xtrape-capsule-site/)
|
|
8
13
|
[](https://xtrape-com.github.io/xtrape-capsule-site/contracts/overview)
|
|
9
14
|
|
|
10
|
-
`@xtrape/capsule-contracts-node` is the
|
|
11
|
-
|
|
15
|
+
`@xtrape/capsule-contracts-node` is the current published TypeScript contract
|
|
16
|
+
package for Panel CE, Agent SDKs, and Worker integrations. It exports Zod
|
|
12
17
|
schemas, inferred TypeScript types, enum values, ID helpers, pagination helpers,
|
|
13
18
|
and protocol error helpers for the Agent/Admin/System wire contracts.
|
|
14
19
|
|
|
15
|
-
> **Package status:** Xtrape
|
|
20
|
+
> **Package status:** Xtrape is currently in **Public Review** before
|
|
16
21
|
> the `v0.1.0 Public Preview` release. This package is **published to npm** under the
|
|
17
22
|
> `public-review` dist-tag. APIs, contracts, deployment instructions, and SDK
|
|
18
23
|
> interfaces may still change.
|
|
@@ -39,15 +44,28 @@ pnpm build
|
|
|
39
44
|
The package currently exports:
|
|
40
45
|
|
|
41
46
|
- Zod itself as `z` for consumers that want one compatible Zod instance.
|
|
42
|
-
- Status enum arrays and types: `AgentStatus`, `
|
|
47
|
+
- Status enum arrays and types: `AgentStatus`, `WorkerStatus` (plus the legacy
|
|
48
|
+
`CapsuleServiceStatus` alias),
|
|
43
49
|
`HealthStatus`, `CommandStatus`, `DangerLevel`, `AuditActorType`,
|
|
44
50
|
`AuditResult`, `TokenStatus`, `AgentMode`.
|
|
45
51
|
- Admin schemas: users, sessions, registration token requests/responses.
|
|
46
52
|
- Agent schemas: registration, heartbeat, service report, command result.
|
|
47
|
-
-
|
|
53
|
+
- Worker schemas: Worker Manifest, Worker Runtime Report, Worker Instance,
|
|
54
|
+
health, config, Action, and Worker Instance detail. Legacy
|
|
55
|
+
Capsule-named aliases remain available for wire compatibility.
|
|
48
56
|
- Command schemas: create command, command detail, command result.
|
|
49
57
|
- Audit and dashboard schemas.
|
|
50
58
|
- System health/version schemas.
|
|
59
|
+
|
|
60
|
+
The additive v0.4 Worker endpoint aliases and their legacy mappings are recorded
|
|
61
|
+
in `spec/worker-compatibility-v0.4.json`. The older CE v0.1 OpenAPI file remains
|
|
62
|
+
the historical baseline rather than being silently rewritten into a different
|
|
63
|
+
protocol version.
|
|
64
|
+
|
|
65
|
+
> **Known contract drift:** the historical structured sources still disagree on
|
|
66
|
+
> some Command and effective-status enum values. The `WorkerStatus` export is an
|
|
67
|
+
> alias of the currently shipped binding; it does not claim that the unresolved
|
|
68
|
+
> enum migration documented in `xtrape-docs` has been completed.
|
|
51
69
|
- Helpers: `parseSort`, `paginate`, `HttpError`, `ListQueryBase`.
|
|
52
70
|
|
|
53
71
|
## Validate Agent Registration
|
|
@@ -69,12 +87,12 @@ import { registerAgentRequestSchema } from "@xtrape/capsule-contracts-node";
|
|
|
69
87
|
const request = registerAgentRequestSchema.parse(input);
|
|
70
88
|
```
|
|
71
89
|
|
|
72
|
-
## v0.3
|
|
90
|
+
## v0.3 External-Agent Compatibility and Metadata
|
|
73
91
|
|
|
74
|
-
v0.3 adds the
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
92
|
+
v0.3 adds the legacy `ophub` Agent-mode wire value for the historical Go
|
|
93
|
+
external-Agent runtime. It represents one or more local Workers. It is not the
|
|
94
|
+
canonical Gateway role: Gateway routes Agent/control-plane traffic while
|
|
95
|
+
preserving Agent protocol semantics.
|
|
78
96
|
|
|
79
97
|
```ts
|
|
80
98
|
import { RegisterAgentRequestSchema, ServiceReportRequestSchema } from "@xtrape/capsule-contracts-node";
|
|
@@ -83,7 +101,7 @@ RegisterAgentRequestSchema.parse({
|
|
|
83
101
|
registrationToken: "opstage_reg_...",
|
|
84
102
|
agent: {
|
|
85
103
|
code: "ophub-a",
|
|
86
|
-
name: "
|
|
104
|
+
name: "External Agent A",
|
|
87
105
|
mode: "ophub",
|
|
88
106
|
runtime: "go",
|
|
89
107
|
},
|
|
@@ -112,7 +130,7 @@ ServiceReportRequestSchema.parse({
|
|
|
112
130
|
```
|
|
113
131
|
|
|
114
132
|
Capability metadata is implemented as declarative service metadata. Event
|
|
115
|
-
metadata is intentionally a foundation for future
|
|
133
|
+
metadata is intentionally a foundation for future legacy event routing work; `designOnly`
|
|
116
134
|
events must not be treated as a working event bus.
|
|
117
135
|
|
|
118
136
|
## Validate Service Report
|
|
@@ -169,7 +187,7 @@ Services:
|
|
|
169
187
|
- `DOWN`
|
|
170
188
|
- `UNKNOWN`
|
|
171
189
|
|
|
172
|
-
|
|
190
|
+
Xtrape Panel may derive an operator-facing `effectiveStatus` such as:
|
|
173
191
|
|
|
174
192
|
- `HEALTHY`
|
|
175
193
|
- `UNHEALTHY`
|
|
@@ -218,7 +236,7 @@ const prepare = ActionPrepareResultSchema.parse({
|
|
|
218
236
|
});
|
|
219
237
|
```
|
|
220
238
|
|
|
221
|
-
When reported back to
|
|
239
|
+
When reported back to Xtrape Panel for an `ACTION_PREPARE` command, this shape is
|
|
222
240
|
placed under `ReportCommandResultRequest.data`. Command result reporting still
|
|
223
241
|
uses `ReportCommandResultRequestSchema`:
|
|
224
242
|
|
|
@@ -285,6 +303,7 @@ Currently exported codes include:
|
|
|
285
303
|
- `FORBIDDEN`
|
|
286
304
|
- `NOT_FOUND`
|
|
287
305
|
- `CONFLICT`
|
|
306
|
+
- `CAPSULE_SERVICE_CODE_TAKEN` (persisted compatibility identifier for a Worker ownership conflict)
|
|
288
307
|
- `CSRF_INVALID`
|
|
289
308
|
- `ACTION_REQUIRES_CONFIRMATION`
|
|
290
309
|
- `COMMAND_EXPIRED`
|
|
@@ -334,21 +353,21 @@ const response = paginate(items, query.page, query.pageSize, total);
|
|
|
334
353
|
## Used By
|
|
335
354
|
|
|
336
355
|
- [`xtrape-capsule-ce`](https://github.com/xtrape-com/xtrape-capsule-ce) —
|
|
337
|
-
|
|
356
|
+
Xtrape Panel CE backend validation and protocol handling.
|
|
338
357
|
- [`xtrape-capsule-agent-node`](https://github.com/xtrape-com/xtrape-capsule-agent-node)
|
|
339
358
|
— Node embedded Agent SDK request/response types.
|
|
340
359
|
- [`xtrape-capsule-demo`](https://github.com/xtrape-com/xtrape-capsule-demo)
|
|
341
|
-
— End-to-end runnable
|
|
360
|
+
— End-to-end runnable Worker that imports these schemas through
|
|
342
361
|
the Agent SDK.
|
|
343
|
-
-
|
|
344
|
-
|
|
362
|
+
- Worker implementations that want local validation before reporting to
|
|
363
|
+
Xtrape Panel.
|
|
345
364
|
|
|
346
365
|
## Compatibility
|
|
347
366
|
|
|
348
367
|
| Package | Compatible with |
|
|
349
368
|
| -------------------------------------- | ---------------------------------------- |
|
|
350
|
-
| `@xtrape/capsule-contracts-node@0.2.x` |
|
|
351
|
-
| `@xtrape/capsule-contracts-node@0.1.x` |
|
|
369
|
+
| `@xtrape/capsule-contracts-node@0.2.x` | Xtrape Panel CE `0.2.x` and Agent SDK `0.2.x` |
|
|
370
|
+
| `@xtrape/capsule-contracts-node@0.1.x` | Xtrape Panel CE `0.1.x` and Agent SDK `0.1.x` |
|
|
352
371
|
|
|
353
372
|
Pin matching minor versions across CE, Agent SDK, and Contracts. The wire
|
|
354
373
|
protocol may still evolve before `v1.0`.
|
|
@@ -375,7 +394,7 @@ guarantees per schema group are:
|
|
|
375
394
|
| ---------------------------------------------------------------------------------------------------------------- | :---------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
376
395
|
| Status enums (`AgentStatus`, `CapsuleServiceStatus`, `HealthStatus`, `CommandStatus`, `DangerLevel`, `TokenStatus`) | Stable | New values may be added in minor versions; existing values will not be removed before `v1.0`. |
|
|
377
396
|
| Agent ↔ Backend wire schemas (`RegisterAgentRequest`, `AgentHeartbeat*`, `ServiceReport*`, `ReportCommandResult*`) | Evolving | Field shape is stable; additive optional fields may land in minor versions. Required fields will not be added before `v1.0` without a deprecation cycle. |
|
|
378
|
-
|
|
|
397
|
+
| Worker shapes (`WorkerManifest`, `WorkerRuntimeReport`, `WorkerInstance`, `HealthReportInput`, `ConfigItemInput`, `ActionDefinitionInput`) | Evolving | Legacy aliases retain the existing physical wire shapes. |
|
|
379
398
|
| Persisted shapes (`Agent`, `CapsuleService`, `ConfigItem`, `ActionDefinition`, `Command*`, `AuditEvent`, `User`) | Evolving | Track CE storage; safe to consume read-only. |
|
|
380
399
|
| `ActionPrepareResultSchema` | Provisional | Added in `0.1.0-public-review.0`. Field shape may still tighten before `v1.0`. |
|
|
381
400
|
| `Command.type` enum | Evolving | Currently `ACTION_PREPARE` / `ACTION_EXECUTE`. New types may be added. |
|
|
@@ -392,7 +411,7 @@ Breaking changes will be called out in `CHANGELOG.md`.
|
|
|
392
411
|
- Health contract: https://xtrape-com.github.io/xtrape-capsule-site/contracts/health
|
|
393
412
|
- Actions contract: https://xtrape-com.github.io/xtrape-capsule-site/contracts/actions
|
|
394
413
|
- Errors: https://xtrape-com.github.io/xtrape-capsule-site/contracts/errors
|
|
395
|
-
-
|
|
414
|
+
- Xtrape Panel CE: https://xtrape-com.github.io/xtrape-capsule-site/opstage-ce/overview
|
|
396
415
|
|
|
397
416
|
## Contributing
|
|
398
417
|
|
|
@@ -402,5 +421,29 @@ contract validation safety guidance.
|
|
|
402
421
|
|
|
403
422
|
## License
|
|
404
423
|
|
|
405
|
-
Apache-2.0. "Xtrape"
|
|
424
|
+
Apache-2.0. "Xtrape" and "Opstage" are trademarks of their
|
|
406
425
|
respective owners; the open-source license does not grant trademark rights.
|
|
426
|
+
|
|
427
|
+
## v0.4 legacy event routing Experimental
|
|
428
|
+
|
|
429
|
+
`v0.4` adds an experimental legacy event routing contract surface for CE's built-in SQLite-backed in-process event-to-command router. It is intentionally small, single-node, and disabled by default; it is **not** a standalone Bus Server, external broker (NATS / RabbitMQ / Redis Streams / Kafka), workflow DSL, or service mesh. No fan-out (`maxCommandsPerEvent`) in v0.4 — one matched route produces at most one `ACTION_EXECUTE` command.
|
|
430
|
+
|
|
431
|
+
Key exports:
|
|
432
|
+
|
|
433
|
+
- `BusEventEnvelopeSchema`
|
|
434
|
+
- `PublishBusEventRequestSchema`
|
|
435
|
+
- `PublishBusEventResponseSchema`
|
|
436
|
+
- `BusRouteRuleSchema`
|
|
437
|
+
- `CreateBusRouteRuleRequestSchema`
|
|
438
|
+
|
|
439
|
+
Minimal event payload:
|
|
440
|
+
|
|
441
|
+
```ts
|
|
442
|
+
BusEventEnvelopeSchema.parse({
|
|
443
|
+
eventType: "demo.item.created",
|
|
444
|
+
sourceServiceCode: "demo-worker",
|
|
445
|
+
payload: { itemId: "item-1" },
|
|
446
|
+
});
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
All schemas include or default `experimental: "v0.4-experimental"`; consumers should treat the wire surface as unstable until v1.0.
|