@kindgi/types 0.0.0-bootstrap.0 → 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.
Files changed (48) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +39 -2
  3. package/SPEC.md +162 -0
  4. package/dist/filter.d.ts +61 -0
  5. package/dist/filter.d.ts.map +1 -0
  6. package/dist/filter.js +4 -0
  7. package/dist/filter.js.map +1 -0
  8. package/dist/hash.d.ts +32 -0
  9. package/dist/hash.d.ts.map +1 -0
  10. package/dist/hash.js +4 -0
  11. package/dist/hash.js.map +1 -0
  12. package/dist/ids.d.ts +171 -0
  13. package/dist/ids.d.ts.map +1 -0
  14. package/dist/ids.js +15 -0
  15. package/dist/ids.js.map +1 -0
  16. package/dist/index.d.ts +9 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +7 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/refs.d.ts +58 -0
  21. package/dist/refs.d.ts.map +1 -0
  22. package/dist/refs.js +4 -0
  23. package/dist/refs.js.map +1 -0
  24. package/dist/result.d.ts +48 -0
  25. package/dist/result.d.ts.map +1 -0
  26. package/dist/result.js +4 -0
  27. package/dist/result.js.map +1 -0
  28. package/dist/temporal.d.ts +30 -0
  29. package/dist/temporal.d.ts.map +1 -0
  30. package/dist/temporal.js +4 -0
  31. package/dist/temporal.js.map +1 -0
  32. package/dist/version.d.ts +36 -0
  33. package/dist/version.d.ts.map +1 -0
  34. package/dist/version.js +4 -0
  35. package/dist/version.js.map +1 -0
  36. package/package.json +46 -4
  37. package/src/filter.ts +66 -0
  38. package/src/hash.ts +37 -0
  39. package/src/ids.test-d.ts +54 -0
  40. package/src/ids.ts +225 -0
  41. package/src/index.ts +15 -0
  42. package/src/refs.test-d.ts +93 -0
  43. package/src/refs.ts +62 -0
  44. package/src/result.test-d.ts +59 -0
  45. package/src/result.ts +42 -0
  46. package/src/temporal.ts +35 -0
  47. package/src/version.ts +41 -0
  48. package/type-manifest.json +99 -0
