@xemahq/kernel-contracts 0.27.0 → 0.28.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.
@@ -1,4 +1,5 @@
1
1
  export * from './lib/capability-ref';
2
+ export * from './lib/connector-capability-ref';
2
3
  export * from './lib/capability-grant';
3
4
  export * from './lib/capability-policy';
4
5
  export * from './lib/permission-profile';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/capability/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/capability/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,cAAc,CAAC"}
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./lib/capability-ref"), exports);
18
+ __exportStar(require("./lib/connector-capability-ref"), exports);
18
19
  __exportStar(require("./lib/capability-grant"), exports);
19
20
  __exportStar(require("./lib/capability-policy"), exports);
20
21
  __exportStar(require("./lib/permission-profile"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/capability/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,yDAAuC;AACvC,0DAAwC;AACxC,2DAAyC;AACzC,iEAA+C;AAC/C,kDAAgC;AAChC,gEAA8C;AAC9C,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/capability/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,iEAA+C;AAC/C,yDAAuC;AACvC,0DAAwC;AACxC,2DAAyC;AACzC,iEAA+C;AAC/C,kDAAgC;AAChC,gEAA8C;AAC9C,+CAA6B"}
@@ -0,0 +1,11 @@
1
+ import { type CapabilityRef } from './capability-ref';
2
+ export declare const CONNECTOR_CAPABILITY_DOMAIN = "connector";
3
+ export interface ParsedConnectorCapabilityRef {
4
+ readonly provider: string;
5
+ readonly verb: string;
6
+ readonly major: number;
7
+ readonly raw: CapabilityRef;
8
+ }
9
+ export declare function buildConnectorCapabilityRef(providerSlug: string, verb: string, major?: number): CapabilityRef;
10
+ export declare function parseConnectorCapabilityRef(ref: string): ParsedConnectorCapabilityRef;
11
+ //# sourceMappingURL=connector-capability-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector-capability-ref.d.ts","sourceRoot":"","sources":["../../../src/capability/lib/connector-capability-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,kBAAkB,CAAC;AAkB1B,eAAO,MAAM,2BAA2B,cAAc,CAAC;AAOvD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;CAC7B;AAiBD,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,EACZ,KAAK,SAAI,GACR,aAAa,CAaf;AAeD,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,MAAM,GACV,4BAA4B,CAoB9B"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONNECTOR_CAPABILITY_DOMAIN = void 0;
4
+ exports.buildConnectorCapabilityRef = buildConnectorCapabilityRef;
5
+ exports.parseConnectorCapabilityRef = parseConnectorCapabilityRef;
6
+ const capability_ref_1 = require("./capability-ref");
7
+ const errors_1 = require("./errors");
8
+ exports.CONNECTOR_CAPABILITY_DOMAIN = 'connector';
9
+ function buildConnectorCapabilityRef(providerSlug, verb, major = 1) {
10
+ const raw = (0, capability_ref_1.formatCapabilityRef)({
11
+ domain: exports.CONNECTOR_CAPABILITY_DOMAIN,
12
+ verbPath: [providerSlug, verb],
13
+ major,
14
+ });
15
+ parseConnectorCapabilityRef(raw);
16
+ return raw;
17
+ }
18
+ function parseConnectorCapabilityRef(ref) {
19
+ const parsed = (0, capability_ref_1.parseCapabilityRef)(ref);
20
+ if (parsed.domain !== exports.CONNECTOR_CAPABILITY_DOMAIN) {
21
+ throw new errors_1.CapabilityRefParseError({
22
+ message: `Connector capability ref "${ref}" must use the "${exports.CONNECTOR_CAPABILITY_DOMAIN}" domain, got "${parsed.domain}".`,
23
+ raw: ref,
24
+ });
25
+ }
26
+ if (parsed.verbPath.length !== 2) {
27
+ throw new errors_1.CapabilityRefParseError({
28
+ message: `Connector capability ref "${ref}" must be exactly "<provider>.<verb>" after the domain (got ${parsed.verbPath.length} segment(s)).`,
29
+ raw: ref,
30
+ });
31
+ }
32
+ return {
33
+ provider: parsed.verbPath[0],
34
+ verb: parsed.verbPath[1],
35
+ major: parsed.major,
36
+ raw: parsed.raw,
37
+ };
38
+ }
39
+ //# sourceMappingURL=connector-capability-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector-capability-ref.js","sourceRoot":"","sources":["../../../src/capability/lib/connector-capability-ref.ts"],"names":[],"mappings":";;;AAmDA,kEAiBC;AAeD,kEAsBC;A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version": "0.28.0",
4
4
  "description": "Consolidated Xema OS kernel wire contracts — pure types + zod schemas for the kernel protocol surfaces. One package, one npm scope, wildcard per-surface subpath exports. No framework/runtime deps.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Neuralchowder Inc. <developer@xema.dev> (https://xema.dev)",
@@ -1,4 +1,5 @@
1
1
  export * from './lib/capability-ref';
2
+ export * from './lib/connector-capability-ref';
2
3
  export * from './lib/capability-grant';
3
4
  export * from './lib/capability-policy';
4
5
  export * from './lib/permission-profile';
@@ -0,0 +1,106 @@
1
+ import {
2
+ type CapabilityRef,
3
+ formatCapabilityRef,
4
+ parseCapabilityRef,
5
+ } from './capability-ref';
6
+ import { CapabilityRefParseError } from './errors';
7
+
8
+ /**
9
+ * The single domain literal for every connector capability ref.
10
+ *
11
+ * Every connector operation — regardless of which backend fulfils it
12
+ * (`native-provider` / `external-mcp` / `openapi-bridge` / `email`, see
13
+ * `ConnectorAdapterKind` in the `connector` surface) — is projected into ONE
14
+ * canonical ref of the shape:
15
+ *
16
+ * `connector:<provider>.<verb>@<major>`
17
+ *
18
+ * i.e. domain `connector`, resource = the provider slug, a single verb
19
+ * segment, and a major version. This is a stricter shape than the generic
20
+ * `CapabilityRef` grammar (which permits arbitrary `.`-joined verb paths); a
21
+ * connector ref is ALWAYS exactly `<provider>.<verb>` after the colon.
22
+ */
23
+ export const CONNECTOR_CAPABILITY_DOMAIN = 'connector';
24
+
25
+ /**
26
+ * Structured parts of a connector capability ref. `provider` is the resource
27
+ * segment, `verb` the single operation segment, `major` the ref's major
28
+ * version.
29
+ */
30
+ export interface ParsedConnectorCapabilityRef {
31
+ readonly provider: string;
32
+ readonly verb: string;
33
+ readonly major: number;
34
+ readonly raw: CapabilityRef;
35
+ }
36
+
37
+ /**
38
+ * The single SSOT for constructing a connector capability ref. Delegates to
39
+ * `formatCapabilityRef` so the canonical grammar (lowercase kebab, positive
40
+ * integer major) is validated in exactly one place — never hand-write a
41
+ * `connector:...@N` literal.
42
+ *
43
+ * @param providerSlug lowercase-kebab provider slug (`github`, `smtp`, …).
44
+ * @param verb single lowercase-kebab operation verb
45
+ * (`create-pull-request`, `send`, …).
46
+ * @param major ref major version, default `1`. Connector refs version
47
+ * like syscalls.
48
+ *
49
+ * Throws `CapabilityRefParseError` if the inputs would produce a ref that does
50
+ * not match the canonical grammar (fail-fast — never returns an invalid ref).
51
+ */
52
+ export function buildConnectorCapabilityRef(
53
+ providerSlug: string,
54
+ verb: string,
55
+ major = 1,
56
+ ): CapabilityRef {
57
+ const raw = formatCapabilityRef({
58
+ domain: CONNECTOR_CAPABILITY_DOMAIN,
59
+ verbPath: [providerSlug, verb],
60
+ major,
61
+ });
62
+ // Re-parse through the connector parser so the builder can ONLY ever emit a
63
+ // canonical exactly-`<provider>.<verb>` connector ref. This rejects a
64
+ // `providerSlug`/`verb` that smuggles in an extra `.` segment (which the
65
+ // generic grammar would otherwise accept), guaranteeing every value produced
66
+ // here round-trips through `parseConnectorCapabilityRef`.
67
+ parseConnectorCapabilityRef(raw);
68
+ return raw;
69
+ }
70
+
71
+ /**
72
+ * Parse a connector capability ref into its structured parts. Delegates to
73
+ * `parseCapabilityRef` for grammar validation, then enforces the connector
74
+ * shape:
75
+ *
76
+ * - domain MUST be `connector`;
77
+ * - the portion after `:` MUST be exactly two segments (`<provider>.<verb>`).
78
+ *
79
+ * Throws `CapabilityRefParseError` (code `CAPABILITY_REF_INVALID`) on any
80
+ * violation — never returns `null`, never silently coerces. This is the
81
+ * inverse of `buildConnectorCapabilityRef`: every value produced by the
82
+ * builder round-trips through this parser.
83
+ */
84
+ export function parseConnectorCapabilityRef(
85
+ ref: string,
86
+ ): ParsedConnectorCapabilityRef {
87
+ const parsed = parseCapabilityRef(ref);
88
+ if (parsed.domain !== CONNECTOR_CAPABILITY_DOMAIN) {
89
+ throw new CapabilityRefParseError({
90
+ message: `Connector capability ref "${ref}" must use the "${CONNECTOR_CAPABILITY_DOMAIN}" domain, got "${parsed.domain}".`,
91
+ raw: ref,
92
+ });
93
+ }
94
+ if (parsed.verbPath.length !== 2) {
95
+ throw new CapabilityRefParseError({
96
+ message: `Connector capability ref "${ref}" must be exactly "<provider>.<verb>" after the domain (got ${parsed.verbPath.length} segment(s)).`,
97
+ raw: ref,
98
+ });
99
+ }
100
+ return {
101
+ provider: parsed.verbPath[0]!,
102
+ verb: parsed.verbPath[1]!,
103
+ major: parsed.major,
104
+ raw: parsed.raw,
105
+ };
106
+ }