@sema-agent/primitives 7.57.0 → 7.58.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 CHANGED
@@ -1,9 +1,10 @@
1
1
  # @sema-agent/primitives
2
2
 
3
3
  Low-level definitions of the sema engine that every layer may import: no policy of any layer, no state, no
4
- dependencies. Today it holds one member, the credential reference. It is compiled from the same source the engine
5
- embeds, so an acceptance gate, a settings validator or an admin form reads the same closed set through the same function
6
- as the engine does. Runs in Node and in browsers; ships its own types.
4
+ dependencies. Today it holds one member, the credential reference. The engine depends on this package and reads it by
5
+ name, so in a project that installs both there is one copy: an acceptance gate, a settings validator or an admin form
6
+ reads the same closed set through the same function object as the engine does. Runs in Node and in browsers; ships its
7
+ own types.
7
8
 
8
9
  ## Install
9
10
 
@@ -18,6 +19,10 @@ ES modules only (`"type": "module"`), Node >= 20.18.1 where Node is used. One en
18
19
  `@sema-agent/primitives@X.Y.Z` is cut with `@sema-agent/core@X.Y.Z`: the same version number, built from the same
19
20
  commit. A package version moves with every core release whether or not the primitives changed.
20
21
 
22
+ `@sema-agent/core@X.Y.Z` depends on `@sema-agent/primitives@X.Y.Z` exactly. A project that also imports this package
23
+ names the same version as its core (or a range npm can resolve to it); then `npm ls @sema-agent/primitives` shows one
24
+ copy. Naming another version installs two — npm keeps core's own beside it — and the two answer for different versions.
25
+
21
26
  ## The credential reference
22
27
 
23
28
  A declaration names a credential by reference instead of carrying its value. The reference is one of a closed set of
@@ -1,5 +1,17 @@
1
+ /**
2
+ * The credential reference: how a declaration names a credential without carrying one. This module says which references
3
+ * exist and whether a value is one, so the engine's door, an acceptance gate, a settings validator and an admin form read
4
+ * one closed set through one function. It resolves nothing, reads no environment and holds no state.
5
+ * Zero dependencies: no builtin, no import, so the same file runs in Node and in a browser.
6
+ */
7
+ /** The closed set of kinds. A value whose `kind` is not in it is refused, never guessed at. */
1
8
  export declare const CREDENTIAL_REF_KINDS: readonly ["env", "vault", "handle", "assertion"];
2
9
  export type CredentialRefKind = (typeof CREDENTIAL_REF_KINDS)[number];
