@spellkave/tool-contracts 0.0.0-bootstrap
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +89 -0
- package/package.json +50 -0
- package/src/admission.ts +62 -0
- package/src/authoring-schemas.ts +3491 -0
- package/src/authoring-tool-names.ts +46 -0
- package/src/contract-data.ts +37 -0
- package/src/contract-guard.ts +377 -0
- package/src/contracts-metadata.json +6940 -0
- package/src/docs-metadata.ts +42 -0
- package/src/exploration.ts +248 -0
- package/src/git-batch.ts +36 -0
- package/src/grant-schemas.ts +38 -0
- package/src/index.ts +10 -0
- package/src/metadata.ts +48 -0
- package/src/owner-instance-read.ts +123 -0
- package/src/personas.generated.json +47 -0
- package/src/personas.ts +19 -0
- package/src/roster.ts +13 -0
- package/src/scene-schemas.ts +29 -0
- package/src/schema-registry.ts +197 -0
- package/src/schemas.ts +786 -0
- package/src/snapshot-storage.ts +133 -0
- package/src/tool-contracts.breaking-acknowledged.json +392 -0
- package/src/tool-contracts.snapshot/index.json +104 -0
- package/src/tool-contracts.snapshot/rosters/AUTHOR.json +54 -0
- package/src/tool-contracts.snapshot/rosters/DM.json +19 -0
- package/src/tool-contracts.snapshot/rosters/PLAYER.json +25 -0
- package/src/tool-contracts.snapshot/tools/spellkave_acting_context.json +35 -0
- package/src/tool-contracts.snapshot/tools/spellkave_actor_principals.json +23 -0
- package/src/tool-contracts.snapshot/tools/spellkave_annotate_place.json +82 -0
- package/src/tool-contracts.snapshot/tools/spellkave_apply_manifest_delta.json +66 -0
- package/src/tool-contracts.snapshot/tools/spellkave_applyset_apply.json +131 -0
- package/src/tool-contracts.snapshot/tools/spellkave_applyset_diff.json +122 -0
- package/src/tool-contracts.snapshot/tools/spellkave_attach_map_layer.json +114 -0
- package/src/tool-contracts.snapshot/tools/spellkave_author_place.json +132 -0
- package/src/tool-contracts.snapshot/tools/spellkave_bind_actor.json +79 -0
- package/src/tool-contracts.snapshot/tools/spellkave_bind_edge_affordance.json +69 -0
- package/src/tool-contracts.snapshot/tools/spellkave_can_i.json +123 -0
- package/src/tool-contracts.snapshot/tools/spellkave_communicate.json +44 -0
- package/src/tool-contracts.snapshot/tools/spellkave_declare_inexpressible.json +33 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_action.json +133 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_action_verb.json +215 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_affordance.json +69 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_behavior.json +505 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_bundle.json +67 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_capability.json +64 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_condition.json +244 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_consequence.json +65 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_entity_type.json +199 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_niche.json +88 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_resource.json +93 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_roll_table.json +87 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_session.json +115 -0
- package/src/tool-contracts.snapshot/tools/spellkave_define_trace_kind.json +71 -0
- package/src/tool-contracts.snapshot/tools/spellkave_describe.json +73 -0
- package/src/tool-contracts.snapshot/tools/spellkave_diff.json +90 -0
- package/src/tool-contracts.snapshot/tools/spellkave_docs.json +104 -0
- package/src/tool-contracts.snapshot/tools/spellkave_end_turn.json +21 -0
- package/src/tool-contracts.snapshot/tools/spellkave_entity.json +32 -0
- package/src/tool-contracts.snapshot/tools/spellkave_entity_body.json +32 -0
- package/src/tool-contracts.snapshot/tools/spellkave_entity_container.json +32 -0
- package/src/tool-contracts.snapshot/tools/spellkave_equip_item.json +49 -0
- package/src/tool-contracts.snapshot/tools/spellkave_eval.json +87 -0
- package/src/tool-contracts.snapshot/tools/spellkave_events.json +30 -0
- package/src/tool-contracts.snapshot/tools/spellkave_explain.json +83 -0
- package/src/tool-contracts.snapshot/tools/spellkave_export.json +66 -0
- package/src/tool-contracts.snapshot/tools/spellkave_export_grants.json +50 -0
- package/src/tool-contracts.snapshot/tools/spellkave_get.json +87 -0
- package/src/tool-contracts.snapshot/tools/spellkave_grant_role.json +80 -0
- package/src/tool-contracts.snapshot/tools/spellkave_hand_over_role.json +89 -0
- package/src/tool-contracts.snapshot/tools/spellkave_intervention_windows.json +32 -0
- package/src/tool-contracts.snapshot/tools/spellkave_inventory.json +40 -0
- package/src/tool-contracts.snapshot/tools/spellkave_item_detail.json +37 -0
- package/src/tool-contracts.snapshot/tools/spellkave_link_places.json +84 -0
- package/src/tool-contracts.snapshot/tools/spellkave_list_grants.json +56 -0
- package/src/tool-contracts.snapshot/tools/spellkave_manipulate.json +84 -0
- package/src/tool-contracts.snapshot/tools/spellkave_manipulation_context.json +62 -0
- package/src/tool-contracts.snapshot/tools/spellkave_map.json +109 -0
- package/src/tool-contracts.snapshot/tools/spellkave_map_graph.json +143 -0
- package/src/tool-contracts.snapshot/tools/spellkave_move.json +75 -0
- package/src/tool-contracts.snapshot/tools/spellkave_note_doc_gap.json +43 -0
- package/src/tool-contracts.snapshot/tools/spellkave_observer_knowledge.json +32 -0
- package/src/tool-contracts.snapshot/tools/spellkave_observer_place_knowledge.json +32 -0
- package/src/tool-contracts.snapshot/tools/spellkave_observer_trace_knowledge.json +32 -0
- package/src/tool-contracts.snapshot/tools/spellkave_offer_control.json +30 -0
- package/src/tool-contracts.snapshot/tools/spellkave_orient.json +39 -0
- package/src/tool-contracts.snapshot/tools/spellkave_pace_time.json +59 -0
- package/src/tool-contracts.snapshot/tools/spellkave_place_actor.json +190 -0
- package/src/tool-contracts.snapshot/tools/spellkave_place_entity.json +190 -0
- package/src/tool-contracts.snapshot/tools/spellkave_prepare_hand_over.json +57 -0
- package/src/tool-contracts.snapshot/tools/spellkave_query.json +290 -0
- package/src/tool-contracts.snapshot/tools/spellkave_react_option.json +47 -0
- package/src/tool-contracts.snapshot/tools/spellkave_reaction_options.json +32 -0
- package/src/tool-contracts.snapshot/tools/spellkave_release_claim.json +32 -0
- package/src/tool-contracts.snapshot/tools/spellkave_remove_entity.json +39 -0
- package/src/tool-contracts.snapshot/tools/spellkave_render_scene.json +59 -0
- package/src/tool-contracts.snapshot/tools/spellkave_return_npc_control.json +59 -0
- package/src/tool-contracts.snapshot/tools/spellkave_revoke_role.json +55 -0
- package/src/tool-contracts.snapshot/tools/spellkave_scene.json +74 -0
- package/src/tool-contracts.snapshot/tools/spellkave_scene_detail.json +37 -0
- package/src/tool-contracts.snapshot/tools/spellkave_self_states.json +77 -0
- package/src/tool-contracts.snapshot/tools/spellkave_self_summary.json +21 -0
- package/src/tool-contracts.snapshot/tools/spellkave_sense.json +68 -0
- package/src/tool-contracts.snapshot/tools/spellkave_sense_context.json +28 -0
- package/src/tool-contracts.snapshot/tools/spellkave_session_close.json +71 -0
- package/src/tool-contracts.snapshot/tools/spellkave_session_move.json +38 -0
- package/src/tool-contracts.snapshot/tools/spellkave_session_open.json +36 -0
- package/src/tool-contracts.snapshot/tools/spellkave_session_status.json +41 -0
- package/src/tool-contracts.snapshot/tools/spellkave_set_metadata.json +205 -0
- package/src/tool-contracts.snapshot/tools/spellkave_set_movement_default.json +58 -0
- package/src/tool-contracts.snapshot/tools/spellkave_stage_scene.json +55 -0
- package/src/tool-contracts.snapshot/tools/spellkave_status.json +23 -0
- package/src/tool-contracts.snapshot/tools/spellkave_stow_item.json +55 -0
- package/src/tool-contracts.snapshot/tools/spellkave_suggest_next_action.json +32 -0
- package/src/tool-contracts.snapshot/tools/spellkave_tag_entity.json +61 -0
- package/src/tool-contracts.snapshot/tools/spellkave_take_npc_control.json +64 -0
- package/src/tool-contracts.snapshot/tools/spellkave_trace_detail.json +36 -0
- package/src/tool-contracts.snapshot/tools/spellkave_traces.json +55 -0
- package/src/tool-contracts.snapshot/tools/spellkave_wake_up.json +23 -0
- package/src/tool-contracts.snapshot/tools/spellkave_withdraw_control.json +30 -0
- package/src/tool-contracts.snapshot/tools/spellkave_write_rows.json +62 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Additive public-help provenance. This object carries no world authority. */
|
|
2
|
+
export interface DocsMetadata {
|
|
3
|
+
document_id: string;
|
|
4
|
+
corpus_revision: string;
|
|
5
|
+
content_status: "implemented" | "planned" | "historical";
|
|
6
|
+
/** Distribution surfaces; this does not certify every described live action. */
|
|
7
|
+
supported_surfaces: string[];
|
|
8
|
+
server_revision: string;
|
|
9
|
+
compatibility: "unknown" | "compatible" | "mismatch";
|
|
10
|
+
feature_prerequisites?: Array<{
|
|
11
|
+
feature: string;
|
|
12
|
+
status: "implemented" | "planned" | "historical";
|
|
13
|
+
minimum_revision: string;
|
|
14
|
+
}>;
|
|
15
|
+
/** Original Markdown href to packaged document/section; never a file read. */
|
|
16
|
+
links?: Array<{ href: string; document_id: string; section?: string }>;
|
|
17
|
+
/** Counts refer to the delivered body, not other sections of the source. */
|
|
18
|
+
links_total?: number;
|
|
19
|
+
links_truncated?: boolean;
|
|
20
|
+
links_hint?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Supplied by an already-authorized host context read, never by docs arguments. */
|
|
24
|
+
export interface DocsVersionEvidence {
|
|
25
|
+
server_revision: string;
|
|
26
|
+
compatibility: DocsMetadata["compatibility"];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Offline lookup never infers a version verdict or performs a context read. */
|
|
30
|
+
export function withDocsVersionEvidence(
|
|
31
|
+
metadata: DocsMetadata | undefined,
|
|
32
|
+
evidence?: Readonly<DocsVersionEvidence>,
|
|
33
|
+
): DocsMetadata | undefined {
|
|
34
|
+
if (!metadata) return undefined; // Compatible with older adapters omitting metadata.
|
|
35
|
+
const revision = evidence?.server_revision.trim();
|
|
36
|
+
const known = revision && revision !== "unknown" && revision !== "0.0.0";
|
|
37
|
+
return {
|
|
38
|
+
...metadata,
|
|
39
|
+
server_revision: known ? revision : "unknown",
|
|
40
|
+
compatibility: known ? (evidence?.compatibility ?? "unknown") : "unknown",
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { type Static, Type } from "typebox";
|
|
2
|
+
|
|
3
|
+
const sources = Type.Union([
|
|
4
|
+
Type.Literal("live"),
|
|
5
|
+
Type.Literal("workspace"),
|
|
6
|
+
Type.Literal("local"),
|
|
7
|
+
]);
|
|
8
|
+
const collections = Type.Union([
|
|
9
|
+
Type.Literal("places"),
|
|
10
|
+
Type.Literal("definitions"),
|
|
11
|
+
Type.Literal("instances"),
|
|
12
|
+
]);
|
|
13
|
+
/**
|
|
14
|
+
* A reference names a row inside one response's source; the source identity is stated once
|
|
15
|
+
* per response (`source.source_id`) and once per request (`source_id`), never per reference.
|
|
16
|
+
* The collection follows from the kind.
|
|
17
|
+
*/
|
|
18
|
+
export const EXPLORATION_REF = Type.Object(
|
|
19
|
+
{
|
|
20
|
+
kind: Type.String(),
|
|
21
|
+
id: Type.String(),
|
|
22
|
+
bundle: Type.Optional(Type.String()),
|
|
23
|
+
},
|
|
24
|
+
{ additionalProperties: false },
|
|
25
|
+
);
|
|
26
|
+
export const EXPLORE_PARAMS = Type.Object(
|
|
27
|
+
{
|
|
28
|
+
operation: Type.Union([
|
|
29
|
+
Type.Literal("summary"),
|
|
30
|
+
Type.Literal("search"),
|
|
31
|
+
Type.Literal("detail"),
|
|
32
|
+
Type.Literal("neighbors"),
|
|
33
|
+
Type.Literal("references"),
|
|
34
|
+
Type.Literal("field"),
|
|
35
|
+
]),
|
|
36
|
+
source: Type.Optional(sources),
|
|
37
|
+
source_id: Type.Optional(
|
|
38
|
+
Type.String({
|
|
39
|
+
maxLength: 64,
|
|
40
|
+
description:
|
|
41
|
+
"The `source.source_id` of the response that returned `ref`/`within`. Required with `ref` and `within`; another source, world or connection is refused.",
|
|
42
|
+
}),
|
|
43
|
+
),
|
|
44
|
+
collection: Type.Optional(collections),
|
|
45
|
+
facets: Type.Optional(
|
|
46
|
+
Type.Boolean({
|
|
47
|
+
description:
|
|
48
|
+
"Summary only: include definition counts by kind and detailed authored tag facets. Default false; the compact summary offers this as a follow-up.",
|
|
49
|
+
}),
|
|
50
|
+
),
|
|
51
|
+
view: Type.Optional(
|
|
52
|
+
Type.Union([Type.Literal("objects"), Type.Literal("rows")], {
|
|
53
|
+
description:
|
|
54
|
+
"Summary/search/neighbors only. Default objects: instance bodies once, without tag rows. Explicit kind selects rows. Use rows for the technical inventory.",
|
|
55
|
+
}),
|
|
56
|
+
),
|
|
57
|
+
text: Type.Optional(Type.String({ maxLength: 512 })),
|
|
58
|
+
tags: Type.Optional(
|
|
59
|
+
Type.Array(Type.String({ maxLength: 256 }), {
|
|
60
|
+
maxItems: 16,
|
|
61
|
+
description:
|
|
62
|
+
"Summary: count these literal tags separately on definitions and distinct objects. Search: require all tags. Tags are never inherited from definitions.",
|
|
63
|
+
}),
|
|
64
|
+
),
|
|
65
|
+
kind: Type.Optional(Type.String()),
|
|
66
|
+
bundle: Type.Optional(Type.String()),
|
|
67
|
+
within: Type.Optional(EXPLORATION_REF),
|
|
68
|
+
ref: Type.Optional(EXPLORATION_REF),
|
|
69
|
+
direction: Type.Optional(Type.Union([Type.Literal("outbound"), Type.Literal("inbound")])),
|
|
70
|
+
field: Type.Optional(Type.String()),
|
|
71
|
+
offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
72
|
+
fields: Type.Optional(
|
|
73
|
+
Type.Array(Type.String({ maxLength: 256 }), {
|
|
74
|
+
maxItems: 16,
|
|
75
|
+
description:
|
|
76
|
+
"search/detail only: scalar names from the collection schema for search, or the selected row kind's schema for detail; `label` is also selectable.",
|
|
77
|
+
}),
|
|
78
|
+
),
|
|
79
|
+
limit: Type.Optional(
|
|
80
|
+
Type.Integer({
|
|
81
|
+
minimum: 1,
|
|
82
|
+
maximum: 100,
|
|
83
|
+
description:
|
|
84
|
+
"Page size. Default 12 tag facets for summary, 5 for search (ranked: label equals, starts with, contains, then other text), 20 otherwise.",
|
|
85
|
+
}),
|
|
86
|
+
),
|
|
87
|
+
cursor: Type.Optional(Type.String({ maxLength: 16384 })),
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
additionalProperties: false,
|
|
91
|
+
description:
|
|
92
|
+
"Bounded admitted discovery. Summary inventories all three collections with coverage and per-kind counts (incomplete kinds are lower bounds). Instance summary/search count objects once by default; view rows preserves technical rows and explicit kind selects rows. Defaults to live; search collection follows kind, otherwise unrestricted text searches all collections and empty text defaults to places. An explicit collection must agree with kind. Explicit workspace/local source is never unioned. Follow exact returned references; no read grants write permission.",
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
export type ExplorationRef = Static<typeof EXPLORATION_REF>;
|
|
96
|
+
export type ExploreRequest = Static<typeof EXPLORE_PARAMS>;
|
|
97
|
+
export type ExplorationCollection = Static<typeof collections>;
|
|
98
|
+
export type ExplorationSourceKind = Static<typeof sources>;
|
|
99
|
+
/** A reader's own full identity and coverage, as a port reports it. The wire form is `ExplorationResultSource`. */
|
|
100
|
+
export interface ExplorationSource {
|
|
101
|
+
source: ExplorationSourceKind;
|
|
102
|
+
source_id: string;
|
|
103
|
+
world: string | null;
|
|
104
|
+
world_instance: string | null;
|
|
105
|
+
connection_epoch: string;
|
|
106
|
+
source_epoch: string;
|
|
107
|
+
projection_version: "exploration-v1";
|
|
108
|
+
coverage: Array<{
|
|
109
|
+
family: string;
|
|
110
|
+
state: "complete" | "incomplete" | "unsupported" | "disconnected";
|
|
111
|
+
reason?: string;
|
|
112
|
+
}>;
|
|
113
|
+
}
|
|
114
|
+
/** Families that are not `complete`, grouped by state and reason; complete families are never listed. */
|
|
115
|
+
export interface ExplorationCoverageGroup {
|
|
116
|
+
state: "incomplete" | "unsupported" | "disconnected";
|
|
117
|
+
reason?: string;
|
|
118
|
+
families: string[];
|
|
119
|
+
}
|
|
120
|
+
export interface ExplorationResultSource {
|
|
121
|
+
source: ExplorationSourceKind;
|
|
122
|
+
/** Opaque token of source, world instance and connection; echo it as `source_id` with any `ref`/`within`. */
|
|
123
|
+
source_id: string;
|
|
124
|
+
world?: string;
|
|
125
|
+
/**
|
|
126
|
+
* `"complete"` when every family the request reads is complete; otherwise only those that are
|
|
127
|
+
* not. A family the request does not read (a place search and the definitions) is never listed.
|
|
128
|
+
*/
|
|
129
|
+
coverage: "complete" | ExplorationCoverageGroup[];
|
|
130
|
+
}
|
|
131
|
+
export type ExplorationScalar = string | number | boolean | null;
|
|
132
|
+
export interface ExplorationItem {
|
|
133
|
+
ref: ExplorationRef;
|
|
134
|
+
label?: string;
|
|
135
|
+
description?: string;
|
|
136
|
+
fields?: Record<string, ExplorationScalar>;
|
|
137
|
+
context?: ExplorationRef[];
|
|
138
|
+
/** Graph occupants are reached through this admitted room, not a fabricated direct edge. */
|
|
139
|
+
via?: ExplorationRef;
|
|
140
|
+
/** All stored links collapsed into this object; the first is also in relationship. */
|
|
141
|
+
relationships?: Array<{ kind: string; key: string; direction: "outbound" | "inbound" }>;
|
|
142
|
+
relationship?: {
|
|
143
|
+
kind: string;
|
|
144
|
+
key: string;
|
|
145
|
+
/** The item is the far end; `via`, when present, otherwise the requested ref is the other end. */
|
|
146
|
+
direction: "outbound" | "inbound";
|
|
147
|
+
};
|
|
148
|
+
/** Fields cut by a preview or byte bound; sizes are raw code points of the admitted value. */
|
|
149
|
+
truncated?: Array<{ field: string; shown_code_points: number; total_code_points: number }>;
|
|
150
|
+
}
|
|
151
|
+
export type ExplorationErrorClass = "usage" | "in_world" | "infra";
|
|
152
|
+
export interface ExplorationResult {
|
|
153
|
+
shape: "exploration";
|
|
154
|
+
operation: ExploreRequest["operation"];
|
|
155
|
+
source: ExplorationResultSource;
|
|
156
|
+
ok: boolean;
|
|
157
|
+
/** Present exactly when `ok` is false. */
|
|
158
|
+
status?: "not_found_in_scope" | "unavailable" | "stale_cursor";
|
|
159
|
+
reason?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Only for `source_unreadable` on a file source: one bounded line naming the caller's own
|
|
162
|
+
* file and what is wrong with it. Never set for a live source (Decision 4).
|
|
163
|
+
*/
|
|
164
|
+
cause?: string;
|
|
165
|
+
/** Only with `cause`: the one thing to change, written for the host that ran the call. */
|
|
166
|
+
hint?: string;
|
|
167
|
+
/** Set exactly when `ok` is false; authoritative over any exit code. */
|
|
168
|
+
error_class?: ExplorationErrorClass;
|
|
169
|
+
/** Static declared alternatives for unsupported fields/kinds, never derived from admitted row presence. */
|
|
170
|
+
valid?: string[];
|
|
171
|
+
/** Coverage of the request's reader families; never a function of inaccessible rows. */
|
|
172
|
+
completeness: "complete" | "incomplete";
|
|
173
|
+
/** Inventory of each collection. Exact totals are absent when coverage is incomplete; kind counts state their coverage. */
|
|
174
|
+
summary?: Array<{
|
|
175
|
+
collection: ExplorationCollection;
|
|
176
|
+
unit?: "objects" | "rows";
|
|
177
|
+
row_metadata?: { actor_rows: number; entity_rows: number; tag_memberships: number };
|
|
178
|
+
/** Requested literal tags on admitted definitions or distinct objects; never inherited. */
|
|
179
|
+
tag_counts?: Array<{ tag: string; count: number }>;
|
|
180
|
+
/** Admitted/examined rows or objects, a lower bound when coverage is incomplete. */
|
|
181
|
+
examined?: number;
|
|
182
|
+
/** Authored tags on admitted definition rows or distinct admitted objects (per collection), bounded by limit (default twelve); never on places. */
|
|
183
|
+
tag_facets?: { items: Array<{ tag: string; count: number }>; more: boolean };
|
|
184
|
+
/**
|
|
185
|
+
* Definitions only, default summary (without --facets): the five most frequent
|
|
186
|
+
* authored definition tags that do not refine another admitted tag (dot parent),
|
|
187
|
+
* as content families. Lower bounds when the collection is incomplete.
|
|
188
|
+
*/
|
|
189
|
+
families?: { items: Array<{ tag: string; count: number }>; more: boolean };
|
|
190
|
+
completeness: "complete" | "incomplete";
|
|
191
|
+
total?: number;
|
|
192
|
+
by_kind?: Array<{ kind: string; count: number; completeness?: "complete" | "incomplete" }>;
|
|
193
|
+
}>;
|
|
194
|
+
/**
|
|
195
|
+
* References only: the declared link families this answer read, from the static
|
|
196
|
+
* projection topology. `complete` is complete over these; other authored links are not read.
|
|
197
|
+
*/
|
|
198
|
+
links?: string[];
|
|
199
|
+
/**
|
|
200
|
+
* Summary only: the bundles of admitted rows (plus authored file bundles without
|
|
201
|
+
* rows), in UTF-8 order, at most twenty. Counts are rows (places, definitions) or
|
|
202
|
+
* distinct objects (instances); lower bounds when `completeness` is incomplete.
|
|
203
|
+
* `title` comes only from an authored bundle row of a file source, never guessed.
|
|
204
|
+
*/
|
|
205
|
+
bundles?: {
|
|
206
|
+
items: Array<{
|
|
207
|
+
bundle: string;
|
|
208
|
+
title?: string;
|
|
209
|
+
places: number;
|
|
210
|
+
definitions: number;
|
|
211
|
+
objects: number;
|
|
212
|
+
}>;
|
|
213
|
+
/** Admitted rows without a bundle, so the per-bundle counts add up to the totals. */
|
|
214
|
+
unbundled?: { places: number; definitions: number; objects: number };
|
|
215
|
+
more: boolean;
|
|
216
|
+
completeness: "complete" | "incomplete";
|
|
217
|
+
};
|
|
218
|
+
items: ExplorationItem[];
|
|
219
|
+
/**
|
|
220
|
+
* `complete` means no further page exists. `total` counts the items paging would
|
|
221
|
+
* return under this snapshot, only for search/neighbors/references with complete coverage.
|
|
222
|
+
* A search page that is cut also offers, in `next`, the same request with `limit: 20`.
|
|
223
|
+
*/
|
|
224
|
+
page: {
|
|
225
|
+
complete: boolean;
|
|
226
|
+
/** Admitted rows in the declared read families before matching or paging; not raw server scan counts. */
|
|
227
|
+
examined?: number;
|
|
228
|
+
/** Matching admitted items across all pages; a lower bound, never an exact total. */
|
|
229
|
+
matching?: number;
|
|
230
|
+
/** Unrestricted text matches across all pages, with independent collection coverage. */
|
|
231
|
+
by_collection?: Array<{
|
|
232
|
+
collection: ExplorationCollection;
|
|
233
|
+
count: number;
|
|
234
|
+
completeness: "complete" | "incomplete";
|
|
235
|
+
}>;
|
|
236
|
+
next_cursor?: string;
|
|
237
|
+
total?: {
|
|
238
|
+
count: number;
|
|
239
|
+
unit?: "objects";
|
|
240
|
+
/** Matching representatives by kind across all pages; rows unless unit is objects. */
|
|
241
|
+
by_kind?: Array<{ kind: string; count: number }>;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
/** At most four ready-to-run follow-ups built from this request and response; omitted when empty. */
|
|
245
|
+
next?: ExploreRequest[];
|
|
246
|
+
/** Reserved for unavailable, stale_cursor and incomplete coverage; omitted when empty. */
|
|
247
|
+
recovery?: Array<{ tool: string; params: Record<string, unknown> }>;
|
|
248
|
+
}
|
package/src/git-batch.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Strict framing for `git cat-file --batch`; sizes count bytes, including UTF-8 content. */
|
|
2
|
+
export function gitBatchInput(specs: readonly string[]): string {
|
|
3
|
+
if (specs.some((spec) => /[\r\n\0]/.test(spec))) throw new Error("unsafe Git batch object name");
|
|
4
|
+
return specs.length === 0 ? "" : `${specs.join("\n")}\n`;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function parseGitBatch(
|
|
8
|
+
specs: readonly string[],
|
|
9
|
+
output: Uint8Array,
|
|
10
|
+
decode: (bytes: Uint8Array) => string,
|
|
11
|
+
): ReadonlyMap<string, string | null> {
|
|
12
|
+
gitBatchInput(specs);
|
|
13
|
+
const files = new Map<string, string | null>();
|
|
14
|
+
let offset = 0;
|
|
15
|
+
for (const spec of specs) {
|
|
16
|
+
const end = output.indexOf(10, offset);
|
|
17
|
+
if (end < 0) throw new Error(`truncated Git batch header: ${spec}`);
|
|
18
|
+
const header = decode(output.subarray(offset, end));
|
|
19
|
+
offset = end + 1;
|
|
20
|
+
if (header === `${spec} missing`) {
|
|
21
|
+
files.set(spec, null);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const match = /^(?:[a-f0-9]{40}|[a-f0-9]{64}) blob ([0-9]+)$/.exec(header);
|
|
25
|
+
if (match === null) throw new Error(`invalid Git batch header: ${spec}`);
|
|
26
|
+
const size = Number(match[1]);
|
|
27
|
+
if (!Number.isSafeInteger(size) || size > output.length - offset - 1) {
|
|
28
|
+
throw new Error(`truncated Git batch content: ${spec}`);
|
|
29
|
+
}
|
|
30
|
+
if (output[offset + size] !== 10) throw new Error(`invalid Git batch delimiter: ${spec}`);
|
|
31
|
+
files.set(spec, decode(output.subarray(offset, offset + size)));
|
|
32
|
+
offset += size + 1;
|
|
33
|
+
}
|
|
34
|
+
if (offset !== output.length) throw new Error("unexpected trailing Git batch output");
|
|
35
|
+
return files;
|
|
36
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
export const GRANT_ROLE_TOOL = "spellkave_grant_role";
|
|
3
|
+
export const REVOKE_ROLE_TOOL = "spellkave_revoke_role";
|
|
4
|
+
export const LIST_GRANTS_TOOL = "spellkave_list_grants";
|
|
5
|
+
export const EXPORT_GRANTS_TOOL = "spellkave_export_grants";
|
|
6
|
+
export const GRANT_ROLE_PARAMS = Type.Object({
|
|
7
|
+
role: Type.String(),
|
|
8
|
+
subject: Type.String(),
|
|
9
|
+
extent_kind: Type.String({ default: "place_graph" }),
|
|
10
|
+
extent: Type.String(),
|
|
11
|
+
expires_at_tick: Type.Optional(Type.String({ pattern: "^[0-9]+$" })),
|
|
12
|
+
description: Type.Optional(Type.String()),
|
|
13
|
+
bundle: Type.Optional(Type.String()),
|
|
14
|
+
});
|
|
15
|
+
export const REVOKE_ROLE_PARAMS = Type.Object({ binding_id: Type.String() });
|
|
16
|
+
export const LIST_GRANTS_PARAMS = Type.Object({
|
|
17
|
+
subject: Type.Optional(Type.String()),
|
|
18
|
+
role: Type.Optional(Type.String()),
|
|
19
|
+
extent: Type.Optional(Type.String()),
|
|
20
|
+
});
|
|
21
|
+
export const EXPORT_GRANTS_PARAMS = Type.Object({ out: Type.Optional(Type.String()) });
|
|
22
|
+
|
|
23
|
+
export const PREPARE_HAND_OVER_TOOL = "spellkave_prepare_hand_over";
|
|
24
|
+
export const HAND_OVER_ROLE_TOOL = "spellkave_hand_over_role";
|
|
25
|
+
export const PREPARE_HAND_OVER_PARAMS = Type.Object({
|
|
26
|
+
binding_id: Type.String(),
|
|
27
|
+
subject: Type.String(),
|
|
28
|
+
});
|
|
29
|
+
export const HAND_OVER_ROLE_PARAMS = Type.Object({
|
|
30
|
+
binding_id: Type.String(),
|
|
31
|
+
subject: Type.String(),
|
|
32
|
+
expected_digest: Type.String({ pattern: "^[a-f0-9]{64}$" }),
|
|
33
|
+
expected_merged_role_digest: Type.String({ pattern: "^[a-f0-9]{64}$" }),
|
|
34
|
+
expected_incarnation: Type.String({ minLength: 1, maxLength: 256 }),
|
|
35
|
+
expected_revision: Type.String({ pattern: "^[0-9]+$" }),
|
|
36
|
+
request_id: Type.String({ format: "uuid" }),
|
|
37
|
+
reason: Type.String({ minLength: 1, maxLength: 1024 }),
|
|
38
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./admission";
|
|
2
|
+
export * from "./contract-data";
|
|
3
|
+
export * from "./docs-metadata";
|
|
4
|
+
export * from "./exploration";
|
|
5
|
+
export * from "./metadata";
|
|
6
|
+
export * from "./owner-instance-read";
|
|
7
|
+
export * from "./personas";
|
|
8
|
+
export * from "./roster";
|
|
9
|
+
export * from "./schema-registry";
|
|
10
|
+
export * from "./schemas";
|
package/src/metadata.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { TSchema } from "typebox";
|
|
2
|
+
import { admitsTool } from "./admission";
|
|
3
|
+
|
|
4
|
+
import { RAW_TOOL_CONTRACT_DATA, type ToolContractData, type ToolRole } from "./contract-data";
|
|
5
|
+
import { getToolParameters } from "./schema-registry";
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
TOOL_EXECUTION_MODES,
|
|
9
|
+
TOOL_ROLES,
|
|
10
|
+
type ToolCliMetadata,
|
|
11
|
+
type ToolContractData,
|
|
12
|
+
type ToolExecutionMode,
|
|
13
|
+
type ToolRole,
|
|
14
|
+
} from "./contract-data";
|
|
15
|
+
|
|
16
|
+
/** Portable descriptor bound to the actual TypeBox schema source. */
|
|
17
|
+
export interface ToolContract extends Omit<ToolContractData, "parameters"> {
|
|
18
|
+
parameters: TSchema;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const TOOL_CONTRACTS: readonly ToolContract[] = RAW_TOOL_CONTRACT_DATA.tools.map(
|
|
22
|
+
(contract) => ({ ...contract, parameters: getToolParameters(contract.name) }),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
/** Ordered host-presentation rosters captured before the package cut. */
|
|
26
|
+
export const TOOL_ROLE_ROSTERS = RAW_TOOL_CONTRACT_DATA.rosters;
|
|
27
|
+
|
|
28
|
+
const contractsByName = new Map(TOOL_CONTRACTS.map((contract) => [contract.name, contract]));
|
|
29
|
+
|
|
30
|
+
export function getToolContract(name: string): ToolContract {
|
|
31
|
+
const contract = contractsByName.get(name);
|
|
32
|
+
if (contract === undefined) throw new Error(`Unknown Spellkave tool contract '${name}'.`);
|
|
33
|
+
return contract;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function toolContractsForRole(role: ToolRole): readonly ToolContract[] {
|
|
37
|
+
return TOOL_ROLE_ROSTERS[role].map(getToolContract);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Canonical PLAYER order followed by admitted elevated contracts in registry order. */
|
|
41
|
+
export function toolContractsForAuthority(
|
|
42
|
+
authority: import("./admission").LiveToolAuthority,
|
|
43
|
+
ports: readonly string[],
|
|
44
|
+
): readonly ToolContract[] {
|
|
45
|
+
const player = toolContractsForRole("PLAYER");
|
|
46
|
+
const ordered = [...player, ...TOOL_CONTRACTS.filter((contract) => !player.includes(contract))];
|
|
47
|
+
return ordered.filter((contract) => admitsTool(contract.admission, authority, ports));
|
|
48
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/** Browser-safe DTOs for `spellkave_get` / `spellkave_describe` (D-11). No runtime. */
|
|
2
|
+
|
|
3
|
+
export const AUTHORED_ENTITIES_ONLY = "authored_entities_only";
|
|
4
|
+
|
|
5
|
+
export type OwnerInstanceRowKind =
|
|
6
|
+
| "entities"
|
|
7
|
+
| "actors"
|
|
8
|
+
| "actor_spatial_locations"
|
|
9
|
+
| "actor_capabilities"
|
|
10
|
+
| "actor_equipment_slots"
|
|
11
|
+
| "entity_containment"
|
|
12
|
+
| "entity_tag"
|
|
13
|
+
| "object_state";
|
|
14
|
+
|
|
15
|
+
export type OwnerGetInput = {
|
|
16
|
+
kind: string;
|
|
17
|
+
key?: string;
|
|
18
|
+
bundle?: string;
|
|
19
|
+
pattern?: string;
|
|
20
|
+
fields?: string[];
|
|
21
|
+
limit?: number;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type OwnerDescribeInput = {
|
|
25
|
+
kind: string;
|
|
26
|
+
key: string;
|
|
27
|
+
bundle?: string;
|
|
28
|
+
limit?: number;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type OwnerGetAnswer =
|
|
32
|
+
| {
|
|
33
|
+
ok: true;
|
|
34
|
+
source?: ScopedReadSource;
|
|
35
|
+
kind: string;
|
|
36
|
+
bundle?: string;
|
|
37
|
+
tick: string;
|
|
38
|
+
labels: readonly string[];
|
|
39
|
+
row?: Record<string, unknown>;
|
|
40
|
+
rows?: Record<string, unknown>[];
|
|
41
|
+
match_count?: number;
|
|
42
|
+
left_out?: number;
|
|
43
|
+
}
|
|
44
|
+
| {
|
|
45
|
+
ok: false;
|
|
46
|
+
source?: ScopedReadSource;
|
|
47
|
+
code:
|
|
48
|
+
| "not_publisher"
|
|
49
|
+
| "unknown_key"
|
|
50
|
+
| "ambiguous_bundle"
|
|
51
|
+
| "usage"
|
|
52
|
+
| "reader_unavailable"
|
|
53
|
+
| "not_found_in_scope";
|
|
54
|
+
message: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type OwnerDescribeAnswer =
|
|
58
|
+
| {
|
|
59
|
+
ok: true;
|
|
60
|
+
source?: ScopedReadSource;
|
|
61
|
+
kind: "entities";
|
|
62
|
+
bundle?: string;
|
|
63
|
+
tick: string;
|
|
64
|
+
labels: readonly string[];
|
|
65
|
+
row: Record<string, unknown>;
|
|
66
|
+
slices: Partial<Record<OwnerInstanceRowKind, Record<string, unknown>[]>>;
|
|
67
|
+
numeric_id: string;
|
|
68
|
+
place?: string;
|
|
69
|
+
container_chain: Array<{
|
|
70
|
+
numeric_id: string;
|
|
71
|
+
entity_key?: string;
|
|
72
|
+
place?: string;
|
|
73
|
+
}>;
|
|
74
|
+
chain_end: { reason: "place" | "none" | "cycle" | "outside_read_scope"; numeric_id?: string };
|
|
75
|
+
belonging: Array<{
|
|
76
|
+
entity_key: string;
|
|
77
|
+
numeric_id: string;
|
|
78
|
+
name?: string;
|
|
79
|
+
definition?: string;
|
|
80
|
+
belongs_to_key?: string;
|
|
81
|
+
belongs_to_numeric_id: string;
|
|
82
|
+
relation: "containment" | "ownership" | "equipment";
|
|
83
|
+
}>;
|
|
84
|
+
match_count: number;
|
|
85
|
+
left_out: number;
|
|
86
|
+
}
|
|
87
|
+
| {
|
|
88
|
+
ok: false;
|
|
89
|
+
source?: ScopedReadSource;
|
|
90
|
+
code:
|
|
91
|
+
| "not_publisher"
|
|
92
|
+
| "unknown_key"
|
|
93
|
+
| "ambiguous_bundle"
|
|
94
|
+
| "usage"
|
|
95
|
+
| "reader_unavailable"
|
|
96
|
+
| "not_found_in_scope";
|
|
97
|
+
message: string;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export interface OwnerInstanceRead {
|
|
101
|
+
get(input: OwnerGetInput): OwnerGetAnswer;
|
|
102
|
+
describe(input: OwnerDescribeInput): OwnerDescribeAnswer;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface ScopedReadSource {
|
|
106
|
+
reads_as_publisher: false;
|
|
107
|
+
identity: string;
|
|
108
|
+
world: string;
|
|
109
|
+
connection_epoch: number;
|
|
110
|
+
source_epoch: number;
|
|
111
|
+
tick: string;
|
|
112
|
+
projection_version: number;
|
|
113
|
+
authorized_scopes: readonly string[];
|
|
114
|
+
read_depths?: readonly { binding_id: string; depth: "hidden" | "internal" }[];
|
|
115
|
+
authorized_bundles?: readonly string[];
|
|
116
|
+
coverage: Readonly<Record<string, string>>;
|
|
117
|
+
labels: readonly string[];
|
|
118
|
+
}
|
|
119
|
+
export interface ScopedInstanceRead {
|
|
120
|
+
get(input: OwnerGetInput): Promise<OwnerGetAnswer>;
|
|
121
|
+
describe(input: OwnerDescribeInput): Promise<OwnerDescribeAnswer>;
|
|
122
|
+
}
|
|
123
|
+
export type InstanceRead = OwnerInstanceRead | ScopedInstanceRead;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "personas/0.6",
|
|
3
|
+
"source": "specifications/prd/personas.md#42-personas--roles",
|
|
4
|
+
"personas": [
|
|
5
|
+
{
|
|
6
|
+
"id": "publisher",
|
|
7
|
+
"name": "Publisher",
|
|
8
|
+
"roles": [],
|
|
9
|
+
"extent": "world",
|
|
10
|
+
"presentation": "all"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"id": "game-system-author",
|
|
14
|
+
"name": "Game System Author",
|
|
15
|
+
"roles": [
|
|
16
|
+
"system-author"
|
|
17
|
+
],
|
|
18
|
+
"extent": "bundle",
|
|
19
|
+
"presentation": "AUTHOR"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "adventure-author",
|
|
23
|
+
"name": "Adventure Author",
|
|
24
|
+
"roles": [
|
|
25
|
+
"adventure-author"
|
|
26
|
+
],
|
|
27
|
+
"extent": "bundle",
|
|
28
|
+
"presentation": "AUTHOR"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "dungeon-master",
|
|
32
|
+
"name": "Dungeon Master",
|
|
33
|
+
"roles": [
|
|
34
|
+
"dm"
|
|
35
|
+
],
|
|
36
|
+
"extent": "place graph or party",
|
|
37
|
+
"presentation": "PLAYER + DM"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": "elevated-player",
|
|
41
|
+
"name": "Elevated Player",
|
|
42
|
+
"roles": [],
|
|
43
|
+
"extent": "party or place",
|
|
44
|
+
"presentation": "PLAYER + the few tools the role admits"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
package/src/personas.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import mapping from "./personas.generated.json";
|
|
2
|
+
|
|
3
|
+
export const PERSONA_DOCUMENTATION_VERSION = mapping.version;
|
|
4
|
+
export const PERSONA_MAPPINGS = mapping.personas;
|
|
5
|
+
|
|
6
|
+
/** Documentary only: no host admission or reducer accepts a persona string. */
|
|
7
|
+
export function explainPersona(name: string) {
|
|
8
|
+
const normalized = name.toLowerCase().replace(/[ _]/g, "-");
|
|
9
|
+
const persona = PERSONA_MAPPINGS.find((row) => row.id === normalized);
|
|
10
|
+
return {
|
|
11
|
+
ok: persona !== undefined,
|
|
12
|
+
kind: "persona",
|
|
13
|
+
documentation_only: true,
|
|
14
|
+
documentation_version: mapping.version,
|
|
15
|
+
source: mapping.source,
|
|
16
|
+
persona: persona ?? null,
|
|
17
|
+
grants_authority: false,
|
|
18
|
+
};
|
|
19
|
+
}
|
package/src/roster.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ToolRole, toolContractsForRole } from "./metadata";
|
|
2
|
+
|
|
3
|
+
export const PLAYER_TOOL_CONTRACTS = toolContractsForRole("PLAYER");
|
|
4
|
+
export const DM_TOOL_CONTRACTS = toolContractsForRole("DM");
|
|
5
|
+
export const AUTHOR_TOOL_CONTRACTS = toolContractsForRole("AUTHOR");
|
|
6
|
+
|
|
7
|
+
export const PLAYER_TOOL_NAMES = PLAYER_TOOL_CONTRACTS.map((contract) => contract.name);
|
|
8
|
+
export const DM_TOOL_NAMES = DM_TOOL_CONTRACTS.map((contract) => contract.name);
|
|
9
|
+
export const AUTHOR_TOOL_NAMES = AUTHOR_TOOL_CONTRACTS.map((contract) => contract.name);
|
|
10
|
+
|
|
11
|
+
export function toolNamesForRole(role: ToolRole): readonly string[] {
|
|
12
|
+
return toolContractsForRole(role).map((contract) => contract.name);
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
export const RENDER_SCENE_TOOL = "spellkave_render_scene";
|
|
3
|
+
export const STAGE_SCENE_TOOL = "spellkave_stage_scene";
|
|
4
|
+
export const RENDER_SCENE_PARAMS = Type.Object(
|
|
5
|
+
{
|
|
6
|
+
package: Type.Record(Type.String(), Type.Unknown(), {
|
|
7
|
+
description:
|
|
8
|
+
"Resolved spellkave-scene/v1 data package; no executable templates or filesystem paths.",
|
|
9
|
+
}),
|
|
10
|
+
values: Type.Record(Type.String(), Type.Unknown(), {
|
|
11
|
+
description: "Data values: anchor_id, optional bearing_deg and counts.",
|
|
12
|
+
}),
|
|
13
|
+
setup_name: Type.String({ pattern: "^[a-z0-9][a-z0-9._-]{0,63}$" }),
|
|
14
|
+
dependencies: Type.Array(Type.String(), {
|
|
15
|
+
maxItems: 32,
|
|
16
|
+
description: "Resolved dependency TOML payloads for offline validation.",
|
|
17
|
+
}),
|
|
18
|
+
},
|
|
19
|
+
{ additionalProperties: false },
|
|
20
|
+
);
|
|
21
|
+
export const STAGE_SCENE_PARAMS = Type.Object(
|
|
22
|
+
{
|
|
23
|
+
plan: Type.Record(Type.String(), Type.Unknown(), {
|
|
24
|
+
description: "Unmodified plan from a connected render_scene preview.",
|
|
25
|
+
}),
|
|
26
|
+
expected_world_instance_id: Type.String({ minLength: 1 }),
|
|
27
|
+
},
|
|
28
|
+
{ additionalProperties: false },
|
|
29
|
+
);
|