@originals/sdk 1.8.0 → 1.8.2

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 (145) hide show
  1. package/dist/utils/hash.js +1 -0
  2. package/package.json +6 -5
  3. package/src/adapters/FeeOracleMock.ts +9 -0
  4. package/src/adapters/index.ts +5 -0
  5. package/src/adapters/providers/OrdHttpProvider.ts +126 -0
  6. package/src/adapters/providers/OrdMockProvider.ts +101 -0
  7. package/src/adapters/types.ts +66 -0
  8. package/src/bitcoin/BitcoinManager.ts +329 -0
  9. package/src/bitcoin/BroadcastClient.ts +54 -0
  10. package/src/bitcoin/OrdinalsClient.ts +120 -0
  11. package/src/bitcoin/PSBTBuilder.ts +106 -0
  12. package/src/bitcoin/fee-calculation.ts +38 -0
  13. package/src/bitcoin/providers/OrdNodeProvider.ts +92 -0
  14. package/src/bitcoin/providers/OrdinalsProvider.ts +56 -0
  15. package/src/bitcoin/providers/types.ts +59 -0
  16. package/src/bitcoin/transactions/commit.ts +465 -0
  17. package/src/bitcoin/transactions/index.ts +13 -0
  18. package/src/bitcoin/transfer.ts +43 -0
  19. package/src/bitcoin/utxo-selection.ts +322 -0
  20. package/src/bitcoin/utxo.ts +113 -0
  21. package/src/cel/ExternalReferenceManager.ts +87 -0
  22. package/src/cel/OriginalsCel.ts +460 -0
  23. package/src/cel/algorithms/createEventLog.ts +68 -0
  24. package/src/cel/algorithms/deactivateEventLog.ts +109 -0
  25. package/src/cel/algorithms/index.ts +11 -0
  26. package/src/cel/algorithms/updateEventLog.ts +99 -0
  27. package/src/cel/algorithms/verifyEventLog.ts +306 -0
  28. package/src/cel/algorithms/witnessEvent.ts +87 -0
  29. package/src/cel/cli/create.ts +330 -0
  30. package/src/cel/cli/index.ts +383 -0
  31. package/src/cel/cli/inspect.ts +549 -0
  32. package/src/cel/cli/migrate.ts +473 -0
  33. package/src/cel/cli/verify.ts +249 -0
  34. package/src/cel/hash.ts +71 -0
  35. package/src/cel/index.ts +16 -0
  36. package/src/cel/layers/BtcoCelManager.ts +408 -0
  37. package/src/cel/layers/PeerCelManager.ts +371 -0
  38. package/src/cel/layers/WebVHCelManager.ts +361 -0
  39. package/src/cel/layers/index.ts +27 -0
  40. package/src/cel/serialization/cbor.ts +189 -0
  41. package/src/cel/serialization/index.ts +10 -0
  42. package/src/cel/serialization/json.ts +209 -0
  43. package/src/cel/types.ts +160 -0
  44. package/src/cel/witnesses/BitcoinWitness.ts +184 -0
  45. package/src/cel/witnesses/HttpWitness.ts +241 -0
  46. package/src/cel/witnesses/WitnessService.ts +51 -0
  47. package/src/cel/witnesses/index.ts +11 -0
  48. package/src/contexts/credentials-v1.json +237 -0
  49. package/src/contexts/credentials-v2-examples.json +5 -0
  50. package/src/contexts/credentials-v2.json +340 -0
  51. package/src/contexts/credentials.json +237 -0
  52. package/src/contexts/data-integrity-v2.json +81 -0
  53. package/src/contexts/dids.json +58 -0
  54. package/src/contexts/ed255192020.json +93 -0
  55. package/src/contexts/ordinals-plus.json +23 -0
  56. package/src/contexts/originals.json +22 -0
  57. package/src/core/OriginalsSDK.ts +420 -0
  58. package/src/crypto/Multikey.ts +194 -0
  59. package/src/crypto/Signer.ts +262 -0
  60. package/src/crypto/noble-init.ts +138 -0
  61. package/src/did/BtcoDidResolver.ts +231 -0
  62. package/src/did/DIDManager.ts +705 -0
  63. package/src/did/Ed25519Verifier.ts +68 -0
  64. package/src/did/KeyManager.ts +239 -0
  65. package/src/did/WebVHManager.ts +499 -0
  66. package/src/did/createBtcoDidDocument.ts +60 -0
  67. package/src/did/providers/OrdinalsClientProviderAdapter.ts +68 -0
  68. package/src/events/EventEmitter.ts +222 -0
  69. package/src/events/index.ts +19 -0
  70. package/src/events/types.ts +331 -0
  71. package/src/examples/basic-usage.ts +78 -0
  72. package/src/examples/create-module-original.ts +435 -0
  73. package/src/examples/full-lifecycle-flow.ts +514 -0
  74. package/src/examples/run.ts +60 -0
  75. package/src/index.ts +204 -0
  76. package/src/kinds/KindRegistry.ts +320 -0
  77. package/src/kinds/index.ts +74 -0
  78. package/src/kinds/types.ts +470 -0
  79. package/src/kinds/validators/AgentValidator.ts +257 -0
  80. package/src/kinds/validators/AppValidator.ts +211 -0
  81. package/src/kinds/validators/DatasetValidator.ts +242 -0
  82. package/src/kinds/validators/DocumentValidator.ts +311 -0
  83. package/src/kinds/validators/MediaValidator.ts +269 -0
  84. package/src/kinds/validators/ModuleValidator.ts +225 -0
  85. package/src/kinds/validators/base.ts +276 -0
  86. package/src/kinds/validators/index.ts +12 -0
  87. package/src/lifecycle/BatchOperations.ts +381 -0
  88. package/src/lifecycle/LifecycleManager.ts +2156 -0
  89. package/src/lifecycle/OriginalsAsset.ts +524 -0
  90. package/src/lifecycle/ProvenanceQuery.ts +280 -0
  91. package/src/lifecycle/ResourceVersioning.ts +163 -0
  92. package/src/migration/MigrationManager.ts +587 -0
  93. package/src/migration/audit/AuditLogger.ts +176 -0
  94. package/src/migration/checkpoint/CheckpointManager.ts +112 -0
  95. package/src/migration/checkpoint/CheckpointStorage.ts +101 -0
  96. package/src/migration/index.ts +33 -0
  97. package/src/migration/operations/BaseMigration.ts +126 -0
  98. package/src/migration/operations/PeerToBtcoMigration.ts +105 -0
  99. package/src/migration/operations/PeerToWebvhMigration.ts +62 -0
  100. package/src/migration/operations/WebvhToBtcoMigration.ts +105 -0
  101. package/src/migration/rollback/RollbackManager.ts +170 -0
  102. package/src/migration/state/StateMachine.ts +92 -0
  103. package/src/migration/state/StateTracker.ts +156 -0
  104. package/src/migration/types.ts +356 -0
  105. package/src/migration/validation/BitcoinValidator.ts +107 -0
  106. package/src/migration/validation/CredentialValidator.ts +62 -0
  107. package/src/migration/validation/DIDCompatibilityValidator.ts +151 -0
  108. package/src/migration/validation/LifecycleValidator.ts +64 -0
  109. package/src/migration/validation/StorageValidator.ts +79 -0
  110. package/src/migration/validation/ValidationPipeline.ts +213 -0
  111. package/src/resources/ResourceManager.ts +655 -0
  112. package/src/resources/index.ts +21 -0
  113. package/src/resources/types.ts +202 -0
  114. package/src/storage/LocalStorageAdapter.ts +64 -0
  115. package/src/storage/MemoryStorageAdapter.ts +29 -0
  116. package/src/storage/StorageAdapter.ts +25 -0
  117. package/src/storage/index.ts +3 -0
  118. package/src/types/bitcoin.ts +98 -0
  119. package/src/types/common.ts +92 -0
  120. package/src/types/credentials.ts +89 -0
  121. package/src/types/did.ts +31 -0
  122. package/src/types/external-shims.d.ts +53 -0
  123. package/src/types/index.ts +7 -0
  124. package/src/types/network.ts +178 -0
  125. package/src/utils/EventLogger.ts +298 -0
  126. package/src/utils/Logger.ts +324 -0
  127. package/src/utils/MetricsCollector.ts +358 -0
  128. package/src/utils/bitcoin-address.ts +132 -0
  129. package/src/utils/cbor.ts +31 -0
  130. package/src/utils/encoding.ts +135 -0
  131. package/src/utils/hash.ts +12 -0
  132. package/src/utils/retry.ts +46 -0
  133. package/src/utils/satoshi-validation.ts +196 -0
  134. package/src/utils/serialization.ts +102 -0
  135. package/src/utils/telemetry.ts +44 -0
  136. package/src/utils/validation.ts +123 -0
  137. package/src/vc/CredentialManager.ts +955 -0
  138. package/src/vc/Issuer.ts +105 -0
  139. package/src/vc/Verifier.ts +54 -0
  140. package/src/vc/cryptosuites/bbs.ts +253 -0
  141. package/src/vc/cryptosuites/bbsSimple.ts +21 -0
  142. package/src/vc/cryptosuites/eddsa.ts +99 -0
  143. package/src/vc/documentLoader.ts +81 -0
  144. package/src/vc/proofs/data-integrity.ts +33 -0
  145. package/src/vc/utils/jsonld.ts +18 -0
