@pascal-app/core 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-operations/__fixtures__/cases.d.ts +3 -2
- package/dist/agent-operations/__fixtures__/cases.d.ts.map +1 -1
- package/dist/agent-operations/__fixtures__/place-items-cases.d.ts.map +1 -1
- package/dist/agent-operations/__fixtures__/place-items-cases.js +28 -0
- package/dist/agent-operations/__fixtures__/roof-bearing-cases.d.ts +2618 -2618
- package/dist/agent-operations/asset-catalog.d.ts +21 -11
- package/dist/agent-operations/asset-catalog.d.ts.map +1 -1
- package/dist/agent-operations/asset-catalog.js +28 -10
- package/dist/agent-operations/asset-views.d.ts +8 -3
- package/dist/agent-operations/asset-views.d.ts.map +1 -1
- package/dist/agent-operations/asset-views.js +19 -3
- package/dist/agent-operations/batch.d.ts +4 -2
- package/dist/agent-operations/batch.d.ts.map +1 -1
- package/dist/agent-operations/batch.js +9 -6
- package/dist/agent-operations/catalog-asset.d.ts +15 -0
- package/dist/agent-operations/catalog-asset.d.ts.map +1 -0
- package/dist/agent-operations/catalog-asset.js +4 -0
- package/dist/agent-operations/circulation-spaces.d.ts +585 -585
- package/dist/agent-operations/design-brief.d.ts.map +1 -1
- package/dist/agent-operations/design-brief.js +2 -0
- package/dist/agent-operations/furnish-room.d.ts.map +1 -1
- package/dist/agent-operations/furnish-room.js +2 -1
- package/dist/agent-operations/index.d.ts +5716 -7
- package/dist/agent-operations/index.d.ts.map +1 -1
- package/dist/agent-operations/index.js +17 -3
- package/dist/agent-operations/level-reads.d.ts.map +1 -1
- package/dist/agent-operations/level-reads.js +4 -1
- package/dist/agent-operations/place-in-room.d.ts.map +1 -1
- package/dist/agent-operations/place-in-room.js +2 -1
- package/dist/agent-operations/place-items.d.ts.map +1 -1
- package/dist/agent-operations/place-items.js +2 -1
- package/dist/agent-operations/scene-queries.d.ts +3818 -3818
- package/dist/agent-operations/scene-view.d.ts.map +1 -1
- package/dist/agent-operations/scene-view.js +38 -13
- package/dist/agent-operations/search-assets.d.ts.map +1 -1
- package/dist/agent-operations/search-assets.js +6 -0
- package/dist/agent-operations/types.d.ts +10 -2
- package/dist/agent-operations/types.d.ts.map +1 -1
- package/dist/agent-operations/usage-checks.js +18 -3
- package/dist/agent-operations/verify-scene.d.ts +7 -3
- package/dist/agent-operations/verify-scene.d.ts.map +1 -1
- package/dist/agent-operations/verify-scene.js +15 -7
- package/dist/agent-tools/assets.js +1 -1
- package/dist/building/__fixtures__/wall-opening-cases.d.ts +30 -30
- package/dist/building/level-duplication.d.ts +3409 -3409
- package/dist/building/level-duplication.d.ts.map +1 -1
- package/dist/building/level-duplication.js +3 -1
- package/dist/building/wall-openings.d.ts +75 -75
- package/dist/commands/structure/shared.d.ts +3407 -3407
- package/dist/commands/structure/zone-wall-merge.d.ts +652 -652
- package/dist/hooks/spatial-grid/spatial-grid-sync.d.ts +3818 -3818
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/lib/__fixtures__/mezzanine.d.ts +2003 -2003
- package/dist/lib/absorb-wall-separators.d.ts +1032 -1032
- package/dist/lib/asset-storage.d.ts.map +1 -1
- package/dist/lib/asset-storage.js +3 -0
- package/dist/lib/floor-foundation-datum.d.ts.map +1 -1
- package/dist/lib/floor-foundation-datum.js +5 -1
- package/dist/lib/floorplan/context.d.ts +95 -0
- package/dist/lib/floorplan/context.d.ts.map +1 -0
- package/dist/lib/floorplan/context.js +155 -0
- package/dist/lib/floorplan/index.d.ts +6 -0
- package/dist/lib/floorplan/index.d.ts.map +1 -0
- package/dist/lib/floorplan/index.js +5 -0
- package/dist/lib/floorplan/marks.d.ts +71 -0
- package/dist/lib/floorplan/marks.d.ts.map +1 -0
- package/dist/lib/floorplan/marks.js +157 -0
- package/dist/lib/floorplan/plan-math.d.ts +18 -0
- package/dist/lib/floorplan/plan-math.d.ts.map +1 -0
- package/dist/lib/floorplan/plan-math.js +82 -0
- package/dist/lib/floorplan/svg-paths.d.ts +17 -0
- package/dist/lib/floorplan/svg-paths.d.ts.map +1 -0
- package/dist/lib/floorplan/svg-paths.js +92 -0
- package/dist/lib/floorplan/wall-affordances.d.ts +31 -0
- package/dist/lib/floorplan/wall-affordances.d.ts.map +1 -0
- package/dist/lib/floorplan/wall-affordances.js +24 -0
- package/dist/lib/steps.d.ts +8 -0
- package/dist/lib/steps.d.ts.map +1 -0
- package/dist/lib/steps.js +7 -0
- package/dist/registry/__fixtures__/roof-planes.d.ts +69 -0
- package/dist/registry/__fixtures__/roof-planes.d.ts.map +1 -0
- package/dist/registry/__fixtures__/roof-planes.js +59 -0
- package/dist/registry/index.d.ts +2 -1
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +1 -0
- package/dist/registry/roofs.d.ts +34 -0
- package/dist/registry/roofs.d.ts.map +1 -0
- package/dist/registry/roofs.js +61 -0
- package/dist/registry/types.d.ts +30 -0
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/registry/validate-relations.d.ts +5 -1
- package/dist/registry/validate-relations.d.ts.map +1 -1
- package/dist/registry/validate-relations.js +6 -2
- package/dist/schema/asset-url.d.ts +8 -0
- package/dist/schema/asset-url.d.ts.map +1 -1
- package/dist/schema/asset-url.js +17 -0
- package/dist/schema/nodes/roof.d.ts +1 -1
- package/dist/schema/nodes/roof.d.ts.map +1 -1
- package/dist/schema/nodes/roof.js +13 -8
- package/dist/schema/types.d.ts +1 -1
- package/dist/services/roof-level.d.ts.map +1 -1
- package/dist/services/roof-level.js +12 -2
- package/dist/services/roof-move.d.ts +4 -2
- package/dist/services/roof-move.d.ts.map +1 -1
- package/dist/services/roof-move.js +21 -9
- package/dist/spatial/usage-field/findings.d.ts +10 -1
- package/dist/spatial/usage-field/findings.d.ts.map +1 -1
- package/dist/spatial/usage-field/findings.js +56 -12
- package/dist/spatial/usage-field/measure.d.ts +3 -1
- package/dist/spatial/usage-field/measure.d.ts.map +1 -1
- package/dist/spatial/usage-field/measure.js +7 -2
- package/dist/spatial/usage-field/path.d.ts.map +1 -1
- package/dist/spatial/usage-field/path.js +28 -18
- package/dist/store/actions/node-actions.d.ts +2380 -2380
- package/dist/store/scene-annotations.d.ts +1279 -1279
- package/dist/systems/document-reconcile.d.ts.map +1 -1
- package/dist/systems/document-reconcile.js +1 -2
- package/dist/systems/roof/roof-elevation.d.ts +11 -6
- package/dist/systems/roof/roof-elevation.d.ts.map +1 -1
- package/dist/systems/roof/roof-elevation.js +24 -11
- package/dist/systems/slab/__fixtures__/floor-step.d.ts +2381 -2381
- package/dist/systems/slab/__fixtures__/raised-room.d.ts +3818 -3818
- package/dist/systems/stair/stair-opening-preview.d.ts +900 -900
- package/dist/utils/ensure-scene-openings.d.ts +4815 -4815
- package/dist/utils/floor-plate-migration.d.ts +1032 -1032
- package/dist/utils/owned-floor-opening-migration.d.ts +1032 -1032
- package/dist/utils/reconcile-structure-on-load.d.ts +2380 -2380
- package/dist/utils/scene-bounds.d.ts +32 -0
- package/dist/utils/scene-bounds.d.ts.map +1 -0
- package/dist/utils/scene-bounds.js +201 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CatalogAsset } from './catalog-asset.js';
|
|
2
2
|
import type { AgentContext, SceneNodes } from './types.js';
|
|
3
3
|
/** One search of an item library: its words (none lists the library), a category, at most `limit` hits. */
|
|
4
4
|
export type AssetSearchQuery = {
|
|
@@ -8,7 +8,7 @@ export type AssetSearchQuery = {
|
|
|
8
8
|
};
|
|
9
9
|
export type AssetSearchResult = {
|
|
10
10
|
/** The best hits first, at most the query's limit. */
|
|
11
|
-
items:
|
|
11
|
+
items: CatalogAsset[];
|
|
12
12
|
/** Every item the query matches. */
|
|
13
13
|
total: number;
|
|
14
14
|
/** The categories of every match, most first, where the host counts them: a cut search names them to narrow by. */
|
|
@@ -24,23 +24,30 @@ export type AssetSearchResult = {
|
|
|
24
24
|
*/
|
|
25
25
|
export type AssetCatalogSource = {
|
|
26
26
|
search(query: AssetSearchQuery): Promise<AssetSearchResult>;
|
|
27
|
-
byId(ids: readonly string[]): Promise<
|
|
27
|
+
byId(ids: readonly string[]): Promise<CatalogAsset[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Makes the scripted items a call is about to place renderable in the scene's project (their
|
|
30
|
+
* GLB, script and images are the library's until copied there). Throws when they cannot be.
|
|
31
|
+
*/
|
|
32
|
+
bring?(items: readonly CatalogAsset[]): Promise<void>;
|
|
28
33
|
};
|
|
29
34
|
/** What a host's agent tools place from: every item (a built-in list), or a source it searches. */
|
|
30
|
-
export type AssetCatalog = readonly
|
|
35
|
+
export type AssetCatalog = readonly CatalogAsset[] | AssetCatalogSource;
|
|
31
36
|
export declare const isAssetCatalogSource: (catalog: AssetCatalog) => catalog is AssetCatalogSource;
|
|
32
37
|
/**
|
|
33
|
-
* Items in the order search_assets lists them for `text` (`rank`)
|
|
34
|
-
*
|
|
38
|
+
* Items in the order search_assets lists them for `text` (`rank`): those the query names first (by
|
|
39
|
+
* name or category), and among them the scripted ones before plain GLBs, whatever their rank, as
|
|
40
|
+
* their params let the agent fit them to the room; then by rank. Items that rank alike keep the order they came in. A
|
|
41
|
+
* host that finds hits its own way (a database's fusion) orders them so too.
|
|
35
42
|
*/
|
|
36
|
-
export declare function rankAssets(items: readonly
|
|
43
|
+
export declare function rankAssets<T extends CatalogAsset>(items: readonly T[], text: string): T[];
|
|
37
44
|
/**
|
|
38
45
|
* A search of a list held whole: the items whose name, id, category or tags hold every word of
|
|
39
46
|
* the query, best first (`rankAssets`, then by name), with the categories of all of them.
|
|
40
47
|
*/
|
|
41
|
-
export declare function searchAssetList(items: readonly
|
|
48
|
+
export declare function searchAssetList(items: readonly CatalogAsset[], { text, category, limit }: AssetSearchQuery): AssetSearchResult;
|
|
42
49
|
/** A list served as a source: searched as `searchAssetList` does, items by id. */
|
|
43
|
-
export declare function assetCatalogSource(items: readonly
|
|
50
|
+
export declare function assetCatalogSource(items: readonly CatalogAsset[]): AssetCatalogSource;
|
|
44
51
|
/** The key of a search in `catalogSearches`: its words, category and limit. */
|
|
45
52
|
export declare const assetSearchKey: ({ text, category, limit }: AssetSearchQuery) => string;
|
|
46
53
|
/** The searches a `search_assets` input runs, one per query, as its operation reads them. */
|
|
@@ -48,16 +55,19 @@ export declare function assetSearchesOf(input: unknown): AssetSearchQuery[];
|
|
|
48
55
|
/**
|
|
49
56
|
* What a call reads of the library, alone or in a batch: the searches of `search_assets`, and the
|
|
50
57
|
* ids the others look up — the items placed or viewed, furnish_room's set for its room type, the
|
|
51
|
-
* catalog items a paint with no role finishes (their models list the surfaces).
|
|
58
|
+
* catalog items a paint with no role finishes (their models list the surfaces). `placing` is those
|
|
59
|
+
* of the ids the call may place.
|
|
52
60
|
*/
|
|
53
61
|
export declare function catalogReads(nodes: SceneNodes, tool: string, input: unknown): {
|
|
54
62
|
ids: string[];
|
|
63
|
+
placing: string[];
|
|
55
64
|
searches: AssetSearchQuery[];
|
|
56
65
|
};
|
|
57
66
|
/**
|
|
58
67
|
* What a call reads of the host's library, read before it as the operations are sync. A list is
|
|
59
68
|
* handed over whole. A source answers the call's searches (`catalogSearches`) and gives the items
|
|
60
|
-
* the call names (`catalog`), so a call that names none reads nothing
|
|
69
|
+
* the call names (`catalog`), so a call that names none reads nothing; the scripted items it may
|
|
70
|
+
* place are brought into the scene's project first (`bring`).
|
|
61
71
|
*/
|
|
62
72
|
export declare function readCatalog(nodes: SceneNodes, tool: string, input: unknown, catalog: AssetCatalog): Promise<Pick<AgentContext, 'catalog' | 'catalogSearches'>>;
|
|
63
73
|
//# sourceMappingURL=asset-catalog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-catalog.d.ts","sourceRoot":"","sources":["../../src/agent-operations/asset-catalog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"asset-catalog.d.ts","sourceRoot":"","sources":["../../src/agent-operations/asset-catalog.ts"],"names":[],"mappings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,SAAS,YAAY,EAAE,EAC9B,EAAE,IAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,gBAAgB,GAC/C,iBAAiB,CAiBnB;AAED,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,GAAG,kBAAkB,CAMrF;AAED,+EAA+E;AAC/E,eAAO,MAAM,cAAc,8BAAoC,gBAAgB,KAAG,MACjC,CAAA;AAKjD,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,EAAE,CAalE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GACb;IAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,gBAAgB,EAAE,CAAA;CAAE,CA2CpE;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,iBAAiB,CAAC,CAAC,CAiB5D"}
|
|
@@ -54,14 +54,22 @@ function rank(item, query) {
|
|
|
54
54
|
: 6);
|
|
55
55
|
return [Math.max(0, ...ranks), ranks.reduce((sum, value) => sum + value, 0)];
|
|
56
56
|
}
|
|
57
|
+
/** The weakest word rank that still says what the item is: its name's words, or its category's. */
|
|
58
|
+
const NAMED = 3;
|
|
57
59
|
/**
|
|
58
|
-
* Items in the order search_assets lists them for `text` (`rank`)
|
|
59
|
-
*
|
|
60
|
+
* Items in the order search_assets lists them for `text` (`rank`): those the query names first (by
|
|
61
|
+
* name or category), and among them the scripted ones before plain GLBs, whatever their rank, as
|
|
62
|
+
* their params let the agent fit them to the room; then by rank. Items that rank alike keep the order they came in. A
|
|
63
|
+
* host that finds hits its own way (a database's fusion) orders them so too.
|
|
60
64
|
*/
|
|
61
65
|
export function rankAssets(items, text) {
|
|
66
|
+
const tier = (item, [weakest]) => weakest > NAMED ? 2 : item.script ? 0 : 1;
|
|
62
67
|
return items
|
|
63
|
-
.map((item) =>
|
|
64
|
-
|
|
68
|
+
.map((item) => {
|
|
69
|
+
const itemRank = rank(item, text);
|
|
70
|
+
return { item, rank: itemRank, tier: tier(item, itemRank) };
|
|
71
|
+
})
|
|
72
|
+
.sort((a, b) => a.tier - b.tier || a.rank[0] - b.rank[0] || a.rank[1] - b.rank[1])
|
|
65
73
|
.map(({ item }) => item);
|
|
66
74
|
}
|
|
67
75
|
/**
|
|
@@ -115,10 +123,12 @@ export function assetSearchesOf(input) {
|
|
|
115
123
|
/**
|
|
116
124
|
* What a call reads of the library, alone or in a batch: the searches of `search_assets`, and the
|
|
117
125
|
* ids the others look up — the items placed or viewed, furnish_room's set for its room type, the
|
|
118
|
-
* catalog items a paint with no role finishes (their models list the surfaces).
|
|
126
|
+
* catalog items a paint with no role finishes (their models list the surfaces). `placing` is those
|
|
127
|
+
* of the ids the call may place.
|
|
119
128
|
*/
|
|
120
129
|
export function catalogReads(nodes, tool, input) {
|
|
121
130
|
const ids = new Set();
|
|
131
|
+
const placing = new Set();
|
|
122
132
|
const searches = [];
|
|
123
133
|
const visit = (name, args) => {
|
|
124
134
|
switch (name) {
|
|
@@ -141,15 +151,19 @@ export function catalogReads(nodes, tool, input) {
|
|
|
141
151
|
const roomType = String(args.roomType);
|
|
142
152
|
for (const id of Object.hasOwn(FURNISH_ROOM_ASSETS, roomType)
|
|
143
153
|
? FURNISH_ROOM_ASSETS[roomType]
|
|
144
|
-
: [])
|
|
154
|
+
: []) {
|
|
145
155
|
ids.add(id);
|
|
156
|
+
placing.add(id);
|
|
157
|
+
}
|
|
146
158
|
return;
|
|
147
159
|
}
|
|
148
160
|
}
|
|
149
161
|
if (typeof name !== 'string')
|
|
150
162
|
return;
|
|
151
|
-
for (const id of placedAssets(name, args))
|
|
163
|
+
for (const id of placedAssets(name, args)) {
|
|
152
164
|
ids.add(id);
|
|
165
|
+
placing.add(id);
|
|
166
|
+
}
|
|
153
167
|
for (const { targets } of roleLessPaints(name, args))
|
|
154
168
|
for (const target of targets) {
|
|
155
169
|
const node = typeof target === 'string' ? nodes[target] : undefined;
|
|
@@ -158,21 +172,25 @@ export function catalogReads(nodes, tool, input) {
|
|
|
158
172
|
}
|
|
159
173
|
};
|
|
160
174
|
visit(tool, asRecord(input));
|
|
161
|
-
return { ids: [...ids], searches };
|
|
175
|
+
return { ids: [...ids], placing: [...placing], searches };
|
|
162
176
|
}
|
|
163
177
|
/**
|
|
164
178
|
* What a call reads of the host's library, read before it as the operations are sync. A list is
|
|
165
179
|
* handed over whole. A source answers the call's searches (`catalogSearches`) and gives the items
|
|
166
|
-
* the call names (`catalog`), so a call that names none reads nothing
|
|
180
|
+
* the call names (`catalog`), so a call that names none reads nothing; the scripted items it may
|
|
181
|
+
* place are brought into the scene's project first (`bring`).
|
|
167
182
|
*/
|
|
168
183
|
export async function readCatalog(nodes, tool, input, catalog) {
|
|
169
184
|
if (!isAssetCatalogSource(catalog))
|
|
170
185
|
return { catalog };
|
|
171
|
-
const { ids, searches } = catalogReads(nodes, tool, input);
|
|
186
|
+
const { ids, placing, searches } = catalogReads(nodes, tool, input);
|
|
172
187
|
const [items, answers] = await Promise.all([
|
|
173
188
|
ids.length ? catalog.byId(ids) : [],
|
|
174
189
|
Promise.all(searches.map((query) => catalog.search(query))),
|
|
175
190
|
]);
|
|
191
|
+
const scripted = items.filter((item) => item.script && placing.includes(item.id));
|
|
192
|
+
if (scripted.length && catalog.bring)
|
|
193
|
+
await catalog.bring(scripted);
|
|
176
194
|
return {
|
|
177
195
|
catalog: items,
|
|
178
196
|
...(searches.length && {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AssetInput } from '../schema/index.js';
|
|
2
1
|
import type { AgentContext, AgentOperation, SceneNodes } from './types.js';
|
|
3
2
|
/**
|
|
4
3
|
* What a host read about one catalog item before the call, as the operations are sync: its
|
|
@@ -14,9 +13,15 @@ export type AssetViewFacts = {
|
|
|
14
13
|
type ViewAssetsInput = {
|
|
15
14
|
ids: string[];
|
|
16
15
|
};
|
|
17
|
-
/**
|
|
18
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The item a host reads: `id` keys its facts, `src` is its model, `thumbnail` its picture. An item
|
|
18
|
+
* built from a script names its `surfaces` (its manifest's slots), so its model is not read.
|
|
19
|
+
*/
|
|
20
|
+
export type AssetViewSubject = {
|
|
21
|
+
id: string;
|
|
22
|
+
src?: string;
|
|
19
23
|
thumbnail?: string;
|
|
24
|
+
surfaces?: readonly string[];
|
|
20
25
|
};
|
|
21
26
|
/**
|
|
22
27
|
* The names of a GLB's paintable surfaces (its `slot_<id>` materials, as the renderer and the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-views.d.ts","sourceRoot":"","sources":["../../src/agent-operations/asset-views.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"asset-views.d.ts","sourceRoot":"","sources":["../../src/agent-operations/asset-views.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEvE;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC5B,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,KAAK,eAAe,GAAG;IAAE,GAAG,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAExC;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC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e,CA6CtE;AAED,oGAAoG;AACpG,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,OAAO,EAAE,CAAA;CAAE,EAAE,CAarF;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,GACrC;IAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CA8BrD;AAWD;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,eAAe,CAyCtD,CAAA"}
|
|
@@ -116,7 +116,11 @@ export function createAssetViewLoader(io) {
|
|
|
116
116
|
return async (subjects, { pictures = true } = {}) => {
|
|
117
117
|
const entries = await Promise.all(subjects.map(async (subject) => {
|
|
118
118
|
const [surface, picture] = await Promise.allSettled([
|
|
119
|
-
subject.
|
|
119
|
+
subject.surfaces
|
|
120
|
+
? [...subject.surfaces]
|
|
121
|
+
: subject.src
|
|
122
|
+
? surfacesOf(subject.src)
|
|
123
|
+
: Promise.reject(new Error('it has no model')),
|
|
120
124
|
pictures && subject.thumbnail
|
|
121
125
|
? io.picture(subject.thumbnail)
|
|
122
126
|
: Promise.reject(new Error(pictures ? 'it has no picture' : 'not asked')),
|
|
@@ -165,7 +169,14 @@ export function assetViewNeeds(nodes, tool, input, context) {
|
|
|
165
169
|
if (tool === 'view_assets') {
|
|
166
170
|
const ids = input?.ids;
|
|
167
171
|
const wanted = new Set(Array.isArray(ids) ? ids : []);
|
|
168
|
-
return {
|
|
172
|
+
return {
|
|
173
|
+
subjects: catalog
|
|
174
|
+
.filter((item) => wanted.has(item.id))
|
|
175
|
+
.map(({ id, src, thumbnail, script }) => script
|
|
176
|
+
? { id, thumbnail, surfaces: script.manifest.slots.map((slot) => slot.id) }
|
|
177
|
+
: { id, src, thumbnail }),
|
|
178
|
+
pictures: true,
|
|
179
|
+
};
|
|
169
180
|
}
|
|
170
181
|
const subjects = new Map();
|
|
171
182
|
for (const { targets } of roleLessPaints(tool, input))
|
|
@@ -174,7 +185,12 @@ export function assetViewNeeds(nodes, tool, input, context) {
|
|
|
174
185
|
if (node?.type !== 'item' || !node.asset?.id)
|
|
175
186
|
continue;
|
|
176
187
|
const entry = catalog.find((item) => item.id === node.asset.id);
|
|
177
|
-
if (entry?.
|
|
188
|
+
if (entry?.script)
|
|
189
|
+
subjects.set(entry.id, {
|
|
190
|
+
id: entry.id,
|
|
191
|
+
surfaces: entry.script.manifest.slots.map((slot) => slot.id),
|
|
192
|
+
});
|
|
193
|
+
else if (entry?.src)
|
|
178
194
|
subjects.set(entry.id, { id: entry.id, src: entry.src });
|
|
179
195
|
}
|
|
180
196
|
return { subjects: [...subjects.values()], pictures: false };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { AgentOperation } from './types.js';
|
|
2
|
+
import type { AgentOperation, AgentOperationSteps } from './types.js';
|
|
3
3
|
type BatchInput = {
|
|
4
4
|
calls: {
|
|
5
5
|
tool: string;
|
|
@@ -16,7 +16,9 @@ type Contract = {
|
|
|
16
16
|
* merged into one set — one undo step, one write on either surface. The user: the model spent a
|
|
17
17
|
* round trip per step on what could be serialised (deleting balcony walls one by one, the same
|
|
18
18
|
* build on every floor). Pre-check and operation refusals follow the same per-call policy.
|
|
19
|
+
* It stops after each call, and where a call that runs in steps (`stepped`) does, so a host that
|
|
20
|
+
* can let other work run meanwhile does (`AGENT_OPERATIONS.run_batch` runs it through in one go).
|
|
19
21
|
*/
|
|
20
|
-
export declare function
|
|
22
|
+
export declare function createBatchSteps(operations: Readonly<Record<string, AgentOperation<never>>>, contracts: readonly Contract[], stepped?: Readonly<Record<string, AgentOperationSteps<never>>>): AgentOperationSteps<BatchInput>;
|
|
21
23
|
export {};
|
|
22
24
|
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/agent-operations/batch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAOvB,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/agent-operations/batch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAOvB,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAgB,MAAM,SAAS,CAAA;AAEhF,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,EAAE,CAAA;IAC1D,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAC5B,CAAA;AACD,KAAK,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;CAAE,CAAA;AA8BlE;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,EAC3D,SAAS,EAAE,SAAS,QAAQ,EAAE,EAC9B,OAAO,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAM,GACjE,mBAAmB,CAAC,UAAU,CAAC,CAqFjC"}
|
|
@@ -21,9 +21,11 @@ function prepareCall(call, index, operations, contracts) {
|
|
|
21
21
|
* merged into one set — one undo step, one write on either surface. The user: the model spent a
|
|
22
22
|
* round trip per step on what could be serialised (deleting balcony walls one by one, the same
|
|
23
23
|
* build on every floor). Pre-check and operation refusals follow the same per-call policy.
|
|
24
|
+
* It stops after each call, and where a call that runs in steps (`stepped`) does, so a host that
|
|
25
|
+
* can let other work run meanwhile does (`AGENT_OPERATIONS.run_batch` runs it through in one go).
|
|
24
26
|
*/
|
|
25
|
-
export function
|
|
26
|
-
return (nodes, { calls, onRefusal = 'stop' }, context)
|
|
27
|
+
export function createBatchSteps(operations, contracts, stepped = {}) {
|
|
28
|
+
return function* (nodes, { calls, onRefusal = 'stop' }, context) {
|
|
27
29
|
let working = nodes;
|
|
28
30
|
let workingContext = context;
|
|
29
31
|
let kept;
|
|
@@ -36,10 +38,10 @@ export function createBatchOperation(operations, contracts) {
|
|
|
36
38
|
catalog: workingContext.catalog,
|
|
37
39
|
});
|
|
38
40
|
const { operation, input } = prepareCall(call, index, operations, contracts);
|
|
39
|
-
const {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
const callContext = { ...workingContext, batchCall: index };
|
|
42
|
+
const { result, changes } = Object.hasOwn(stepped, call.tool)
|
|
43
|
+
? yield* stepped[call.tool](working, input, callContext)
|
|
44
|
+
: operation(working, input, callContext);
|
|
43
45
|
if (changes) {
|
|
44
46
|
sets.push(changes);
|
|
45
47
|
working = applySceneChanges(working, changes);
|
|
@@ -78,6 +80,7 @@ export function createBatchOperation(operations, contracts) {
|
|
|
78
80
|
error: error.message,
|
|
79
81
|
});
|
|
80
82
|
}
|
|
83
|
+
yield;
|
|
81
84
|
}
|
|
82
85
|
const applied = reports.filter((report) => report.status === 'ok').length;
|
|
83
86
|
const merged = mergeSceneChanges(sets);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AssetInput, GeometryScriptSource } from '../schema/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* A library item as the agent tools read and place it. A scripted one (a three.js recipe) carries
|
|
4
|
+
* the script it was built from: placed with it, the item keeps its params, so add_object can
|
|
5
|
+
* resize or rework it afterwards, where a plain GLB is fixed.
|
|
6
|
+
*/
|
|
7
|
+
export type CatalogAsset = AssetInput & {
|
|
8
|
+
script?: GeometryScriptSource;
|
|
9
|
+
};
|
|
10
|
+
/** The item node fields a catalog entry places as: its asset, and its script as the node's source. */
|
|
11
|
+
export declare function catalogItemFields({ script, ...asset }: CatalogAsset): {
|
|
12
|
+
asset: AssetInput;
|
|
13
|
+
source?: GeometryScriptSource;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=catalog-asset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-asset.d.ts","sourceRoot":"","sources":["../../src/agent-operations/catalog-asset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEjE;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG;IAAE,MAAM,CAAC,EAAE,oBAAoB,CAAA;CAAE,CAAA;AAEzE,sGAAsG;AACtG,wBAAgB,iBAAiB,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,GAAG;IACrE,KAAK,EAAE,UAAU,CAAA;IACjB,MAAM,CAAC,EAAE,oBAAoB,CAAA;CAC9B,CAEA"}
|