@world-engines/tmw 0.1.0-alpha.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 (120) hide show
  1. package/LICENSE +46 -0
  2. package/dist/activation.d.ts +50 -0
  3. package/dist/activation.js +113 -0
  4. package/dist/audio-presentation-projection.d.ts +23 -0
  5. package/dist/audio-presentation-projection.js +39 -0
  6. package/dist/author-scenario-source-v3.d.ts +34 -0
  7. package/dist/author-scenario-source-v3.js +1 -0
  8. package/dist/authoring-runtime.d.ts +76 -0
  9. package/dist/authoring-runtime.js +282 -0
  10. package/dist/builder-diagnostics.d.ts +3 -0
  11. package/dist/builder-diagnostics.js +8 -0
  12. package/dist/builder-node.d.ts +178 -0
  13. package/dist/builder-node.js +212 -0
  14. package/dist/builder.d.ts +32 -0
  15. package/dist/builder.js +127 -0
  16. package/dist/capability-registry.d.ts +32 -0
  17. package/dist/capability-registry.js +33 -0
  18. package/dist/compile-target-profile.d.ts +16 -0
  19. package/dist/compile-target-profile.js +70 -0
  20. package/dist/compiled-plan.d.ts +44 -0
  21. package/dist/compiled-plan.js +1 -0
  22. package/dist/compiler-compatibility-gate.d.ts +96 -0
  23. package/dist/compiler-compatibility-gate.js +609 -0
  24. package/dist/compiler-release-authority.d.ts +212 -0
  25. package/dist/compiler-release-authority.js +676 -0
  26. package/dist/compiler-stage-cache.d.ts +42 -0
  27. package/dist/compiler-stage-cache.js +100 -0
  28. package/dist/compiler-stage-registry.d.ts +48 -0
  29. package/dist/compiler-stage-registry.js +126 -0
  30. package/dist/compiler.d.ts +7 -0
  31. package/dist/compiler.js +68 -0
  32. package/dist/condition-graph.d.ts +46 -0
  33. package/dist/condition-graph.js +135 -0
  34. package/dist/diagnostics.d.ts +20 -0
  35. package/dist/diagnostics.js +20 -0
  36. package/dist/durable-intent.d.ts +29 -0
  37. package/dist/durable-intent.js +60 -0
  38. package/dist/effect-flow.d.ts +69 -0
  39. package/dist/effect-flow.js +98 -0
  40. package/dist/event-fabric.d.ts +81 -0
  41. package/dist/event-fabric.js +227 -0
  42. package/dist/event-lifecycle.d.ts +59 -0
  43. package/dist/event-lifecycle.js +161 -0
  44. package/dist/evidence.d.ts +37 -0
  45. package/dist/evidence.js +92 -0
  46. package/dist/gameplay-state.d.ts +127 -0
  47. package/dist/gameplay-state.js +214 -0
  48. package/dist/index.d.ts +66 -0
  49. package/dist/index.js +52 -0
  50. package/dist/isolated-replay.d.ts +81 -0
  51. package/dist/isolated-replay.js +316 -0
  52. package/dist/music-candidate-set.d.ts +38 -0
  53. package/dist/music-candidate-set.js +102 -0
  54. package/dist/natural-language-chunking.d.ts +10 -0
  55. package/dist/natural-language-chunking.js +62 -0
  56. package/dist/natural-language-ingestion.d.ts +14 -0
  57. package/dist/natural-language-ingestion.js +128 -0
  58. package/dist/natural-language-structured-decode.d.ts +2 -0
  59. package/dist/natural-language-structured-decode.js +69 -0
  60. package/dist/natural-language-world-types.d.ts +142 -0
  61. package/dist/natural-language-world-types.js +2 -0
  62. package/dist/neutral-source-compiler.d.ts +135 -0
  63. package/dist/neutral-source-compiler.js +608 -0
  64. package/dist/presentation-intent.d.ts +42 -0
  65. package/dist/presentation-intent.js +137 -0
  66. package/dist/recall-query-envelope.d.ts +32 -0
  67. package/dist/recall-query-envelope.js +51 -0
  68. package/dist/rewrite-compensation.d.ts +28 -0
  69. package/dist/rewrite-compensation.js +85 -0
  70. package/dist/runtime-contract.d.ts +56 -0
  71. package/dist/runtime-contract.js +96 -0
  72. package/dist/runtime-domain-capabilities.d.ts +12 -0
  73. package/dist/runtime-domain-capabilities.js +20 -0
  74. package/dist/runtime-sav.d.ts +117 -0
  75. package/dist/runtime-sav.js +356 -0
  76. package/dist/runtime-trace.d.ts +44 -0
  77. package/dist/runtime-trace.js +119 -0
  78. package/dist/runtime.d.ts +238 -0
  79. package/dist/runtime.js +1887 -0
  80. package/dist/scene-author-source.d.ts +13 -0
  81. package/dist/scene-author-source.js +25 -0
  82. package/dist/scene-state.d.ts +275 -0
  83. package/dist/scene-state.js +334 -0
  84. package/dist/scheduler.d.ts +55 -0
  85. package/dist/scheduler.js +235 -0
  86. package/dist/selector-ast.d.ts +24 -0
  87. package/dist/selector-ast.js +18 -0
  88. package/dist/semantic-verdict.d.ts +48 -0
  89. package/dist/semantic-verdict.js +101 -0
  90. package/dist/simulator.d.ts +45 -0
  91. package/dist/simulator.js +58 -0
  92. package/dist/source-canonical.d.ts +4 -0
  93. package/dist/source-canonical.js +51 -0
  94. package/dist/source-crypto.d.ts +20 -0
  95. package/dist/source-crypto.js +17 -0
  96. package/dist/source-revision.d.ts +22 -0
  97. package/dist/source-revision.js +43 -0
  98. package/dist/spatial-impact-receipt.d.ts +38 -0
  99. package/dist/spatial-impact-receipt.js +67 -0
  100. package/dist/temporal-rewrite.d.ts +59 -0
  101. package/dist/temporal-rewrite.js +214 -0
  102. package/dist/time-domains.d.ts +37 -0
  103. package/dist/time-domains.js +142 -0
  104. package/dist/timeline-revision.d.ts +28 -0
  105. package/dist/timeline-revision.js +59 -0
  106. package/dist/trigger-document-v3.d.ts +99 -0
  107. package/dist/trigger-document-v3.js +334 -0
  108. package/dist/turn-commit.d.ts +56 -0
  109. package/dist/turn-commit.js +190 -0
  110. package/dist/validator.d.ts +7 -0
  111. package/dist/validator.js +142 -0
  112. package/dist/value-graph.d.ts +98 -0
  113. package/dist/value-graph.js +318 -0
  114. package/dist/view-event-delivery.d.ts +47 -0
  115. package/dist/view-event-delivery.js +197 -0
  116. package/dist/view-interaction-manifest-v3.d.ts +60 -0
  117. package/dist/view-interaction-manifest-v3.js +198 -0
  118. package/dist/view-payload-schema.d.ts +17 -0
  119. package/dist/view-payload-schema.js +84 -0
  120. package/package.json +62 -0