package/src/index.ts ADDED
@@ -0,0 +1,204 @@
1
+ /* istanbul ignore file */
2
+ // Initialize noble crypto libraries first (must run before any crypto operations)
3
+ import './crypto/noble-init.js';
4
+
5
+ import { OriginalsSDK } from './core/OriginalsSDK.js';
6
+
7
+ // Main exports
8
+ export { OriginalsSDK } from './core/OriginalsSDK.js';
9
+ export type {
10
+ OriginalsSDKOptions,
11
+ OriginalResult,
12
+ CreateOriginalOptions,
13
+ UpdateOriginalOptions,
14
+ CreateDIDOriginalOptions,
15
+ UpdateDIDOriginalOptions
16
+ } from './core/OriginalsSDK.js';
17
+ export { OriginalsAsset } from './lifecycle/OriginalsAsset.js';
18
+ export type { ProvenanceChain } from './lifecycle/OriginalsAsset.js';
19
+
20
+ // Type exports
21
+ export * from './types/index.js';
22
+
23
+ // Manager exports
24
+ export { DIDManager, type CreateWebVHOptions, type CreateWebVHResult } from './did/DIDManager.js';
25
+ export { KeyManager } from './did/KeyManager.js';
26
+ export { Ed25519Verifier } from './did/Ed25519Verifier.js';
27
+ export * as encoding from './utils/encoding.js';
28
+ export {
29
+ CredentialManager,
30
+ type ResourceCreatedSubject,
31
+ type ResourceUpdatedSubject,
32
+ type MigrationSubject,
33
+ type OwnershipSubject,
34
+ type CredentialChainOptions,
35
+ type SelectiveDisclosureOptions,
36
+ type DerivedProofResult
37
+ } from './vc/CredentialManager.js';
38
+ export {
39
+ LifecycleManager,
40
+ type CostEstimate,
41
+ type MigrationValidation,
42
+ type LifecycleProgress,
43
+ type ProgressCallback,
44
+ type LifecycleOperationOptions
45
+ } from './lifecycle/LifecycleManager.js';
46
+ export { BitcoinManager } from './bitcoin/BitcoinManager.js';
47
+ export { OrdinalsClient } from './bitcoin/OrdinalsClient.js';
48
+ export { buildTransferTransaction } from './bitcoin/transfer.js';
49
+ export { selectUtxos, UtxoSelectionError, estimateFeeSats } from './bitcoin/utxo.js';
50
+ export {
51
+ selectUtxos as selectUtxosSimple,
52
+ selectResourceUtxos,
53
+ selectUtxosForPayment,
54
+ tagResourceUtxos,
55
+ estimateTransactionSize
56
+ } from './bitcoin/utxo-selection.js';
57
+ export { calculateFee } from './bitcoin/fee-calculation.js';
58
+ export { BBSCryptosuiteUtils } from './vc/cryptosuites/bbs.js';
59
+ export { BbsSimple } from './vc/cryptosuites/bbsSimple.js';
60
+ export * from './storage/index.js';
61
+
62
+ // Resource management exports
63
+ export { ResourceManager } from './resources/index.js';
64
+ export type {
65
+ Resource,
66
+ ResourceOptions,
67
+ ResourceUpdateOptions,
68
+ ResourceVersionHistory,
69
+ ResourceManagerConfig,
70
+ ResourceValidationResult,
71
+ ResourceType,
72
+ } from './resources/index.js';
73
+ export { MIME_TYPE_MAP, DEFAULT_RESOURCE_CONFIG } from './resources/index.js';
74
+
75
+ // Crypto exports
76
+ export { Signer, ES256KSigner, Ed25519Signer, ES256Signer, Bls12381G2Signer } from './crypto/Signer.js';
77
+ export { multikey } from './crypto/Multikey.js';
78
+ export type { MultikeyType } from './crypto/Multikey.js';
79
+
80
+ // Event system exports
81
+ export * from './events/index.js';
82
+
83
+ // Migration system exports
84
+ export { MigrationManager } from './migration/index.js';
85
+ export * from './migration/types.js';
86
+
87
+ // Batch operations exports
88
+ export {
89
+ BatchOperationExecutor,
90
+ BatchValidator,
91
+ BatchError,
92
+ type BatchResult,
93
+ type BatchOperationOptions,
94
+ type BatchInscriptionOptions,
95
+ type BatchInscriptionResult,
96
+ type ValidationResult as BatchValidationResult
97
+ } from './lifecycle/BatchOperations.js';
98
+
99
+ // Kind system exports
100
+ export {
101
+ OriginalKind,
102
+ KindRegistry,
103
+ type DependencyRef,
104
+ type BaseManifest,
105
+ type AppMetadata,
106
+ type AgentMetadata,
107
+ type ModuleMetadata,
108
+ type DatasetMetadata,
109
+ type MediaMetadata,
110
+ type DocumentMetadata,
111
+ type KindMetadataMap,
112
+ type KindMetadata,
113
+ type OriginalManifest,
114
+ type AppManifest,
115
+ type AgentManifest,
116
+ type ModuleManifest,
117
+ type DatasetManifest,
118
+ type MediaManifest,
119
+ type DocumentManifest,
120
+ type AnyManifest,
121
+ type ValidationResult as KindValidationResult,
122
+ type ValidationError as KindValidationError,
123
+ type ValidationWarning,
124
+ type CreateTypedOriginalOptions,
125
+ type KindValidator,
126
+ BaseKindValidator,
127
+ ValidationUtils,
128
+ AppValidator,
129
+ AgentValidator,
130
+ ModuleValidator,
131
+ DatasetValidator,
132
+ MediaValidator,
133
+ DocumentValidator,
134
+ } from './kinds/index.js';
135
+
136
+ // Utility exports
137
+ export * from './utils/validation.js';
138
+ export * from './utils/satoshi-validation.js';
139
+ export * from './utils/serialization.js';
140
+ export * from './utils/retry.js';
141
+ export * from './utils/telemetry.js';
142
+ export { sha256Bytes } from './utils/hash.js';
143
+
144
+ // Adapter exports (for testing and custom integrations)
145
+ export { OrdMockProvider } from './adapters/providers/OrdMockProvider.js';
146
+ export { FeeOracleMock } from './adapters/FeeOracleMock.js';
147
+ export type { OrdinalsProvider, FeeOracleAdapter, StorageAdapter } from './adapters/types.js';
148
+
149
+ // CEL (Cryptographic Event Log) exports
150
+ export {
151
+ OriginalsCel,
152
+ type CelLayer,
153
+ type CelSigner,
154
+ type OriginalsCelConfig,
155
+ type OriginalsCelOptions,
156
+ } from './cel/OriginalsCel.js';
157
+ export type {
158
+ EventLog,
159
+ LogEntry,
160
+ EventType,
161
+ DataIntegrityProof,
162
+ WitnessProof,
163
+ ExternalReference,
164
+ VerificationResult,
165
+ EventVerification,
166
+ AssetState,
167
+ CreateOptions,
168
+ UpdateOptions,
169
+ DeactivateOptions,
170
+ VerifyOptions,
171
+ } from './cel/types.js';
172
+ export {
173
+ createEventLog,
174
+ updateEventLog,
175
+ deactivateEventLog,
176
+ verifyEventLog,
177
+ witnessEvent,
178
+ } from './cel/algorithms/index.js';
179
+ export {
180
+ computeDigestMultibase,
181
+ verifyDigestMultibase,
182
+ decodeDigestMultibase,
183
+ } from './cel/hash.js';
184
+ export {
185
+ createExternalReference,
186
+ verifyExternalReference,
187
+ } from './cel/ExternalReferenceManager.js';
188
+ export { PeerCelManager } from './cel/layers/PeerCelManager.js';
189
+ export { WebVHCelManager } from './cel/layers/WebVHCelManager.js';
190
+ export { BtcoCelManager } from './cel/layers/BtcoCelManager.js';
191
+ export type { WitnessService } from './cel/witnesses/WitnessService.js';
192
+ export { HttpWitness, HttpWitnessError } from './cel/witnesses/HttpWitness.js';
193
+ export { BitcoinWitness, BitcoinWitnessError, type BitcoinWitnessProof } from './cel/witnesses/BitcoinWitness.js';
194
+ export {
195
+ serializeEventLogJson,
196
+ parseEventLogJson,
197
+ } from './cel/serialization/json.js';
198
+ export {
199
+ serializeEventLogCbor,
200
+ parseEventLogCbor,
201
+ } from './cel/serialization/cbor.js';
202
+
203
+ // Default export
204
+ export default OriginalsSDK;
@@ -0,0 +1,320 @@
1
+ /**
2
+ * Kind Registry
3
+ *
4
+ * Central registry for Original kinds, providing validation and type management.
5
+ */
6
+
7
+ import {
8
+ OriginalKind,
9
+ type OriginalManifest,
10
+ type ValidationResult,
11
+ type CreateTypedOriginalOptions,
12
+ } from './types';
13
+ import {
14
+ type KindValidator,
15
+ ValidationUtils,
16
+ AppValidator,
17
+ AgentValidator,
18
+ ModuleValidator,
19
+ DatasetValidator,
20
+ MediaValidator,
21
+ DocumentValidator,
22
+ } from './validators';
23
+
24
+ /**
25
+ * Registry for Original kinds
26
+ *
27
+ * Provides centralized validation and type information for all kinds.
28
+ */
29
+ export class KindRegistry {
30
+ private static instance: KindRegistry;
31
+ private validators: Map<OriginalKind, KindValidator<OriginalKind>>;
32
+
33
+ private constructor() {
34
+ this.validators = new Map();
35
+ this.registerDefaultValidators();
36
+ }
37
+
38
+ /**
39
+ * Get the singleton instance
40
+ */
41
+ static getInstance(): KindRegistry {
42
+ if (!KindRegistry.instance) {
43
+ KindRegistry.instance = new KindRegistry();
44
+ }
45
+ return KindRegistry.instance;
46
+ }
47
+
48
+ /**
49
+ * Register default validators for all built-in kinds
50
+ */
51
+ private registerDefaultValidators(): void {
52
+ this.validators.set(OriginalKind.App, new AppValidator());
53
+ this.validators.set(OriginalKind.Agent, new AgentValidator());
54
+ this.validators.set(OriginalKind.Module, new ModuleValidator());
55
+ this.validators.set(OriginalKind.Dataset, new DatasetValidator());
56
+ this.validators.set(OriginalKind.Media, new MediaValidator());
57
+ this.validators.set(OriginalKind.Document, new DocumentValidator());
58
+ }
59
+
60
+ /**
61
+ * Register a custom validator for a kind
62
+ * Can be used to override built-in validators or add new kinds
63
+ */
64
+ registerValidator<K extends OriginalKind>(
65
+ kind: K,
66
+ validator: KindValidator<K>
67
+ ): void {
68
+ this.validators.set(kind, validator as KindValidator<OriginalKind>);
69
+ }
70
+
71
+ /**
72
+ * Get the validator for a kind
73
+ */
74
+ getValidator<K extends OriginalKind>(kind: K): KindValidator<K> | undefined {
75
+ return this.validators.get(kind) as KindValidator<K> | undefined;
76
+ }
77
+
78
+ /**
79
+ * Check if a kind is registered
80
+ */
81
+ hasKind(kind: OriginalKind): boolean {
82
+ return this.validators.has(kind);
83
+ }
84
+
85
+ /**
86
+ * Get all registered kinds
87
+ */
88
+ getRegisteredKinds(): OriginalKind[] {
89
+ return Array.from(this.validators.keys());
90
+ }
91
+
92
+ /**
93
+ * Validate a manifest
94
+ *
95
+ * @param manifest - The manifest to validate
96
+ * @param options - Validation options
97
+ * @returns Validation result
98
+ */
99
+ validate<K extends OriginalKind>(
100
+ manifest: OriginalManifest<K>,
101
+ options?: CreateTypedOriginalOptions
102
+ ): ValidationResult {
103
+ // First check if kind is valid
104
+ if (!manifest.kind) {
105
+ return ValidationUtils.failure([
106
+ ValidationUtils.error('MISSING_KIND', 'Manifest must specify a kind', 'kind'),
107
+ ]);
108
+ }
109
+
110
+ // Check if kind is registered
111
+ if (!this.hasKind(manifest.kind)) {
112
+ return ValidationUtils.failure([
113
+ ValidationUtils.error(
114
+ 'UNKNOWN_KIND',
115
+ `Unknown kind: "${manifest.kind}". Registered kinds: ${this.getRegisteredKinds().join(', ')}`,
116
+ 'kind',
117
+ manifest.kind,
118
+ ),
119
+ ]);
120
+ }
121
+
122
+ // Get validator and run validation
123
+ const validator = this.getValidator(manifest.kind);
124
+ if (!validator) {
125
+ return ValidationUtils.failure([
126
+ ValidationUtils.error('VALIDATOR_NOT_FOUND', `No validator found for kind: ${manifest.kind}`, 'kind'),
127
+ ]);
128
+ }
129
+
130
+ const result = validator.validate(manifest);
131
+
132
+ // In strict mode, treat warnings as errors
133
+ if (options?.strictMode && result.warnings.length > 0) {
134
+ const warningErrors = result.warnings.map(w =>
135
+ ValidationUtils.error(
136
+ `STRICT_${w.code}`,
137
+ `[Warning treated as error] ${w.message}`,
138
+ w.path,
139
+ )
140
+ );
141
+ return ValidationUtils.failure([...result.errors, ...warningErrors], []);
142
+ }
143
+
144
+ return result;
145
+ }
146
+
147
+ /**
148
+ * Validate a manifest and throw if invalid
149
+ */
150
+ validateOrThrow<K extends OriginalKind>(
151
+ manifest: OriginalManifest<K>,
152
+ options?: CreateTypedOriginalOptions
153
+ ): void {
154
+ if (options?.skipValidation) {
155
+ return;
156
+ }
157
+
158
+ const result = this.validate(manifest, options);
159
+
160
+ if (!result.isValid) {
161
+ const errorMessages = result.errors.map(e => {
162
+ const path = e.path ? ` at ${e.path}` : '';
163
+ return `[${e.code}]${path}: ${e.message}`;
164
+ });
165
+
166
+ throw new Error(`Manifest validation failed:\n${errorMessages.join('\n')}`);
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Check if a value is a valid OriginalKind
172
+ */
173
+ static isValidKind(value: unknown): value is OriginalKind {
174
+ return typeof value === 'string' && Object.values(OriginalKind).includes(value as OriginalKind);
175
+ }
176
+
177
+ /**
178
+ * Parse a kind string to OriginalKind
179
+ * Accepts both full URIs (originals:kind:app) and short names (app)
180
+ */
181
+ static parseKind(value: string): OriginalKind | null {
182
+ // Check if it's already a full kind URI
183
+ if (KindRegistry.isValidKind(value)) {
184
+ return value;
185
+ }
186
+
187
+ // Try to match short name
188
+ const normalized = value.toLowerCase().trim();
189
+ for (const kind of Object.values(OriginalKind)) {
190
+ const shortName = kind.split(':').pop()?.toLowerCase();
191
+ if (shortName === normalized) {
192
+ return kind;
193
+ }
194
+ }
195
+
196
+ return null;
197
+ }
198
+
199
+ /**
200
+ * Get the short name of a kind (e.g., "app" from "originals:kind:app")
201
+ */
202
+ static getShortName(kind: OriginalKind): string {
203
+ return kind.split(':').pop() || kind;
204
+ }
205
+
206
+ /**
207
+ * Get human-readable display name for a kind
208
+ */
209
+ static getDisplayName(kind: OriginalKind): string {
210
+ const shortName = KindRegistry.getShortName(kind);
211
+ return shortName.charAt(0).toUpperCase() + shortName.slice(1);
212
+ }
213
+
214
+ /**
215
+ * Create an empty manifest template for a kind
216
+ * Useful for scaffolding new Originals
217
+ */
218
+ static createTemplate<K extends OriginalKind>(
219
+ kind: K,
220
+ name: string,
221
+ version = '1.0.0'
222
+ ): Partial<OriginalManifest<K>> {
223
+ const base = {
224
+ kind,
225
+ name,
226
+ version,
227
+ resources: [],
228
+ };
229
+
230
+ // Add kind-specific metadata templates
231
+ switch (kind) {
232
+ case OriginalKind.App: {
233
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
234
+ const appMetadata = {
235
+ runtime: 'node',
236
+ entrypoint: 'index.js',
237
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
238
+ } as any;
239
+ return {
240
+ ...base,
241
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
242
+ metadata: appMetadata,
243
+ };
244
+ }
245
+
246
+ case OriginalKind.Agent: {
247
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
248
+ const agentMetadata = {
249
+ capabilities: [],
250
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
251
+ } as any;
252
+ return {
253
+ ...base,
254
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
255
+ metadata: agentMetadata,
256
+ };
257
+ }
258
+
259
+ case OriginalKind.Module: {
260
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
261
+ const moduleMetadata = {
262
+ format: 'esm',
263
+ main: 'index.js',
264
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
265
+ } as any;
266
+ return {
267
+ ...base,
268
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
269
+ metadata: moduleMetadata,
270
+ };
271
+ }
272
+
273
+ case OriginalKind.Dataset: {
274
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
275
+ const datasetMetadata = {
276
+ format: 'json',
277
+ schema: {},
278
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
279
+ } as any;
280
+ return {
281
+ ...base,
282
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
283
+ metadata: datasetMetadata,
284
+ };
285
+ }
286
+
287
+ case OriginalKind.Media: {
288
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
289
+ const mediaMetadata = {
290
+ mediaType: 'image',
291
+ mimeType: 'image/png',
292
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
293
+ } as any;
294
+ return {
295
+ ...base,
296
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
297
+ metadata: mediaMetadata,
298
+ };
299
+ }
300
+
301
+ case OriginalKind.Document: {
302
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
303
+ const documentMetadata = {
304
+ format: 'markdown',
305
+ content: 'content',
306
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
307
+ } as any;
308
+ return {
309
+ ...base,
310
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
311
+ metadata: documentMetadata,
312
+ };
313
+ }
314
+
315
+ default:
316
+ return base;
317
+ }
318
+ }
319
+ }
320
+
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Originals Kind System
3
+ *
4
+ * Provides typed "Kinds" for Originals - a classification system that
5
+ * enables kind-specific validation, metadata schemas, and behaviors.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { OriginalKind, KindRegistry } from '@originals/sdk';
10
+ *
11
+ * // Create an App Original manifest
12
+ * const appManifest = {
13
+ * kind: OriginalKind.App,
14
+ * name: 'MyApp',
15
+ * version: '1.0.0',
16
+ * resources: [entrypointResource],
17
+ * metadata: {
18
+ * runtime: 'node',
19
+ * entrypoint: 'index.js',
20
+ * },
21
+ * };
22
+ *
23
+ * // Validate the manifest
24
+ * const registry = KindRegistry.getInstance();
25
+ * const result = registry.validate(appManifest);
26
+ * if (!result.isValid) {
27
+ * console.error('Validation errors:', result.errors);
28
+ * }
29
+ * ```
30
+ */
31
+
32
+ // Type exports
33
+ export {
34
+ OriginalKind,
35
+ type DependencyRef,
36
+ type BaseManifest,
37
+ type AppMetadata,
38
+ type AgentMetadata,
39
+ type ModuleMetadata,
40
+ type DatasetMetadata,
41
+ type MediaMetadata,
42
+ type DocumentMetadata,
43
+ type KindMetadataMap,
44
+ type KindMetadata,
45
+ type OriginalManifest,
46
+ type AppManifest,
47
+ type AgentManifest,
48
+ type ModuleManifest,
49
+ type DatasetManifest,
50
+ type MediaManifest,
51
+ type DocumentManifest,
52
+ type AnyManifest,
53
+ type ValidationResult,
54
+ type ValidationError,
55
+ type ValidationWarning,
56
+ type CreateTypedOriginalOptions,
57
+ } from './types';
58
+
59
+ // Registry export
60
+ export { KindRegistry } from './KindRegistry';
61
+
62
+ // Validator exports (for extension/customization)
63
+ export {
64
+ type KindValidator,
65
+ BaseKindValidator,
66
+ ValidationUtils,
67
+ AppValidator,
68
+ AgentValidator,
69
+ ModuleValidator,
70
+ DatasetValidator,
71
+ MediaValidator,
72
+ DocumentValidator,
73
+ } from './validators';
74
+