@spellkave/sdk 0.0.0-stage → 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 (144) hide show
  1. package/LICENSE +89 -0
  2. package/README.md +155 -2
  3. package/package.json +63 -4
  4. package/src/binding_rows.ts +186 -0
  5. package/src/connection.ts +964 -0
  6. package/src/core/actor.ts +62 -0
  7. package/src/core/actor_control.ts +193 -0
  8. package/src/core/actor_control_query_methods.ts +101 -0
  9. package/src/core/actor_control_reaction_methods.ts +79 -0
  10. package/src/core/actor_control_sense_methods.ts +81 -0
  11. package/src/core/actor_control_source.ts +57 -0
  12. package/src/core/actor_session_methods.ts +226 -0
  13. package/src/core/binding_drift.ts +301 -0
  14. package/src/core/credential.ts +259 -0
  15. package/src/core/driver_control.ts +54 -0
  16. package/src/core/effective_environment_state.ts +71 -0
  17. package/src/core/factored_manipulation_attempt.ts +158 -0
  18. package/src/core/ids.ts +60 -0
  19. package/src/core/interaction/canonical.ts +15 -0
  20. package/src/core/interaction/fingerprint.ts +118 -0
  21. package/src/core/interaction/index.ts +31 -0
  22. package/src/core/interaction/intent.ts +284 -0
  23. package/src/core/interaction/outcome.ts +67 -0
  24. package/src/core/interaction/rejection_ledger.ts +108 -0
  25. package/src/core/kernel_contract.generated.ts +10 -0
  26. package/src/core/log.ts +23 -0
  27. package/src/core/movement.ts +111 -0
  28. package/src/core/node-io.ts +208 -0
  29. package/src/core/paths.ts +220 -0
  30. package/src/core/profile.ts +270 -0
  31. package/src/core/profiles.ts +9 -0
  32. package/src/core/provenance_buffer.ts +102 -0
  33. package/src/core/readers/_helpers.ts +273 -0
  34. package/src/core/readers/action_description.ts +17 -0
  35. package/src/core/readers/action_economy_events.ts +149 -0
  36. package/src/core/readers/actor_body_swaps.ts +62 -0
  37. package/src/core/readers/actor_snapshot.ts +197 -0
  38. package/src/core/readers/actor_states.ts +163 -0
  39. package/src/core/readers/actors_and_bodies.ts +179 -0
  40. package/src/core/readers/affordance_cue.ts +59 -0
  41. package/src/core/readers/affordance_defaults.ts +158 -0
  42. package/src/core/readers/affordance_group_membership.ts +67 -0
  43. package/src/core/readers/affordance_input.ts +129 -0
  44. package/src/core/readers/affordance_reference.ts +41 -0
  45. package/src/core/readers/apply_consequences.ts +54 -0
  46. package/src/core/readers/audience_trace_presentation.ts +62 -0
  47. package/src/core/readers/bounded_collection.ts +29 -0
  48. package/src/core/readers/bundle_definitions.ts +74 -0
  49. package/src/core/readers/bundle_entities.ts +62 -0
  50. package/src/core/readers/co_location.ts +71 -0
  51. package/src/core/readers/combat_session.ts +124 -0
  52. package/src/core/readers/combat_session_active.ts +44 -0
  53. package/src/core/readers/combat_session_feedback.ts +37 -0
  54. package/src/core/readers/combat_session_grid.ts +117 -0
  55. package/src/core/readers/combat_session_roster.ts +98 -0
  56. package/src/core/readers/combat_session_types.ts +51 -0
  57. package/src/core/readers/condition_deltas.ts +53 -0
  58. package/src/core/readers/container_contents.ts +92 -0
  59. package/src/core/readers/dialogue_guide.ts +99 -0
  60. package/src/core/readers/dialogue_prompt_presentation.ts +90 -0
  61. package/src/core/readers/driver_control.ts +64 -0
  62. package/src/core/readers/entity_art.ts +219 -0
  63. package/src/core/readers/entity_containment.ts +119 -0
  64. package/src/core/readers/equipment.ts +99 -0
  65. package/src/core/readers/intervention_windows.ts +136 -0
  66. package/src/core/readers/inventory_query.ts +145 -0
  67. package/src/core/readers/item_detail.ts +198 -0
  68. package/src/core/readers/location_snapshot.ts +216 -0
  69. package/src/core/readers/manifest_apply_provenance.ts +32 -0
  70. package/src/core/readers/manifest_export.ts +81 -0
  71. package/src/core/readers/manipulation_context.ts +475 -0
  72. package/src/core/readers/map_layers.ts +49 -0
  73. package/src/core/readers/metadata_rows.ts +56 -0
  74. package/src/core/readers/object_state.ts +124 -0
  75. package/src/core/readers/observer_knowledge.ts +41 -0
  76. package/src/core/readers/observer_place_knowledge.ts +37 -0
  77. package/src/core/readers/observer_trace_knowledge.ts +45 -0
  78. package/src/core/readers/outcome_template.ts +41 -0
  79. package/src/core/readers/place_topology.ts +109 -0
  80. package/src/core/readers/reaction_options.ts +156 -0
  81. package/src/core/readers/resource_deltas.ts +47 -0
  82. package/src/core/readers/scene.ts +275 -0
  83. package/src/core/readers/seats.ts +33 -0
  84. package/src/core/readers/self.ts +245 -0
  85. package/src/core/readers/self_capabilities.ts +159 -0
  86. package/src/core/readers/self_economy.ts +101 -0
  87. package/src/core/readers/self_economy_budget.ts +93 -0
  88. package/src/core/readers/self_evaluations.ts +128 -0
  89. package/src/core/readers/self_identity.ts +104 -0
  90. package/src/core/readers/sense_context.ts +112 -0
  91. package/src/core/readers/session.ts +207 -0
  92. package/src/core/readers/session_detail.ts +211 -0
  93. package/src/core/readers/session_status.ts +68 -0
  94. package/src/core/readers/spatial_environment_state.ts +74 -0
  95. package/src/core/readers/spatial_niche_attachments.ts +28 -0
  96. package/src/core/readers/substrate_definitions.ts +27 -0
  97. package/src/core/readers/suggest_next_action.ts +72 -0
  98. package/src/core/readers/surface_membership.ts +78 -0
  99. package/src/core/readers/tag_reads.ts +54 -0
  100. package/src/core/readers/trace_query.ts +120 -0
  101. package/src/core/readers/trace_response.ts +80 -0
  102. package/src/core/readers/traces.ts +124 -0
  103. package/src/core/readers/travel_session.ts +88 -0
  104. package/src/core/readers/turn_state.ts +34 -0
  105. package/src/core/readers/world_events.ts +43 -0
  106. package/src/core/readers/world_status.ts +63 -0
  107. package/src/core/reducers/manipulation_args.ts +239 -0
  108. package/src/core/reducers/manipulation_receipt.ts +66 -0
  109. package/src/core/reducers/r_actor_wake_up.ts +32 -0
  110. package/src/core/reducers/r_inscribe_trace.ts +109 -0
  111. package/src/core/reducers/r_manipulate.ts +163 -0
  112. package/src/core/reducers/r_move.ts +155 -0
  113. package/src/core/reducers/r_react.ts +143 -0
  114. package/src/core/reducers/r_release_claim.ts +81 -0
  115. package/src/core/reducers/r_sense.ts +84 -0
  116. package/src/core/reducers/r_session_close.ts +130 -0
  117. package/src/core/reducers/r_session_move.ts +116 -0
  118. package/src/core/reducers/r_session_open.ts +91 -0
  119. package/src/core/reducers/session_lookup.ts +64 -0
  120. package/src/core/reducers/tick.ts +65 -0
  121. package/src/core/reducers/trace_lookup.ts +29 -0
  122. package/src/core/reducers/transport.ts +84 -0
  123. package/src/core/resolve.ts +228 -0
  124. package/src/core/shape_telemetry.ts +146 -0
  125. package/src/core/snapshot_rows.ts +109 -0
  126. package/src/core/tick_cadence.ts +61 -0
  127. package/src/core/types.ts +501 -0
  128. package/src/core/watch_provenance.ts +113 -0
  129. package/src/core/world-contract/classify.ts +38 -0
  130. package/src/core/world-contract/index.ts +12 -0
  131. package/src/core/world-contract/normalise.ts +574 -0
  132. package/src/core/world-contract/runtime.ts +144 -0
  133. package/src/core/world-contract/served.ts +173 -0
  134. package/src/core/world-contract/strict-reducers.ts +14 -0
  135. package/src/core/world-contract/typetext.ts +94 -0
  136. package/src/core/world_time.ts +22 -0
  137. package/src/index.ts +262 -0
  138. package/src/manifest-apply.ts +497 -0
  139. package/src/provenance.ts +568 -0
  140. package/src/reader-manifest.ts +338 -0
  141. package/src/readers.ts +392 -0
  142. package/src/replay.ts +515 -0
  143. package/src/watch-buffer.ts +438 -0
  144. package/src/world-events/builder.ts +1042 -0