@@ -0,0 +1,70 @@
1
+ import { canonicalTmwBytes, tmwSha256Hex } from "./runtime-contract.js";
2
+ export const COMPILE_TARGET_PROFILE_SCHEMA_VERSION = 1;
3
+ const IDENTIFIER_PATTERN = /^[a-z0-9][a-z0-9._-]{0,127}$/u;
4
+ function compareAscii(left, right) {
5
+ return left < right ? -1 : left > right ? 1 : 0;
6
+ }
7
+ function requireIdentifier(value, code) {
8
+ if (typeof value !== "string"
9
+ || !IDENTIFIER_PATTERN.test(value)
10
+ || value !== value.normalize("NFC"))
11
+ throw new Error(code);
12
+ return value;
13
+ }
14
+ function plainObject(value, code) {
15
+ if (typeof value !== "object"
16
+ || value === null
17
+ || Array.isArray(value)
18
+ || Object.getPrototypeOf(value) !== Object.prototype)
19
+ throw new Error(code);
20
+ return value;
21
+ }
22
+ function exactKeys(value, expected, code) {
23
+ const actual = Object.keys(value).sort();
24
+ const canonical = [...expected].sort();
25
+ if (actual.length !== canonical.length
26
+ || actual.some((key, index) => key !== canonical[index]))
27
+ throw new Error(code);
28
+ }
29
+ export function parseCompileTargetProfile(value) {
30
+ const profile = plainObject(value, "compile_target_profile_object_required");
31
+ exactKeys(profile, [
32
+ "schema_version",
33
+ "compiler_release",
34
+ "runtime_semantics",
35
+ "sdk_schema",
36
+ "artifact_format",
37
+ "stage_versions",
38
+ ], "compile_target_profile_fields_mismatch");
39
+ if (profile.schema_version !== COMPILE_TARGET_PROFILE_SCHEMA_VERSION) {
40
+ throw new Error("compile_target_profile_schema_version_invalid");
41
+ }
42
+ if (!Array.isArray(profile.stage_versions) || profile.stage_versions.length === 0) {
43
+ throw new Error("compile_target_profile_stage_versions_required");
44
+ }
45
+ const stageVersions = profile.stage_versions.map((value, index) => {
46
+ const stage = plainObject(value, `compile_target_stage_version_object_required:${index}`);
47
+ exactKeys(stage, ["stage_id", "stage_version"], `compile_target_stage_version_fields_mismatch:${index}`);
48
+ return Object.freeze({
49
+ stage_id: requireIdentifier(stage.stage_id, `compile_target_stage_id_invalid:${index}`),
50
+ stage_version: requireIdentifier(stage.stage_version, `compile_target_stage_version_invalid:${index}`),
51
+ });
52
+ }).sort((left, right) => compareAscii(left.stage_id, right.stage_id));
53
+ if (new Set(stageVersions.map((stage) => stage.stage_id)).size !== stageVersions.length) {
54
+ throw new Error("compile_target_stage_id_duplicate");
55
+ }
56
+ return Object.freeze({
57
+ schema_version: COMPILE_TARGET_PROFILE_SCHEMA_VERSION,
58
+ compiler_release: requireIdentifier(profile.compiler_release, "compile_target_compiler_release_invalid"),
59
+ runtime_semantics: requireIdentifier(profile.runtime_semantics, "compile_target_runtime_semantics_invalid"),
60
+ sdk_schema: requireIdentifier(profile.sdk_schema, "compile_target_sdk_schema_invalid"),
61
+ artifact_format: requireIdentifier(profile.artifact_format, "compile_target_artifact_format_invalid"),
62
+ stage_versions: Object.freeze(stageVersions),
63
+ });
64
+ }
65
+ export function canonicalCompileTargetProfileBytes(profile) {
66
+ return canonicalTmwBytes(parseCompileTargetProfile(profile));
67
+ }
68
+ export async function compileTargetProfileDigest(profile) {
69
+ return tmwSha256Hex(canonicalCompileTargetProfileBytes(profile));
70
+ }
@@ -0,0 +1,44 @@
1
+ import type { TMW_RUNTIME_GENERATION } from "./runtime-contract.js";
2
+ import type { TmwDiagnostic } from "./diagnostics.js";
3
+ import type { TmwJsonValue } from "./runtime-contract.js";
4
+ import type { EffectExecutionPolicy, EffectRewritePolicy } from "./effect-flow.js";
5
+ import type { TriggerEdgeV3, TriggerNodeKindV3 } from "./trigger-document-v3.js";
6
+ import type { TmwEffectiveTime } from "./time-domains.js";
7
+ interface CompiledPlanNodeV3Base {
8
+ readonly stable_id: string;
9
+ readonly kind: TriggerNodeKindV3;
10
+ readonly effective_time: TmwEffectiveTime;
11
+ readonly dependencies: readonly string[];
12
+ readonly canonical_payload: TmwJsonValue;
13
+ }
14
+ export type CompiledPlanNodeV3 = (CompiledPlanNodeV3Base & {
15
+ readonly kind: "effect";
16
+ readonly execution_policy: EffectExecutionPolicy;
17
+ readonly rewrite_policy: EffectRewritePolicy;
18
+ readonly priority: number;
19
+ readonly idempotency_key: string;
20
+ }) | (CompiledPlanNodeV3Base & {
21
+ readonly kind: Exclude<TriggerNodeKindV3, "effect">;
22
+ });
23
+ export interface CompiledPlanV3Core {
24
+ readonly plan_version: 3;
25
+ readonly runtime_generation: typeof TMW_RUNTIME_GENERATION;
26
+ readonly runtime_contract_hash: string;
27
+ readonly registry_version: string;
28
+ readonly document_sha256: string;
29
+ readonly nodes: readonly CompiledPlanNodeV3[];
30
+ readonly edges: readonly TriggerEdgeV3[];
31
+ readonly value_graph?: import("./value-graph.js").TmwValueGraphV1;
32
+ }
33
+ export interface CompiledPlanV3 extends CompiledPlanV3Core {
34
+ readonly plan_sha256: string;
35
+ }
36
+ export type CompileTmw3Result = {
37
+ readonly ok: true;
38
+ readonly plan: CompiledPlanV3;
39
+ readonly diagnostics: readonly TmwDiagnostic[];
40
+ } | {
41
+ readonly ok: false;
42
+ readonly diagnostics: readonly TmwDiagnostic[];
43
+ };
44
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,96 @@
1
+ import { type CompileTargetProfile } from "./compile-target-profile.js";
2
+ import type { CompilerStageCache } from "./compiler-stage-cache.js";
3
+ import type { CompilerStageRegistry } from "./compiler-stage-registry.js";
4
+ import { type NeutralSourceCompilerReceipt } from "./neutral-source-compiler.js";
5
+ export declare const ACCEPTED_NEUTRAL_SOURCE_CORPUS_SCHEMA_VERSION: 1;
6
+ export interface AcceptedNeutralSourceSectionDigest {
7
+ readonly section_key: string;
8
+ readonly sha256: string;
9
+ readonly byte_length: string;
10
+ }
11
+ export interface AcceptedNeutralSourceByteRangeWitness {
12
+ readonly kind: string;
13
+ readonly path: string;
14
+ readonly start: string;
15
+ readonly end: string;
16
+ readonly sha256: string;
17
+ }
18
+ export interface AcceptedNeutralSourceContentWitness {
19
+ readonly kind: string;
20
+ readonly section_key: string;
21
+ readonly sha256: string;
22
+ readonly metrics: Readonly<Record<string, string>>;
23
+ }
24
+ export interface AcceptedNeutralSourcePreservedSectionDigest {
25
+ readonly section_key: string;
26
+ readonly sha256: string;
27
+ }
28
+ export interface AcceptedNeutralSourceSizeWitness {
29
+ readonly kind: string;
30
+ readonly limit_bytes: string;
31
+ readonly source_byte_length: string;
32
+ readonly plus_one_byte_length: string;
33
+ }
34
+ export interface AcceptedNeutralSourceMutationWitness {
35
+ readonly after_head_sha256: string;
36
+ readonly after_manifest_sha256: string;
37
+ readonly after_revision: string;
38
+ readonly after_source_sha256: string;
39
+ readonly after_value_sha256: string;
40
+ readonly author_client: string;
41
+ readonly before_head_sha256: string;
42
+ readonly before_manifest_sha256: string;
43
+ readonly before_revision: string;
44
+ readonly before_source_base64: string;
45
+ readonly before_source_sha256: string;
46
+ readonly before_value_sha256: string;
47
+ readonly changed_field_path: string;
48
+ readonly changed_section_key: string;
49
+ readonly operation_id: string;
50
+ readonly preserved_section_digests: readonly AcceptedNeutralSourcePreservedSectionDigest[];
51
+ readonly preserved_unknown_sha256s: readonly string[];
52
+ }
53
+ export interface AcceptedNeutralSourceCorpusEntry {
54
+ readonly fixture_id: string;
55
+ readonly relative_path: string;
56
+ readonly source_sha256: string;
57
+ readonly scenario_id: string;
58
+ readonly manifest_sha256: string;
59
+ readonly acceptance_ref: string;
60
+ readonly section_digests: readonly AcceptedNeutralSourceSectionDigest[];
61
+ readonly target_profiles: readonly CompileTargetProfile[];
62
+ readonly byte_range_witnesses: readonly AcceptedNeutralSourceByteRangeWitness[];
63
+ readonly content_witnesses: readonly AcceptedNeutralSourceContentWitness[];
64
+ readonly mutation_witnesses: readonly AcceptedNeutralSourceMutationWitness[];
65
+ readonly size_witnesses: readonly AcceptedNeutralSourceSizeWitness[];
66
+ }
67
+ export interface AcceptedNeutralSourceCorpus {
68
+ readonly schema_version: typeof ACCEPTED_NEUTRAL_SOURCE_CORPUS_SCHEMA_VERSION;
69
+ readonly sources: readonly AcceptedNeutralSourceCorpusEntry[];
70
+ }
71
+ export interface CompilerCompatibilityCandidate {
72
+ readonly target_profile: CompileTargetProfile;
73
+ readonly registry: CompilerStageRegistry;
74
+ createCache(): CompilerStageCache;
75
+ }
76
+ export interface CompilerCompatibilityFixturePass {
77
+ readonly fixture_id: string;
78
+ readonly source_sha256: string;
79
+ readonly manifest_sha256: string;
80
+ readonly receipt: NeutralSourceCompilerReceipt;
81
+ }
82
+ export interface CompilerCompatibilityFixtureFailure {
83
+ readonly fixture_id: string;
84
+ readonly code: string;
85
+ }
86
+ export type CompilerCompatibilityGateResult = {
87
+ readonly promotable: true;
88
+ readonly passes: readonly CompilerCompatibilityFixturePass[];
89
+ readonly failures: readonly never[];
90
+ } | {
91
+ readonly promotable: false;
92
+ readonly passes: readonly CompilerCompatibilityFixturePass[];
93
+ readonly failures: readonly CompilerCompatibilityFixtureFailure[];
94
+ };
95
+ export declare function parseAcceptedNeutralSourceCorpus(value: unknown): AcceptedNeutralSourceCorpus;
96
+ export declare function evaluateCompilerCandidate(candidate: CompilerCompatibilityCandidate, corpusValue: unknown, loadFixture: (relativePath: string) => Promise<Uint8Array>): Promise<CompilerCompatibilityGateResult>;