@capabilityhostprotocol/types 0.1.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/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # @chp/types
2
+
3
+ TypeScript protocol types for CHP v0.1.
4
+
5
+ ## Overview
6
+
7
+ CHP v0.1 makes capability execution visible, replayable, and ready for governance. The package root exports only the schema-aligned v0.1 protocol types and mirrors the JSON Schemas in `schemas/`.
8
+
9
+ The root export is the public v0.1 protocol surface. It does not expose the
10
+ older internal mesh/governance model.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @chp/types
16
+ # or
17
+ pnpm add @chp/types
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```typescript
23
+ import type {
24
+ CapabilityDescriptor,
25
+ CorrelationContext,
26
+ ExecutionEvidence,
27
+ HostDescriptor,
28
+ InvocationEnvelope,
29
+ InvocationResult,
30
+ ReplayResult,
31
+ } from '@chp/types';
32
+ ```
33
+
34
+ ```typescript
35
+ const correlation: CorrelationContext = {
36
+ correlation_id: 'corr_123',
37
+ };
38
+
39
+ const descriptor: CapabilityDescriptor = {
40
+ id: 'example.search_information',
41
+ version: '0.1.0',
42
+ description: 'Search for information.',
43
+ modes: ['sync'],
44
+ emits: ['execution_started', 'execution_completed', 'execution_failed'],
45
+ };
46
+ ```
47
+
48
+ Use the schema names for v0.1 integrations:
49
+
50
+ - `CapabilityDescriptor`
51
+ - `HostDescriptor`
52
+ - `InvocationEnvelope`
53
+ - `InvocationResult`
54
+ - `ExecutionEvidence`
55
+ - `CorrelationContext`
56
+ - `ReplayQuery`
57
+ - `ReplayResult`
58
+
59
+ ## Legacy Usage
60
+
61
+ Older internal mesh/governance helper types are available from the explicit
62
+ legacy subpath while internal systems migrate:
63
+
64
+ ```typescript
65
+ import {
66
+ createEvidence,
67
+ createGovernedContext,
68
+ createSubjectContext,
69
+ type Evidence,
70
+ type RiskClass,
71
+ type AssuranceTier,
72
+ } from '@chp/types/legacy';
73
+
74
+ // Create a subject
75
+ const subject = createSubjectContext({
76
+ subject_id: 'user-123',
77
+ subject_type: 'user',
78
+ entitlements: ['payment.process', 'user.read'],
79
+ });
80
+
81
+ // Create governed context
82
+ const ctx = createGovernedContext({
83
+ capability_id: 'payment.process:1.0.0',
84
+ subject,
85
+ governance_mode: 'enforce',
86
+ risk_class: 'high',
87
+ minimum_tier: 'S2',
88
+ });
89
+
90
+ // Emit evidence
91
+ const evidence = createEvidence({
92
+ evidence_type: 'execution_completed',
93
+ capability_id: ctx.capability_id,
94
+ subject_id: subject.subject_id,
95
+ correlation_id: ctx.correlation_id,
96
+ assurance_tier: 'S2',
97
+ payload: { amount: 100.00, currency: 'USD' },
98
+ });
99
+ ```
100
+
101
+ ## Type Correspondence
102
+
103
+ | CHP v0.1 Concept | Python `chp_core` | TypeScript `@chp/types` |
104
+ |---|---|---|
105
+ | Capability descriptor | `CapabilityDescriptor` | `CapabilityDescriptor` |
106
+ | Host descriptor | `HostDescriptor` | `HostDescriptor` |
107
+ | Invocation envelope | `InvocationEnvelope` | `InvocationEnvelope` |
108
+ | Invocation result | `InvocationResult` | `InvocationResult` |
109
+ | Execution evidence | `ExecutionEvidence` | `ExecutionEvidence` |
110
+ | Correlation context | `CorrelationContext` | `CorrelationContext` |
111
+ | Replay query | `ReplayQuery` | `ReplayQuery` |
112
+ | Replay result | `ReplayResult` | `ReplayResult` |
113
+
114
+ ## Verification
115
+
116
+ ```bash
117
+ npm run typecheck --workspace @chp/types
118
+ npm run build --workspace @chp/types
119
+ ```
120
+
121
+ ## License
122
+
123
+ Apache-2.0. See [LICENSE](../../LICENSE).
@@ -0,0 +1,150 @@
1
+ /**
2
+ * CHP v0.1 protocol types.
3
+ *
4
+ * These interfaces mirror the JSON Schemas in the repository root `schemas/`
5
+ * directory. They are intentionally transport-neutral and do not depend on the
6
+ * older mesh/governance TypeScript model in this package.
7
+ */
8
+ declare const CHP_V0_1_VERSION: "0.1";
9
+ type JsonPrimitive = string | number | boolean | null;
10
+ type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
11
+ interface JsonObject {
12
+ [key: string]: JsonValue;
13
+ }
14
+ type CapabilityRisk = "low" | "medium" | "high" | "critical";
15
+ type ChpV01InvocationMode = "sync" | "async" | "stream" | "fire_and_forget";
16
+ type ChpV01ExecutionOutcome = "success" | "failure" | "denied" | "skipped";
17
+ type AssuranceLevel = "S1" | "S2" | "S3";
18
+ type InvariantEnforcement = "declarative" | "host" | "runtime";
19
+ type InvariantFailureBehavior = "deny" | "warn" | "degrade";
20
+ declare const CHP_V0_1_OUTCOMES: readonly ["success", "failure", "denied", "skipped"];
21
+ declare const CHP_V0_1_CORE_EVIDENCE_TYPES: readonly ["execution_started", "execution_completed", "execution_failed", "execution_denied", "execution_skipped"];
22
+ interface AssuranceMetadata {
23
+ level: AssuranceLevel;
24
+ evidence_policy?: string;
25
+ notes?: string[];
26
+ }
27
+ interface InvariantDescriptor {
28
+ id: string;
29
+ kind: string;
30
+ description?: string;
31
+ enforcement?: InvariantEnforcement;
32
+ failure_behavior?: InvariantFailureBehavior;
33
+ parameters?: JsonObject;
34
+ }
35
+ interface CapabilityDescriptor {
36
+ id: string;
37
+ version: string;
38
+ capability_uri?: string;
39
+ description: string;
40
+ modes: ChpV01InvocationMode[];
41
+ input_schema?: JsonObject;
42
+ output_schema?: JsonObject;
43
+ invariants?: InvariantDescriptor[];
44
+ emits: string[];
45
+ owner?: string | null;
46
+ tags?: string[];
47
+ risk?: CapabilityRisk;
48
+ assurance?: AssuranceMetadata;
49
+ metadata?: JsonObject;
50
+ }
51
+ interface HostDescriptor {
52
+ id: string;
53
+ version: string;
54
+ protocol_version: typeof CHP_V0_1_VERSION;
55
+ kind: string;
56
+ capabilities: CapabilityDescriptor[];
57
+ evidence: {
58
+ store: string;
59
+ append_only: boolean;
60
+ [key: string]: JsonValue;
61
+ };
62
+ metadata?: JsonObject;
63
+ }
64
+ interface CorrelationContext {
65
+ correlation_id: string;
66
+ causation_id?: string | null;
67
+ parent_correlation_id?: string | null;
68
+ trace_id?: string | null;
69
+ baggage?: Record<string, JsonPrimitive>;
70
+ }
71
+ interface InvocationEnvelope {
72
+ invocation_id: string;
73
+ capability_id: string;
74
+ version?: string | null;
75
+ mode: ChpV01InvocationMode;
76
+ correlation: CorrelationContext;
77
+ subject: JsonObject;
78
+ payload: JsonObject;
79
+ requested_at: string;
80
+ metadata?: JsonObject;
81
+ }
82
+ interface DenialReason {
83
+ code: string;
84
+ message: string;
85
+ invariant_id?: string | null;
86
+ retryable: boolean;
87
+ details?: JsonObject;
88
+ }
89
+ interface InvocationResult {
90
+ invocation_id: string;
91
+ capability_id: string;
92
+ capability_version?: string | null;
93
+ correlation: CorrelationContext;
94
+ outcome: ChpV01ExecutionOutcome;
95
+ success: boolean;
96
+ data?: JsonValue;
97
+ error?: JsonObject | null;
98
+ denial?: DenialReason | null;
99
+ evidence_ids: string[];
100
+ started_at?: string | null;
101
+ completed_at: string;
102
+ }
103
+ interface ExecutionEvidence {
104
+ event_id: string;
105
+ event_type: string;
106
+ invocation_id: string;
107
+ capability_id: string;
108
+ capability_version?: string | null;
109
+ host_id: string;
110
+ correlation: CorrelationContext;
111
+ timestamp: string;
112
+ sequence: number;
113
+ outcome?: ChpV01ExecutionOutcome | null;
114
+ payload: JsonObject;
115
+ redacted: boolean;
116
+ error?: JsonObject | null;
117
+ denial?: DenialReason | null;
118
+ assurance: AssuranceMetadata;
119
+ }
120
+ interface ReplayQuery {
121
+ correlation_id: string;
122
+ limit?: number | null;
123
+ since_sequence?: number | null;
124
+ include_payloads?: boolean;
125
+ }
126
+ interface ReplayResult {
127
+ correlation_id: string;
128
+ events: ExecutionEvidence[];
129
+ event_count: number;
130
+ replayed_at: string;
131
+ }
132
+ declare function capabilityUri(descriptor: Pick<CapabilityDescriptor, "id" | "version">): string;
133
+ declare function isChpV01Outcome(value: string): value is ChpV01ExecutionOutcome;
134
+
135
+ /**
136
+ * Public TypeScript types for CHP v0.1.
137
+ *
138
+ * The root export is intentionally limited to the open-source protocol surface
139
+ * described by `spec/chp-v0.1.md` and the JSON Schemas in `schemas/`.
140
+ *
141
+ * Internal legacy mesh/governance helpers are available from
142
+ * `@auxo/ts-types/legacy`.
143
+ *
144
+ * @packageDocumentation
145
+ */
146
+
147
+ declare const CHP_VERSION = "0.1";
148
+ declare const VERSION = "0.1.0";
149
+
150
+ export { type AssuranceLevel, type AssuranceMetadata, CHP_V0_1_CORE_EVIDENCE_TYPES, CHP_V0_1_OUTCOMES, CHP_V0_1_VERSION, CHP_VERSION, type CapabilityDescriptor, type CapabilityRisk, type ChpV01ExecutionOutcome, type ChpV01InvocationMode, type CorrelationContext, type DenialReason, type ExecutionEvidence, type HostDescriptor, type InvariantDescriptor, type InvariantEnforcement, type InvariantFailureBehavior, type InvocationEnvelope, type InvocationResult, type JsonObject, type JsonPrimitive, type JsonValue, type ReplayQuery, type ReplayResult, VERSION, capabilityUri, isChpV01Outcome };
@@ -0,0 +1,150 @@
1
+ /**
2
+ * CHP v0.1 protocol types.
3
+ *
4
+ * These interfaces mirror the JSON Schemas in the repository root `schemas/`
5
+ * directory. They are intentionally transport-neutral and do not depend on the
6
+ * older mesh/governance TypeScript model in this package.
7
+ */
8
+ declare const CHP_V0_1_VERSION: "0.1";
9
+ type JsonPrimitive = string | number | boolean | null;
10
+ type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
11
+ interface JsonObject {
12
+ [key: string]: JsonValue;
13
+ }
14
+ type CapabilityRisk = "low" | "medium" | "high" | "critical";
15
+ type ChpV01InvocationMode = "sync" | "async" | "stream" | "fire_and_forget";
16
+ type ChpV01ExecutionOutcome = "success" | "failure" | "denied" | "skipped";
17
+ type AssuranceLevel = "S1" | "S2" | "S3";
18
+ type InvariantEnforcement = "declarative" | "host" | "runtime";
19
+ type InvariantFailureBehavior = "deny" | "warn" | "degrade";
20
+ declare const CHP_V0_1_OUTCOMES: readonly ["success", "failure", "denied", "skipped"];
21
+ declare const CHP_V0_1_CORE_EVIDENCE_TYPES: readonly ["execution_started", "execution_completed", "execution_failed", "execution_denied", "execution_skipped"];
22
+ interface AssuranceMetadata {
23
+ level: AssuranceLevel;
24
+ evidence_policy?: string;
25
+ notes?: string[];
26
+ }
27
+ interface InvariantDescriptor {
28
+ id: string;
29
+ kind: string;
30
+ description?: string;
31
+ enforcement?: InvariantEnforcement;
32
+ failure_behavior?: InvariantFailureBehavior;
33
+ parameters?: JsonObject;
34
+ }
35
+ interface CapabilityDescriptor {
36
+ id: string;
37
+ version: string;
38
+ capability_uri?: string;
39
+ description: string;
40
+ modes: ChpV01InvocationMode[];
41
+ input_schema?: JsonObject;
42
+ output_schema?: JsonObject;
43
+ invariants?: InvariantDescriptor[];
44
+ emits: string[];
45
+ owner?: string | null;
46
+ tags?: string[];
47
+ risk?: CapabilityRisk;
48
+ assurance?: AssuranceMetadata;
49
+ metadata?: JsonObject;
50
+ }
51
+ interface HostDescriptor {
52
+ id: string;
53
+ version: string;
54
+ protocol_version: typeof CHP_V0_1_VERSION;
55
+ kind: string;
56
+ capabilities: CapabilityDescriptor[];
57
+ evidence: {
58
+ store: string;
59
+ append_only: boolean;
60
+ [key: string]: JsonValue;
61
+ };
62
+ metadata?: JsonObject;
63
+ }
64
+ interface CorrelationContext {
65
+ correlation_id: string;
66
+ causation_id?: string | null;
67
+ parent_correlation_id?: string | null;
68
+ trace_id?: string | null;
69
+ baggage?: Record<string, JsonPrimitive>;
70
+ }
71
+ interface InvocationEnvelope {
72
+ invocation_id: string;
73
+ capability_id: string;
74
+ version?: string | null;
75
+ mode: ChpV01InvocationMode;
76
+ correlation: CorrelationContext;
77
+ subject: JsonObject;
78
+ payload: JsonObject;
79
+ requested_at: string;
80
+ metadata?: JsonObject;
81
+ }
82
+ interface DenialReason {
83
+ code: string;
84
+ message: string;
85
+ invariant_id?: string | null;
86
+ retryable: boolean;
87
+ details?: JsonObject;
88
+ }
89
+ interface InvocationResult {
90
+ invocation_id: string;
91
+ capability_id: string;
92
+ capability_version?: string | null;
93
+ correlation: CorrelationContext;
94
+ outcome: ChpV01ExecutionOutcome;
95
+ success: boolean;
96
+ data?: JsonValue;
97
+ error?: JsonObject | null;
98
+ denial?: DenialReason | null;
99
+ evidence_ids: string[];
100
+ started_at?: string | null;
101
+ completed_at: string;
102
+ }
103
+ interface ExecutionEvidence {
104
+ event_id: string;
105
+ event_type: string;
106
+ invocation_id: string;
107
+ capability_id: string;
108
+ capability_version?: string | null;
109
+ host_id: string;
110
+ correlation: CorrelationContext;
111
+ timestamp: string;
112
+ sequence: number;
113
+ outcome?: ChpV01ExecutionOutcome | null;
114
+ payload: JsonObject;
115
+ redacted: boolean;
116
+ error?: JsonObject | null;
117
+ denial?: DenialReason | null;
118
+ assurance: AssuranceMetadata;
119
+ }
120
+ interface ReplayQuery {
121
+ correlation_id: string;
122
+ limit?: number | null;
123
+ since_sequence?: number | null;
124
+ include_payloads?: boolean;
125
+ }
126
+ interface ReplayResult {
127
+ correlation_id: string;
128
+ events: ExecutionEvidence[];
129
+ event_count: number;
130
+ replayed_at: string;
131
+ }
132
+ declare function capabilityUri(descriptor: Pick<CapabilityDescriptor, "id" | "version">): string;
133
+ declare function isChpV01Outcome(value: string): value is ChpV01ExecutionOutcome;
134
+
135
+ /**
136
+ * Public TypeScript types for CHP v0.1.
137
+ *
138
+ * The root export is intentionally limited to the open-source protocol surface
139
+ * described by `spec/chp-v0.1.md` and the JSON Schemas in `schemas/`.
140
+ *
141
+ * Internal legacy mesh/governance helpers are available from
142
+ * `@auxo/ts-types/legacy`.
143
+ *
144
+ * @packageDocumentation
145
+ */
146
+
147
+ declare const CHP_VERSION = "0.1";
148
+ declare const VERSION = "0.1.0";
149
+
150
+ export { type AssuranceLevel, type AssuranceMetadata, CHP_V0_1_CORE_EVIDENCE_TYPES, CHP_V0_1_OUTCOMES, CHP_V0_1_VERSION, CHP_VERSION, type CapabilityDescriptor, type CapabilityRisk, type ChpV01ExecutionOutcome, type ChpV01InvocationMode, type CorrelationContext, type DenialReason, type ExecutionEvidence, type HostDescriptor, type InvariantDescriptor, type InvariantEnforcement, type InvariantFailureBehavior, type InvocationEnvelope, type InvocationResult, type JsonObject, type JsonPrimitive, type JsonValue, type ReplayQuery, type ReplayResult, VERSION, capabilityUri, isChpV01Outcome };
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.ts
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ CHP_V0_1_CORE_EVIDENCE_TYPES: () => CHP_V0_1_CORE_EVIDENCE_TYPES,
23
+ CHP_V0_1_OUTCOMES: () => CHP_V0_1_OUTCOMES,
24
+ CHP_V0_1_VERSION: () => CHP_V0_1_VERSION,
25
+ CHP_VERSION: () => CHP_VERSION,
26
+ VERSION: () => VERSION,
27
+ capabilityUri: () => capabilityUri,
28
+ isChpV01Outcome: () => isChpV01Outcome
29
+ });
30
+ module.exports = __toCommonJS(index_exports);
31
+
32
+ // src/v0_1.ts
33
+ var CHP_V0_1_VERSION = "0.1";
34
+ var CHP_V0_1_OUTCOMES = [
35
+ "success",
36
+ "failure",
37
+ "denied",
38
+ "skipped"
39
+ ];
40
+ var CHP_V0_1_CORE_EVIDENCE_TYPES = [
41
+ "execution_started",
42
+ "execution_completed",
43
+ "execution_failed",
44
+ "execution_denied",
45
+ "execution_skipped"
46
+ ];
47
+ function capabilityUri(descriptor) {
48
+ return `${descriptor.id}:${descriptor.version}`;
49
+ }
50
+ function isChpV01Outcome(value) {
51
+ return CHP_V0_1_OUTCOMES.includes(value);
52
+ }
53
+
54
+ // src/index.ts
55
+ var CHP_VERSION = "0.1";
56
+ var VERSION = "0.1.0";
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ CHP_V0_1_CORE_EVIDENCE_TYPES,
60
+ CHP_V0_1_OUTCOMES,
61
+ CHP_V0_1_VERSION,
62
+ CHP_VERSION,
63
+ VERSION,
64
+ capabilityUri,
65
+ isChpV01Outcome
66
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,34 @@
1
+ // src/v0_1.ts
2
+ var CHP_V0_1_VERSION = "0.1";
3
+ var CHP_V0_1_OUTCOMES = [
4
+ "success",
5
+ "failure",
6
+ "denied",
7
+ "skipped"
8
+ ];
9
+ var CHP_V0_1_CORE_EVIDENCE_TYPES = [
10
+ "execution_started",
11
+ "execution_completed",
12
+ "execution_failed",
13
+ "execution_denied",
14
+ "execution_skipped"
15
+ ];
16
+ function capabilityUri(descriptor) {
17
+ return `${descriptor.id}:${descriptor.version}`;
18
+ }
19
+ function isChpV01Outcome(value) {
20
+ return CHP_V0_1_OUTCOMES.includes(value);
21
+ }
22
+
23
+ // src/index.ts
24
+ var CHP_VERSION = "0.1";
25
+ var VERSION = "0.1.0";
26
+ export {
27
+ CHP_V0_1_CORE_EVIDENCE_TYPES,
28
+ CHP_V0_1_OUTCOMES,
29
+ CHP_V0_1_VERSION,
30
+ CHP_VERSION,
31
+ VERSION,
32
+ capabilityUri,
33
+ isChpV01Outcome
34
+ };