package/LICENSE ADDED
@@ -0,0 +1,89 @@
1
+ # PolyForm Shield License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/shield/1.0.0>
4
+
5
+ ## Acceptance
6
+
7
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
12
+
13
+ ## Distribution License
14
+
15
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
16
+
17
+ ## Notices
18
+
19
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
20
+
21
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
22
+
23
+ ## Changes and New Works License
24
+
25
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
26
+
27
+ ## Patent License
28
+
29
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
30
+
31
+ ## Noncompete
32
+
33
+ Any purpose is a permitted purpose, except for providing any product that competes with the software or any product the licensor or any of its affiliates provides using the software.
34
+
35
+ ## Competition
36
+
37
+ Goods and services compete even when they provide functionality through different kinds of interfaces or for different technical platforms. Applications can compete with services, libraries with plugins, frameworks with development tools, and so on, even if they're written in different programming languages or for different computer architectures. Goods and services compete even when provided free of charge. If you market a product as a practical substitute for the software or another product, it definitely competes.
38
+
39
+ ## New Products
40
+
41
+ If you are using the software to provide a product that does not compete, but the licensor or any of its affiliates brings your product into competition by providing a new version of the software or another product using the software, you may continue using versions of the software available under these terms beforehand to provide your competing product, but not any later versions.
42
+
43
+ ## Discontinued Products
44
+
45
+ You may begin using the software to compete with a product or service that the licensor or any of its affiliates has stopped providing, unless the licensor includes a plain-text line beginning with `Licensor Line of Business:` with the software that mentions that line of business. For example:
46
+
47
+ > Licensor Line of Business: YoyodyneCMS Content Management System (http://example.com/cms)
48
+
49
+ ## Sales of Business
50
+
51
+ If the licensor or any of its affiliates sells a line of business developing the software or using the software to provide a product, the buyer can also enforce [Noncompete](#noncompete) for that product.
52
+
53
+ ## Fair Use
54
+
55
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
56
+
57
+ ## No Other Rights
58
+
59
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
60
+
61
+ ## Patent Defense
62
+
63
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
64
+
65
+ ## Violations
66
+
67
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
68
+
69
+ ## No Liability
70
+
71
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
72
+
73
+ ## Definitions
74
+
75
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
76
+
77
+ A **product** can be a good or service, or a combination of them.
78
+
79
+ **You** refers to the individual or entity agreeing to these terms.
80
+
81
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all its affiliates.
82
+
83
+ **Affiliates** means the other organizations than an organization has control over, is under the control of, or is under common control with.
84
+
85
+ **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
86
+
87
+ **Your licenses** are all the licenses granted to you for the software under these terms.
88
+
89
+ **Use** means anything you do with the software requiring one of your licenses.
package/README.md CHANGED
@@ -1,3 +1,156 @@
1
- # Temporary Holding Version
1
+ # @spellkave/sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Host-neutral TypeScript SDK over generated Spellkave bindings. Runtime reads use
4
+ `SnapshotDb`; writes use typed `ActorClient` reducer methods. Server views and
5
+ reducers remain the authority boundary.
6
+
7
+ ## PLAYER projection flow
8
+
9
+ The SDK readers under `src/core/readers/` provide deterministic projections for
10
+ the companion package's orientation and direct-attempt workflow. In particular,
11
+ the player layer reads `spellkave_manipulation_context` for independent action
12
+ and target facts, then submits a typed `spellkave_manipulate` attempt; the
13
+ server remains the sole authority for admission.
14
+
15
+ - `self.ts` supplies the connected body summary and owned-state rows;
16
+ - `scene.ts` supplies the current authorized scene, targets, and detail;
17
+ - `inventory_query.ts` plus `item_detail.ts` supply possession lists and joined
18
+ item identity/state;
19
+ - `trace_query.ts` supplies perceived trace summaries, entries, and detail;
20
+ - `session_status.ts` plus `reaction_options.ts` supply participant session and
21
+ reaction choices.
22
+
23
+ Readers return sorted authorized rows and do not mint handles. The companion
24
+ layer applies finite limits, opaque cursors, revision-bound handles, and compact
25
+ presentation. Actions delegate to `ActorClient`; neither a reader result nor a
26
+ handle authorizes a reducer.
27
+
28
+ Capability details join optional authored `capability_definition.description`
29
+ only for the connected body's visible grants. Item state details join optional
30
+ `resource_definition.description` only after the item resolves through the
31
+ authorized possession projection. Both omit unavailable or blank prose and
32
+ preserve supplied plain text. Consumers provide missing-description copy;
33
+ the readers do not invent explanations or infer additional grants/items from
34
+ public definition catalogs. These additive fields retain existing row ordering
35
+ and identity. Capability-query revisions include the projected prose; item
36
+ detail retains the inventory handle/revision used to resolve its owned item.
37
+
38
+ ## General/operator compatibility
39
+
40
+ Broader legacy readers and low-level `ActorClient` methods remain available for
41
+ operator automation and compatibility tests. They are not the canonical PLAYER
42
+ workflow and must not be used to bypass server-defined caller scope, direct-body
43
+ control, capabilities, or gameplay predicates.
44
+
45
+ ## Lightweight subpaths (no live connection)
46
+
47
+ `@spellkave/sdk/readers` and `@spellkave/sdk/schema-surface` are the names and
48
+ HTTP schema helpers used at process start. They do not import `connection.ts`
49
+ or generated world `module_bindings`. Live `connect()` stays on the package
50
+ root (`src/index.ts`).
51
+
52
+ ## Live tests live in `@spellkave/test-lab`
53
+
54
+ The live-node TypeScript test harness (test worlds, private scenes, forced
55
+ RNG seed, manual scheduler control; ADR-0088 D-2) is its own package,
56
+ [`packages/spellkave-test-lab`](../spellkave-test-lab/README.md)
57
+ (`@spellkave/test-lab`). It depends on this SDK; the SDK does not depend on
58
+ it and does not re-export it, so test-lab semantics stay out of the
59
+ production surface (`connection.ts`, `readers.ts`, `replay.ts`,
60
+ `provenance.ts`).
61
+
62
+ ## Actor action observation
63
+
64
+ Actor actions submit the reducer once, then classify the result against the
65
+ same subscribed cache on delivered-row or reducer-result callbacks. The
66
+ observation deadline remains a failure bound. Snapshot hosts without removable
67
+ cache listeners retain the configured polling fallback. Listeners and the
68
+ pending timer are removed when an attempt ends, including rejection or a
69
+ caller predicate error. The injected-delivery contract is covered by
70
+ [reducer_observation_delivery.test.ts](src/__tests__/reducer_observation_delivery.test.ts).
71
+ The [creation measurement](../../docs/research/ci-reducer-observation-callbacks.md)
72
+ records local before/after and counterfactual timings with their limits.
73
+
74
+ For `ActorClient.manipulate`, an actor ID and a fresh provenance row are
75
+ insufficient to identify a call: two processes may act through the same
76
+ presence. The wrapper waits for its own reducer result and accepts only a
77
+ single terminal Affordance receipt delivered with that invocation's original
78
+ argument object. The pinned SpacetimeDB 2.10.1 transport preserves that object
79
+ in the caller's ReducerResult callbacks; other sockets receive Transaction
80
+ callbacks. Driver-token wrappers retain the nested manipulation args object.
81
+ The live transport and same-presence two-process contract is
82
+ [manipulation-receipt.local-node.test.ts](../spellkave-test-lab/src/scene-live/manipulation-receipt.local-node.test.ts).
83
+
84
+ A changed state predicate alone no longer proves manipulation success. Without
85
+ an attributable receipt (including snapshot-only hosts, wrappers that clone
86
+ the nested args, deferred admission with only a Predicate receipt, or ambiguous
87
+ terminal receipts), a settled call returns `unobservable` immediately
88
+ without attaching another call's provenance. A transport rejection remains
89
+ `rejected` without a provenance receipt. `successOnProvenance` uses the same
90
+ attribution rule. Callers must inspect this uncertainty; it does not establish
91
+ that the act failed and must not cause an automatic retry.
92
+ A deferred reaction admission may return only a Predicate receipt. Ending that
93
+ observation promptly lets the caller answer the pending reaction; waiting for
94
+ a terminal Affordance here can prevent that continuation from being answered.
95
+ The portable consumer regression is
96
+ [AUTH-48-01](../spellkave-tool-player/src/__tests__/seal-break.local-node.test.ts).
97
+
98
+ This tightens observation only: argument/reducer signatures and result variants
99
+ stay compatible, server authority and persistent state are preserved, and no
100
+ module publish, world reload, or reset is required. Upgrade consumers together
101
+ when they rely on snapshot-only predicate success. Rolling back this SDK restores
102
+ the earlier subject-based observation race; retain a single invocation owner
103
+ or the scoped controller's conservative guard during rollback.
104
+
105
+ ## World-event stream
106
+
107
+ `createWorldEventBuilder` (`@spellkave/sdk/world-events`,
108
+ [builder.ts](src/world-events/builder.ts)) derives the closed `WorldEvent`
109
+ stream that Play, the player MCP gateway, the Pi extension and `sk` deliver.
110
+ Its contract and every dated change live in
111
+ [unified-world-event-stream.md](../../ledger/designs/unified-world-event-stream.md).
112
+
113
+ Since the compatibility decision of 2026-11-12:
114
+
115
+ - Within one drain, the resource-delta and condition-delta kinds come out
116
+ together, oldest-first by event id, and a `session_lifecycle` `closed` event
117
+ is last. The trace kinds (`speech_heard`, `trace_addressed`,
118
+ `trace_departure`) keep reader order, newest-first. The readers' own sort is
119
+ unchanged. Pinned by
120
+ [world_events_builder_order.test.ts](src/__tests__/world_events_builder_order.test.ts).
121
+ - `self_resource_spent` is not emitted when the delta's `source_entity_ref`
122
+ is non-empty and not the actor. The rule keys on that field, which is the
123
+ frame's `Actor` binding: a `ForEachActorInRadius` body rebinds it to each
124
+ target, so a radius-applied delta reads as self-caused, stays a spend, and
125
+ an area `self_hit` carries no `attacker_name`. Pinned by
126
+ [world_events_builder_spend_source.test.ts](src/__tests__/world_events_builder_spend_source.test.ts).
127
+ - `self_hit` may carry the optional `attacker_name`, resolved at emit time from
128
+ the same source as `dealt_hit.target_name`. The key is absent when no name
129
+ resolves or the attacker is the actor. Pinned by
130
+ [world_events_builder_attacker_name.test.ts](src/__tests__/world_events_builder_attacker_name.test.ts).
131
+
132
+ This changes delivery only: no kind was added or removed, no existing field
133
+ changed type, server authority and persistent state are preserved, and no
134
+ module publish, world reload, or reset is required. Upgrade consumers that
135
+ match the `self_hit` sentence or rely on the earlier within-drain order
136
+ together with this SDK. Rolling back this SDK restores the earlier order, the
137
+ spends sourced by another entity and the earlier sentence, with no data migration.
138
+
139
+ ## Manifest apply observation
140
+
141
+ Manifest applies through the shared lane (test-lab uses it too) submit once and observe the subscribed digest/outcome
142
+ insert callbacks. An external `MF-APPLY-013` collision fails immediately. The
143
+ 15-minute dead-scheduler watchdog remains a failure bound; it is not a delay on
144
+ the successful path. Production callers supplying `onUpdate` likewise use
145
+ post-cache notifications without polling. Legacy callers that supply no update
146
+ source retain the polling compatibility path and explicit retry opt-in.
147
+
148
+ Failed results retain an `outcome` with `applyId`, `digest`, `code`, and `message`
149
+ when the server supplies a failure row. Throwing wrappers use
150
+ `ManifestApplyError`, preserving that outcome and the original exception as
151
+ `cause` when enqueue or observation throws. The message also prints correlation
152
+ for text-only consumers. A generic `MF-APPLY-029` row still cannot explain a
153
+ server-side cause that was not persisted; use its correlation with node logs.
154
+
155
+ See the [test-lab live probe verification](../spellkave-test-lab/README.md) for
156
+ the owned-node proof, repeatability boundary, and counterfactual.
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@spellkave/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Host-neutral Spellkave TypeScript SDK. Read-first connection, snapshot, and read-model helpers built on `spacetimedb` + `@spellkave/bindings`. No pi.dev / React / Vite / Playwright deps.",
5
+ "type": "module",
6
+ "main": "./src/index.ts",
7
+ "types": "./src/index.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./src/index.ts",
11
+ "default": "./src/index.ts"
12
+ },
13
+ "./readers": {
14
+ "types": "./src/readers.ts",
15
+ "default": "./src/readers.ts"
16
+ },
17
+ "./schema-surface": {
18
+ "types": "./src/core/binding_drift.ts",
19
+ "default": "./src/core/binding_drift.ts"
20
+ },
21
+ "./replay": {
22
+ "types": "./src/replay.ts",
23
+ "default": "./src/replay.ts"
24
+ },
25
+ "./actor-control": {
26
+ "types": "./src/core/actor_control.ts",
27
+ "default": "./src/core/actor_control.ts"
28
+ },
29
+ "./profiles": {
30
+ "types": "./src/core/profiles.ts",
31
+ "default": "./src/core/profiles.ts"
32
+ },
33
+ "./node": {
34
+ "types": "./src/core/node-io.ts",
35
+ "default": "./src/core/node-io.ts"
36
+ },
37
+ "./world-events": {
38
+ "types": "./src/world-events/builder.ts",
39
+ "default": "./src/world-events/builder.ts"
40
+ },
41
+ "./environment-state": {
42
+ "types": "./src/core/effective_environment_state.ts",
43
+ "default": "./src/core/effective_environment_state.ts"
44
+ }
45
+ },
46
+ "files": [
47
+ "src"
48
+ ],
49
+ "dependencies": {
50
+ "@spellkave/bindings": "2.1.0",
51
+ "@spellkave/world-events": "0.1.0",
52
+ "smol-toml": "^1.9.1",
53
+ "spacetimedb": "2.14.1"
54
+ },
55
+ "license": "PolyForm-Shield-1.0.0",
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "git+https://github.com/b4mad-technologies/sk-sdk.git",
59
+ "directory": "packages/spellkave-sdk"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public",
63
+ "registry": "https://registry.npmjs.org/"
64
+ }
65
+ }
@@ -0,0 +1,186 @@
1
+ // Row types derived from the live DbConnection accessor, not from the generator's
2
+ // `.name("snake_case")` metadata. The `.name(...)` annotation is BSATN wire-format
3
+ // only — runtime field keys from iter() are always camelCase. See:
4
+ // repos/SpacetimeDB/crates/bindings-typescript/src/sdk/table_cache.ts (iter signature).
5
+ import type { DbConnection } from "@spellkave/bindings";
6
+
7
+ // biome-ignore lint/suspicious/noExplicitAny: pre-existing debt from #1368 biome onboarding, tracked in #1455
8
+ type IterRow<T extends { iter(): Iterator<any, any> }> =
9
+ // biome-ignore lint/suspicious/noExplicitAny: pre-existing debt from #1368 biome onboarding, tracked in #1455
10
+ ReturnType<T["iter"]> extends Iterator<infer R, any> ? R : never;
11
+
12
+ export type ActorSpatialLocationRow = IterRow<DbConnection["db"]["visible_actor_spatial_location"]>;
13
+ export type EntityLocationRow = IterRow<DbConnection["db"]["visible_entity_location"]>;
14
+ export type ActorRow = IterRow<DbConnection["db"]["actor"]>;
15
+ // `actor_identity` is private (#915 PR-5); `visible_actor_identity` is its
16
+ // self-only view (ADR-0084 D-5 Family 1 shape).
17
+ export type VisibleActorIdentityRow = IterRow<DbConnection["db"]["visible_actor_identity"]>;
18
+ export type SeatRow = IterRow<DbConnection["db"]["seat"]>;
19
+ export type EntityRow = IterRow<DbConnection["db"]["entity"]>;
20
+ export type EntityDefinitionRow = IterRow<DbConnection["db"]["entity_definition"]>;
21
+ export type ObjectStateDefinitionRow = IterRow<DbConnection["db"]["object_state_definition"]>;
22
+ export type ObjectStateRow = IterRow<DbConnection["db"]["visible_object_state"]>;
23
+ export type SessionRow = IterRow<DbConnection["db"]["visible_session"]>;
24
+ export type SessionDefinitionRow = IterRow<DbConnection["db"]["session_definition"]>;
25
+ export type SessionParticipantRow = IterRow<DbConnection["db"]["visible_session_participant"]>;
26
+ export type TurnStateRow = IterRow<DbConnection["db"]["visible_turn_state"]>;
27
+ export type PendingResolutionRow = IterRow<DbConnection["db"]["visible_pending_resolution"]>;
28
+ export type PendingResolutionReactorRow = IterRow<
29
+ DbConnection["db"]["visible_pending_resolution_reactor"]
30
+ >;
31
+ // The frozen stochastic-draw extension row for a parked pending_resolution
32
+ // (post-roll intervention windows, #2058) — sibling of PendingResolutionRow,
33
+ // joined by pending_id. Present only for a stochastically-resolved action.
34
+ export type PendingStochasticResolutionRow = IterRow<
35
+ DbConnection["db"]["visible_pending_stochastic_resolution"]
36
+ >;
37
+ export type EntityTagRow = IterRow<DbConnection["db"]["visible_entity_tag"]>;
38
+ // entity_definition_tag: authored tags on an entity's DEFINITION (species,
39
+ // class, background, …), keyed by entity_def_id — distinct from `entity_tag`
40
+ // above, which tags an individual entity INSTANCE (#2094).
41
+ export type TagCapabilityGrantRow = IterRow<DbConnection["db"]["tag_capability_grant"]>;
42
+ export type EntityDefinitionTagRow = IterRow<DbConnection["db"]["entity_definition_tag"]>;
43
+ export type ActionDefinitionTagRow = IterRow<DbConnection["db"]["action_definition_tag"]>;
44
+ export type TargetConditionRow = IterRow<DbConnection["db"]["visible_target_condition"]>;
45
+ export type EntityDescriptionRow = IterRow<DbConnection["db"]["entity_description"]>;
46
+ export type ManifestAuthoredEntityRow = IterRow<
47
+ DbConnection["db"]["visible_manifest_authored_entity"]
48
+ >;
49
+ // ADR-0139's private per-perceiver context is delivered only through this
50
+ // caller-scoped view. The deprecated descriptor satellite intentionally has no
51
+ // SDK alias: shared action metadata remains in public action_definition.
52
+ export type ManipulationContextRow = IterRow<DbConnection["db"]["visible_manipulation_context"]>;
53
+ export type ManipulationAvailableActionRow = IterRow<
54
+ DbConnection["db"]["visible_manipulation_available_action"]
55
+ >;
56
+ export type ManipulationObservedTargetRow = IterRow<
57
+ DbConnection["db"]["visible_manipulation_observed_target"]
58
+ >;
59
+ // ADR-0142 D-6's per-perceiver dialogue-prompt projection.
60
+ export type PromptOccurrenceRow = IterRow<DbConnection["db"]["visible_prompt_occurrence"]>;
61
+ export type ManipulationPromptRow = IterRow<DbConnection["db"]["visible_manipulation_prompt"]>;
62
+ export type ManipulationParticipantContextRow = IterRow<
63
+ DbConnection["db"]["visible_manipulation_participant_context"]
64
+ >;
65
+ export type ManipulationParticipantBindingRow = IterRow<
66
+ DbConnection["db"]["visible_manipulation_participant_binding"]
67
+ >;
68
+ export type PlaceNodeRow = IterRow<DbConnection["db"]["visible_place_node"]>;
69
+ export type PlaceEdgeRow = IterRow<DbConnection["db"]["visible_place_edge"]>;
70
+ export type PlaceEdgeAffordanceRow = IterRow<DbConnection["db"]["place_edge_affordance"]>;
71
+ export type PlaceGraphDefinitionRow = IterRow<DbConnection["db"]["visible_place_graph_definition"]>;
72
+ export type MapLayerRow = IterRow<DbConnection["db"]["visible_map_layer"]>;
73
+ // Public catalog (not fog-of-war gated) — indoor/outdoor class for OSM export.
74
+ export type SubstrateDefinitionRow = IterRow<DbConnection["db"]["substrate_definition"]>;
75
+ export type VisibleSpatialNicheAttachmentRow = IterRow<
76
+ DbConnection["db"]["visible_spatial_niche_attachment"]
77
+ >;
78
+ export type EvaluationProvenanceRow = IterRow<DbConnection["db"]["visible_evaluation_provenance"]>;
79
+ export type ConfigRow = IterRow<DbConnection["db"]["config"]>;
80
+ export type WorldTimeRow = IterRow<DbConnection["db"]["world_time"]>;
81
+ // `world_event` is private (#915 PR-8); rows arrive via the per-caller
82
+ // `visible_world_event` dispatch view (identical columns).
83
+ export type WorldEventRow = IterRow<DbConnection["db"]["visible_world_event"]>;
84
+ // `event_apply_consequence` / `event_resource_delta` / `event_actor_body_swapped`
85
+ // are private (ADR-0120, #915); rows arrive via their per-caller `visible_*`
86
+ // views (identical columns, owner/DM-extent-bounded).
87
+ export type EventApplyConsequenceRow = IterRow<
88
+ DbConnection["db"]["visible_event_apply_consequence"]
89
+ >;
90
+ export type EventResourceDeltaRow = IterRow<DbConnection["db"]["visible_event_resource_delta"]>;
91
+ // `event_condition_delta` is private (ADR-0120, K-B Part B); rows arrive via
92
+ // the per-caller `visible_event_condition_delta` view (identical columns,
93
+ // owner/DM-extent-bounded — same shape as event_resource_delta above).
94
+ export type EventConditionDeltaRow = IterRow<DbConnection["db"]["visible_event_condition_delta"]>;
95
+ export type EventActorBodySwappedRow = IterRow<
96
+ DbConnection["db"]["visible_event_actor_body_swapped"]
97
+ >;
98
+ export type EventChannelSpendRow = IterRow<DbConnection["db"]["event_channel_spend"]>;
99
+ export type EventBoundaryFiredRow = IterRow<DbConnection["db"]["event_boundary_fired"]>;
100
+ export type EventChannelWindowRefreshRow = IterRow<
101
+ DbConnection["db"]["event_channel_window_refresh"]
102
+ >;
103
+ export type EventActionRechargeFiredRow = IterRow<
104
+ DbConnection["db"]["event_action_recharge_fired"]
105
+ >;
106
+ // `condition_boundary_expiry` is private operational state; the owner-scoped
107
+ // view is the only SDK read surface (ADR-0120, #915).
108
+ export type ConditionBoundaryExpiryRow = IterRow<
109
+ DbConnection["db"]["visible_condition_boundary_expiry"]
110
+ >;
111
+ // `economy_channel_spend` is private (ADR-0120, #915); rows arrive via the
112
+ // per-caller `visible_economy_channel_spend` view (identical columns,
113
+ // owner-body-bounded — #2083/#2096).
114
+ export type VisibleEconomyChannelSpendRow = IterRow<
115
+ DbConnection["db"]["visible_economy_channel_spend"]
116
+ >;
117
+ export type VisibleEconomyChannelBudgetRow = IterRow<
118
+ DbConnection["db"]["visible_economy_channel_budget"]
119
+ >;
120
+ export type ActionDefinitionRow = IterRow<DbConnection["db"]["action_definition"]>;
121
+ export type AffordanceTemplateRow = IterRow<DbConnection["db"]["affordance_template"]>;
122
+ // `niche_definition` is public (actor-carried-verbs D1/D2); `provider` names
123
+ // WHO offers the niche (`place`/`entity`/`actor`, empty = `place`).
124
+ export type NicheDefinitionRow = IterRow<DbConnection["db"]["niche_definition"]>;
125
+ export type NicheProviderDefinitionRow = IterRow<DbConnection["db"]["niche_provider_definition"]>;
126
+ // `observer_knowledge` / `observer_place_knowledge` / `observer_trace_knowledge`
127
+ // are private (ADR-0120, #915 sweep PR-2); the row shapes are read through
128
+ // their per-caller `visible_*` views (identical columns, perception-bounded).
129
+ export type ObserverKnowledgeRow = IterRow<DbConnection["db"]["visible_observer_knowledge"]>;
130
+ export type ObserverPlaceKnowledgeRow = IterRow<
131
+ DbConnection["db"]["visible_observer_place_knowledge"]
132
+ >;
133
+ export type ObserverTraceKnowledgeRow = IterRow<
134
+ DbConnection["db"]["visible_observer_trace_knowledge"]
135
+ >;
136
+ // `trace` is private (ADR-0120, #915); the row shape is read through the
137
+ // per-caller `visible_trace` view (identical columns, perception-bounded).
138
+ export type TraceRow = IterRow<DbConnection["db"]["visible_trace"]>;
139
+ export type EntityContainmentRow = IterRow<DbConnection["db"]["visible_entity_containment"]>;
140
+ export type CapabilityDefinitionRow = IterRow<DbConnection["db"]["capability_definition"]>;
141
+ export type ConditionDefinitionRow = IterRow<DbConnection["db"]["condition_definition"]>;
142
+ export type ConditionDefinitionDescriptionRow = IterRow<
143
+ DbConnection["db"]["condition_definition_description"]
144
+ >;
145
+ // `capability` is private (ADR-0120); rows arrive via the per-caller
146
+ // `visible_capability` view (identical columns, entity-owner-bounded).
147
+ export type VisibleCapabilityRow = IterRow<DbConnection["db"]["visible_capability"]>;
148
+ // `entity_equipment_slot` is private (ADR-0120, #915 PR-6); rows arrive via
149
+ // the per-caller `visible_entity_equipment_slot` view (identical columns,
150
+ // owner/DM-extent-bounded).
151
+ export type EntityEquipmentSlotRow = IterRow<DbConnection["db"]["visible_entity_equipment_slot"]>;
152
+ export type EquipmentSlotDefinitionRow = IterRow<DbConnection["db"]["equipment_slot_definition"]>;
153
+ export type ResourceDefinitionRow = IterRow<DbConnection["db"]["resource_definition"]>;
154
+ export type ResourceDefinitionTagRow = IterRow<DbConnection["db"]["resource_definition_tag"]>;
155
+ // `spatial_environment_state` is private (ADR-0120, #915 sweep PR-4); the row
156
+ // shape is read through the per-caller `visible_spatial_environment_state`
157
+ // view (identical columns).
158
+ export type SpatialEnvironmentStateRow = IterRow<
159
+ DbConnection["db"]["visible_spatial_environment_state"]
160
+ >;
161
+ export type OutcomeTemplateRow = IterRow<DbConnection["db"]["outcome_template"]>;
162
+ // `metadata_attachment` is private (ADR-0130 D-1); clients read through
163
+ // three views sharing this row shape (D-5). `public_metadata_attachment` and
164
+ // `visible_metadata_attachment` union to the readable metadata set for a
165
+ // play session (D-6, `core/readers/metadata_rows.ts`'s
166
+ // `readMetadataAttachmentRows`); `public_reference_metadata` carries public
167
+ // `on_demand` rows (rules text, creation data, docs) for reference consumers.
168
+ export type PublicMetadataAttachmentRow = IterRow<DbConnection["db"]["public_metadata_attachment"]>;
169
+ export type VisibleMetadataAttachmentRow = IterRow<
170
+ DbConnection["db"]["visible_metadata_attachment"]
171
+ >;
172
+ export type PublicReferenceMetadataRow = IterRow<DbConnection["db"]["public_reference_metadata"]>;
173
+ // tag_value_definition: bundle-authored catalog metadata for one exact tag
174
+ // value (e.g. `srd.species.human`) — `prefix` groups a facet's values,
175
+ // `description` is source-derived discovery prose. Public, keyed by `tag`.
176
+ // Joined onto `entity_definition_tag` rows by `readSelfIdentity` (#2119
177
+ // identity-out-of-summary move); a tag with no catalog row (a bare tag like
178
+ // `creature`) simply has no matching row here.
179
+ export type TagValueDefinitionRow = IterRow<DbConnection["db"]["tag_value_definition"]>;
180
+
181
+ export type ObservedContainerContentRow = IterRow<
182
+ DbConnection["db"]["visible_observed_container_content"]
183
+ >;
184
+ export type ObservedContainerCoverageRow = IterRow<
185
+ DbConnection["db"]["visible_observed_container_coverage"]
186
+ >;