10
+ /**
11
+ * A reference, by kind. `env` names variables of the resolver's environment (header name → variable name for an http
12
+ * peer, child variable → variable name for a stdio peer; the maps have no prototype); `vault` names a stored entry;
13
+ * `handle` is an opaque id the deployment minted; `assertion` names the audience a short-lived assertion is requested for.
14
+ */
3
15
  export type CredentialRef = {
4
16
  readonly kind: "env";
5
17
  readonly headers?: Readonly<Record<string, string>>;
@@ -14,15 +26,31 @@ export type CredentialRef = {
14
26
  readonly kind: "assertion";
15
27
  readonly audience: string;
16
28
  };
29
+ /** What an acceptance gate may do with a reference that arrives on the request surface (the deployment may write any kind). */
17
30
  export type CredentialRefRequestAdmission = "refused" | "own_entry";
18
31
  type TrustRow = {
19
32
  readonly request: CredentialRefRequestAdmission;
20
33
  };
34
+ /**
35
+ * Where each kind may come from. `refused`: a request surface may not carry it (an environment name would read any
36
+ * variable of the resolver's process, a handle names someone else's credential, an assertion is minted by the deployment);
37
+ * `own_entry`: only for an entry that belongs to the submitting principal. A row per kind and nothing else (no prototype);
38
+ * look a kind up only after `readCredentialRef` accepted the value. A shape for a gate to read; it authenticates nothing.
39
+ */
21
40
  export declare const CREDENTIAL_REF_TRUST: Readonly<Record<CredentialRefKind, TrustRow>>;
41
+ /** The longest text member (entry, id, audience, header name, variable name) a reference may carry, in UTF-16 code units. */
22
42
  export declare const CREDENTIAL_REF_TEXT_MAX = 2048;
43
+ /** The most entries one name map (`headers`, `env`) of an `env` reference may hold. */
23
44
  export declare const CREDENTIAL_REF_MAP_MAX = 64;
45
+ /** Why a value is not a reference; each reason is its own exit. */
24
46
  export declare const CREDENTIAL_REF_PROBLEM_REASONS: readonly ["not_a_record", "unknown_kind", "missing_field", "extra_field", "bad_value"];
25
47
  export type CredentialRefProblemReason = (typeof CREDENTIAL_REF_PROBLEM_REASONS)[number];
48
+ /**
49
+ * The first fault found, in this order: not an ordinary record; `kind` missing, not text or outside the set; a member the
50
+ * kind does not have; a member it needs (for `env`, one of `headers` and `env`, written `headers|env`); a member of the
51
+ * wrong form. A `kind` or `field` read off the caller's value is untrusted text, cut to 64 characters with unsafe
52
+ * characters replaced; fence it before rendering it where markup is interpreted.
53
+ */
26
54
  export type CredentialRefProblem = {
27
55
  readonly reason: "not_a_record";
28
56
  } | {
@@ -48,5 +76,14 @@ export type CredentialRefReading = {
48
76
  readonly ok: false;
49
77
  readonly problem: CredentialRefProblem;
50
78
  };
79
+ /**
80
+ * The one reader of a credential reference: a fresh frozen copy that the caller's later writes cannot reach (forward the
81
+ * copy, never the value read), or the first problem. Nothing inside it throws: a value whose members cannot be read (a
82
+ * revoked or throwing Proxy) is `not_a_record`, or the `bad_value` of the map that holds it. A getter is refused and never
83
+ * called, no prototype is read for a member, and a Proxy's own traps (on the value, its maps or its prototype) are the
84
+ * caller's code and run as for any property read. Text is compared as written: nothing is normalised, and visually
85
+ * confusable text is not judged. With no stack left a valid value may be refused (any reason), never an invalid one
86
+ * accepted, and the call itself may throw a `RangeError` before it is entered.
87
+ */
51
88
  export declare function readCredentialRef(value: unknown): CredentialRefReading;
52
89
  export {};
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
+ /** The package entry of `@sema-agent/primitives`; core imports the package by name, never these modules. */
1
2
  export { CREDENTIAL_REF_KINDS, CREDENTIAL_REF_TRUST, CREDENTIAL_REF_TEXT_MAX, CREDENTIAL_REF_MAP_MAX, CREDENTIAL_REF_PROBLEM_REASONS, readCredentialRef, type CredentialRef, type CredentialRefKind, type CredentialRefRequestAdmission, type CredentialRefProblem, type CredentialRefProblemReason, type CredentialRefReading, } from "./credential-ref.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/primitives",
3
- "version": "7.57.0",
3
+ "version": "7.58.0",
4
4
  "private": false,
5
5
  "description": "Shared low-level definitions of the sema engine, importable by any layer: the credential reference (closed set of kinds, one reader). Zero dependencies.",
6
6
  "type": "module",
@@ -29,7 +29,7 @@
29
29
  "access": "public"
30
30
  },
31
31
  "scripts": {
32
- "build": "tsc -p tsconfig.json"
32
+ "build": "tsc -p tsconfig.json && tsc -p tsconfig.json --emitDeclarationOnly --removeComments false"
33
33
  },
34
- "gitHead": "84be0e09dcdd8e157f88f083241ceafedc0f33aa"
34
+ "gitHead": "05f1a14710d078da0b338fe8712e16f8d790f6bd"
35
35
  }