package/dist/ids.d.ts ADDED
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Branded ID types for every entity kind in Kindgi.
3
+ *
4
+ * Every ID is a nominal string type — structurally a string, but statically distinct.
5
+ * A `TenantId` cannot be passed where a `UserId` is expected, catching a whole class
6
+ * of bugs at compile time.
7
+ *
8
+ * These are pure compile-time constructs; there is no runtime cost. Construction
9
+ * is by cast (`as`). The one exception is `EnvName`, which has the validated
10
+ * factory `makeEnvName` (the only runtime export of this package); validation of
11
+ * wire payloads lives in `@kindgi/schema`.
12
+ *
13
+ * Naming convention:
14
+ * - `<Entity>Id` — a single identifier for that entity kind.
15
+ * - Most entity kinds in the `@kindgi/specs/*.schema.json` files have an ID
16
+ * here (eval suites, for one, use plain strings); some IDs (e.g.
17
+ * `ConversationId`, `TriggerId`) name entities that have no schema.
18
+ *
19
+ * If you add a new entity kind to Kindgi, add its ID here. Consumers rely on
20
+ * this being the canonical registry of branded IDs.
21
+ */
22
+ /**
23
+ * Generic brand utility. Prefer using the pre-defined branded types below;
24
+ * this is exported for downstream packs that need to declare pack-scoped IDs
25
+ * (e.g. `Brand<string, 'MatterId'>` in a pack that tracks legal matters).
26
+ */
27
+ export type Brand<T, B extends string> = T & {
28
+ readonly __brand: B;
29
+ };
30
+ /**
31
+ * `T` with every branded string in it (`FlowId`, `NodeId`, `EdgeId`, …)
32
+ * loosened to plain `string`, all the way down: through arrays, objects
33
+ * and unions. For authoring inputs, so an author writes `'acme.review'`
34
+ * rather than `'acme.review' as FlowId`. A branded value still fits, since
35
+ * it is a string. The validated result is branded again.
36
+ */
37
+ export type Unbranded<T> = T extends string & {
38
+ readonly __brand: string;
39
+ } ? string : T extends readonly (infer E)[] ? readonly Unbranded<E>[] : T extends object ? {
40
+ readonly [K in keyof T]: Unbranded<T[K]>;
41
+ } : T;
42
+ /** Tenant — the sovereignty boundary. Cross-tenant access is denied by policy. */
43
+ export type TenantId = Brand<string, 'TenantId'>;
44
+ /** User within a tenant. */
45
+ export type UserId = Brand<string, 'UserId'>;
46
+ /** Organization scope within a tenant — optional structural subdivision (a firm's litigation department, a hospital's cardiology). Small tenants ignore this; large tenants use it. */
47
+ export type OrgId = Brand<string, 'OrgId'>;
48
+ /** Team scope — a people-group. A named collection of users who work together; users can belong to many teams. Same team works on many projects; same project can have many teams collaborating. Distinct from Org (structural) — Team is about working groups. */
49
+ export type TeamId = Brand<string, 'TeamId'>;
50
+ /** Project scope — vertical-agnostic ('matter' in legal, 'case' in HR, 'engagement' in accounting, 'episode' in healthcare). This is the primary content-scope: facts, artifacts, runs, blobs belong to a project. */
51
+ export type ProjectId = Brand<string, 'ProjectId'>;
52
+ /** Conversation thread within a session. */
53
+ export type ThreadId = Brand<string, 'ThreadId'>;
54
+ /**
55
+ * Agent conversation. A conversation is a first-class primitive (see the
56
+ * `agent_conversations` migration in `@kindgi/agents`): it groups many
57
+ * agent invocations into one durable thread the user can reopen, hand
58
+ * off, or reference in a later run. Distinct from `ThreadId` (which is a
59
+ * lower-level session-thread identifier used by the session store).
60
+ */
61
+ export type ConversationId = Brand<string, 'ConversationId'>;
62
+ /** User session. */
63
+ export type SessionId = Brand<string, 'SessionId'>;
64
+ /** A run — one execution of a flow. */
65
+ export type RunId = Brand<string, 'RunId'>;
66
+ /**
67
+ * Task flow definition id. Convention: `<pack-id>.<flow-name>`
68
+ * (kebab-case, dot-namespaced) — e.g. `acme.brief-review-flow`,
69
+ * `demo.echo-flow`. The framework's built-in agent-turn flow is
70
+ * `agent.turn` (`AGENT_TURN_FLOW_ID` in `@kindgi/agents`).
71
+ */
72
+ export type FlowId = Brand<string, 'FlowId'>;
73
+ /** A node within a flow. Convention: kebab-case, unique within the flow — e.g. `dispatch-tool`, `wait-for-approval`. */
74
+ export type NodeId = Brand<string, 'NodeId'>;
75
+ /** An edge within a flow. Declared by the flow author (`FlowEdge.id` in `@kindgi/flow`); must be unique across the flow, including its loop bodies. */
76
+ export type EdgeId = Brand<string, 'EdgeId'>;
77
+ /**
78
+ * Agent definition id. Convention: `<pack-id>.<agent-name>`
79
+ * (kebab-case, dot-namespaced) — e.g. `acme.brief-writer`,
80
+ * `demo.echo-agent`. The `<pack-id>` prefix scopes the agent to
81
+ * its pack; `<agent-name>` describes the agent's role. Enforced by
82
+ * `defineAgent` at author time.
83
+ */
84
+ export type AgentId = Brand<string, 'AgentId'>;
85
+ /**
86
+ * Tool definition id. Convention: `<pack-id>.<tool-name>`
87
+ * (kebab-case, dot-namespaced) — e.g. `acme.verify-citation`,
88
+ * `demo.echo`. The `<pack-id>` prefix scopes the tool to its pack;
89
+ * `<tool-name>` names the operation. Enforced by `defineTool` at
90
+ * author time.
91
+ */
92
+ export type ToolId = Brand<string, 'ToolId'>;
93
+ /**
94
+ * Guardrail declaration id. Convention: `<pack-id>.<guardrail-name>`
95
+ * (kebab-case, dot-namespaced) — e.g. `acme.no-fabricated-quotes`,
96
+ * `demo.response-not-empty`. `<guardrail-name>` describes the
97
+ * property being asserted (usually a positive rule the agent turn
98
+ * must satisfy). Enforced by `defineGuardrail` at author time.
99
+ */
100
+ export type GuardrailId = Brand<string, 'GuardrailId'>;
101
+ /** A tenant policy document. */
102
+ export type PolicyId = Brand<string, 'PolicyId'>;
103
+ /** A pack manifest (installable vertical application). */
104
+ export type PackId = Brand<string, 'PackId'>;
105
+ /** An event (runtime-emitted or user-emitted). */
106
+ export type EventId = Brand<string, 'EventId'>;
107
+ /** A memory Fact — typed, versioned, retrievable. */
108
+ export type FactId = Brand<string, 'FactId'>;
109
+ /** A memory LogEntry — one line in the append-only event stream. */
110
+ export type LogEntryId = Brand<string, 'LogEntryId'>;
111
+ /** A generated artifact (draft, memo, report). */
112
+ export type ArtifactId = Brand<string, 'ArtifactId'>;
113
+ /** A provenance DAG record. */
114
+ export type ProvenanceId = Brand<string, 'ProvenanceId'>;
115
+ /** A subscription registration for the events system. */
116
+ export type SubscriptionId = Brand<string, 'SubscriptionId'>;
117
+ /** An approval request in the HITL queue. */
118
+ export type ApprovalId = Brand<string, 'ApprovalId'>;
119
+ /** A reviewer registered with HITL — carries a role class (standard/senior/admin). */
120
+ export type ReviewerId = Brand<string, 'ReviewerId'>;
121
+ /** A supervisor definition — the actor that observes runs and proposes fixes. */
122
+ export type SupervisorId = Brand<string, 'SupervisorId'>;
123
+ /** A recorded supervisor observation of a single agent run. */
124
+ export type ObservationId = Brand<string, 'ObservationId'>;
125
+ /** A supervisor's proposed fix to an agent artifact (prompt / retrieval / tool-config). */
126
+ export type FixProposalId = Brand<string, 'FixProposalId'>;
127
+ /** A signed audit bundle exported from HITL. Wraps approvals + evidence + provenance refs. */
128
+ export type AuditBundleId = Brand<string, 'AuditBundleId'>;
129
+ /** A compliance evidence bundle. */
130
+ export type ComplianceEvidenceId = Brand<string, 'ComplianceEvidenceId'>;
131
+ /** A wait token issued for pausing a run (HITL, external callback). */
132
+ export type WaitTokenId = Brand<string, 'WaitTokenId'>;
133
+ /** A training dataset registered in memory. */
134
+ export type DatasetId = Brand<string, 'DatasetId'>;
135
+ /** A recurring schedule that triggers agent / flow runs on a cadence. */
136
+ export type ScheduleId = Brand<string, 'ScheduleId'>;
137
+ /** A registered capability provider (model provider, embedding provider, etc.). */
138
+ export type ProviderId = Brand<string, 'ProviderId'>;
139
+ /** An API token issued to a caller for authenticating platform requests. */
140
+ export type ApiTokenId = Brand<string, 'ApiTokenId'>;
141
+ /** The routable public identifier of an inbound webhook trigger: the id in its receiver URL (see `TriggerId`). */
142
+ export type WebhookId = Brand<string, 'WebhookId'>;
143
+ /** An outbound webhook endpoint: a URL the platform sends signed events to. */
144
+ export type WebhookEndpointId = Brand<string, 'WebhookEndpointId'>;
145
+ /** One outbound webhook event. Sent as the `webhook-id` header and the same on every retry, so receivers deduplicate on it. */
146
+ export type WebhookEventId = Brand<string, 'WebhookEventId'>;
147
+ /** One event's delivery to one outbound endpoint, across all its attempts. */
148
+ export type WebhookDeliveryId = Brand<string, 'WebhookDeliveryId'>;
149
+ /** An installed pack instance for a tenant. Reserved: no package in this repository issues one. */
150
+ export type InstallationId = Brand<string, 'InstallationId'>;
151
+ /** A signing key — identifies a key pair in a caller-provided key store (see `SigningKeyBinding` in `@kindgi/crypto`). Keys themselves are opaque `Uint8Array` values; this ID is how consumers reference them at runtime without owning the store. */
152
+ export type SigningKeyId = Brand<string, 'SigningKeyId'>;
153
+ /** A registered trigger — its storage primary key. Distinct from `WebhookId` (routable public identifier used on the receiver URL); a webhook trigger has both a `TriggerId` (private, primary key) and a `WebhookId` (public, routable). */
154
+ export type TriggerId = Brand<string, 'TriggerId'>;
155
+ /**
156
+ * A per-environment slug carried as a required dimension by `EnvBinding`
157
+ * and `SecretBinding`.
158
+ *
159
+ * Grammar: `[a-z][a-z0-9-]{0,62}` — RFC-1035-like label (lowercase alnum
160
+ * + hyphen, 1–63 chars, starts with a letter). Cross-provider portable
161
+ * (Vault path chars, GCP secret names, AWS ARN paths, k8s namespaces).
162
+ * Use `makeEnvName` for validated construction; unchecked casts are
163
+ * a policy violation for any code path that receives external input.
164
+ */
165
+ export type EnvName = Brand<string, 'EnvName'>;
166
+ /**
167
+ * Validated `EnvName` factory. Returns `null` on any grammar violation
168
+ * (uppercase, underscore, dot, slash, non-ASCII, empty, >63 chars).
169
+ */
170
+ export declare function makeEnvName(raw: string): EnvName | null;
171
+ //# sourceMappingURL=ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;GAIG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACt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AC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAEnE,mGAAmG;AACnG,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAE7D,uPAAuP;AACvP,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAEzD,6OAA6O;AAC7O,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEnD;;;;;;;;;GASG;AACH,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAI/C;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAIvD"}
package/dist/ids.js ADDED
@@ -0,0 +1,15 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ const ENV_NAME_GRAMMAR = /^[a-z][a-z0-9-]{0,62}$/;
4
+ /**
5
+ * Validated `EnvName` factory. Returns `null` on any grammar violation
6
+ * (uppercase, underscore, dot, slash, non-ASCII, empty, >63 chars).
7
+ */
8
+ export function makeEnvName(raw) {
9
+ if (typeof raw !== 'string')
10
+ return null;
11
+ if (!ENV_NAME_GRAMMAR.test(raw))
12
+ return null;
13
+ return raw;
14
+ }
15
+ //# sourceMappingURL=ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAqNjC,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAElD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACzC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7C,OAAO,GAAc,CAAC;AACxB,CAAC"}
@@ -0,0 +1,9 @@
1
+ export type * from './filter.js';
2
+ export type * from './hash.js';
3
+ export type * from './ids.js';
4
+ export type * from './refs.js';
5
+ export type * from './result.js';
6
+ export type * from './temporal.js';
7
+ export type * from './version.js';
8
+ export { makeEnvName } from './ids.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,mBAAmB,aAAa,CAAC;AACjC,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,aAAa,CAAC;AACjC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,cAAc,CAAC;AAKlC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ // Runtime factories on branded IDs (validated construction). Kept as a
4
+ // separate value re-export so the `export type *` barrels above stay
5
+ // pure-type — value exports live only where explicitly listed.
6
+ export { makeEnvName } from './ids.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAUjC,uEAAuE;AACvE,qEAAqE;AACrE,+DAA+D;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
package/dist/refs.d.ts ADDED
@@ -0,0 +1,58 @@
1
+ import type { ContentHash } from './hash.js';
2
+ import type { TenantId } from './ids.js';
3
+ import type { Timestamp } from './temporal.js';
4
+ /**
5
+ * Reference to a blob in object storage.
6
+ *
7
+ * BlobRef is a handle to bytes held by an object-storage provider (e.g.
8
+ * MinIO, S3, R2, GCS).
9
+ *
10
+ * The required fields are populated by the storage layer that wrote the
11
+ * bytes. Consumers must NEVER construct a BlobRef by hand; a real one always
12
+ * comes from a provider that has already written the bytes.
13
+ */
14
+ export interface BlobRef {
15
+ /** Which provider holds this blob (e.g. 'minio', 's3', 'r2', 'gcs'). */
16
+ readonly provider: string;
17
+ /** Bucket name within the provider. */
18
+ readonly bucket: string;
19
+ /** Object key within the bucket. Never contains a leading slash. */
20
+ readonly key: string;
21
+ /** Size in bytes. */
22
+ readonly size: number;
23
+ /** Content hash of the blob bytes — enables dedup and tamper detection. */
24
+ readonly sha256: ContentHash;
25
+ /** MIME type. */
26
+ readonly contentType: string;
27
+ /** Owning tenant. Cross-tenant access is denied by policy. */
28
+ readonly tenantId: TenantId;
29
+ /** When the blob was written. */
30
+ readonly createdAt: Timestamp;
31
+ /**
32
+ * Optional retention lock — after this timestamp, provider MAY delete;
33
+ * before, provider MUST refuse deletion. Enables legal-hold semantics.
34
+ */
35
+ readonly retentionUntil?: Timestamp;
36
+ }
37
+ /**
38
+ * Reference to a versioned dataset: a collection of memory Facts (see
39
+ * `@kindgi/memory`) of one declared type — e.g. eval corpora, held-out sets,
40
+ * or examples a pack ships with.
41
+ *
42
+ * The DatasetRef captures which collection and which version.
43
+ */
44
+ export interface DatasetRef {
45
+ /** Dataset identifier. */
46
+ readonly datasetId: string;
47
+ /** Owning tenant. */
48
+ readonly tenantId: TenantId;
49
+ /** Version of the dataset (semver). */
50
+ readonly version: string;
51
+ /** Fact type stored in this dataset (matches memory.schema.json Fact.type). */
52
+ readonly factType: string;
53
+ /** Number of items in this version. */
54
+ readonly count: number;
55
+ /** When this version was created. */
56
+ readonly createdAt: Timestamp;
57
+ }
58
+ //# sourceMappingURL=refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../src/refs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,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,"file":"refs.js","sourceRoot":"","sources":["../src/refs.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * A discriminated-union result type. Preferred over throwing for boundary
3
+ * operations where the caller must handle both success and failure explicitly.
4
+ *
5
+ * Every member carries a runtime `kind` tag so consumers can narrow via
6
+ * `if (r.kind === 'ok') { ... }`. This is the codebase's standard shape;
7
+ * do not invent parallel Ok/Err representations.
8
+ *
9
+ * @example
10
+ * function loadSchema(path: string): Result<Schema, SchemaLoadError> {
11
+ * try {
12
+ * return { kind: 'ok', value: parse(readFileSync(path)) };
13
+ * } catch (cause) {
14
+ * return { kind: 'err', error: { code: 'load-failed', path, cause } };
15
+ * }
16
+ * }
17
+ *
18
+ * const r = loadSchema('./flow.schema.json');
19
+ * if (r.kind === 'ok') { use(r.value); } else { handle(r.error); }
20
+ */
21
+ export type Result<T, E> = {
22
+ readonly kind: 'ok';
23
+ readonly value: T;
24
+ } | {
25
+ readonly kind: 'err';
26
+ readonly error: E;
27
+ };
28
+ /**
29
+ * Extract the success type from a Result.
30
+ *
31
+ * @example
32
+ * type Value = OkOf<Result<number, string>>; // number
33
+ */
34
+ export type OkOf<R> = R extends {
35
+ readonly kind: 'ok';
36
+ readonly value: infer T;
37
+ } ? T : never;
38
+ /**
39
+ * Extract the error type from a Result.
40
+ *
41
+ * @example
42
+ * type Failure = ErrOf<Result<number, string>>; // string
43
+ */
44
+ export type ErrOf<R> = R extends {
45
+ readonly kind: 'err';
46
+ readonly error: infer E;
47
+ } ? E : never;
48
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,IACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAC1C;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AAE7F;;;;;GAKG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,KAAK,CAAC"}
package/dist/result.js ADDED
@@ -0,0 +1,4 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ export {};
4
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC"}
@@ -0,0 +1,30 @@
1
+ import type { Brand } from './ids.js';
2
+ /**
3
+ * An ISO 8601 timestamp string, always UTC (trailing 'Z').
4
+ *
5
+ * Example: '2026-09-16T14:23:45.123Z'
6
+ *
7
+ * Kept as a string rather than a Date object for two reasons:
8
+ * 1. JSON-serializable by construction — no `.toISOString()` traps at boundaries.
9
+ * 2. Deterministic ordering by lexicographic sort, which matches temporal order
10
+ * for well-formed ISO 8601 UTC strings. Anything that orders records by
11
+ * timestamp (e.g. run replay) relies on this.
12
+ */
13
+ export type Timestamp = Brand<string, 'Timestamp'>;
14
+ /**
15
+ * A duration expressed in milliseconds.
16
+ *
17
+ * Branded to distinguish from arbitrary numbers at call sites like
18
+ * `wait(500)` vs `wait(500 as DurationMs)`.
19
+ */
20
+ export type DurationMs = Brand<number, 'DurationMs'>;
21
+ /**
22
+ * A duration expressed as an ISO 8601 duration string.
23
+ *
24
+ * Example: 'PT30S' (30 seconds), 'PT2H' (2 hours), 'P1D' (1 day).
25
+ *
26
+ * Preferred over `DurationMs` in declarative artifacts (task flows, retention
27
+ * policies) because it's human-readable and unambiguous across serialization.
28
+ */
29
+ export type IsoDuration = Brand<string, 'IsoDuration'>;
30
+ //# sourceMappingURL=temporal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temporal.d.ts","sourceRoot":"","sources":["../src/temporal.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ export {};
4
+ //# sourceMappingURL=temporal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temporal.js","sourceRoot":"","sources":["../src/temporal.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC"}
@@ -0,0 +1,36 @@
1
+ import type { Brand } from './ids.js';
2
+ /**
3
+ * A semver version string (major.minor.patch, with optional pre-release).
4
+ *
5
+ * Regex convention: `^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$`.
6
+ *
7
+ * Used for:
8
+ * - Artifact versions (flow.version, policy.version, provenance.version).
9
+ * - Pack manifest versions.
10
+ * - Schema versions in `$comment: "schema-version: X.Y.Z"`.
11
+ *
12
+ * The brand prevents mixing free-form strings with validated semver values.
13
+ */
14
+ export type Semver = Brand<string, 'Semver'>;
15
+ /**
16
+ * Major version number extracted from a semver, used for schema $id path segments.
17
+ *
18
+ * Convention: `1`, `2`, `3` (positive integer). No `v` prefix — the `v` is added
19
+ * by the URL scheme (`/v1/flow.schema.json`), not part of the value.
20
+ */
21
+ export type SchemaMajor = Brand<number, 'SchemaMajor'>;
22
+ /**
23
+ * Version-pinned artifact reference. Combines an artifact id with an exact
24
+ * semver, so replays and audit trails always know which version was in force.
25
+ *
26
+ * @example
27
+ * const flowRef: VersionedRef<FlowId> = {
28
+ * id: 'acme.contract-review' as FlowId,
29
+ * version: '1.2.3' as Semver,
30
+ * };
31
+ */
32
+ export interface VersionedRef<Id extends string> {
33
+ readonly id: Id;
34
+ readonly version: Semver;
35
+ }
36
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAEvD;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY,CAAC,EAAE,SAAS,MAAM;IAC7C,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,4 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ export {};
4
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC"}
package/package.json CHANGED
@@ -1,7 +1,49 @@
1
1
  {
2
2
  "name": "@kindgi/types",
3
- "version": "0.0.0-bootstrap.0",
4
- "description": "Placeholder so a trusted publisher can be attached. Releases are published from https://github.com/kindgi/kindgi-sdk with provenance; use 0.1.0 or later.",
3
+ "version": "0.1.0",
4
+ "description": "Foundational TypeScript types shared across Kindgi. Branded IDs, timestamps, hashes, refs, Result, list filter / page shapes. Zero runtime dependencies; the only runtime export is the makeEnvName validator.",
5
5
  "license": "Apache-2.0",
6
- "repository": { "type": "git", "url": "git+https://github.com/kindgi/kindgi-sdk.git" }
7
- }
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/kindgi/kindgi-sdk.git",
9
+ "directory": "packages/types"
10
+ },
11
+ "homepage": "https://github.com/kindgi/kindgi-sdk/tree/main/packages/types#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/kindgi/kindgi-sdk/issues"
14
+ },
15
+ "type": "module",
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "src",
27
+ "README.md",
28
+ "SPEC.md",
29
+ "type-manifest.json"
30
+ ],
31
+ "engines": {
32
+ "node": ">=22.0.0"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public",
36
+ "provenance": true
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^22.10.5",
40
+ "typescript": "^5.7.3",
41
+ "vitest": "^2.1.8"
42
+ },
43
+ "scripts": {
44
+ "build": "tsc -p tsconfig.build.json",
45
+ "typecheck": "tsc --noEmit",
46
+ "test": "vitest run --typecheck --typecheck.only --passWithNoTests",
47
+ "clean": "rm -rf dist *.tsbuildinfo"
48
+ }
49
+ }
package/src/filter.ts ADDED
@@ -0,0 +1,66 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+
4
+ import type { Brand } from './ids.js';
5
+ import type { Timestamp } from './temporal.js';
6
+
7
+ /**
8
+ * Opaque pagination cursor. Producers return a `Cursor`; consumers pass
9
+ * it back verbatim to the next list call. The value is implementation-
10
+ * defined (usually a timestamp or opaque token) — callers must not
11
+ * parse or construct one by hand.
12
+ */
13
+ export type Cursor = Brand<string, 'Cursor'>;
14
+
15
+ /**
16
+ * Shared list-filter shape. List inputs extend this (e.g. the team and
17
+ * project bindings in `@kindgi/platform`) so resources share one
18
+ * facet-filter shape.
19
+ *
20
+ * `TStatus` narrows the `status` field per-resource (e.g. the
21
+ * `ApprovalStatus`, `FixProposalStatus` and `ObservationStatus` unions
22
+ * in `@kindgi/api`).
23
+ *
24
+ * All fields are optional. A caller can pass an empty `Filter` to get
25
+ * the default page.
26
+ */
27
+ export interface Filter<TStatus extends string = string> {
28
+ /**
29
+ * Filter to one status or a set of statuses. The resource-specific
30
+ * input type narrows TStatus so consumers get autocomplete on the
31
+ * allowed values.
32
+ */
33
+ readonly status?: TStatus | readonly TStatus[];
34
+ /**
35
+ * Lower bound on the resource's canonical timestamp — typically
36
+ * `createdAt` or `observedAt`. Inclusive. Absent = no lower bound.
37
+ */
38
+ readonly since?: Timestamp;
39
+ /**
40
+ * Upper bound on the resource's canonical timestamp. Inclusive.
41
+ * Absent = no upper bound.
42
+ */
43
+ readonly until?: Timestamp;
44
+ /**
45
+ * Max items to return. Producers clamp to a resource-specific ceiling
46
+ * (typically 500). Default page size is producer-defined.
47
+ */
48
+ readonly limit?: number;
49
+ /** Opaque cursor from a prior list call's `nextCursor` field. */
50
+ readonly cursor?: Cursor;
51
+ }
52
+
53
+ /**
54
+ * Shared list-result envelope. List producers that use it return
55
+ * `{ items, nextCursor? }`. Consumers keep calling with `cursor:
56
+ * result.nextCursor` until it's absent.
57
+ *
58
+ * `truncated: true` explicitly signals "more items exist beyond the
59
+ * cursor" for aggregators that don't paginate but should still know
60
+ * they missed data.
61
+ */
62
+ export interface Page<T> {
63
+ readonly items: readonly T[];
64
+ readonly nextCursor?: Cursor;
65
+ readonly truncated?: boolean;
66
+ }
package/src/hash.ts ADDED
@@ -0,0 +1,37 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+
4
+ import type { Brand } from './ids.js';
5
+
6
+ /**
7
+ * A content-addressed hash of a payload, formatted as `<algo>:<hex>`.
8
+ *
9
+ * Current supported algorithms:
10
+ * - `sha256:<64 hex chars>`
11
+ *
12
+ * Meant for content addressing: tamper-evident provenance node content,
13
+ * blob dedup at ingest, memory LogEntry / Fact content hashes.
14
+ *
15
+ * The prefix is significant: consumers must reject hashes without a recognized
16
+ * algorithm prefix, so future migration to sha3 or blake3 is non-breaking.
17
+ */
18
+ export type ContentHash = Brand<string, 'ContentHash'>;
19
+
20
+ /**
21
+ * An Ed25519 signature over some canonical serialization, base64-encoded.
22
+ *
23
+ * Format is padded base64 (RFC 4648 §4). No URL-safe variants — canonical form
24
+ * for interoperability with signing tools.
25
+ */
26
+ export type SignatureValue = Brand<string, 'SignatureValue'>;
27
+
28
+ /**
29
+ * Identifier for a signing key in provider-qualified form. Opaque to Kindgi;
30
+ * interpreted by whichever key provider resolves it. (Keys held in a
31
+ * `SigningKeyBinding` from `@kindgi/crypto` are addressed by `SigningKeyId`.)
32
+ *
33
+ * Convention: `<provider>:<key-name>` (e.g. `ed25519-local:tenant-abc-v1`,
34
+ * `hsm:pkcs11:slot-3:key-42`, `kms:aws:arn:aws:kms:...`). Consumers should
35
+ * treat this string as opaque and let the provider resolve it.
36
+ */
37
+ export type KeyId = Brand<string, 'KeyId'>;