@iniesta8888/agent-live 0.3.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.
- package/CODE_OF_CONDUCT.md +7 -0
- package/CONTRIBUTING.md +56 -0
- package/LICENSE +21 -0
- package/README.md +92 -0
- package/SECURITY.md +13 -0
- package/dist/adapter-sdk/index.d.ts +45 -0
- package/dist/adapter-sdk/index.d.ts.map +1 -0
- package/dist/adapter-sdk/index.js +106 -0
- package/dist/adapter-sdk/index.js.map +1 -0
- package/dist/content/compiler.d.ts +31 -0
- package/dist/content/compiler.d.ts.map +1 -0
- package/dist/content/compiler.js +218 -0
- package/dist/content/compiler.js.map +1 -0
- package/dist/content/graph-validator.d.ts +56 -0
- package/dist/content/graph-validator.d.ts.map +1 -0
- package/dist/content/graph-validator.js +226 -0
- package/dist/content/graph-validator.js.map +1 -0
- package/dist/content/library.d.ts +4 -0
- package/dist/content/library.d.ts.map +1 -0
- package/dist/content/library.js +45 -0
- package/dist/content/library.js.map +1 -0
- package/dist/content/registry.d.ts +34 -0
- package/dist/content/registry.d.ts.map +1 -0
- package/dist/content/registry.js +130 -0
- package/dist/content/registry.js.map +1 -0
- package/dist/content/runtime-content.d.ts +63 -0
- package/dist/content/runtime-content.d.ts.map +1 -0
- package/dist/content/runtime-content.js +78 -0
- package/dist/content/runtime-content.js.map +1 -0
- package/dist/content/schema.d.ts +142 -0
- package/dist/content/schema.d.ts.map +1 -0
- package/dist/content/schema.js +280 -0
- package/dist/content/schema.js.map +1 -0
- package/dist/content/validator.d.ts +35 -0
- package/dist/content/validator.d.ts.map +1 -0
- package/dist/content/validator.js +205 -0
- package/dist/content/validator.js.map +1 -0
- package/dist/core/agents.d.ts +56 -0
- package/dist/core/agents.d.ts.map +1 -0
- package/dist/core/agents.js +148 -0
- package/dist/core/agents.js.map +1 -0
- package/dist/core/limits.d.ts +15 -0
- package/dist/core/limits.d.ts.map +1 -0
- package/dist/core/limits.js +16 -0
- package/dist/core/limits.js.map +1 -0
- package/dist/core/mapping.d.ts +17 -0
- package/dist/core/mapping.d.ts.map +1 -0
- package/dist/core/mapping.js +94 -0
- package/dist/core/mapping.js.map +1 -0
- package/dist/core/protocol.d.ts +105 -0
- package/dist/core/protocol.d.ts.map +1 -0
- package/dist/core/protocol.js +6 -0
- package/dist/core/protocol.js.map +1 -0
- package/dist/core/state.d.ts +49 -0
- package/dist/core/state.d.ts.map +1 -0
- package/dist/core/state.js +216 -0
- package/dist/core/state.js.map +1 -0
- package/dist/creator/commands.d.ts +19 -0
- package/dist/creator/commands.d.ts.map +1 -0
- package/dist/creator/commands.js +44 -0
- package/dist/creator/commands.js.map +1 -0
- package/dist/creator/mode.d.ts +10 -0
- package/dist/creator/mode.d.ts.map +1 -0
- package/dist/creator/mode.js +23 -0
- package/dist/creator/mode.js.map +1 -0
- package/dist/creator/service.d.ts +199 -0
- package/dist/creator/service.d.ts.map +1 -0
- package/dist/creator/service.js +159 -0
- package/dist/creator/service.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/agent-live-runtime.d.ts +17 -0
- package/dist/runtime/agent-live-runtime.d.ts.map +1 -0
- package/dist/runtime/agent-live-runtime.js +50 -0
- package/dist/runtime/agent-live-runtime.js.map +1 -0
- package/dist/runtime/content-service.d.ts +75 -0
- package/dist/runtime/content-service.d.ts.map +1 -0
- package/dist/runtime/content-service.js +60 -0
- package/dist/runtime/content-service.js.map +1 -0
- package/dist/runtime/resource-guard.d.ts +17 -0
- package/dist/runtime/resource-guard.d.ts.map +1 -0
- package/dist/runtime/resource-guard.js +54 -0
- package/dist/runtime/resource-guard.js.map +1 -0
- package/dist/runtime/server.d.ts +39 -0
- package/dist/runtime/server.d.ts.map +1 -0
- package/dist/runtime/server.js +286 -0
- package/dist/runtime/server.js.map +1 -0
- package/dist/web/app.d.ts +1 -0
- package/dist/web/app.js +1317 -0
- package/dist/web/index.html +45 -0
- package/dist/web/office.js +350 -0
- package/dist/web/sprites.js +185 -0
- package/dist/web/style.css +288 -0
- package/dist/web/v2/bootstrap.js +276 -0
- package/dist/web/v2/content/README.md +17 -0
- package/dist/web/v2/content/agent-skins/studio-team.json +33 -0
- package/dist/web/v2/content/agent-skins/tiny-developers.json +33 -0
- package/dist/web/v2/content/atmospheres/default.json +13 -0
- package/dist/web/v2/content/atmospheres/rainy-night.json +37 -0
- package/dist/web/v2/content/catalog.json +14 -0
- package/dist/web/v2/content/component-library/activity-implementations.json +873 -0
- package/dist/web/v2/content/component-library/activity-recipes.json +25 -0
- package/dist/web/v2/content/component-library/agent-profile-templates.json +18 -0
- package/dist/web/v2/content/component-library/catalog.json +38 -0
- package/dist/web/v2/content/component-library/npc-templates.json +42 -0
- package/dist/web/v2/content/component-library/props.json +41 -0
- package/dist/web/v2/content/environments/local-office.json +31 -0
- package/dist/web/v2/content/environments/rainy-night.json +28 -0
- package/dist/web/v2/content/environments/static-office.json +27 -0
- package/dist/web/v2/content/layouts/boardroom-office.json +122 -0
- package/dist/web/v2/content/layouts/demo-office.json +88 -0
- package/dist/web/v2/content/layouts/lively-office.json +96 -0
- package/dist/web/v2/content/layouts/old-school-office.json +154 -0
- package/dist/web/v2/content/layouts/tech-open-office.json +132 -0
- package/dist/web/v2/content/life-activities/boardroom-routines.json +67 -0
- package/dist/web/v2/content/life-activities/none.json +10 -0
- package/dist/web/v2/content/life-activities/office-basics.json +39 -0
- package/dist/web/v2/content/life-activities/old-school-routines.json +74 -0
- package/dist/web/v2/content/life-activities/tech-office-routines.json +148 -0
- package/dist/web/v2/content/npcs/boardroom-staff.json +54 -0
- package/dist/web/v2/content/npcs/none.json +10 -0
- package/dist/web/v2/content/npcs/office-staff.json +25 -0
- package/dist/web/v2/content/npcs/old-school-staff.json +39 -0
- package/dist/web/v2/content/npcs/tech-office-staff.json +40 -0
- package/dist/web/v2/content/official-offices/boardroom-office.json +25 -0
- package/dist/web/v2/content/official-offices/old-school-office.json +25 -0
- package/dist/web/v2/content/official-offices/tech-open-office.json +25 -0
- package/dist/web/v2/content/presets/boardroom-office.json +21 -0
- package/dist/web/v2/content/presets/cozy-studio.json +19 -0
- package/dist/web/v2/content/presets/demo-office.json +19 -0
- package/dist/web/v2/content/presets/lively-office.json +19 -0
- package/dist/web/v2/content/presets/night-shift.json +19 -0
- package/dist/web/v2/content/presets/old-school-office.json +20 -0
- package/dist/web/v2/content/presets/refined-demo.json +20 -0
- package/dist/web/v2/content/presets/tech-open-office.json +21 -0
- package/dist/web/v2/content/props/default-office.json +23 -0
- package/dist/web/v2/content/props/extended-office.json +39 -0
- package/dist/web/v2/content/props/tech-office.json +28 -0
- package/dist/web/v2/content/styles/pixel-classic.json +160 -0
- package/dist/web/v2/content/styles/warm-studio.json +150 -0
- package/dist/web/v2/environment-runtime.d.ts +1 -0
- package/dist/web/v2/environment-runtime.js +138 -0
- package/dist/web/v2/graph-validator.d.ts +55 -0
- package/dist/web/v2/graph-validator.js +225 -0
- package/dist/web/v2/i18n.js +54 -0
- package/dist/web/v2/locales/en.json +209 -0
- package/dist/web/v2/locales/zh-CN.json +52 -0
- package/dist/web/v2/office-engine.d.ts +1 -0
- package/dist/web/v2/office-engine.js +145 -0
- package/dist/web/v2/office-renderer.d.ts +1 -0
- package/dist/web/v2/office-renderer.js +843 -0
- package/dist/web/v2/parity.html +10 -0
- package/dist/web/v2/parity.js +82 -0
- package/dist/web/v2/sprite-renderer.d.ts +1 -0
- package/dist/web/v2/sprite-renderer.js +242 -0
- package/dist/web/v2/static-content.js +48 -0
- package/dist/web/v2/style.css +140 -0
- package/dist/web/v2.html +68 -0
- package/docs/ADAPTER-DEVELOPMENT.md +328 -0
- package/docs/ADAPTER-SDK.md +109 -0
- package/docs/ARCHITECTURE.md +223 -0
- package/docs/COMPONENT-LIBRARY.md +212 -0
- package/docs/CUSTOMIZATION.md +163 -0
- package/docs/DEVELOPER.md +186 -0
- package/docs/DSH-ADAPTER-DESIGN.md +173 -0
- package/docs/OFFICE-THEMES.md +516 -0
- package/docs/PRESET-CONFIG.md +460 -0
- package/docs/RELEASE-CHECK.md +23 -0
- package/docs/TECHNICAL.md +515 -0
- package/docs/USING-CODEX.md +24 -0
- package/docs/USING-DSH.md +44 -0
- package/docs/USING-PI.md +50 -0
- package/docs/VISION.md +146 -0
- package/examples/adapter/local-office.mjs +52 -0
- package/package.json +89 -0
- package/skills/agent-live-adapter-builder/SKILL.md +30 -0
- package/skills/agent-live-adapter-builder/agents/openai.yaml +4 -0
- package/skills/agent-live-adapter-builder/references/investigation.md +9 -0
- package/skills/agent-live-adapter-builder/references/review.md +7 -0
- package/skills/agent-live-adapter-builder/scripts/create-adapter.mjs +26 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { OfficeSpec } from "../content/schema.ts";
|
|
2
|
+
import type { ComponentLibraryView } from "../content/validator.ts";
|
|
3
|
+
import { OfficeRegistry } from "../content/registry.ts";
|
|
4
|
+
export declare const COMPONENT_CATEGORIES: readonly ["summary", "room", "npcs", "props", "activities", "appearance", "environment", "all"];
|
|
5
|
+
export type ComponentCategory = typeof COMPONENT_CATEGORIES[number];
|
|
6
|
+
export declare class CreatorService {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(registry: OfficeRegistry, library: ComponentLibraryView);
|
|
9
|
+
listOffices(): Promise<import("../content/registry.ts").RegistryEntry[]>;
|
|
10
|
+
selectOffice(id: string): Promise<{
|
|
11
|
+
selected: false;
|
|
12
|
+
error: string;
|
|
13
|
+
office?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
selected: true;
|
|
16
|
+
office: OfficeSpec;
|
|
17
|
+
error?: undefined;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Capabilities the model may map a request onto. `room` describes the room of
|
|
21
|
+
* the currently selected Office only — zones, placement slots and NPC spawns —
|
|
22
|
+
* because "add a plant" or "put a water cooler in the lounge" is only reliable
|
|
23
|
+
* when the model can see what this Office actually offers. Rooms are never
|
|
24
|
+
* presented as a choice.
|
|
25
|
+
*/
|
|
26
|
+
listComponents(category?: ComponentCategory): Promise<{
|
|
27
|
+
room: {
|
|
28
|
+
name: any;
|
|
29
|
+
zones: any;
|
|
30
|
+
slots: any;
|
|
31
|
+
npcSpawns: any;
|
|
32
|
+
textSlots: any;
|
|
33
|
+
placements: {
|
|
34
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
35
|
+
id: string;
|
|
36
|
+
component: string;
|
|
37
|
+
slot: string;
|
|
38
|
+
}[];
|
|
39
|
+
} | null;
|
|
40
|
+
styles: any[];
|
|
41
|
+
agentSkins: any[];
|
|
42
|
+
props: any[];
|
|
43
|
+
npcTemplates: any[];
|
|
44
|
+
agentProfileTemplates: any[];
|
|
45
|
+
activities: any[];
|
|
46
|
+
atmospheres: any[];
|
|
47
|
+
environments: any[];
|
|
48
|
+
} | {
|
|
49
|
+
room: {
|
|
50
|
+
name: any;
|
|
51
|
+
zones: any;
|
|
52
|
+
slots: any;
|
|
53
|
+
npcSpawns: any;
|
|
54
|
+
textSlots: any;
|
|
55
|
+
placements: {
|
|
56
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
57
|
+
id: string;
|
|
58
|
+
component: string;
|
|
59
|
+
slot: string;
|
|
60
|
+
}[];
|
|
61
|
+
} | null;
|
|
62
|
+
npcTemplates?: undefined;
|
|
63
|
+
props?: undefined;
|
|
64
|
+
activities?: undefined;
|
|
65
|
+
styles?: undefined;
|
|
66
|
+
agentSkins?: undefined;
|
|
67
|
+
agentProfileTemplates?: undefined;
|
|
68
|
+
atmospheres?: undefined;
|
|
69
|
+
environments?: undefined;
|
|
70
|
+
office?: undefined;
|
|
71
|
+
counts?: undefined;
|
|
72
|
+
categories?: undefined;
|
|
73
|
+
} | {
|
|
74
|
+
npcTemplates: any[];
|
|
75
|
+
room?: undefined;
|
|
76
|
+
props?: undefined;
|
|
77
|
+
activities?: undefined;
|
|
78
|
+
styles?: undefined;
|
|
79
|
+
agentSkins?: undefined;
|
|
80
|
+
agentProfileTemplates?: undefined;
|
|
81
|
+
atmospheres?: undefined;
|
|
82
|
+
environments?: undefined;
|
|
83
|
+
office?: undefined;
|
|
84
|
+
counts?: undefined;
|
|
85
|
+
categories?: undefined;
|
|
86
|
+
} | {
|
|
87
|
+
room: {
|
|
88
|
+
name: any;
|
|
89
|
+
zones: any;
|
|
90
|
+
slots: any;
|
|
91
|
+
npcSpawns: any;
|
|
92
|
+
textSlots: any;
|
|
93
|
+
placements: {
|
|
94
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
95
|
+
id: string;
|
|
96
|
+
component: string;
|
|
97
|
+
slot: string;
|
|
98
|
+
}[];
|
|
99
|
+
} | null;
|
|
100
|
+
props: any[];
|
|
101
|
+
npcTemplates?: undefined;
|
|
102
|
+
activities?: undefined;
|
|
103
|
+
styles?: undefined;
|
|
104
|
+
agentSkins?: undefined;
|
|
105
|
+
agentProfileTemplates?: undefined;
|
|
106
|
+
atmospheres?: undefined;
|
|
107
|
+
environments?: undefined;
|
|
108
|
+
office?: undefined;
|
|
109
|
+
counts?: undefined;
|
|
110
|
+
categories?: undefined;
|
|
111
|
+
} | {
|
|
112
|
+
activities: any[];
|
|
113
|
+
room?: undefined;
|
|
114
|
+
npcTemplates?: undefined;
|
|
115
|
+
props?: undefined;
|
|
116
|
+
styles?: undefined;
|
|
117
|
+
agentSkins?: undefined;
|
|
118
|
+
agentProfileTemplates?: undefined;
|
|
119
|
+
atmospheres?: undefined;
|
|
120
|
+
environments?: undefined;
|
|
121
|
+
office?: undefined;
|
|
122
|
+
counts?: undefined;
|
|
123
|
+
categories?: undefined;
|
|
124
|
+
} | {
|
|
125
|
+
styles: any[];
|
|
126
|
+
agentSkins: any[];
|
|
127
|
+
agentProfileTemplates: any[];
|
|
128
|
+
room?: undefined;
|
|
129
|
+
npcTemplates?: undefined;
|
|
130
|
+
props?: undefined;
|
|
131
|
+
activities?: undefined;
|
|
132
|
+
atmospheres?: undefined;
|
|
133
|
+
environments?: undefined;
|
|
134
|
+
office?: undefined;
|
|
135
|
+
counts?: undefined;
|
|
136
|
+
categories?: undefined;
|
|
137
|
+
} | {
|
|
138
|
+
atmospheres: any[];
|
|
139
|
+
environments: any[];
|
|
140
|
+
room?: undefined;
|
|
141
|
+
npcTemplates?: undefined;
|
|
142
|
+
props?: undefined;
|
|
143
|
+
activities?: undefined;
|
|
144
|
+
styles?: undefined;
|
|
145
|
+
agentSkins?: undefined;
|
|
146
|
+
agentProfileTemplates?: undefined;
|
|
147
|
+
office?: undefined;
|
|
148
|
+
counts?: undefined;
|
|
149
|
+
categories?: undefined;
|
|
150
|
+
} | {
|
|
151
|
+
office: {
|
|
152
|
+
id: string;
|
|
153
|
+
name: string;
|
|
154
|
+
origin: "official" | "custom";
|
|
155
|
+
agentProfile: import("../content/schema.ts").AgentProfile | null;
|
|
156
|
+
texts: Record<string, string>;
|
|
157
|
+
npcs: {
|
|
158
|
+
id: string;
|
|
159
|
+
template: string | undefined;
|
|
160
|
+
name: string | undefined;
|
|
161
|
+
title: string | undefined;
|
|
162
|
+
gender: "female" | "male" | "nonbinary" | "unspecified" | undefined;
|
|
163
|
+
spawn: string | undefined;
|
|
164
|
+
}[];
|
|
165
|
+
};
|
|
166
|
+
counts: {
|
|
167
|
+
styles: number;
|
|
168
|
+
agentSkins: number;
|
|
169
|
+
props: number;
|
|
170
|
+
npcTemplates: number;
|
|
171
|
+
activities: number;
|
|
172
|
+
atmospheres: number;
|
|
173
|
+
environments: number;
|
|
174
|
+
};
|
|
175
|
+
categories: ("npcs" | "props" | "activities" | "environment" | "appearance" | "room" | "all")[];
|
|
176
|
+
room?: undefined;
|
|
177
|
+
npcTemplates?: undefined;
|
|
178
|
+
props?: undefined;
|
|
179
|
+
activities?: undefined;
|
|
180
|
+
styles?: undefined;
|
|
181
|
+
agentSkins?: undefined;
|
|
182
|
+
agentProfileTemplates?: undefined;
|
|
183
|
+
atmospheres?: undefined;
|
|
184
|
+
environments?: undefined;
|
|
185
|
+
}>;
|
|
186
|
+
/** Validate, persist and select one customization without exposing draft state. */
|
|
187
|
+
customize(patchInput: unknown, baseOffice?: string): Promise<{
|
|
188
|
+
saved: boolean;
|
|
189
|
+
errors: import("../content/validator.ts").ValidationIssue[];
|
|
190
|
+
adjustments: import("../content/compiler.ts").CompileAdjustment[];
|
|
191
|
+
office?: undefined;
|
|
192
|
+
} | {
|
|
193
|
+
saved: boolean;
|
|
194
|
+
office: OfficeSpec;
|
|
195
|
+
errors: never[];
|
|
196
|
+
adjustments: import("../content/compiler.ts").CompileAdjustment[];
|
|
197
|
+
}>;
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../plugins/agent-live/src/creator/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,eAAO,MAAM,oBAAoB,iGAAkG,CAAC;AACpI,MAAM,MAAM,iBAAiB,GAAG,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAuBpE,qBAAa,cAAc;;gBAId,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,oBAAoB;IAK7D,WAAW;IAEX,YAAY,CAAC,EAAE,EAAE,MAAM;;;;;;;;;IAO7B;;;;;;OAMG;IACG,cAAc,CAAC,QAAQ,GAAE,iBAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoD5D,mFAAmF;IAC7E,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM;;;;;;;;;;;CAgDxD"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { compileOfficePatch, ownerPresetId, patchOfficeId, presetIdForLocalId } from "../content/compiler.js";
|
|
2
|
+
export const COMPONENT_CATEGORIES = ["summary", "room", "npcs", "props", "activities", "appearance", "environment", "all"];
|
|
3
|
+
/**
|
|
4
|
+
* What the selected Office's room offers: the zones a request can name, the
|
|
5
|
+
* slots that exist and what they accept, who currently occupies them, and where
|
|
6
|
+
* NPCs may spawn. This is model-facing context only; rooms are never a choice.
|
|
7
|
+
*/
|
|
8
|
+
function roomView(library, office) {
|
|
9
|
+
const layout = library.layouts.get(office.layout);
|
|
10
|
+
if (!layout)
|
|
11
|
+
return null;
|
|
12
|
+
const occupants = new Map();
|
|
13
|
+
for (const slot of layout.placementSlots ?? [])
|
|
14
|
+
occupants.set(slot.id, null);
|
|
15
|
+
for (const placement of office.placements)
|
|
16
|
+
occupants.set(placement.slot, placement.id);
|
|
17
|
+
return {
|
|
18
|
+
name: layout.name,
|
|
19
|
+
zones: (layout.zones ?? []).map((zone) => ({ id: zone.id, name: zone.name, x: zone.x, y: zone.y, width: zone.width, height: zone.height })),
|
|
20
|
+
slots: (layout.placementSlots ?? []).map((slot) => ({ id: slot.id, zone: slot.zone, accepts: slot.accepts ?? [], maxSize: slot.maxSize, occupiedBy: occupants.get(slot.id) ?? null })),
|
|
21
|
+
npcSpawns: layout.npcSpawns ?? [],
|
|
22
|
+
textSlots: (layout.textSlots ?? []).map((slot) => ({ id: slot.id, name: slot.name, maxLength: slot.maxLength, text: office.texts?.[slot.id] ?? slot.defaultText ?? "" })),
|
|
23
|
+
placements: office.placements.map((placement) => ({ id: placement.id, component: placement.component, slot: placement.slot, ...(placement.orientation ? { orientation: placement.orientation } : {}) })),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export class CreatorService {
|
|
27
|
+
#registry;
|
|
28
|
+
#library;
|
|
29
|
+
constructor(registry, library) {
|
|
30
|
+
this.#registry = registry;
|
|
31
|
+
this.#library = library;
|
|
32
|
+
}
|
|
33
|
+
async listOffices() { return this.#registry.list(); }
|
|
34
|
+
async selectOffice(id) {
|
|
35
|
+
const office = await this.#registry.get(id);
|
|
36
|
+
if (!office)
|
|
37
|
+
return { selected: false, error: `unknown or invalid office ${id}` };
|
|
38
|
+
await this.#registry.select(id);
|
|
39
|
+
return { selected: true, office };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Capabilities the model may map a request onto. `room` describes the room of
|
|
43
|
+
* the currently selected Office only — zones, placement slots and NPC spawns —
|
|
44
|
+
* because "add a plant" or "put a water cooler in the lounge" is only reliable
|
|
45
|
+
* when the model can see what this Office actually offers. Rooms are never
|
|
46
|
+
* presented as a choice.
|
|
47
|
+
*/
|
|
48
|
+
async listComponents(category = "summary") {
|
|
49
|
+
const office = await this.#registry.selected();
|
|
50
|
+
const full = {
|
|
51
|
+
room: roomView(this.#library, office),
|
|
52
|
+
styles: structuredClone(this.#library.descriptors.styles),
|
|
53
|
+
agentSkins: structuredClone(this.#library.descriptors.agentSkins),
|
|
54
|
+
props: structuredClone([...this.#library.props.values()]),
|
|
55
|
+
npcTemplates: structuredClone([...this.#library.npcTemplates.values()]),
|
|
56
|
+
agentProfileTemplates: structuredClone([...this.#library.agentProfileTemplates.values()]),
|
|
57
|
+
activities: [...this.#library.activityRecipes.values()].map((entry) => ({ ...structuredClone(entry), rooms: [...this.#library.activityImplementations.values()].filter((implementation) => implementation.recipe === entry.id).map((implementation) => implementation.layout) })),
|
|
58
|
+
atmospheres: structuredClone(this.#library.descriptors.atmospheres),
|
|
59
|
+
environments: structuredClone(this.#library.descriptors.environments),
|
|
60
|
+
};
|
|
61
|
+
if (category === "all")
|
|
62
|
+
return full;
|
|
63
|
+
if (category === "room")
|
|
64
|
+
return { room: full.room };
|
|
65
|
+
if (category === "npcs")
|
|
66
|
+
return { npcTemplates: full.npcTemplates };
|
|
67
|
+
if (category === "props")
|
|
68
|
+
return { room: full.room, props: full.props };
|
|
69
|
+
if (category === "activities")
|
|
70
|
+
return { activities: full.activities };
|
|
71
|
+
if (category === "appearance")
|
|
72
|
+
return { styles: full.styles, agentSkins: full.agentSkins, agentProfileTemplates: full.agentProfileTemplates };
|
|
73
|
+
if (category === "environment")
|
|
74
|
+
return { atmospheres: full.atmospheres, environments: full.environments };
|
|
75
|
+
return {
|
|
76
|
+
// The compact view is also the model's edit baseline. Supplying the
|
|
77
|
+
// bounded, user-editable state here avoids filesystem inspection and
|
|
78
|
+
// repeated catalog calls just to discover an NPC id or text slot.
|
|
79
|
+
office: {
|
|
80
|
+
id: office.id,
|
|
81
|
+
name: office.name,
|
|
82
|
+
origin: office.origin,
|
|
83
|
+
agentProfile: structuredClone(office.agentProfile ?? null),
|
|
84
|
+
texts: structuredClone(office.texts ?? {}),
|
|
85
|
+
npcs: office.npcs.map((npc) => ({
|
|
86
|
+
id: npc.id,
|
|
87
|
+
template: npc.template,
|
|
88
|
+
name: npc.name,
|
|
89
|
+
title: npc.title,
|
|
90
|
+
gender: npc.gender,
|
|
91
|
+
spawn: npc.spawn,
|
|
92
|
+
})),
|
|
93
|
+
},
|
|
94
|
+
counts: {
|
|
95
|
+
styles: full.styles.length,
|
|
96
|
+
agentSkins: full.agentSkins.length,
|
|
97
|
+
props: full.props.length,
|
|
98
|
+
npcTemplates: full.npcTemplates.length,
|
|
99
|
+
activities: full.activities.length,
|
|
100
|
+
atmospheres: full.atmospheres.length,
|
|
101
|
+
environments: full.environments.length,
|
|
102
|
+
},
|
|
103
|
+
categories: COMPONENT_CATEGORIES.filter((entry) => entry !== "summary"),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** Validate, persist and select one customization without exposing draft state. */
|
|
107
|
+
async customize(patchInput, baseOffice) {
|
|
108
|
+
if (!patchInput || typeof patchInput !== "object" || Array.isArray(patchInput)) {
|
|
109
|
+
return { saved: false, errors: [{ code: "invalid-patch-shape", path: "$", message: "patch must be an object" }], adjustments: [] };
|
|
110
|
+
}
|
|
111
|
+
const base = baseOffice ? await this.#registry.get(baseOffice) : await this.#registry.selected();
|
|
112
|
+
if (!base)
|
|
113
|
+
return { saved: false, errors: [{ code: "unknown-base", path: "$.base", message: `unknown or invalid base office ${baseOffice}` }], adjustments: [] };
|
|
114
|
+
const patch = {
|
|
115
|
+
...patchInput,
|
|
116
|
+
schemaVersion: 1,
|
|
117
|
+
kind: "office-patch",
|
|
118
|
+
base: base.id,
|
|
119
|
+
};
|
|
120
|
+
const compiled = compileOfficePatch(base, patch, this.#library);
|
|
121
|
+
if (!compiled.draft)
|
|
122
|
+
return { saved: false, errors: compiled.errors, adjustments: compiled.adjustments };
|
|
123
|
+
const owner = ownerPresetId(base);
|
|
124
|
+
const targetId = patchOfficeId(base);
|
|
125
|
+
const refuse = (code, message) => ({
|
|
126
|
+
saved: false,
|
|
127
|
+
errors: [{ code, path: "$.id", message }],
|
|
128
|
+
adjustments: compiled.adjustments,
|
|
129
|
+
});
|
|
130
|
+
if (compiled.draft.id !== targetId) {
|
|
131
|
+
// A patch may name the Office it creates, but it must not resolve onto an
|
|
132
|
+
// Office that already exists, and a `local/<preset>` id belongs to that
|
|
133
|
+
// Preset's own copy — taking it would leave that Preset unable to be edited.
|
|
134
|
+
if (await this.#registry.get(compiled.draft.id)) {
|
|
135
|
+
return refuse("id-conflict", `${compiled.draft.id} already exists; a patch cannot overwrite another Office`);
|
|
136
|
+
}
|
|
137
|
+
const reserved = presetIdForLocalId(compiled.draft.id);
|
|
138
|
+
if (reserved && reserved !== owner && await this.#registry.get(reserved)) {
|
|
139
|
+
return refuse("reserved-office-id", `${compiled.draft.id} is the editable copy of ${reserved}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
// The id this Office owns must not be held by an Office from another
|
|
144
|
+
// Preset, and an Office that declares no base Preset cannot prove it is
|
|
145
|
+
// this Preset's own copy, so it is never overwritten either.
|
|
146
|
+
const existing = await this.#registry.get(targetId);
|
|
147
|
+
if (existing && existing.basePreset !== owner) {
|
|
148
|
+
const occupant = existing.basePreset ? `an Office based on ${existing.basePreset}` : "an Office without a base Preset";
|
|
149
|
+
return refuse("id-conflict", `${targetId} already holds ${occupant}; it will not be overwritten`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const saved = await this.#registry.save(compiled.draft);
|
|
153
|
+
if (!saved.saved)
|
|
154
|
+
return { saved: false, errors: saved.issues, adjustments: compiled.adjustments };
|
|
155
|
+
await this.#registry.select(compiled.draft.id);
|
|
156
|
+
return { saved: true, office: structuredClone(compiled.draft), errors: [], adjustments: compiled.adjustments };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../plugins/agent-live/src/creator/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAK9G,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,CAAU,CAAC;AAGpI;;;;GAIG;AACH,SAAS,QAAQ,CAAC,OAA6B,EAAE,MAAkB;IAClE,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAClD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;IACnD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,cAAc,IAAI,EAAE;QAAE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC7E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,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;IAChH,CAAC;CAED"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { AgentLiveRuntime } from "./runtime/agent-live-runtime.ts";
|
|
2
|
+
export { OfficeState } from "./core/state.ts";
|
|
3
|
+
export { AgentRegistry } from "./core/agents.ts";
|
|
4
|
+
export { SCENE_LIMITS } from "./core/limits.ts";
|
|
5
|
+
export { CreatorModeRegistry, CREATOR_MODE_CONTEXT } from "./creator/mode.ts";
|
|
6
|
+
export { OfficeContentService } from "./runtime/content-service.ts";
|
|
7
|
+
export { CreatorService } from "./creator/service.ts";
|
|
8
|
+
export { CreatorCommandRouter } from "./creator/commands.ts";
|
|
9
|
+
export type { OfficeSpec, OfficePatch } from "./content/schema.ts";
|
|
10
|
+
export type { OfficeServer, OfficeControls, OfficeContentControls, CreatorControls } from "./runtime/server.ts";
|
|
11
|
+
export type { AgentState, AgentView, OfficeAction, OfficeDelta, OfficeEvent, SessionInfo } from "./core/protocol.ts";
|
|
12
|
+
export { defineAdapter, adapterCapabilities, connectAdapter, createOfficeEventPublisher } from "./adapter-sdk/index.ts";
|
|
13
|
+
export type { AdapterCapabilities, AdapterCleanup, AdapterContext, AdapterControls, AdapterDefinition, ConnectedAdapter, OfficeEventPublisher } from "./adapter-sdk/index.ts";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../plugins/agent-live/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACnE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAChH,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACrH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACxH,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { AgentLiveRuntime } from "./runtime/agent-live-runtime.js";
|
|
2
|
+
export { OfficeState } from "./core/state.js";
|
|
3
|
+
export { AgentRegistry } from "./core/agents.js";
|
|
4
|
+
export { SCENE_LIMITS } from "./core/limits.js";
|
|
5
|
+
export { CreatorModeRegistry, CREATOR_MODE_CONTEXT } from "./creator/mode.js";
|
|
6
|
+
export { OfficeContentService } from "./runtime/content-service.js";
|
|
7
|
+
export { CreatorService } from "./creator/service.js";
|
|
8
|
+
export { CreatorCommandRouter } from "./creator/commands.js";
|
|
9
|
+
export { defineAdapter, adapterCapabilities, connectAdapter, createOfficeEventPublisher } from "./adapter-sdk/index.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../plugins/agent-live/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OfficeState } from "../core/state.ts";
|
|
2
|
+
import { startServer, type OfficeServer } from "./server.ts";
|
|
3
|
+
/** Shared host-neutral owner for state, local HTTP/SSE service, and cleanup. */
|
|
4
|
+
export declare class AgentLiveRuntime {
|
|
5
|
+
readonly cwd: string;
|
|
6
|
+
readonly state: OfficeState;
|
|
7
|
+
private server;
|
|
8
|
+
private readonly dataRoot?;
|
|
9
|
+
private readonly resources;
|
|
10
|
+
private closed;
|
|
11
|
+
constructor(cwd: string, options?: {
|
|
12
|
+
dataRoot?: string;
|
|
13
|
+
});
|
|
14
|
+
start(options: Parameters<typeof startServer>[1]): Promise<OfficeServer>;
|
|
15
|
+
close(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=agent-live-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-live-runtime.d.ts","sourceRoot":"","sources":["../../plugins/agent-live/src/runtime/agent-live-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAI7D,gFAAgF;AAChF,qBAAa,gBAAgB;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAuB;IACjD,OAAO,CAAC,MAAM,CAAS;gBAEX,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO;IAOtD,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;IAsBxE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAK5B"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { OfficeState } from "../core/state.js";
|
|
2
|
+
import { startServer } from "./server.js";
|
|
3
|
+
import { OfficeContentService } from "./content-service.js";
|
|
4
|
+
import { ResourceGuard } from "./resource-guard.js";
|
|
5
|
+
/** Shared host-neutral owner for state, local HTTP/SSE service, and cleanup. */
|
|
6
|
+
export class AgentLiveRuntime {
|
|
7
|
+
cwd;
|
|
8
|
+
state;
|
|
9
|
+
server = null;
|
|
10
|
+
dataRoot;
|
|
11
|
+
resources = new ResourceGuard();
|
|
12
|
+
closed = false;
|
|
13
|
+
constructor(cwd, options = {}) {
|
|
14
|
+
this.cwd = cwd;
|
|
15
|
+
this.state = new OfficeState(cwd);
|
|
16
|
+
this.dataRoot = options.dataRoot;
|
|
17
|
+
this.resources.track("office-state", () => this.state.dispose());
|
|
18
|
+
}
|
|
19
|
+
async start(options) {
|
|
20
|
+
if (this.closed)
|
|
21
|
+
throw new Error("Agent Live Runtime is closed");
|
|
22
|
+
if (this.server)
|
|
23
|
+
return this.server;
|
|
24
|
+
let server = null;
|
|
25
|
+
try {
|
|
26
|
+
const contentService = options.content ? undefined : await OfficeContentService.create({ dataRoot: this.dataRoot });
|
|
27
|
+
server = await startServer(this.state, { ...options, content: options.content ?? contentService });
|
|
28
|
+
// close() may have finished while the server was starting. Registering it
|
|
29
|
+
// now would be rejected by the guard and leak a listening socket, so the
|
|
30
|
+
// freshly started server is closed instead.
|
|
31
|
+
if (this.closed)
|
|
32
|
+
throw new Error("Agent Live Runtime is closed");
|
|
33
|
+
this.server = server;
|
|
34
|
+
this.resources.track("office-server", () => server.close());
|
|
35
|
+
return server;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
this.closed = true;
|
|
39
|
+
await server?.close().catch(() => undefined);
|
|
40
|
+
await this.resources.close().catch(() => undefined);
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async close() {
|
|
45
|
+
this.closed = true;
|
|
46
|
+
this.server = null;
|
|
47
|
+
await this.resources.close();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=agent-live-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-live-runtime.js","sourceRoot":"","sources":["../../plugins/agent-live/src/runtime/agent-live-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAqB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,gFAAgF;AAChF,MAAM,OAAO,gBAAgB;IACnB,GAAG,CAAS;IACZ,KAAK,CAAc;IACpB,MAAM,GAAwB,IAAI,CAAC;IAC1B,QAAQ,CAAU;IAClB,SAAS,G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7D,OAAO,MAAM,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAC7C,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACpD,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;IAED,KAAK,CAAC,KAAK;QACV,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { loadComponentLibrary } from "../content/library.ts";
|
|
2
|
+
import { OfficeRegistry } from "../content/registry.ts";
|
|
3
|
+
export declare class OfficeContentService {
|
|
4
|
+
#private;
|
|
5
|
+
readonly registry: OfficeRegistry;
|
|
6
|
+
readonly library: Awaited<ReturnType<typeof loadComponentLibrary>>;
|
|
7
|
+
private constructor();
|
|
8
|
+
static create(options?: {
|
|
9
|
+
dataRoot?: string;
|
|
10
|
+
contentRoot?: string;
|
|
11
|
+
}): Promise<OfficeContentService>;
|
|
12
|
+
list(): Promise<import("../content/registry.ts").RegistryEntry[]>;
|
|
13
|
+
select(id: string): Promise<void>;
|
|
14
|
+
resolve(id?: string): Promise<{
|
|
15
|
+
preset: Record<string, unknown>;
|
|
16
|
+
style: any;
|
|
17
|
+
layout: any;
|
|
18
|
+
agentSkin: any;
|
|
19
|
+
agentProfile: {
|
|
20
|
+
appearance: any;
|
|
21
|
+
title?: string | undefined;
|
|
22
|
+
name?: string | undefined;
|
|
23
|
+
template: any;
|
|
24
|
+
};
|
|
25
|
+
props: {
|
|
26
|
+
schemaVersion: number;
|
|
27
|
+
kind: string;
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
version: string;
|
|
31
|
+
contract: string;
|
|
32
|
+
types: {
|
|
33
|
+
[k: string]: {
|
|
34
|
+
size: any;
|
|
35
|
+
capabilities: any;
|
|
36
|
+
renderer: any;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
npcs: {
|
|
41
|
+
schemaVersion: number;
|
|
42
|
+
kind: string;
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
version: string;
|
|
46
|
+
contract: string;
|
|
47
|
+
entries: {
|
|
48
|
+
role: any;
|
|
49
|
+
id: string;
|
|
50
|
+
template?: string;
|
|
51
|
+
profile?: string;
|
|
52
|
+
name?: string;
|
|
53
|
+
title?: string;
|
|
54
|
+
gender?: import("../content/schema.ts").Gender;
|
|
55
|
+
appearance?: import("../content/schema.ts").Appearance;
|
|
56
|
+
spawn?: string;
|
|
57
|
+
shift?: import("../content/schema.ts").Shift;
|
|
58
|
+
pose?: import("../content/schema.ts").NpcPose;
|
|
59
|
+
}[];
|
|
60
|
+
};
|
|
61
|
+
lifeActivities: {
|
|
62
|
+
schemaVersion: number;
|
|
63
|
+
kind: string;
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
version: string;
|
|
67
|
+
contract: string;
|
|
68
|
+
entries: any[];
|
|
69
|
+
};
|
|
70
|
+
atmosphere: any;
|
|
71
|
+
environment: any;
|
|
72
|
+
}>;
|
|
73
|
+
subscribe(listener: (change: unknown) => void): () => import("events")<[never]>;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=content-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-service.d.ts","sourceRoot":"","sources":["../../plugins/agent-live/src/runtime/content-service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAuB,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAkBxD,qBAAa,oBAAoB;;IAChC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAElC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC;IAEnE,OAAO;WAMM,MAAM,CAAC,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAO;IAS7E,IAAI;IACJ,MAAM,CAAC,EAAE,EAAE,MAAM;IAEX,OAAO,CAAC,EAAE,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAazB,SAAS,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI;CAI7C"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { loadComponentLibrary, loadOfficialOffices } from "../content/library.js";
|
|
6
|
+
import { OfficeRegistry } from "../content/registry.js";
|
|
7
|
+
import { resolveRuntimeContent } from "../content/runtime-content.js";
|
|
8
|
+
import { compileOfficeSpec } from "../content/compiler.js";
|
|
9
|
+
import { graphIssueMessages } from "../content/graph-validator.js";
|
|
10
|
+
function pluginRoot() {
|
|
11
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
12
|
+
}
|
|
13
|
+
function bundledContentRoot() {
|
|
14
|
+
const directory = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
const candidates = [
|
|
16
|
+
path.resolve(directory, "../../web/v2/content"),
|
|
17
|
+
path.resolve(directory, "../web/v2/content"),
|
|
18
|
+
];
|
|
19
|
+
return candidates.find((candidate) => existsSync(candidate)) ?? path.join(pluginRoot(), "web/v2/content");
|
|
20
|
+
}
|
|
21
|
+
export class OfficeContentService {
|
|
22
|
+
registry;
|
|
23
|
+
#contentRoot;
|
|
24
|
+
library;
|
|
25
|
+
constructor(contentRoot, library, registry) {
|
|
26
|
+
this.#contentRoot = contentRoot;
|
|
27
|
+
this.library = library;
|
|
28
|
+
this.registry = registry;
|
|
29
|
+
}
|
|
30
|
+
static async create(options = {}) {
|
|
31
|
+
const contentRoot = options.contentRoot ?? bundledContentRoot();
|
|
32
|
+
const library = await loadComponentLibrary(contentRoot);
|
|
33
|
+
const officialOffices = await loadOfficialOffices(contentRoot);
|
|
34
|
+
const dataRoot = options.dataRoot ?? process.env.AGENT_LIVE_DATA_DIR ?? path.join(os.homedir(), ".agent-live");
|
|
35
|
+
const registry = new OfficeRegistry({ root: dataRoot, library, officialOffices });
|
|
36
|
+
return new OfficeContentService(contentRoot, library, registry);
|
|
37
|
+
}
|
|
38
|
+
list() { return this.registry.list(); }
|
|
39
|
+
select(id) { return this.registry.select(id); }
|
|
40
|
+
async resolve(id) {
|
|
41
|
+
const office = id ? await this.registry.get(id) : await this.registry.selected();
|
|
42
|
+
if (!office)
|
|
43
|
+
throw new Error(`unknown or invalid office ${id}`);
|
|
44
|
+
const compiled = compileOfficeSpec(office, this.library);
|
|
45
|
+
if (!compiled.draft)
|
|
46
|
+
throw new Error(`office ${id} failed compilation: ${compiled.errors.map((issue) => issue.message).join("; ")}`);
|
|
47
|
+
const graph = await resolveRuntimeContent(compiled.draft, this.#contentRoot, this.library);
|
|
48
|
+
// The viewer applies the same rules; refusing here keeps "saved" and
|
|
49
|
+
// "renderable" the same thing instead of failing in the browser.
|
|
50
|
+
const issues = graphIssueMessages(graph);
|
|
51
|
+
if (issues.length)
|
|
52
|
+
throw new Error(`office ${office.id} produced content the viewer cannot render: ${issues.join("; ")}`);
|
|
53
|
+
return graph;
|
|
54
|
+
}
|
|
55
|
+
subscribe(listener) {
|
|
56
|
+
const stopRegistry = this.registry.onChange((officeId) => listener({ type: "office", officeId }));
|
|
57
|
+
return stopRegistry;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=content-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-service.js","sourceRoot":"","sources":["../../plugins/agent-live/src/runtime/content-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,SAAS,UAAU;IAClB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,kBAAkB;IAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,MAAM,UAAU,GAAG;QAClB,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,sBAAsB,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,mBAAmB,CAAC;KAC5C,CAAC;IACF,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI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